Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7cf759a760 |
+4
-1
@@ -10,9 +10,12 @@ if (CMAKE_CROSSCOMPILING)
|
||||
set(THREADS_PTHREAD_ARG
|
||||
"PLEASE_FILL_OUT-FAILED_TO_RUN"
|
||||
CACHE STRING "Result from TRY_RUN" FORCE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
||||
endif()
|
||||
|
||||
if (UNIX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
||||
endif(UNIX)
|
||||
|
||||
add_subdirectory(sdk_core sdk_core)
|
||||
add_subdirectory(sample/hub)
|
||||
add_subdirectory(sample/lidar)
|
||||
|
||||
+143
-610
@@ -3,99 +3,115 @@
|
||||
Livox-SDK
|
||||
├── CMakeLists.txt
|
||||
├── sample
|
||||
│ ├── hub
|
||||
│ │ ├── CMakeLists.txt
|
||||
│ │ └── main.c
|
||||
│ ├── hub_lvx_file
|
||||
│ │ ├── CMakeLists.txt
|
||||
│ │ ├── lvx_file.cpp
|
||||
│ │ ├── lvx_file.h
|
||||
│ │ └── main.cpp
|
||||
│ ├── lidar
|
||||
│ │ ├── CMakeLists.txt
|
||||
│ │ └── main.c
|
||||
│ └── lidar_lvx_file
|
||||
│ ├── CMakeLists.txt
|
||||
│ ├── lvx_file.cpp
|
||||
│ ├── lvx_file.h
|
||||
│ └── main.cpp
|
||||
│ ├── hub
|
||||
│ │ ├── CMakeLists.txt
|
||||
│ │ └── main.c
|
||||
│ ├── hub_lvx_file
|
||||
│ │ ├── CMakeLists.txt
|
||||
│ │ ├── lvx_file.cpp
|
||||
│ │ ├── lvx_file.h
|
||||
│ │ └── main.cpp
|
||||
│ ├── lidar
|
||||
│ │ ├── CMakeLists.txt
|
||||
│ │ └── main.c
|
||||
│ └── lidar_lvx_file
|
||||
│ ├── CMakeLists.txt
|
||||
│ ├── lvx_file.cpp
|
||||
│ ├── lvx_file.h
|
||||
│ └── main.cpp
|
||||
├── sample_cc
|
||||
│ ├── hub
|
||||
│ │ ├── CMakeLists.txt
|
||||
│ │ ├── lds_hub.cpp
|
||||
│ │ ├── lds_hub.h
|
||||
│ │ └── main.cpp
|
||||
│ ├── lidar
|
||||
│ │ ├── CMakeLists.txt
|
||||
│ │ ├── lds_lidar.cpp
|
||||
│ │ ├── lds_lidar.h
|
||||
│ │ └── main.cpp
|
||||
│ ├── lidar_utc_sync
|
||||
│ │ ├── CMakeLists.txt
|
||||
│ │ ├── lds_lidar.cpp
|
||||
│ │ ├── lds_lidar.h
|
||||
│ │ ├── main.cpp
|
||||
│ │ ├── synchro.cpp
|
||||
│ │ └── synchro.h
|
||||
│ └── trouble_shooting
|
||||
│ ├── CMakeLists.txt
|
||||
│ └── main.cpp
|
||||
├── sdk_core
|
||||
│ ├── CMakeLists.txt
|
||||
│ ├── include
|
||||
│ │ ├── comm
|
||||
│ │ │ ├── comm_port.h
|
||||
│ │ │ └── protocol.h
|
||||
│ │ ├── livox_def.h
|
||||
│ │ └── livox_sdk.h
|
||||
│ └── src
|
||||
│ ├── base
|
||||
│ │ ├── command_callback.h
|
||||
│ │ ├── io_loop.cpp
|
||||
│ │ ├── io_loop.h
|
||||
│ │ ├── io_thread.cpp
|
||||
│ │ ├── io_thread.h
|
||||
│ │ ├── logging.cpp
|
||||
│ │ ├── logging.h
|
||||
│ │ ├── network_util.cpp
|
||||
│ │ ├── network_util.h
|
||||
│ │ ├── noncopyable.h
|
||||
│ │ ├── thread_base.cpp
|
||||
│ │ ├── thread_base.h
|
||||
│ │ ├── util.cpp
|
||||
│ │ └── util.h
|
||||
│ ├── comm
|
||||
│ │ ├── comm_port.cpp
|
||||
│ │ ├── sdk_protocol.cpp
|
||||
│ │ └── sdk_protocol.h
|
||||
│ ├── command_handler
|
||||
│ │ ├── command_channel.cpp
|
||||
│ │ ├── command_channel.h
|
||||
│ │ ├── command_handler.cpp
|
||||
│ │ ├── command_handler.h
|
||||
│ │ ├── command_impl.cpp
|
||||
│ │ ├── command_impl.h
|
||||
│ │ ├── hub_command_handler.cpp
|
||||
│ │ ├── hub_command_handler.h
|
||||
│ │ ├── lidar_command_handler.cpp
|
||||
│ │ └── lidar_command_handler.h
|
||||
│ ├── data_handler
|
||||
│ │ ├── data_handler.cpp
|
||||
│ │ ├── data_handler.h
|
||||
│ │ ├── hub_data_handler.cpp
|
||||
│ │ ├── hub_data_handler.h
|
||||
│ │ ├── lidar_data_handler.cpp
|
||||
│ │ └── lidar_data_handler.h
|
||||
│ ├── device_discovery.cpp
|
||||
│ ├── device_discovery.h
|
||||
│ ├── device_manager.cpp
|
||||
│ ├── device_manager.h
|
||||
│ └── livox_sdk.cpp
|
||||
└── third_party
|
||||
└── apr
|
||||
├── apr_build.bat
|
||||
├── apr_build.sh
|
||||
└── apr_cross_build.sh
|
||||
│ ├── hub
|
||||
│ │ ├── CMakeLists.txt
|
||||
│ │ ├── lds_hub.cpp
|
||||
│ │ ├── lds_hub.h
|
||||
│ │ └── main.cpp
|
||||
│ ├── lidar
|
||||
│ │ ├── CMakeLists.txt
|
||||
│ │ ├── lds_lidar.cpp
|
||||
│ │ ├── lds_lidar.h
|
||||
│ │ └── main.cpp
|
||||
│ ├── lidar_utc_sync
|
||||
│ │ ├── CMakeLists.txt
|
||||
│ │ ├── lds_lidar.cpp
|
||||
│ │ ├── lds_lidar.h
|
||||
│ │ ├── main.cpp
|
||||
│ │ ├── synchro.cpp
|
||||
│ │ └── synchro.h
|
||||
│ └── trouble_shooting
|
||||
│ ├── CMakeLists.txt
|
||||
│ └── main.cpp
|
||||
└── sdk_core
|
||||
├── CMakeLists.txt
|
||||
├── include
|
||||
│ ├── comm
|
||||
│ │ ├── comm_port.h
|
||||
│ │ └── protocol.h
|
||||
│ ├── config.h
|
||||
│ ├── livox_def.h
|
||||
│ └─ livox_sdk.h
|
||||
└── src
|
||||
├── base
|
||||
│ ├── command_callback.h
|
||||
│ ├── io_loop.cpp
|
||||
│ ├── io_loop.h
|
||||
│ ├── io_thread.cpp
|
||||
│ ├── io_thread.h
|
||||
│ ├── logging.cpp
|
||||
│ ├── logging.h
|
||||
│ ├── multiple_io
|
||||
│ │ ├── multiple_io_base.cpp
|
||||
│ │ ├── multiple_io_base.h
|
||||
│ │ ├── multiple_io_epoll.cpp
|
||||
│ │ ├── multiple_io_epoll.h
|
||||
│ │ ├── multiple_io_factory.h
|
||||
│ │ ├── multiple_io_kqueue.cpp
|
||||
│ │ ├── multiple_io_kqueue.h
|
||||
│ │ ├── multiple_io_poll.cpp
|
||||
│ │ ├── multiple_io_poll.h
|
||||
│ │ ├── multiple_io_select.cpp
|
||||
│ │ └── multiple_io_select.h
|
||||
│ ├── network
|
||||
│ │ ├── network_util.h
|
||||
│ │ ├── unix
|
||||
│ │ │ └── network_util.cpp
|
||||
│ │ └── win
|
||||
│ │ └── network_util.cpp
|
||||
│ ├── noncopyable.h
|
||||
│ ├── thread_base.cpp
|
||||
│ ├── thread_base.h
|
||||
│ └── wake_up
|
||||
│ ├── unix
|
||||
│ │ └── wake_up_pipe.cpp
|
||||
│ ├── wake_up_pipe.h
|
||||
│ └── win
|
||||
│ └── wake_up_pipe.cpp
|
||||
├── comm
|
||||
│ ├── comm_port.cpp
|
||||
│ ├── sdk_protocol.cpp
|
||||
│ └── sdk_protocol.h
|
||||
├── command_handler
|
||||
│ ├── command_channel.cpp
|
||||
│ ├── command_channel.h
|
||||
│ ├── command_handler.cpp
|
||||
│ ├── command_handler.h
|
||||
│ ├── command_impl.cpp
|
||||
│ ├── command_impl.h
|
||||
│ ├── hub_command_handler.cpp
|
||||
│ ├── hub_command_handler.h
|
||||
│ ├── lidar_command_handler.cpp
|
||||
│ └── lidar_command_handler.h
|
||||
├── data_handler
|
||||
│ ├── data_handler.cpp
|
||||
│ ├── data_handler.h
|
||||
│ ├── hub_data_handler.cpp
|
||||
│ ├── hub_data_handler.h
|
||||
│ ├── lidar_data_handler.cpp
|
||||
│ └── lidar_data_handler.h
|
||||
├── device_discovery.cpp
|
||||
├── device_discovery.h
|
||||
├── device_manager.cpp
|
||||
├── device_manager.h
|
||||
└── livox_sdk.cpp
|
||||
|
||||
-------------------------------------------------------------
|
||||
The MIT License (MIT)
|
||||
@@ -120,524 +136,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
===============================================================
|
||||
LIVOX’s Livox SDK uses unmodified libraries of Apache Portable Runtime Library (APR)(https://github.com/apache/apr), which is licensed under Apache license. A copy of the Apache license is provided below and is also available at https://raw.githubusercontent.com/apache/apr/trunk/LICENSE.
|
||||
|
||||
-------------------------------------------------------------
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
|
||||
|
||||
APACHE PORTABLE RUNTIME SUBCOMPONENTS:
|
||||
|
||||
The Apache Portable Runtime includes a number of subcomponents with
|
||||
separate copyright notices and license terms. Your use of the source
|
||||
code for these subcomponents is subject to the terms and conditions
|
||||
of the following licenses.
|
||||
|
||||
From strings/apr_fnmatch.c, include/apr_fnmatch.h, misc/unix/getopt.c,
|
||||
file_io/unix/mktemp.c, strings/apr_strings.c:
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
|
||||
From network_io/unix/inet_ntop.c, network_io/unix/inet_pton.c:
|
||||
|
||||
/* Copyright (c) 1996 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
|
||||
From dso/aix/dso.c:
|
||||
|
||||
* Based on libdl (dlfcn.c/dlfcn.h) which is
|
||||
* Copyright (c) 1992,1993,1995,1996,1997,1988
|
||||
* Jens-Uwe Mager, Helios Software GmbH, Hannover, Germany.
|
||||
*
|
||||
* Not derived from licensed software.
|
||||
*
|
||||
* Permission is granted to freely use, copy, modify, and redistribute
|
||||
* this software, provided that the author is not construed to be liable
|
||||
* for any results of using the software, alterations are clearly marked
|
||||
* as such, and this notice is not modified.
|
||||
|
||||
From strings/apr_strnatcmp.c, include/apr_strings.h:
|
||||
|
||||
strnatcmp.c -- Perform 'natural order' comparisons of strings in C.
|
||||
Copyright (C) 2000 by Martin Pool <mbp@humbug.org.au>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
From strings/apr_snprintf.c:
|
||||
|
||||
*
|
||||
* cvt - IEEE floating point formatting routines.
|
||||
* Derived from UNIX V7, Copyright(C) Caldera International Inc.
|
||||
*
|
||||
|
||||
Copyright(C) Caldera International Inc. 2001-2002. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
Redistributions of source code and documentation must retain the above
|
||||
copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed or owned by Caldera
|
||||
International, Inc.
|
||||
|
||||
Neither the name of Caldera International, Inc. nor the names of other
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
|
||||
INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
For the include\apr_md5.h component:
|
||||
|
||||
* This is work is derived from material Copyright RSA Data Security, Inc.
|
||||
*
|
||||
* The RSA copyright statement and Licence for that original material is
|
||||
* included below. This is followed by the Apache copyright statement and
|
||||
* licence for the modifications made to that material.
|
||||
|
||||
Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
|
||||
rights reserved.
|
||||
|
||||
License to copy and use this software is granted provided that it
|
||||
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
|
||||
Algorithm" in all material mentioning or referencing this software
|
||||
or this function.
|
||||
|
||||
License is also granted to make and use derivative works provided
|
||||
that such works are identified as "derived from the RSA Data
|
||||
Security, Inc. MD5 Message-Digest Algorithm" in all material
|
||||
mentioning or referencing the derived work.
|
||||
|
||||
RSA Data Security, Inc. makes no representations concerning either
|
||||
the merchantability of this software or the suitability of this
|
||||
software for any particular purpose. It is provided "as is"
|
||||
without express or implied warranty of any kind.
|
||||
|
||||
These notices must be retained in any copies of any part of this
|
||||
documentation and/or software.
|
||||
|
||||
For the passwd\apr_md5.c component:
|
||||
|
||||
* This is work is derived from material Copyright RSA Data Security, Inc.
|
||||
*
|
||||
* The RSA copyright statement and Licence for that original material is
|
||||
* included below. This is followed by the Apache copyright statement and
|
||||
* licence for the modifications made to that material.
|
||||
|
||||
Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
|
||||
rights reserved.
|
||||
|
||||
License to copy and use this software is granted provided that it
|
||||
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
|
||||
Algorithm" in all material mentioning or referencing this software
|
||||
or this function.
|
||||
|
||||
License is also granted to make and use derivative works provided
|
||||
that such works are identified as "derived from the RSA Data
|
||||
Security, Inc. MD5 Message-Digest Algorithm" in all material
|
||||
mentioning or referencing the derived work.
|
||||
|
||||
RSA Data Security, Inc. makes no representations concerning either
|
||||
the merchantability of this software or the suitability of this
|
||||
software for any particular purpose. It is provided "as is"
|
||||
without express or implied warranty of any kind.
|
||||
|
||||
These notices must be retained in any copies of any part of this
|
||||
documentation and/or software.
|
||||
|
||||
* The apr_md5_encode() routine uses much code obtained from the FreeBSD 3.0
|
||||
* MD5 crypt() function, which is licenced as follows:
|
||||
* ----------------------------------------------------------------------------
|
||||
* "THE BEER-WARE LICENSE" (Revision 42):
|
||||
* <phk@login.dknet.dk> wrote this file. As long as you retain this notice you
|
||||
* can do whatever you want with this stuff. If we meet some day, and you think
|
||||
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
||||
* ----------------------------------------------------------------------------
|
||||
|
||||
For the crypto\apr_md4.c component:
|
||||
|
||||
* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
|
||||
* rights reserved.
|
||||
*
|
||||
* License to copy and use this software is granted provided that it
|
||||
* is identified as the "RSA Data Security, Inc. MD4 Message-Digest
|
||||
* Algorithm" in all material mentioning or referencing this software
|
||||
* or this function.
|
||||
*
|
||||
* License is also granted to make and use derivative works provided
|
||||
* that such works are identified as "derived from the RSA Data
|
||||
* Security, Inc. MD4 Message-Digest Algorithm" in all material
|
||||
* mentioning or referencing the derived work.
|
||||
*
|
||||
* RSA Data Security, Inc. makes no representations concerning either
|
||||
* the merchantability of this software or the suitability of this
|
||||
* software for any particular purpose. It is provided "as is"
|
||||
* without express or implied warranty of any kind.
|
||||
*
|
||||
* These notices must be retained in any copies of any part of this
|
||||
* documentation and/or software.
|
||||
|
||||
For the crypto\crypt_blowfish.c(.h) component:
|
||||
|
||||
* Written by Solar Designer <solar at openwall.com> in 1998-2011.
|
||||
* No copyright is claimed, and the software is hereby placed in the public
|
||||
* domain. In case this attempt to disclaim copyright and place the software
|
||||
* in the public domain is deemed null and void, then the software is
|
||||
* Copyright (c) 1998-2011 Solar Designer and it is hereby released to the
|
||||
* general public under the following terms:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted.
|
||||
*
|
||||
* There's ABSOLUTELY NO WARRANTY, express or implied.
|
||||
|
||||
See crypto/crypt_blowfish.c for more information.
|
||||
|
||||
For the include\apr_md4.h component:
|
||||
|
||||
* This is derived from material copyright RSA Data Security, Inc.
|
||||
* Their notice is reproduced below in its entirety.
|
||||
*
|
||||
* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
|
||||
* rights reserved.
|
||||
*
|
||||
* License to copy and use this software is granted provided that it
|
||||
* is identified as the "RSA Data Security, Inc. MD4 Message-Digest
|
||||
* Algorithm" in all material mentioning or referencing this software
|
||||
* or this function.
|
||||
*
|
||||
* License is also granted to make and use derivative works provided
|
||||
* that such works are identified as "derived from the RSA Data
|
||||
* Security, Inc. MD4 Message-Digest Algorithm" in all material
|
||||
* mentioning or referencing the derived work.
|
||||
*
|
||||
* RSA Data Security, Inc. makes no representations concerning either
|
||||
* the merchantability of this software or the suitability of this
|
||||
* software for any particular purpose. It is provided "as is"
|
||||
* without express or implied warranty of any kind.
|
||||
*
|
||||
* These notices must be retained in any copies of any part of this
|
||||
* documentation and/or software.
|
||||
|
||||
For the test\testmd4.c component:
|
||||
|
||||
* This is derived from material copyright RSA Data Security, Inc.
|
||||
* Their notice is reproduced below in its entirety.
|
||||
*
|
||||
* Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All
|
||||
* rights reserved.
|
||||
*
|
||||
* RSA Data Security, Inc. makes no representations concerning either
|
||||
* the merchantability of this software or the suitability of this
|
||||
* software for any particular purpose. It is provided "as is"
|
||||
* without express or implied warranty of any kind.
|
||||
*
|
||||
* These notices must be retained in any copies of any part of this
|
||||
* documentation and/or software.
|
||||
===============================================================
|
||||
LIVOX’s Livox SDK uses unmodified libraries of Boost (https://www.boost.org), which is licensed under the Boost Software license. A copy of the Boost Software license is provided below and is also available at https://www.boost.org/LICENSE_1_0.txt.
|
||||
|
||||
-------------------------------------------------------------
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
===============================================================
|
||||
FastCRC
|
||||
└── sdk_core
|
||||
├── include
|
||||
@@ -790,3 +288,38 @@ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
IN THE SOFTWARE.
|
||||
|
||||
===============================================================
|
||||
LIVOX’s Livox SDK uses modified libraries of cmdline (https://github.com/tanakh/cmdline). A copy of license is provided below and is also available at https://github.com/tanakh/cmdline/blob/master/LICENSE.
|
||||
|
||||
-------------------------------------------------------------
|
||||
Copyright (c) 2009, Hideyuki Tanaka
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
* Neither the name of Hideyuki Tanaka nor the names of other
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
@@ -8,7 +8,7 @@ Livox SDK consists of Livox SDK communication protocol, Livox SDK core, Livox SD
|
||||
|
||||
## Prerequisites
|
||||
* Ubuntu 14.04/Ubuntu 16.04/Ubuntu 18.04, both x86 and ARM (Nvidia TX2)
|
||||
* Windows 7/10, Visual Studio 2015 Update3/2017
|
||||
* Windows 7/10, Visual Studio 2015 Update3/2017/2019
|
||||
* C++11 compiler
|
||||
|
||||
# 2 Livox SDK Communication Protocol
|
||||
@@ -35,7 +35,7 @@ The installation procedures in Ubuntu 18.04/16.04/14.04 LTS and Windows 7/10 are
|
||||
#### Dependencies
|
||||
Livox SDK requires [CMake 3.0.0+](https://cmake.org/) as dependencies. You can install these packages using apt:
|
||||
```
|
||||
sudo apt install cmake pkg-config
|
||||
sudo apt install cmake
|
||||
```
|
||||
#### Compile Livox SDK
|
||||
|
||||
@@ -43,22 +43,6 @@ In the Livox SDK directory, run the following commands to compile the project:
|
||||
```
|
||||
git clone https://github.com/Livox-SDK/Livox-SDK.git
|
||||
cd Livox-SDK
|
||||
```
|
||||
Install apr library by:
|
||||
|
||||
```
|
||||
sudo ./third_party/apr/apr_build.sh
|
||||
```
|
||||
|
||||
or by:
|
||||
|
||||
```
|
||||
sudo apt install libapr1-dev
|
||||
```
|
||||
|
||||
then
|
||||
|
||||
```
|
||||
cd build && cmake ..
|
||||
make
|
||||
sudo make install
|
||||
@@ -67,24 +51,39 @@ sudo make install
|
||||
### 4.1.2 Windows 7/10
|
||||
|
||||
#### Dependencies
|
||||
Livox SDK supports Visual Studio 2015 Update3/2017 and requires install [CMake 3.0.0+](https://cmake.org/) as dependencies.
|
||||
Livox SDK supports Visual Studio 2015 Update3/2017/2019 and requires install [CMake 3.0.0+](https://cmake.org/) as dependencies.
|
||||
|
||||
In the Livox SDK directory, run the following commands to create the Visual Studio solution file.
|
||||
Generate the 32-bit project:
|
||||
|
||||
```
|
||||
cd Livox-SDK
|
||||
.\third_party\apr\apr_build.bat
|
||||
cd build && \
|
||||
cd Livox-SDK/build
|
||||
```
|
||||
For Viusal Studio 2015 Update3/2017:
|
||||
```
|
||||
cmake ..
|
||||
```
|
||||
For Viusal Studio 2019:
|
||||
```
|
||||
cmake .. -G "Visual Studio 16 2019" -A Win32
|
||||
```
|
||||
Generate the 64-bit project:
|
||||
```
|
||||
cd Livox-SDK
|
||||
.\third_party\apr\apr_build.bat amd64
|
||||
cd build && \
|
||||
cd Livox-SDK/build
|
||||
```
|
||||
For Viusal Studio 2015 Update3:
|
||||
```
|
||||
cmake .. -G "Visual Studio 14 2015 Win64"
|
||||
```
|
||||
For Viusal Studio 2017:
|
||||
```
|
||||
cmake .. -G "Visual Studio 15 2017 Win64"
|
||||
```
|
||||
For Viusal Studio 2019:
|
||||
```
|
||||
cmake .. -G "Visual Studio 16 2019" -A x64
|
||||
```
|
||||
|
||||
#### Compile Livox SDK
|
||||
You can now compile the Livox SDK in Visual Studio.
|
||||
|
||||
@@ -94,10 +93,10 @@ The procedure of cross compile Livox-SDK in ARM-Linux are shown below.
|
||||
|
||||
#### Dependencies
|
||||
|
||||
Host machine requires install cmake and gcc. You can install these packages using apt:
|
||||
Host machine requires install cmake. You can install these packages using apt:
|
||||
|
||||
```
|
||||
sudo apt install cmake gcc
|
||||
sudo apt install cmake
|
||||
```
|
||||
|
||||
#### Cross Compile Toolchain
|
||||
@@ -187,8 +186,8 @@ We provide the following program options for connecting the specific units and s
|
||||
```
|
||||
Here is the example:
|
||||
```
|
||||
./lidar_sample -c "00000000000002&00000000000003&00000000000004" -l
|
||||
./hub_sample -c "00000000000001" -l
|
||||
./lidar_sample_cc -c "00000000000002&00000000000003&00000000000004" -l
|
||||
./hub_sample_cc -c "00000000000001" -l
|
||||
```
|
||||
|
||||
#### 4.3.2 Edit Broadcast Code List
|
||||
|
||||
+30
-31
@@ -7,7 +7,7 @@ Livox SDK 包括了 Livox SDK 通信协议,Livox SDK 内核,Livox SDK 应用
|
||||
|
||||
## 前置依赖
|
||||
* Ubuntu 14.04/Ubuntu 16.04/Ubuntu 18.04, x86 和 ARM (Nvidia TX2)
|
||||
* Windows 7/10, Visual Studio 2015 Update3/2017
|
||||
* Windows 7/10, Visual Studio 2015 Update3/2017/2019
|
||||
* C++11 编译器
|
||||
|
||||
# 2 Livox SDK 通信协议
|
||||
@@ -34,7 +34,7 @@ Livox SDK 应用接口提供了一系列 C 风格的接口,可以很方便地
|
||||
#### 依赖
|
||||
Livox SDK 依赖于 cmake 。你可以通过 apt 工具安装这些依赖包 :
|
||||
```
|
||||
sudo apt install cmake pkg-config
|
||||
sudo apt install cmake
|
||||
```
|
||||
#### 编译 Livox SDK
|
||||
|
||||
@@ -42,24 +42,6 @@ sudo apt install cmake pkg-config
|
||||
```
|
||||
git clone https://github.com/Livox-SDK/Livox-SDK.git
|
||||
cd Livox-SDK
|
||||
|
||||
|
||||
```
|
||||
安装 apr 库通过:
|
||||
|
||||
```
|
||||
sudo ./third_party/apr/apr_build.sh
|
||||
```
|
||||
|
||||
或者通过:
|
||||
|
||||
```
|
||||
sudo apt install libapr1-dev
|
||||
```
|
||||
|
||||
然后:
|
||||
|
||||
```
|
||||
cd build && cmake ..
|
||||
make
|
||||
sudo make install
|
||||
@@ -68,23 +50,40 @@ sudo make install
|
||||
### 4.1.2 Windows 7/10
|
||||
|
||||
#### 依赖
|
||||
Livox SDK 支持 Visual Studio 2015 Update3/2017,需要安装 [CMake 3.0.0+](https://cmake.org/) 依赖。
|
||||
Livox SDK 支持 Visual Studio 2015 Update3/2017/2019,需要安装 [CMake 3.0.0+](https://cmake.org/) 依赖。
|
||||
|
||||
在 Livox SDK 目录中,执行以下指令生成 Visual Studio solution 文件。
|
||||
生成 32-bit 工程:
|
||||
|
||||
```
|
||||
cd Livox-SDK
|
||||
.\third_party\apr\apr_build.bat
|
||||
cd build && cmake ..
|
||||
cd Livox-SDK/build
|
||||
```
|
||||
|
||||
对于 Viusal Studio 2015 Update3/2017:
|
||||
|
||||
```
|
||||
cmake ..
|
||||
```
|
||||
对于 Viusal Studio 2019:
|
||||
```
|
||||
cmake .. -G "Visual Studio 16 2019" -A Win32
|
||||
```
|
||||
生成 64-bit 工程:
|
||||
```
|
||||
cd Livox-SDK
|
||||
.\third_party\apr\apr_build.bat amd64
|
||||
cd build && \
|
||||
cd Livox-SDK/build
|
||||
```
|
||||
对于 Viusal Studio 2015 Update3:
|
||||
```
|
||||
cmake .. -G "Visual Studio 14 2015 Win64"
|
||||
```
|
||||
对于 Viusal Studio 2017:
|
||||
```
|
||||
cmake .. -G "Visual Studio 15 2017 Win64"
|
||||
```
|
||||
对于 Viusal Studio 2019:
|
||||
```
|
||||
cmake .. -G "Visual Studio 16 2019" -A x64
|
||||
```
|
||||
#### 编译 Livox SDK
|
||||
然后就可以在 Visual Studio 中编译 Livox SDK 。
|
||||
|
||||
@@ -94,10 +93,10 @@ cmake .. -G "Visual Studio 15 2017 Win64"
|
||||
|
||||
#### 依赖
|
||||
|
||||
交叉编译需要在主机安装 cmake 和 gcc。 你可以通过 apt 工具安装这些依赖包 :
|
||||
交叉编译需要在主机安装 cmake。 你可以通过 apt 工具安装这些依赖包 :
|
||||
|
||||
```
|
||||
sudo apt install cmake gcc
|
||||
sudo apt install cmake
|
||||
```
|
||||
|
||||
#### 交叉编译工具链
|
||||
@@ -188,8 +187,8 @@ cd sample/hub && ./hub_sample
|
||||
```
|
||||
这里是示例 :
|
||||
```
|
||||
./lidar_sample -c "00000000000002&00000000000003&00000000000004" -l
|
||||
./hub_sample -c "00000000000001" -l
|
||||
./lidar_sample_cc -c "00000000000002&00000000000003&00000000000004" -l
|
||||
./hub_sample_cc -c "00000000000001" -l
|
||||
```
|
||||
|
||||
#### 4.3.2 编辑广播码
|
||||
|
||||
@@ -3,13 +3,6 @@ cmake_minimum_required(VERSION 3.0)
|
||||
set(DEMO_NAME hub_sample)
|
||||
add_executable(${DEMO_NAME} main.c)
|
||||
|
||||
if (WIN32)
|
||||
add_custom_command(TARGET ${DEMO_NAME} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${PROJECT_SOURCE_DIR}/third_party/apr/bin/libapr-1.dll"
|
||||
$<TARGET_FILE_DIR:${DEMO_NAME}>)
|
||||
endif()
|
||||
|
||||
target_link_libraries(${DEMO_NAME}
|
||||
PRIVATE
|
||||
${PROJECT_NAME}_static
|
||||
|
||||
@@ -30,8 +30,6 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <apr_general.h>
|
||||
#include <apr_getopt.h>
|
||||
#include "livox_sdk.h"
|
||||
|
||||
typedef enum {
|
||||
@@ -249,77 +247,7 @@ void OnDeviceBroadcast(const BroadcastDeviceInfo *info) {
|
||||
}
|
||||
}
|
||||
|
||||
/** Set the program options.
|
||||
* You can input the registered device broadcast code and decide whether to save the log file.
|
||||
*/
|
||||
int SetProgramOption(int argc, const char *argv[]) {
|
||||
apr_status_t rv;
|
||||
apr_pool_t *mp = NULL;
|
||||
static const apr_getopt_option_t opt_option[] = {
|
||||
/** Long-option, short-option, has-arg flag, description */
|
||||
{ "code", 'c', 1, "Register device broadcast code" },
|
||||
{ "log", 'l', 0, "Save the log file" },
|
||||
{ "help", 'h', 0, "Show help" },
|
||||
{ NULL, 0, 0, NULL },
|
||||
};
|
||||
apr_getopt_t *opt = NULL;
|
||||
int optch = 0;
|
||||
const char *optarg = NULL;
|
||||
|
||||
if (apr_initialize() != APR_SUCCESS) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (apr_pool_create(&mp, NULL) != APR_SUCCESS) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
rv = apr_getopt_init(&opt, mp, argc, argv);
|
||||
if (rv != APR_SUCCESS) {
|
||||
printf("Program options initialization failed.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/** Parse the all options based on opt_option[] */
|
||||
bool is_help = false;
|
||||
while ((rv = apr_getopt_long(opt, opt_option, &optch, &optarg)) == APR_SUCCESS) {
|
||||
switch (optch) {
|
||||
case 'c':
|
||||
printf("Register broadcast code: %s\n", optarg);
|
||||
is_connect_all_broadcast_device = false;
|
||||
strncpy(broadcast_code_list[0], optarg, kBroadcastCodeSize);
|
||||
break;
|
||||
case 'l':
|
||||
printf("Save the log file.\n");
|
||||
SaveLoggerFile();
|
||||
break;
|
||||
case 'h':
|
||||
printf(
|
||||
" [-c] Register device broadcast code\n"
|
||||
" [-l] Save the log file\n"
|
||||
" [-h] Show help\n"
|
||||
);
|
||||
is_help = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (rv != APR_EOF) {
|
||||
printf("Invalid options.\n");
|
||||
}
|
||||
|
||||
apr_pool_destroy(mp);
|
||||
mp = NULL;
|
||||
apr_terminate();
|
||||
if (is_help)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
/** Set the program options. */
|
||||
if (SetProgramOption(argc, argv))
|
||||
return 0;
|
||||
|
||||
printf("Livox SDK initializing.\n");
|
||||
/** Initialize Livox-SDK. */
|
||||
if (!Init()) {
|
||||
|
||||
@@ -3,13 +3,6 @@ cmake_minimum_required(VERSION 3.0)
|
||||
set(DEMO_NAME hub_lvx_sample)
|
||||
add_executable(${DEMO_NAME} main.cpp lvx_file.cpp)
|
||||
|
||||
if (WIN32)
|
||||
add_custom_command(TARGET ${DEMO_NAME} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${PROJECT_SOURCE_DIR}/third_party/apr/bin/libapr-1.dll"
|
||||
$<TARGET_FILE_DIR:${DEMO_NAME}>)
|
||||
endif()
|
||||
|
||||
target_link_libraries(${DEMO_NAME}
|
||||
PRIVATE
|
||||
${PROJECT_NAME}_static
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <time.h>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include "lvx_file.h"
|
||||
|
||||
#define WRITE_BUFFER_LEN 1024 * 1024
|
||||
|
||||
@@ -22,9 +22,6 @@
|
||||
// SOFTWARE.
|
||||
//
|
||||
|
||||
#include <apr_thread_cond.h>
|
||||
#include <apr_thread_mutex.h>
|
||||
#include <apr_thread_proc.h>
|
||||
#include <condition_variable>
|
||||
#include <memory>
|
||||
#include <fstream>
|
||||
|
||||
@@ -22,16 +22,12 @@
|
||||
// SOFTWARE.
|
||||
//
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <apr_general.h>
|
||||
#include <apr_getopt.h>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
#include <string.h>
|
||||
#include <algorithm>
|
||||
#include "lvx_file.h"
|
||||
#include "cmdline.h"
|
||||
|
||||
DeviceItem devices[kMaxLidarCount];
|
||||
LvxFileHandle lvx_file_handler;
|
||||
@@ -262,7 +258,7 @@ void OnDeviceBroadcast(const BroadcastDeviceInfo *info) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool result = false;
|
||||
livox_status result = kStatusFailure;
|
||||
uint8_t handle = 0;
|
||||
result = AddHubToConnect(info->broadcast_code, &handle);
|
||||
if (result == kStatusSuccess) {
|
||||
@@ -275,81 +271,33 @@ void OnDeviceBroadcast(const BroadcastDeviceInfo *info) {
|
||||
/** Set the program options.
|
||||
* You can input the registered device broadcast code and decide whether to save the log file.
|
||||
*/
|
||||
int SetProgramOption(int argc, const char *argv[]) {
|
||||
apr_status_t rv;
|
||||
apr_pool_t *mp = nullptr;
|
||||
static const apr_getopt_option_t opt_option[] = {
|
||||
/** Long-option, short-option, has-arg flag, description */
|
||||
{ "code", 'c', 1, "Register device broadcast code" },
|
||||
{ "log", 'l', 0, "Save the log file" },
|
||||
{ "time", 't', 1, "Time to save point cloud to the lvx file" },
|
||||
{ "help", 'h', 0, "Show help" },
|
||||
{ nullptr, 0, 0, nullptr },
|
||||
};
|
||||
apr_getopt_t *opt = nullptr;
|
||||
int optch = 0;
|
||||
const char *optarg = nullptr;
|
||||
|
||||
if (apr_initialize() != APR_SUCCESS) {
|
||||
return -1;
|
||||
void SetProgramOption(int argc, const char *argv[]) {
|
||||
cmdline::parser cmd;
|
||||
cmd.add<std::string>("code", 'c', "Register device broadcast code", false);
|
||||
cmd.add("log", 'l', "Save the log file");
|
||||
cmd.add<int>("time", 't', "Time to save point cloud to the lvx file", false);
|
||||
cmd.add("help", 'h', "Show help");
|
||||
cmd.parse_check(argc, const_cast<char **>(argv));
|
||||
if (cmd.exist("code")) {
|
||||
std::string sn_list = cmd.get<std::string>("code");
|
||||
printf("Register broadcast code: %s\n", sn_list.c_str());
|
||||
broadcast_code_list.clear();
|
||||
broadcast_code_list.push_back(sn_list);
|
||||
}
|
||||
|
||||
if (apr_pool_create(&mp, NULL) != APR_SUCCESS) {
|
||||
return -1;
|
||||
if (cmd.exist("log")) {
|
||||
printf("Save the log file.\n");
|
||||
SaveLoggerFile();
|
||||
}
|
||||
|
||||
rv = apr_getopt_init(&opt, mp, argc, argv);
|
||||
if (rv != APR_SUCCESS) {
|
||||
printf("Program options initialization failed.\n");
|
||||
return -1;
|
||||
if (cmd.exist("time")) {
|
||||
printf("Time to save point cloud to the lvx file:%d.\n", cmd.get<int>("time"));
|
||||
lvx_file_save_time = cmd.get<int>("time");
|
||||
}
|
||||
|
||||
/** Parse the all options based on opt_option[] */
|
||||
bool is_help = false;
|
||||
while ((rv = apr_getopt_long(opt, opt_option, &optch, &optarg)) == APR_SUCCESS) {
|
||||
switch (optch) {
|
||||
case 'c': {
|
||||
printf("Register broadcast code: %s\n", optarg);
|
||||
broadcast_code_list.push_back(optarg);
|
||||
break;
|
||||
}
|
||||
case 'l': {
|
||||
printf("Save the log file.\n");
|
||||
SaveLoggerFile();
|
||||
break;
|
||||
}
|
||||
case 't': {
|
||||
printf("Time to save point cloud to the lvx file:%s.\n", optarg);
|
||||
lvx_file_save_time = atoi(optarg);
|
||||
break;
|
||||
}
|
||||
case 'h': {
|
||||
printf(
|
||||
" [-c] Register device broadcast code\n"
|
||||
" [-l] Save the log file\n"
|
||||
" [-t] Time to save point cloud to the lvx file\n"
|
||||
" [-h] Show help\n"
|
||||
);
|
||||
is_help = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (rv != APR_EOF) {
|
||||
printf("Invalid options.\n");
|
||||
}
|
||||
|
||||
apr_pool_destroy(mp);
|
||||
mp = nullptr;
|
||||
if (is_help)
|
||||
return 1;
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
/** Set the program options. */
|
||||
if (SetProgramOption(argc, argv))
|
||||
return 0;
|
||||
SetProgramOption(argc, argv);
|
||||
|
||||
printf("Livox SDK initializing.\n");
|
||||
/** Initialize Livox-SDK. */
|
||||
|
||||
@@ -3,13 +3,6 @@ cmake_minimum_required(VERSION 3.0)
|
||||
set(DEMO_NAME lidar_sample)
|
||||
add_executable(${DEMO_NAME} main.c)
|
||||
|
||||
if (WIN32)
|
||||
add_custom_command(TARGET ${DEMO_NAME} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${PROJECT_SOURCE_DIR}/third_party/apr/bin/libapr-1.dll"
|
||||
$<TARGET_FILE_DIR:${DEMO_NAME}>)
|
||||
endif()
|
||||
|
||||
target_link_libraries(${DEMO_NAME}
|
||||
PRIVATE
|
||||
${PROJECT_NAME}_static
|
||||
|
||||
@@ -30,8 +30,6 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <apr_general.h>
|
||||
#include <apr_getopt.h>
|
||||
#include "livox_sdk.h"
|
||||
|
||||
typedef enum {
|
||||
@@ -236,88 +234,7 @@ void OnDeviceBroadcast(const BroadcastDeviceInfo *info) {
|
||||
}
|
||||
}
|
||||
|
||||
/** Set the program options.
|
||||
* You can input the registered device broadcast code and decide whether to save the log file.
|
||||
*/
|
||||
int SetProgramOption(int argc, const char *argv[]) {
|
||||
apr_status_t rv;
|
||||
apr_pool_t *mp = NULL;
|
||||
static const apr_getopt_option_t opt_option[] = {
|
||||
/** Long-option, short-option, has-arg flag, description */
|
||||
{ "code", 'c', 1, "Register device broadcast code" },
|
||||
{ "log", 'l', 0, "Save the log file" },
|
||||
{ "help", 'h', 0, "Show help" },
|
||||
{ NULL, 0, 0, NULL },
|
||||
};
|
||||
apr_getopt_t *opt = NULL;
|
||||
int optch = 0;
|
||||
const char *optarg = NULL;
|
||||
|
||||
if (apr_initialize() != APR_SUCCESS) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (apr_pool_create(&mp, NULL) != APR_SUCCESS) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
rv = apr_getopt_init(&opt, mp, argc, argv);
|
||||
if (rv != APR_SUCCESS) {
|
||||
printf("Program options initialization failed.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/** Parse the all options based on opt_option[] */
|
||||
bool is_help = false;
|
||||
while ((rv = apr_getopt_long(opt, opt_option, &optch, &optarg)) == APR_SUCCESS) {
|
||||
switch (optch) {
|
||||
case 'c':
|
||||
printf("Register broadcast code: %s\n", optarg);
|
||||
char *sn_list = (char *)malloc(sizeof(char)*(strlen(optarg) + 1));
|
||||
strncpy(sn_list, optarg, sizeof(char)*(strlen(optarg) + 1));
|
||||
char *sn_list_head = sn_list;
|
||||
sn_list = strtok(sn_list, "&");
|
||||
int i = 0;
|
||||
while (sn_list) {
|
||||
strncpy(broadcast_code_list[i], sn_list, kBroadcastCodeSize);
|
||||
sn_list = strtok(NULL, "&");
|
||||
i++;
|
||||
}
|
||||
lidar_count = i;
|
||||
free(sn_list_head);
|
||||
sn_list_head = NULL;
|
||||
break;
|
||||
case 'l':
|
||||
printf("Save the log file.\n");
|
||||
SaveLoggerFile();
|
||||
break;
|
||||
case 'h':
|
||||
printf(
|
||||
" [-c] Register device broadcast code\n"
|
||||
" [-l] Save the log file\n"
|
||||
" [-h] Show help\n"
|
||||
);
|
||||
is_help = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (rv != APR_EOF) {
|
||||
printf("Invalid options.\n");
|
||||
}
|
||||
|
||||
apr_pool_destroy(mp);
|
||||
mp = NULL;
|
||||
apr_terminate();
|
||||
if (is_help)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
/** Set the program options. */
|
||||
if (SetProgramOption(argc, argv))
|
||||
return 0;
|
||||
|
||||
printf("Livox SDK initializing.\n");
|
||||
/** Initialize Livox-SDK. */
|
||||
if (!Init()) {
|
||||
|
||||
@@ -3,13 +3,6 @@ cmake_minimum_required(VERSION 3.0)
|
||||
set(DEMO_NAME lidar_lvx_sample)
|
||||
add_executable(${DEMO_NAME} main.cpp lvx_file.cpp)
|
||||
|
||||
if (WIN32)
|
||||
add_custom_command(TARGET ${DEMO_NAME} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${PROJECT_SOURCE_DIR}/third_party/apr/bin/libapr-1.dll"
|
||||
$<TARGET_FILE_DIR:${DEMO_NAME}>)
|
||||
endif()
|
||||
|
||||
target_link_libraries(${DEMO_NAME}
|
||||
PRIVATE
|
||||
${PROJECT_NAME}_static
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <time.h>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include "lvx_file.h"
|
||||
#include "third_party/rapidxml/rapidxml.hpp"
|
||||
#include "third_party/rapidxml/rapidxml_utils.hpp"
|
||||
|
||||
@@ -22,9 +22,6 @@
|
||||
// SOFTWARE.
|
||||
//
|
||||
|
||||
#include <apr_thread_cond.h>
|
||||
#include <apr_thread_mutex.h>
|
||||
#include <apr_thread_proc.h>
|
||||
#include <condition_variable>
|
||||
#include <memory>
|
||||
#include <fstream>
|
||||
|
||||
@@ -22,11 +22,10 @@
|
||||
// SOFTWARE.
|
||||
//
|
||||
|
||||
#include <apr_general.h>
|
||||
#include <apr_getopt.h>
|
||||
#include <algorithm>
|
||||
#include <string.h>
|
||||
#include "lvx_file.h"
|
||||
#include "cmdline.h"
|
||||
|
||||
DeviceItem devices[kMaxLidarCount];
|
||||
LvxFileHandle lvx_file_handler;
|
||||
@@ -43,7 +42,6 @@ uint8_t connected_lidar_count = 0;
|
||||
|
||||
#define FRAME_RATE 20
|
||||
|
||||
|
||||
using namespace std::chrono;
|
||||
|
||||
/** Connect all the broadcast device in default and connect specific device when use program options or broadcast_code_list is not empty. */
|
||||
@@ -270,7 +268,7 @@ void AddDevicesToConnect() {
|
||||
continue;
|
||||
}
|
||||
uint8_t handle = 0;
|
||||
bool result = AddLidarToConnect(broadcast_code_rev[i].c_str(), &handle);
|
||||
livox_status result = AddLidarToConnect(broadcast_code_rev[i].c_str(), &handle);
|
||||
if (result == kStatusSuccess) {
|
||||
/** Set the point cloud data for a specific Livox LiDAR. */
|
||||
SetDataCallback(handle, GetLidarData, nullptr);
|
||||
@@ -281,104 +279,46 @@ void AddDevicesToConnect() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Set the program options.
|
||||
* You can input the registered device broadcast code and decide whether to save the log file.
|
||||
*/
|
||||
int SetProgramOption(int argc, const char *argv[]) {
|
||||
apr_status_t rv;
|
||||
apr_pool_t *mp = nullptr;
|
||||
static const apr_getopt_option_t opt_option[] = {
|
||||
/** Long-option, short-option, has-arg flag, description */
|
||||
{ "code", 'c', 1, "Register device broadcast code" },
|
||||
{ "log", 'l', 0, "Save the log file" },
|
||||
{ "time", 't', 1, "Time to save point cloud to the lvx file" },
|
||||
{ "param", 'p', 0, "Get the extrinsic parameter from extrinsic.xml file" },
|
||||
{ "help", 'h', 0, "Show help" },
|
||||
{ nullptr, 0, 0, nullptr },
|
||||
};
|
||||
apr_getopt_t *opt = nullptr;
|
||||
int optch = 0;
|
||||
const char *optarg = nullptr;
|
||||
|
||||
if (apr_initialize() != APR_SUCCESS) {
|
||||
return -1;
|
||||
void SetProgramOption(int argc, const char *argv[]) {
|
||||
cmdline::parser cmd;
|
||||
cmd.add<std::string>("code", 'c', "Register device broadcast code", false);
|
||||
cmd.add("log", 'l', "Save the log file");
|
||||
cmd.add<int>("time", 't', "Time to save point cloud to the lvx file", false);
|
||||
cmd.add("param", 'p', "Get the extrinsic parameter from extrinsic.xml file");
|
||||
cmd.add("help", 'h', "Show help");
|
||||
cmd.parse_check(argc, const_cast<char **>(argv));
|
||||
if (cmd.exist("code")) {
|
||||
std::string sn_list = cmd.get<std::string>("code");
|
||||
printf("Register broadcast code: %s\n", sn_list.c_str());
|
||||
size_t pos = 0;
|
||||
broadcast_code_list.clear();
|
||||
while ((pos = sn_list.find("&")) != std::string::npos) {
|
||||
broadcast_code_list.push_back(sn_list.substr(0, pos));
|
||||
sn_list.erase(0, pos + 1);
|
||||
}
|
||||
broadcast_code_list.push_back(sn_list);
|
||||
}
|
||||
|
||||
if (apr_pool_create(&mp, NULL) != APR_SUCCESS) {
|
||||
return -1;
|
||||
if (cmd.exist("log")) {
|
||||
printf("Save the log file.\n");
|
||||
SaveLoggerFile();
|
||||
}
|
||||
|
||||
rv = apr_getopt_init(&opt, mp, argc, argv);
|
||||
if (rv != APR_SUCCESS) {
|
||||
printf("Program options initialization failed.\n");
|
||||
return -1;
|
||||
if (cmd.exist("time")) {
|
||||
printf("Time to save point cloud to the lvx file:%d.\n", cmd.get<int>("time"));
|
||||
lvx_file_save_time = cmd.get<int>("time");
|
||||
}
|
||||
|
||||
/** Parse the all options based on opt_option[] */
|
||||
bool is_help = false;
|
||||
while ((rv = apr_getopt_long(opt, opt_option, &optch, &optarg)) == APR_SUCCESS) {
|
||||
switch (optch) {
|
||||
case 'c': {
|
||||
printf("Register broadcast code: %s\n", optarg);
|
||||
char *sn_list = (char *)malloc(sizeof(char)*(strlen(optarg) + 1));
|
||||
strncpy(sn_list, optarg, sizeof(char)*(strlen(optarg) + 1));
|
||||
char *sn_list_head = sn_list;
|
||||
sn_list = strtok(sn_list, "&");
|
||||
int i = 0;
|
||||
broadcast_code_list.clear();
|
||||
while (sn_list) {
|
||||
broadcast_code_list.push_back(sn_list);
|
||||
sn_list = strtok(nullptr, "&");
|
||||
i++;
|
||||
}
|
||||
free(sn_list_head);
|
||||
sn_list_head = nullptr;
|
||||
break;
|
||||
}
|
||||
case 'l': {
|
||||
printf("Save the log file.\n");
|
||||
SaveLoggerFile();
|
||||
break;
|
||||
}
|
||||
case 't': {
|
||||
printf("Time to save point cloud to the lvx file:%s.\n", optarg);
|
||||
lvx_file_save_time = atoi(optarg);
|
||||
break;
|
||||
}
|
||||
case 'p': {
|
||||
printf("Get the extrinsic parameter from extrinsic.xml file.\n");
|
||||
is_read_extrinsic_from_xml = true;
|
||||
break;
|
||||
}
|
||||
case 'h': {
|
||||
printf(
|
||||
" [-c] Register device broadcast code\n"
|
||||
" [-l] Save the log file\n"
|
||||
" [-t] Time to save point cloud to the lvx file\n"
|
||||
" [-p] Get the extrinsic parameter from extrinsic.xml file\n"
|
||||
" [-h] Show help\n"
|
||||
);
|
||||
is_help = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cmd.exist("param")) {
|
||||
printf("Get the extrinsic parameter from extrinsic.xml file.\n");
|
||||
is_read_extrinsic_from_xml = true;
|
||||
}
|
||||
if (rv != APR_EOF) {
|
||||
printf("Invalid options.\n");
|
||||
}
|
||||
|
||||
apr_pool_destroy(mp);
|
||||
mp = nullptr;
|
||||
if (is_help)
|
||||
return 1;
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
/** Set the program options. */
|
||||
if (SetProgramOption(argc, argv))
|
||||
return 0;
|
||||
SetProgramOption(argc, argv);
|
||||
|
||||
printf("Livox SDK initializing.\n");
|
||||
/** Initialize Livox-SDK. */
|
||||
|
||||
@@ -3,13 +3,6 @@ cmake_minimum_required(VERSION 3.0)
|
||||
set(DEMO_NAME hub_sample_cc)
|
||||
add_executable(${DEMO_NAME} lds_hub.cpp main.cpp)
|
||||
|
||||
if (WIN32)
|
||||
add_custom_command(TARGET ${DEMO_NAME} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${PROJECT_SOURCE_DIR}/third_party/apr/bin/libapr-1.dll"
|
||||
$<TARGET_FILE_DIR:${DEMO_NAME}>)
|
||||
endif()
|
||||
|
||||
target_link_libraries(${DEMO_NAME}
|
||||
PRIVATE
|
||||
${PROJECT_NAME}_static
|
||||
|
||||
@@ -207,7 +207,7 @@ void LdsHub::OnDeviceBroadcast(const BroadcastDeviceInfo *info) {
|
||||
|
||||
LidarDevice* p_hub = &g_lds_hub->hub_;
|
||||
if (p_hub->connect_state == kConnectStateOff) {
|
||||
bool result = false;
|
||||
livox_status result = kStatusFailure;
|
||||
uint8_t handle = 0;
|
||||
result = AddHubToConnect(info->broadcast_code, &handle);
|
||||
if (result == kStatusSuccess && handle < kMaxLidarCount) {
|
||||
|
||||
+20
-83
@@ -25,15 +25,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
#include "cmdline.h"
|
||||
#include <string.h>
|
||||
#include <apr_general.h>
|
||||
#include <apr_getopt.h>
|
||||
#include "lds_hub.h"
|
||||
|
||||
/** Cmdline input broadcast code */
|
||||
@@ -42,82 +37,28 @@ static std::vector<std::string> cmdline_broadcast_code;
|
||||
/** Set the program options.
|
||||
* You can input the registered device broadcast code and decide whether to save the log file.
|
||||
*/
|
||||
static int SetProgramOption(int argc, const char *argv[]) {
|
||||
apr_status_t rv;
|
||||
apr_pool_t *mp = NULL;
|
||||
static const apr_getopt_option_t opt_option[] = {
|
||||
/** Long-option, short-option, has-arg flag, description */
|
||||
{ "code", 'c', 1, "Register device broadcast code" },
|
||||
{ "log", 'l', 0, "Save the log file" },
|
||||
{ "help", 'h', 0, "Show help" },
|
||||
{ NULL, 0, 0, NULL },
|
||||
};
|
||||
apr_getopt_t *opt = NULL;
|
||||
int optch = 0;
|
||||
const char *optarg = NULL;
|
||||
|
||||
if (apr_initialize() != APR_SUCCESS) {
|
||||
return -1;
|
||||
void SetProgramOption(int argc, const char *argv[]) {
|
||||
cmdline::parser cmd;
|
||||
cmd.add<std::string>("code", 'c', "Register device broadcast code", false);
|
||||
cmd.add("log", 'l', "Save the log file");
|
||||
cmd.add("help", 'h', "Show help");
|
||||
cmd.parse_check(argc, const_cast<char **>(argv));
|
||||
if (cmd.exist("code")) {
|
||||
std::string sn_list = cmd.get<std::string>("code");
|
||||
printf("Register broadcast code: %s\n", sn_list.c_str());
|
||||
cmdline_broadcast_code.clear();
|
||||
cmdline_broadcast_code.push_back(sn_list);
|
||||
}
|
||||
|
||||
if (apr_pool_create(&mp, NULL) != APR_SUCCESS) {
|
||||
return -1;
|
||||
if (cmd.exist("log")) {
|
||||
printf("Save the log file.\n");
|
||||
SaveLoggerFile();
|
||||
}
|
||||
|
||||
rv = apr_getopt_init(&opt, mp, argc, argv);
|
||||
if (rv != APR_SUCCESS) {
|
||||
printf("Program options initialization failed.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/** Parse the all options based on opt_option[] */
|
||||
bool is_help = false;
|
||||
while ((rv = apr_getopt_long(opt, opt_option, &optch, &optarg)) == APR_SUCCESS) {
|
||||
switch (optch) {
|
||||
case 'c': {
|
||||
printf("Register broadcast code: %s\n", optarg);
|
||||
cmdline_broadcast_code.clear();
|
||||
cmdline_broadcast_code.push_back(optarg);
|
||||
break;
|
||||
}
|
||||
case 'l': {
|
||||
printf("Save the log file.\n");
|
||||
SaveLoggerFile();
|
||||
break;
|
||||
}
|
||||
case 'h': {
|
||||
printf(
|
||||
" [-c] Register device broadcast code\n"
|
||||
" [-l] Save the log file\n"
|
||||
" [-h] Show help\n"
|
||||
);
|
||||
is_help = true;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rv != APR_EOF) {
|
||||
printf("Invalid options.\n");
|
||||
}
|
||||
|
||||
apr_pool_destroy(mp);
|
||||
mp = NULL;
|
||||
apr_terminate();
|
||||
if (is_help)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
/** Set the program options. */
|
||||
if (SetProgramOption(argc, argv)) {
|
||||
return 0;
|
||||
}
|
||||
SetProgramOption(argc, argv);
|
||||
|
||||
LdsHub& read_hub = LdsHub::GetInstance();
|
||||
int ret = read_hub.InitLdsHub(cmdline_broadcast_code);
|
||||
@@ -129,11 +70,7 @@ int main(int argc, const char *argv[]) {
|
||||
|
||||
printf("Start discovering device.\n");
|
||||
|
||||
#ifdef WIN32
|
||||
Sleep(100000);
|
||||
#else
|
||||
sleep(100);
|
||||
#endif
|
||||
std::this_thread::sleep_for(std::chrono::seconds(100));
|
||||
|
||||
read_hub.DeInitLdsHub();
|
||||
printf("Livox hub demo end!\n");
|
||||
|
||||
@@ -3,13 +3,6 @@ cmake_minimum_required(VERSION 3.0)
|
||||
set(DEMO_NAME lidar_sample_cc)
|
||||
add_executable(${DEMO_NAME} main.cpp lds_lidar.cpp)
|
||||
|
||||
if (WIN32)
|
||||
add_custom_command(TARGET ${DEMO_NAME} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${PROJECT_SOURCE_DIR}/third_party/apr/bin/libapr-1.dll"
|
||||
$<TARGET_FILE_DIR:${DEMO_NAME}>)
|
||||
endif()
|
||||
|
||||
target_link_libraries(${DEMO_NAME}
|
||||
PRIVATE
|
||||
${PROJECT_NAME}_static
|
||||
|
||||
@@ -196,7 +196,7 @@ void LdsLidar::OnDeviceBroadcast(const BroadcastDeviceInfo *info) {
|
||||
}
|
||||
}
|
||||
|
||||
bool result = false;
|
||||
livox_status result = kStatusFailure;
|
||||
uint8_t handle = 0;
|
||||
result = AddLidarToConnect(info->broadcast_code, &handle);
|
||||
if (result == kStatusSuccess && handle < kMaxLidarCount) {
|
||||
|
||||
+24
-92
@@ -24,16 +24,10 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <apr_general.h>
|
||||
#include <apr_getopt.h>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
#include "cmdline.h"
|
||||
#include "lds_lidar.h"
|
||||
|
||||
/** Cmdline input broadcast code */
|
||||
@@ -42,91 +36,33 @@ static std::vector<std::string> cmdline_broadcast_code;
|
||||
/** Set the program options.
|
||||
* You can input the registered device broadcast code and decide whether to save the log file.
|
||||
*/
|
||||
static int SetProgramOption(int argc, const char *argv[]) {
|
||||
apr_status_t rv;
|
||||
apr_pool_t *mp = NULL;
|
||||
static const apr_getopt_option_t opt_option[] = {
|
||||
/** Long-option, short-option, has-arg flag, description */
|
||||
{ "code", 'c', 1, "Register device broadcast code" },
|
||||
{ "log", 'l', 0, "Save the log file" },
|
||||
{ "help", 'h', 0, "Show help" },
|
||||
{ NULL, 0, 0, NULL },
|
||||
};
|
||||
apr_getopt_t *opt = NULL;
|
||||
int optch = 0;
|
||||
const char *optarg = NULL;
|
||||
|
||||
if (apr_initialize() != APR_SUCCESS) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (apr_pool_create(&mp, NULL) != APR_SUCCESS) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
rv = apr_getopt_init(&opt, mp, argc, argv);
|
||||
if (rv != APR_SUCCESS) {
|
||||
printf("Program options initialization failed.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/** Parse the all options based on opt_option[] */
|
||||
bool is_help = false;
|
||||
while ((rv = apr_getopt_long(opt, opt_option, &optch, &optarg)) == APR_SUCCESS) {
|
||||
switch (optch) {
|
||||
case 'c': {
|
||||
printf("Register broadcast code: %s\n", optarg);
|
||||
char *sn_list = (char *)malloc(sizeof(char)*(strlen(optarg) + 1));
|
||||
strncpy(sn_list, optarg, sizeof(char)*(strlen(optarg) + 1));
|
||||
char *sn_list_head = sn_list;
|
||||
sn_list = strtok(sn_list, "&");
|
||||
cmdline_broadcast_code.clear();
|
||||
while (sn_list) {
|
||||
cmdline_broadcast_code.push_back(sn_list);
|
||||
sn_list = strtok(nullptr, "&");
|
||||
}
|
||||
free(sn_list_head);
|
||||
sn_list_head = nullptr;
|
||||
break;
|
||||
}
|
||||
case 'l': {
|
||||
printf("Save the log file.\n");
|
||||
SaveLoggerFile();
|
||||
break;
|
||||
}
|
||||
case 'h': {
|
||||
printf(
|
||||
" [-c] Register device broadcast code\n"
|
||||
" [-l] Save the log file\n"
|
||||
" [-h] Show help\n"
|
||||
);
|
||||
is_help = true;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
void SetProgramOption(int argc, const char *argv[]) {
|
||||
cmdline::parser cmd;
|
||||
cmd.add<std::string>("code", 'c', "Register device broadcast code", false);
|
||||
cmd.add("log", 'l', "Save the log file");
|
||||
cmd.add("help", 'h', "Show help");
|
||||
cmd.parse_check(argc, const_cast<char **>(argv));
|
||||
if (cmd.exist("code")) {
|
||||
std::string sn_list = cmd.get<std::string>("code");
|
||||
printf("Register broadcast code: %s\n", sn_list.c_str());
|
||||
size_t pos = 0;
|
||||
cmdline_broadcast_code.clear();
|
||||
while ((pos = sn_list.find("&")) != std::string::npos) {
|
||||
cmdline_broadcast_code.push_back(sn_list.substr(0, pos));
|
||||
sn_list.erase(0, pos + 1);
|
||||
}
|
||||
cmdline_broadcast_code.push_back(sn_list);
|
||||
}
|
||||
|
||||
if (rv != APR_EOF) {
|
||||
printf("Invalid options.\n");
|
||||
if (cmd.exist("log")) {
|
||||
printf("Save the log file.\n");
|
||||
SaveLoggerFile();
|
||||
}
|
||||
|
||||
apr_pool_destroy(mp);
|
||||
mp = NULL;
|
||||
apr_terminate();
|
||||
if (is_help)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
/** Set the program options. */
|
||||
if (SetProgramOption(argc, argv)) {
|
||||
return 0;
|
||||
}
|
||||
SetProgramOption(argc, argv);
|
||||
|
||||
LdsLidar& read_lidar = LdsLidar::GetInstance();
|
||||
|
||||
@@ -139,11 +75,7 @@ int main(int argc, const char *argv[]) {
|
||||
|
||||
printf("Start discovering device.\n");
|
||||
|
||||
#ifdef WIN32
|
||||
Sleep(100000);
|
||||
#else
|
||||
sleep(100);
|
||||
#endif
|
||||
std::this_thread::sleep_for(std::chrono::seconds(100));
|
||||
|
||||
read_lidar.DeInitLdsLidar();
|
||||
printf("Livox lidar demo end!\n");
|
||||
|
||||
@@ -7,13 +7,6 @@ endif ()
|
||||
set(DEMO_NAME lidar_utc_sync)
|
||||
add_executable(${DEMO_NAME} main.cpp lds_lidar.cpp synchro.cpp)
|
||||
|
||||
if (WIN32)
|
||||
add_custom_command(TARGET ${DEMO_NAME} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${PROJECT_SOURCE_DIR}/third_party/apr/bin/libapr-1.dll"
|
||||
$<TARGET_FILE_DIR:${DEMO_NAME}>)
|
||||
endif()
|
||||
|
||||
target_link_libraries(${DEMO_NAME}
|
||||
PRIVATE
|
||||
${PROJECT_NAME}_static
|
||||
|
||||
@@ -156,7 +156,7 @@ void LdsLidar::OnDeviceBroadcast(const BroadcastDeviceInfo *info) {
|
||||
}
|
||||
}
|
||||
|
||||
bool result = false;
|
||||
livox_status result = kStatusFailure;
|
||||
uint8_t handle = 0;
|
||||
result = AddLidarToConnect(info->broadcast_code, &handle);
|
||||
if (result == kStatusSuccess && handle < kMaxLidarCount) {
|
||||
|
||||
@@ -24,16 +24,10 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
#include <string.h>
|
||||
#include <apr_general.h>
|
||||
#include <apr_getopt.h>
|
||||
#include "cmdline.h"
|
||||
#include "lds_lidar.h"
|
||||
#include "synchro.h"
|
||||
|
||||
@@ -44,91 +38,33 @@ static std::vector<std::string> cmdline_broadcast_code;
|
||||
/** Set the program options.
|
||||
* You can input the registered device broadcast code and decide whether to save the log file.
|
||||
*/
|
||||
static int SetProgramOption(int argc, const char *argv[]) {
|
||||
apr_status_t rv;
|
||||
apr_pool_t *mp = NULL;
|
||||
static const apr_getopt_option_t opt_option[] = {
|
||||
/** Long-option, short-option, has-arg flag, description */
|
||||
{ "code", 'c', 1, "Register device broadcast code" },
|
||||
{ "log", 'l', 0, "Save the log file" },
|
||||
{ "help", 'h', 0, "Show help" },
|
||||
{ NULL, 0, 0, NULL },
|
||||
};
|
||||
apr_getopt_t *opt = NULL;
|
||||
int optch = 0;
|
||||
const char *optarg = NULL;
|
||||
|
||||
if (apr_initialize() != APR_SUCCESS) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (apr_pool_create(&mp, NULL) != APR_SUCCESS) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
rv = apr_getopt_init(&opt, mp, argc, argv);
|
||||
if (rv != APR_SUCCESS) {
|
||||
printf("Program options initialization failed.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/** Parse the all options based on opt_option[] */
|
||||
bool is_help = false;
|
||||
while ((rv = apr_getopt_long(opt, opt_option, &optch, &optarg)) == APR_SUCCESS) {
|
||||
switch (optch) {
|
||||
case 'c': {
|
||||
printf("Register broadcast code: %s\n", optarg);
|
||||
char *sn_list = (char *)malloc(sizeof(char)*(strlen(optarg) + 1));
|
||||
strncpy(sn_list, optarg, sizeof(char)*(strlen(optarg) + 1));
|
||||
char *sn_list_head = sn_list;
|
||||
sn_list = strtok(sn_list, "&");
|
||||
cmdline_broadcast_code.clear();
|
||||
while (sn_list) {
|
||||
cmdline_broadcast_code.push_back(sn_list);
|
||||
sn_list = strtok(nullptr, "&");
|
||||
}
|
||||
free(sn_list_head);
|
||||
sn_list_head = nullptr;
|
||||
break;
|
||||
}
|
||||
case 'l': {
|
||||
printf("Save the log file.\n");
|
||||
SaveLoggerFile();
|
||||
break;
|
||||
}
|
||||
case 'h': {
|
||||
printf(
|
||||
" [-c] Register device broadcast code\n"
|
||||
" [-l] Save the log file\n"
|
||||
" [-h] Show help\n"
|
||||
);
|
||||
is_help = true;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
void SetProgramOption(int argc, const char *argv[]) {
|
||||
cmdline::parser cmd;
|
||||
cmd.add<std::string>("code", 'c', "Register device broadcast code", false);
|
||||
cmd.add("log", 'l', "Save the log file");
|
||||
cmd.add("help", 'h', "Show help");
|
||||
cmd.parse_check(argc, const_cast<char **>(argv));
|
||||
if (cmd.exist("code")) {
|
||||
std::string sn_list = cmd.get<std::string>("code");
|
||||
printf("Register broadcast code: %s\n", sn_list.c_str());
|
||||
size_t pos = 0;
|
||||
cmdline_broadcast_code.clear();
|
||||
while ((pos = sn_list.find("&")) != std::string::npos) {
|
||||
cmdline_broadcast_code.push_back(sn_list.substr(0, pos));
|
||||
sn_list.erase(0, pos + 1);
|
||||
}
|
||||
cmdline_broadcast_code.push_back(sn_list);
|
||||
}
|
||||
|
||||
if (rv != APR_EOF) {
|
||||
printf("Invalid options.\n");
|
||||
if (cmd.exist("log")) {
|
||||
printf("Save the log file.\n");
|
||||
SaveLoggerFile();
|
||||
}
|
||||
|
||||
apr_pool_destroy(mp);
|
||||
mp = NULL;
|
||||
apr_terminate();
|
||||
if (is_help)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
/** Set the program options. */
|
||||
if (SetProgramOption(argc, argv)) {
|
||||
return 0;
|
||||
}
|
||||
SetProgramOption(argc, argv);
|
||||
|
||||
LdsLidar& read_lidar = LdsLidar::GetInstance();
|
||||
|
||||
@@ -162,11 +98,7 @@ int main(int argc, const char *argv[]) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
Sleep(100000);
|
||||
#else
|
||||
sleep(100);
|
||||
#endif
|
||||
std::this_thread::sleep_for(std::chrono::seconds(100));
|
||||
|
||||
synchro.Stop();
|
||||
read_lidar.DeInitLdsLidar();
|
||||
|
||||
@@ -268,10 +268,8 @@ void Synchro::Close() {
|
||||
|
||||
/* Sets up the port parameters */
|
||||
int Synchro::Setup(enum BaudRate baud, enum Parity parity) {
|
||||
static uint32_t baud_map[19] = {\
|
||||
B2400, B4800, B9600, B19200, B38400, B57600,B115200, B230400,\
|
||||
B460800, B500000, B576000,B921600,B1152000, B1500000, B2000000,\
|
||||
B2500000, B3000000, B3500000, B4000000\
|
||||
static uint32_t baud_map[19] = {
|
||||
B2400, B4800, B9600, B19200, B38400, B57600,B115200, B230400
|
||||
};
|
||||
tcflag_t baudrate;
|
||||
struct termios options;
|
||||
@@ -284,19 +282,18 @@ int Synchro::Setup(enum BaudRate baud, enum Parity parity) {
|
||||
usleep(10000);
|
||||
|
||||
/* Minimum number of characters to read */
|
||||
options.c_cc[VMIN] = 0;
|
||||
|
||||
options.c_cc[VMIN] = 0;
|
||||
/* Time to wait for data */
|
||||
options.c_cc[VTIME] = 100;
|
||||
options.c_cc[VTIME] = 100;
|
||||
|
||||
/* Enable the receiver and set local mode... */
|
||||
options.c_cflag |= (CLOCAL | CREAD);
|
||||
|
||||
/* Set boadrate */
|
||||
options.c_cflag &= ~CBAUD;
|
||||
baudrate = baud_map[baud];
|
||||
options.c_cflag |= baudrate;
|
||||
printf("[Baudrate]: %d %d\r\n", baud, baudrate);
|
||||
cfsetispeed(&options, baudrate);
|
||||
cfsetospeed(&options, baudrate);
|
||||
printf("[Baudrate]: %d %u\r\n", baud, baudrate);
|
||||
|
||||
switch (parity) {
|
||||
case P_8N1:
|
||||
|
||||
@@ -3,13 +3,6 @@ cmake_minimum_required(VERSION 3.0)
|
||||
set(DEMO_NAME trouble_shooting)
|
||||
add_executable(${DEMO_NAME} main.cpp)
|
||||
|
||||
if (WIN32)
|
||||
add_custom_command(TARGET ${DEMO_NAME} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${PROJECT_SOURCE_DIR}/third_party/apr/bin/libapr-1.dll"
|
||||
$<TARGET_FILE_DIR:${DEMO_NAME}>)
|
||||
endif()
|
||||
|
||||
target_link_libraries(${DEMO_NAME}
|
||||
PRIVATE
|
||||
${PROJECT_NAME}_static
|
||||
|
||||
+25
-45
@@ -4,60 +4,28 @@ set(SDK_LIBRARY ${PROJECT_NAME}_static)
|
||||
add_library(${SDK_LIBRARY} STATIC "")
|
||||
|
||||
set(LIVOX_SDK_MAJOR_VERSION "2")
|
||||
set(LIVOX_SDK_MINOR_VERSION "1")
|
||||
set(LIVOX_SDK_MINOR_VERSION "3")
|
||||
set(LIVOX_SDK_PATCH_VERSION "0")
|
||||
set(LIVOX_SDK_VERSION_STRING "${LIVOX_SDK_MAJOR_VERSION}.${LIVOX_SDK_MINOR_VERSION}.${LIVOX_SDK_PATCH_VERSION}")
|
||||
|
||||
if (WIN32)
|
||||
set(APR_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/third_party/apr/include)
|
||||
set(APR_LIBRARIES ${PROJECT_SOURCE_DIR}/third_party/apr/lib/libapr-1.lib)
|
||||
set(APR_FOUND "YES")
|
||||
else (WIN32)
|
||||
if (CMAKE_CROSSCOMPILING)
|
||||
MESSAGE(STATUS "CMAKE CROSS COMPILE")
|
||||
execute_process(
|
||||
COMMAND bash ${PROJECT_SOURCE_DIR}/third_party/apr/apr_cross_build.sh
|
||||
${CMAKE_C_COMPILER}
|
||||
RESULT_VARIABLE cmd_result
|
||||
)
|
||||
MESSAGE("${cmd_result}")
|
||||
if (cmd_result)
|
||||
MESSAGE(FATAL_ERROR "APR BUILD FAILED")
|
||||
endif()
|
||||
set(APR_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/third_party/apr/include/apr-1)
|
||||
set(APR_LIBRARIES ${PROJECT_SOURCE_DIR}/third_party/apr/lib/libapr-1.so)
|
||||
set(APR_FOUND "YES")
|
||||
else (CMAKE_CROSSCOMPILING)
|
||||
find_package(PkgConfig)
|
||||
pkg_check_modules(APR apr-1)
|
||||
endif(CMAKE_CROSSCOMPILING)
|
||||
endif (WIN32)
|
||||
|
||||
if (APR_FOUND)
|
||||
target_include_directories(${SDK_LIBRARY}
|
||||
PUBLIC
|
||||
${APR_INCLUDE_DIRS})
|
||||
if (APR_LIBRARY_DIRS AND NOT APPLE)
|
||||
target_link_libraries(${SDK_LIBRARY}
|
||||
PUBLIC
|
||||
${APR_LIBRARY_DIRS}/libapr-1.so)
|
||||
else ()
|
||||
target_link_libraries(${SDK_LIBRARY}
|
||||
PUBLIC
|
||||
${APR_LIBRARIES})
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
target_include_directories(${SDK_LIBRARY}
|
||||
PUBLIC
|
||||
include
|
||||
include/third_party/FastCRC
|
||||
include/third_party/spdlog
|
||||
include/third_party/cmdline
|
||||
PRIVATE
|
||||
src)
|
||||
|
||||
set_target_properties(${SDK_LIBRARY} PROPERTIES PUBLIC_HEADER "include/livox_def.h;include/livox_sdk.h")
|
||||
|
||||
if(WIN32)
|
||||
set(PLATFORM win)
|
||||
else(WIN32)
|
||||
set(PLATFORM unix)
|
||||
endif (WIN32)
|
||||
|
||||
target_compile_options(${SDK_LIBRARY}
|
||||
PRIVATE $<$<CXX_COMPILER_ID:GNU>:-Wall -Werror -Wno-c++11-long-long>
|
||||
PRIVATE $<$<CXX_COMPILER_ID:AppleClang>:-Wno-unknown-pragmas -Wall -Werror -Wno-c++11-long-long>
|
||||
@@ -73,12 +41,11 @@ target_sources(${SDK_LIBRARY}
|
||||
src/base/thread_base.cpp
|
||||
src/base/io_thread.h
|
||||
src/base/io_thread.cpp
|
||||
src/base/network_util.h
|
||||
src/base/network_util.cpp
|
||||
src/base/network/network_util.h
|
||||
src/base/network/${PLATFORM}/network_util.cpp
|
||||
src/base/logging.h
|
||||
src/base/logging.cpp
|
||||
src/base/noncopyable.h
|
||||
src/base/util.cpp
|
||||
src/livox_sdk.cpp
|
||||
src/device_discovery.h
|
||||
src/device_discovery.cpp
|
||||
@@ -102,10 +69,23 @@ target_sources(${SDK_LIBRARY}
|
||||
src/command_handler/lidar_command_handler.h
|
||||
src/command_handler/lidar_command_handler.cpp
|
||||
src/command_handler/command_impl.cpp
|
||||
src/command_handler/command_impl.h)
|
||||
src/command_handler/command_impl.h
|
||||
src/base/multiple_io/multiple_io_base.h
|
||||
src/base/multiple_io/multiple_io_base.cpp
|
||||
src/base/multiple_io/multiple_io_factory.h
|
||||
src/base/multiple_io/multiple_io_epoll.h
|
||||
src/base/multiple_io/multiple_io_epoll.cpp
|
||||
src/base/multiple_io/multiple_io_poll.h
|
||||
src/base/multiple_io/multiple_io_poll.cpp
|
||||
src/base/multiple_io/multiple_io_select.h
|
||||
src/base/multiple_io/multiple_io_select.cpp
|
||||
src/base/multiple_io/multiple_io_kqueue.h
|
||||
src/base/multiple_io/multiple_io_kqueue.cpp
|
||||
src/base/wake_up/wake_up_pipe.h
|
||||
src/base/wake_up/${PLATFORM}/wake_up_pipe.cpp)
|
||||
|
||||
|
||||
install(TARGETS ${SDK_LIBRARY}
|
||||
PUBLIC_HEADER DESTINATION include
|
||||
ARCHIVE DESTINATION lib
|
||||
LIBRARY DESTINATION lib)
|
||||
LIBRARY DESTINATION lib)
|
||||
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2019 Livox. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
|
||||
#ifndef CONFIG_H_
|
||||
#define CONFIG_H_
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <sys/epoll.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#define HAVE_EPOLL 1
|
||||
#elif defined(_WIN32)
|
||||
#include <winsock2.h>
|
||||
#define HAVE_SELECT 1
|
||||
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined (__NetBSD__)
|
||||
#include <sys/event.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#define HAVE_KQUEUE 1
|
||||
#else
|
||||
#include <sys/poll.h>
|
||||
#define HAVE POLL 1
|
||||
#endif
|
||||
|
||||
#endif // CONFIG_H_
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ typedef enum {
|
||||
#pragma pack(1)
|
||||
|
||||
#define LIVOX_SDK_MAJOR_VERSION 2
|
||||
#define LIVOX_SDK_MINOR_VERSION 2
|
||||
#define LIVOX_SDK_MINOR_VERSION 3
|
||||
#define LIVOX_SDK_PATCH_VERSION 0
|
||||
|
||||
#define kBroadcastCodeSize 16
|
||||
|
||||
@@ -204,7 +204,7 @@ livox_status HubStopSampling(CommonCommandCallback cb, void *client_data);
|
||||
* @param id Livox Hub's id.
|
||||
* @return LiDAR unit handle.
|
||||
*/
|
||||
livox_status HubGetLidarHandle(uint8_t slot, uint8_t id);
|
||||
uint8_t HubGetLidarHandle(uint8_t slot, uint8_t id);
|
||||
|
||||
/**
|
||||
* Disconnect divice.
|
||||
|
||||
+823
@@ -0,0 +1,823 @@
|
||||
/*
|
||||
Copyright (c) 2009, Hideyuki Tanaka
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the <organization> nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY <copyright holder> ''AS IS'' AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include <typeinfo>
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
#if defined(_MSC_VER)
|
||||
#include <windows.h>
|
||||
#include <dbghelp.h>
|
||||
#undef max
|
||||
#pragma comment(lib, "dbghelp.lib")
|
||||
#elif defined(__clang__) || defined(__GNUC__)
|
||||
#include <cxxabi.h>
|
||||
#endif
|
||||
#include <cstdlib>
|
||||
|
||||
namespace cmdline{
|
||||
|
||||
namespace detail{
|
||||
|
||||
template <typename Target, typename Source, bool Same>
|
||||
class lexical_cast_t{
|
||||
public:
|
||||
static Target cast(const Source &arg){
|
||||
Target ret;
|
||||
std::stringstream ss;
|
||||
if (!(ss<<arg && ss>>ret && ss.eof()))
|
||||
throw std::bad_cast();
|
||||
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Target, typename Source>
|
||||
class lexical_cast_t<Target, Source, true>{
|
||||
public:
|
||||
static Target cast(const Source &arg){
|
||||
return arg;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Source>
|
||||
class lexical_cast_t<std::string, Source, false>{
|
||||
public:
|
||||
static std::string cast(const Source &arg){
|
||||
std::ostringstream ss;
|
||||
ss<<arg;
|
||||
return ss.str();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Target>
|
||||
class lexical_cast_t<Target, std::string, false>{
|
||||
public:
|
||||
static Target cast(const std::string &arg){
|
||||
Target ret;
|
||||
std::istringstream ss(arg);
|
||||
if (!(ss>>ret && ss.eof()))
|
||||
throw std::bad_cast();
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct is_same {
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct is_same<T, T>{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
template<typename Target, typename Source>
|
||||
Target lexical_cast(const Source &arg)
|
||||
{
|
||||
return lexical_cast_t<Target, Source, detail::is_same<Target, Source>::value>::cast(arg);
|
||||
}
|
||||
|
||||
static inline std::string demangle(const std::string &name)
|
||||
{
|
||||
#if defined(_MSC_VER)
|
||||
TCHAR ret[256];
|
||||
std::memset(ret, 0, 256);
|
||||
::UnDecorateSymbolName(name.c_str(), ret, 256, 0);
|
||||
return ret;
|
||||
#else
|
||||
int status=0;
|
||||
char *p=abi::__cxa_demangle(name.c_str(), 0, 0, &status);
|
||||
std::string ret(p);
|
||||
free(p);
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
std::string readable_typename()
|
||||
{
|
||||
return demangle(typeid(T).name());
|
||||
}
|
||||
|
||||
template <class T>
|
||||
std::string default_value(T def)
|
||||
{
|
||||
return detail::lexical_cast<std::string>(def);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline std::string readable_typename<std::string>()
|
||||
{
|
||||
return "string";
|
||||
}
|
||||
|
||||
} // detail
|
||||
|
||||
//-----
|
||||
|
||||
class cmdline_error : public std::exception {
|
||||
public:
|
||||
cmdline_error(const std::string &msg): msg(msg){}
|
||||
~cmdline_error() throw() {}
|
||||
const char *what() const throw() { return msg.c_str(); }
|
||||
private:
|
||||
std::string msg;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct default_reader{
|
||||
T operator()(const std::string &str){
|
||||
return detail::lexical_cast<T>(str);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct range_reader{
|
||||
range_reader(const T &low, const T &high): low(low), high(high) {}
|
||||
T operator()(const std::string &s) const {
|
||||
T ret=default_reader<T>()(s);
|
||||
if (!(ret>=low && ret<=high)) throw cmdline::cmdline_error("range_error");
|
||||
return ret;
|
||||
}
|
||||
private:
|
||||
T low, high;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
range_reader<T> range(const T &low, const T &high)
|
||||
{
|
||||
return range_reader<T>(low, high);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
struct oneof_reader{
|
||||
T operator()(const std::string &s){
|
||||
T ret=default_reader<T>()(s);
|
||||
if (std::find(alt.begin(), alt.end(), ret)==alt.end())
|
||||
throw cmdline_error("");
|
||||
return ret;
|
||||
}
|
||||
void add(const T &v){ alt.push_back(v); }
|
||||
private:
|
||||
std::vector<T> alt;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
oneof_reader<T> oneof(T a1)
|
||||
{
|
||||
oneof_reader<T> ret;
|
||||
ret.add(a1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
oneof_reader<T> oneof(T a1, T a2)
|
||||
{
|
||||
oneof_reader<T> ret;
|
||||
ret.add(a1);
|
||||
ret.add(a2);
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
oneof_reader<T> oneof(T a1, T a2, T a3)
|
||||
{
|
||||
oneof_reader<T> ret;
|
||||
ret.add(a1);
|
||||
ret.add(a2);
|
||||
ret.add(a3);
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
oneof_reader<T> oneof(T a1, T a2, T a3, T a4)
|
||||
{
|
||||
oneof_reader<T> ret;
|
||||
ret.add(a1);
|
||||
ret.add(a2);
|
||||
ret.add(a3);
|
||||
ret.add(a4);
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
oneof_reader<T> oneof(T a1, T a2, T a3, T a4, T a5)
|
||||
{
|
||||
oneof_reader<T> ret;
|
||||
ret.add(a1);
|
||||
ret.add(a2);
|
||||
ret.add(a3);
|
||||
ret.add(a4);
|
||||
ret.add(a5);
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
oneof_reader<T> oneof(T a1, T a2, T a3, T a4, T a5, T a6)
|
||||
{
|
||||
oneof_reader<T> ret;
|
||||
ret.add(a1);
|
||||
ret.add(a2);
|
||||
ret.add(a3);
|
||||
ret.add(a4);
|
||||
ret.add(a5);
|
||||
ret.add(a6);
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
oneof_reader<T> oneof(T a1, T a2, T a3, T a4, T a5, T a6, T a7)
|
||||
{
|
||||
oneof_reader<T> ret;
|
||||
ret.add(a1);
|
||||
ret.add(a2);
|
||||
ret.add(a3);
|
||||
ret.add(a4);
|
||||
ret.add(a5);
|
||||
ret.add(a6);
|
||||
ret.add(a7);
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
oneof_reader<T> oneof(T a1, T a2, T a3, T a4, T a5, T a6, T a7, T a8)
|
||||
{
|
||||
oneof_reader<T> ret;
|
||||
ret.add(a1);
|
||||
ret.add(a2);
|
||||
ret.add(a3);
|
||||
ret.add(a4);
|
||||
ret.add(a5);
|
||||
ret.add(a6);
|
||||
ret.add(a7);
|
||||
ret.add(a8);
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
oneof_reader<T> oneof(T a1, T a2, T a3, T a4, T a5, T a6, T a7, T a8, T a9)
|
||||
{
|
||||
oneof_reader<T> ret;
|
||||
ret.add(a1);
|
||||
ret.add(a2);
|
||||
ret.add(a3);
|
||||
ret.add(a4);
|
||||
ret.add(a5);
|
||||
ret.add(a6);
|
||||
ret.add(a7);
|
||||
ret.add(a8);
|
||||
ret.add(a9);
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
oneof_reader<T> oneof(T a1, T a2, T a3, T a4, T a5, T a6, T a7, T a8, T a9, T a10)
|
||||
{
|
||||
oneof_reader<T> ret;
|
||||
ret.add(a1);
|
||||
ret.add(a2);
|
||||
ret.add(a3);
|
||||
ret.add(a4);
|
||||
ret.add(a5);
|
||||
ret.add(a6);
|
||||
ret.add(a7);
|
||||
ret.add(a8);
|
||||
ret.add(a9);
|
||||
ret.add(a10);
|
||||
return ret;
|
||||
}
|
||||
|
||||
//-----
|
||||
|
||||
class parser{
|
||||
public:
|
||||
parser(){
|
||||
}
|
||||
~parser(){
|
||||
for (std::map<std::string, option_base*>::iterator p=options.begin();
|
||||
p!=options.end(); p++)
|
||||
delete p->second;
|
||||
}
|
||||
|
||||
void add(const std::string &name,
|
||||
char short_name=0,
|
||||
const std::string &desc=""){
|
||||
if (options.count(name)) throw cmdline_error("multiple definition: "+name);
|
||||
options[name]=new option_without_value(name, short_name, desc);
|
||||
ordered.push_back(options[name]);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void add(const std::string &name,
|
||||
char short_name=0,
|
||||
const std::string &desc="",
|
||||
bool need=true,
|
||||
const T def=T()){
|
||||
add(name, short_name, desc, need, def, default_reader<T>());
|
||||
}
|
||||
|
||||
template <class T, class F>
|
||||
void add(const std::string &name,
|
||||
char short_name=0,
|
||||
const std::string &desc="",
|
||||
bool need=true,
|
||||
const T def=T(),
|
||||
F reader=F()){
|
||||
if (options.count(name)) throw cmdline_error("multiple definition: "+name);
|
||||
options[name]=new option_with_value_with_reader<T, F>(name, short_name, need, def, desc, reader);
|
||||
ordered.push_back(options[name]);
|
||||
}
|
||||
|
||||
void footer(const std::string &f){
|
||||
ftr=f;
|
||||
}
|
||||
|
||||
void set_program_name(const std::string &name){
|
||||
prog_name=name;
|
||||
}
|
||||
|
||||
bool exist(const std::string &name) const {
|
||||
if (options.count(name)==0) throw cmdline_error("there is no flag: --"+name);
|
||||
return options.find(name)->second->has_set();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
const T &get(const std::string &name) const {
|
||||
if (options.count(name)==0) throw cmdline_error("there is no flag: --"+name);
|
||||
const option_with_value<T> *p=dynamic_cast<const option_with_value<T>*>(options.find(name)->second);
|
||||
if (p==NULL) throw cmdline_error("type mismatch flag '"+name+"'");
|
||||
return p->get();
|
||||
}
|
||||
|
||||
const std::vector<std::string> &rest() const {
|
||||
return others;
|
||||
}
|
||||
|
||||
bool parse(const std::string &arg){
|
||||
std::vector<std::string> args;
|
||||
|
||||
std::string buf;
|
||||
bool in_quote=false;
|
||||
for (std::string::size_type i=0; i<arg.length(); i++){
|
||||
if (arg[i]=='\"'){
|
||||
in_quote=!in_quote;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (arg[i]==' ' && !in_quote){
|
||||
args.push_back(buf);
|
||||
buf="";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (arg[i]=='\\'){
|
||||
i++;
|
||||
if (i>=arg.length()){
|
||||
errors.push_back("unexpected occurrence of '\\' at end of string");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
buf+=arg[i];
|
||||
}
|
||||
|
||||
if (in_quote){
|
||||
errors.push_back("quote is not closed");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (buf.length()>0)
|
||||
args.push_back(buf);
|
||||
|
||||
for (size_t i=0; i<args.size(); i++)
|
||||
std::cout<<"\""<<args[i]<<"\""<<std::endl;
|
||||
|
||||
return parse(args);
|
||||
}
|
||||
|
||||
bool parse(const std::vector<std::string> &args){
|
||||
int argc=static_cast<int>(args.size());
|
||||
std::vector<const char*> argv(argc);
|
||||
|
||||
for (int i=0; i<argc; i++)
|
||||
argv[i]=args[i].c_str();
|
||||
|
||||
return parse(argc, &argv[0]);
|
||||
}
|
||||
|
||||
bool parse(int argc, const char * const argv[]){
|
||||
errors.clear();
|
||||
others.clear();
|
||||
|
||||
if (argc<1){
|
||||
errors.push_back("argument number must be longer than 0");
|
||||
return false;
|
||||
}
|
||||
if (prog_name=="")
|
||||
prog_name=argv[0];
|
||||
|
||||
std::map<char, std::string> lookup;
|
||||
for (std::map<std::string, option_base*>::iterator p=options.begin();
|
||||
p!=options.end(); p++){
|
||||
if (p->first.length()==0) continue;
|
||||
char initial=p->second->short_name();
|
||||
if (initial){
|
||||
if (lookup.count(initial)>0){
|
||||
lookup[initial]="";
|
||||
errors.push_back(std::string("short option '")+initial+"' is ambiguous");
|
||||
return false;
|
||||
}
|
||||
else lookup[initial]=p->first;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=1; i<argc; i++){
|
||||
if (strncmp(argv[i], "--", 2)==0){
|
||||
const char *p=strchr(argv[i]+2, '=');
|
||||
if (p){
|
||||
std::string name(argv[i]+2, p);
|
||||
std::string val(p+1);
|
||||
set_option(name, val);
|
||||
}
|
||||
else{
|
||||
std::string name(argv[i]+2);
|
||||
if (options.count(name)==0){
|
||||
errors.push_back("undefined option: --"+name);
|
||||
continue;
|
||||
}
|
||||
if (options[name]->has_value()){
|
||||
if (i+1>=argc){
|
||||
errors.push_back("option needs value: --"+name);
|
||||
continue;
|
||||
}
|
||||
else{
|
||||
i++;
|
||||
set_option(name, argv[i]);
|
||||
}
|
||||
}
|
||||
else{
|
||||
set_option(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (strncmp(argv[i], "-", 1)==0){
|
||||
if (!argv[i][1]) continue;
|
||||
char last=argv[i][1];
|
||||
for (int j=2; argv[i][j]; j++){
|
||||
last=argv[i][j];
|
||||
if (lookup.count(argv[i][j-1])==0){
|
||||
errors.push_back(std::string("undefined short option: -")+argv[i][j-1]);
|
||||
continue;
|
||||
}
|
||||
if (lookup[argv[i][j-1]]==""){
|
||||
errors.push_back(std::string("ambiguous short option: -")+argv[i][j-1]);
|
||||
continue;
|
||||
}
|
||||
set_option(lookup[argv[i][j-1]]);
|
||||
}
|
||||
|
||||
if (lookup.count(last)==0){
|
||||
errors.push_back(std::string("undefined short option: -")+last);
|
||||
continue;
|
||||
}
|
||||
if (lookup[last]==""){
|
||||
errors.push_back(std::string("ambiguous short option: -")+last);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i+1<argc && options[lookup[last]]->has_value()){
|
||||
set_option(lookup[last], argv[i+1]);
|
||||
i++;
|
||||
}
|
||||
else{
|
||||
set_option(lookup[last]);
|
||||
}
|
||||
}
|
||||
else{
|
||||
others.push_back(argv[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for (std::map<std::string, option_base*>::iterator p=options.begin();
|
||||
p!=options.end(); p++)
|
||||
if (!p->second->valid())
|
||||
errors.push_back("need option: --"+std::string(p->first));
|
||||
|
||||
return errors.size()==0;
|
||||
}
|
||||
|
||||
void parse_check(const std::string &arg){
|
||||
if (!options.count("help"))
|
||||
add("help", '?', "print this message");
|
||||
check(0, parse(arg));
|
||||
}
|
||||
|
||||
void parse_check(const std::vector<std::string> &args){
|
||||
if (!options.count("help"))
|
||||
add("help", '?', "print this message");
|
||||
check(args.size(), parse(args));
|
||||
}
|
||||
|
||||
void parse_check(int argc, char *argv[]){
|
||||
if (!options.count("help"))
|
||||
add("help", '?', "print this message");
|
||||
check(argc, parse(argc, argv));
|
||||
}
|
||||
|
||||
std::string error() const{
|
||||
return errors.size()>0?errors[0]:"";
|
||||
}
|
||||
|
||||
std::string error_full() const{
|
||||
std::ostringstream oss;
|
||||
for (size_t i=0; i<errors.size(); i++)
|
||||
oss<<errors[i]<<std::endl;
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
std::string usage() const {
|
||||
std::ostringstream oss;
|
||||
oss<<"usage: "<<prog_name<<" ";
|
||||
for (size_t i=0; i<ordered.size(); i++){
|
||||
if (ordered[i]->must())
|
||||
oss<<ordered[i]->short_description()<<" ";
|
||||
}
|
||||
|
||||
oss<<"[options] ... "<<ftr<<std::endl;
|
||||
oss<<"options:"<<std::endl;
|
||||
|
||||
size_t max_width=0;
|
||||
for (size_t i=0; i<ordered.size(); i++){
|
||||
max_width=std::max(max_width, ordered[i]->name().length());
|
||||
}
|
||||
for (size_t i=0; i<ordered.size(); i++){
|
||||
if (ordered[i]->short_name()){
|
||||
oss<<" -"<<ordered[i]->short_name()<<", ";
|
||||
}
|
||||
else{
|
||||
oss<<" ";
|
||||
}
|
||||
|
||||
oss<<"--"<<ordered[i]->name();
|
||||
for (size_t j=ordered[i]->name().length(); j<max_width+4; j++)
|
||||
oss<<' ';
|
||||
oss<<ordered[i]->description()<<std::endl;
|
||||
}
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void check(int argc, bool ok){
|
||||
if ((argc==1 && !ok) || exist("help")){
|
||||
std::cerr<<usage();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (!ok){
|
||||
std::cerr<<error()<<std::endl<<usage();
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
void set_option(const std::string &name){
|
||||
if (options.count(name)==0){
|
||||
errors.push_back("undefined option: --"+name);
|
||||
return;
|
||||
}
|
||||
if (!options[name]->set()){
|
||||
errors.push_back("option needs value: --"+name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void set_option(const std::string &name, const std::string &value){
|
||||
if (options.count(name)==0){
|
||||
errors.push_back("undefined option: --"+name);
|
||||
return;
|
||||
}
|
||||
if (!options[name]->set(value)){
|
||||
errors.push_back("option value is invalid: --"+name+"="+value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
class option_base{
|
||||
public:
|
||||
virtual ~option_base(){}
|
||||
|
||||
virtual bool has_value() const=0;
|
||||
virtual bool set()=0;
|
||||
virtual bool set(const std::string &value)=0;
|
||||
virtual bool has_set() const=0;
|
||||
virtual bool valid() const=0;
|
||||
virtual bool must() const=0;
|
||||
|
||||
virtual const std::string &name() const=0;
|
||||
virtual char short_name() const=0;
|
||||
virtual const std::string &description() const=0;
|
||||
virtual std::string short_description() const=0;
|
||||
};
|
||||
|
||||
class option_without_value : public option_base {
|
||||
public:
|
||||
option_without_value(const std::string &name,
|
||||
char short_name,
|
||||
const std::string &desc)
|
||||
:nam(name), snam(short_name), desc(desc), has(false){
|
||||
}
|
||||
~option_without_value(){}
|
||||
|
||||
bool has_value() const { return false; }
|
||||
|
||||
bool set(){
|
||||
has=true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool set(const std::string &){
|
||||
return false;
|
||||
}
|
||||
|
||||
bool has_set() const {
|
||||
return has;
|
||||
}
|
||||
|
||||
bool valid() const{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool must() const{
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::string &name() const{
|
||||
return nam;
|
||||
}
|
||||
|
||||
char short_name() const{
|
||||
return snam;
|
||||
}
|
||||
|
||||
const std::string &description() const {
|
||||
return desc;
|
||||
}
|
||||
|
||||
std::string short_description() const{
|
||||
return "--"+nam;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string nam;
|
||||
char snam;
|
||||
std::string desc;
|
||||
bool has;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class option_with_value : public option_base {
|
||||
public:
|
||||
option_with_value(const std::string &name,
|
||||
char short_name,
|
||||
bool need,
|
||||
const T &def,
|
||||
const std::string &desc)
|
||||
: nam(name), snam(short_name), need(need), has(false)
|
||||
, def(def), actual(def) {
|
||||
this->desc=full_description(desc);
|
||||
}
|
||||
~option_with_value(){}
|
||||
|
||||
const T &get() const {
|
||||
return actual;
|
||||
}
|
||||
|
||||
bool has_value() const { return true; }
|
||||
|
||||
bool set(){
|
||||
return false;
|
||||
}
|
||||
|
||||
bool set(const std::string &value){
|
||||
try{
|
||||
actual=read(value);
|
||||
has=true;
|
||||
}
|
||||
catch(const std::exception &){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool has_set() const{
|
||||
return has;
|
||||
}
|
||||
|
||||
bool valid() const{
|
||||
if (need && !has) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool must() const{
|
||||
return need;
|
||||
}
|
||||
|
||||
const std::string &name() const{
|
||||
return nam;
|
||||
}
|
||||
|
||||
char short_name() const{
|
||||
return snam;
|
||||
}
|
||||
|
||||
const std::string &description() const {
|
||||
return desc;
|
||||
}
|
||||
|
||||
std::string short_description() const{
|
||||
return "--"+nam+"="+detail::readable_typename<T>();
|
||||
}
|
||||
|
||||
protected:
|
||||
std::string full_description(const std::string &desc){
|
||||
return
|
||||
desc+" ("+detail::readable_typename<T>()+
|
||||
(need?"":" [="+detail::default_value<T>(def)+"]")
|
||||
+")";
|
||||
}
|
||||
|
||||
virtual T read(const std::string &s)=0;
|
||||
|
||||
std::string nam;
|
||||
char snam;
|
||||
bool need;
|
||||
std::string desc;
|
||||
|
||||
bool has;
|
||||
T def;
|
||||
T actual;
|
||||
};
|
||||
|
||||
template <class T, class F>
|
||||
class option_with_value_with_reader : public option_with_value<T> {
|
||||
public:
|
||||
option_with_value_with_reader(const std::string &name,
|
||||
char short_name,
|
||||
bool need,
|
||||
const T def,
|
||||
const std::string &desc,
|
||||
F reader)
|
||||
: option_with_value<T>(name, short_name, need, def, desc), reader(reader){
|
||||
}
|
||||
|
||||
private:
|
||||
T read(const std::string &s){
|
||||
return reader(s);
|
||||
}
|
||||
|
||||
F reader;
|
||||
};
|
||||
|
||||
std::map<std::string, option_base*> options;
|
||||
std::vector<option_base*> ordered;
|
||||
std::string ftr;
|
||||
|
||||
std::string prog_name;
|
||||
std::vector<std::string> others;
|
||||
|
||||
std::vector<std::string> errors;
|
||||
};
|
||||
|
||||
} // cmdline
|
||||
+48
-106
@@ -26,6 +26,7 @@
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include "logging.h"
|
||||
|
||||
using std::lock_guard;
|
||||
@@ -33,101 +34,37 @@ using std::mutex;
|
||||
using std::vector;
|
||||
using std::chrono::steady_clock;
|
||||
|
||||
|
||||
namespace livox {
|
||||
|
||||
bool IOLoop::Init() {
|
||||
if (mem_pool_ == NULL) {
|
||||
auto multiple_io = MultipleIOFactory::CreateMultipleIO();
|
||||
if (!multiple_io) {
|
||||
LOG_ERROR("Creat Multiple IO Failed!");
|
||||
return false;
|
||||
}
|
||||
|
||||
apr_status_t rv =
|
||||
apr_pollset_create(&pollset_, kMaxPollCount, mem_pool_, APR_POLLSET_WAKEABLE);
|
||||
|
||||
if (rv != APR_SUCCESS) {
|
||||
LOG_ERROR(PrintAPRStatus(rv));
|
||||
multiple_io_base_ = std::move(multiple_io);
|
||||
if (!multiple_io_base_->PollCreate(OPEN_MAX_POLL)) {
|
||||
LOG_ERROR("Poll Create Failed!");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void IOLoop::Uninit() {
|
||||
if (pollset_) {
|
||||
apr_pollset_destroy(pollset_);
|
||||
pollset_ = NULL;
|
||||
}
|
||||
|
||||
for (DelegatesType::const_iterator ite = delegates_.begin(); ite != delegates_.end(); ++ite) {
|
||||
ClientData *data = ite->second;
|
||||
if (data) {
|
||||
delete data;
|
||||
}
|
||||
}
|
||||
|
||||
delegates_.clear();
|
||||
mem_pool_ = NULL;
|
||||
multiple_io_base_->PollDestroy();
|
||||
}
|
||||
|
||||
void IOLoop::AddDelegate(apr_socket_t *sock, IOLoop::IOLoopDelegate *delegate, void *data) {
|
||||
void IOLoop::AddDelegate(socket_t sock, IOLoop::IOLoopDelegate *delegate, void *data) {
|
||||
PostTask(std::bind(&IOLoop::AddDelegateAsync, this, sock, delegate, data));
|
||||
}
|
||||
|
||||
void IOLoop::RemoveDelegate(apr_socket_t *sock, IOLoopDelegate *) {
|
||||
void IOLoop::RemoveDelegate(socket_t sock, IOLoopDelegate *) {
|
||||
PostTask(std::bind(&IOLoop::RemoveDelegateAsync, this, sock));
|
||||
}
|
||||
|
||||
void IOLoop::RemoveDelegateSync(apr_socket_t *sock) {
|
||||
assert(apr_os_thread_equal(this->thread_id_, apr_os_thread_current()));
|
||||
RemoveDelegateAsync(sock);
|
||||
}
|
||||
|
||||
void IOLoop::Loop() {
|
||||
apr_int32_t num = 0;
|
||||
const apr_pollfd_t *ret_pfd = NULL;
|
||||
apr_status_t rv = apr_pollset_poll(pollset_, apr_time_from_msec(50), &num, &ret_pfd);
|
||||
|
||||
if (rv == APR_SUCCESS) {
|
||||
for (int i = 0; i < num; i++) {
|
||||
ClientData *data = static_cast<ClientData *>(ret_pfd[i].client_data);
|
||||
if (data) {
|
||||
IOLoopDelegate *delegate = data->first;
|
||||
if (delegate) {
|
||||
delegate->OnData(ret_pfd[i].desc.s, data->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (enable_wake_ && APR_STATUS_IS_EINTR(rv)) {
|
||||
DelegatesType delegates = delegates_;
|
||||
for (DelegatesType::const_iterator ite = delegates.begin(); ite != delegates.end(); ++ite) {
|
||||
ClientData *data = ite->second;
|
||||
if (data) {
|
||||
IOLoopDelegate *delegate = data->first;
|
||||
if (delegate) {
|
||||
delegate->OnWake();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (enable_timer_) {
|
||||
TimePoint t = steady_clock::now();;
|
||||
if (last_timeout_ == TimePoint() || t - last_timeout_ > std::chrono::milliseconds(50)) {
|
||||
last_timeout_ = t;
|
||||
// copy delegates_ in case delegate is removed in callback.
|
||||
DelegatesType delegates = delegates_;
|
||||
for (DelegatesType::const_iterator ite = delegates.begin(); ite != delegates.end(); ++ite) {
|
||||
ClientData *data = ite->second;
|
||||
if (data) {
|
||||
IOLoopDelegate *delegate = data->first;
|
||||
if (delegate) {
|
||||
delegate->OnTimer(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
multiple_io_base_->Poll(POLL_TIMEOUT);
|
||||
|
||||
vector<IOLoopTask> tasks;
|
||||
{
|
||||
@@ -135,24 +72,17 @@ void IOLoop::Loop() {
|
||||
tasks.swap(pending_tasks_);
|
||||
}
|
||||
|
||||
for (vector<IOLoopTask>::iterator ite = tasks.begin(); ite != tasks.end(); ++ite) {
|
||||
IOLoopTask &task = *ite;
|
||||
for (auto &task : tasks) {
|
||||
task();
|
||||
}
|
||||
|
||||
if (rv != APR_SUCCESS && !APR_STATUS_IS_TIMEUP(rv) && !APR_STATUS_IS_EINTR(rv)) {
|
||||
LOG_ERROR(PrintAPRStatus(rv));
|
||||
}
|
||||
}
|
||||
|
||||
bool IOLoop::Wakeup() {
|
||||
apr_status_t rv = apr_pollset_wakeup(pollset_);
|
||||
if (rv != APR_SUCCESS) {
|
||||
LOG_ERROR(PrintAPRStatus(rv));
|
||||
return false;
|
||||
bool IOLoop::Wakeup() {
|
||||
if (multiple_io_base_) {
|
||||
multiple_io_base_->PollWakeUp();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void IOLoop::PostTask(const IOLoopTask &task) {
|
||||
{
|
||||
@@ -162,27 +92,39 @@ void IOLoop::PostTask(const IOLoopTask &task) {
|
||||
Wakeup();
|
||||
}
|
||||
|
||||
void IOLoop::AddDelegateAsync(apr_socket_t *sock, IOLoop::IOLoopDelegate *delegate, void *data) {
|
||||
ClientData *p = new ClientData(delegate, data);
|
||||
apr_pollfd_t pfd = {mem_pool_, APR_POLL_SOCKET, APR_POLLIN, 0, {NULL}, p};
|
||||
pfd.desc.s = sock;
|
||||
apr_pollset_add(pollset_, &pfd);
|
||||
delegates_[sock] = p;
|
||||
void IOLoop::AddDelegateAsync(socket_t sock, IOLoop::IOLoopDelegate *delegate, void *data) {
|
||||
PollFd pollfd = {};
|
||||
pollfd.fd = sock;
|
||||
pollfd.event = READBLE_EVENT;
|
||||
pollfd.event_callback = [=](FdEvent event) {
|
||||
if (event & READBLE_EVENT) {
|
||||
if (delegate) {
|
||||
delegate->OnData(sock, data);
|
||||
}
|
||||
}
|
||||
};
|
||||
if (enable_timer_) {
|
||||
pollfd.timer_callback = [=](TimePoint t) {
|
||||
if (delegate) {
|
||||
delegate->OnTimer(t);
|
||||
}
|
||||
};
|
||||
}
|
||||
if (enable_wake_) {
|
||||
pollfd.wake_callback = [=]() {
|
||||
if (delegate) {
|
||||
delegate->OnWake();
|
||||
}
|
||||
};
|
||||
}
|
||||
multiple_io_base_->PollSetAdd(pollfd);
|
||||
}
|
||||
|
||||
void IOLoop::RemoveDelegateAsync(apr_socket_t *sock) {
|
||||
apr_pollfd_t pfd = {mem_pool_, APR_POLL_SOCKET, 0, 0, {NULL}, NULL};
|
||||
pfd.desc.s = sock;
|
||||
apr_pollset_remove(pollset_, &pfd);
|
||||
|
||||
DelegatesType::iterator ite = delegates_.find(sock);
|
||||
if (ite != delegates_.end()) {
|
||||
ClientData *p = ite->second;
|
||||
if (p) {
|
||||
delete p;
|
||||
}
|
||||
delegates_.erase(ite);
|
||||
}
|
||||
void IOLoop::RemoveDelegateAsync(socket_t sock) {
|
||||
PollFd pollfd = {};
|
||||
pollfd.fd = sock;
|
||||
pollfd.event = READBLE_EVENT;
|
||||
multiple_io_base_->PollSetRemove(pollfd);
|
||||
}
|
||||
|
||||
} // namespace livox
|
||||
|
||||
+19
-27
@@ -30,61 +30,53 @@
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include "apr_general.h"
|
||||
#include "apr_network_io.h"
|
||||
#include "apr_poll.h"
|
||||
#include "apr_thread_proc.h"
|
||||
#include <algorithm>
|
||||
#include "command_callback.h"
|
||||
#include "noncopyable.h"
|
||||
#include "thread_base.h"
|
||||
#include "util.h"
|
||||
#include "multiple_io/multiple_io_base.h"
|
||||
#include "multiple_io/multiple_io_factory.h"
|
||||
|
||||
namespace livox {
|
||||
|
||||
#define OPEN_MAX_POLL 48
|
||||
#define POLL_TIMEOUT 50 //ms
|
||||
typedef int socket_t;
|
||||
|
||||
class IOLoop : public noncopyable {
|
||||
public:
|
||||
typedef std::chrono::steady_clock::time_point TimePoint;
|
||||
typedef std::function<void(void)> IOLoopTask;
|
||||
|
||||
class IOLoopDelegate {
|
||||
public:
|
||||
virtual void OnData(apr_socket_t *, void *) {}
|
||||
virtual void OnTimer(TimePoint) {}
|
||||
virtual void OnData(socket_t, void *) {}
|
||||
virtual void OnTimer(std::chrono::steady_clock::time_point) {}
|
||||
virtual void OnWake() {}
|
||||
};
|
||||
|
||||
typedef std::function<void(void)> IOLoopTask;
|
||||
|
||||
public:
|
||||
explicit IOLoop(apr_pool_t *mem_pool, bool enable_timer = true, bool enable_wake = true)
|
||||
: pollset_(NULL), mem_pool_(mem_pool), last_timeout_(), enable_timer_(enable_timer), enable_wake_(enable_wake){};
|
||||
explicit IOLoop(bool enable_timer = true, bool enable_wake = true)
|
||||
: enable_timer_(enable_timer), enable_wake_(enable_wake){};
|
||||
|
||||
|
||||
bool Init();
|
||||
void Uninit();
|
||||
void AddDelegate(apr_socket_t *sock, IOLoopDelegate *delegate, void *data = NULL);
|
||||
void RemoveDelegate(apr_socket_t *sock, IOLoopDelegate *delegate);
|
||||
void RemoveDelegateSync(apr_socket_t *sock);
|
||||
void AddDelegate(socket_t sock, IOLoopDelegate *delegate, void *data = NULL);
|
||||
void RemoveDelegate(socket_t sock, IOLoopDelegate *delegate);
|
||||
void Loop();
|
||||
bool Wakeup();
|
||||
void PostTask(const IOLoopTask &task);
|
||||
void SetThreadId (apr_os_thread_t thread_id) { thread_id_ = thread_id; }
|
||||
apr_os_thread_t GetThreadId () { return thread_id_; }
|
||||
|
||||
private:
|
||||
void AddDelegateAsync(apr_socket_t *sock, IOLoopDelegate *delegate, void *data);
|
||||
void RemoveDelegateAsync(apr_socket_t *sock);
|
||||
void AddDelegateAsync(socket_t sock, IOLoopDelegate *delegate, void *data);
|
||||
void RemoveDelegateAsync(socket_t sock);
|
||||
|
||||
private:
|
||||
static const apr_uint32_t kMaxPollCount = 48;
|
||||
typedef std::pair<IOLoopDelegate *, void *> ClientData;
|
||||
typedef std::unordered_map<apr_socket_t *, ClientData *> DelegatesType;
|
||||
DelegatesType delegates_;
|
||||
apr_pollset_t *pollset_;
|
||||
apr_pool_t *mem_pool_;
|
||||
TimePoint last_timeout_;
|
||||
std::mutex mutex_;
|
||||
bool enable_timer_;
|
||||
bool enable_wake_;
|
||||
std::vector<IOLoopTask> pending_tasks_;
|
||||
apr_os_thread_t thread_id_;
|
||||
std::unique_ptr<MultipleIOBase> multiple_io_base_;
|
||||
};
|
||||
|
||||
} // namespace livox
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
//
|
||||
|
||||
#include "io_thread.h"
|
||||
#include "apr_pools.h"
|
||||
|
||||
namespace livox {
|
||||
|
||||
@@ -32,11 +31,9 @@ void IOThread::Join() {
|
||||
}
|
||||
|
||||
void IOThread::ThreadFunc() {
|
||||
if (loop_ == NULL) {
|
||||
if (!loop_) {
|
||||
return;
|
||||
}
|
||||
apr_os_thread_t thread_id = apr_os_thread_current();
|
||||
loop_->SetThreadId(thread_id);
|
||||
|
||||
while (!IsQuit()) {
|
||||
loop_->Loop();
|
||||
@@ -48,14 +45,13 @@ bool IOThread::Init(bool enable_timer, bool enable_wake) {
|
||||
return false;
|
||||
}
|
||||
|
||||
loop_.reset(new IOLoop(pool_, enable_timer, enable_wake));
|
||||
loop_ = std::make_shared<IOLoop>(enable_timer, enable_wake);
|
||||
return loop_->Init();
|
||||
}
|
||||
|
||||
void IOThread::Uninit() {
|
||||
if (loop_) {
|
||||
loop_->Uninit();
|
||||
loop_.reset(NULL);
|
||||
}
|
||||
ThreadBase::Uninit();
|
||||
}
|
||||
|
||||
@@ -37,11 +37,11 @@ class IOThread : public ThreadBase {
|
||||
void Join();
|
||||
void Uninit();
|
||||
|
||||
IOLoop *loop() { return loop_.get(); }
|
||||
std::weak_ptr<IOLoop> loop() { return loop_; }
|
||||
void ThreadFunc();
|
||||
|
||||
private:
|
||||
std::unique_ptr<IOLoop> loop_;
|
||||
std::shared_ptr<IOLoop> loop_;
|
||||
};
|
||||
} // namespace livox
|
||||
#endif // LIVOX_IO_THREAD_H_
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2019 Livox. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
|
||||
#include "multiple_io_base.h"
|
||||
|
||||
namespace livox {
|
||||
|
||||
void MultipleIOBase::CheckTimer() {
|
||||
TimePoint t = std::chrono::steady_clock::now();
|
||||
if (t - last_timeout_ > std::chrono::milliseconds(50)) {
|
||||
last_timeout_ = t;
|
||||
for (auto & descriptor : descriptors_) {
|
||||
PollFd pollfd = descriptor.second;
|
||||
if (pollfd.timer_callback) {
|
||||
pollfd.timer_callback(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MultipleIOBase::WakeUpInit() {
|
||||
//Initialize wake up pipe
|
||||
wake_up_pipe_.reset(new WakeUpPipe());
|
||||
wake_up_pipe_->PipeCreate();
|
||||
//register wake_fd to multiple io
|
||||
PollFd wake_fd = {};
|
||||
wake_fd.fd = wake_up_pipe_->GetPipeOut();
|
||||
wake_fd.event = READBLE_EVENT;
|
||||
wake_fd.event_callback = [this](FdEvent event) {
|
||||
if (event & READBLE_EVENT) {
|
||||
if (wake_up_pipe_) {
|
||||
wake_up_pipe_->Drain();
|
||||
}
|
||||
for (auto & descriptor : descriptors_) {
|
||||
PollFd pollfd = descriptor.second;
|
||||
if (pollfd.wake_callback) {
|
||||
pollfd.wake_callback();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
PollSetAdd(wake_fd);
|
||||
}
|
||||
|
||||
void MultipleIOBase::WakeUpUninit() {
|
||||
PollFd wake_fd = {};
|
||||
wake_fd.fd = wake_up_pipe_->GetPipeOut();
|
||||
wake_fd.event = READBLE_EVENT | WRITABLE_EVENT;
|
||||
PollSetRemove(wake_fd);
|
||||
if (wake_up_pipe_) {
|
||||
wake_up_pipe_->PipeDestroy();
|
||||
wake_up_pipe_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void MultipleIOBase::PollWakeUp() {
|
||||
if (wake_up_pipe_) {
|
||||
wake_up_pipe_->WakeUp();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
} // namespace livox
|
||||
@@ -0,0 +1,73 @@
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2019 Livox. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
|
||||
#ifndef MULTIPLE_IO_BASE_H_
|
||||
#define MULTIPLE_IO_BASE_H_
|
||||
|
||||
#include <map>
|
||||
#include <functional>
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
#include "base/wake_up/wake_up_pipe.h"
|
||||
|
||||
namespace livox {
|
||||
|
||||
#define NONE_EVENT 0 /* No events registered. */
|
||||
#define READBLE_EVENT 1 /* when descriptor is readable. */
|
||||
#define WRITABLE_EVENT 2 /* when descriptor is writeable. */
|
||||
|
||||
typedef std::chrono::steady_clock::time_point TimePoint;
|
||||
typedef int FdEvent;
|
||||
|
||||
typedef struct {
|
||||
int fd; /* File descriptor. */
|
||||
FdEvent event; /* Read | Write Event to listen. */
|
||||
std::function<void(FdEvent)> event_callback; /* Read or Write Event Callback. */
|
||||
std::function<void(TimePoint)> timer_callback; /* Timer Event Callback. */
|
||||
std::function<void()> wake_callback; /* WakeUp Event Callback. */
|
||||
} PollFd;
|
||||
|
||||
class MultipleIOBase {
|
||||
public:
|
||||
MultipleIOBase() = default;
|
||||
virtual ~MultipleIOBase() = default;
|
||||
virtual bool PollCreate(int size) = 0;
|
||||
virtual void PollDestroy() = 0;
|
||||
virtual bool PollSetAdd(PollFd poll_fd) = 0;
|
||||
virtual bool PollSetRemove(PollFd poll_fd) = 0;
|
||||
virtual void Poll(int timeout) = 0;
|
||||
virtual void PollWakeUp();
|
||||
protected:
|
||||
virtual void CheckTimer();
|
||||
std::map<int, PollFd> descriptors_;
|
||||
TimePoint last_timeout_ = TimePoint();
|
||||
|
||||
virtual void WakeUpInit();
|
||||
virtual void WakeUpUninit();
|
||||
std::unique_ptr<WakeUpPipe> wake_up_pipe_;
|
||||
};
|
||||
|
||||
} // namespace livox
|
||||
|
||||
#endif // MULTIPLE_IO_BASE_H_
|
||||
@@ -0,0 +1,107 @@
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2019 Livox. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
|
||||
#include "multiple_io_epoll.h"
|
||||
#ifdef HAVE_EPOLL
|
||||
namespace livox {
|
||||
|
||||
int GetEvent (FdEvent event) {
|
||||
FdEvent rv = 0;
|
||||
if (event & READBLE_EVENT)
|
||||
rv |= EPOLLIN;
|
||||
if (event & WRITABLE_EVENT)
|
||||
rv |= EPOLLOUT;
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool MultipleIOEpoll::PollCreate(int size) {
|
||||
max_poll_size_ = size + 1;
|
||||
epoll_fd_ = epoll_create(max_poll_size_);
|
||||
if (epoll_fd_ < 0) {
|
||||
return false;
|
||||
}
|
||||
pollset_.reset(new struct epoll_event[size]);
|
||||
WakeUpInit();
|
||||
return true;
|
||||
}
|
||||
|
||||
void MultipleIOEpoll::PollDestroy() {
|
||||
WakeUpUninit();
|
||||
if (epoll_fd_ > 0) {
|
||||
close(epoll_fd_);
|
||||
epoll_fd_ = -1;
|
||||
}
|
||||
}
|
||||
|
||||
bool MultipleIOEpoll::PollSetAdd(PollFd poll_fd) {
|
||||
if (max_poll_size_ <= (int)descriptors_.size()) {
|
||||
return false;
|
||||
}
|
||||
struct epoll_event ee = {0};
|
||||
ee.events = GetEvent(poll_fd.event);
|
||||
ee.data.fd = poll_fd.fd;
|
||||
if (epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, poll_fd.fd, &ee) == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int fd = poll_fd.fd;
|
||||
descriptors_[fd] = poll_fd;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MultipleIOEpoll::PollSetRemove(PollFd poll_fd) {
|
||||
int fd = poll_fd.fd;
|
||||
struct epoll_event ee = {0};
|
||||
epoll_ctl(epoll_fd_, EPOLL_CTL_DEL, fd, &ee);
|
||||
if (descriptors_.find(fd) != descriptors_.end()) {
|
||||
descriptors_.erase(fd);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void MultipleIOEpoll::Poll(int time_out) {
|
||||
int ret = epoll_wait(epoll_fd_, pollset_.get(), (int)descriptors_.size(),
|
||||
time_out);
|
||||
if (ret > 0) {
|
||||
for (int i =0; i< ret; i++) {
|
||||
FdEvent fd_event = NONE_EVENT;
|
||||
if (pollset_[i].events & EPOLLIN) {
|
||||
fd_event |= READBLE_EVENT;
|
||||
}
|
||||
if (pollset_[i].events & EPOLLOUT) {
|
||||
fd_event |= WRITABLE_EVENT;
|
||||
}
|
||||
int fd = pollset_[i].data.fd;
|
||||
if (descriptors_.find(fd) != descriptors_.end()) {
|
||||
PollFd pollfd = descriptors_[fd];
|
||||
pollfd.event_callback(fd_event);
|
||||
}
|
||||
}
|
||||
}
|
||||
CheckTimer();
|
||||
}
|
||||
|
||||
} // namespace livox
|
||||
|
||||
#endif // HAVE_EPOLL
|
||||
@@ -0,0 +1,51 @@
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2019 Livox. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
|
||||
#ifndef MULTIPLE_IO_EPOLL_H_
|
||||
#define MULTIPLE_IO_EPOLL_H_
|
||||
|
||||
#include "multiple_io_base.h"
|
||||
#include "config.h"
|
||||
#include <memory>
|
||||
|
||||
#ifdef HAVE_EPOLL
|
||||
|
||||
namespace livox {
|
||||
|
||||
class MultipleIOEpoll : public MultipleIOBase {
|
||||
public:
|
||||
bool PollCreate(int size);
|
||||
bool PollSetAdd(PollFd poll_fd);
|
||||
bool PollSetRemove(PollFd poll_fd);
|
||||
void Poll(int timeout);
|
||||
void PollDestroy();
|
||||
private:
|
||||
int epoll_fd_ = -1;
|
||||
std::unique_ptr<struct epoll_event[]> pollset_;
|
||||
int max_poll_size_ = 0;
|
||||
};
|
||||
} // namespace livox
|
||||
|
||||
#endif // HAVE_EPOLL
|
||||
#endif // MULTIPLE_IO_EPOLL_H_
|
||||
@@ -0,0 +1,56 @@
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2019 Livox. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
|
||||
#ifndef MULTIPLE_IO_FACTORY_H_
|
||||
#define MULTIPLE_IO_FACTORY_H_
|
||||
|
||||
#include "multiple_io_base.h"
|
||||
#include "multiple_io_epoll.h"
|
||||
#include "multiple_io_kqueue.h"
|
||||
#include "multiple_io_select.h"
|
||||
#include "multiple_io_poll.h"
|
||||
#include <memory>
|
||||
|
||||
namespace livox {
|
||||
|
||||
class MultipleIOFactory {
|
||||
public:
|
||||
static std::unique_ptr<MultipleIOBase> CreateMultipleIO() {
|
||||
#if defined(HAVE_EPOLL)
|
||||
return std::unique_ptr<MultipleIOBase>(new MultipleIOEpoll());
|
||||
#elif defined(HAVE_KQUEUE)
|
||||
return std::unique_ptr<MultipleIOBase>(new MultipleIOKqueue());
|
||||
#elif defined(HAVE_SELECT)
|
||||
return std::unique_ptr<MultipleIOBase>(new MultipleIOSelect());
|
||||
#elif defined(HAVE_POLL)
|
||||
return std::unique_ptr<MultipleIOBase>(new MultipleIOPoll());
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace livox
|
||||
|
||||
#endif // MULTIPLE_IO_FACTORY_H_
|
||||
@@ -0,0 +1,135 @@
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2019 Livox. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
|
||||
#include "multiple_io_kqueue.h"
|
||||
#ifdef HAVE_KQUEUE
|
||||
|
||||
namespace livox {
|
||||
|
||||
bool MultipleIOKqueue::PollCreate(int size) {
|
||||
kqueue_fd_ = kqueue();
|
||||
if (kqueue_fd_ == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int flags = 0;
|
||||
if ((flags = fcntl(kqueue_fd_, F_GETFD)) == -1) {
|
||||
close(kqueue_fd_);
|
||||
return false;
|
||||
}
|
||||
flags |= FD_CLOEXEC;
|
||||
if (fcntl(kqueue_fd_, F_SETFD, flags) == -1) {
|
||||
close(kqueue_fd_);
|
||||
return false;
|
||||
}
|
||||
max_poll_size_ = size + 1;
|
||||
set_size_ = 2 * max_poll_size_;
|
||||
kevent_set_.reset(new struct kevent[set_size_]);
|
||||
WakeUpInit();
|
||||
return true;
|
||||
}
|
||||
|
||||
void MultipleIOKqueue::PollDestroy() {
|
||||
WakeUpUninit();
|
||||
if (kqueue_fd_ > 0) {
|
||||
close(kqueue_fd_);
|
||||
kqueue_fd_ = -1;
|
||||
}
|
||||
}
|
||||
|
||||
bool MultipleIOKqueue::PollSetAdd(PollFd poll_fd) {
|
||||
if (max_poll_size_ <= (int)descriptors_.size()) {
|
||||
return false;
|
||||
}
|
||||
int fd = poll_fd.fd;
|
||||
descriptors_[fd] = poll_fd;
|
||||
if (poll_fd.event & READBLE_EVENT) {
|
||||
EV_SET(&kevent_, fd, EVFILT_READ, EV_ADD, 0, 0, &descriptors_[fd].fd);
|
||||
if (kevent(kqueue_fd_, &kevent_, 1, nullptr, 0, nullptr) == -1) {
|
||||
descriptors_.erase(fd);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (poll_fd.event & WRITABLE_EVENT) {
|
||||
EV_SET(&kevent_, fd, EVFILT_WRITE, EV_ADD, 0, 0, &descriptors_[fd].fd);
|
||||
if (kevent(kqueue_fd_, &kevent_, 1, nullptr, 0, nullptr) == -1) {
|
||||
descriptors_.erase(fd);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MultipleIOKqueue::PollSetRemove(PollFd poll_fd) {
|
||||
int fd = poll_fd.fd;
|
||||
if (descriptors_.find(fd) != descriptors_.end()) {
|
||||
if (descriptors_[fd].event & READBLE_EVENT) {
|
||||
EV_SET(&kevent_, fd, EVFILT_READ, EV_DELETE, 0, 0, NULL);
|
||||
if (kevent(kqueue_fd_, &kevent_, 1, nullptr, 0, nullptr) == -1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (descriptors_[fd].event & WRITABLE_EVENT) {
|
||||
EV_SET(&kevent_, fd, EVFILT_WRITE, EV_DELETE, 0, 0, NULL);
|
||||
if (kevent(kqueue_fd_, &kevent_, 1, nullptr, 0, nullptr) == -1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
descriptors_.erase(fd);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void MultipleIOKqueue::Poll(int time_out) {
|
||||
struct timespec tv, *tvptr;
|
||||
|
||||
if (time_out < 0) {
|
||||
tvptr = NULL;
|
||||
} else {
|
||||
tv.tv_sec = (long) time_out / 1000;
|
||||
tv.tv_nsec = (long) (time_out % 1000) * 1000000;
|
||||
tvptr = &tv;
|
||||
}
|
||||
|
||||
int rv = kevent(kqueue_fd_, NULL, 0, kevent_set_.get(), set_size_, tvptr);
|
||||
if (rv > 0) {
|
||||
for (int i = 0; i < rv; i++) {
|
||||
int fd = *(int *)(kevent_set_[i].udata);
|
||||
if (descriptors_.find(fd) != descriptors_.end()) {
|
||||
PollFd pollfd = descriptors_[fd];
|
||||
if (kevent_set_[i].filter == EVFILT_READ) {
|
||||
pollfd.event_callback(READBLE_EVENT);
|
||||
}
|
||||
if (kevent_set_[i].filter == EVFILT_WRITE) {
|
||||
pollfd.event_callback(WRITABLE_EVENT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
CheckTimer();
|
||||
}
|
||||
|
||||
} // namespace livox
|
||||
|
||||
#endif // HAVE_KQUEUE
|
||||
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2019 Livox. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
|
||||
#ifndef MULTIPLE_IO_KQUEUE_H_
|
||||
#define MULTIPLE_IO_KQUEUE_H_
|
||||
|
||||
#include "multiple_io_base.h"
|
||||
#include "config.h"
|
||||
#ifdef HAVE_KQUEUE
|
||||
|
||||
namespace livox {
|
||||
|
||||
class MultipleIOKqueue : public MultipleIOBase {
|
||||
public:
|
||||
bool PollCreate(int size);
|
||||
bool PollSetAdd(PollFd poll_fd);
|
||||
bool PollSetRemove(PollFd poll_fd);
|
||||
void Poll(int timeout);
|
||||
void PollDestroy();
|
||||
private:
|
||||
int kqueue_fd_ = -1;
|
||||
struct kevent kevent_ = {};
|
||||
std::unique_ptr<struct kevent[]> kevent_set_;
|
||||
int max_poll_size_ = 0;
|
||||
int set_size_ = 0;
|
||||
};
|
||||
|
||||
} // namespace livox
|
||||
|
||||
#endif // HAVE_KQUEUE
|
||||
#endif // MULTIPLE_IO_KQUEUE_H_
|
||||
@@ -0,0 +1,114 @@
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2019 Livox. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
|
||||
#include "multiple_io_poll.h"
|
||||
|
||||
#ifdef HAVE_POLL
|
||||
|
||||
namespace livox {
|
||||
|
||||
int GetEvent (FdEvent event) {
|
||||
int rv = 0;
|
||||
if (event & READBLE_EVENT)
|
||||
rv |= POLLIN;
|
||||
if (event & WRITABLE_EVENT)
|
||||
rv |= POLLOUT;
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool MultipleIOPoll:: PollCreate(int size) {
|
||||
max_poll_size_ = size + 1;
|
||||
pollset_.reset(new struct pollfd[max_poll_size_]);
|
||||
WakeUpInit();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MultipleIOPoll:: PollSetAdd(PollFd poll_fd) {
|
||||
if (max_poll_size_ <= (int)descriptors_.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int fd = poll_fd.fd;
|
||||
descriptors_[fd] = poll_fd;
|
||||
|
||||
struct pollfd fds;
|
||||
fds.fd = fd;
|
||||
fds.events = GetEvent(poll_fd.event);
|
||||
pollset_[pollset_num_] = fds;
|
||||
pollset_num_++;
|
||||
return true;
|
||||
}
|
||||
|
||||
void MultipleIOPoll::PollDestroy() {
|
||||
WakeUpUninit();
|
||||
return;
|
||||
}
|
||||
|
||||
bool MultipleIOPoll:: PollSetRemove(PollFd poll_fd) {
|
||||
int fd = poll_fd.fd;
|
||||
if (descriptors_.find(fd) != descriptors_.end()) {
|
||||
descriptors_.erase(fd);
|
||||
}
|
||||
|
||||
for (int i = 0; i< pollset_num_; i++) {
|
||||
if (pollset_[i].fd == fd) {
|
||||
int dst = i;
|
||||
for (i++; i < pollset_num_ - 1; i++) {
|
||||
if (pollset_[i].fd == fd) {
|
||||
pollset_num_--;
|
||||
} else {
|
||||
pollset_[dst] = pollset_[i];
|
||||
dst++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void MultipleIOPoll:: Poll(int time_out) {
|
||||
int rv = poll(pollset_.get(), pollset_num_, time_out);
|
||||
if (rv > 0) {
|
||||
for (int i = 0; i < pollset_num_; i++) {
|
||||
FdEvent fd_event = NONE_EVENT;
|
||||
if (pollset_[i].revents & POLLIN) {
|
||||
fd_event = | READBLE_EVENT;
|
||||
}
|
||||
if (pollset_[i].revents & POLLOUT) {
|
||||
fd_event = | WRITABLE_EVENT;
|
||||
}
|
||||
int fd = pollset_[i].fd;
|
||||
if (descriptors_.find(fd) != descriptors_.end()) {
|
||||
PollFd pollfd = descriptors_[fd];
|
||||
pollfd.event_callback(fd_event);
|
||||
}
|
||||
pollset_[i].revents = NONE_EVENT;
|
||||
}
|
||||
}
|
||||
CheckTimer();
|
||||
}
|
||||
|
||||
} // namespace livox
|
||||
|
||||
#endif // HAVE_POLL
|
||||
@@ -22,31 +22,32 @@
|
||||
// SOFTWARE.
|
||||
//
|
||||
|
||||
#include "util.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
using std::string;
|
||||
#ifndef MULTIPLE_IO_POLL_H_
|
||||
#define MULTIPLE_IO_POLL_H_
|
||||
|
||||
#include "multiple_io_base.h"
|
||||
#include "config.h"
|
||||
#include <memory>
|
||||
|
||||
|
||||
#ifdef HAVE_POLL
|
||||
|
||||
namespace livox {
|
||||
|
||||
string PrintAPRStatus(apr_status_t s) {
|
||||
char buf[128];
|
||||
apr_strerror(s, buf, sizeof(buf));
|
||||
return buf;
|
||||
}
|
||||
string PrintAPRTime(apr_time_t t) {
|
||||
char cbuf[45 + 1];
|
||||
apr_size_t sz = 45;
|
||||
apr_time_exp_t xt;
|
||||
apr_time_exp_gmt(&xt, t);
|
||||
int milli = t % 1000;
|
||||
apr_strftime(cbuf, &sz, 45, " %T.", &xt);
|
||||
string s(cbuf);
|
||||
|
||||
char buffer[33];
|
||||
sprintf(buffer, "%d", milli);
|
||||
|
||||
s += buffer;
|
||||
return s;
|
||||
}
|
||||
class MultipleIOPoll : public MultipleIOBase {
|
||||
public:
|
||||
bool PollCreate(int size);
|
||||
bool PollSetAdd(PollFd poll_fd);
|
||||
bool PollSetRemove(PollFd poll_fd);
|
||||
void Poll(int timeout);
|
||||
void PollDestroy();
|
||||
private:
|
||||
std::unique_ptr<struct pollfd[]> pollset_;
|
||||
int pollset_num_ = 0;
|
||||
int max_poll_size_ = 0;
|
||||
};
|
||||
|
||||
} // namespace livox
|
||||
|
||||
#endif // HAVE_POLL
|
||||
#endif // MULTIPLE_IO_POLL_H_
|
||||
@@ -0,0 +1,121 @@
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2019 Livox. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
|
||||
#include "multiple_io_select.h"
|
||||
#include <thread>
|
||||
|
||||
#ifdef HAVE_SELECT
|
||||
namespace livox {
|
||||
|
||||
bool MultipleIOSelect:: PollCreate(int size) {
|
||||
FD_ZERO(&rfds_);
|
||||
FD_ZERO(&wfds_);
|
||||
//wake up fd + 1
|
||||
max_poll_size_ = size + 1;
|
||||
WakeUpInit();
|
||||
return true;
|
||||
}
|
||||
|
||||
void MultipleIOSelect::PollDestroy() {
|
||||
WakeUpUninit();
|
||||
FD_ZERO(&rfds_);
|
||||
FD_ZERO(&wfds_);
|
||||
}
|
||||
|
||||
bool MultipleIOSelect:: PollSetAdd(PollFd poll_fd) {
|
||||
if (max_poll_size_ <= (int)descriptors_.size()) {
|
||||
return false;
|
||||
}
|
||||
int fd = poll_fd.fd;
|
||||
descriptors_[fd] = poll_fd;
|
||||
if (max_fd_ < fd) {
|
||||
max_fd_ = fd;
|
||||
}
|
||||
if (poll_fd.event & READBLE_EVENT) {
|
||||
FD_SET(fd, &rfds_);
|
||||
}
|
||||
if (poll_fd.event & WRITABLE_EVENT) {
|
||||
FD_SET(fd, &wfds_);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MultipleIOSelect:: PollSetRemove(PollFd poll_fd) {
|
||||
int fd = poll_fd.fd;
|
||||
if (descriptors_.find(fd) != descriptors_.end()) {
|
||||
descriptors_.erase(fd);
|
||||
}
|
||||
FD_CLR(fd, &rfds_);
|
||||
FD_CLR(fd, &wfds_);
|
||||
if (max_fd_ <= fd) {
|
||||
max_fd_--;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void MultipleIOSelect:: Poll(int time_out) {
|
||||
fd_set readset, writeset;
|
||||
struct timeval tv, *tvptr;
|
||||
if (descriptors_.size() == 0) {
|
||||
if (time_out > 0) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(time_out));
|
||||
return;
|
||||
}
|
||||
return ;
|
||||
}
|
||||
|
||||
if (time_out < 0) {
|
||||
tvptr = nullptr;
|
||||
} else {
|
||||
tv.tv_sec = (long)time_out / 1000;
|
||||
tv.tv_usec = (long)time_out % 1000;
|
||||
tvptr = &tv;
|
||||
}
|
||||
|
||||
memcpy(&readset, &rfds_, sizeof(fd_set));
|
||||
memcpy(&writeset, &wfds_, sizeof(fd_set));
|
||||
|
||||
int rv = select(max_fd_ + 1, &readset, &writeset, nullptr, tvptr);
|
||||
if (rv > 0) {
|
||||
for (auto& descriptor : descriptors_) {
|
||||
int fd = descriptor.first;
|
||||
FdEvent fd_event = NONE_EVENT;
|
||||
if (FD_ISSET(fd, &readset)) {
|
||||
fd_event |= READBLE_EVENT;
|
||||
}
|
||||
if (FD_ISSET(fd, &writeset)) {
|
||||
fd_event |= WRITABLE_EVENT;
|
||||
}
|
||||
if (fd_event != NONE_EVENT) {
|
||||
PollFd pollfd = descriptor.second;
|
||||
pollfd.event_callback(fd_event);
|
||||
}
|
||||
}
|
||||
}
|
||||
CheckTimer();
|
||||
}
|
||||
|
||||
} // namespace livox
|
||||
|
||||
#endif // HAVE_SELECT
|
||||
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2019 Livox. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
|
||||
#ifndef MULTIPLE_IO_SELECT_H_
|
||||
#define MULTIPLE_IO_SELECT_H_
|
||||
|
||||
#include "multiple_io_base.h"
|
||||
#include "config.h"
|
||||
|
||||
#ifdef HAVE_SELECT
|
||||
|
||||
namespace livox {
|
||||
|
||||
class MultipleIOSelect : public MultipleIOBase {
|
||||
public:
|
||||
bool PollCreate(int size);
|
||||
bool PollSetAdd(PollFd poll_fd);
|
||||
bool PollSetRemove(PollFd poll_fd);
|
||||
void Poll(int timeout);
|
||||
void PollDestroy();
|
||||
private:
|
||||
int max_fd_ = -1;
|
||||
fd_set rfds_;
|
||||
fd_set wfds_;
|
||||
int max_poll_size_ = 0;
|
||||
};
|
||||
|
||||
} // namespace livox
|
||||
|
||||
#endif // HAVE_SELECT
|
||||
#endif // MULTIPLE_IO_SELECT_H_
|
||||
@@ -24,19 +24,35 @@
|
||||
|
||||
#ifndef LIVOX_NETWORK_UTIL_H_
|
||||
#define LIVOX_NETWORK_UTIL_H_
|
||||
#include <apr_general.h>
|
||||
#include <apr_network_io.h>
|
||||
#ifdef WIN32
|
||||
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#ifdef WIN32
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#endif // WIN32
|
||||
#include <stdio.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
|
||||
namespace livox {
|
||||
namespace util {
|
||||
|
||||
apr_socket_t *CreateBindSocket(uint16_t port, apr_pool_t *mem_pool, bool reuse_port = false, bool nonblock = true);
|
||||
typedef int socket_t;
|
||||
|
||||
socket_t CreateSocket(uint16_t port, bool nonblock = true, bool reuse_port = true);
|
||||
|
||||
void CloseSock(socket_t sock);
|
||||
|
||||
bool FindLocalIp(const struct sockaddr_in &client_addr, uint32_t &local_ip);
|
||||
|
||||
size_t RecvFrom(socket_t &sock, void *buff, size_t buf_size, int flag, struct sockaddr *addr, int* addrlen);
|
||||
|
||||
} // namespace util
|
||||
} // namespace livox
|
||||
|
||||
#endif // LIVOX_NETWORK_UTIL_H_
|
||||
@@ -0,0 +1,124 @@
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2019 Livox. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
#ifndef WIN32
|
||||
#include "base/network/network_util.h"
|
||||
#include <ifaddrs.h>
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#include <netdb.h>
|
||||
|
||||
namespace livox {
|
||||
namespace util {
|
||||
|
||||
socket_t CreateSocket(uint16_t port, bool nonblock, bool reuse_port) {
|
||||
int status = -1;
|
||||
int on = -1;
|
||||
int sock = -1;
|
||||
struct sockaddr_in servaddr;
|
||||
|
||||
sock = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (sock < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (nonblock) {
|
||||
status = ioctl(sock, FIONBIO, (char*)&on);
|
||||
if (status != 0) {
|
||||
close(sock);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (reuse_port) {
|
||||
status = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
|
||||
(char *) &on, sizeof (on));
|
||||
if (status != 0) {
|
||||
close(sock);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
memset(&servaddr, 0, sizeof(servaddr));
|
||||
|
||||
// Filling server information
|
||||
servaddr.sin_family = AF_INET; // IPv4
|
||||
servaddr.sin_addr.s_addr = INADDR_ANY;
|
||||
servaddr.sin_port = htons(port);
|
||||
|
||||
status = bind(sock, (const struct sockaddr *)&servaddr, sizeof(servaddr));
|
||||
if (status != 0) {
|
||||
close(sock);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return sock;
|
||||
}
|
||||
|
||||
void CloseSock(int sock) {
|
||||
if (sock > 0) {
|
||||
close(sock);
|
||||
}
|
||||
}
|
||||
|
||||
bool FindLocalIp(const struct sockaddr_in &client_addr, uint32_t &local_ip) {
|
||||
struct ifaddrs *if_addrs = NULL, *addrs = NULL;
|
||||
if (getifaddrs(&if_addrs) == -1) {
|
||||
return false;
|
||||
}
|
||||
addrs = if_addrs;
|
||||
bool found = false;
|
||||
while (if_addrs != NULL) {
|
||||
if ((if_addrs->ifa_addr != NULL) && (if_addrs->ifa_addr->sa_family == AF_INET)) // check it is IP4
|
||||
{
|
||||
// is a connected IP4 Address
|
||||
struct sockaddr_in *ifu_localaddr = (struct sockaddr_in *)if_addrs->ifa_addr;
|
||||
struct sockaddr_in *ifu_netmask = (struct sockaddr_in *)if_addrs->ifa_netmask;
|
||||
if (ifu_localaddr->sin_addr.s_addr != htonl(INADDR_ANY)) {
|
||||
if ((ifu_localaddr->sin_addr.s_addr & ifu_netmask->sin_addr.s_addr) ==
|
||||
(client_addr.sin_addr.s_addr & ifu_netmask->sin_addr.s_addr)) {
|
||||
local_ip = ifu_localaddr->sin_addr.s_addr;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if_addrs = if_addrs->ifa_next;
|
||||
}
|
||||
|
||||
if (addrs) {
|
||||
freeifaddrs(addrs);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
size_t RecvFrom(socket_t &sock, void *buff, size_t buf_size, int flag, struct sockaddr *addr, int *addrlen) {
|
||||
return recvfrom(sock, buff, buf_size, 0, addr, (socklen_t *)addrlen);
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
} // namespace livox
|
||||
|
||||
#endif // WIN32
|
||||
+46
-72
@@ -22,65 +22,64 @@
|
||||
// SOFTWARE.
|
||||
//
|
||||
|
||||
#include "network_util.h"
|
||||
#ifdef WIN32
|
||||
#include "base/network/network_util.h"
|
||||
#include <memory>
|
||||
#include <Winsock2.h>
|
||||
#include <iphlpapi.h>
|
||||
#include <string>
|
||||
#pragma comment(lib,"iphlpapi.lib")
|
||||
#pragma comment(lib,"ws2_32.lib")
|
||||
#else
|
||||
#include <ifaddrs.h>
|
||||
#endif
|
||||
|
||||
namespace livox {
|
||||
namespace util {
|
||||
apr_socket_t *CreateBindSocket(uint16_t port, apr_pool_t *mem_pool, bool reuse_port, bool nonblock) {
|
||||
apr_sockaddr_t *sa = NULL;
|
||||
apr_socket_t *s = NULL;
|
||||
apr_status_t rv = APR_SUCCESS;
|
||||
|
||||
void CloseSock(socket_t sock) {
|
||||
closesocket(sock);
|
||||
}
|
||||
|
||||
|
||||
rv = apr_sockaddr_info_get(&sa, NULL, APR_INET, port, 0, mem_pool);
|
||||
if (rv != APR_SUCCESS) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rv = apr_socket_create(&s, sa->family, SOCK_DGRAM, APR_PROTO_UDP, mem_pool);
|
||||
if (rv != APR_SUCCESS) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (reuse_port) {
|
||||
rv = apr_socket_opt_set(s, APR_SO_REUSEADDR, 1);
|
||||
if (rv != APR_SUCCESS) {
|
||||
apr_socket_close(s);
|
||||
s = NULL;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
rv = apr_socket_bind(s, sa);
|
||||
if (rv != APR_SUCCESS) {
|
||||
apr_socket_close(s);
|
||||
s = NULL;
|
||||
return NULL;
|
||||
socket_t CreateSocket(uint16_t port, bool nonblock, bool reuse_port) {
|
||||
int status = -1;
|
||||
int on = -1;
|
||||
int sock = -1;
|
||||
struct sockaddr_in servaddr;
|
||||
sock = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (sock == INVALID_SOCKET) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (nonblock) {
|
||||
apr_socket_opt_set(s, APR_SO_NONBLOCK, 1);
|
||||
apr_socket_timeout_set(s, 0);
|
||||
status = ioctlsocket(sock, FIONBIO, (u_long *)&on);
|
||||
if (status != NO_ERROR) {
|
||||
closesocket(sock);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return s;
|
||||
|
||||
if (reuse_port) {
|
||||
status = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
|
||||
(char *) &on, sizeof (on));
|
||||
if (status != 0) {
|
||||
closesocket(sock);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
memset(&servaddr, 0, sizeof(servaddr));
|
||||
// Filling server information
|
||||
servaddr.sin_family = AF_INET; // IPv4
|
||||
servaddr.sin_addr.s_addr = INADDR_ANY;
|
||||
servaddr.sin_port = htons(port);
|
||||
|
||||
status = bind(sock, (const struct sockaddr *)&servaddr, sizeof(servaddr));
|
||||
if (status != 0) {
|
||||
closesocket(sock);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return sock;
|
||||
}
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
bool GetAdapterState(const IP_ADAPTER_INFO *pAdapter)
|
||||
{
|
||||
bool GetAdapterState(const IP_ADAPTER_INFO *pAdapter) {
|
||||
if(pAdapter == NULL) {
|
||||
return false;
|
||||
}
|
||||
@@ -129,37 +128,12 @@ bool FindLocalIp(const struct sockaddr_in &client_addr, uint32_t &local_ip) {
|
||||
}
|
||||
return found;
|
||||
}
|
||||
#else
|
||||
bool FindLocalIp(const struct sockaddr_in &client_addr, uint32_t &local_ip) {
|
||||
struct ifaddrs *if_addrs = NULL, *addrs = NULL;
|
||||
if (getifaddrs(&if_addrs) == -1) {
|
||||
return false;
|
||||
}
|
||||
addrs = if_addrs;
|
||||
bool found = false;
|
||||
while (if_addrs != NULL) {
|
||||
if ((if_addrs->ifa_addr != NULL) && (if_addrs->ifa_addr->sa_family == AF_INET)) // check it is IP4
|
||||
{
|
||||
// is a connected IP4 Address
|
||||
struct sockaddr_in *ifu_localaddr = (struct sockaddr_in *)if_addrs->ifa_addr;
|
||||
struct sockaddr_in *ifu_netmask = (struct sockaddr_in *)if_addrs->ifa_netmask;
|
||||
if (ifu_localaddr->sin_addr.s_addr != htonl(INADDR_ANY)) {
|
||||
if ((ifu_localaddr->sin_addr.s_addr & ifu_netmask->sin_addr.s_addr) ==
|
||||
(client_addr.sin_addr.s_addr & ifu_netmask->sin_addr.s_addr)) {
|
||||
local_ip = ifu_localaddr->sin_addr.s_addr;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if_addrs = if_addrs->ifa_next;
|
||||
}
|
||||
|
||||
if (addrs) {
|
||||
freeifaddrs(addrs);
|
||||
}
|
||||
return found;
|
||||
size_t RecvFrom(socket_t &sock, void *buff, size_t buf_size, int flag, struct sockaddr *addr, int* addrlen) {
|
||||
return recvfrom(sock, (char *)buff, buf_size, 0, addr, addrlen);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace util
|
||||
} // namespace livox
|
||||
|
||||
#endif // WIN32
|
||||
@@ -23,49 +23,30 @@
|
||||
//
|
||||
|
||||
#include "thread_base.h"
|
||||
#include <thread>
|
||||
|
||||
namespace livox {
|
||||
static void *APR_THREAD_FUNC ClassThreadHelperFunc(apr_thread_t *thd, void *data) {
|
||||
ThreadBase *caller = static_cast<ThreadBase *>(data);
|
||||
if (caller == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
caller->ThreadFunc();
|
||||
apr_thread_exit(thd, APR_SUCCESS);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ThreadBase::ThreadBase() : thread_(NULL), quit_(false), pool_(NULL) {}
|
||||
ThreadBase::ThreadBase() : quit_(false), is_thread_valid_(false) {}
|
||||
|
||||
bool ThreadBase::Start() {
|
||||
quit_ = false;
|
||||
apr_threadattr_t *thread_attr = NULL;
|
||||
apr_status_t rv = APR_SUCCESS;
|
||||
rv = apr_threadattr_create(&thread_attr, pool_);
|
||||
if (rv != APR_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
rv = apr_thread_create(&thread_, thread_attr, ClassThreadHelperFunc, this, pool_);
|
||||
return rv == APR_SUCCESS;
|
||||
thread_ = std::make_shared<std::thread>(&ThreadBase::ThreadFunc, this);
|
||||
is_thread_valid_ = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void ThreadBase::Join() {
|
||||
apr_status_t rv = APR_SUCCESS;
|
||||
if (thread_) {
|
||||
apr_thread_join(&rv, thread_);
|
||||
thread_ = NULL;
|
||||
if (is_thread_valid_) {
|
||||
thread_->join();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ThreadBase::Init() {
|
||||
return apr_pool_create(&pool_, NULL) == APR_SUCCESS;
|
||||
return true;
|
||||
}
|
||||
|
||||
void ThreadBase::Uninit() {
|
||||
if (pool_) {
|
||||
apr_pool_destroy(pool_);
|
||||
pool_ = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace livox
|
||||
|
||||
@@ -24,10 +24,8 @@
|
||||
|
||||
#ifndef LIVOX_THREAD_BASE_H_
|
||||
#define LIVOX_THREAD_BASE_H_
|
||||
#include <apr_general.h>
|
||||
#include <apr_thread_proc.h>
|
||||
#include <apr_portable.h>
|
||||
#include <atomic>
|
||||
#include <thread>
|
||||
#include "noncopyable.h"
|
||||
|
||||
namespace livox {
|
||||
@@ -45,9 +43,11 @@ class ThreadBase : public noncopyable {
|
||||
bool IsQuit() { return quit_; }
|
||||
|
||||
protected:
|
||||
apr_thread_t *thread_;
|
||||
std::shared_ptr<std::thread> thread_;
|
||||
std::atomic_bool quit_;
|
||||
apr_pool_t *pool_;
|
||||
|
||||
private:
|
||||
std::atomic_bool is_thread_valid_;
|
||||
};
|
||||
|
||||
} // namespace livox
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2019 Livox. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
|
||||
#ifndef WIN32
|
||||
#include "base/wake_up/wake_up_pipe.h"
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
namespace livox {
|
||||
|
||||
WakeUpPipe::~WakeUpPipe() {
|
||||
PipeDestroy();
|
||||
}
|
||||
|
||||
bool WakeUpPipe::WakeUp() {
|
||||
char ch = '1';
|
||||
ssize_t nbytes = sizeof(ch);
|
||||
if (pipe_in_ > 0) {
|
||||
if (nbytes != write(pipe_in_, &ch, nbytes)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WakeUpPipe::Drain() {
|
||||
char ch[512];
|
||||
size_t size = sizeof(ch);
|
||||
if (pipe_out_ > 0) {
|
||||
if (read(pipe_out_, ch, size) < 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WakeUpPipe::PipeDestroy() {
|
||||
if (pipe_in_ > 0) {
|
||||
close(pipe_in_);
|
||||
}
|
||||
if (pipe_out_ > 0) {
|
||||
close(pipe_out_);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WakeUpPipe::PipeCreate() {
|
||||
//in filedes[0]
|
||||
//out filedes[1]
|
||||
int filedes[2];
|
||||
if (pipe(filedes) == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int flags = 0;
|
||||
if ((flags = fcntl(filedes[0], F_GETFL|O_NONBLOCK)) == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
flags |= FD_CLOEXEC;
|
||||
if (fcntl(filedes[0], F_SETFL, flags) == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
flags = 0;
|
||||
if ((flags = fcntl(filedes[1], F_GETFD)) == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
flags |= FD_CLOEXEC;
|
||||
if (fcntl(filedes[1], F_SETFD, flags) == -1) {
|
||||
return false;
|
||||
}
|
||||
pipe_out_ = filedes[0];
|
||||
pipe_in_ = filedes[1];
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace livox
|
||||
|
||||
#endif // WIN32
|
||||
@@ -22,16 +22,24 @@
|
||||
// SOFTWARE.
|
||||
//
|
||||
|
||||
#ifndef LIVOX_UTIL_H_
|
||||
#define LIVOX_UTIL_H_
|
||||
#include <string>
|
||||
#include "apr_general.h"
|
||||
#include "apr_time.h"
|
||||
#ifndef WAKE_UP_PIPE_H_
|
||||
#define WAKE_UP_PIPE_H_
|
||||
|
||||
namespace livox {
|
||||
class WakeUpPipe {
|
||||
public:
|
||||
WakeUpPipe(): pipe_in_(0), pipe_out_(0) {}
|
||||
virtual ~WakeUpPipe();
|
||||
bool PipeCreate();
|
||||
bool PipeDestroy();
|
||||
bool WakeUp();
|
||||
bool Drain();
|
||||
int GetPipeOut() { return pipe_out_; }
|
||||
protected:
|
||||
int pipe_in_;
|
||||
int pipe_out_;
|
||||
};
|
||||
|
||||
std::string PrintAPRStatus(apr_status_t s);
|
||||
std::string PrintAPRTime(apr_time_t t);
|
||||
} // namespace livox
|
||||
|
||||
} // namespace livox
|
||||
#endif // LIVOX_UTIL_H_
|
||||
#endif // WAKE_UP_PIPE_H_
|
||||
@@ -0,0 +1,132 @@
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2019 Livox. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
|
||||
#ifdef WIN32
|
||||
#include "base/wake_up/wake_up_pipe.h"
|
||||
#include <fcntl.h>
|
||||
#include <winsock2.h>
|
||||
#include <stdio.h>
|
||||
#pragma comment(lib,"iphlpapi.lib")
|
||||
#pragma comment(lib,"ws2_32.lib")
|
||||
|
||||
namespace livox {
|
||||
|
||||
WakeUpPipe::~WakeUpPipe() {
|
||||
PipeDestroy();
|
||||
}
|
||||
|
||||
bool WakeUpPipe::WakeUp() {
|
||||
char ch = '1';
|
||||
size_t nbytes = sizeof(ch);
|
||||
if (pipe_in_ > 0) {
|
||||
if (nbytes != send(pipe_in_,&ch, nbytes, 0)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WakeUpPipe::Drain() {
|
||||
char ch[512];
|
||||
size_t size = sizeof(ch);
|
||||
if (pipe_out_ > 0) {
|
||||
recv(pipe_out_, ch, size, 0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WakeUpPipe::PipeDestroy() {
|
||||
if (pipe_in_ > 0) {
|
||||
closesocket(pipe_in_);
|
||||
}
|
||||
if (pipe_out_ > 0) {
|
||||
closesocket(pipe_out_);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WakeUpPipe::PipeCreate() {
|
||||
int listen_sock = -1;
|
||||
unsigned long on = 1;
|
||||
bool status = false;
|
||||
if ((listen_sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) {
|
||||
return false;
|
||||
}
|
||||
|
||||
struct sockaddr_in servaddr;
|
||||
int servaddr_len = sizeof(servaddr);
|
||||
servaddr.sin_family = AF_INET;
|
||||
servaddr.sin_port = 0;
|
||||
servaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
|
||||
|
||||
do {
|
||||
if (bind(listen_sock, (const struct sockaddr *)&servaddr, sizeof(servaddr)) == SOCKET_ERROR) {
|
||||
break;
|
||||
}
|
||||
if (getsockname(listen_sock, (struct sockaddr *)&servaddr, &servaddr_len) == SOCKET_ERROR) {
|
||||
break;
|
||||
}
|
||||
if (listen(listen_sock, 1) == SOCKET_ERROR) {
|
||||
break;
|
||||
}
|
||||
if ((pipe_in_ = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) {
|
||||
break;
|
||||
}
|
||||
if (connect(pipe_in_, (const struct sockaddr *)&servaddr, sizeof(servaddr)) == SOCKET_ERROR) {
|
||||
break;
|
||||
}
|
||||
if (ioctlsocket(listen_sock, FIONBIO, &on) == SOCKET_ERROR) {
|
||||
break;
|
||||
}
|
||||
|
||||
struct sockaddr_in clientaddr;
|
||||
int clientaddr_len = sizeof(clientaddr);
|
||||
fd_set poll_set;
|
||||
FD_ZERO(&poll_set);
|
||||
FD_SET(listen_sock, &poll_set);
|
||||
// timeout 2s
|
||||
struct timeval timeout = {2, 0};
|
||||
int rv = select(0, &poll_set, nullptr, nullptr, &timeout);
|
||||
if (rv <= 0) {
|
||||
break;
|
||||
}
|
||||
if ((pipe_out_ = accept(listen_sock, (struct sockaddr *)&clientaddr, &clientaddr_len)) == INVALID_SOCKET) {
|
||||
break;
|
||||
}
|
||||
status = true;
|
||||
} while(0);
|
||||
|
||||
closesocket(listen_sock);
|
||||
if (!status) {
|
||||
if (pipe_in_ > 0) {
|
||||
closesocket(pipe_in_);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace livox
|
||||
|
||||
#endif // WIN32
|
||||
@@ -26,10 +26,11 @@
|
||||
#include <functional>
|
||||
#include <atomic>
|
||||
#include "base/logging.h"
|
||||
#include "base/network_util.h"
|
||||
#include "base/network/network_util.h"
|
||||
#include "command_impl.h"
|
||||
#include "device_manager.h"
|
||||
#include "livox_def.h"
|
||||
#include <stdio.h>
|
||||
|
||||
using std::bind;
|
||||
using std::list;
|
||||
@@ -41,49 +42,46 @@ using std::chrono::steady_clock;
|
||||
|
||||
namespace livox {
|
||||
|
||||
CommandChannel::CommandChannel(apr_port_t port,
|
||||
CommandChannel::CommandChannel(uint16_t port,
|
||||
uint8_t handle,
|
||||
const string &remote_ip,
|
||||
CommandChannelDelegate *cb,
|
||||
apr_pool_t *pool)
|
||||
CommandChannelDelegate *cb)
|
||||
: handle_(handle),
|
||||
port_(port),
|
||||
sock_(NULL),
|
||||
mem_pool_(pool),
|
||||
loop_(NULL),
|
||||
loop_(),
|
||||
callback_(cb),
|
||||
comm_port_(new CommPort),
|
||||
heartbeat_time_(),
|
||||
remote_ip_(remote_ip),
|
||||
heartbeat_time_(),
|
||||
last_heartbeat_() {}
|
||||
|
||||
bool CommandChannel::Bind(IOLoop *loop) {
|
||||
if (loop == NULL) {
|
||||
|
||||
bool CommandChannel::Bind(std::weak_ptr<IOLoop> loop) {
|
||||
if (loop.expired()) {
|
||||
return false;
|
||||
}
|
||||
loop_ = loop;
|
||||
sock_ = util::CreateBindSocket(port_, mem_pool_);
|
||||
if (sock_ == NULL) {
|
||||
sock_ = util::CreateSocket(port_);
|
||||
if (sock_ == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
loop_->AddDelegate(sock_, this);
|
||||
loop_.lock()->AddDelegate(sock_, this);
|
||||
last_heartbeat_ = steady_clock::now();
|
||||
return true;
|
||||
}
|
||||
|
||||
void CommandChannel::OnData(apr_socket_t *, void *) {
|
||||
apr_sockaddr_t addr;
|
||||
void CommandChannel::OnData(socket_t , void *) {
|
||||
struct sockaddr addr;
|
||||
int addrlen = sizeof(addr);
|
||||
uint32_t buf_size = 0;
|
||||
uint8_t *cache_buf = comm_port_->FetchCacheFreeSpace(&buf_size);
|
||||
apr_size_t size = buf_size;
|
||||
apr_status_t rv = apr_socket_recvfrom(&addr, sock_, 0, reinterpret_cast<char *>(cache_buf), &size);
|
||||
comm_port_->UpdateCacheWrIdx(size);
|
||||
if (rv != APR_SUCCESS) {
|
||||
LOG_ERROR(PrintAPRStatus(rv));
|
||||
int size = buf_size;
|
||||
size = util::RecvFrom(sock_, reinterpret_cast<char *>(cache_buf), buf_size, 0, &addr, &addrlen);
|
||||
if (size <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
comm_port_->UpdateCacheWrIdx(size);
|
||||
CommPacket packet;
|
||||
memset(&packet, 0, sizeof(packet));
|
||||
|
||||
@@ -115,8 +113,14 @@ void CommandChannel::OnData(apr_socket_t *, void *) {
|
||||
|
||||
void CommandChannel::SendAsync(const Command &command) {
|
||||
Command cmd = DeepCopy(command);
|
||||
if (loop_) {
|
||||
loop_->PostTask(bind(&CommandChannel::Send, this, cmd));
|
||||
if (!loop_.expired()) {
|
||||
auto w_ptr = WeakProtector(protector_);
|
||||
loop_.lock()->PostTask([this, w_ptr, cmd](){
|
||||
if(w_ptr.expired()) {
|
||||
return;
|
||||
}
|
||||
Send(cmd);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +138,7 @@ void CommandChannel::OnTimer(TimePoint now) {
|
||||
}
|
||||
|
||||
for (list<Command>::iterator ite = timeout_commands.begin(); ite != timeout_commands.end(); ++ite) {
|
||||
LOG_WARN("Command Timeout: Set {}, Id {}, Seq {}",
|
||||
LOG_WARN("Command Timeout: Set {}, Id {}, Seq {}",
|
||||
(uint16_t)ite->packet.cmd_set, ite->packet.cmd_code, ite->packet.seq_num);
|
||||
if (callback_) {
|
||||
ite->packet.packet_type = kCommandTypeAck;
|
||||
@@ -150,16 +154,12 @@ void CommandChannel::OnTimer(TimePoint now) {
|
||||
}
|
||||
|
||||
void CommandChannel::Uninit() {
|
||||
if (sock_) {
|
||||
apr_os_thread_t thread_id = apr_os_thread_current();
|
||||
if (apr_os_thread_equal(loop_->GetThreadId(), thread_id)) {
|
||||
loop_->RemoveDelegateSync(sock_);
|
||||
} else {
|
||||
loop_->RemoveDelegate(sock_, this);
|
||||
if (sock_ != -1) {
|
||||
if (!loop_.expired()) {
|
||||
loop_.lock()->RemoveDelegate(sock_, this);
|
||||
}
|
||||
loop_ = NULL;
|
||||
apr_socket_close(sock_);
|
||||
sock_ = NULL;
|
||||
util::CloseSock(sock_);
|
||||
sock_ = -1;
|
||||
}
|
||||
callback_ = NULL;
|
||||
if (comm_port_) {
|
||||
@@ -190,22 +190,22 @@ void CommandChannel::HeartBeat(TimePoint t) {
|
||||
}
|
||||
|
||||
void CommandChannel::SendInternal(const Command &command) {
|
||||
apr_pool_t *subpool = NULL;
|
||||
apr_pool_create(&subpool, mem_pool_);
|
||||
uint8_t *buf = (uint8_t *)apr_palloc(subpool, kMaxCommandBufferSize);
|
||||
uint32_t size = 0;
|
||||
comm_port_->Pack(buf, kMaxCommandBufferSize, &size, command.packet);
|
||||
apr_size_t apr_size = size;
|
||||
apr_status_t rv = APR_SUCCESS;
|
||||
apr_sockaddr_t *sa = NULL;
|
||||
rv = apr_sockaddr_info_get(&sa, remote_ip_.c_str(), APR_INET, 65000, 0, subpool);
|
||||
if (rv == APR_SUCCESS) {
|
||||
rv = apr_socket_sendto(sock_, sa, 0, (const char *)buf, &apr_size);
|
||||
std::vector<uint8_t> buf(kMaxCommandBufferSize + 1);
|
||||
int size = 0;
|
||||
comm_port_->Pack(buf.data(), kMaxCommandBufferSize, (uint32_t *)&size, command.packet);
|
||||
|
||||
struct sockaddr_in servaddr;
|
||||
servaddr.sin_family = AF_INET;
|
||||
servaddr.sin_port = htons(65000);
|
||||
servaddr.sin_addr.s_addr = inet_addr(remote_ip_.c_str());
|
||||
|
||||
int byte_send = sendto(sock_, (const char*)buf.data(), size, 0, (const struct sockaddr *) &servaddr,
|
||||
sizeof(servaddr));
|
||||
if (byte_send < 0) {
|
||||
if (command.cb) {
|
||||
(*command.cb)(kStatusSendFailed, handle_, NULL);
|
||||
}
|
||||
}
|
||||
if (rv != APR_SUCCESS) {
|
||||
(*command.cb)(kStatusSendFailed, handle_, NULL);
|
||||
}
|
||||
apr_pool_destroy(subpool);
|
||||
}
|
||||
|
||||
uint16_t CommandChannel::GenerateSeq() {
|
||||
|
||||
@@ -28,8 +28,7 @@
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
#include "apr_network_io.h"
|
||||
#include <algorithm>
|
||||
#include "base/io_loop.h"
|
||||
#include "comm/comm_port.h"
|
||||
|
||||
@@ -67,18 +66,19 @@ class CommandChannelDelegate {
|
||||
virtual void OnHeartbeatStateUpdate(uint8_t handle, const HeartbeatResponse &state) = 0;
|
||||
};
|
||||
|
||||
class Protector {};
|
||||
|
||||
/**
|
||||
* CommandChannel implements the sending/receiving commands with a specific device.
|
||||
*/
|
||||
class CommandChannel : public IOLoop::IOLoopDelegate {
|
||||
public:
|
||||
typedef std::chrono::steady_clock::time_point TimePoint;
|
||||
|
||||
CommandChannel(apr_port_t port,
|
||||
|
||||
CommandChannel(uint16_t port,
|
||||
uint8_t handle,
|
||||
const std::string &remote_ip,
|
||||
CommandChannelDelegate *cb,
|
||||
apr_pool_t *pool);
|
||||
CommandChannelDelegate *cb);
|
||||
virtual ~CommandChannel() { Uninit(); }
|
||||
|
||||
/** Uninitialize CommandChannel. */
|
||||
@@ -89,7 +89,7 @@ class CommandChannel : public IOLoop::IOLoopDelegate {
|
||||
* @param loop the IOLoop to bind.
|
||||
* @return true on successfully.
|
||||
*/
|
||||
bool Bind(IOLoop *loop);
|
||||
bool Bind(std::weak_ptr<IOLoop> loop);
|
||||
|
||||
/**
|
||||
* Send a command asynchronously.
|
||||
@@ -97,7 +97,7 @@ class CommandChannel : public IOLoop::IOLoopDelegate {
|
||||
*/
|
||||
void SendAsync(const Command &command);
|
||||
|
||||
void OnData(apr_socket_t *, void *);
|
||||
void OnData(socket_t, void *);
|
||||
void OnTimer(TimePoint now);
|
||||
|
||||
static uint16_t GenerateSeq();
|
||||
@@ -113,16 +113,18 @@ class CommandChannel : public IOLoop::IOLoopDelegate {
|
||||
private:
|
||||
const std::chrono::milliseconds kHeartbeatTimer = std::chrono::milliseconds(800);
|
||||
uint8_t handle_;
|
||||
apr_port_t port_;
|
||||
apr_socket_t *sock_;
|
||||
apr_pool_t *mem_pool_;
|
||||
IOLoop *loop_;
|
||||
uint16_t port_;
|
||||
socket_t sock_ = -1;
|
||||
std::weak_ptr<IOLoop> loop_;
|
||||
CommandChannelDelegate *callback_;
|
||||
std::map<uint16_t, std::pair<Command, TimePoint> > commands_;
|
||||
std::unique_ptr<CommPort> comm_port_;
|
||||
TimePoint heartbeat_time_;
|
||||
std::string remote_ip_;
|
||||
TimePoint heartbeat_time_;
|
||||
TimePoint last_heartbeat_;
|
||||
using SharedProtecotr = std::shared_ptr<Protector>;
|
||||
using WeakProtector = std::weak_ptr<Protector>;
|
||||
SharedProtecotr protector_ = std::make_shared<Protector>();
|
||||
};
|
||||
|
||||
} // namespace livox
|
||||
|
||||
@@ -90,9 +90,9 @@ bool CommandHandler::AddDevice(const DeviceInfo &info) {
|
||||
if (impl_ == NULL) {
|
||||
DeviceMode mode = static_cast<DeviceMode>(device_manager().device_mode());
|
||||
if (mode == kDeviceModeHub) {
|
||||
impl_.reset(new HubCommandHandlerImpl(this, mem_pool_, loop_));
|
||||
impl_.reset(new HubCommandHandlerImpl(this, loop_));
|
||||
} else if (mode == kDeviceModeLidar) {
|
||||
impl_.reset(new LidarCommandHandlerImpl(this, mem_pool_, loop_));
|
||||
impl_.reset(new LidarCommandHandlerImpl(this, loop_));
|
||||
}
|
||||
}
|
||||
if (impl_ == NULL) {
|
||||
@@ -102,26 +102,15 @@ bool CommandHandler::AddDevice(const DeviceInfo &info) {
|
||||
return impl_->AddDevice(info);
|
||||
}
|
||||
|
||||
bool CommandHandler::Init(IOLoop *loop) {
|
||||
apr_status_t rv = apr_pool_create(&mem_pool_, NULL);
|
||||
if (rv != APR_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CommandHandler::Init(std::weak_ptr<IOLoop> loop) {
|
||||
loop_ = loop;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CommandHandler::Uninit() {
|
||||
loop_ = NULL;
|
||||
if (impl_) {
|
||||
impl_.reset(NULL);
|
||||
}
|
||||
|
||||
if (mem_pool_) {
|
||||
apr_pool_destroy(mem_pool_);
|
||||
mem_pool_ = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CommandHandler::OnCommand(uint8_t handle, const Command &command) {
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include "base/command_callback.h"
|
||||
#include "base/util.h"
|
||||
#include "command_channel.h"
|
||||
#include "device_discovery.h"
|
||||
#include "livox_sdk.h"
|
||||
@@ -39,9 +38,9 @@ class CommandHandlerImpl;
|
||||
|
||||
class CommandHandler : public noncopyable {
|
||||
public:
|
||||
explicit CommandHandler() : mem_pool_(NULL), loop_(NULL) {}
|
||||
explicit CommandHandler() {}
|
||||
|
||||
bool Init(IOLoop *loop);
|
||||
bool Init(std::weak_ptr<IOLoop> loop);
|
||||
void Uninit();
|
||||
|
||||
bool AddDevice(const DeviceInfo &info);
|
||||
@@ -71,10 +70,9 @@ class CommandHandler : public noncopyable {
|
||||
|
||||
private:
|
||||
std::multimap<uint16_t, Command> message_registers_;
|
||||
apr_pool_t *mem_pool_;
|
||||
std::unique_ptr<CommandHandlerImpl> impl_;
|
||||
std::mutex mutex_;
|
||||
IOLoop *loop_;
|
||||
std::weak_ptr<IOLoop> loop_;
|
||||
};
|
||||
|
||||
class CommandHandlerImpl : public CommandChannelDelegate {
|
||||
|
||||
@@ -262,7 +262,7 @@ livox_status HubStopSampling(CommonCommandCallback cb, void *client_data) {
|
||||
return DeviceSampleControl(kHubDefaultHandle, false, cb, client_data);
|
||||
}
|
||||
|
||||
livox_status HubGetLidarHandle(uint8_t slot, uint8_t id) {
|
||||
uint8_t HubGetLidarHandle(uint8_t slot, uint8_t id) {
|
||||
return (slot - 1) * 3 + id - 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
//
|
||||
|
||||
#include "hub_command_handler.h"
|
||||
#include "base/network_util.h"
|
||||
#include "base/network/network_util.h"
|
||||
|
||||
namespace livox {
|
||||
|
||||
@@ -41,7 +41,7 @@ bool HubCommandHandlerImpl::AddDevice(const DeviceInfo &info) {
|
||||
is_valid_ = true;
|
||||
hub_info_ = info;
|
||||
|
||||
channel_.reset(new CommandChannel(info.cmd_port, info.handle, info.ip, this, mem_pool_));
|
||||
channel_.reset(new CommandChannel(info.cmd_port, info.handle, info.ip, this));
|
||||
channel_->Bind(loop_);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -31,16 +31,15 @@
|
||||
namespace livox {
|
||||
class HubCommandHandlerImpl : public CommandHandlerImpl {
|
||||
public:
|
||||
HubCommandHandlerImpl(CommandHandler *handler, apr_pool_t *pool, IOLoop *loop)
|
||||
: CommandHandlerImpl(handler), mem_pool_(pool), loop_(loop), is_valid_(false) {}
|
||||
HubCommandHandlerImpl(CommandHandler *handler, std::weak_ptr<IOLoop> loop)
|
||||
: CommandHandlerImpl(handler), loop_(loop), is_valid_(false) {}
|
||||
void Uninit();
|
||||
bool AddDevice(const DeviceInfo &info);
|
||||
bool RemoveDevice(uint8_t handle);
|
||||
livox_status SendCommand(uint8_t handle, const Command &command);
|
||||
|
||||
private:
|
||||
apr_pool_t *mem_pool_;
|
||||
IOLoop *loop_;
|
||||
std::weak_ptr<IOLoop> loop_;
|
||||
bool is_valid_;
|
||||
DeviceInfo hub_info_;
|
||||
std::unique_ptr<CommandChannel> channel_;
|
||||
|
||||
@@ -34,7 +34,7 @@ void LidarCommandHandlerImpl::Uninit() {
|
||||
|
||||
bool LidarCommandHandlerImpl::AddDevice(const DeviceInfo &info) {
|
||||
std::shared_ptr<CommandChannel> channel =
|
||||
std::make_shared<CommandChannel>(info.cmd_port, info.handle, info.ip, this, mem_pool_);
|
||||
std::make_shared<CommandChannel>(info.cmd_port, info.handle, info.ip, this);
|
||||
channel->Bind(loop_);
|
||||
|
||||
DeviceItem item = {channel, info};
|
||||
|
||||
@@ -31,8 +31,8 @@ namespace livox {
|
||||
|
||||
class LidarCommandHandlerImpl : public CommandHandlerImpl {
|
||||
public:
|
||||
LidarCommandHandlerImpl(CommandHandler *handler, apr_pool_t *pool, IOLoop *loop)
|
||||
: CommandHandlerImpl(handler), mem_pool_(pool), loop_(loop) {}
|
||||
LidarCommandHandlerImpl(CommandHandler *handler, std::weak_ptr<IOLoop> loop)
|
||||
: CommandHandlerImpl(handler), loop_(loop) {}
|
||||
|
||||
void Uninit();
|
||||
|
||||
@@ -45,9 +45,8 @@ class LidarCommandHandlerImpl : public CommandHandlerImpl {
|
||||
std::shared_ptr<CommandChannel> channel;
|
||||
DeviceInfo info;
|
||||
} DeviceItem;
|
||||
apr_pool_t *mem_pool_;
|
||||
std::list<DeviceItem> devices_;
|
||||
IOLoop *loop_;
|
||||
std::weak_ptr<IOLoop> loop_;
|
||||
};
|
||||
|
||||
} // namespace livox
|
||||
|
||||
@@ -49,9 +49,9 @@ bool DataHandler::AddDevice(const DeviceInfo &info) {
|
||||
if (impl_ == NULL) {
|
||||
DeviceMode mode = static_cast<DeviceMode>(device_manager().device_mode());
|
||||
if (mode == kDeviceModeHub) {
|
||||
impl_.reset(new HubDataHandlerImpl(this, mem_pool_));
|
||||
impl_.reset(new HubDataHandlerImpl(this));
|
||||
} else if (mode == kDeviceModeLidar) {
|
||||
impl_.reset(new LidarDataHandlerImpl(this, mem_pool_));
|
||||
impl_.reset(new LidarDataHandlerImpl(this));
|
||||
}
|
||||
|
||||
if (impl_ == NULL || !impl_->Init()) {
|
||||
@@ -63,10 +63,6 @@ bool DataHandler::AddDevice(const DeviceInfo &info) {
|
||||
}
|
||||
|
||||
bool DataHandler::Init() {
|
||||
apr_status_t rv = apr_pool_create(&mem_pool_, NULL);
|
||||
if (rv != APR_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -74,10 +70,6 @@ void DataHandler::Uninit() {
|
||||
if (impl_) {
|
||||
impl_.reset(NULL);
|
||||
}
|
||||
if (mem_pool_) {
|
||||
apr_pool_destroy(mem_pool_);
|
||||
mem_pool_ = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void DataHandler::OnDataCallback(uint8_t handle, void *data, uint16_t size) {
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include "apr_pools.h"
|
||||
#include "base/io_thread.h"
|
||||
#include "device_manager.h"
|
||||
|
||||
@@ -41,7 +40,7 @@ class DataHandler : public noncopyable {
|
||||
typedef std::function<void(uint8_t handle, LivoxEthPacket *data, uint32_t data_num, void *client_data)> DataCallback;
|
||||
|
||||
public:
|
||||
DataHandler() : mem_pool_(NULL) {}
|
||||
DataHandler() {}
|
||||
|
||||
bool Init();
|
||||
void Uninit();
|
||||
@@ -53,7 +52,6 @@ class DataHandler : public noncopyable {
|
||||
void OnDataCallback(uint8_t handle, void *data, uint16_t size);
|
||||
|
||||
private:
|
||||
apr_pool_t *mem_pool_;
|
||||
std::array<DataCallback, kMaxConnectedDeviceNum> callbacks_;
|
||||
std::array<void *, kMaxConnectedDeviceNum> client_data_;
|
||||
std::unique_ptr<DataHandlerImpl> impl_;
|
||||
|
||||
@@ -24,7 +24,14 @@
|
||||
|
||||
#include "hub_data_handler.h"
|
||||
#include <base/logging.h>
|
||||
#include "base/network_util.h"
|
||||
#include "base/network/network_util.h"
|
||||
#ifdef WIN32
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <ws2def.h>
|
||||
#else
|
||||
#include "arpa/inet.h"
|
||||
#endif
|
||||
|
||||
namespace livox {
|
||||
|
||||
@@ -43,12 +50,11 @@ void HubDataHandlerImpl::Uninit() {
|
||||
thread_.reset(NULL);
|
||||
}
|
||||
|
||||
if (sock_) {
|
||||
apr_socket_close(sock_);
|
||||
sock_ = NULL;
|
||||
if (sock_ > 0) {
|
||||
util::CloseSock(sock_);
|
||||
sock_ = -1;
|
||||
}
|
||||
is_valid_ = false;
|
||||
mem_pool_ = NULL;
|
||||
}
|
||||
|
||||
bool HubDataHandlerImpl::AddDevice(const DeviceInfo &info) {
|
||||
@@ -58,23 +64,29 @@ bool HubDataHandlerImpl::AddDevice(const DeviceInfo &info) {
|
||||
is_valid_ = true;
|
||||
hub_info_ = info;
|
||||
|
||||
sock_ = util::CreateBindSocket(info.data_port, mem_pool_);
|
||||
if (sock_ == NULL) {
|
||||
sock_ = util::CreateSocket(info.data_port);
|
||||
if (sock_ < 0) {
|
||||
is_valid_ = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
thread_->loop()->AddDelegate(sock_, this);
|
||||
auto loop = thread_->loop();
|
||||
if (!loop.expired()) {
|
||||
loop.lock()->AddDelegate(sock_, this);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void HubDataHandlerImpl::OnData(apr_socket_t *, void *) {
|
||||
apr_sockaddr_t addr;
|
||||
void HubDataHandlerImpl::OnData(socket_t, void *) {
|
||||
struct sockaddr addr;
|
||||
int addrlen = sizeof(addr);
|
||||
if (buf_.size() < kMaxBufferSize) {
|
||||
buf_.resize(kMaxBufferSize);
|
||||
}
|
||||
apr_size_t size = kMaxBufferSize;
|
||||
apr_socket_recvfrom(&addr, sock_, 0, &buf_[0], &size);
|
||||
int size = kMaxBufferSize;
|
||||
size = util::RecvFrom(sock_, reinterpret_cast<char *>(&buf_[0]), kMaxBufferSize, 0, &addr, &addrlen);
|
||||
if (size <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (handler_) {
|
||||
handler_->OnDataCallback(hub_info_.handle, &buf_[0], size);
|
||||
@@ -83,9 +95,12 @@ void HubDataHandlerImpl::OnData(apr_socket_t *, void *) {
|
||||
|
||||
void HubDataHandlerImpl::RemoveDevice(uint8_t handle) {
|
||||
if (handle == hub_info_.handle) {
|
||||
thread_->loop()->RemoveDelegate(sock_, this);
|
||||
apr_socket_close(sock_);
|
||||
sock_ = NULL;
|
||||
auto loop = thread_->loop();
|
||||
if (!loop.expired()) {
|
||||
loop.lock()->RemoveDelegate(sock_, this);
|
||||
}
|
||||
util::CloseSock(sock_);
|
||||
sock_ = -1;
|
||||
is_valid_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
namespace livox {
|
||||
class HubDataHandlerImpl : public DataHandlerImpl {
|
||||
public:
|
||||
HubDataHandlerImpl(DataHandler *handler, apr_pool_t *mem_pool)
|
||||
: DataHandlerImpl(handler), mem_pool_(mem_pool), thread_(new IOThread()), sock_(NULL), is_valid_(false) {}
|
||||
HubDataHandlerImpl(DataHandler *handler)
|
||||
: DataHandlerImpl(handler), thread_(new IOThread()), is_valid_(false) {}
|
||||
|
||||
~HubDataHandlerImpl() { Uninit(); }
|
||||
bool Init();
|
||||
@@ -41,12 +41,11 @@ class HubDataHandlerImpl : public DataHandlerImpl {
|
||||
|
||||
bool AddDevice(const DeviceInfo &info);
|
||||
void RemoveDevice(uint8_t t);
|
||||
void OnData(apr_socket_t *sock, void *client_data);
|
||||
void OnData(socket_t sock, void *client_data);
|
||||
|
||||
private:
|
||||
apr_pool_t *mem_pool_;
|
||||
std::unique_ptr<IOThread> thread_;
|
||||
apr_socket_t *sock_;
|
||||
socket_t sock_ = -1;
|
||||
DeviceInfo hub_info_;
|
||||
bool is_valid_;
|
||||
std::vector<char> buf_;
|
||||
|
||||
@@ -24,7 +24,15 @@
|
||||
|
||||
#include "lidar_data_handler.h"
|
||||
#include <mutex>
|
||||
#include "base/network_util.h"
|
||||
#include "base/network/network_util.h"
|
||||
#ifdef WIN32
|
||||
#include <winsock2.h>
|
||||
#include <ws2def.h>
|
||||
#pragma comment(lib, "Ws2_32.lib")
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif // WIN32
|
||||
|
||||
|
||||
using std::lock_guard;
|
||||
using std::mutex;
|
||||
@@ -41,16 +49,14 @@ void LidarDataHandlerImpl::Uninit() {
|
||||
for (list<DeviceItem>::iterator ite = devices_.begin(); ite != devices_.end(); ++ite) {
|
||||
DeviceItem &item = *ite;
|
||||
if (item.thread) {
|
||||
if (item.thread->loop()) {
|
||||
item.thread->loop()->RemoveDelegate(item.sock, this);
|
||||
}
|
||||
item.thread->loop().lock()->RemoveDelegate(item.sock, this);
|
||||
item.thread->Quit();
|
||||
item.thread->Join();
|
||||
item.thread->Uninit();
|
||||
}
|
||||
|
||||
if (item.sock) {
|
||||
apr_socket_close(item.sock);
|
||||
if (item.sock > 0) {
|
||||
util::CloseSock(item.sock);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,14 +64,11 @@ void LidarDataHandlerImpl::Uninit() {
|
||||
}
|
||||
|
||||
bool LidarDataHandlerImpl::AddDevice(const DeviceInfo &info) {
|
||||
apr_socket_t *sock = util::CreateBindSocket(info.data_port, mem_pool_);
|
||||
if (sock == NULL) {
|
||||
return false;
|
||||
}
|
||||
socket_t sock = util::CreateSocket(info.data_port);
|
||||
|
||||
shared_ptr<IOThread> thread = std::make_shared<IOThread>();
|
||||
std::shared_ptr<IOThread> thread = std::make_shared<IOThread>();
|
||||
thread->Init(false, false);
|
||||
thread->loop()->AddDelegate(sock, this, reinterpret_cast<void *>(info.handle));
|
||||
thread->loop().lock()->AddDelegate(sock, this, reinterpret_cast<void *>(info.handle));
|
||||
{
|
||||
lock_guard<mutex> lock(mutex_);
|
||||
DeviceItem item = {sock, thread, info.handle};
|
||||
@@ -90,17 +93,19 @@ void LidarDataHandlerImpl::RemoveDevice(uint8_t handle) {
|
||||
}
|
||||
|
||||
if (found) {
|
||||
item.thread->loop()->RemoveDelegate(item.sock, this);
|
||||
item.thread->loop().lock()->RemoveDelegate(item.sock, this);
|
||||
item.thread->Quit();
|
||||
item.thread->Join();
|
||||
item.thread->Uninit();
|
||||
if (item.sock) {
|
||||
apr_socket_close(item.sock);
|
||||
if (item.sock > 0) {
|
||||
util::CloseSock(item.sock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LidarDataHandlerImpl::OnData(apr_socket_t *sock, void *client_data) {
|
||||
void LidarDataHandlerImpl::OnData(socket_t sock, void *client_data) {
|
||||
struct sockaddr addr;
|
||||
int addrlen = sizeof(addr);
|
||||
uint8_t handle = static_cast<uint8_t>(reinterpret_cast<uintptr_t>(client_data));
|
||||
if (handle > data_buffers_.size()) {
|
||||
return;
|
||||
@@ -110,13 +115,15 @@ void LidarDataHandlerImpl::OnData(apr_socket_t *sock, void *client_data) {
|
||||
buf.reset(new char[kMaxBufferSize]);
|
||||
}
|
||||
|
||||
apr_sockaddr_t addr;
|
||||
apr_size_t size = kMaxBufferSize;
|
||||
if (APR_SUCCESS == apr_socket_recvfrom(&addr, sock, 0, buf.get(), &size)) {
|
||||
if (handler_) {
|
||||
handler_->OnDataCallback(handle, buf.get(), size);
|
||||
}
|
||||
int size = kMaxBufferSize;
|
||||
size = util::RecvFrom(sock, reinterpret_cast<char *>(buf.get()), kMaxBufferSize, 0, &addr, &addrlen);
|
||||
if (size <= 0) {
|
||||
return;
|
||||
}
|
||||
if (handler_) {
|
||||
handler_->OnDataCallback(handle, buf.get(), size);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace livox
|
||||
|
||||
@@ -34,24 +34,23 @@ namespace livox {
|
||||
|
||||
class LidarDataHandlerImpl : public DataHandlerImpl {
|
||||
public:
|
||||
LidarDataHandlerImpl(DataHandler *handler, apr_pool_t *mem_pool) : DataHandlerImpl(handler), mem_pool_(mem_pool) {}
|
||||
LidarDataHandlerImpl(DataHandler *handler) : DataHandlerImpl(handler) {}
|
||||
~LidarDataHandlerImpl() { Uninit(); }
|
||||
bool Init();
|
||||
void Uninit();
|
||||
bool AddDevice(const DeviceInfo &info);
|
||||
void RemoveDevice(uint8_t handle);
|
||||
void OnData(apr_socket_t *sock, void *client_data);
|
||||
void OnData(socket_t sock, void *client_data);
|
||||
|
||||
private:
|
||||
typedef struct {
|
||||
apr_socket_t *sock;
|
||||
socket_t sock;
|
||||
std::shared_ptr<IOThread> thread;
|
||||
uint16_t handle;
|
||||
} DeviceItem;
|
||||
std::list<DeviceItem> devices_;
|
||||
|
||||
std::array<std::unique_ptr<char[]>, kMaxConnectedDeviceNum> data_buffers_;
|
||||
apr_pool_t *mem_pool_;
|
||||
std::mutex mutex_;
|
||||
};
|
||||
|
||||
|
||||
@@ -27,15 +27,8 @@
|
||||
#include <mutex>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include "apr_network_io.h"
|
||||
#include "apr_pools.h"
|
||||
#ifdef WIN32
|
||||
#include "winsock.h"
|
||||
#else
|
||||
#include "arpa/inet.h"
|
||||
#endif
|
||||
#include "base/logging.h"
|
||||
#include "base/network_util.h"
|
||||
#include "base/network/network_util.h"
|
||||
#include "command_handler/command_impl.h"
|
||||
#include "device_manager.h"
|
||||
#include "livox_def.h"
|
||||
@@ -45,48 +38,43 @@ using std::string;
|
||||
using std::vector;
|
||||
using std::chrono::steady_clock;
|
||||
|
||||
|
||||
namespace livox {
|
||||
|
||||
uint16_t DeviceDiscovery::port_count = 0;
|
||||
|
||||
bool DeviceDiscovery::Init() {
|
||||
apr_status_t rv = apr_pool_create(&mem_pool_, NULL);
|
||||
if (rv != APR_SUCCESS) {
|
||||
LOG_ERROR(PrintAPRStatus(rv));
|
||||
return false;
|
||||
}
|
||||
if (comm_port_ == NULL) {
|
||||
comm_port_.reset(new CommPort());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DeviceDiscovery::Start(IOLoop *loop) {
|
||||
if (loop == NULL) {
|
||||
bool DeviceDiscovery::Start(std::weak_ptr<IOLoop> loop) {
|
||||
if (loop.expired()) {
|
||||
return false;
|
||||
}
|
||||
loop_ = loop;
|
||||
sock_ = util::CreateBindSocket(kListenPort, mem_pool_, true);
|
||||
if (sock_ == NULL) {
|
||||
LOG_ERROR("DeviceDiscovery Create Socket Failed");
|
||||
sock_ = util::CreateSocket(kListenPort);
|
||||
if (sock_ < 0) {
|
||||
return false;
|
||||
}
|
||||
loop_->AddDelegate(sock_, this);
|
||||
loop_.lock()->AddDelegate(sock_, this);
|
||||
return true;
|
||||
}
|
||||
|
||||
void DeviceDiscovery::OnData(apr_socket_t *sock, void *) {
|
||||
apr_sockaddr_t addr;
|
||||
void DeviceDiscovery::OnData(socket_t sock, void *) {
|
||||
struct sockaddr addr;
|
||||
int addrlen = sizeof(addr);
|
||||
uint32_t buf_size = 0;
|
||||
uint8_t *cache_buf = comm_port_->FetchCacheFreeSpace(&buf_size);
|
||||
apr_size_t size = buf_size;
|
||||
apr_status_t rv = apr_socket_recvfrom(&addr, sock, 0, reinterpret_cast<char *>(cache_buf), &size);
|
||||
|
||||
comm_port_->UpdateCacheWrIdx(size);
|
||||
if (rv != APR_SUCCESS) {
|
||||
LOG_WARN(" Receive Failed {}", PrintAPRStatus(rv));
|
||||
int size = buf_size;
|
||||
size = util::RecvFrom(sock, reinterpret_cast<char *>(cache_buf), buf_size, 0, &addr, &addrlen);
|
||||
if (size < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
comm_port_->UpdateCacheWrIdx(size);
|
||||
CommPacket packet;
|
||||
memset(&packet, 0, sizeof(packet));
|
||||
|
||||
@@ -97,10 +85,11 @@ void DeviceDiscovery::OnData(apr_socket_t *sock, void *) {
|
||||
if (connecting_devices_.find(sock) == connecting_devices_.end()) {
|
||||
continue;
|
||||
}
|
||||
DeviceInfo info = std::get<2>(connecting_devices_[sock]);
|
||||
loop_->RemoveDelegate(sock, this);
|
||||
apr_socket_close(sock);
|
||||
apr_pool_destroy(std::get<0>(connecting_devices_[sock]));
|
||||
DeviceInfo info = std::get<1>(connecting_devices_[sock]);
|
||||
if (!loop_.expired()) {
|
||||
loop_.lock()->RemoveDelegate(sock, this);
|
||||
}
|
||||
util::CloseSock(sock);
|
||||
connecting_devices_.erase(sock);
|
||||
|
||||
if (packet.data == NULL) {
|
||||
@@ -123,11 +112,12 @@ void DeviceDiscovery::OnData(apr_socket_t *sock, void *) {
|
||||
void DeviceDiscovery::OnTimer(TimePoint now) {
|
||||
ConnectingDeviceMap::iterator ite = connecting_devices_.begin();
|
||||
while (ite != connecting_devices_.end()) {
|
||||
tuple<apr_pool_t *, TimePoint, DeviceInfo> &device_tuple = ite->second;
|
||||
if (now - std::get<1>(device_tuple) > std::chrono::milliseconds(500)) {
|
||||
loop_->RemoveDelegate(ite->first, this);
|
||||
apr_socket_close(ite->first);
|
||||
apr_pool_destroy(std::get<0>(device_tuple));
|
||||
tuple<TimePoint, DeviceInfo> &device_tuple = ite->second;
|
||||
if (now - std::get<0>(device_tuple) > std::chrono::milliseconds(500)) {
|
||||
if (!loop_.expired()) {
|
||||
loop_.lock()->RemoveDelegate(ite->first, this);
|
||||
}
|
||||
util::CloseSock(ite->first);
|
||||
connecting_devices_.erase(ite++);
|
||||
} else {
|
||||
++ite;
|
||||
@@ -136,23 +126,20 @@ void DeviceDiscovery::OnTimer(TimePoint now) {
|
||||
}
|
||||
|
||||
void DeviceDiscovery::Uninit() {
|
||||
if (sock_) {
|
||||
loop_->RemoveDelegate(sock_, this);
|
||||
apr_socket_close(sock_);
|
||||
sock_ = NULL;
|
||||
if (sock_ > 0) {
|
||||
if (!loop_.expired()) {
|
||||
loop_.lock()->RemoveDelegate(sock_, this);
|
||||
}
|
||||
util::CloseSock(sock_);
|
||||
sock_ = -1;
|
||||
}
|
||||
|
||||
if (comm_port_) {
|
||||
comm_port_.reset(NULL);
|
||||
}
|
||||
|
||||
if (mem_pool_) {
|
||||
apr_pool_destroy(mem_pool_);
|
||||
mem_pool_ = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceDiscovery::OnBroadcast(const CommPacket &packet, apr_sockaddr_t *addr) {
|
||||
void DeviceDiscovery::OnBroadcast(const CommPacket &packet, struct sockaddr *addr) {
|
||||
if (packet.data == NULL) {
|
||||
return;
|
||||
}
|
||||
@@ -164,11 +151,7 @@ void DeviceDiscovery::OnBroadcast(const CommPacket &packet, apr_sockaddr_t *addr
|
||||
|
||||
char ip[16];
|
||||
memset(&ip, 0, sizeof(ip));
|
||||
apr_status_t rv = apr_sockaddr_ip_getbuf(ip, sizeof(ip), addr);
|
||||
if (rv != APR_SUCCESS) {
|
||||
LOG_ERROR(PrintAPRStatus(rv));
|
||||
return;
|
||||
}
|
||||
inet_ntop(AF_INET, &((struct sockaddr_in*)addr)->sin_addr, ip, INET_ADDRSTRLEN);
|
||||
strncpy(device_info.ip, ip, sizeof(device_info.ip));
|
||||
|
||||
device_manager().BroadcastDevices(&device_info);
|
||||
@@ -195,35 +178,28 @@ void DeviceDiscovery::OnBroadcast(const CommPacket &packet, apr_sockaddr_t *addr
|
||||
lidar_info.status.progress = 0;
|
||||
|
||||
strncpy(lidar_info.ip, ip, sizeof(lidar_info.ip));
|
||||
apr_pool_t *pool = NULL;
|
||||
rv = apr_pool_create(&pool, mem_pool_);
|
||||
if (rv != APR_SUCCESS) {
|
||||
LOG_ERROR(PrintAPRStatus(rv));
|
||||
|
||||
socket_t cmd_sock = util::CreateSocket(lidar_info.cmd_port);
|
||||
if (cmd_sock < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
apr_socket_t *cmd_sock = util::CreateBindSocket(lidar_info.cmd_port, pool);
|
||||
if (cmd_sock == NULL) {
|
||||
apr_pool_destroy(pool);
|
||||
pool = NULL;
|
||||
return;
|
||||
if (!loop_.expired()) {
|
||||
loop_.lock()->AddDelegate(cmd_sock, this);
|
||||
}
|
||||
|
||||
loop_->AddDelegate(cmd_sock, this);
|
||||
OnTimer(steady_clock::now());
|
||||
std::get<0>(connecting_devices_[cmd_sock]) = pool;
|
||||
std::get<2>(connecting_devices_[cmd_sock]) = lidar_info;
|
||||
std::get<1>(connecting_devices_[cmd_sock]) = lidar_info;
|
||||
|
||||
bool result = false;
|
||||
do {
|
||||
HandshakeRequest handshake_req;
|
||||
uint32_t local_ip = 0;
|
||||
if (util::FindLocalIp(addr->sa.sin, local_ip) == false) {
|
||||
if (util::FindLocalIp(*(struct sockaddr_in*)addr, local_ip) == false) {
|
||||
result = false;
|
||||
LOG_INFO("LocalIp and DeviceIp are not in same subnet");
|
||||
break;
|
||||
}
|
||||
LOG_INFO("LocalIP: {}", inet_ntoa(*(struct in_addr *)&local_ip));
|
||||
LOG_INFO("DeviceIP: {}", inet_ntoa(((struct sockaddr_in *)addr)->sin_addr));
|
||||
LOG_INFO("Command Port: {}", lidar_info.cmd_port);
|
||||
LOG_INFO("Data Port: {}", lidar_info.data_port);
|
||||
CommPacket packet;
|
||||
@@ -240,21 +216,21 @@ void DeviceDiscovery::OnBroadcast(const CommPacket &packet, apr_sockaddr_t *addr
|
||||
packet.data = (uint8_t *)&handshake_req;
|
||||
|
||||
vector<uint8_t> buf(kMaxCommandBufferSize + 1);
|
||||
apr_size_t o_len = kMaxCommandBufferSize;
|
||||
int o_len = kMaxCommandBufferSize;
|
||||
comm_port_->Pack(buf.data(), kMaxCommandBufferSize, (uint32_t *)&o_len, packet);
|
||||
rv = apr_socket_sendto(cmd_sock, addr, 0, reinterpret_cast<const char *>(buf.data()), &o_len);
|
||||
if (rv != APR_SUCCESS) {
|
||||
result = false;
|
||||
break;
|
||||
int byte_send = sendto(cmd_sock, reinterpret_cast<const char *>(buf.data()), o_len, 0, addr, sizeof(*addr));
|
||||
if (byte_send < 0) {
|
||||
return;
|
||||
}
|
||||
std::get<1>(connecting_devices_[cmd_sock]) = steady_clock::now();
|
||||
std::get<0>(connecting_devices_[cmd_sock]) = steady_clock::now();
|
||||
result = true;
|
||||
} while (0);
|
||||
|
||||
if (result == false) {
|
||||
loop_->RemoveDelegate(cmd_sock, this);
|
||||
apr_socket_close(cmd_sock);
|
||||
apr_pool_destroy(pool);
|
||||
if (!loop_.expired()) {
|
||||
loop_.lock()->RemoveDelegate(cmd_sock, this);
|
||||
}
|
||||
util::CloseSock(cmd_sock);
|
||||
connecting_devices_.erase(cmd_sock);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,13 +27,20 @@
|
||||
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include "apr_general.h"
|
||||
#include "apr_network_io.h"
|
||||
#include "apr_pools.h"
|
||||
#include <algorithm>
|
||||
#include "base/io_thread.h"
|
||||
#include "base/noncopyable.h"
|
||||
#include "comm/comm_port.h"
|
||||
#include "command_handler/command_channel.h"
|
||||
#include <stdio.h>
|
||||
#ifdef WIN32
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <ws2def.h>
|
||||
#pragma comment(lib,"ws2_32.lib")
|
||||
#else
|
||||
#include "arpa/inet.h"
|
||||
#endif
|
||||
|
||||
namespace livox {
|
||||
|
||||
@@ -45,7 +52,7 @@ class DeviceDiscovery : public noncopyable, IOLoop::IOLoopDelegate {
|
||||
public:
|
||||
typedef std::chrono::steady_clock::time_point TimePoint;
|
||||
|
||||
DeviceDiscovery() : sock_(NULL), mem_pool_(NULL), loop_(NULL), comm_port_(nullptr) {}
|
||||
DeviceDiscovery() : comm_port_(nullptr) {}
|
||||
bool Init();
|
||||
void Uninit();
|
||||
|
||||
@@ -54,36 +61,36 @@ class DeviceDiscovery : public noncopyable, IOLoop::IOLoopDelegate {
|
||||
* @param loop IOLoop on where DeviceDiscovery runs.
|
||||
* @return true if successfully.
|
||||
*/
|
||||
bool Start(IOLoop *loop);
|
||||
bool Start(std::weak_ptr<IOLoop> loop);
|
||||
|
||||
/**
|
||||
* IOLoop callback delegate.
|
||||
* @param client_data client data passed in IOLoop::AddDelegate
|
||||
*/
|
||||
void OnData(apr_socket_t *, void *client_data);
|
||||
void OnData(socket_t, void *client_data);
|
||||
void OnTimer(TimePoint now);
|
||||
|
||||
private:
|
||||
void OnBroadcast(const CommPacket &packet, apr_sockaddr_t *addr);
|
||||
void OnBroadcast(const CommPacket &packet, struct sockaddr *addr);
|
||||
|
||||
private:
|
||||
/** broadcast listening port number. */
|
||||
static const apr_port_t kListenPort = 55000;
|
||||
static const uint16_t kListenPort = 55000;
|
||||
/** command port number start offset. */
|
||||
static const apr_port_t kCmdPortOffset = 500;
|
||||
static const uint16_t kCmdPortOffset = 500;
|
||||
/** data port number start offset. */
|
||||
static const apr_port_t kDataPortOffset = 1000;
|
||||
static const uint16_t kDataPortOffset = 1000;
|
||||
/** sensor port number start offset. */
|
||||
static const apr_port_t kSensorPortOffset = 1000;
|
||||
static const uint16_t kSensorPortOffset = 1000;
|
||||
|
||||
|
||||
static uint16_t port_count;
|
||||
apr_socket_t *sock_;
|
||||
apr_pool_t *mem_pool_;
|
||||
IOLoop *loop_;
|
||||
socket_t sock_ = -1;
|
||||
std::weak_ptr<IOLoop> loop_;
|
||||
std::unique_ptr<CommPort> comm_port_;
|
||||
std::mutex mutex_;
|
||||
typedef std::map<apr_socket_t *, std::tuple<apr_pool_t *, TimePoint, DeviceInfo> > ConnectingDeviceMap;
|
||||
typedef std::map<socket_t, std::tuple<TimePoint, DeviceInfo> > ConnectingDeviceMap;
|
||||
|
||||
ConnectingDeviceMap connecting_devices_;
|
||||
};
|
||||
|
||||
|
||||
@@ -49,11 +49,6 @@ inline bool IsLidar(uint8_t mode) {
|
||||
}
|
||||
|
||||
bool DeviceManager::Init() {
|
||||
apr_status_t rv = apr_pool_create(&mem_pool_, NULL);
|
||||
if (rv != APR_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -66,11 +61,6 @@ void DeviceManager::Uninit() {
|
||||
for (DeviceContainer::iterator ite = devices_.begin(); ite != devices_.end(); ++ite) {
|
||||
ite->clear();
|
||||
}
|
||||
|
||||
if (mem_pool_) {
|
||||
apr_pool_destroy(mem_pool_);
|
||||
mem_pool_ = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool DeviceManager::AddDevice(const DeviceInfo &device) {
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
#include "device_discovery.h"
|
||||
#include "livox_sdk.h"
|
||||
|
||||
@@ -53,7 +54,7 @@ typedef enum {
|
||||
*/
|
||||
class DeviceManager : public noncopyable {
|
||||
public:
|
||||
DeviceManager() : mem_pool_(NULL), device_mode_(kDeviceModeNone), connected_cb_(NULL), broadcast_cb_(NULL) {}
|
||||
DeviceManager() : device_mode_(kDeviceModeNone), connected_cb_(NULL), broadcast_cb_(NULL) {}
|
||||
|
||||
bool Init();
|
||||
void Uninit();
|
||||
@@ -149,7 +150,6 @@ class DeviceManager : public noncopyable {
|
||||
} DetailDeviceInfo;
|
||||
typedef std::array<DetailDeviceInfo, kMaxConnectedDeviceNum> DeviceContainer;
|
||||
DeviceContainer devices_;
|
||||
apr_pool_t *mem_pool_;
|
||||
DeviceMode device_mode_;
|
||||
std::function<void(const DeviceInfo *, DeviceEvent)> connected_cb_;
|
||||
std::function<void(const BroadcastDeviceInfo *info)> broadcast_cb_;
|
||||
|
||||
+19
-16
@@ -23,11 +23,14 @@
|
||||
//
|
||||
|
||||
#include "livox_sdk.h"
|
||||
#include "apr_general.h"
|
||||
#include "command_handler/command_handler.h"
|
||||
#include "data_handler/data_handler.h"
|
||||
#include "base/logging.h"
|
||||
#include "device_manager.h"
|
||||
#ifdef WIN32
|
||||
#include<winsock2.h>
|
||||
#endif // WIN32
|
||||
|
||||
using namespace livox;
|
||||
IOThread *g_thread = NULL;
|
||||
static bool is_initialized = false;
|
||||
@@ -44,16 +47,18 @@ bool Init() {
|
||||
if (is_initialized) {
|
||||
return false;
|
||||
}
|
||||
#ifdef WIN32
|
||||
WORD sockVersion = MAKEWORD(2, 0);
|
||||
WSADATA wsdata;
|
||||
if (WSAStartup(sockVersion, &wsdata) != 0) {
|
||||
return false;
|
||||
}
|
||||
#endif // WIN32
|
||||
|
||||
bool result = false;
|
||||
do {
|
||||
InitLogger();
|
||||
|
||||
if (apr_initialize() != APR_SUCCESS) {
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
|
||||
g_thread = new IOThread();
|
||||
g_thread->Init();
|
||||
|
||||
@@ -79,10 +84,6 @@ bool Init() {
|
||||
result = true;
|
||||
} while (0);
|
||||
|
||||
if (result == false) {
|
||||
apr_terminate();
|
||||
}
|
||||
|
||||
is_initialized = result;
|
||||
return result;
|
||||
}
|
||||
@@ -91,24 +92,26 @@ void Uninit() {
|
||||
if (!is_initialized) {
|
||||
return;
|
||||
}
|
||||
#ifdef WIN32
|
||||
WSACleanup();
|
||||
#endif // WIN32
|
||||
if (g_thread) {
|
||||
g_thread->Quit();
|
||||
g_thread->Join();
|
||||
}
|
||||
|
||||
device_discovery().Uninit();
|
||||
command_handler().Uninit();
|
||||
data_handler().Uninit();
|
||||
device_manager().Uninit();
|
||||
|
||||
if (g_thread) {
|
||||
g_thread->Uninit();
|
||||
delete g_thread;
|
||||
g_thread = NULL;
|
||||
}
|
||||
|
||||
device_discovery().Uninit();
|
||||
command_handler().Uninit();
|
||||
data_handler().Uninit();
|
||||
device_manager().Uninit();
|
||||
|
||||
UninitLogger();
|
||||
apr_terminate();
|
||||
is_initialized = false;
|
||||
}
|
||||
|
||||
|
||||
Vendored
-157
@@ -1,157 +0,0 @@
|
||||
-*- coding: utf-8 -*-
|
||||
Changes for APR 1.6.5
|
||||
|
||||
*) Fix Win32 build breakage in apr_os_exp_time_put() in 1.6.4. [Rainer Jung]
|
||||
|
||||
Changes for APR 1.6.4 (not released)
|
||||
|
||||
*) configure: Fix detection of <net/if.h> on OpenBSD.
|
||||
PR 61976. [David Carlier <devnexen gmail.com>, Yann Ylavic]
|
||||
|
||||
*) Fix apr_parse_addr_port() regression in scope_id parsing introduced
|
||||
in 1.6.3. [Rainer Jung]
|
||||
|
||||
*) Fix Win32 file buffer locking behavior for single threaded file streams.
|
||||
[Evgeny Kotkov, Mladen Turk, Jean-Frederic Clere]
|
||||
|
||||
*) Numerous corrections to APR poll behavior. [Yann Ylavic]
|
||||
|
||||
Changes for APR 1.6.3
|
||||
|
||||
*) apr_file_trunc: Truncating a buffered file could add unexpected
|
||||
data after the truncate position. PR 51017.
|
||||
[Evgeny Kotkov <evgeny.kotkov visualsvn.com>]
|
||||
|
||||
*) apr_file_trunc: Fix an issue where reading from a buffered file
|
||||
after truncate could return stale data from the buffer.
|
||||
[Evgeny Kotkov <evgeny.kotkov visualsvn.com>]
|
||||
|
||||
*) apr_ipsubnet_create() now fails for an empty input string.
|
||||
[Joe Orton]
|
||||
|
||||
Changes for APR 1.6.2
|
||||
|
||||
*) Corrected non-Unix builds for APR_LOCK_DEFAULT.
|
||||
|
||||
Changes for APR 1.6.1
|
||||
|
||||
*) Defer timed locks API for later 1.7 release [Nick Kew, William Rowe]
|
||||
|
||||
*) Export build files find_apr.m4 and apr_common.m4 [Jacob Champion]
|
||||
|
||||
Changes for APR 1.6.0
|
||||
|
||||
*) apr_allocator: Provide apr_allocator_align() to get the true size that
|
||||
would be allocated for the given size (including the header and
|
||||
alignment). [Yann Ylavic]
|
||||
|
||||
*) apr_os_proc_mutex_put_ex: Allow to specify whether the OS native
|
||||
mutex should or not be cleaned up (destroyed) with the constructed
|
||||
APR mutex (given pool), and default to not for the simple _put()
|
||||
function. [Yann Ylavic]
|
||||
|
||||
*) apr_proc/global_mutex: Fix API regarding the native OS mutexes
|
||||
accessors from/to available APR mechanisms, adding the new functions
|
||||
apr_os_proc_mutex_get_ex() and apr_os_proc_mutex_set_ex() which give
|
||||
control to the user over the selected mechanisms, including the missing
|
||||
POSIX semaphores (sem_t) on platforms supporting them.
|
||||
[Yann Ylavic]
|
||||
|
||||
*) apr_proc_mutex-pthread: Refcount shared mutexes usage to avoid
|
||||
destruction while still is use by some process(es). PR 49504.
|
||||
[Yann Ylavic]
|
||||
|
||||
*) apr_file_io: Add apr_file_pipe_create_pools() allowing a pair of
|
||||
pipes to be created, each in a different pool. [Graham Leggett]
|
||||
|
||||
*) Add apr_pollcb_wakeup(), with similar behavior to
|
||||
apr_pollset_wakeup(). Add apr_pollcb_method_name(), with similar
|
||||
behavior to apr_pollset_method_name().
|
||||
[Neil Conway <nrc cs berkeley edu>, Jeff Trawick]
|
||||
|
||||
*) apr_table_overlap: Add APR_OVERLAP_TABLES_ADD to merge and set when
|
||||
overlapping tables. [Graham Leggett]
|
||||
|
||||
*) locks: Introduce apr_{thread,proc,global}_mutex_timedlock().
|
||||
[Yann Ylavic]
|
||||
|
||||
*) Introduce the apr_cstr_fn() family of functions, derived from
|
||||
the svn_cstring_ functions of the Subversion project.
|
||||
|
||||
*) Add APR_SO_FREEBIND option for apr_socket_opt_set. PR 58725.
|
||||
[Ashley GC, Jan Kaluza, Joe Orton]
|
||||
|
||||
*) apr_filepath_merge: Fix truename length calculation on Windows
|
||||
in cases where the "short" name variant is actually longer than
|
||||
the "long" or "true" name. See: testnames.c:merge_shortname().
|
||||
[Bert Huijben <rhuijben a.o>]
|
||||
|
||||
*) apr_atomic: Fix errors when building on Visual Studio 2013 while
|
||||
maintaining the ability to build on Visual Studio 6 with Windows
|
||||
Server 2003 R2 SDK. PR 57191. [Gregg Smith]
|
||||
|
||||
*) apr_skiplist: Add apr_skiplist_addne*() family to preserve existing
|
||||
values (no duplicate), add apr_skiplist_size(), apr_skiplist_height()
|
||||
and apr_skiplist_preheight() to get the corresponding current values,
|
||||
and apr_skiplist_set_preheight() to modify it. [ Yann Ylavic ]
|
||||
|
||||
*) Add new --enable-allocator-guard-pages which is like allocator-uses-mmap,
|
||||
but will also add inaccessible guard pages before and after each memnode.
|
||||
This will result in higher ressource usage but allow to find/protect
|
||||
against certain buffer overflow/overread bugs. Under Linux, it may be
|
||||
necessary to increase /proc/sys/vm/max_map_count . [Stefan Fritsch]
|
||||
|
||||
*) apr_skiplist: Add apr_skiplist_add() to support multiple values.
|
||||
|
||||
*) Add new --enable-pool-concurrency-check configure option to detect
|
||||
thread-unsafe concurrent accesses to pools. Runtime costs should be
|
||||
relatively low. [Stefan Fritsch]
|
||||
|
||||
*) Add support code to teach valgrind about APR pools and allocators.
|
||||
[Stefan Fritsch]
|
||||
|
||||
*) Add apr_sockaddr_info_copy(), for making a deep copy of an
|
||||
apr_sockaddr_t into a specified pool. [Yann Ylavic
|
||||
<ylavic.dev gmail.com>]
|
||||
|
||||
*) Added Unix domain socket support.
|
||||
[Mladen Turk]
|
||||
|
||||
*) Add apr_shm_delete() to compliment apr_shm_remove().
|
||||
[Jim Jagielski]
|
||||
|
||||
*) Intruduce APR_PERMS_SET macros for setting the owner/group on
|
||||
objects. Currently only implemented for shm, proc and global
|
||||
mutexes on posix platforms.
|
||||
[Mladen Turk]
|
||||
|
||||
*) Add apr_escape_ldap() and apr_pescape_ldap(), escaping characters
|
||||
as described by RFC4514 and RFC4515 respectively. [Graham Leggett]
|
||||
|
||||
Changes for APR 1.5.x and later:
|
||||
|
||||
*) http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/CHANGES?view=markup
|
||||
|
||||
Changes for APR 1.4.x and later:
|
||||
|
||||
*) http://svn.apache.org/viewvc/apr/apr/branches/1.4.x/CHANGES?view=markup
|
||||
|
||||
Changes for APR 1.3.x and later:
|
||||
|
||||
*) http://svn.apache.org/viewvc/apr/apr/branches/1.3.x/CHANGES?view=markup
|
||||
|
||||
Changes for APR 1.2.x and later:
|
||||
|
||||
*) http://svn.apache.org/viewvc/apr/apr/branches/1.2.x/CHANGES?view=markup
|
||||
|
||||
Changes for APR 1.1.x and later:
|
||||
|
||||
*) http://svn.apache.org/viewvc/apr/apr/branches/1.1.x/CHANGES?view=markup
|
||||
|
||||
Changes for APR 1.0.x and later:
|
||||
|
||||
*) http://svn.apache.org/viewvc/apr/apr/branches/1.0.x/CHANGES?view=markup
|
||||
|
||||
Changes for APR 0.9.x and later/earlier:
|
||||
|
||||
*) http://svn.apache.org/viewvc/apr/apr/branches/0.9.x/CHANGES?view=markup
|
||||
-431
@@ -1,431 +0,0 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# Read README.cmake before using this.
|
||||
|
||||
PROJECT(APR C)
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
|
||||
OPTION(APR_INSTALL_PRIVATE_H "Install selected private .h files (for httpd)" OFF)
|
||||
OPTION(APR_HAVE_IPV6 "IPv6 support" ON)
|
||||
OPTION(INSTALL_PDB "Install .pdb files (if generated)" ON)
|
||||
OPTION(APR_BUILD_TESTAPR "Build the test suite" OFF)
|
||||
OPTION(TEST_STATIC_LIBS "Test programs use APR static libraries instead of shared libraries?" OFF)
|
||||
SET(MIN_WINDOWS_VER "Vista"
|
||||
CACHE STRING "Minimum Windows version")
|
||||
|
||||
# create 1-or-0 representation of feature tests for apr.h
|
||||
|
||||
SET(apr_have_ipv6_10 0)
|
||||
|
||||
IF(APR_HAVE_IPV6)
|
||||
SET(apr_have_ipv6_10 1)
|
||||
ENDIF()
|
||||
|
||||
IF("${MIN_WINDOWS_VER}" STREQUAL "")
|
||||
SET(win32_winnt_str "0x0600")
|
||||
ELSEIF(${MIN_WINDOWS_VER} STREQUAL "Vista")
|
||||
SET(win32_winnt_str "0x0600")
|
||||
ELSEIF(${MIN_WINDOWS_VER} STREQUAL "Windows7")
|
||||
SET(win32_winnt_str "0x0601")
|
||||
ELSE()
|
||||
SET(win32_winnt_str ${MIN_WINDOWS_VER})
|
||||
ENDIF()
|
||||
|
||||
CONFIGURE_FILE(include/apr.hwc
|
||||
${PROJECT_BINARY_DIR}/apr.h)
|
||||
|
||||
ADD_EXECUTABLE(gen_test_char tools/gen_test_char.c)
|
||||
GET_TARGET_PROPERTY(GEN_TEST_CHAR_EXE gen_test_char LOCATION)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
COMMENT "Generating character tables, apr_escape_test_char.h, for current locale"
|
||||
DEPENDS gen_test_char
|
||||
COMMAND ${GEN_TEST_CHAR_EXE} > ${PROJECT_BINARY_DIR}/apr_escape_test_char.h
|
||||
OUTPUT ${PROJECT_BINARY_DIR}/apr_escape_test_char.h
|
||||
)
|
||||
ADD_CUSTOM_TARGET(
|
||||
test_char_header ALL
|
||||
DEPENDS ${PROJECT_BINARY_DIR}/apr_escape_test_char.h
|
||||
)
|
||||
|
||||
# Generated .h files are stored in PROJECT_BINARY_DIR, not the
|
||||
# source tree.
|
||||
#
|
||||
# BROKEN: not searching PROJECT_BINARY_DIR first, so you have to
|
||||
# manually delete apr.h in PROJECT_SOURCE_DIR/include if
|
||||
# you've generated apr.h before using a different build
|
||||
|
||||
SET(APR_INCLUDE_DIRECTORIES
|
||||
${PROJECT_BINARY_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/arch/win32
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/arch/unix
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/private
|
||||
)
|
||||
|
||||
SET(APR_SYSTEM_LIBS
|
||||
ws2_32
|
||||
mswsock
|
||||
rpcrt4
|
||||
)
|
||||
|
||||
INCLUDE_DIRECTORIES(${APR_INCLUDE_DIRECTORIES})
|
||||
|
||||
SET(APR_PUBLIC_HEADERS_STATIC
|
||||
include/apr_allocator.h
|
||||
include/apr_atomic.h
|
||||
include/apr_cstr.h
|
||||
include/apr_dso.h
|
||||
include/apr_env.h
|
||||
include/apr_errno.h
|
||||
include/apr_escape.h
|
||||
include/apr_file_info.h
|
||||
include/apr_file_io.h
|
||||
include/apr_fnmatch.h
|
||||
include/apr_general.h
|
||||
include/apr_getopt.h
|
||||
include/apr_global_mutex.h
|
||||
include/apr_hash.h
|
||||
include/apr_inherit.h
|
||||
include/apr_lib.h
|
||||
include/apr_mmap.h
|
||||
include/apr_network_io.h
|
||||
include/apr_perms_set.h
|
||||
include/apr_poll.h
|
||||
include/apr_pools.h
|
||||
include/apr_portable.h
|
||||
include/apr_proc_mutex.h
|
||||
include/apr_random.h
|
||||
include/apr_ring.h
|
||||
include/apr_shm.h
|
||||
include/apr_signal.h
|
||||
include/apr_skiplist.h
|
||||
include/apr_strings.h
|
||||
include/apr_support.h
|
||||
include/apr_tables.h
|
||||
include/apr_thread_cond.h
|
||||
include/apr_thread_mutex.h
|
||||
include/apr_thread_proc.h
|
||||
include/apr_thread_rwlock.h
|
||||
include/apr_time.h
|
||||
include/apr_user.h
|
||||
include/apr_version.h
|
||||
include/apr_want.h
|
||||
)
|
||||
SET(APR_PUBLIC_HEADERS_GENERATED
|
||||
${PROJECT_BINARY_DIR}/apr.h
|
||||
)
|
||||
|
||||
SET(APR_SOURCES
|
||||
atomic/win32/apr_atomic.c
|
||||
dso/win32/dso.c
|
||||
encoding/apr_escape.c
|
||||
file_io/unix/copy.c
|
||||
file_io/unix/fileacc.c
|
||||
file_io/unix/filepath_util.c
|
||||
file_io/unix/fullrw.c
|
||||
file_io/unix/mktemp.c
|
||||
file_io/unix/tempdir.c
|
||||
file_io/win32/buffer.c
|
||||
file_io/win32/dir.c
|
||||
file_io/win32/filedup.c
|
||||
file_io/win32/filepath.c
|
||||
file_io/win32/filestat.c
|
||||
file_io/win32/filesys.c
|
||||
file_io/win32/flock.c
|
||||
file_io/win32/open.c
|
||||
file_io/win32/pipe.c
|
||||
file_io/win32/readwrite.c
|
||||
file_io/win32/seek.c
|
||||
locks/win32/proc_mutex.c
|
||||
locks/win32/thread_cond.c
|
||||
locks/win32/thread_mutex.c
|
||||
locks/win32/thread_rwlock.c
|
||||
memory/unix/apr_pools.c
|
||||
misc/unix/errorcodes.c
|
||||
misc/unix/getopt.c
|
||||
misc/unix/otherchild.c
|
||||
misc/unix/version.c
|
||||
misc/win32/charset.c
|
||||
misc/win32/env.c
|
||||
misc/win32/internal.c
|
||||
misc/win32/misc.c
|
||||
misc/win32/rand.c
|
||||
misc/win32/start.c
|
||||
misc/win32/utf8.c
|
||||
mmap/unix/common.c
|
||||
mmap/win32/mmap.c
|
||||
network_io/unix/inet_ntop.c
|
||||
network_io/unix/inet_pton.c
|
||||
network_io/unix/multicast.c
|
||||
network_io/unix/sockaddr.c
|
||||
network_io/unix/socket_util.c
|
||||
network_io/win32/sendrecv.c
|
||||
network_io/win32/sockets.c
|
||||
network_io/win32/sockopt.c
|
||||
passwd/apr_getpass.c
|
||||
poll/unix/poll.c
|
||||
poll/unix/pollcb.c
|
||||
poll/unix/pollset.c
|
||||
poll/unix/select.c
|
||||
poll/unix/wakeup.c
|
||||
random/unix/apr_random.c
|
||||
random/unix/sha2.c
|
||||
random/unix/sha2_glue.c
|
||||
shmem/win32/shm.c
|
||||
strings/apr_cpystrn.c
|
||||
strings/apr_cstr.c
|
||||
strings/apr_fnmatch.c
|
||||
strings/apr_snprintf.c
|
||||
strings/apr_strings.c
|
||||
strings/apr_strnatcmp.c
|
||||
strings/apr_strtok.c
|
||||
tables/apr_hash.c
|
||||
tables/apr_skiplist.c
|
||||
tables/apr_tables.c
|
||||
threadproc/win32/proc.c
|
||||
threadproc/win32/signals.c
|
||||
threadproc/win32/thread.c
|
||||
threadproc/win32/threadpriv.c
|
||||
time/win32/time.c
|
||||
time/win32/timestr.c
|
||||
user/win32/groupinfo.c
|
||||
user/win32/userinfo.c
|
||||
)
|
||||
|
||||
SET(APR_TEST_SOURCES
|
||||
test/abts.c
|
||||
test/testargs.c
|
||||
test/testatomic.c
|
||||
test/testcond.c
|
||||
test/testdir.c
|
||||
test/testdso.c
|
||||
test/testdup.c
|
||||
test/testenv.c
|
||||
test/testescape.c
|
||||
test/testfile.c
|
||||
test/testfilecopy.c
|
||||
test/testfileinfo.c
|
||||
test/testflock.c
|
||||
test/testfmt.c
|
||||
test/testfnmatch.c
|
||||
test/testglobalmutex.c
|
||||
test/testhash.c
|
||||
test/testipsub.c
|
||||
test/testlfs.c
|
||||
test/testlock.c
|
||||
test/testmmap.c
|
||||
test/testnames.c
|
||||
test/testoc.c
|
||||
test/testpath.c
|
||||
test/testpipe.c
|
||||
test/testpoll.c
|
||||
test/testpools.c
|
||||
test/testproc.c
|
||||
test/testprocmutex.c
|
||||
test/testrand.c
|
||||
test/testshm.c
|
||||
test/testskiplist.c
|
||||
test/testsleep.c
|
||||
test/testsock.c
|
||||
test/testsockets.c
|
||||
test/testsockopt.c
|
||||
test/teststr.c
|
||||
test/teststrnatcmp.c
|
||||
test/testtable.c
|
||||
test/testtemp.c
|
||||
test/testthread.c
|
||||
test/testtime.c
|
||||
test/testud.c
|
||||
test/testuser.c
|
||||
test/testutil.c
|
||||
test/testvsn.c
|
||||
)
|
||||
|
||||
SET(install_targets)
|
||||
SET(install_bin_pdb)
|
||||
|
||||
# libapr-1 is shared, apr-1 is static
|
||||
ADD_LIBRARY(libapr-1 SHARED ${APR_SOURCES} ${APR_PUBLIC_HEADERS_GENERATED} libapr.rc)
|
||||
SET(install_targets ${install_targets} libapr-1)
|
||||
SET(install_bin_pdb ${install_bin_pdb} ${PROJECT_BINARY_DIR}/libapr-1.pdb)
|
||||
TARGET_LINK_LIBRARIES(libapr-1 ${APR_SYSTEM_LIBS})
|
||||
SET_TARGET_PROPERTIES(libapr-1 PROPERTIES COMPILE_DEFINITIONS "APR_DECLARE_EXPORT;WINNT")
|
||||
ADD_DEPENDENCIES(libapr-1 test_char_header)
|
||||
|
||||
ADD_LIBRARY(apr-1 STATIC ${APR_SOURCES} ${APR_PUBLIC_HEADERS_GENERATED})
|
||||
SET(install_targets ${install_targets} apr-1)
|
||||
TARGET_LINK_LIBRARIES(apr-1 ${APR_SYSTEM_LIBS})
|
||||
SET_TARGET_PROPERTIES(apr-1 PROPERTIES COMPILE_DEFINITIONS "APR_DECLARE_STATIC;WINNT")
|
||||
ADD_DEPENDENCIES(apr-1 test_char_header)
|
||||
|
||||
# libaprapp-1 and aprapp-1 are static
|
||||
ADD_LIBRARY(libaprapp-1 STATIC misc/win32/apr_app.c misc/win32/internal.c ${APR_PUBLIC_HEADERS_GENERATED})
|
||||
SET(install_targets ${install_targets} libaprapp-1)
|
||||
SET_TARGET_PROPERTIES(libaprapp-1 PROPERTIES COMPILE_DEFINITIONS "APR_APP;WINNT")
|
||||
|
||||
ADD_LIBRARY(aprapp-1 STATIC misc/win32/apr_app.c misc/win32/internal.c ${APR_PUBLIC_HEADERS_GENERATED})
|
||||
SET(install_targets ${install_targets} aprapp-1)
|
||||
SET_TARGET_PROPERTIES(aprapp-1 PROPERTIES COMPILE_DEFINITIONS "APR_DECLARE_STATIC;APR_APP;WINNT")
|
||||
|
||||
IF(APR_BUILD_TESTAPR)
|
||||
ENABLE_TESTING()
|
||||
# Create a "check" target that displays test program output to the console.
|
||||
ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND} --verbose)
|
||||
|
||||
# copy data files to build directory so that we can run programs from there
|
||||
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E make_directory
|
||||
${PROJECT_BINARY_DIR}/data)
|
||||
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${PROJECT_SOURCE_DIR}/test/data/file_datafile.txt
|
||||
${PROJECT_BINARY_DIR}/data/file_datafile.txt)
|
||||
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${PROJECT_SOURCE_DIR}/test/data/mmap_datafile.txt
|
||||
${PROJECT_BINARY_DIR}/data/mmap_datafile.txt)
|
||||
|
||||
IF(TEST_STATIC_LIBS)
|
||||
SET(whichapr apr-1)
|
||||
SET(whichaprapp aprapp-1)
|
||||
SET(apiflag -DAPR_DECLARE_STATIC)
|
||||
ELSE()
|
||||
SET(whichapr libapr-1)
|
||||
SET(whichaprapp libaprapp-1)
|
||||
SET(apiflag)
|
||||
ENDIF()
|
||||
|
||||
ADD_EXECUTABLE(testapp test/testapp.c)
|
||||
TARGET_LINK_LIBRARIES(testapp ${whichapr} ${whichaprapp} ${APR_SYSTEM_LIBS})
|
||||
SET_TARGET_PROPERTIES(testapp PROPERTIES LINK_FLAGS /entry:wmainCRTStartup)
|
||||
IF(apiflag)
|
||||
SET_TARGET_PROPERTIES(testapp PROPERTIES COMPILE_FLAGS ${apiflag})
|
||||
ENDIF()
|
||||
ADD_TEST(NAME testapp COMMAND testapp)
|
||||
|
||||
ADD_EXECUTABLE(testall ${APR_TEST_SOURCES})
|
||||
TARGET_LINK_LIBRARIES(testall ${whichapr} ${APR_SYSTEM_LIBS})
|
||||
IF(apiflag)
|
||||
SET_TARGET_PROPERTIES(testall PROPERTIES COMPILE_FLAGS ${apiflag})
|
||||
ENDIF()
|
||||
ADD_TEST(NAME testall COMMAND testall)
|
||||
|
||||
ADD_LIBRARY(mod_test MODULE test/mod_test.c)
|
||||
TARGET_LINK_LIBRARIES(mod_test ${whichapr} ${APR_SYSTEM_LIBS})
|
||||
SET_PROPERTY(TARGET mod_test APPEND PROPERTY LINK_FLAGS /export:print_hello)
|
||||
# nasty work-around for difficulties adding more than one additional flag
|
||||
# (they get joined in a bad way behind the scenes)
|
||||
GET_PROPERTY(link_flags TARGET mod_test PROPERTY LINK_FLAGS)
|
||||
SET(link_flags "${link_flags} /export:count_reps")
|
||||
SET_TARGET_PROPERTIES(mod_test PROPERTIES LINK_FLAGS ${link_flags})
|
||||
IF(apiflag)
|
||||
SET_TARGET_PROPERTIES(mod_test PROPERTIES COMPILE_FLAGS ${apiflag})
|
||||
ENDIF()
|
||||
|
||||
# Build all the single-source executable files with no special build
|
||||
# requirements.
|
||||
SET(single_source_programs
|
||||
test/echod.c
|
||||
test/sendfile.c
|
||||
test/sockperf.c
|
||||
test/testlockperf.c
|
||||
test/testmutexscope.c
|
||||
test/globalmutexchild.c
|
||||
test/occhild.c
|
||||
test/proc_child.c
|
||||
test/readchild.c
|
||||
test/sockchild.c
|
||||
test/testshmproducer.c
|
||||
test/testshmconsumer.c
|
||||
test/tryread.c
|
||||
test/internal/testucs.c
|
||||
)
|
||||
|
||||
FOREACH(sourcefile ${single_source_programs})
|
||||
STRING(REGEX REPLACE ".*/([^\\]+)\\.c" "\\1" proggie ${sourcefile})
|
||||
ADD_EXECUTABLE(${proggie} ${sourcefile})
|
||||
TARGET_LINK_LIBRARIES(${proggie} ${whichapr} ${APR_SYSTEM_LIBS})
|
||||
IF(apiflag)
|
||||
SET_TARGET_PROPERTIES(${proggie} PROPERTIES COMPILE_FLAGS ${apiflag})
|
||||
ENDIF()
|
||||
ENDFOREACH()
|
||||
|
||||
# Add tests for programs that run by themselves with no arguments.
|
||||
SET(simple_tests
|
||||
testmutexscope
|
||||
testucs
|
||||
)
|
||||
|
||||
FOREACH(simple ${simple_tests})
|
||||
ADD_TEST(NAME ${simple} COMMAND ${simple})
|
||||
ENDFOREACH()
|
||||
|
||||
# testlockperf takes forever on Windows with default counter limit
|
||||
ADD_TEST(NAME testlockperf COMMAND testlockperf -c 50000)
|
||||
|
||||
# sendfile runs multiple times with different parameters.
|
||||
FOREACH(sendfile_mode blocking nonblocking timeout)
|
||||
ADD_TEST(NAME sendfile-${sendfile_mode} COMMAND sendfile client ${sendfile_mode} startserver)
|
||||
ENDFOREACH()
|
||||
|
||||
# No test is added for echod+sockperf. Those will have to be run manually.
|
||||
|
||||
ENDIF (APR_BUILD_TESTAPR)
|
||||
|
||||
# Installation
|
||||
|
||||
INSTALL(TARGETS ${install_targets}
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib
|
||||
)
|
||||
|
||||
IF(INSTALL_PDB)
|
||||
INSTALL(FILES ${install_bin_pdb}
|
||||
DESTINATION bin
|
||||
CONFIGURATIONS RelWithDebInfo Debug)
|
||||
ENDIF()
|
||||
|
||||
INSTALL(FILES ${APR_PUBLIC_HEADERS_STATIC} ${APR_PUBLIC_HEADERS_GENERATED} DESTINATION include)
|
||||
IF(APR_INSTALL_PRIVATE_H)
|
||||
# Kludges for unexpected dependencies of httpd 2.x, not installed by default
|
||||
SET(APR_PRIVATE_H_FOR_HTTPD
|
||||
include/arch/win32/apr_arch_file_io.h
|
||||
include/arch/win32/apr_arch_misc.h
|
||||
include/arch/win32/apr_arch_utf8.h
|
||||
include/arch/win32/apr_private.h
|
||||
)
|
||||
INSTALL(FILES ${APR_PRIVATE_H_FOR_HTTPD} DESTINATION include/arch/win32)
|
||||
INSTALL(FILES include/arch/apr_private_common.h DESTINATION include/arch)
|
||||
ENDIF()
|
||||
|
||||
STRING(TOUPPER "${CMAKE_BUILD_TYPE}" buildtype)
|
||||
MESSAGE(STATUS "")
|
||||
MESSAGE(STATUS "")
|
||||
MESSAGE(STATUS "APR configuration summary:")
|
||||
MESSAGE(STATUS "")
|
||||
|
||||
MESSAGE(STATUS " Build type ...................... : ${CMAKE_BUILD_TYPE}")
|
||||
MESSAGE(STATUS " Install .pdb (if available)...... : ${INSTALL_PDB}")
|
||||
MESSAGE(STATUS " Install prefix .................. : ${CMAKE_INSTALL_PREFIX}")
|
||||
MESSAGE(STATUS " C compiler ...................... : ${CMAKE_C_COMPILER}")
|
||||
MESSAGE(STATUS " IPv6 ............................ : ${APR_HAVE_IPV6}")
|
||||
MESSAGE(STATUS " Minimum Windows version ......... : ${MIN_WINDOWS_VER}")
|
||||
MESSAGE(STATUS " Build test suite ................ : ${APR_BUILD_TESTAPR}")
|
||||
IF(TEST_STATIC_LIBS)
|
||||
MESSAGE(STATUS " (testing static libraries)")
|
||||
ELSE()
|
||||
MESSAGE(STATUS " (testing dynamic libraries)")
|
||||
ENDIF()
|
||||
MESSAGE(STATUS " Install private .h for httpd .... : ${APR_INSTALL_PRIVATE_H}")
|
||||
Vendored
-341
@@ -1,341 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
|
||||
|
||||
APACHE PORTABLE RUNTIME SUBCOMPONENTS:
|
||||
|
||||
The Apache Portable Runtime includes a number of subcomponents with
|
||||
separate copyright notices and license terms. Your use of the source
|
||||
code for these subcomponents is subject to the terms and conditions
|
||||
of the following licenses.
|
||||
|
||||
From strings/apr_fnmatch.c, include/apr_fnmatch.h, misc/unix/getopt.c,
|
||||
file_io/unix/mktemp.c, strings/apr_strings.c:
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
|
||||
From network_io/unix/inet_ntop.c, network_io/unix/inet_pton.c:
|
||||
|
||||
/* Copyright (c) 1996 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
|
||||
From dso/aix/dso.c:
|
||||
|
||||
* Based on libdl (dlfcn.c/dlfcn.h) which is
|
||||
* Copyright (c) 1992,1993,1995,1996,1997,1988
|
||||
* Jens-Uwe Mager, Helios Software GmbH, Hannover, Germany.
|
||||
*
|
||||
* Not derived from licensed software.
|
||||
*
|
||||
* Permission is granted to freely use, copy, modify, and redistribute
|
||||
* this software, provided that the author is not construed to be liable
|
||||
* for any results of using the software, alterations are clearly marked
|
||||
* as such, and this notice is not modified.
|
||||
|
||||
From strings/apr_strnatcmp.c, include/apr_strings.h:
|
||||
|
||||
strnatcmp.c -- Perform 'natural order' comparisons of strings in C.
|
||||
Copyright (C) 2000 by Martin Pool <mbp@humbug.org.au>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
From strings/apr_snprintf.c:
|
||||
|
||||
*
|
||||
* cvt - IEEE floating point formatting routines.
|
||||
* Derived from UNIX V7, Copyright(C) Caldera International Inc.
|
||||
*
|
||||
|
||||
Copyright(C) Caldera International Inc. 2001-2002. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
Redistributions of source code and documentation must retain the above
|
||||
copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
|
||||
This product includes software developed or owned by Caldera
|
||||
International, Inc.
|
||||
|
||||
Neither the name of Caldera International, Inc. nor the names of other
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
|
||||
INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
-151
@@ -1,151 +0,0 @@
|
||||
|
||||
srcdir=@srcdir@
|
||||
VPATH=@srcdir@
|
||||
top_srcdir=@apr_srcdir@
|
||||
top_blddir=@apr_builddir@
|
||||
|
||||
#
|
||||
# APR (Apache Portable Runtime) library Makefile.
|
||||
#
|
||||
CPP = @CPP@
|
||||
|
||||
# get substituted into some targets
|
||||
APR_MAJOR_VERSION=@APR_MAJOR_VERSION@
|
||||
|
||||
#
|
||||
# Macros for supporting directories
|
||||
#
|
||||
INCDIR=./include
|
||||
OSDIR=$(top_srcdir)/include/arch/@OSDIR@
|
||||
DEFOSDIR=$(INCDIR)/arch/@DEFAULT_OSDIR@
|
||||
INCLUDES=-I$(INCDIR) -I$(OSDIR) -I$(DEFOSDIR) -I$(top_srcdir)/include/arch/@DEFAULT_OSDIR@ -I$(top_srcdir)/include -I$(top_srcdir)/include/private -I$(top_blddir)/include/private
|
||||
|
||||
#
|
||||
# Macros for target determination
|
||||
#
|
||||
CLEAN_SUBDIRS= test
|
||||
INSTALL_SUBDIRS=@INSTALL_SUBDIRS@
|
||||
|
||||
TARGET_LIB = lib@APR_LIBNAME@.la
|
||||
APR_PCFILE = apr-$(APR_MAJOR_VERSION).pc
|
||||
APR_CONFIG = apr-$(APR_MAJOR_VERSION)-config
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
|
||||
#
|
||||
# Rules for building specific targets, starting with 'all' for
|
||||
# building the entire package.
|
||||
#
|
||||
TARGETS = $(TARGET_LIB) include/private/apr_escape_test_char.h apr.exp apr-config.out build/apr_rules.out
|
||||
|
||||
LT_VERSION = @LT_VERSION@
|
||||
|
||||
# bring in rules.mk for standard functionality
|
||||
@INCLUDE_RULES@
|
||||
@INCLUDE_OUTPUTS@
|
||||
|
||||
CLEAN_TARGETS = apr-config.out apr.exp exports.c export_vars.c .make.dirs \
|
||||
build/apr_rules.out tools/gen_test_char@EXEEXT@ \
|
||||
tools/gen_test_char.o tools/gen_test_char.lo \
|
||||
include/private/apr_escape_test_char.h
|
||||
DISTCLEAN_TARGETS = config.cache config.log config.status \
|
||||
include/apr.h include/arch/unix/apr_private.h \
|
||||
libtool $(APR_CONFIG) build/apr_rules.mk apr.pc \
|
||||
build/pkg/pkginfo
|
||||
EXTRACLEAN_TARGETS = configure aclocal.m4 include/arch/unix/apr_private.h.in \
|
||||
build-outputs.mk build/ltcf-c.sh build/aclocal.m4 \
|
||||
build/ltconfig build/ltmain.sh \
|
||||
build/argz.m4 build/libtool.m4 build/ltoptions.m4 \
|
||||
build/ltsugar.m4 build/ltversion.m4 build/lt~obsolete.m4
|
||||
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
bindir=@bindir@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
datadir=@datadir@
|
||||
installbuilddir=@installbuilddir@
|
||||
|
||||
# Create apr-config script suitable for the install tree
|
||||
apr-config.out: $(APR_CONFIG)
|
||||
sed 's,^\(location=\).*$$,\1installed,' < $(APR_CONFIG) > $@
|
||||
|
||||
# Create apr_rules.mk suitable for the install tree
|
||||
build/apr_rules.out: build/apr_rules.mk
|
||||
sed -e 's,^\(apr_build.*=\).*$$,\1$(installbuilddir),' -e 's,^\(top_build.*=\).*$$,\1$(installbuilddir),' < build/apr_rules.mk > $@
|
||||
|
||||
install: $(TARGETS)
|
||||
$(APR_MKDIR) $(DESTDIR)$(libdir) $(DESTDIR)$(bindir) $(DESTDIR)$(installbuilddir) \
|
||||
$(DESTDIR)$(libdir)/pkgconfig $(DESTDIR)$(includedir)
|
||||
$(INSTALL_DATA) $(top_blddir)/include/apr.h $(DESTDIR)$(includedir)
|
||||
for f in $(top_srcdir)/include/apr_*.h; do \
|
||||
$(INSTALL_DATA) $${f} $(DESTDIR)$(includedir); \
|
||||
done
|
||||
$(LIBTOOL) --mode=install $(INSTALL) -m 755 $(TARGET_LIB) $(DESTDIR)$(libdir)
|
||||
$(INSTALL_DATA) apr.exp $(DESTDIR)$(libdir)/apr.exp
|
||||
$(INSTALL_DATA) apr.pc $(DESTDIR)$(libdir)/pkgconfig/$(APR_PCFILE)
|
||||
for f in libtool shlibtool; do \
|
||||
if test -f $${f}; then $(INSTALL) -m 755 $${f} $(DESTDIR)$(installbuilddir); fi; \
|
||||
done
|
||||
$(INSTALL) -m 755 $(top_srcdir)/build/mkdir.sh $(DESTDIR)$(installbuilddir)
|
||||
for f in make_exports.awk make_var_export.awk; do \
|
||||
$(INSTALL_DATA) $(top_srcdir)/build/$${f} $(DESTDIR)$(installbuilddir); \
|
||||
done
|
||||
$(INSTALL_DATA) build/apr_rules.out $(DESTDIR)$(installbuilddir)/apr_rules.mk
|
||||
$(INSTALL_DATA) $(top_srcdir)/build/apr_common.m4 $(DESTDIR)$(installbuilddir)
|
||||
$(INSTALL_DATA) $(top_srcdir)/build/find_apr.m4 $(DESTDIR)$(installbuilddir)
|
||||
$(INSTALL) -m 755 apr-config.out $(DESTDIR)$(bindir)/$(APR_CONFIG)
|
||||
@if [ $(INSTALL_SUBDIRS) != "none" ]; then \
|
||||
for i in $(INSTALL_SUBDIRS); do \
|
||||
( cd $$i ; $(MAKE) DESTDIR=$(DESTDIR) install ); \
|
||||
done \
|
||||
fi
|
||||
|
||||
$(TARGET_LIB): $(OBJECTS)
|
||||
$(LINK) @lib_target@ $(ALL_LIBS)
|
||||
|
||||
encoding/apr_escape.lo: include/private/apr_escape_test_char.h
|
||||
|
||||
exports.c: $(HEADERS)
|
||||
$(APR_MKEXPORT) $(HEADERS) > $@
|
||||
|
||||
export_vars.c: $(HEADERS)
|
||||
$(APR_MKVAREXPORT) $(HEADERS) > $@
|
||||
|
||||
apr.exp: exports.c export_vars.c
|
||||
@echo "#! lib@APR_LIBNAME@.so" > $@
|
||||
@echo "* This file was AUTOGENERATED at build time." >> $@
|
||||
@echo "* Please do not edit by hand." >> $@
|
||||
$(CPP) $(ALL_CPPFLAGS) $(ALL_INCLUDES) exports.c | grep "ap_hack_" | sed -e 's/^.*[)]\(.*\);$$/\1/' >> $@
|
||||
$(CPP) $(ALL_CPPFLAGS) $(ALL_INCLUDES) export_vars.c | sed -e 's/^\#[^!]*//' | sed -e '/^$$/d' >> $@
|
||||
|
||||
dox:
|
||||
doxygen $(top_srcdir)/docs/doxygen.conf
|
||||
|
||||
gcov:
|
||||
@build/run-gcov.sh
|
||||
|
||||
test: check
|
||||
check: $(TARGET_LIB)
|
||||
cd test && $(MAKE) all check
|
||||
|
||||
etags:
|
||||
etags `find . -name '*.[ch]'`
|
||||
|
||||
OBJECTS_gen_test_char = tools/gen_test_char.lo $(LOCAL_LIBS)
|
||||
tools/gen_test_char.lo: tools/gen_test_char.c
|
||||
$(APR_MKDIR) tools
|
||||
$(LT_COMPILE)
|
||||
|
||||
tools/gen_test_char@EXEEXT@: $(OBJECTS_gen_test_char)
|
||||
$(LINK_PROG) $(OBJECTS_gen_test_char) $(ALL_LIBS)
|
||||
|
||||
include/private/apr_escape_test_char.h: tools/gen_test_char@EXEEXT@
|
||||
$(APR_MKDIR) include/private
|
||||
tools/gen_test_char@EXEEXT@ > $@
|
||||
|
||||
LINK_PROG = $(LIBTOOL) $(LTFLAGS) --mode=link $(COMPILE) $(LT_LDFLAGS) \
|
||||
@LT_NO_INSTALL@ $(ALL_LDFLAGS) -o $@
|
||||
|
||||
# DO NOT REMOVE
|
||||
docs: $(INCDIR)/*.h
|
||||
-171
@@ -1,171 +0,0 @@
|
||||
# Makefile.win for Win32 APR alone
|
||||
#
|
||||
# Targets are:
|
||||
#
|
||||
# buildall - compile everything
|
||||
# checkall - run APR regression tests
|
||||
# install - compile everything
|
||||
# clean - mop up everything
|
||||
#
|
||||
# You can override the build mechanism, choose only one;
|
||||
#
|
||||
# USEMAK=1 - compile from exported make files
|
||||
# USEDSW=1 - compile from .dsw / .dsp VC6 projects
|
||||
# USESLN=1 - compile from converted .sln / .vcproj VC7+ files
|
||||
#
|
||||
# Define ARCH to your desired preference (your PATH must point
|
||||
# to the correct compiler tools!) Choose only one;
|
||||
#
|
||||
# ARCH="Win32 Release"
|
||||
# ARCH="Win32 Debug"
|
||||
# ARCH="x64 Release"
|
||||
# ARCH="x64 Debug"
|
||||
#
|
||||
# For example;
|
||||
#
|
||||
# nmake -f Makefile.win PREFIX=C:\APR buildall checkall install clean
|
||||
#
|
||||
|
||||
!IF EXIST("apr.sln") && ([devenv /help > NUL 2>&1] == 0) \
|
||||
&& !defined(USEMAK) && !defined(USEDSW)
|
||||
USESLN=1
|
||||
USEMAK=0
|
||||
USEDSW=0
|
||||
!ELSEIF EXIST("apr.mak") && !defined(USEDSW)
|
||||
USESLN=0
|
||||
USEMAK=1
|
||||
USEDSW=0
|
||||
!ELSE
|
||||
USESLN=0
|
||||
USEMAK=0
|
||||
USEDSW=1
|
||||
!ENDIF
|
||||
|
||||
PREFIX=..\apr-dist
|
||||
|
||||
!IF [$(COMSPEC) /c cl /nologo /? \
|
||||
| $(SystemRoot)\System32\find.exe "x64" >NUL ] == 0
|
||||
ARCH=x64 Release
|
||||
!ELSE
|
||||
ARCH=Win32 Release
|
||||
!ENDIF
|
||||
|
||||
!MESSAGE ARCH = $(ARCH)
|
||||
!MESSAGE PREFIX = $(PREFIX) (install path)
|
||||
|
||||
|
||||
# Utility and Translation things, nothing here for the user
|
||||
#
|
||||
!IF "$(ARCH)" == "Win32 Release"
|
||||
SLNARCH=Release|Win32
|
||||
ARCHOSPATH=Release
|
||||
LIBSOSPATH=LibR
|
||||
!ELSEIF "$(ARCH)" == "Win32 Debug"
|
||||
SLNARCH=Debug|Win32
|
||||
ARCHOSPATH=Debug
|
||||
LIBSOSPATH=LibD
|
||||
!ELSEIF "$(ARCH)" == "x64 Release"
|
||||
SLNARCH=Release|x64
|
||||
ARCHOSPATH=x64\Release
|
||||
LIBSOSPATH=x64\LibR
|
||||
!ELSEIF "$(ARCH)" == "x64 Debug"
|
||||
SLNARCH=Debug|x64
|
||||
ARCHOSPATH=x64\Debug
|
||||
LIBSOSPATH=x64\LibD
|
||||
!ENDIF
|
||||
|
||||
!IFNDEF MAKEOPT
|
||||
# Only default the behavior if MAKEOPT= is omitted
|
||||
!IFDEF _NMAKE_VER
|
||||
# Microsoft NMake options
|
||||
MAKEOPT=-nologo
|
||||
!ELSEIF "$(MAKE)" == "make"
|
||||
# Borland make options? Not really supported (yet)
|
||||
MAKEOPT=-s -N
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
|
||||
all: buildall checkall
|
||||
|
||||
!IF $(USEMAK) == 1
|
||||
|
||||
clean:
|
||||
$(MAKE) $(MAKEOPT) -f Makefile.win ARCH="$(ARCH)" \
|
||||
CTARGET=CLEAN buildall
|
||||
|
||||
buildall:
|
||||
$(MAKE) $(MAKEOPT) -f apr.mak CFG="apr - $(ARCH)" RECURSE=0 $(CTARGET)
|
||||
$(MAKE) $(MAKEOPT) -f libapr.mak CFG="libapr - $(ARCH)" RECURSE=0 $(CTARGET)
|
||||
cd build
|
||||
$(MAKE) $(MAKEOPT) -f aprapp.mak CFG="aprapp - $(ARCH)" RECURSE=0 $(CTARGET)
|
||||
$(MAKE) $(MAKEOPT) -f libaprapp.mak CFG="libaprapp - $(ARCH)" RECURSE=0 $(CTARGET)
|
||||
cd ..
|
||||
|
||||
!ELSEIF $(USESLN) == 1
|
||||
|
||||
clean:
|
||||
-devenv apr.sln /useenv /clean "$(SLNARCH)" /project libaprapp
|
||||
-devenv apr.sln /useenv /clean "$(SLNARCH)" /project libapr
|
||||
-devenv apr.sln /useenv /clean "$(SLNARCH)" /project aprapp
|
||||
-devenv apr.sln /useenv /clean "$(SLNARCH)" /project apr
|
||||
|
||||
buildall:
|
||||
devenv apr.sln /useenv /build "$(SLNARCH)" /project apr
|
||||
devenv apr.sln /useenv /build "$(SLNARCH)" /project aprapp
|
||||
devenv apr.sln /useenv /build "$(SLNARCH)" /project libapr
|
||||
devenv apr.sln /useenv /build "$(SLNARCH)" /project libaprapp
|
||||
|
||||
!ELSE
|
||||
# $(USEDSP) == 1
|
||||
|
||||
clean:
|
||||
-msdev apr.dsw /USEENV /MAKE "libaprapp - $(ARCH)" /CLEAN
|
||||
-msdev apr.dsw /USEENV /MAKE "libapr - $(ARCH)" /CLEAN
|
||||
-msdev apr.dsw /USEENV /MAKE "aprapp - $(ARCH)" /CLEAN
|
||||
-msdev apr.dsw /USEENV /MAKE "apr - $(ARCH)" /CLEAN
|
||||
|
||||
buildall:
|
||||
@msdev apr.dsw /USEENV /MAKE "apr - $(ARCH)"
|
||||
@msdev apr.dsw /USEENV /MAKE "aprapp - $(ARCH)"
|
||||
@msdev apr.dsw /USEENV /MAKE "libapr - $(ARCH)"
|
||||
@msdev apr.dsw /USEENV /MAKE "libaprapp - $(ARCH)"
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
checkapr:
|
||||
cd test
|
||||
$(MAKE) $(MAKEOPT) -f Makefile.win MODEL=static \
|
||||
OUTDIR=$(LIBSOSPATH) check
|
||||
$(MAKE) $(MAKEOPT) -f Makefile.win MODEL=dynamic \
|
||||
OUTDIR=$(ARCHOSPATH) check
|
||||
cd ..
|
||||
|
||||
checkall: checkapr
|
||||
|
||||
|
||||
install:
|
||||
echo Y >.y
|
||||
echo A >.A
|
||||
@if NOT EXIST "$(PREFIX)\." mkdir "$(PREFIX)"
|
||||
@if NOT EXIST "$(PREFIX)\bin\." mkdir "$(PREFIX)\bin"
|
||||
@if NOT EXIST "$(PREFIX)\include\." mkdir "$(PREFIX)\include"
|
||||
@if NOT EXIST "$(PREFIX)\lib\." mkdir "$(PREFIX)\lib"
|
||||
copy CHANGES "$(PREFIX)\APR-CHANGES.txt" <.y
|
||||
copy LICENSE "$(PREFIX)\APR-LICENSE.txt" <.y
|
||||
copy NOTICE "$(PREFIX)\APR-NOTICE.txt" <.y
|
||||
xcopy include\*.h "$(PREFIX)\include\" /d < .a
|
||||
copy $(LIBSOSPATH)\apr-1.lib "$(PREFIX)\lib\" <.y
|
||||
copy $(LIBSOSPATH)\apr-1.pdb "$(PREFIX)\lib\" <.y
|
||||
copy $(LIBSOSPATH)\aprapp-1.lib "$(PREFIX)\lib\" <.y
|
||||
copy $(LIBSOSPATH)\aprapp-1.pdb "$(PREFIX)\lib\" <.y
|
||||
copy $(ARCHOSPATH)\libaprapp-1.lib "$(PREFIX)\lib\" <.y
|
||||
copy $(ARCHOSPATH)\libaprapp-1.pdb "$(PREFIX)\lib\" <.y
|
||||
copy $(ARCHOSPATH)\libapr-1.lib "$(PREFIX)\lib\" <.y
|
||||
copy $(ARCHOSPATH)\libapr-1.exp "$(PREFIX)\lib\" <.y
|
||||
copy $(ARCHOSPATH)\libapr-1.dll "$(PREFIX)\bin\" <.y
|
||||
copy $(ARCHOSPATH)\libapr-1.pdb "$(PREFIX)\bin\" <.y
|
||||
del .y
|
||||
del .a
|
||||
|
||||
Vendored
-15
@@ -1,15 +0,0 @@
|
||||
Apache Portable Runtime
|
||||
Copyright (c) 2000-2018 The Apache Software Foundation.
|
||||
|
||||
This product includes software developed at
|
||||
The Apache Software Foundation (http://www.apache.org/).
|
||||
|
||||
Portions of this software were developed at the National Center
|
||||
for Supercomputing Applications (NCSA) at the University of
|
||||
Illinois at Urbana-Champaign.
|
||||
|
||||
This software contains code derived from the RSA Data Security
|
||||
Inc. MD5 Message-Digest Algorithm.
|
||||
|
||||
This software contains code derived from UNIX V7, Copyright(C)
|
||||
Caldera International Inc.
|
||||
-434
@@ -1,434 +0,0 @@
|
||||
#
|
||||
# Define our macros with defaults if we dont got them already.
|
||||
#
|
||||
ifndef APR_WORK
|
||||
export APR_WORK = $(CURDIR)
|
||||
endif
|
||||
ifneq "$(wildcard $(APR_WORK)/include/apr_version.h)" "$(APR_WORK)/include/apr_version.h"
|
||||
$(error APR_WORK does not point to a valid APR source tree)
|
||||
endif
|
||||
ifndef APU_WORK
|
||||
export APU_WORK = $(CURDIR)/../apr-util
|
||||
endif
|
||||
ifneq "$(wildcard $(APU_WORK)/include/apu_version.h)" "$(APU_WORK)/include/apu_version.h"
|
||||
$(error APU_WORK does not point to a valid APU source tree)
|
||||
endif
|
||||
|
||||
#
|
||||
# Declare the sub-directories to be built here
|
||||
#
|
||||
|
||||
SUBDIRS = \
|
||||
build \
|
||||
$(APU_WORK) \
|
||||
$(EOLIST)
|
||||
|
||||
ifeq "$(TEST)" "1"
|
||||
SUBDIRS += \
|
||||
test \
|
||||
$(APU_WORK)/test \
|
||||
$(EOLIST)
|
||||
endif
|
||||
|
||||
#
|
||||
# Get the 'head' of the build environment. This includes default targets and
|
||||
# paths to tools
|
||||
#
|
||||
|
||||
include $(APR_WORK)/build/NWGNUhead.inc
|
||||
|
||||
#
|
||||
# build this level's files
|
||||
|
||||
#
|
||||
# Make sure all needed macro's are defined
|
||||
#
|
||||
|
||||
#
|
||||
# These directories will be at the beginning of the include list, followed by
|
||||
# INCDIRS
|
||||
#
|
||||
XINCDIRS += \
|
||||
$(APR)/include \
|
||||
$(APR)/include/private \
|
||||
$(APR)/include/arch/NetWare \
|
||||
$(APR)/include/arch/unix \
|
||||
$(APR)/memory/unix \
|
||||
$(APR)/random/unix \
|
||||
$(APU)/include \
|
||||
$(APU)/xml \
|
||||
$(LDAPSDK)/inc \
|
||||
$(EOLIST)
|
||||
|
||||
#
|
||||
# These flags will come after CFLAGS
|
||||
#
|
||||
XCFLAGS += \
|
||||
$(EOLIST)
|
||||
|
||||
#
|
||||
# These defines will come after DEFINES
|
||||
#
|
||||
XDEFINES += \
|
||||
$(EOLIST)
|
||||
|
||||
#
|
||||
# These flags will be added to the link.opt file
|
||||
#
|
||||
XLFLAGS += \
|
||||
$(EOLIST)
|
||||
|
||||
#
|
||||
# These values will be appended to the correct variables based on the value of
|
||||
# RELEASE
|
||||
#
|
||||
ifeq "$(RELEASE)" "debug"
|
||||
XINCDIRS += \
|
||||
$(EOLIST)
|
||||
|
||||
XCFLAGS += \
|
||||
$(EOLIST)
|
||||
|
||||
XDEFINES += \
|
||||
$(EOLIST)
|
||||
|
||||
XLFLAGS += \
|
||||
$(EOLIST)
|
||||
endif
|
||||
|
||||
ifeq "$(RELEASE)" "noopt"
|
||||
XINCDIRS += \
|
||||
$(EOLIST)
|
||||
|
||||
XCFLAGS += \
|
||||
$(EOLIST)
|
||||
|
||||
XDEFINES += \
|
||||
$(EOLIST)
|
||||
|
||||
XLFLAGS += \
|
||||
$(EOLIST)
|
||||
endif
|
||||
|
||||
ifeq "$(RELEASE)" "release"
|
||||
XINCDIRS += \
|
||||
$(EOLIST)
|
||||
|
||||
XCFLAGS += \
|
||||
$(EOLIST)
|
||||
|
||||
XDEFINES += \
|
||||
$(EOLIST)
|
||||
|
||||
XLFLAGS += \
|
||||
$(EOLIST)
|
||||
endif
|
||||
|
||||
#
|
||||
# These are used by the link target if an NLM is being generated
|
||||
# This is used by the link 'name' directive to name the nlm. If left blank
|
||||
# TARGET_nlm (see below) will be used.
|
||||
#
|
||||
NLM_NAME = aprlib
|
||||
|
||||
#
|
||||
# This is used by the link '-desc ' directive.
|
||||
# If left blank, NLM_NAME will be used.
|
||||
#
|
||||
NLM_DESCRIPTION = Apache Portability Runtime Library $(VERSION_STR) $(VERSION_SKT)
|
||||
|
||||
#
|
||||
# This is used by the '-threadname' directive. If left blank,
|
||||
# NLM_NAME Thread will be used.
|
||||
#
|
||||
NLM_THREAD_NAME =
|
||||
#
|
||||
# If this is specified, it will override VERSION value in
|
||||
# $(APR_WORK)/build/NWGNUenvironment.inc
|
||||
#
|
||||
NLM_VERSION =
|
||||
|
||||
#
|
||||
# If this is specified, it will override the default of 64K
|
||||
#
|
||||
NLM_STACK_SIZE =
|
||||
|
||||
#
|
||||
# If this is specified it will be used by the link '-entry' directive
|
||||
#
|
||||
NLM_ENTRY_SYM =
|
||||
|
||||
#
|
||||
# If this is specified it will be used by the link '-exit' directive
|
||||
#
|
||||
NLM_EXIT_SYM =
|
||||
|
||||
#
|
||||
# If this is specified it will be used by the link '-check' directive
|
||||
#
|
||||
NLM_CHECK_SYM =
|
||||
|
||||
#
|
||||
# If this is specified it will be used by the link '-flags' directive
|
||||
#
|
||||
NLM_FLAGS =
|
||||
|
||||
#
|
||||
# If this is specified it will be linked in with the XDCData option in the def
|
||||
# file instead of the default of $(APR)/misc/netware/apache.xdc. XDCData can
|
||||
# be disabled by setting APACHE_UNIPROC in the environment
|
||||
#
|
||||
XDCDATA =
|
||||
|
||||
#
|
||||
# Declare all target files (you must add your files here)
|
||||
#
|
||||
|
||||
#
|
||||
# If there is an NLM target, put it here
|
||||
#
|
||||
TARGET_nlm = \
|
||||
$(OBJDIR)/aprlib.nlm \
|
||||
$(EOLIST)
|
||||
|
||||
#
|
||||
# If there is an LIB target, put it here
|
||||
#
|
||||
TARGET_lib = \
|
||||
$(OBJDIR)/aprlib.lib \
|
||||
$(EOLIST)
|
||||
|
||||
#
|
||||
# These are the OBJ files needed to create the NLM target above.
|
||||
# Paths must all use the '/' character
|
||||
#
|
||||
FILES_nlm_objs = \
|
||||
$(OBJDIR)/libprews.o \
|
||||
$(EOLIST)
|
||||
|
||||
#
|
||||
# These are the LIB files needed to create the NLM target above.
|
||||
# These will be added as a library command in the link.opt file.
|
||||
#
|
||||
FILES_nlm_libs = \
|
||||
$(PRELUDE) \
|
||||
$(APRLIB) \
|
||||
$(APULIB) \
|
||||
$(APULDAPLIB) \
|
||||
$(APUXMLLIB) \
|
||||
$(EOLIST)
|
||||
|
||||
#
|
||||
# These are the modules that the above NLM target depends on to load.
|
||||
# These will be added as a module command in the link.opt file.
|
||||
#
|
||||
FILES_nlm_modules = \
|
||||
Libc \
|
||||
$(EOLIST)
|
||||
|
||||
# Include the Winsock libraries if Winsock is being used
|
||||
ifndef USE_STDSOCKETS
|
||||
FILES_nlm_modules += ws2_32 \
|
||||
$(EOLIST)
|
||||
endif
|
||||
|
||||
#If the LDAP support is defined then add the auto-load modules
|
||||
ifneq "$(LDAPSDK)" ""
|
||||
FILES_nlm_modules += \
|
||||
lldapsdk \
|
||||
lldapssl \
|
||||
$(EOLIST)
|
||||
endif
|
||||
|
||||
#
|
||||
# If the nlm has a msg file, put it's path here
|
||||
#
|
||||
FILE_nlm_msg =
|
||||
|
||||
#
|
||||
# If the nlm has a hlp file put it's path here
|
||||
#
|
||||
FILE_nlm_hlp =
|
||||
|
||||
#
|
||||
# If this is specified, it will override $(NWOS)\copyright.txt.
|
||||
#
|
||||
FILE_nlm_copyright =
|
||||
|
||||
#
|
||||
# Any additional imports go here
|
||||
#
|
||||
FILES_nlm_Ximports = \
|
||||
@libc.imp \
|
||||
@netware.imp \
|
||||
$(EOLIST)
|
||||
|
||||
# Include the Winsock imports if Winsock is being used
|
||||
ifndef USE_STDSOCKETS
|
||||
FILES_nlm_Ximports += \
|
||||
@ws2nlm.imp \
|
||||
WSAStartupRTags \
|
||||
WSACleanupRTag \
|
||||
$(EOLIST)
|
||||
endif
|
||||
|
||||
#If the LDAP support is defined then add the imports
|
||||
ifneq "$(LDAPSDK)" ""
|
||||
FILES_nlm_Ximports += \
|
||||
@lldapsdk.imp \
|
||||
@lldapssl.imp \
|
||||
$(EOLIST)
|
||||
endif
|
||||
|
||||
#
|
||||
# Any symbols exported to here
|
||||
#
|
||||
FILES_nlm_exports = \
|
||||
@aprlib.imp \
|
||||
$(EOLIST)
|
||||
|
||||
#
|
||||
# These are the OBJ files needed to create the LIB target above.
|
||||
# Paths must all use the '/' character
|
||||
#
|
||||
FILES_lib_objs = \
|
||||
$(OBJDIR)/apr_atomic.o \
|
||||
$(OBJDIR)/apr_cpystrn.o \
|
||||
$(OBJDIR)/apr_escape.o \
|
||||
$(OBJDIR)/apr_fnmatch.o \
|
||||
$(OBJDIR)/apr_getpass.o \
|
||||
$(OBJDIR)/apr_hash.o \
|
||||
$(OBJDIR)/apr_pools.o \
|
||||
$(OBJDIR)/apr_random.o \
|
||||
$(OBJDIR)/apr_skiplist.o \
|
||||
$(OBJDIR)/apr_snprintf.o \
|
||||
$(OBJDIR)/apr_strings.o \
|
||||
$(OBJDIR)/apr_strnatcmp.o \
|
||||
$(OBJDIR)/apr_strtok.o \
|
||||
$(OBJDIR)/apr_tables.o \
|
||||
$(OBJDIR)/buffer.o \
|
||||
$(OBJDIR)/charset.o \
|
||||
$(OBJDIR)/copy.o \
|
||||
$(OBJDIR)/common.o \
|
||||
$(OBJDIR)/dir.o \
|
||||
$(OBJDIR)/dso.o \
|
||||
$(OBJDIR)/errorcodes.o \
|
||||
$(OBJDIR)/env.o \
|
||||
$(OBJDIR)/fileacc.o \
|
||||
$(OBJDIR)/filedup.o \
|
||||
$(OBJDIR)/filepath.o \
|
||||
$(OBJDIR)/filepath_util.o \
|
||||
$(OBJDIR)/filestat.o \
|
||||
$(OBJDIR)/filesys.o \
|
||||
$(OBJDIR)/flock.o \
|
||||
$(OBJDIR)/fullrw.o \
|
||||
$(OBJDIR)/getopt.o \
|
||||
$(OBJDIR)/groupinfo.o \
|
||||
$(OBJDIR)/inet_pton.o \
|
||||
$(OBJDIR)/inet_ntop.o \
|
||||
$(OBJDIR)/mktemp.o \
|
||||
$(OBJDIR)/mmap.o \
|
||||
$(OBJDIR)/multicast.o \
|
||||
$(OBJDIR)/open.o \
|
||||
$(OBJDIR)/pipe.o \
|
||||
$(OBJDIR)/otherchild.o \
|
||||
$(OBJDIR)/proc.o \
|
||||
$(OBJDIR)/procsup.o \
|
||||
$(OBJDIR)/proc_mutex.o \
|
||||
$(OBJDIR)/rand.o \
|
||||
$(OBJDIR)/readwrite.o \
|
||||
$(OBJDIR)/seek.o \
|
||||
$(OBJDIR)/pollcb.o \
|
||||
$(OBJDIR)/pollset.o \
|
||||
$(OBJDIR)/select.o \
|
||||
$(OBJDIR)/sendrecv.o \
|
||||
$(OBJDIR)/sha2.o \
|
||||
$(OBJDIR)/sha2_glue.o \
|
||||
$(OBJDIR)/shm.o \
|
||||
$(OBJDIR)/signals.o \
|
||||
$(OBJDIR)/sockaddr.o \
|
||||
$(OBJDIR)/socket_util.o \
|
||||
$(OBJDIR)/sockets.o \
|
||||
$(OBJDIR)/sockopt.o \
|
||||
$(OBJDIR)/start.o \
|
||||
$(OBJDIR)/tempdir.o \
|
||||
$(OBJDIR)/thread.o \
|
||||
$(OBJDIR)/thread_cond.o \
|
||||
$(OBJDIR)/thread_mutex.o \
|
||||
$(OBJDIR)/thread_rwlock.o \
|
||||
$(OBJDIR)/threadpriv.o \
|
||||
$(OBJDIR)/time.o \
|
||||
$(OBJDIR)/timestr.o \
|
||||
$(OBJDIR)/userinfo.o \
|
||||
$(OBJDIR)/version.o \
|
||||
$(OBJDIR)/waitio.o \
|
||||
$(OBJDIR)/wakeup.o \
|
||||
$(EOLIST)
|
||||
|
||||
|
||||
#
|
||||
# implement targets and dependancies (leave this section alone)
|
||||
#
|
||||
|
||||
libs :: $(OBJDIR) $(TARGET_lib)
|
||||
|
||||
nlms :: libs $(TARGET_nlm)
|
||||
|
||||
#
|
||||
# Updated this target to create necessary directories and copy files to the
|
||||
# correct place. (See $(APR_WORK)/build/NWGNUhead.inc for examples)
|
||||
#
|
||||
install :: nlms $(INSTDIRS) FORCE
|
||||
$(call COPY,$(APR)/$(TARGET_nlm),$(INSTALLBASE)/)
|
||||
ifndef DEST
|
||||
-$(call COPY,$(APR)/LICENSE,$(INSTALLBASE)/)
|
||||
-$(call COPY,$(APR)/STATUS,$(INSTALLBASE)/STATUS.apr)
|
||||
-$(call COPY,$(APR)/CHANGES,$(INSTALLBASE)/CHANGES.apr)
|
||||
-$(call COPY,$(APU)/STATUS,$(INSTALLBASE)/STATUS.apu)
|
||||
-$(call COPY,$(APU)/CHANGES,$(INSTALLBASE)/CHANGES.apu)
|
||||
-$(call COPYR,$(APR)/docs,$(INSTALLBASE)/docs/)
|
||||
endif
|
||||
|
||||
ifndef DEST
|
||||
installdev :: $(INSTDEVDIRS) FORCE
|
||||
$(call COPY,$(APR)/include/*.h,$(INSTALLBASE)/include/)
|
||||
$(call COPY,$(APR)/*.imp,$(INSTALLBASE)/lib/)
|
||||
$(call COPY,$(APR)/misc/netware/*.xdc,$(INSTALLBASE)/lib/)
|
||||
$(call COPY,$(APR)/$(TARGET_nlm),$(INSTALLBASE)/bin/)
|
||||
$(call COPY,$(APRLIB),$(INSTALLBASE)/lib/)
|
||||
$(call COPY,$(APULIB),$(INSTALLBASE)/lib/)
|
||||
$(call COPY,$(APULDAPLIB),$(INSTALLBASE)/lib/)
|
||||
$(call COPY,$(APUXMLLIB),$(INSTALLBASE)/lib/)
|
||||
|
||||
$(INSTDEVDIRS) ::
|
||||
$(call MKDIR,$@)
|
||||
endif
|
||||
|
||||
#
|
||||
# Any specialized rules here
|
||||
#
|
||||
|
||||
vpath %.c atomic/netware:strings:tables:passwd:lib:time/unix
|
||||
vpath %.c file_io/unix:locks/netware:misc/netware:misc/unix:threadproc/netware
|
||||
vpath %.c poll/unix:shmem/unix:support/unix:random/unix
|
||||
vpath %.c dso/netware:memory/unix:mmap/unix:user/netware:encoding
|
||||
|
||||
# Use the win32 network_io if Winsock is being used
|
||||
ifndef USE_STDSOCKETS
|
||||
vpath %.c network_io/win32
|
||||
endif
|
||||
vpath %.c network_io/unix
|
||||
|
||||
$(OBJDIR)/%.o: file_io/netware/%.c $(OBJDIR)/$(NLM_NAME)_cc.opt
|
||||
# @echo Compiling $<
|
||||
@echo $(DL)CC $<$(DL)
|
||||
$(CC) $< -cwd source -o=$@ @$(OBJDIR)/$(NLM_NAME)_cc.opt
|
||||
|
||||
#
|
||||
# Include the 'tail' makefile that has targets that depend on variables defined
|
||||
# in this makefile
|
||||
#
|
||||
|
||||
include $(APRBUILD)/NWGNUtail.inc
|
||||
|
||||
|
||||
Vendored
-167
@@ -1,167 +0,0 @@
|
||||
Apache Portable Runtime Library (APR)
|
||||
-------------------------------------
|
||||
|
||||
The Apache Portable Runtime Library provides a predictable and
|
||||
consistent interface to underlying platform-specific
|
||||
implementations, with an API to which software developers may code
|
||||
and be assured of predictable if not identical behavior regardless
|
||||
of the platform on which their software is built, relieving them of
|
||||
the need to code special-case conditions to work around or take
|
||||
advantage of platform-specific deficiencies or features.
|
||||
|
||||
APR and its companion libraries are implemented entirely in C
|
||||
and provide a common programming interface across a wide variety
|
||||
of operating system platforms without sacrificing performance.
|
||||
Currently supported platforms include:
|
||||
|
||||
UNIX variants
|
||||
Windows
|
||||
Netware
|
||||
Mac OS X
|
||||
OS/2
|
||||
|
||||
To give a brief overview, the primary core
|
||||
subsystems of APR 1.3 include the following:
|
||||
|
||||
Atomic operations
|
||||
Dynamic Shared Object loading
|
||||
File I/O
|
||||
Locks (mutexes, condition variables, etc)
|
||||
Memory management (high performance allocators)
|
||||
Memory-mapped files
|
||||
Multicast Sockets
|
||||
Network I/O
|
||||
Shared memory
|
||||
Thread and Process management
|
||||
Various data structures (tables, hashes, priority queues, etc)
|
||||
|
||||
For a more complete list, please refer to the following URLs:
|
||||
|
||||
http://apr.apache.org/docs/apr/modules.html
|
||||
|
||||
Users of APR 0.9 should be aware that migrating to the APR 1.x
|
||||
programming interfaces may require some adjustments; APR 1.x is
|
||||
neither source nor binary compatible with earlier APR 0.9 releases.
|
||||
Users of APR 1.x can expect consistent interfaces and binary backwards
|
||||
compatibility throughout the entire APR 1.x release cycle, as defined
|
||||
in our versioning rules:
|
||||
|
||||
http://apr.apache.org/versioning.html
|
||||
|
||||
APR is already used extensively by the Apache HTTP Server
|
||||
version 2 and the Subversion revision control system, to
|
||||
name but a few. We list all known projects using APR at
|
||||
http://apr.apache.org/projects.html -- so please let us know
|
||||
if you find our libraries useful in your own projects!
|
||||
|
||||
|
||||
Using a Subversion Checkout on Unix
|
||||
===================================
|
||||
|
||||
If you are building APR from SVN, you need to perform a prerequisite
|
||||
step. You must have autoconf, libtool and python installed for this
|
||||
to work. The prerequisite is simply;
|
||||
|
||||
./buildconf
|
||||
|
||||
If you are building APR from a distribution tarball, buildconf is
|
||||
already run for you, and you do not need autoconf, libtool or python
|
||||
installed or to run buildconf unless you have patched APR's buildconf
|
||||
inputs (such as configure.in, build.conf, virtually any file within
|
||||
the build/ tree, or you add or remove source files).
|
||||
|
||||
Remember when updating from svn that you must rerun ./buildconf again
|
||||
to effect any changes made to the build schema in your fresh update.
|
||||
|
||||
|
||||
Configuring and Building APR on Unix
|
||||
====================================
|
||||
|
||||
Simply;
|
||||
|
||||
./configure --prefix=/desired/path/of/apr
|
||||
make
|
||||
make test
|
||||
make install
|
||||
|
||||
Configure has additional options, ./configure --help will offer you
|
||||
those choices. You may also add CC=compiler CFLAGS="compiler flags"
|
||||
etc. prior to the ./configure statement (on the same line). Please
|
||||
be warned, some flags must be passed as part of the CC command,
|
||||
itself, in order for autoconf to make the right determinations. Eg.;
|
||||
|
||||
CC="gcc -m64" ./configure --prefix=/desired/path/of/apr
|
||||
|
||||
will inform APR that you are compiling to a 64 bit CPU, and autoconf
|
||||
must consider that when setting up all of APR's internal and external
|
||||
type declarations.
|
||||
|
||||
For more verbose output from testall, you may wish to invoke testall
|
||||
with the flag;
|
||||
|
||||
cd test
|
||||
./testall -v
|
||||
|
||||
|
||||
Building APR RPM files on Linux
|
||||
===============================
|
||||
|
||||
Run the following to create SRPMs:
|
||||
|
||||
rpmbuild -ts apr-<version>.tar.bz2
|
||||
rpmbuild -ts apr-util-<version>.tar.bz2
|
||||
|
||||
Run the following to create RPMs (or build from the SRPMs):
|
||||
|
||||
rpmbuild -tb apr-<version>.tar.bz2
|
||||
rpmbuild -tb apr-util-<version>.tar.bz2
|
||||
|
||||
Resolve dependencies as appropriate.
|
||||
|
||||
|
||||
Configuring and Building APR on Windows
|
||||
=======================================
|
||||
|
||||
Using Visual Studio, you can build and run the test validation of APR.
|
||||
The Makefile.win make file has a bunch of documentation about it's
|
||||
options, but a trivial build is simply;
|
||||
|
||||
nmake -f Makefile.win
|
||||
nmake -f Makefile.win PREFIX=c:\desired\path\of\apr install
|
||||
|
||||
Note you must manually modify the include\apr.hw file before you
|
||||
build to change default options, see the #define APR_HAS_... or the
|
||||
#define APR_HAVE_... statements. Be careful, many of these aren't
|
||||
appropriate to be modified. The most common change is
|
||||
|
||||
#define APR_HAVE_IPV6 1
|
||||
|
||||
rather than 0 if this build of APR will be used strictly on machines
|
||||
with the IPv6 adapter support installed.
|
||||
|
||||
It's trivial to include the apr.dsp (for a static library) or the
|
||||
libapr.dsp (for a dynamic library) in your own build project, or you
|
||||
can load apr.dsw in Visual Studio 2002 (.NET) or later, which will
|
||||
convert these for you into apr.sln and associated .vcproj files.
|
||||
|
||||
When using APR as a dynamic library, nothing special is required,
|
||||
simply link to libapr.lib. To use it as a static library, simply
|
||||
define APR_DECLARE_STATIC before you include any apr header files
|
||||
in your source, and link to apr.lib instead.
|
||||
|
||||
|
||||
Generating Test Coverage information with gcc
|
||||
=============================================
|
||||
|
||||
If you want to generate test coverage data, use the following steps:
|
||||
|
||||
./buildconf
|
||||
CFLAGS="-fprofile-arcs -ftest-coverage" ./configure
|
||||
make
|
||||
cd test
|
||||
make
|
||||
./testall
|
||||
cd ..
|
||||
make gcov
|
||||
|
||||
|
||||
-112
@@ -1,112 +0,0 @@
|
||||
Experimental cmake-based build support for APR on Microsoft Windows
|
||||
|
||||
Status
|
||||
------
|
||||
|
||||
This build support is currently intended only for Microsoft Windows.
|
||||
Only Windows NT-based systems can be targeted. (The traditional
|
||||
Windows build support for APR can target Windows 9x as well.)
|
||||
|
||||
This build support is experimental. Specifically,
|
||||
|
||||
* It does not support all features of APR.
|
||||
* Some components may not be built correctly and/or in a manner
|
||||
compatible with the previous Windows build support.
|
||||
* Build interfaces, such as the mechanisms which are used to enable
|
||||
optional functionality or specify prerequisites, may change from
|
||||
release to release as feedback is received from users and bugs and
|
||||
limitations are resolved.
|
||||
|
||||
Important: Refer to the "Known Bugs and Limitations" section for further
|
||||
information.
|
||||
|
||||
It is beyond the scope of this document to document or explain
|
||||
how to utilize the various cmake features, such as different
|
||||
build backends or provisions for finding support libraries.
|
||||
|
||||
Please refer to the cmake documentation for additional information
|
||||
that applies to building any project with cmake.
|
||||
|
||||
Prerequisites
|
||||
-------------
|
||||
|
||||
The following tools must be in PATH:
|
||||
|
||||
* cmake, version 2.8 or later
|
||||
* If using a command-line compiler: compiler and linker and related tools
|
||||
(Refer to the cmake documentation for more information.)
|
||||
|
||||
How to build
|
||||
------------
|
||||
|
||||
1. cd to a clean directory for building (i.e., don't build in your
|
||||
source tree)
|
||||
|
||||
2. Some cmake backends may want your compile tools in PATH. (Hint: "Visual
|
||||
Studio Command Prompt")
|
||||
|
||||
3. cmake -G "some backend, like 'NMake Makefiles'"
|
||||
-DCMAKE_INSTALL_PREFIX=d:/path/to/aprinst
|
||||
-DAPR-specific-flags
|
||||
d:/path/to/aprsource
|
||||
|
||||
Alternately, use cmake-gui and update settings in the GUI.
|
||||
|
||||
APR feature flags:
|
||||
|
||||
APR_INSTALL_PRIVATE_H Install extra .h files which are required when
|
||||
building httpd and Subversion but which aren't
|
||||
intended for use by applications.
|
||||
Default: OFF
|
||||
APR_HAVE_IPV6 Enable IPv6 support
|
||||
Default: ON
|
||||
APR_BUILD_TESTAPR Build APR test suite
|
||||
Default: OFF
|
||||
TEST_STATIC_LIBS Build the test suite to test the APR static
|
||||
library instead of the APR dynamic library.
|
||||
Default: OFF
|
||||
In order to build the test suite against both
|
||||
static and dynamic libraries, separate builds
|
||||
will be required, one with TEST_STATIC_LIBS
|
||||
set to ON.
|
||||
MIN_WINDOWS_VER Minimum Windows version supported by this build
|
||||
(This controls the setting of _WIN32_WINNT.)
|
||||
"Vista" or "Windows7" or a numeric value like
|
||||
"0x0601"
|
||||
Default: "Vista"
|
||||
For desktop/server equivalence or other values,
|
||||
refer to
|
||||
http://msdn.microsoft.com/en-us/library/windows/
|
||||
desktop/aa383745(v=vs.85).aspx
|
||||
INSTALL_PDB Install .pdb files if generated.
|
||||
Default: ON
|
||||
|
||||
CMAKE_C_FLAGS_RELEASE, _DEBUG, _RELWITHDEBINFO, _MINSIZEREL
|
||||
|
||||
CMAKE_BUILD_TYPE
|
||||
|
||||
For NMake Makefiles the choices are at least DEBUG, RELEASE,
|
||||
RELWITHDEBINFO, and MINSIZEREL
|
||||
Other backends make have other selections.
|
||||
|
||||
4. build using chosen backend (e.g., "nmake install")
|
||||
|
||||
Known Bugs and Limitations
|
||||
--------------------------
|
||||
|
||||
* If include/apr.h or other generated files have been created in the source
|
||||
directory by another build system, they will be used unexpectedly and
|
||||
cause the build to fail.
|
||||
* Options should be provided for remaining features:
|
||||
+ APR_POOL_DEBUG
|
||||
* APR-CHANGES.txt, APR-LICENSE.txt, and APR-NOTICE.txt are not installed,
|
||||
though perhaps that is a job for a higher-level script.
|
||||
|
||||
Generally:
|
||||
|
||||
* Many APR features have not been tested with this build.
|
||||
* Developers need to examine the existing Windows build in great detail and see
|
||||
what is missing from the cmake-based build, whether a feature or some build
|
||||
nuance.
|
||||
* Any feedback you can provide on your experiences with this build will be
|
||||
helpful.
|
||||
-251
@@ -1,251 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
# APR script designed to allow easy command line access to APR configuration
|
||||
# parameters.
|
||||
|
||||
APR_MAJOR_VERSION="@APR_MAJOR_VERSION@"
|
||||
APR_DOTTED_VERSION="@APR_DOTTED_VERSION@"
|
||||
|
||||
prefix="@prefix@"
|
||||
exec_prefix="@exec_prefix@"
|
||||
bindir="@bindir@"
|
||||
libdir="@libdir@"
|
||||
datarootdir="@datadir@"
|
||||
datadir="@datadir@"
|
||||
installbuilddir="@installbuilddir@"
|
||||
includedir="@includedir@"
|
||||
|
||||
CC="@CC@"
|
||||
CPP="@CPP@"
|
||||
SHELL="@SHELL@"
|
||||
CPPFLAGS="@EXTRA_CPPFLAGS@"
|
||||
CFLAGS="@EXTRA_CFLAGS@"
|
||||
LDFLAGS="@EXTRA_LDFLAGS@"
|
||||
LIBS="@EXTRA_LIBS@"
|
||||
EXTRA_INCLUDES="@EXTRA_INCLUDES@"
|
||||
SHLIBPATH_VAR="@shlibpath_var@"
|
||||
APR_SOURCE_DIR="@apr_srcdir@"
|
||||
APR_BUILD_DIR="@apr_builddir@"
|
||||
APR_SO_EXT="@so_ext@"
|
||||
APR_LIB_TARGET="@export_lib_target@"
|
||||
APR_LIBNAME="@APR_LIBNAME@"
|
||||
|
||||
# NOTE: the following line is modified during 'make install': alter with care!
|
||||
location=@APR_CONFIG_LOCATION@
|
||||
|
||||
show_usage()
|
||||
{
|
||||
cat << EOF
|
||||
Usage: apr-$APR_MAJOR_VERSION-config [OPTION]
|
||||
|
||||
Known values for OPTION are:
|
||||
--prefix[=DIR] change prefix to DIR
|
||||
--bindir print location where binaries are installed
|
||||
--includedir print location where headers are installed
|
||||
--cc print C compiler name
|
||||
--cpp print C preprocessor name and any required options
|
||||
--cflags print C compiler flags
|
||||
--cppflags print C preprocessor flags
|
||||
--includes print include information
|
||||
--ldflags print linker flags
|
||||
--libs print additional libraries to link against
|
||||
--srcdir print APR source directory
|
||||
--installbuilddir print APR build helper directory
|
||||
--link-ld print link switch(es) for linking to APR
|
||||
--link-libtool print the libtool inputs for linking to APR
|
||||
--shlib-path-var print the name of the shared library path env var
|
||||
--apr-la-file print the path to the .la file, if available
|
||||
--apr-so-ext print the extensions of shared objects on this platform
|
||||
--apr-lib-target print the libtool target information
|
||||
--apr-libtool print the path to APR's libtool
|
||||
--version print the APR's version as a dotted triple
|
||||
--help print this help
|
||||
|
||||
When linking with libtool, an application should do something like:
|
||||
APR_LIBS="\`apr-$APR_MAJOR_VERSION-config --link-libtool --libs\`"
|
||||
or when linking directly:
|
||||
APR_LIBS="\`apr-$APR_MAJOR_VERSION-config --link-ld --libs\`"
|
||||
|
||||
An application should use the results of --cflags, --cppflags, --includes,
|
||||
and --ldflags in their build process.
|
||||
EOF
|
||||
}
|
||||
|
||||
if test $# -eq 0; then
|
||||
show_usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test "$location" = "installed"; then
|
||||
LA_FILE="$libdir/lib${APR_LIBNAME}.la"
|
||||
else
|
||||
LA_FILE="$APR_BUILD_DIR/lib${APR_LIBNAME}.la"
|
||||
fi
|
||||
|
||||
flags=""
|
||||
|
||||
while test $# -gt 0; do
|
||||
# Normalize the prefix.
|
||||
case "$1" in
|
||||
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
|
||||
*) optarg= ;;
|
||||
esac
|
||||
|
||||
case "$1" in
|
||||
# It is possible for the user to override our prefix.
|
||||
--prefix=*)
|
||||
prefix=$optarg
|
||||
;;
|
||||
--prefix)
|
||||
echo $prefix
|
||||
exit 0
|
||||
;;
|
||||
--bindir)
|
||||
echo $bindir
|
||||
exit 0
|
||||
;;
|
||||
--includedir)
|
||||
if test "$location" = "installed"; then
|
||||
flags="$includedir"
|
||||
elif test "$location" = "source"; then
|
||||
flags="$APR_SOURCE_DIR/include"
|
||||
else
|
||||
# this is for VPATH builds
|
||||
flags="$APR_BUILD_DIR/include $APR_SOURCE_DIR/include"
|
||||
fi
|
||||
echo $flags
|
||||
exit 0
|
||||
;;
|
||||
--cc)
|
||||
echo $CC
|
||||
exit 0
|
||||
;;
|
||||
--cpp)
|
||||
echo $CPP
|
||||
exit 0
|
||||
;;
|
||||
--cflags)
|
||||
flags="$flags $CFLAGS"
|
||||
;;
|
||||
--cppflags)
|
||||
flags="$flags $CPPFLAGS"
|
||||
;;
|
||||
--libs)
|
||||
flags="$flags $LIBS"
|
||||
;;
|
||||
--ldflags)
|
||||
flags="$flags $LDFLAGS"
|
||||
;;
|
||||
--includes)
|
||||
if test "$location" = "installed"; then
|
||||
flags="$flags -I$includedir $EXTRA_INCLUDES"
|
||||
elif test "$location" = "source"; then
|
||||
flags="$flags -I$APR_SOURCE_DIR/include $EXTRA_INCLUDES"
|
||||
else
|
||||
# this is for VPATH builds
|
||||
flags="$flags -I$APR_BUILD_DIR/include -I$APR_SOURCE_DIR/include $EXTRA_INCLUDES"
|
||||
fi
|
||||
;;
|
||||
--srcdir)
|
||||
echo $APR_SOURCE_DIR
|
||||
exit 0
|
||||
;;
|
||||
--installbuilddir)
|
||||
if test "$location" = "installed"; then
|
||||
echo "${installbuilddir}"
|
||||
elif test "$location" = "source"; then
|
||||
echo "$APR_SOURCE_DIR/build"
|
||||
else
|
||||
# this is for VPATH builds
|
||||
echo "$APR_BUILD_DIR/build"
|
||||
fi
|
||||
exit 0
|
||||
;;
|
||||
--version)
|
||||
echo $APR_DOTTED_VERSION
|
||||
exit 0
|
||||
;;
|
||||
--link-ld)
|
||||
if test "$location" = "installed"; then
|
||||
### avoid using -L if libdir is a "standard" location like /usr/lib
|
||||
flags="$flags -L$libdir -l${APR_LIBNAME}"
|
||||
else
|
||||
### this surely can't work since the library is in .libs?
|
||||
flags="$flags -L$APR_BUILD_DIR -l${APR_LIBNAME}"
|
||||
fi
|
||||
;;
|
||||
--link-libtool)
|
||||
# If the LA_FILE exists where we think it should be, use it. If we're
|
||||
# installed and the LA_FILE does not exist, assume to use -L/-l
|
||||
# (the LA_FILE may not have been installed). If we're building ourselves,
|
||||
# we'll assume that at some point the .la file be created.
|
||||
if test -f "$LA_FILE"; then
|
||||
flags="$flags $LA_FILE"
|
||||
elif test "$location" = "installed"; then
|
||||
### avoid using -L if libdir is a "standard" location like /usr/lib
|
||||
# Since the user is specifying they are linking with libtool, we
|
||||
# *know* that -R will be recognized by libtool.
|
||||
flags="$flags -L$libdir -R$libdir -l${APR_LIBNAME}"
|
||||
else
|
||||
flags="$flags $LA_FILE"
|
||||
fi
|
||||
;;
|
||||
--shlib-path-var)
|
||||
echo "$SHLIBPATH_VAR"
|
||||
exit 0
|
||||
;;
|
||||
--apr-la-file)
|
||||
if test -f "$LA_FILE"; then
|
||||
flags="$flags $LA_FILE"
|
||||
fi
|
||||
;;
|
||||
--apr-so-ext)
|
||||
echo "$APR_SO_EXT"
|
||||
exit 0
|
||||
;;
|
||||
--apr-lib-target)
|
||||
echo "$APR_LIB_TARGET"
|
||||
exit 0
|
||||
;;
|
||||
--apr-libtool)
|
||||
if test "$location" = "installed"; then
|
||||
echo "${installbuilddir}/libtool"
|
||||
else
|
||||
echo "$APR_BUILD_DIR/libtool"
|
||||
fi
|
||||
exit 0
|
||||
;;
|
||||
--help)
|
||||
show_usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
show_usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Next please.
|
||||
shift
|
||||
done
|
||||
|
||||
if test -n "$flags"; then
|
||||
echo "$flags"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
Vendored
-1916
File diff suppressed because it is too large
Load Diff
Vendored
-818
@@ -1,818 +0,0 @@
|
||||
# Microsoft Developer Studio Project File - Name="apr" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=apr - Win32 Release
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "apr.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "apr.mak" CFG="apr - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "apr - Win32 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "apr - Win32 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "apr - x64 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "apr - x64 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "apr - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "LibR"
|
||||
# PROP BASE Intermediate_Dir "LibR"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "LibR"
|
||||
# PROP Intermediate_Dir "LibR"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /Zi /O2 /Oy- /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "NDEBUG" /D "APR_DECLARE_STATIC" /D "WIN32" /D "WINNT" /D "_WINDOWS" /Fo"$(INTDIR)\" /Fd"$(OUTDIR)\apr-1" /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo /out:"LibR\apr-1.lib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "apr - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "LibD"
|
||||
# PROP BASE Intermediate_Dir "LibD"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "LibD"
|
||||
# PROP Intermediate_Dir "LibD"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MDd /W3 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /EHsc /c
|
||||
# ADD CPP /nologo /MDd /W3 /Zi /Od /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "_DEBUG" /D "APR_DECLARE_STATIC" /D "WIN32" /D "WINNT" /D "_WINDOWS" /Fo"$(INTDIR)\" /Fd"$(OUTDIR)\apr-1" /FD /EHsc /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo /out:"LibD\apr-1.lib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "apr - x64 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "x64\LibR"
|
||||
# PROP BASE Intermediate_Dir "x64\LibR"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "x64\LibR"
|
||||
# PROP Intermediate_Dir "x64\LibR"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /Zi /O2 /Oy- /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "NDEBUG" /D "APR_DECLARE_STATIC" /D "WIN32" /D "WINNT" /D "_WINDOWS" /Fo"$(INTDIR)\" /Fd"$(OUTDIR)\apr-1" /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo /out:"x64\LibR\apr-1.lib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "apr - x64 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "x64\LibD"
|
||||
# PROP BASE Intermediate_Dir "x64\LibD"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "x64\LibD"
|
||||
# PROP Intermediate_Dir "x64\LibD"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MDd /W3 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /EHsc /c
|
||||
# ADD CPP /nologo /MDd /W3 /Zi /Od /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "_DEBUG" /D "APR_DECLARE_STATIC" /D "WIN32" /D "WINNT" /D "_WINDOWS" /Fo"$(INTDIR)\" /Fd"$(OUTDIR)\apr-1" /FD /EHsc /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo /out:"x64\LibD\apr-1.lib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "apr - Win32 Release"
|
||||
# Name "apr - Win32 Debug"
|
||||
# Name "apr - x64 Release"
|
||||
# Name "apr - x64 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter ".c"
|
||||
# Begin Group "atomic"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\atomic\win32\apr_atomic.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "dso"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dso\win32\dso.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "encoding"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\encoding\apr_escape.c
|
||||
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "file_io"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\file_io\win32\buffer.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\file_io\unix\copy.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\file_io\win32\dir.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\file_io\unix\fileacc.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\file_io\win32\filedup.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\file_io\win32\filepath.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\file_io\unix\filepath_util.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\file_io\win32\filestat.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\file_io\win32\filesys.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\file_io\win32\flock.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\file_io\unix\fullrw.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\file_io\unix\mktemp.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\file_io\win32\open.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\file_io\win32\pipe.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\file_io\win32\readwrite.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\file_io\win32\seek.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\file_io\unix\tempdir.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "locks"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\locks\win32\proc_mutex.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\locks\win32\thread_cond.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\locks\win32\thread_mutex.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\locks\win32\thread_rwlock.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "memory"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\memory\unix\apr_pools.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "misc"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\misc\win32\apr_app.c
|
||||
# PROP Exclude_From_Build 1
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\misc\win32\charset.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\misc\win32\env.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\misc\unix\errorcodes.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\misc\unix\getopt.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\misc\win32\internal.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\misc\win32\misc.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\misc\unix\otherchild.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\misc\win32\rand.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\misc\win32\start.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\misc\win32\utf8.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\misc\unix\version.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "mmap"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\mmap\unix\common.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\mmap\win32\mmap.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "network_io"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\network_io\unix\inet_ntop.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\network_io\unix\inet_pton.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\network_io\unix\multicast.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\network_io\win32\sendrecv.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\network_io\unix\sockaddr.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\network_io\win32\sockets.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\network_io\unix\socket_util.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\network_io\win32\sockopt.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "passwd"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\passwd\apr_getpass.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "poll"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\poll\unix\poll.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\poll\unix\pollcb.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\poll\unix\pollset.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\poll\unix\select.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\poll\unix\wakeup.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "random"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\random\unix\apr_random.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\random\unix\sha2.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\random\unix\sha2_glue.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "shmem"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\shmem\win32\shm.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "strings"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\strings\apr_cpystrn.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\strings\apr_fnmatch.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\strings\apr_snprintf.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\strings\apr_strings.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\strings\apr_strnatcmp.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\strings\apr_strtok.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "tables"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tables\apr_hash.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tables\apr_skiplist.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tables\apr_tables.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "threadproc"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\threadproc\win32\proc.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\threadproc\win32\signals.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\threadproc\win32\thread.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\threadproc\win32\threadpriv.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "time"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\time\win32\time.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\time\win32\timestr.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "user"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\user\win32\groupinfo.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\user\win32\userinfo.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Group
|
||||
# Begin Group "Private Header Files"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\arch\win32\apr_arch_atime.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\arch\win32\apr_arch_dso.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\arch\win32\apr_arch_file_io.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\arch\win32\apr_arch_inherit.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\arch\win32\apr_arch_misc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\arch\win32\apr_arch_networkio.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\arch\win32\apr_arch_thread_mutex.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\arch\win32\apr_arch_thread_rwlock.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\arch\win32\apr_arch_threadproc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\arch\win32\apr_arch_utf8.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\arch\win32\apr_private.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\arch\apr_private_common.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Public Header Files"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr.h.in
|
||||
# PROP Exclude_From_Build 1
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr.hnw
|
||||
# PROP Exclude_From_Build 1
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr.hw
|
||||
|
||||
!IF "$(CFG)" == "apr - Win32 Release"
|
||||
|
||||
# Begin Custom Build - Creating apr.h from apr.hw
|
||||
InputPath=.\include\apr.hw
|
||||
|
||||
".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
type .\include\apr.hw > .\include\apr.h
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "apr - Win32 Debug"
|
||||
|
||||
# Begin Custom Build - Creating apr.h from apr.hw
|
||||
InputPath=.\include\apr.hw
|
||||
|
||||
".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
type .\include\apr.hw > .\include\apr.h
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "apr - x64 Release"
|
||||
|
||||
# Begin Custom Build - Creating apr.h from apr.hw
|
||||
InputPath=.\include\apr.hw
|
||||
|
||||
".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
type .\include\apr.hw > .\include\apr.h
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "apr - x64 Debug"
|
||||
|
||||
# Begin Custom Build - Creating apr.h from apr.hw
|
||||
InputPath=.\include\apr.hw
|
||||
|
||||
".\include\apr.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
type .\include\apr.hw > .\include\apr.h
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_allocator.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_atomic.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_dso.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_env.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_errno.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_escape.h
|
||||
|
||||
!IF "$(CFG)" == "libapr - Win32 Release"
|
||||
|
||||
# Begin Custom Build - Creating gen_test_char.exe and apr_escape_test_char.h
|
||||
InputPath=.\include\apr_escape.h
|
||||
|
||||
".\include\apr_escape_test_char.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
cl.exe /nologo /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /I ".\include" /Fo.\Release\gen_test_char /Fe.\Release\gen_test_char.exe .\tools\gen_test_char.c
|
||||
.\Release\gen_test_char.exe > .\include\apr_escape_test_char.h
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "libapr - Win32 Debug"
|
||||
|
||||
# Begin Custom Build - Creating gen_test_char.exe and apr_escape_test_char.h
|
||||
InputPath=.\include\apr_escape.h
|
||||
|
||||
".\include\apr_escape_test_char.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
cl.exe /nologo /W3 /EHsc /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /I ".\include" /Fo.\Debug\gen_test_char /Fe.\Debug\gen_test_char.exe .\tools\gen_test_char.c
|
||||
.\Debug\gen_test_char.exe > .\include\apr_escape_test_char.h
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "libapr - x64 Release"
|
||||
|
||||
# Begin Custom Build - Creating gen_test_char.exe and apr_escape_test_char.h
|
||||
InputPath=.\include\apr_escape.h
|
||||
|
||||
".\include\apr_escape_test_char.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
cl.exe /nologo /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /I ".\include" /Fo.\x64\Release\gen_test_char /Fe.\x64\Release\gen_test_char.exe .\tools\gen_test_char.c
|
||||
.\x64\Release\gen_test_char.exe > .\include\apr_escape_test_char.h
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "libapr - x64 Debug"
|
||||
|
||||
# Begin Custom Build - Creating gen_test_char.exe and apr_escape_test_char.h
|
||||
InputPath=.\include\apr_escape.h
|
||||
|
||||
".\include\apr_escape_test_char.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
cl.exe /nologo /W3 /EHsc /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /I ".\include" /Fo.\x64\Debug\gen_test_char /Fe.\x64\Debug\gen_test_char.exe .\tools\gen_test_char.c
|
||||
.\x64\Debug\gen_test_char.exe > .\include\apr_escape_test_char.h
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_file_info.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_file_io.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_fnmatch.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_general.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_getopt.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_global_mutex.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_hash.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_inherit.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_lib.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_mmap.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_network_io.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_poll.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_pools.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_portable.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_proc_mutex.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_random.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_ring.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_shm.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_signal.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_skiplist.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_strings.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_support.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_tables.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_thread_cond.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_thread_mutex.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_thread_proc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_thread_rwlock.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_time.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_user.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_version.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\include\apr_want.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
Vendored
-101
@@ -1,101 +0,0 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "apr"=".\apr.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "aprapp"=".\build\aprapp.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name preaprapp
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "libapr"=".\libapr.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "libaprapp"=".\build\libaprapp.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name prelibaprapp
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "preaprapp"=".\build\preaprapp.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name apr
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "prelibaprapp"=".\build\prelibaprapp.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name libapr
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Vendored
-1508
File diff suppressed because it is too large
Load Diff
Vendored
-11
@@ -1,11 +0,0 @@
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
APR_MAJOR_VERSION=@APR_MAJOR_VERSION@
|
||||
includedir=@includedir@
|
||||
|
||||
Name: APR
|
||||
Description: The Apache Portable Runtime library
|
||||
Version: @APR_DOTTED_VERSION@
|
||||
Libs: -L${libdir} -l@APR_LIBNAME@ @EXTRA_LIBS@
|
||||
Cflags: @EXTRA_CPPFLAGS@ @EXTRA_CFLAGS@ -I${includedir}
|
||||
Vendored
-100
@@ -1,100 +0,0 @@
|
||||
|
||||
%define aprver 1
|
||||
|
||||
Summary: Apache Portable Runtime library
|
||||
Name: apr
|
||||
Version: 1.6.5
|
||||
Release: 1
|
||||
License: Apache Software License
|
||||
Group: System Environment/Libraries
|
||||
URL: http://apr.apache.org/
|
||||
Source0: http://www.apache.org/dist/apr/%{name}-%{version}.tar.bz2
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
|
||||
BuildRequires: autoconf, libtool, doxygen, libuuid-devel, python
|
||||
|
||||
%description
|
||||
The mission of the Apache Portable Runtime (APR) is to provide a
|
||||
free library of C data structures and routines, forming a system
|
||||
portability layer to as many operating systems as possible,
|
||||
including Unices, MS Win32, BeOS and OS/2.
|
||||
|
||||
%package devel
|
||||
Group: Development/Libraries
|
||||
Summary: APR library development kit
|
||||
Requires: apr = %{version}
|
||||
|
||||
%description devel
|
||||
This package provides the support files which can be used to
|
||||
build applications using the APR library. The mission of the
|
||||
Apache Portable Runtime (APR) is to provide a free library of
|
||||
C data structures and routines.
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
|
||||
%build
|
||||
# regenerate configure script etc.
|
||||
./buildconf
|
||||
%configure \
|
||||
--prefix=/usr \
|
||||
--includedir=%{_includedir}/apr-%{aprver} \
|
||||
--with-installbuilddir=%{_libdir}/apr/build-%{aprver} \
|
||||
--with-devrandom=/dev/urandom \
|
||||
CC=gcc CXX=g++
|
||||
make %{?_smp_mflags} && make dox
|
||||
|
||||
%check
|
||||
# Run non-interactive tests
|
||||
pushd test
|
||||
make %{?_smp_mflags} all CFLAGS=-fno-strict-aliasing
|
||||
make check || exit 1
|
||||
popd
|
||||
|
||||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
make install DESTDIR=$RPM_BUILD_ROOT
|
||||
|
||||
# Move docs to more convenient location
|
||||
mv docs/dox/html html
|
||||
|
||||
# Unpackaged files:
|
||||
rm -f $RPM_BUILD_ROOT%{_libdir}/apr.exp
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%post -p /sbin/ldconfig
|
||||
|
||||
%postun -p /sbin/ldconfig
|
||||
|
||||
%files
|
||||
%defattr(-,root,root,-)
|
||||
%doc CHANGES LICENSE NOTICE
|
||||
%{_libdir}/libapr-%{aprver}.so.*
|
||||
|
||||
%files devel
|
||||
%defattr(-,root,root,-)
|
||||
%doc docs/APRDesign.html docs/canonical_filenames.html
|
||||
%doc docs/incomplete_types docs/non_apr_programs
|
||||
%doc html
|
||||
%{_bindir}/apr*config
|
||||
%{_libdir}/libapr-%{aprver}.*a
|
||||
%{_libdir}/libapr-%{aprver}.so
|
||||
%dir %{_libdir}/apr
|
||||
%dir %{_libdir}/apr/build-%{aprver}
|
||||
%{_libdir}/apr/build-%{aprver}/*
|
||||
%{_libdir}/pkgconfig/apr-%{aprver}.pc
|
||||
%dir %{_includedir}/apr-%{aprver}
|
||||
%{_includedir}/apr-%{aprver}/*.h
|
||||
|
||||
%changelog
|
||||
* Sat Aug 30 2008 Graham Leggett <minfrin@sharp.fm> 1.3.3
|
||||
- update to depend on the bzip2 binary
|
||||
- build depends on python
|
||||
|
||||
* Tue Jun 22 2004 Graham Leggett <minfrin@sharp.fm> 1.0.0-1
|
||||
- update to support v1.0.0 of APR
|
||||
|
||||
* Tue Jun 22 2004 Graham Leggett <minfrin@sharp.fm> 1.0.0-1
|
||||
- derived from Fedora Core apr.spec
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "apr.h"
|
||||
#include "apr_atomic.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *pool)
|
||||
{
|
||||
return APR_SUCCESS;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
return atomic_xchgadd((unsigned long *)mem,(unsigned long)val);
|
||||
}
|
||||
|
||||
APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
atomic_sub((unsigned long *)mem,(unsigned long)val);
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_inc32(volatile apr_uint32_t *mem)
|
||||
{
|
||||
return atomic_xchgadd((unsigned long *)mem, 1);
|
||||
}
|
||||
|
||||
APR_DECLARE(void) apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
*mem = val;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_read32(volatile apr_uint32_t *mem)
|
||||
{
|
||||
return *mem;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint32_t with,apr_uint32_t cmp)
|
||||
{
|
||||
return atomic_cmpxchg((unsigned long *)mem,(unsigned long)cmp,(unsigned long)with);
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
return atomic_xchg((unsigned long *)mem,(unsigned long)val);
|
||||
}
|
||||
|
||||
APR_DECLARE(int) apr_atomic_dec32(volatile apr_uint32_t *mem)
|
||||
{
|
||||
return (atomic_xchgadd((unsigned long *)mem, 0xFFFFFFFF) - 1);
|
||||
}
|
||||
|
||||
APR_DECLARE(void *) apr_atomic_casptr(volatile void **mem, void *with, const void *cmp)
|
||||
{
|
||||
return (void*)atomic_cmpxchg((unsigned long *)mem,(unsigned long)cmp,(unsigned long)with);
|
||||
}
|
||||
|
||||
APR_DECLARE(void*) apr_atomic_xchgptr(volatile void **mem, void *with)
|
||||
{
|
||||
return (void*)atomic_xchg((unsigned long *)mem,(unsigned long)with);
|
||||
}
|
||||
-137
@@ -1,137 +0,0 @@
|
||||
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#include "apr.h"
|
||||
#include "apr_atomic.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
apr_status_t apr_atomic_init(apr_pool_t *p)
|
||||
{
|
||||
return APR_SUCCESS;
|
||||
}
|
||||
|
||||
apr_uint32_t apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
apr_uint32_t old, new_val;
|
||||
|
||||
old = *mem; /* old is automatically updated on cs failure */
|
||||
do {
|
||||
new_val = old + val;
|
||||
} while (__cs(&old, (cs_t *)mem, new_val));
|
||||
return old;
|
||||
}
|
||||
|
||||
void apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
apr_uint32_t old, new_val;
|
||||
|
||||
old = *mem; /* old is automatically updated on cs failure */
|
||||
do {
|
||||
new_val = old - val;
|
||||
} while (__cs(&old, (cs_t *)mem, new_val));
|
||||
}
|
||||
|
||||
apr_uint32_t apr_atomic_inc32(volatile apr_uint32_t *mem)
|
||||
{
|
||||
return apr_atomic_add32(mem, 1);
|
||||
}
|
||||
|
||||
int apr_atomic_dec32(volatile apr_uint32_t *mem)
|
||||
{
|
||||
apr_uint32_t old, new_val;
|
||||
|
||||
old = *mem; /* old is automatically updated on cs failure */
|
||||
do {
|
||||
new_val = old - 1;
|
||||
} while (__cs(&old, (cs_t *)mem, new_val));
|
||||
|
||||
return new_val != 0;
|
||||
}
|
||||
|
||||
apr_uint32_t apr_atomic_read32(volatile apr_uint32_t *mem)
|
||||
{
|
||||
return *mem;
|
||||
}
|
||||
|
||||
void apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
*mem = val;
|
||||
}
|
||||
|
||||
apr_uint32_t apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint32_t swap,
|
||||
apr_uint32_t cmp)
|
||||
{
|
||||
apr_uint32_t old = cmp;
|
||||
|
||||
__cs(&old, (cs_t *)mem, swap);
|
||||
return old; /* old is automatically updated from mem on cs failure */
|
||||
}
|
||||
|
||||
#if APR_SIZEOF_VOIDP == 4
|
||||
void *apr_atomic_casptr(volatile void **mem_ptr,
|
||||
void *swap_ptr,
|
||||
const void *cmp_ptr)
|
||||
{
|
||||
__cs1(&cmp_ptr, /* automatically updated from mem on __cs1 failure */
|
||||
mem_ptr, /* set from swap when __cs1 succeeds */
|
||||
&swap_ptr);
|
||||
return (void *)cmp_ptr;
|
||||
}
|
||||
#elif APR_SIZEOF_VOIDP == 8
|
||||
void *apr_atomic_casptr(volatile void **mem_ptr,
|
||||
void *swap_ptr,
|
||||
const void *cmp_ptr)
|
||||
{
|
||||
__csg(&cmp_ptr, /* automatically updated from mem on __csg failure */
|
||||
mem_ptr, /* set from swap when __csg succeeds */
|
||||
&swap_ptr);
|
||||
return (void *)cmp_ptr;
|
||||
}
|
||||
#else
|
||||
#error APR_SIZEOF_VOIDP value not supported
|
||||
#endif /* APR_SIZEOF_VOIDP */
|
||||
|
||||
apr_uint32_t apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
apr_uint32_t old, new_val;
|
||||
|
||||
old = *mem; /* old is automatically updated on cs failure */
|
||||
do {
|
||||
new_val = val;
|
||||
} while (__cs(&old, (cs_t *)mem, new_val));
|
||||
|
||||
return old;
|
||||
}
|
||||
|
||||
APR_DECLARE(void*) apr_atomic_xchgptr(volatile void **mem_ptr, void *new_ptr)
|
||||
{
|
||||
void *old_ptr;
|
||||
|
||||
old_ptr = *(void **)mem_ptr; /* old is automatically updated on cs failure */
|
||||
#if APR_SIZEOF_VOIDP == 4
|
||||
do {
|
||||
} while (__cs1(&old_ptr, mem_ptr, &new_ptr));
|
||||
#elif APR_SIZEOF_VOIDP == 8
|
||||
do {
|
||||
} while (__csg(&old_ptr, mem_ptr, &new_ptr));
|
||||
#else
|
||||
#error APR_SIZEOF_VOIDP value not supported
|
||||
#endif /* APR_SIZEOF_VOIDP */
|
||||
|
||||
return old_ptr;
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "apr_arch_atomic.h"
|
||||
|
||||
#ifdef USE_ATOMICS_BUILTINS
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p)
|
||||
{
|
||||
return APR_SUCCESS;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_read32(volatile apr_uint32_t *mem)
|
||||
{
|
||||
return *mem;
|
||||
}
|
||||
|
||||
APR_DECLARE(void) apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
*mem = val;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
return __sync_fetch_and_add(mem, val);
|
||||
}
|
||||
|
||||
APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
__sync_fetch_and_sub(mem, val);
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_inc32(volatile apr_uint32_t *mem)
|
||||
{
|
||||
return __sync_fetch_and_add(mem, 1);
|
||||
}
|
||||
|
||||
APR_DECLARE(int) apr_atomic_dec32(volatile apr_uint32_t *mem)
|
||||
{
|
||||
return __sync_sub_and_fetch(mem, 1);
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint32_t with,
|
||||
apr_uint32_t cmp)
|
||||
{
|
||||
return __sync_val_compare_and_swap(mem, cmp, with);
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
__sync_synchronize();
|
||||
|
||||
return __sync_lock_test_and_set(mem, val);
|
||||
}
|
||||
|
||||
APR_DECLARE(void*) apr_atomic_casptr(volatile void **mem, void *with, const void *cmp)
|
||||
{
|
||||
return (void*) __sync_val_compare_and_swap(mem, cmp, with);
|
||||
}
|
||||
|
||||
APR_DECLARE(void*) apr_atomic_xchgptr(volatile void **mem, void *with)
|
||||
{
|
||||
__sync_synchronize();
|
||||
|
||||
return (void*) __sync_lock_test_and_set(mem, with);
|
||||
}
|
||||
|
||||
#endif /* USE_ATOMICS_BUILTINS */
|
||||
-127
@@ -1,127 +0,0 @@
|
||||
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "apr_arch_atomic.h"
|
||||
|
||||
#ifdef USE_ATOMICS_IA32
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p)
|
||||
{
|
||||
return APR_SUCCESS;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_read32(volatile apr_uint32_t *mem)
|
||||
{
|
||||
return *mem;
|
||||
}
|
||||
|
||||
APR_DECLARE(void) apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
*mem = val;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
asm volatile ("lock; xaddl %0,%1"
|
||||
: "=r" (val), "=m" (*mem)
|
||||
: "0" (val), "m" (*mem)
|
||||
: "memory", "cc");
|
||||
return val;
|
||||
}
|
||||
|
||||
APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
asm volatile ("lock; subl %1, %0"
|
||||
: /* no output */
|
||||
: "m" (*(mem)), "r" (val)
|
||||
: "memory", "cc");
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_inc32(volatile apr_uint32_t *mem)
|
||||
{
|
||||
return apr_atomic_add32(mem, 1);
|
||||
}
|
||||
|
||||
APR_DECLARE(int) apr_atomic_dec32(volatile apr_uint32_t *mem)
|
||||
{
|
||||
unsigned char prev;
|
||||
|
||||
asm volatile ("lock; decl %0; setnz %1"
|
||||
: "=m" (*mem), "=qm" (prev)
|
||||
: "m" (*mem)
|
||||
: "memory");
|
||||
|
||||
return prev;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint32_t with,
|
||||
apr_uint32_t cmp)
|
||||
{
|
||||
apr_uint32_t prev;
|
||||
|
||||
asm volatile ("lock; cmpxchgl %1, %2"
|
||||
: "=a" (prev)
|
||||
: "r" (with), "m" (*(mem)), "0"(cmp)
|
||||
: "memory", "cc");
|
||||
return prev;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
apr_uint32_t prev = val;
|
||||
|
||||
asm volatile ("xchgl %0, %1"
|
||||
: "=r" (prev), "+m" (*mem)
|
||||
: "0" (prev));
|
||||
return prev;
|
||||
}
|
||||
|
||||
APR_DECLARE(void*) apr_atomic_casptr(volatile void **mem, void *with, const void *cmp)
|
||||
{
|
||||
void *prev;
|
||||
#if APR_SIZEOF_VOIDP == 4
|
||||
asm volatile ("lock; cmpxchgl %2, %1"
|
||||
: "=a" (prev), "=m" (*mem)
|
||||
: "r" (with), "m" (*mem), "0" (cmp));
|
||||
#elif APR_SIZEOF_VOIDP == 8
|
||||
asm volatile ("lock; cmpxchgq %q2, %1"
|
||||
: "=a" (prev), "=m" (*mem)
|
||||
: "r" ((unsigned long)with), "m" (*mem),
|
||||
"0" ((unsigned long)cmp));
|
||||
#else
|
||||
#error APR_SIZEOF_VOIDP value not supported
|
||||
#endif
|
||||
return prev;
|
||||
}
|
||||
|
||||
APR_DECLARE(void*) apr_atomic_xchgptr(volatile void **mem, void *with)
|
||||
{
|
||||
void *prev;
|
||||
#if APR_SIZEOF_VOIDP == 4
|
||||
asm volatile ("xchgl %2, %1"
|
||||
: "=a" (prev), "+m" (*mem)
|
||||
: "0" (with));
|
||||
#elif APR_SIZEOF_VOIDP == 8
|
||||
asm volatile ("xchgq %q2, %1"
|
||||
: "=a" (prev), "+m" (*mem)
|
||||
: "0" (with));
|
||||
#else
|
||||
#error APR_SIZEOF_VOIDP value not supported
|
||||
#endif
|
||||
return prev;
|
||||
}
|
||||
|
||||
#endif /* USE_ATOMICS_IA32 */
|
||||
-205
@@ -1,205 +0,0 @@
|
||||
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "apr_arch_atomic.h"
|
||||
|
||||
#ifdef USE_ATOMICS_GENERIC
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#if APR_HAS_THREADS
|
||||
# define DECLARE_MUTEX_LOCKED(name, mem) \
|
||||
apr_thread_mutex_t *name = mutex_hash(mem)
|
||||
# define MUTEX_UNLOCK(name) \
|
||||
do { \
|
||||
if (apr_thread_mutex_unlock(name) != APR_SUCCESS) \
|
||||
abort(); \
|
||||
} while (0)
|
||||
#else
|
||||
# define DECLARE_MUTEX_LOCKED(name, mem)
|
||||
# define MUTEX_UNLOCK(name)
|
||||
# warning Be warned: using stubs for all atomic operations
|
||||
#endif
|
||||
|
||||
#if APR_HAS_THREADS
|
||||
|
||||
static apr_thread_mutex_t **hash_mutex;
|
||||
|
||||
#define NUM_ATOMIC_HASH 7
|
||||
/* shift by 2 to get rid of alignment issues */
|
||||
#define ATOMIC_HASH(x) (unsigned int)(((unsigned long)(x)>>2)%(unsigned int)NUM_ATOMIC_HASH)
|
||||
|
||||
static apr_status_t atomic_cleanup(void *data)
|
||||
{
|
||||
if (hash_mutex == data)
|
||||
hash_mutex = NULL;
|
||||
|
||||
return APR_SUCCESS;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p)
|
||||
{
|
||||
int i;
|
||||
apr_status_t rv;
|
||||
|
||||
if (hash_mutex != NULL)
|
||||
return APR_SUCCESS;
|
||||
|
||||
hash_mutex = apr_palloc(p, sizeof(apr_thread_mutex_t*) * NUM_ATOMIC_HASH);
|
||||
apr_pool_cleanup_register(p, hash_mutex, atomic_cleanup,
|
||||
apr_pool_cleanup_null);
|
||||
|
||||
for (i = 0; i < NUM_ATOMIC_HASH; i++) {
|
||||
rv = apr_thread_mutex_create(&(hash_mutex[i]),
|
||||
APR_THREAD_MUTEX_DEFAULT, p);
|
||||
if (rv != APR_SUCCESS) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
return APR_SUCCESS;
|
||||
}
|
||||
|
||||
static APR_INLINE apr_thread_mutex_t *mutex_hash(volatile apr_uint32_t *mem)
|
||||
{
|
||||
apr_thread_mutex_t *mutex = hash_mutex[ATOMIC_HASH(mem)];
|
||||
|
||||
if (apr_thread_mutex_lock(mutex) != APR_SUCCESS) {
|
||||
abort();
|
||||
}
|
||||
|
||||
return mutex;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p)
|
||||
{
|
||||
return APR_SUCCESS;
|
||||
}
|
||||
|
||||
#endif /* APR_HAS_THREADS */
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_read32(volatile apr_uint32_t *mem)
|
||||
{
|
||||
return *mem;
|
||||
}
|
||||
|
||||
APR_DECLARE(void) apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
DECLARE_MUTEX_LOCKED(mutex, mem);
|
||||
|
||||
*mem = val;
|
||||
|
||||
MUTEX_UNLOCK(mutex);
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
apr_uint32_t old_value;
|
||||
DECLARE_MUTEX_LOCKED(mutex, mem);
|
||||
|
||||
old_value = *mem;
|
||||
*mem += val;
|
||||
|
||||
MUTEX_UNLOCK(mutex);
|
||||
|
||||
return old_value;
|
||||
}
|
||||
|
||||
APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
DECLARE_MUTEX_LOCKED(mutex, mem);
|
||||
*mem -= val;
|
||||
MUTEX_UNLOCK(mutex);
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_inc32(volatile apr_uint32_t *mem)
|
||||
{
|
||||
return apr_atomic_add32(mem, 1);
|
||||
}
|
||||
|
||||
APR_DECLARE(int) apr_atomic_dec32(volatile apr_uint32_t *mem)
|
||||
{
|
||||
apr_uint32_t new;
|
||||
DECLARE_MUTEX_LOCKED(mutex, mem);
|
||||
|
||||
(*mem)--;
|
||||
new = *mem;
|
||||
|
||||
MUTEX_UNLOCK(mutex);
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint32_t with,
|
||||
apr_uint32_t cmp)
|
||||
{
|
||||
apr_uint32_t prev;
|
||||
DECLARE_MUTEX_LOCKED(mutex, mem);
|
||||
|
||||
prev = *mem;
|
||||
if (prev == cmp) {
|
||||
*mem = with;
|
||||
}
|
||||
|
||||
MUTEX_UNLOCK(mutex);
|
||||
|
||||
return prev;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
apr_uint32_t prev;
|
||||
DECLARE_MUTEX_LOCKED(mutex, mem);
|
||||
|
||||
prev = *mem;
|
||||
*mem = val;
|
||||
|
||||
MUTEX_UNLOCK(mutex);
|
||||
|
||||
return prev;
|
||||
}
|
||||
|
||||
APR_DECLARE(void*) apr_atomic_casptr(volatile void **mem, void *with, const void *cmp)
|
||||
{
|
||||
void *prev;
|
||||
DECLARE_MUTEX_LOCKED(mutex, *mem);
|
||||
|
||||
prev = *(void **)mem;
|
||||
if (prev == cmp) {
|
||||
*mem = with;
|
||||
}
|
||||
|
||||
MUTEX_UNLOCK(mutex);
|
||||
|
||||
return prev;
|
||||
}
|
||||
|
||||
APR_DECLARE(void*) apr_atomic_xchgptr(volatile void **mem, void *with)
|
||||
{
|
||||
void *prev;
|
||||
DECLARE_MUTEX_LOCKED(mutex, *mem);
|
||||
|
||||
prev = *(void **)mem;
|
||||
*mem = with;
|
||||
|
||||
MUTEX_UNLOCK(mutex);
|
||||
|
||||
return prev;
|
||||
}
|
||||
|
||||
#endif /* USE_ATOMICS_GENERIC */
|
||||
-207
@@ -1,207 +0,0 @@
|
||||
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "apr_arch_atomic.h"
|
||||
|
||||
#ifdef USE_ATOMICS_PPC
|
||||
|
||||
#ifdef PPC405_ERRATA
|
||||
# define PPC405_ERR77_SYNC " sync\n"
|
||||
#else
|
||||
# define PPC405_ERR77_SYNC
|
||||
#endif
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p)
|
||||
{
|
||||
return APR_SUCCESS;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_read32(volatile apr_uint32_t *mem)
|
||||
{
|
||||
return *mem;
|
||||
}
|
||||
|
||||
APR_DECLARE(void) apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
*mem = val;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
apr_uint32_t prev, temp;
|
||||
|
||||
asm volatile ("1:\n" /* lost reservation */
|
||||
" lwarx %0,0,%3\n" /* load and reserve */
|
||||
" add %1,%0,%4\n" /* add val and prev */
|
||||
PPC405_ERR77_SYNC /* ppc405 Erratum 77 */
|
||||
" stwcx. %1,0,%3\n" /* store new value */
|
||||
" bne- 1b\n" /* loop if lost */
|
||||
: "=&r" (prev), "=&r" (temp), "=m" (*mem)
|
||||
: "b" (mem), "r" (val)
|
||||
: "cc", "memory");
|
||||
|
||||
return prev;
|
||||
}
|
||||
|
||||
APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
apr_uint32_t temp;
|
||||
|
||||
asm volatile ("1:\n" /* lost reservation */
|
||||
" lwarx %0,0,%2\n" /* load and reserve */
|
||||
" subf %0,%3,%0\n" /* subtract val */
|
||||
PPC405_ERR77_SYNC /* ppc405 Erratum 77 */
|
||||
" stwcx. %0,0,%2\n" /* store new value */
|
||||
" bne- 1b\n" /* loop if lost */
|
||||
: "=&r" (temp), "=m" (*mem)
|
||||
: "b" (mem), "r" (val)
|
||||
: "cc", "memory");
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_inc32(volatile apr_uint32_t *mem)
|
||||
{
|
||||
apr_uint32_t prev;
|
||||
|
||||
asm volatile ("1:\n" /* lost reservation */
|
||||
" lwarx %0,0,%2\n" /* load and reserve */
|
||||
" addi %0,%0,1\n" /* add immediate */
|
||||
PPC405_ERR77_SYNC /* ppc405 Erratum 77 */
|
||||
" stwcx. %0,0,%2\n" /* store new value */
|
||||
" bne- 1b\n" /* loop if lost */
|
||||
" subi %0,%0,1\n" /* return old value */
|
||||
: "=&b" (prev), "=m" (*mem)
|
||||
: "b" (mem), "m" (*mem)
|
||||
: "cc", "memory");
|
||||
|
||||
return prev;
|
||||
}
|
||||
|
||||
APR_DECLARE(int) apr_atomic_dec32(volatile apr_uint32_t *mem)
|
||||
{
|
||||
apr_uint32_t prev;
|
||||
|
||||
asm volatile ("1:\n" /* lost reservation */
|
||||
" lwarx %0,0,%2\n" /* load and reserve */
|
||||
" subi %0,%0,1\n" /* subtract immediate */
|
||||
PPC405_ERR77_SYNC /* ppc405 Erratum 77 */
|
||||
" stwcx. %0,0,%2\n" /* store new value */
|
||||
" bne- 1b\n" /* loop if lost */
|
||||
: "=&b" (prev), "=m" (*mem)
|
||||
: "b" (mem), "m" (*mem)
|
||||
: "cc", "memory");
|
||||
|
||||
return prev;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint32_t with,
|
||||
apr_uint32_t cmp)
|
||||
{
|
||||
apr_uint32_t prev;
|
||||
|
||||
asm volatile ("1:\n" /* lost reservation */
|
||||
" lwarx %0,0,%1\n" /* load and reserve */
|
||||
" cmpw %0,%3\n" /* compare operands */
|
||||
" bne- exit_%=\n" /* skip if not equal */
|
||||
PPC405_ERR77_SYNC /* ppc405 Erratum 77 */
|
||||
" stwcx. %2,0,%1\n" /* store new value */
|
||||
" bne- 1b\n" /* loop if lost */
|
||||
"exit_%=:\n" /* not equal */
|
||||
: "=&r" (prev)
|
||||
: "b" (mem), "r" (with), "r" (cmp)
|
||||
: "cc", "memory");
|
||||
|
||||
return prev;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
apr_uint32_t prev;
|
||||
|
||||
asm volatile ("1:\n" /* lost reservation */
|
||||
" lwarx %0,0,%1\n" /* load and reserve */
|
||||
PPC405_ERR77_SYNC /* ppc405 Erratum 77 */
|
||||
" stwcx. %2,0,%1\n" /* store new value */
|
||||
" bne- 1b" /* loop if lost */
|
||||
: "=&r" (prev)
|
||||
: "b" (mem), "r" (val)
|
||||
: "cc", "memory");
|
||||
|
||||
return prev;
|
||||
}
|
||||
|
||||
APR_DECLARE(void*) apr_atomic_casptr(volatile void **mem, void *with, const void *cmp)
|
||||
{
|
||||
void *prev;
|
||||
#if APR_SIZEOF_VOIDP == 4
|
||||
asm volatile ("1:\n" /* lost reservation */
|
||||
" lwarx %0,0,%1\n" /* load and reserve */
|
||||
" cmpw %0,%3\n" /* compare operands */
|
||||
" bne- 2f\n" /* skip if not equal */
|
||||
PPC405_ERR77_SYNC /* ppc405 Erratum 77 */
|
||||
" stwcx. %2,0,%1\n" /* store new value */
|
||||
" bne- 1b\n" /* loop if lost */
|
||||
"2:\n" /* not equal */
|
||||
: "=&r" (prev)
|
||||
: "b" (mem), "r" (with), "r" (cmp)
|
||||
: "cc", "memory");
|
||||
#elif APR_SIZEOF_VOIDP == 8
|
||||
asm volatile ("1:\n" /* lost reservation */
|
||||
" ldarx %0,0,%1\n" /* load and reserve */
|
||||
" cmpd %0,%3\n" /* compare operands */
|
||||
" bne- 2f\n" /* skip if not equal */
|
||||
PPC405_ERR77_SYNC /* ppc405 Erratum 77 */
|
||||
" stdcx. %2,0,%1\n" /* store new value */
|
||||
" bne- 1b\n" /* loop if lost */
|
||||
"2:\n" /* not equal */
|
||||
: "=&r" (prev)
|
||||
: "b" (mem), "r" (with), "r" (cmp)
|
||||
: "cc", "memory");
|
||||
#else
|
||||
#error APR_SIZEOF_VOIDP value not supported
|
||||
#endif
|
||||
return prev;
|
||||
}
|
||||
|
||||
APR_DECLARE(void*) apr_atomic_xchgptr(volatile void **mem, void *with)
|
||||
{
|
||||
void *prev;
|
||||
#if APR_SIZEOF_VOIDP == 4
|
||||
asm volatile ("1:\n" /* lost reservation */
|
||||
" lwarx %0,0,%1\n" /* load and reserve */
|
||||
PPC405_ERR77_SYNC /* ppc405 Erratum 77 */
|
||||
" stwcx. %2,0,%1\n" /* store new value */
|
||||
" bne- 1b\n" /* loop if lost */
|
||||
" isync\n" /* memory barrier */
|
||||
: "=&r" (prev)
|
||||
: "b" (mem), "r" (with)
|
||||
: "cc", "memory");
|
||||
#elif APR_SIZEOF_VOIDP == 8
|
||||
asm volatile ("1:\n" /* lost reservation */
|
||||
" ldarx %0,0,%1\n" /* load and reserve */
|
||||
PPC405_ERR77_SYNC /* ppc405 Erratum 77 */
|
||||
" stdcx. %2,0,%1\n" /* store new value */
|
||||
" bne- 1b\n" /* loop if lost */
|
||||
" isync\n" /* memory barrier */
|
||||
: "=&r" (prev)
|
||||
: "b" (mem), "r" (with)
|
||||
: "cc", "memory");
|
||||
#else
|
||||
#error APR_SIZEOF_VOIDP value not supported
|
||||
#endif
|
||||
return prev;
|
||||
}
|
||||
|
||||
#endif /* USE_ATOMICS_PPC */
|
||||
-155
@@ -1,155 +0,0 @@
|
||||
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "apr_arch_atomic.h"
|
||||
|
||||
#ifdef USE_ATOMICS_S390
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p)
|
||||
{
|
||||
return APR_SUCCESS;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_read32(volatile apr_uint32_t *mem)
|
||||
{
|
||||
return *mem;
|
||||
}
|
||||
|
||||
APR_DECLARE(void) apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
*mem = val;
|
||||
}
|
||||
|
||||
static APR_INLINE apr_uint32_t atomic_add(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
apr_uint32_t prev = *mem, temp;
|
||||
|
||||
asm volatile ("loop_%=:\n"
|
||||
" lr %1,%0\n"
|
||||
" alr %1,%3\n"
|
||||
" cs %0,%1,%2\n"
|
||||
" jl loop_%=\n"
|
||||
: "+d" (prev), "+d" (temp), "=Q" (*mem)
|
||||
: "d" (val), "m" (*mem)
|
||||
: "cc", "memory");
|
||||
|
||||
return prev;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
return atomic_add(mem, val);
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_inc32(volatile apr_uint32_t *mem)
|
||||
{
|
||||
return atomic_add(mem, 1);
|
||||
}
|
||||
|
||||
static APR_INLINE apr_uint32_t atomic_sub(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
apr_uint32_t prev = *mem, temp;
|
||||
|
||||
asm volatile ("loop_%=:\n"
|
||||
" lr %1,%0\n"
|
||||
" slr %1,%3\n"
|
||||
" cs %0,%1,%2\n"
|
||||
" jl loop_%=\n"
|
||||
: "+d" (prev), "+d" (temp), "=Q" (*mem)
|
||||
: "d" (val), "m" (*mem)
|
||||
: "cc", "memory");
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
atomic_sub(mem, val);
|
||||
}
|
||||
|
||||
APR_DECLARE(int) apr_atomic_dec32(volatile apr_uint32_t *mem)
|
||||
{
|
||||
return atomic_sub(mem, 1);
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint32_t with,
|
||||
apr_uint32_t cmp)
|
||||
{
|
||||
asm volatile (" cs %0,%2,%1\n"
|
||||
: "+d" (cmp), "=Q" (*mem)
|
||||
: "d" (with), "m" (*mem)
|
||||
: "cc", "memory");
|
||||
|
||||
return cmp;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
apr_uint32_t prev = *mem;
|
||||
|
||||
asm volatile ("loop_%=:\n"
|
||||
" cs %0,%2,%1\n"
|
||||
" jl loop_%=\n"
|
||||
: "+d" (prev), "=Q" (*mem)
|
||||
: "d" (val), "m" (*mem)
|
||||
: "cc", "memory");
|
||||
|
||||
return prev;
|
||||
}
|
||||
|
||||
APR_DECLARE(void*) apr_atomic_casptr(volatile void **mem, void *with, const void *cmp)
|
||||
{
|
||||
void *prev = (void *) cmp;
|
||||
#if APR_SIZEOF_VOIDP == 4
|
||||
asm volatile (" cs %0,%2,%1\n"
|
||||
: "+d" (prev), "=Q" (*mem)
|
||||
: "d" (with), "m" (*mem)
|
||||
: "cc", "memory");
|
||||
#elif APR_SIZEOF_VOIDP == 8
|
||||
asm volatile (" csg %0,%2,%1\n"
|
||||
: "+d" (prev), "=Q" (*mem)
|
||||
: "d" (with), "m" (*mem)
|
||||
: "cc", "memory");
|
||||
#else
|
||||
#error APR_SIZEOF_VOIDP value not supported
|
||||
#endif
|
||||
return prev;
|
||||
}
|
||||
|
||||
APR_DECLARE(void*) apr_atomic_xchgptr(volatile void **mem, void *with)
|
||||
{
|
||||
void *prev = (void *) *mem;
|
||||
#if APR_SIZEOF_VOIDP == 4
|
||||
asm volatile ("loop_%=:\n"
|
||||
" cs %0,%2,%1\n"
|
||||
" jl loop_%=\n"
|
||||
: "+d" (prev), "=Q" (*mem)
|
||||
: "d" (with), "m" (*mem)
|
||||
: "cc", "memory");
|
||||
#elif APR_SIZEOF_VOIDP == 8
|
||||
asm volatile ("loop_%=:\n"
|
||||
" csg %0,%2,%1\n"
|
||||
" jl loop_%=\n"
|
||||
: "+d" (prev), "=Q" (*mem)
|
||||
: "d" (with), "m" (*mem)
|
||||
: "cc", "memory");
|
||||
#else
|
||||
#error APR_SIZEOF_VOIDP value not supported
|
||||
#endif
|
||||
return prev;
|
||||
}
|
||||
|
||||
#endif /* USE_ATOMICS_S390 */
|
||||
-79
@@ -1,79 +0,0 @@
|
||||
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "apr_arch_atomic.h"
|
||||
|
||||
#ifdef USE_ATOMICS_SOLARIS
|
||||
|
||||
#include <atomic.h>
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p)
|
||||
{
|
||||
return APR_SUCCESS;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_read32(volatile apr_uint32_t *mem)
|
||||
{
|
||||
return *mem;
|
||||
}
|
||||
|
||||
APR_DECLARE(void) apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
*mem = val;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
return atomic_add_32_nv(mem, val) - val;
|
||||
}
|
||||
|
||||
APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
atomic_add_32(mem, -val);
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_inc32(volatile apr_uint32_t *mem)
|
||||
{
|
||||
return atomic_inc_32_nv(mem) - 1;
|
||||
}
|
||||
|
||||
APR_DECLARE(int) apr_atomic_dec32(volatile apr_uint32_t *mem)
|
||||
{
|
||||
return atomic_dec_32_nv(mem);
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint32_t with,
|
||||
apr_uint32_t cmp)
|
||||
{
|
||||
return atomic_cas_32(mem, cmp, with);
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
return atomic_swap_32(mem, val);
|
||||
}
|
||||
|
||||
APR_DECLARE(void*) apr_atomic_casptr(volatile void **mem, void *with, const void *cmp)
|
||||
{
|
||||
return atomic_cas_ptr(mem, (void*) cmp, with);
|
||||
}
|
||||
|
||||
APR_DECLARE(void*) apr_atomic_xchgptr(volatile void **mem, void *with)
|
||||
{
|
||||
return atomic_swap_ptr(mem, with);
|
||||
}
|
||||
|
||||
#endif /* USE_ATOMICS_SOLARIS */
|
||||
-113
@@ -1,113 +0,0 @@
|
||||
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "apr.h"
|
||||
#include "apr_atomic.h"
|
||||
#include "apr_thread_mutex.h"
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p)
|
||||
{
|
||||
return APR_SUCCESS;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
#if (defined(_M_IA64) || defined(_M_AMD64))
|
||||
return InterlockedExchangeAdd(mem, val);
|
||||
#else
|
||||
return InterlockedExchangeAdd((long *)mem, val);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Of course we want the 2's compliment of the unsigned value, val */
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable: 4146)
|
||||
#endif
|
||||
|
||||
APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
#if (defined(_M_IA64) || defined(_M_AMD64))
|
||||
InterlockedExchangeAdd(mem, -val);
|
||||
#else
|
||||
InterlockedExchangeAdd((long *)mem, -val);
|
||||
#endif
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_inc32(volatile apr_uint32_t *mem)
|
||||
{
|
||||
/* we return old value, win32 returns new value :( */
|
||||
#if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED)
|
||||
return InterlockedIncrement(mem) - 1;
|
||||
#else
|
||||
return InterlockedIncrement((long *)mem) - 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
APR_DECLARE(int) apr_atomic_dec32(volatile apr_uint32_t *mem)
|
||||
{
|
||||
#if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED)
|
||||
return InterlockedDecrement(mem);
|
||||
#else
|
||||
return InterlockedDecrement((long *)mem);
|
||||
#endif
|
||||
}
|
||||
|
||||
APR_DECLARE(void) apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
#if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED)
|
||||
InterlockedExchange(mem, val);
|
||||
#else
|
||||
InterlockedExchange((long*)mem, val);
|
||||
#endif
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_read32(volatile apr_uint32_t *mem)
|
||||
{
|
||||
return *mem;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint32_t with,
|
||||
apr_uint32_t cmp)
|
||||
{
|
||||
#if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED)
|
||||
return InterlockedCompareExchange(mem, with, cmp);
|
||||
#else
|
||||
return InterlockedCompareExchange((long*)mem, with, cmp);
|
||||
#endif
|
||||
}
|
||||
|
||||
APR_DECLARE(void *) apr_atomic_casptr(volatile void **mem, void *with, const void *cmp)
|
||||
{
|
||||
#if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED)
|
||||
return InterlockedCompareExchangePointer((void* volatile*)mem, with, (void*)cmp);
|
||||
#else
|
||||
return InterlockedCompareExchangePointer((void**)mem, with, (void*)cmp);
|
||||
#endif
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
#if (defined(_M_IA64) || defined(_M_AMD64)) && !defined(RC_INVOKED)
|
||||
return InterlockedExchange(mem, val);
|
||||
#else
|
||||
return InterlockedExchange((long *)mem, val);
|
||||
#endif
|
||||
}
|
||||
|
||||
APR_DECLARE(void*) apr_atomic_xchgptr(volatile void **mem, void *with)
|
||||
{
|
||||
return InterlockedExchangePointer((void**)mem, with);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user