aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcharan makkina <charan795m@gmail.com>2019-04-30 17:40:53 +0530
committercharan makkina <charan795m@gmail.com>2019-05-20 18:14:40 +0530
commita826fe833d3f2a8fe2673fa05811fe1a22baf045 (patch)
treeda11a17c46ca9b8a002a52a290628574fa3f5eda
parent3e6bf7b64eea418c59959c18750261b815b2892c (diff)
Feature: 19.04 part 1
Change-Id: Ibba924b8deca1f246b9dcb12d89d085b6fd33046 Signed-off-by: charan makkina <charan795m@gmail.com>
-rw-r--r--.gitignore52
-rw-r--r--CMakeLists.txt108
-rw-r--r--README.md49
-rw-r--r--RELEASE.md34
-rw-r--r--app_example/func-test/file_transfer/client_filetrans.c284
-rw-r--r--app_example/func-test/file_transfer/server_filetrans.c344
-rw-r--r--app_example/func-test/fork/tcpclient.c173
-rw-r--r--app_example/func-test/fork/tcpserver.c161
-rw-r--r--app_example/perf-test/multi_tcp_common_Ser.c544
-rw-r--r--app_example/perf-test/multi_tcp_common_app_Cli.c396
-rw-r--r--app_example/perf-test/multi_tcp_epoll_app_Ser.c632
-rw-r--r--app_example/perf-test/multi_tcp_select_app_Ser.c436
-rw-r--r--demo/nginx_proxy/README.md24
-rw-r--r--demo/nginx_proxy/demo-1/Vagrantfile98
-rw-r--r--demo/nginx_proxy/demo-1/adjust_hugepage.sh14
-rwxr-xr-xdemo/nginx_proxy/demo-1/apply_patch.sh9
-rw-r--r--demo/nginx_proxy/demo-1/demo_2stack.patch29
-rw-r--r--demo/nginx_proxy/demo-1/module_config.json23
-rw-r--r--demo/nginx_proxy/demo-1/proxy_nginx.conf81
-rw-r--r--demo/nginx_proxy/demo-1/rd_config.json27
-rw-r--r--demo/nginx_proxy/demo-1/setup_proxy.sh54
-rw-r--r--demo/nginx_proxy/demo-1/setup_upstream.sh45
-rw-r--r--demo/nginx_proxy/demo-1/startup.conf20
-rw-r--r--demo/nginx_proxy/demo-1/upstream_nginx.conf80
-rw-r--r--demo/nginx_proxy/demo-1/vpp_config6
-rw-r--r--demo/nginx_proxy/demo-2/README.md69
-rw-r--r--demo/nginx_proxy/demo-2/Vagrantfile116
-rw-r--r--demo/nginx_proxy/demo-2/adjust_hugepage.sh14
-rwxr-xr-xdemo/nginx_proxy/demo-2/apply_patch.sh9
-rw-r--r--demo/nginx_proxy/demo-2/dem-2-topo.pngbin32437 -> 0 bytes
-rw-r--r--demo/nginx_proxy/demo-2/demo-2.pngbin125156 -> 0 bytes
-rw-r--r--demo/nginx_proxy/demo-2/demo_2stack.patch29
-rw-r--r--demo/nginx_proxy/demo-2/module_config.json23
-rw-r--r--demo/nginx_proxy/demo-2/proxy_nginx.conf33
-rw-r--r--demo/nginx_proxy/demo-2/rd_config.json31
-rw-r--r--demo/nginx_proxy/demo-2/setup_client.sh25
-rw-r--r--demo/nginx_proxy/demo-2/setup_proxy.sh54
-rw-r--r--demo/nginx_proxy/demo-2/setup_udpserver.sh25
-rw-r--r--demo/nginx_proxy/demo-2/setup_upstream.sh44
-rw-r--r--demo/nginx_proxy/demo-2/startup.conf20
-rw-r--r--demo/nginx_proxy/demo-2/udpclient.c50
-rw-r--r--demo/nginx_proxy/demo-2/udpserver.c55
-rw-r--r--demo/nginx_proxy/demo-2/upstream_nginx.conf80
-rw-r--r--demo/nginx_proxy/demo-2/vpp_config6
-rw-r--r--demo/nginx_proxy/demo-3/NGINX_with_DMM_Demo.md26
-rw-r--r--demo/nginx_proxy/demo-3/proxy_nginx.conf81
-rw-r--r--demo/nginx_proxy/demo-3/rd_config.json23
-rw-r--r--demo/nginx_proxy/demo-3/rsocket.pngbin10614 -> 0 bytes
-rw-r--r--demo/nginx_proxy/demo-3/server/index.html31
-rw-r--r--demo/nginx_proxy/demo-3/server/test.c320
-rw-r--r--doc/Build_DMM.md111
-rw-r--r--doc/DMM_DeveloperManual.md1119
-rw-r--r--doc/TestAppUserGuide.md188
-rw-r--r--docker/dmm_image/README.md13
-rw-r--r--docker/dmm_image/centos/Dockerfile17
-rw-r--r--license/Third_Party_Open_Source_Software_Notice4
-rw-r--r--pkg/deb/control13
-rw-r--r--pkg/rpm/dmm.spec50
-rw-r--r--release/bin/.gitkeep (renamed from stacks/lwip_stack/build/.gitkeep)0
-rw-r--r--release/configure/rd_config.json26
-rw-r--r--release/include/declare_syscalls.h51
-rw-r--r--resources/Epoll_flwChart.pngbin59162 -> 0 bytes
-rw-r--r--resources/EvntNotify_StackX.pngbin6397 -> 0 bytes
-rw-r--r--resources/ForkChild.pngbin25757 -> 0 bytes
-rw-r--r--resources/Integration.pngbin117529 -> 0 bytes
-rw-r--r--resources/RD_Topo.PNGbin211226 -> 0 bytes
-rw-r--r--resources/SelectFunc.pngbin33674 -> 0 bytes
-rw-r--r--resources/extras/Vagrantfile62
-rw-r--r--resources/extras/env.sh7
-rw-r--r--resources/extras/install_prereq.sh39
-rw-r--r--resources/logo_fdio-300x184.pngbin9072 -> 0 bytes
-rw-r--r--resources/nStack_Architecture.pngbin47190 -> 0 bytes
-rwxr-xr-xscripts/build.sh2
-rwxr-xr-xscripts/build_vpp.sh6
-rwxr-xr-xscripts/checkstyle.sh11
-rw-r--r--set_permission.sh17
-rw-r--r--src/CMakeLists.txt36
-rw-r--r--src/adapt/nstack_dmm_adpt.c231
-rw-r--r--src/adapt/nstack_dmm_adpt.h64
-rw-r--r--src/adapt/nstack_epoll_comm.c1076
-rw-r--r--src/adapt/nstack_share_res.c176
-rw-r--r--src/adapt/nstack_share_res.h66
-rw-r--r--src/framework/CMakeLists.txt60
-rw-r--r--src/framework/common/base/include/common/common_func.h115
-rw-r--r--src/framework/common/base/include/common/common_mem_api.h143
-rw-r--r--src/framework/common/base/include/common/common_mem_base_type.h85
-rw-r--r--src/framework/common/base/include/common/common_mem_buf.h78
-rw-r--r--src/framework/common/base/include/common/common_mem_malloc.h25
-rw-r--r--src/framework/common/base/include/common/common_mem_mbuf.h40
-rw-r--r--src/framework/common/base/include/common/common_mem_mempool.h25
-rw-r--r--src/framework/common/base/include/common/common_mem_memzone.h25
-rw-r--r--src/framework/common/base/include/common/common_mem_pal.h30
-rw-r--r--src/framework/common/base/include/common/common_mem_spinlock.h40
-rw-r--r--src/framework/common/base/include/common/common_sys_config.h46
-rw-r--r--src/framework/common/base/include/common/generic/common_mem_rwlock.h25
-rw-r--r--src/framework/common/base/include/common_pal_bitwide_adjust.h202
-rw-r--r--src/framework/common/base/include/nsfw_base_linux_api.h58
-rw-r--r--src/framework/common/base/liblinuxapi/base_linux_api_declare.h72
-rw-r--r--src/framework/common/base/liblinuxapi/nsfw_base_linux_api.c428
-rw-r--r--src/framework/common/base/liblinuxapi/nsfw_lock_file.c169
-rw-r--r--src/framework/common/data_struct/eprb_tree.c546
-rw-r--r--src/framework/common/data_struct/list.c134
-rw-r--r--src/framework/common/data_struct/pidinfo.c104
-rw-r--r--src/framework/common/data_struct/sha256.c383
-rw-r--r--src/framework/common/include/arch/x86/dmm_atomic.h21
-rw-r--r--src/framework/common/include/arch/x86/dmm_barrier.h21
-rw-r--r--src/framework/common/include/arch/x86/dmm_pause.h30
-rw-r--r--src/framework/common/include/arch/x86/dmm_rwlock.h21
-rw-r--r--src/framework/common/include/arch/x86/dmm_spinlock.h21
-rw-r--r--src/framework/common/include/ephlist.h199
-rw-r--r--src/framework/common/include/generic/dmm_atomic.h177
-rw-r--r--src/framework/common/include/generic/dmm_spinlock.h53
-rw-r--r--src/framework/common/include/sha256.h94
-rw-r--r--src/framework/common/include/types.h93
-rw-r--r--src/framework/common/mem_mgr/include/nsfw_mem_desc.h172
-rw-r--r--src/framework/common/mem_mgr/include/nsfw_ring_data.h95
-rw-r--r--src/framework/common/mem_mgr/include/nsfw_ring_fun.h110
-rw-r--r--src/framework/common/mem_mgr/nsfw_mem_api.c879
-rw-r--r--src/framework/common/mem_mgr/nsfw_mem_construct.c21
-rw-r--r--src/framework/common/mem_mgr/nsfw_mem_desc.c92
-rw-r--r--src/framework/common/mem_mgr/nsfw_mem_stat.c292
-rw-r--r--src/framework/common/mem_mgr/nsfw_nshmem/nsfw_nshmem_mdesc.c47
-rw-r--r--src/framework/common/mem_mgr/nsfw_nshmem/nsfw_nshmem_mdesc.h22
-rw-r--r--src/framework/common/mem_mgr/nsfw_nshmem/nsfw_nshmem_mng.c544
-rw-r--r--src/framework/common/mem_mgr/nsfw_nshmem/nsfw_nshmem_mng.h70
-rw-r--r--src/framework/common/mem_mgr/nsfw_nshmem/nsfw_nshmem_ring.c437
-rw-r--r--src/framework/common/mem_mgr/nsfw_nshmem/nsfw_nshmem_ring.h37
-rw-r--r--src/framework/common/mem_mgr/nsfw_res_mgr.c429
-rw-r--r--src/framework/common/mem_mgr/nsfw_shmem/nsfw_rshmem_mng.c987
-rw-r--r--src/framework/common/mem_mgr/nsfw_shmem/nsfw_rshmem_mng.h51
-rw-r--r--src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_mdesc.c47
-rw-r--r--src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_mdesc.h22
-rw-r--r--src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_mng.c814
-rw-r--r--src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_mng.h133
-rw-r--r--src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_ring.c839
-rw-r--r--src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_ring.h60
-rw-r--r--src/framework/common/pid_common.c167
-rw-r--r--src/framework/dfx/nstack_dmm_dfx.c161
-rw-r--r--src/framework/dfx/nstack_dmm_dfx.h69
-rw-r--r--src/framework/event/epoll/ephlist.h203
-rw-r--r--src/framework/event/epoll/eprb_tree.h (renamed from src/framework/common/include/eprb_tree.h)40
-rw-r--r--src/framework/event/epoll/nstack_epoll_api.c192
-rw-r--r--src/framework/event/epoll/nstack_epoll_comm.c1757
-rw-r--r--src/framework/event/epoll/nstack_eventpoll.c391
-rw-r--r--src/framework/event/epoll/nstack_eventpoll.h384
-rw-r--r--src/framework/event/epoll/nstack_sem.c433
-rw-r--r--src/framework/event/epoll/nstack_sem.h74
-rw-r--r--src/framework/hal/hal.c883
-rw-r--r--src/framework/hal/hal.h157
-rw-r--r--src/framework/include/common/compile_config.h (renamed from src/framework/common/include/compile_config.h)0
-rw-r--r--src/framework/include/common/compiling_check.h (renamed from src/framework/common/include/compiling_check.h)34
-rw-r--r--src/framework/include/common/dmm_fs.h (renamed from src/framework/common/include/dmm_fs.h)13
-rw-r--r--src/framework/include/common/generic/dmm_atomic.h184
-rw-r--r--src/framework/include/common/generic/dmm_barrier.h (renamed from src/framework/common/include/generic/dmm_barrier.h)6
-rw-r--r--src/framework/include/common/generic/dmm_common.h68
-rw-r--r--src/framework/include/common/generic/dmm_config.h (renamed from src/framework/include/dmm_config.h)17
-rw-r--r--src/framework/include/common/generic/dmm_pause.h (renamed from src/framework/common/include/generic/dmm_pause.h)6
-rw-r--r--src/framework/include/common/generic/dmm_rwlock.h (renamed from src/framework/common/include/generic/dmm_rwlock.h)46
-rw-r--r--src/framework/include/common/generic/dmm_spinlock.h119
-rw-r--r--src/framework/include/common/list.h (renamed from src/framework/common/include/list.h)78
-rw-r--r--src/framework/include/common/pid_common.h82
-rw-r--r--src/framework/include/common/pidinfo.h (renamed from src/framework/common/include/pidinfo.h)17
-rw-r--r--src/framework/include/dmm_ring.h100
-rw-r--r--src/framework/include/hal_api.h148
-rw-r--r--src/framework/include/nsfw_alarm_api.h61
-rw-r--r--src/framework/include/nsfw_base_linux_api.h61
-rw-r--r--src/framework/include/nsfw_branch_prediction.h (renamed from src/framework/common/base/include/common/common_mem_pal_memconfig.h)12
-rw-r--r--src/framework/include/nsfw_common_defs.h (renamed from stacks/lwip_stack/lwip_src/include/stackx/spl_err.h)30
-rw-r--r--src/framework/include/nsfw_dfx_api.h74
-rw-r--r--src/framework/include/nsfw_fd_timer_api.h33
-rw-r--r--src/framework/include/nsfw_hal_api.h275
-rw-r--r--src/framework/include/nsfw_init_api.h (renamed from src/framework/include/nsfw_init.h)131
-rw-r--r--src/framework/include/nsfw_maintain_api.h765
-rw-r--r--src/framework/include/nsfw_mem_api.h520
-rw-r--r--src/framework/include/nsfw_mgr_com_api.h242
-rw-r--r--src/framework/include/nsfw_ps_api.h117
-rw-r--r--src/framework/include/nsfw_recycle_api.h56
-rw-r--r--src/framework/include/nsfw_ring_data.h99
-rw-r--r--src/framework/include/nsfw_ring_fun.h114
-rw-r--r--src/framework/include/nsfw_snapshot_api.h (renamed from src/framework/include/nsfw_snapshot.h)77
-rw-r--r--src/framework/include/nsfw_upgrade.h4
-rw-r--r--src/framework/include/nstack_log.h474
-rw-r--r--src/framework/include/nstack_rd_data.h70
-rw-r--r--src/framework/include/nstack_securec.h145
-rw-r--r--src/framework/include/nstack_share_res.h91
-rw-r--r--src/framework/init/CMakeLists.txt24
-rw-r--r--src/framework/init/fw_init.c355
-rw-r--r--src/framework/init/fw_module.c342
-rw-r--r--src/framework/init/fw_module.h44
-rw-r--r--src/framework/ipc/mgr_com/mgr_com.c2220
-rw-r--r--src/framework/ipc/mgr_com/mgr_com.h98
-rw-r--r--src/framework/ipc/ps/nsfw_fd_timer.c374
-rw-r--r--src/framework/ipc/ps/nsfw_ps_mem_module.c1170
-rw-r--r--src/framework/ipc/ps/nsfw_ps_mem_module.h37
-rw-r--r--src/framework/ipc/ps/nsfw_ps_module.c2320
-rw-r--r--src/framework/ipc/ps/nsfw_ps_module.h42
-rw-r--r--src/framework/ipc/ps/nsfw_recycle_module.c613
-rw-r--r--src/framework/ipc/ps/nsfw_recycle_module.h39
-rw-r--r--src/framework/ipc/ps/nsfw_soft_param.c297
-rw-r--r--src/framework/lib_common_mem/common_api.c325
-rw-r--r--src/framework/lib_common_mem/common_buf.c299
-rw-r--r--src/framework/lib_common_mem/common_func.c205
-rw-r--r--src/framework/log/nsfw_set_log.c227
-rw-r--r--src/framework/log/nstack_log.c1039
-rw-r--r--src/framework/log/nstack_log_async.c1427
-rw-r--r--src/framework/log/nstack_log_async.h93
-rw-r--r--src/framework/log/nstack_log_auto_suppress.c376
-rw-r--r--src/framework/log/nstack_log_auto_suppress.h67
-rw-r--r--src/framework/log/nstack_log_auto_suppress_rb_tree.c506
-rw-r--r--src/framework/log/nstack_log_auto_suppress_rb_tree.h37
-rw-r--r--src/framework/log/nstack_log_base.h97
-rw-r--r--src/framework/maintain/fw_mt_config.c78
-rw-r--r--src/framework/maintain/nsfw_lock_file.c174
-rw-r--r--src/framework/maintain/nsfw_mem_stat.c286
-rw-r--r--src/framework/maintain/nsfw_res_mgr.c70
-rw-r--r--src/framework/maintain/nsfw_set_log.c196
-rw-r--r--src/framework/maintain/nsfw_soft_param.c289
-rw-r--r--src/framework/maintain/nsfw_ver_mgr.c391
-rw-r--r--src/framework/mem/basic_mem/dmm_fshm.c200
-rw-r--r--src/framework/mem/basic_mem/dmm_group.c212
-rw-r--r--src/framework/mem/basic_mem/dmm_group.h (renamed from src/framework/mem/dmm_group.h)14
-rw-r--r--src/framework/mem/basic_mem/dmm_heap.c82
-rw-r--r--src/framework/mem/basic_mem/dmm_huge.c192
-rw-r--r--src/framework/mem/basic_mem/dmm_memory.c284
-rw-r--r--src/framework/mem/basic_mem/dmm_memory.h126
-rw-r--r--src/framework/mem/basic_mem/dmm_segment.c536
-rw-r--r--src/framework/mem/basic_mem/dmm_segment.h (renamed from src/framework/mem/dmm_segment.h)29
-rw-r--r--src/framework/mem/basic_mem/dmm_share.h (renamed from src/framework/mem/dmm_share.h)67
-rw-r--r--src/framework/mem/dmm_fshm.c144
-rw-r--r--src/framework/mem/dmm_group.c185
-rw-r--r--src/framework/mem/dmm_heap.c83
-rw-r--r--src/framework/mem/dmm_huge.c53
-rw-r--r--src/framework/mem/dmm_memory.c133
-rw-r--r--src/framework/mem/dmm_memory.h78
-rw-r--r--src/framework/mem/dmm_nshmem_mng.c126
-rw-r--r--src/framework/mem/dmm_nshmem_mng.h (renamed from stacks/lwip_stack/lwip_src/common/stackx_tx_box.h)34
-rw-r--r--src/framework/mem/dmm_segment.c543
-rw-r--r--src/framework/mem/dmm_shmem_mng.c287
-rw-r--r--src/framework/mem/dmm_shmem_mng.h54
-rw-r--r--src/framework/mem/nsfw_mem_api.c932
-rw-r--r--src/framework/mem/nsfw_mem_desc.c104
-rw-r--r--src/framework/rd/nstack_rd_api.c766
-rw-r--r--src/framework/res/nstack_share_res.c270
-rw-r--r--src/framework/ring/dmm_ring.c214
-rw-r--r--src/framework/ring/dmm_ring_base.h190
-rw-r--r--src/framework/snapshot/fw_snapshot.c733
-rw-r--r--src/framework/snapshot/fw_snapshot.h (renamed from src/framework/snapshot/fw_ss_tlv.h)6
-rw-r--r--src/include/declare_syscalls.h.tmpl56
-rw-r--r--src/include/nstack_callback_ops.h95
-rw-r--r--src/include/nstack_epoll_api.h53
-rw-r--r--src/include/nstack_ip_addr.h95
-rw-r--r--src/include/nstack_log.h596
-rw-r--r--src/include/nstack_rd_api.h124
-rw-r--r--src/include/nstack_securec.h114
-rw-r--r--src/include/types.h (renamed from src/nSocket/include/nstack_types.h)95
-rw-r--r--src/nSocket/CMakeLists.txt41
-rw-r--r--src/nSocket/include/declare_syscalls.h51
-rw-r--r--src/nSocket/include/nstack_atomic.h8
-rw-r--r--src/nSocket/include/nstack_dmm_api.h93
-rw-r--r--src/nSocket/include/nstack_eventpoll.h338
-rw-r--r--src/nSocket/include/nstack_ip_addr.h36
-rw-r--r--src/nSocket/include/nstack_rd.h29
-rw-r--r--src/nSocket/include/nstack_rd_init.h45
-rw-r--r--src/nSocket/include/nstack_rd_priv.h (renamed from src/nSocket/nstack_rd/nstack_rd_priv.h)74
-rw-r--r--src/nSocket/include/nstack_select.h193
-rw-r--r--src/nSocket/include/nstack_sockops.h7
-rw-r--r--src/nSocket/include/select_adapt.h82
-rw-r--r--src/nSocket/kernel/linux_kernel_module.c419
-rw-r--r--src/nSocket/kernel/linux_kernel_module.h26
-rw-r--r--src/nSocket/kernel/linux_kernel_socket.c42
-rw-r--r--src/nSocket/kernel/linux_kernel_socket.h6
-rw-r--r--src/nSocket/nstack/event/epoll/nstack_epoll.c887
-rw-r--r--src/nSocket/nstack/event/epoll/nstack_eventpoll.c1215
-rw-r--r--src/nSocket/nstack/event/select/nstack_select.c1368
-rw-r--r--src/nSocket/nstack/event/select/select_adapt.c301
-rw-r--r--src/nSocket/nstack/nstack.c1124
-rw-r--r--src/nSocket/nstack/nstack.h104
-rw-r--r--src/nSocket/nstack/nstack_fd_mng.c402
-rw-r--r--src/nSocket/nstack/nstack_fd_mng.h179
-rw-r--r--src/nSocket/nstack/nstack_info_parse.c736
-rw-r--r--src/nSocket/nstack/nstack_info_parse.h5
-rw-r--r--src/nSocket/nstack/nstack_module.c423
-rw-r--r--src/nSocket/nstack/nstack_module.h127
-rw-r--r--src/nSocket/nstack/nstack_nsocket_construct.c28
-rw-r--r--src/nSocket/nstack/nstack_socket.c4464
-rw-r--r--src/nSocket/nstack/nstack_socket.h120
-rw-r--r--src/nSocket/nstack_rd/nstack_rd.c776
-rw-r--r--src/nSocket/nstack_rd/nstack_rd_init.c171
-rw-r--r--src/nSocket/nstack_rd/nstack_rd_ip.c387
-rw-r--r--src/nSocket/nstack_rd/nstack_rd_ip.h16
-rw-r--r--src/nSocket/nstack_rd/nstack_rd_ip6.c261
-rw-r--r--src/nSocket/nstack_rd/nstack_rd_ip6.h (renamed from src/framework/common/base/include/common/common_mem_common.h)16
-rw-r--r--src/nSocket/nstack_rd/nstack_rd_proto.c251
-rw-r--r--src/nSocket/nstack_rd/nstack_rd_proto.h25
-rw-r--r--src/nSocket/nstack_rd/nstack_rd_type.c229
-rw-r--r--src/nSocket/nstack_rd/nstack_rd_type.h42
-rw-r--r--stacks/lwip_stack/CMakeLists.txt111
-rw-r--r--stacks/lwip_stack/configure/module_config.json17
-rw-r--r--stacks/lwip_stack/configure/nStackConfig.json32
-rw-r--r--stacks/lwip_stack/configure/rd_config.json26
-rw-r--r--stacks/lwip_stack/doc/README.md125
-rw-r--r--stacks/lwip_stack/doc/dmm_lwip.pngbin52940 -> 0 bytes
-rw-r--r--stacks/lwip_stack/lwip_src/CMakeLists.txt98
-rw-r--r--stacks/lwip_stack/lwip_src/api/spl_api.c51
-rw-r--r--stacks/lwip_stack/lwip_src/api/spl_api_msg.c3329
-rw-r--r--stacks/lwip_stack/lwip_src/api/spl_netbuf.c58
-rw-r--r--stacks/lwip_stack/lwip_src/api/spl_netifapi.c288
-rw-r--r--stacks/lwip_stack/lwip_src/api/spl_sbr.c495
-rw-r--r--stacks/lwip_stack/lwip_src/api/spl_tcpip.c1547
-rw-r--r--stacks/lwip_stack/lwip_src/common/rb_tree.c393
-rw-r--r--stacks/lwip_stack/lwip_src/common/rb_tree.h112
-rw-r--r--stacks/lwip_stack/lwip_src/common/spl_def.h142
-rw-r--r--stacks/lwip_stack/lwip_src/common/spl_opt.h329
-rw-r--r--stacks/lwip_stack/lwip_src/common/stackx_app_res.c972
-rw-r--r--stacks/lwip_stack/lwip_src/common/stackx_app_res.h103
-rw-r--r--stacks/lwip_stack/lwip_src/common/stackx_common.c357
-rw-r--r--stacks/lwip_stack/lwip_src/common/stackx_common.h44
-rw-r--r--stacks/lwip_stack/lwip_src/common/stackx_common_opt.h147
-rw-r--r--stacks/lwip_stack/lwip_src/common/stackx_debug.h70
-rw-r--r--stacks/lwip_stack/lwip_src/common/stackx_err.h68
-rw-r--r--stacks/lwip_stack/lwip_src/common/stackx_ip_addr.c280
-rw-r--r--stacks/lwip_stack/lwip_src/common/stackx_ip_addr.h82
-rw-r--r--stacks/lwip_stack/lwip_src/common/stackx_ip_tos.h146
-rw-r--r--stacks/lwip_stack/lwip_src/common/stackx_netbuf.h43
-rw-r--r--stacks/lwip_stack/lwip_src/common/stackx_pbuf.c223
-rw-r--r--stacks/lwip_stack/lwip_src/common/stackx_pbuf.h82
-rw-r--r--stacks/lwip_stack/lwip_src/common/stackx_pbuf_comm.h109
-rw-r--r--stacks/lwip_stack/lwip_src/common/stackx_spl_msg.h241
-rw-r--r--stacks/lwip_stack/lwip_src/common/stackx_spl_share.c198
-rw-r--r--stacks/lwip_stack/lwip_src/common/stackx_spl_share.h490
-rw-r--r--stacks/lwip_stack/lwip_src/common/stackx_tcp_opt.h42
-rw-r--r--stacks/lwip_stack/lwip_src/common/stackx_tx_box.c64
-rw-r--r--stacks/lwip_stack/lwip_src/common/stackx_types.h68
-rw-r--r--stacks/lwip_stack/lwip_src/common/stackxopts.h53
-rw-r--r--stacks/lwip_stack/lwip_src/core/global_tick.c48
-rw-r--r--stacks/lwip_stack/lwip_src/core/spl_pbuf.c611
-rw-r--r--stacks/lwip_stack/lwip_src/core/spl_timers.c607
-rw-r--r--stacks/lwip_stack/lwip_src/core/unmatch_version.c59
-rw-r--r--stacks/lwip_stack/lwip_src/include/ip_module/config_common.h64
-rw-r--r--stacks/lwip_stack/lwip_src/include/ip_module/configuration_reader.h26
-rw-r--r--stacks/lwip_stack/lwip_src/include/ip_module/container_ip.h39
-rw-r--r--stacks/lwip_stack/lwip_src/include/ip_module/ip_module_api.h223
-rw-r--r--stacks/lwip_stack/lwip_src/include/ip_module/network.h36
-rw-r--r--stacks/lwip_stack/lwip_src/include/ip_module/trp_rb_tree.h77
-rw-r--r--stacks/lwip_stack/lwip_src/include/ipv4/stackx/spl_ip_addr.h162
-rw-r--r--stacks/lwip_stack/lwip_src/include/netif/common.h233
-rw-r--r--stacks/lwip_stack/lwip_src/include/netif/kni_proc.h103
-rw-r--r--stacks/lwip_stack/lwip_src/include/netif/sc_dpdk.h80
-rw-r--r--stacks/lwip_stack/lwip_src/include/netif/sharedmemory.h149
-rw-r--r--stacks/lwip_stack/lwip_src/include/netif/spl_hal.h114
-rw-r--r--stacks/lwip_stack/lwip_src/include/stackx/internal_msg.h90
-rw-r--r--stacks/lwip_stack/lwip_src/include/stackx/spl_api.h276
-rw-r--r--stacks/lwip_stack/lwip_src/include/stackx/spl_api_msg.h129
-rw-r--r--stacks/lwip_stack/lwip_src/include/stackx/spl_instance.h30
-rw-r--r--stacks/lwip_stack/lwip_src/include/stackx/spl_netbuf.h52
-rw-r--r--stacks/lwip_stack/lwip_src/include/stackx/spl_pbuf.h176
-rw-r--r--stacks/lwip_stack/lwip_src/include/stackx/spl_sbr.h33
-rw-r--r--stacks/lwip_stack/lwip_src/include/stackx/spl_sockets.h252
-rw-r--r--stacks/lwip_stack/lwip_src/include/stackx/spl_tcpip.h80
-rw-r--r--stacks/lwip_stack/lwip_src/include/stackx/spl_timers.h108
-rw-r--r--stacks/lwip_stack/lwip_src/include/stackx/stackx_instance.h91
-rw-r--r--stacks/lwip_stack/lwip_src/instance/spl_instance.c49
-rw-r--r--stacks/lwip_stack/lwip_src/ip_module/configuration_reader.c1052
-rw-r--r--stacks/lwip_stack/lwip_src/ip_module/container_ip.c1132
-rw-r--r--stacks/lwip_stack/lwip_src/ip_module/ip_module_api.c347
-rw-r--r--stacks/lwip_stack/lwip_src/ip_module/network.c1106
-rw-r--r--stacks/lwip_stack/lwip_src/ip_module/trp_rb_tree.c563
-rw-r--r--stacks/lwip_stack/lwip_src/netif/ethernetif.c167
-rw-r--r--stacks/lwip_stack/lwip_src/netif/sc_dpdk.c574
-rw-r--r--stacks/lwip_stack/lwip_src/netif/spl_hal.c1774
-rw-r--r--stacks/lwip_stack/lwip_src/recycle/stackx_recycle.c676
-rw-r--r--stacks/lwip_stack/lwip_src/socket/CMakeLists.txt76
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_cfg.h54
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_container_cfg.c332
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_epoll_api.c150
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_epoll_api.h48
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_event.c128
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_event.h46
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_macro.h24
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_msg_handler.c775
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_msg_handler.h78
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_prot_com.c679
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_prot_com.h162
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_protocol_api.c113
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_res_mgr.c279
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_res_mgr.h70
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_socket.h141
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_tcp.c1691
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_udp.c1153
-rw-r--r--stacks/lwip_stack/release/configure/ip_data.json8
-rw-r--r--stacks/lwip_stack/release/configure/nStackConfig.json32
-rw-r--r--stacks/lwip_stack/release/configure/network_data_tonStack.json16
-rw-r--r--stacks/lwip_stack/release/include/nstack_custom_api.h42
-rw-r--r--stacks/lwip_stack/release/lwip_helper_files/arch/queue.c120
-rw-r--r--stacks/lwip_stack/release/lwip_helper_files/arch/sys_arch.c237
-rw-r--r--stacks/lwip_stack/release/lwip_helper_files/core/timeouts.c527
-rwxr-xr-xstacks/lwip_stack/release/lwip_helper_files/download_lwip.sh35
-rw-r--r--stacks/lwip_stack/release/lwip_helper_files/include/lwipopts.h47
-rw-r--r--stacks/lwip_stack/release/lwip_helper_files/include/opt.h2875
-rw-r--r--stacks/lwip_stack/release/lwip_helper_files/include/sys.h455
-rw-r--r--stacks/lwip_stack/release/lwip_helper_files/include/timeouts.h134
-rw-r--r--stacks/lwip_stack/release/lwip_helper_files/lwip/arch/atomic_32.h53
-rw-r--r--stacks/lwip_stack/release/lwip_helper_files/lwip/arch/cc.h82
-rw-r--r--stacks/lwip_stack/release/lwip_helper_files/lwip/arch/queue.h30
-rw-r--r--stacks/lwip_stack/release/lwip_helper_files/lwip/arch/sys_arch.h29
-rw-r--r--stacks/lwip_stack/release/lwip_helper_files/lwip/arch/win_minmax.h120
-rwxr-xr-xstacks/lwip_stack/release/script/nstack_fun.sh596
-rwxr-xr-xstacks/lwip_stack/release/script/nstack_var.sh65
-rwxr-xr-xstacks/lwip_stack/release/script/run_nstack_main.sh27
-rwxr-xr-xstacks/lwip_stack/release/script/run_nstack_master.sh29
-rwxr-xr-xstacks/lwip_stack/release/send_alarm.sh17
-rwxr-xr-xstacks/lwip_stack/release/start_nstack.sh149
-rwxr-xr-xstacks/lwip_stack/release/stop_nstack.sh51
-rwxr-xr-xstacks/lwip_stack/release/uninstall.sh34
-rw-r--r--stacks/lwip_stack/release_tar.sh86
-rw-r--r--stacks/lwip_stack/run_stackx.txt52
-rw-r--r--stacks/lwip_stack/src/CMakeLists.txt62
-rw-r--r--stacks/lwip_stack/src/alarm/CMakeLists.txt34
-rw-r--r--stacks/lwip_stack/src/alarm/alarm.c861
-rw-r--r--stacks/lwip_stack/src/alarm/alarm.h80
-rw-r--r--stacks/lwip_stack/src/alarm/alarm_api.h107
-rw-r--r--stacks/lwip_stack/src/include/nsfw_msg.h203
-rw-r--r--stacks/lwip_stack/src/include/nsfw_msg_api.h309
-rw-r--r--stacks/lwip_stack/src/include/nsfw_mt_config.h292
-rw-r--r--stacks/lwip_stack/src/include/nsfw_rti.h66
-rw-r--r--stacks/lwip_stack/src/io_adpt/CMakeLists.txt31
-rw-r--r--stacks/lwip_stack/src/io_adpt/dpdk.c2476
-rw-r--r--stacks/lwip_stack/src/maintain/CMakeLists.txt44
-rw-r--r--stacks/lwip_stack/src/maintain/fw_mt_config.c807
-rw-r--r--stacks/lwip_stack/src/maintain/nsfw_msg.c23
-rw-r--r--stacks/lwip_stack/src/maintain/nsfw_rti.c92
-rw-r--r--stacks/lwip_stack/src/nStackMain/CMakeLists.txt60
-rw-r--r--stacks/lwip_stack/src/nStackMain/main.c429
-rw-r--r--stacks/lwip_stack/src/sbr/CMakeLists.txt30
-rw-r--r--stacks/lwip_stack/src/sbr/sbr_err.h191
-rw-r--r--stacks/lwip_stack/src/sbr/sbr_index_ring.c212
-rw-r--r--stacks/lwip_stack/src/sbr/sbr_index_ring.h61
-rw-r--r--stacks/lwip_stack/src/sbr/sbr_protocol_api.h103
-rw-r--r--stacks/lwip_stack/src/sbr/sbr_res_mgr.c88
-rw-r--r--stacks/lwip_stack/src/sbr/sbr_res_mgr.h159
-rw-r--r--stacks/lwip_stack/src/sbr/sbr_socket.c1274
-rw-r--r--stacks/lwip_stack/src/tools/CMakeLists.txt22
-rw-r--r--stacks/lwip_stack/src/tools/dump_tool.c622
-rw-r--r--stacks/lwip_stack/src/tools/dump_tool.h81
-rw-r--r--stacks/lwip_stack/tools/CMakeLists.txt91
-rw-r--r--stacks/lwip_stack/tools/nping.c627
-rw-r--r--stacks/lwip_stack/tools/ntcpdump.c1368
-rw-r--r--stacks/lwip_stack/tools/tool_common.h243
-rw-r--r--stacks/lwip_stack/vagrant/Vagrantfile65
-rwxr-xr-xstacks/lwip_stack/vagrant/build.sh59
-rwxr-xr-xstacks/lwip_stack/vagrant/env.sh7
-rwxr-xr-xstacks/lwip_stack/vagrant/start_nstackMain.sh110
-rw-r--r--stacks/readme.txt1
-rw-r--r--stacks/rsocket/CMakeLists.txt42
-rw-r--r--stacks/rsocket/build/.gitkeep (renamed from stacks/lwip_stack/patch/.gitkeep)0
-rw-r--r--stacks/rsocket/configure/module_config.json10
-rw-r--r--stacks/rsocket/configure/rd_config.json31
-rw-r--r--stacks/rsocket/doc/README.md8
-rw-r--r--stacks/rsocket/src/rsocket_adpt.c258
-rw-r--r--stacks/rsocket/src/rsocket_adpt.h23
-rw-r--r--stacks/rsocket/src/rsocket_rdma.h40
-rw-r--r--stacks/rsocket/src/rsocket_rs.c422
-rw-r--r--stacks/vpp/adapt/dmm_vcl.h36
-rw-r--r--stacks/vpp/adapt/dmm_vcl_adpt.c173
-rw-r--r--stacks/vpp/configure/module_config.json20
-rw-r--r--stacks/vpp/configure/rd_config.json26
-rw-r--r--stacks/vpp/configure/startup.conf21
-rw-r--r--stacks/vpp/configure/vpp_config6
-rw-r--r--stacks/vpp/doc/README.md115
-rw-r--r--stacks/vpp/patch/0001-Fix-modify-makefile-to-adapt-dmm.patch72
-rw-r--r--stacks/vpp/patch/0002-Fix-fix-epoll-problem.patch62
-rw-r--r--stacks/vpp/vagrant/Vagrantfile63
-rw-r--r--stacks/vpp/vagrant/build.sh224
-rw-r--r--stacks/vpp/vagrant/env.sh7
-rw-r--r--stacks/vpp/vagrant/install_prereq.sh39
-rw-r--r--test/perf/bps.md141
-rw-r--r--test/perf/bps_epoll.md141
-rw-r--r--test/perf/bps_select.md141
-rw-r--r--test/perf/iperf.md136
-rw-r--r--test/perf/resources/test_topology.pngbin33310 -> 0 bytes
-rw-r--r--testcode/app_example/CMakeLists.txt (renamed from app_example/CMakeLists.txt)13
-rw-r--r--testcode/app_example/build/.gitkeep (renamed from stacks/lwip_stack/release/lib64/.gitkeep)0
-rw-r--r--testcode/app_example/func-test/CMakeLists.txt (renamed from app_example/func-test/CMakeLists.txt)0
-rw-r--r--testcode/app_example/func-test/file_transfer/CMakeLists.txt (renamed from app_example/func-test/file_transfer/CMakeLists.txt)4
-rw-r--r--testcode/app_example/func-test/file_transfer/client_filetrans.c276
-rw-r--r--testcode/app_example/func-test/file_transfer/server_filetrans.c336
-rw-r--r--testcode/app_example/func-test/fork/CMakeLists.txt (renamed from app_example/func-test/fork/CMakeLists.txt)4
-rw-r--r--testcode/app_example/func-test/fork/tcpclient.c170
-rw-r--r--testcode/app_example/func-test/fork/tcpserver.c156
-rw-r--r--testcode/app_example/module_config.json (renamed from release/configure/module_config.json)10
-rw-r--r--testcode/app_example/perf-test/CMakeLists.txt (renamed from app_example/perf-test/CMakeLists.txt)4
-rw-r--r--testcode/app_example/perf-test/multi_tcp_common_Ser.c538
-rw-r--r--testcode/app_example/perf-test/multi_tcp_common_app_Cli.c392
-rw-r--r--testcode/app_example/perf-test/multi_tcp_epoll_app_Ser.c627
-rw-r--r--testcode/app_example/perf-test/multi_tcp_select_app_Ser.c431
-rw-r--r--testcode/app_example/rd_config.json14
-rw-r--r--thirdparty/glog/glog-0.3.4/AUTHORS2
-rw-r--r--thirdparty/glog/glog-0.3.5/.gitignore (renamed from thirdparty/glog/glog-0.3.4/.gitignore)0
-rw-r--r--thirdparty/glog/glog-0.3.5/AUTHORS22
-rw-r--r--thirdparty/glog/glog-0.3.5/CMakeLists.txt583
-rw-r--r--thirdparty/glog/glog-0.3.5/CONTRIBUTING.md58
-rw-r--r--thirdparty/glog/glog-0.3.5/CONTRIBUTORS40
-rw-r--r--thirdparty/glog/glog-0.3.5/COPYING (renamed from thirdparty/glog/glog-0.3.4/COPYING)0
-rw-r--r--thirdparty/glog/glog-0.3.5/ChangeLog (renamed from thirdparty/glog/glog-0.3.4/ChangeLog)0
-rw-r--r--thirdparty/glog/glog-0.3.5/INSTALL297
-rw-r--r--thirdparty/glog/glog-0.3.5/Makefile.am (renamed from thirdparty/glog/glog-0.3.4/Makefile.am)4
-rw-r--r--thirdparty/glog/glog-0.3.5/Makefile.in2084
-rw-r--r--thirdparty/glog/glog-0.3.5/NEWS (renamed from thirdparty/glog/glog-0.3.4/NEWS)0
-rw-r--r--thirdparty/glog/glog-0.3.5/README (renamed from thirdparty/glog/glog-0.3.4/README)0
-rw-r--r--thirdparty/glog/glog-0.3.5/README.windows (renamed from thirdparty/glog/glog-0.3.4/README.windows)0
-rw-r--r--thirdparty/glog/glog-0.3.5/aclocal.m41196
-rw-r--r--thirdparty/glog/glog-0.3.5/cmake/DetermineGflagsNamespace.cmake69
-rw-r--r--thirdparty/glog/glog-0.3.5/cmake/INSTALL.md30
-rw-r--r--thirdparty/glog/glog-0.3.5/compile (renamed from thirdparty/glog/glog-0.3.4/compile)0
-rw-r--r--thirdparty/glog/glog-0.3.5/config.guess1523
-rw-r--r--thirdparty/glog/glog-0.3.5/config.sub1626
-rw-r--r--thirdparty/glog/glog-0.3.5/configure20104
-rw-r--r--thirdparty/glog/glog-0.3.5/configure.ac (renamed from thirdparty/glog/glog-0.3.4/configure.ac)2
-rw-r--r--thirdparty/glog/glog-0.3.5/depcomp589
-rw-r--r--thirdparty/glog/glog-0.3.5/doc/designstyle.css (renamed from thirdparty/glog/glog-0.3.4/doc/designstyle.css)0
-rw-r--r--thirdparty/glog/glog-0.3.5/doc/glog.html (renamed from thirdparty/glog/glog-0.3.4/doc/glog.html)0
-rw-r--r--thirdparty/glog/glog-0.3.5/glog-config.cmake.in7
-rw-r--r--thirdparty/glog/glog-0.3.5/google-glog.sln (renamed from thirdparty/glog/glog-0.3.4/google-glog.sln)88
-rw-r--r--thirdparty/glog/glog-0.3.5/install-sh519
-rw-r--r--thirdparty/glog/glog-0.3.5/libglog.pc.in (renamed from thirdparty/glog/glog-0.3.4/libglog.pc.in)0
-rw-r--r--thirdparty/glog/glog-0.3.5/ltmain.sh9661
-rw-r--r--thirdparty/glog/glog-0.3.5/m4/ac_have_attribute.m4 (renamed from thirdparty/glog/glog-0.3.4/m4/ac_have_attribute.m4)0
-rw-r--r--thirdparty/glog/glog-0.3.5/m4/ac_have_builtin_expect.m4 (renamed from thirdparty/glog/glog-0.3.4/m4/ac_have_builtin_expect.m4)0
-rw-r--r--thirdparty/glog/glog-0.3.5/m4/ac_have_sync_val_compare_and_swap.m4 (renamed from thirdparty/glog/glog-0.3.4/m4/ac_have_sync_val_compare_and_swap.m4)0
-rw-r--r--thirdparty/glog/glog-0.3.5/m4/ac_rwlock.m4 (renamed from thirdparty/glog/glog-0.3.4/m4/ac_rwlock.m4)0
-rw-r--r--thirdparty/glog/glog-0.3.5/m4/acx_pthread.m4 (renamed from thirdparty/glog/glog-0.3.4/m4/acx_pthread.m4)0
-rw-r--r--thirdparty/glog/glog-0.3.5/m4/google_namespace.m4 (renamed from thirdparty/glog/glog-0.3.4/m4/google_namespace.m4)0
-rw-r--r--thirdparty/glog/glog-0.3.5/m4/libtool.m48001
-rw-r--r--thirdparty/glog/glog-0.3.5/m4/ltoptions.m4 (renamed from thirdparty/glog/glog-0.3.4/m4/ltoptions.m4)0
-rw-r--r--thirdparty/glog/glog-0.3.5/m4/ltsugar.m4 (renamed from thirdparty/glog/glog-0.3.4/m4/ltsugar.m4)0
-rw-r--r--thirdparty/glog/glog-0.3.5/m4/ltversion.m4 (renamed from thirdparty/glog/glog-0.3.4/m4/ltversion.m4)0
-rw-r--r--thirdparty/glog/glog-0.3.5/m4/lt~obsolete.m4 (renamed from thirdparty/glog/glog-0.3.4/m4/lt~obsolete.m4)0
-rw-r--r--thirdparty/glog/glog-0.3.5/m4/namespaces.m4 (renamed from thirdparty/glog/glog-0.3.4/m4/namespaces.m4)0
-rw-r--r--thirdparty/glog/glog-0.3.5/m4/pc_from_ucontext.m4 (renamed from thirdparty/glog/glog-0.3.4/m4/pc_from_ucontext.m4)0
-rw-r--r--thirdparty/glog/glog-0.3.5/m4/stl_namespace.m4 (renamed from thirdparty/glog/glog-0.3.4/m4/stl_namespace.m4)0
-rw-r--r--thirdparty/glog/glog-0.3.5/m4/using_operator.m4 (renamed from thirdparty/glog/glog-0.3.4/m4/using_operator.m4)0
-rw-r--r--thirdparty/glog/glog-0.3.5/missing367
-rw-r--r--thirdparty/glog/glog-0.3.5/mkinstalldirs161
-rw-r--r--thirdparty/glog/glog-0.3.5/packages/deb.sh (renamed from thirdparty/glog/glog-0.3.4/packages/deb.sh)0
-rw-r--r--thirdparty/glog/glog-0.3.5/packages/deb/README (renamed from thirdparty/glog/glog-0.3.4/packages/deb/README)0
-rw-r--r--thirdparty/glog/glog-0.3.5/packages/deb/changelog (renamed from thirdparty/glog/glog-0.3.4/packages/deb/changelog)6
-rw-r--r--thirdparty/glog/glog-0.3.5/packages/deb/compat (renamed from thirdparty/glog/glog-0.3.4/packages/deb/compat)0
-rw-r--r--thirdparty/glog/glog-0.3.5/packages/deb/control (renamed from thirdparty/glog/glog-0.3.4/packages/deb/control)0
-rw-r--r--thirdparty/glog/glog-0.3.5/packages/deb/copyright (renamed from thirdparty/glog/glog-0.3.4/packages/deb/copyright)0
-rw-r--r--thirdparty/glog/glog-0.3.5/packages/deb/docs (renamed from thirdparty/glog/glog-0.3.4/packages/deb/docs)0
-rw-r--r--thirdparty/glog/glog-0.3.5/packages/deb/libgoogle-glog-dev.dirs (renamed from thirdparty/glog/glog-0.3.4/packages/deb/libgoogle-glog-dev.dirs)0
-rw-r--r--thirdparty/glog/glog-0.3.5/packages/deb/libgoogle-glog-dev.install (renamed from thirdparty/glog/glog-0.3.4/packages/deb/libgoogle-glog-dev.install)0
-rw-r--r--thirdparty/glog/glog-0.3.5/packages/deb/libgoogle-glog0.dirs (renamed from thirdparty/glog/glog-0.3.4/packages/deb/libgoogle-glog0.dirs)0
-rw-r--r--thirdparty/glog/glog-0.3.5/packages/deb/libgoogle-glog0.install (renamed from thirdparty/glog/glog-0.3.4/packages/deb/libgoogle-glog0.install)0
-rw-r--r--thirdparty/glog/glog-0.3.5/packages/deb/rules (renamed from thirdparty/glog/glog-0.3.4/packages/deb/rules)0
-rw-r--r--thirdparty/glog/glog-0.3.5/packages/rpm.sh (renamed from thirdparty/glog/glog-0.3.4/packages/rpm.sh)0
-rw-r--r--thirdparty/glog/glog-0.3.5/packages/rpm/rpm.spec (renamed from thirdparty/glog/glog-0.3.4/packages/rpm/rpm.spec)0
-rw-r--r--thirdparty/glog/glog-0.3.5/src/base/commandlineflags.h (renamed from thirdparty/glog/glog-0.3.4/src/base/commandlineflags.h)13
-rw-r--r--thirdparty/glog/glog-0.3.5/src/base/googleinit.h (renamed from thirdparty/glog/glog-0.3.4/src/base/googleinit.h)0
-rw-r--r--thirdparty/glog/glog-0.3.5/src/base/mutex.h (renamed from thirdparty/glog/glog-0.3.4/src/base/mutex.h)35
-rw-r--r--thirdparty/glog/glog-0.3.5/src/config.h.cmake.in184
-rw-r--r--thirdparty/glog/glog-0.3.5/src/config.h.in180
-rw-r--r--thirdparty/glog/glog-0.3.5/src/config_for_unittests.h (renamed from thirdparty/glog/glog-0.3.4/src/config_for_unittests.h)0
-rw-r--r--thirdparty/glog/glog-0.3.5/src/demangle.cc (renamed from thirdparty/glog/glog-0.3.4/src/demangle.cc)29
-rw-r--r--thirdparty/glog/glog-0.3.5/src/demangle.h (renamed from thirdparty/glog/glog-0.3.4/src/demangle.h)3
-rw-r--r--thirdparty/glog/glog-0.3.5/src/demangle_unittest.cc (renamed from thirdparty/glog/glog-0.3.4/src/demangle_unittest.cc)5
-rw-r--r--thirdparty/glog/glog-0.3.5/src/demangle_unittest.sh (renamed from thirdparty/glog/glog-0.3.4/src/demangle_unittest.sh)0
-rw-r--r--thirdparty/glog/glog-0.3.5/src/demangle_unittest.txt (renamed from thirdparty/glog/glog-0.3.4/src/demangle_unittest.txt)0
-rw-r--r--thirdparty/glog/glog-0.3.5/src/glog/log_severity.h (renamed from thirdparty/glog/glog-0.3.4/src/glog/log_severity.h)0
-rw-r--r--thirdparty/glog/glog-0.3.5/src/glog/logging.h.in (renamed from thirdparty/glog/glog-0.3.4/src/glog/logging.h.in)138
-rw-r--r--thirdparty/glog/glog-0.3.5/src/glog/nstack_adapter.ph (renamed from thirdparty/glog/glog-0.3.4/src/glog/nstack_adapter.ph)11
-rw-r--r--thirdparty/glog/glog-0.3.5/src/glog/nstack_glog.ph (renamed from thirdparty/glog/glog-0.3.4/src/glog/nstack_glog.ph)35
-rw-r--r--thirdparty/glog/glog-0.3.5/src/glog/nstack_glog_in.h (renamed from thirdparty/glog/glog-0.3.4/src/glog/nstack_glog_in.h)40
-rw-r--r--thirdparty/glog/glog-0.3.5/src/glog/raw_logging.h.in (renamed from thirdparty/glog/glog-0.3.4/src/glog/raw_logging.h.in)18
-rw-r--r--thirdparty/glog/glog-0.3.5/src/glog/stl_logging.h.in (renamed from thirdparty/glog/glog-0.3.4/src/glog/stl_logging.h.in)7
-rw-r--r--thirdparty/glog/glog-0.3.5/src/glog/vlog_is_on.h.in (renamed from thirdparty/glog/glog-0.3.4/src/glog/vlog_is_on.h.in)0
-rw-r--r--thirdparty/glog/glog-0.3.5/src/googletest.h (renamed from thirdparty/glog/glog-0.3.4/src/googletest.h)51
-rw-r--r--thirdparty/glog/glog-0.3.5/src/logging.cc (renamed from thirdparty/glog/glog-0.3.4/src/logging.cc)396
-rw-r--r--thirdparty/glog/glog-0.3.5/src/logging_striplog_test.sh (renamed from thirdparty/glog/glog-0.3.4/src/logging_striplog_test.sh)0
-rw-r--r--thirdparty/glog/glog-0.3.5/src/logging_striptest10.cc (renamed from thirdparty/glog/glog-0.3.4/src/logging_striptest10.cc)0
-rw-r--r--thirdparty/glog/glog-0.3.5/src/logging_striptest2.cc (renamed from thirdparty/glog/glog-0.3.4/src/logging_striptest2.cc)0
-rw-r--r--thirdparty/glog/glog-0.3.5/src/logging_striptest_main.cc (renamed from thirdparty/glog/glog-0.3.4/src/logging_striptest_main.cc)10
-rw-r--r--thirdparty/glog/glog-0.3.5/src/logging_unittest.cc (renamed from thirdparty/glog/glog-0.3.4/src/logging_unittest.cc)23
-rw-r--r--thirdparty/glog/glog-0.3.5/src/logging_unittest.err (renamed from thirdparty/glog/glog-0.3.4/src/logging_unittest.err)0
-rw-r--r--thirdparty/glog/glog-0.3.5/src/mock-log.h (renamed from thirdparty/glog/glog-0.3.4/src/mock-log.h)11
-rw-r--r--thirdparty/glog/glog-0.3.5/src/mock-log_test.cc (renamed from thirdparty/glog/glog-0.3.4/src/mock-log_test.cc)6
-rw-r--r--thirdparty/glog/glog-0.3.5/src/nstack_logging.cc (renamed from thirdparty/glog/glog-0.3.4/src/nstack_logging.cc)124
-rw-r--r--thirdparty/glog/glog-0.3.5/src/raw_logging.cc (renamed from thirdparty/glog/glog-0.3.4/src/raw_logging.cc)11
-rw-r--r--thirdparty/glog/glog-0.3.5/src/signalhandler.cc (renamed from thirdparty/glog/glog-0.3.4/src/signalhandler.cc)24
-rw-r--r--thirdparty/glog/glog-0.3.5/src/signalhandler_unittest.cc (renamed from thirdparty/glog/glog-0.3.4/src/signalhandler_unittest.cc)10
-rw-r--r--thirdparty/glog/glog-0.3.5/src/signalhandler_unittest.sh (renamed from thirdparty/glog/glog-0.3.4/src/signalhandler_unittest.sh)0
-rw-r--r--thirdparty/glog/glog-0.3.5/src/stacktrace.h (renamed from thirdparty/glog/glog-0.3.4/src/stacktrace.h)0
-rw-r--r--thirdparty/glog/glog-0.3.5/src/stacktrace_generic-inl.h (renamed from thirdparty/glog/glog-0.3.4/src/stacktrace_generic-inl.h)0
-rw-r--r--thirdparty/glog/glog-0.3.5/src/stacktrace_libunwind-inl.h (renamed from thirdparty/glog/glog-0.3.4/src/stacktrace_libunwind-inl.h)5
-rw-r--r--thirdparty/glog/glog-0.3.5/src/stacktrace_powerpc-inl.h (renamed from thirdparty/glog/glog-0.3.4/src/stacktrace_powerpc-inl.h)8
-rw-r--r--thirdparty/glog/glog-0.3.5/src/stacktrace_unittest.cc (renamed from thirdparty/glog/glog-0.3.4/src/stacktrace_unittest.cc)12
-rw-r--r--thirdparty/glog/glog-0.3.5/src/stacktrace_x86-inl.h (renamed from thirdparty/glog/glog-0.3.4/src/stacktrace_x86-inl.h)0
-rw-r--r--thirdparty/glog/glog-0.3.5/src/stacktrace_x86_64-inl.h (renamed from thirdparty/glog/glog-0.3.4/src/stacktrace_x86_64-inl.h)9
-rw-r--r--thirdparty/glog/glog-0.3.5/src/stl_logging_unittest.cc (renamed from thirdparty/glog/glog-0.3.4/src/stl_logging_unittest.cc)9
-rw-r--r--thirdparty/glog/glog-0.3.5/src/symbolize.cc (renamed from thirdparty/glog/glog-0.3.4/src/symbolize.cc)37
-rw-r--r--thirdparty/glog/glog-0.3.5/src/symbolize.h (renamed from thirdparty/glog/glog-0.3.4/src/symbolize.h)0
-rw-r--r--thirdparty/glog/glog-0.3.5/src/symbolize_unittest.cc (renamed from thirdparty/glog/glog-0.3.4/src/symbolize_unittest.cc)5
-rw-r--r--thirdparty/glog/glog-0.3.5/src/utilities.cc (renamed from thirdparty/glog/glog-0.3.4/src/utilities.cc)46
-rw-r--r--thirdparty/glog/glog-0.3.5/src/utilities.h (renamed from thirdparty/glog/glog-0.3.4/src/utilities.h)8
-rw-r--r--thirdparty/glog/glog-0.3.5/src/utilities_unittest.cc (renamed from thirdparty/glog/glog-0.3.4/src/utilities_unittest.cc)6
-rw-r--r--thirdparty/glog/glog-0.3.5/src/vlog_is_on.cc (renamed from thirdparty/glog/glog-0.3.4/src/vlog_is_on.cc)53
-rw-r--r--thirdparty/glog/glog-0.3.5/src/windows/config.h (renamed from thirdparty/glog/glog-0.3.4/src/windows/config.h)0
-rw-r--r--thirdparty/glog/glog-0.3.5/src/windows/glog/log_severity.h (renamed from thirdparty/glog/glog-0.3.4/src/windows/glog/log_severity.h)0
-rw-r--r--thirdparty/glog/glog-0.3.5/src/windows/glog/logging.h (renamed from thirdparty/glog/glog-0.3.4/src/windows/glog/logging.h)106
-rw-r--r--thirdparty/glog/glog-0.3.5/src/windows/glog/raw_logging.h (renamed from thirdparty/glog/glog-0.3.4/src/windows/glog/raw_logging.h)0
-rw-r--r--thirdparty/glog/glog-0.3.5/src/windows/glog/stl_logging.h (renamed from thirdparty/glog/glog-0.3.4/src/windows/glog/stl_logging.h)0
-rw-r--r--thirdparty/glog/glog-0.3.5/src/windows/glog/vlog_is_on.h (renamed from thirdparty/glog/glog-0.3.4/src/windows/glog/vlog_is_on.h)0
-rw-r--r--thirdparty/glog/glog-0.3.5/src/windows/port.cc (renamed from thirdparty/glog/glog-0.3.4/src/windows/port.cc)9
-rw-r--r--thirdparty/glog/glog-0.3.5/src/windows/port.h (renamed from thirdparty/glog/glog-0.3.4/src/windows/port.h)10
-rw-r--r--thirdparty/glog/glog-0.3.5/src/windows/preprocess.sh (renamed from thirdparty/glog/glog-0.3.4/src/windows/preprocess.sh)2
-rw-r--r--thirdparty/glog/glog-0.3.5/test-driver1
-rw-r--r--thirdparty/glog/glog-0.3.5/vsprojects/libglog/libglog.vcproj (renamed from thirdparty/glog/glog-0.3.4/vsprojects/libglog/libglog.vcproj)498
-rw-r--r--thirdparty/glog/glog-0.3.5/vsprojects/libglog_static/libglog_static.vcproj (renamed from thirdparty/glog/glog-0.3.4/vsprojects/libglog_static/libglog_static.vcproj)440
-rw-r--r--thirdparty/glog/glog-0.3.5/vsprojects/logging_unittest/logging_unittest.vcproj (renamed from thirdparty/glog/glog-0.3.4/vsprojects/logging_unittest/logging_unittest.vcproj)386
-rw-r--r--thirdparty/glog/glog-0.3.5/vsprojects/logging_unittest_static/logging_unittest_static.vcproj (renamed from thirdparty/glog/glog-0.3.4/vsprojects/logging_unittest_static/logging_unittest_static.vcproj)364
620 files changed, 83298 insertions, 82635 deletions
diff --git a/.gitignore b/.gitignore
index 21902dc..2805e9f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,44 +1,14 @@
-#ignoring the changes in sub folders of release folder
-/release/bin/
-/release/lib64/
-/release/include/
-/release/include/common/
-/release/include/generic/
-/release/include/*.h
-!/release/include/declare_syscalls.h
-!/release/include/nsocket_dmm_api.h
+#ignore file with suffix .bak
+*.bak
#ignoring the changes in sub folders of build folder
-/build/app_example/
-/build/CMakeFiles/
-/build/GLOG-prefix/
-/build/JSON-prefix/
-/build/clean_compile.sh
-/build/cmake_install.cmake
-/build/CMakeCache.txt
-/build/libdmm_api.a
-/build/libglog.a
-/build/libjson-c.a
-/build/Makefile
-/build/post_compile.sh
-/build/src/
-/build/stacks/
-/build/thirdparty/
-/build/libnStackMaintain.a
-/build/libsocket.a
-/stacks/lwip_stack/lwip_src/lwip-2.0.3.zip
-/stacks/lwip_stack/lwip_src/lwip/
-/stacks/lwip_stack/build/
-/stacks/lwip_stack/release/
-/scripts/checkstyle.sh
-/stacks/lwip_stack/release/bin/
-/stacks/lwip_stack/release/script/
-/stacks/lwip_stack/src/include/
-!/stacks/lwip_stack/src/include/nsfw_msg_api.h
-!/stacks/lwip_stack/src/include/nsfw_msg.h
-!/stacks/lwip_stack/src/include/nsfw_mt_config.h
-!/stacks/lwip_stack/src/include/nsfw_rti.h
+build/
+
#ignoring the changes in sub folders of thirdparty folder
-/thirdparty/
-/thirdparty/glog/glog-0.3.4/compile/
-/thirdparty/glog/glog-0.3.4/m4/
+thirdparty/
+
+#ignoring the changes in sub folders of release folder
+release/
+
+#ignoring the changes in sub folders of platform folder
+platform/
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2f5e9f0..e199873 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,13 +14,11 @@
# limitations under the License.
#########################################################################
-
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11)
PROJECT(nStack)
option(RMWS "automatically remove trailing whitespace using git pre-commit hook" OFF)
-option(WITH_SECUREC_LIB "Option description" OFF)
-option(WITH_HAL_LIB "Option description" OFF)
+OPTION(SYSTEMC_LIB "Use system provided C library instead of secure C library" ON)
SET(CMAKE_C_COMPILER "gcc")
SET(EXECUTABLE_PATH ${CMAKE_CURRENT_LIST_DIR}/release/bin)
@@ -29,26 +27,19 @@ SET(LIB_PATH_SHARED ${CMAKE_CURRENT_LIST_DIR}/release/lib64)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIB_PATH_STATIC})
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_PATH})
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIB_PATH_SHARED})
-SET(DMM_DPDK_INSTALL_DIR "" CACHE STRING "to get the dpdk install path by cmd")
+SET(OLD_DPDK_PATH ${CMAKE_CURRENT_LIST_DIR}/src/framework/common/base/librtp-*)
SET(DMM_REL_INC_DIR ${CMAKE_CURRENT_LIST_DIR}/release/include)
SET(DMM_ARCH x86)
-SET(GENERATE_RPM_PATH ${CMAKE_CURRENT_LIST_DIR}/release/rpm)
-file(MAKE_DIRECTORY ${GENERATE_RPM_PATH})
-
-SET(GENERATE_DEB_PATH ${CMAKE_CURRENT_LIST_DIR}/release/deb)
-file(MAKE_DIRECTORY ${GENERATE_DEB_PATH})
+if(SYSTEMC_LIB)
+ ADD_DEFINITIONS(-DSYSTEMC_LIB)
+endif()
MESSAGE(STATUS "Top dir is: " ${CMAKE_CURRENT_LIST_DIR})
MESSAGE(STATUS "Static library dir: " ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
MESSAGE(STATUS "Executable binary dir: " ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
MESSAGE(STATUS "Shared library dir: " ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
-
-add_custom_target(clean-cmake-files
- COMMAND ${CMAKE_COMMAND} -P clean-all.cmake
-)
-
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
message(STATUS "Setting git commit template...")
execute_process(COMMAND git config --local commit.template ${CMAKE_SOURCE_DIR}/scripts/git/commit-msg-template
@@ -96,63 +87,40 @@ if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
endif()
endif()
-if(WITH_SECUREC_LIB)
- add_definitions(-DSECUREC_LIB)
-endif()
-
-if(WITH_HAL_LIB)
- add_definitions(-DHAL_LIB)
-endif()
-
SET(post_compile "${PROJECT_BINARY_DIR}/post_compile.sh")
FILE(WRITE ${post_compile} "#!/bin/bash\n")
-if(WITH_HAL_LIB)
-else()
FILE(APPEND ${post_compile}
"
-cp -f ${CMAKE_CURRENT_LIST_DIR}/src/nSocket/include/nstack_dmm_api.h ${CMAKE_CURRENT_LIST_DIR}/release/include/
-cp -f ${CMAKE_CURRENT_LIST_DIR}/src/adapt/nstack_dmm_adpt.h ${CMAKE_CURRENT_LIST_DIR}/release/include/
-cp -f ${CMAKE_CURRENT_LIST_DIR}/src/adapt/nstack_share_res.h ${CMAKE_CURRENT_LIST_DIR}/release/include/
-cp -f ${CMAKE_CURRENT_LIST_DIR}/src/nSocket/include/declare_syscalls.h ${CMAKE_CURRENT_LIST_DIR}/release/include/
-cp -f ${CMAKE_CURRENT_LIST_DIR}/src/framework/include/* ${CMAKE_CURRENT_LIST_DIR}/release/include/
-cp -rf ${CMAKE_CURRENT_LIST_DIR}/src/framework/common/base/include/*.h ${CMAKE_CURRENT_LIST_DIR}/release/include/
-cp -rf ${CMAKE_CURRENT_LIST_DIR}/src/framework/common/base/include/common/* ${CMAKE_CURRENT_LIST_DIR}/release/include/
-
-cp -f ${CMAKE_CURRENT_LIST_DIR}/src/framework/common/include/*.h ${CMAKE_CURRENT_LIST_DIR}/release/include/
-cp -rf ${CMAKE_CURRENT_LIST_DIR}/src/framework/common/include/generic ${CMAKE_CURRENT_LIST_DIR}/release/include/
-cp -f ${CMAKE_CURRENT_LIST_DIR}/src/framework/common/include/arch/${DMM_ARCH}/* ${CMAKE_CURRENT_LIST_DIR}/release/include/
-cp -f ${CMAKE_CURRENT_LIST_DIR}/src/framework/ipc/mgr_com/mgr_com.h ${CMAKE_CURRENT_LIST_DIR}/release/include/
-cp -f ${CMAKE_CURRENT_LIST_DIR}/src/framework/hal/hal.h ${CMAKE_CURRENT_LIST_DIR}/release/include/
-cp -f ${CMAKE_CURRENT_LIST_DIR}/src/nSocket/include/nstack_dmm_api.h ${CMAKE_CURRENT_LIST_DIR}/release/include/
+rm -rf ${OLD_DPDK_PATH};
+
+cp -f ${CMAKE_CURRENT_LIST_DIR}/src/include/*.h ${CMAKE_CURRENT_LIST_DIR}/release/include/
+mkdir ${CMAKE_CURRENT_LIST_DIR}/release/include/glog/
+cp -f ${CMAKE_CURRENT_LIST_DIR}/thirdparty/glog/glog-0.3.5/src/glog/nstack_glog.ph ${CMAKE_CURRENT_LIST_DIR}/release/include/glog/
+cp -f ${CMAKE_CURRENT_LIST_DIR}/thirdparty/glog/glog-0.3.5/src/glog/nstack_glog_in.h ${CMAKE_CURRENT_LIST_DIR}/release/include/glog/
echo post compile process success.
"
)
-endif()
+
+ADD_CUSTOM_TARGET(DPDK ALL COMMAND sh post_compile.sh)
SET(clean_compile "${PROJECT_BINARY_DIR}/clean_compile.sh")
FILE(WRITE ${clean_compile} "#!/bin/bash\n")
FILE(APPEND ${clean_compile}
"
-rm -rf ${CMAKE_CURRENT_LIST_DIR}/release/include/*.h
-rm -rf ${CMAKE_CURRENT_LIST_DIR}/release/include/generic
-rm -rf ${CMAKE_CURRENT_LIST_DIR}/release/lib64/libdmm_api.so
+rm -rf ${CMAKE_CURRENT_LIST_DIR}/release/lib64/libsecurec.so
echo post clean process success.
"
)
-
-ADD_CUSTOM_TARGET(DPDK ALL COMMAND sh post_compile.sh)
-ADD_DEPENDENCIES(DPDK dmm_api)
-
ADD_CUSTOM_TARGET(pkg-rpm COMMAND sh ../scripts/generate_dmm_rpm.sh)
ADD_CUSTOM_TARGET(pkg-deb COMMAND sh ../scripts/generate_dmm_deb.sh)
-
-ADD_CUSTOM_TARGET(vpp-stack COMMAND sh ../scripts/build_vpp.sh)
+ADD_CUSTOM_TARGET(vpp-stack
+COMMAND cp -f ${CMAKE_CURRENT_LIST_DIR}/src/include/declare_syscalls.h.tmpl ${CMAKE_CURRENT_LIST_DIR}/release/include/
+COMMAND sh ../scripts/build_vpp.sh)
ADD_DEPENDENCIES(vpp-stack DPDK)
-
ADD_CUSTOM_TARGET(checkstyle
COMMAND bash ${CMAKE_CURRENT_LIST_DIR}/scripts/checkstyle.sh -c)
ADD_CUSTOM_TARGET(fixstyle
@@ -182,34 +150,30 @@ ExternalProject_Add(
INSTALL_COMMAND cp -f .libs/libjson-c.a ${LIB_PATH_STATIC}/
)
-SET(SECUREC_SRC ${CMAKE_CURRENT_LIST_DIR}/thirdparty/SecureC/src)
-SET(SECUREC_SRC_H ${CMAKE_CURRENT_LIST_DIR}/thirdparty/SecureC/include)
-
-if(WITH_SECUREC_LIB)
-INCLUDE(ExternalProject)
-ExternalProject_Add(
- SECUREC
- SOURCE_DIR ${SECUREC_SRC}
- BUILD_IN_SOURCE 1
- CONFIGURE_COMMAND ""
- BUILD_COMMAND COMMAND make -j 8
- INSTALL_COMMAND cp -f ${SECUREC_SRC}/../lib/libsecurec.so ${LIB_PATH_SHARED}/
-)
+if(NOT SYSTEMC_LIB)
+ SET(SECUREC_SRC ${CMAKE_CURRENT_LIST_DIR}/thirdparty/SecureC/src)
+ INCLUDE(ExternalProject)
+ ExternalProject_Add(
+ SECUREC
+ SOURCE_DIR ${SECUREC_SRC}
+ BUILD_IN_SOURCE 1
+ CONFIGURE_COMMAND ""
+ BUILD_COMMAND COMMAND make -j 8
+ INSTALL_COMMAND cp -f ${SECUREC_SRC}/../lib/libsecurec.so ${LIB_PATH_SHARED}/
+ )
endif()
-SET(GLOG_SRC ${CMAKE_CURRENT_LIST_DIR}/thirdparty/glog/glog-0.3.4)
+SET(GLOG_SRC ${CMAKE_CURRENT_LIST_DIR}/thirdparty/glog/glog-0.3.5)
INCLUDE(ExternalProject)
ExternalProject_Add(
- GLOG
- SOURCE_DIR ${GLOG_SRC}
- BUILD_IN_SOURCE 1
- CONFIGURE_COMMAND autoreconf -ivf COMMAND sh configure CFLAGS=-fPIC CXXFLAGS=-fPIC
- BUILD_COMMAND COMMAND make -j 8
- INSTALL_COMMAND cp -f ${GLOG_SRC}/.libs/libglog.a ${LIB_PATH_STATIC}/
+ GLOG
+ SOURCE_DIR ${GLOG_SRC}
+ BUILD_IN_SOURCE 1
+ CONFIGURE_COMMAND autoreconf COMMAND sh configure CFLAGS=-fPIC CXXFLAGS=-fPIC
+ BUILD_COMMAND COMMAND make
+ INSTALL_COMMAND cp -f ${GLOG_SRC}/.libs/libglog.a ${LIB_PATH_STATIC}/
)
ADD_SUBDIRECTORY(src)
-ADD_SUBDIRECTORY(app_example)
-
-ADD_SUBDIRECTORY(stacks/rsocket)
ADD_SUBDIRECTORY(thirdparty/apps)
+ADD_SUBDIRECTORY(stacks/rsocket)
diff --git a/README.md b/README.md
deleted file mode 100644
index 688161e..0000000
--- a/README.md
+++ /dev/null
@@ -1,49 +0,0 @@
-# 1. Introduction
-
-![nStack_Architecture](resources/nStack_Architecture.png "nStack_Architecture")
-
-DMM (Dual Mode, Multi-protocol, Multi-instance) is a framework between applications
-and transport layer of networking stack. This framework can host different types of
-networking stack instances operating on different domains (kernel/user-space) with
-different protocol suites (TCP/IP, RDMA, or others). Application can use different type of
-protocol stack implementations based on functional/performance requirements.
-
-# 2. History
-Emerging applications are bringing extremely high-performance requirements to the
-network system. Eg. AR/VR, IOT etc. And many of them come with their unique demand
-of QOS/SLA. Some applications need low latency network, some need high reliability etc.
-Though such performance targets should be required for the complete communication system,
-the transport layer protocols play a key role and there are relatively bigger challenges,
-because traditionally the TCP-based transport layer exploits the “best-effort†principle
-and provides no performance guarantees by its nature. However, as Internet applications rapidly
-grow and diversify, all-powerful or one-fits-all protocol or algorithm become less feasible.
-Thus, the traditional single-instance TCP-based network stack bears great challenges when
-serving many applications with different QoS/SLA requirements simultaneously on the
-same platform. Also moving the networking stack out of the kernel is an obvious trend in both
-the industry and literature. Technologies, e.g. DPDK, improve performance of network
-stack, by bypassing the kernel, avoiding context-switching and data copies, as well as providing
-a complete set of packet-processing acceleration libraries. Keeping above trends in mind,the
-DMM/nStack provides a framework where, system operators can plug in dedicated types of
-networking stack instances according to performance and/or functional requirements from
-the user space applications. Application doesn't have to worry about change their transport
-layer API. A lightweight nStack management daemon is responsible for maintaining the stack
-instances and the app/socket-to-stack-mappings, which are provided via the orchestration
-/management interface. So DMM provide a framework which can hide all the complexity of
-different transport layer protocol and also provide the flexibility to choose a protocol stack
-from manybased on functional/performance requirements.
-# 3. Quick Start
- * [Refer doc/Build_DMM.md.](https://git.fd.io/dmm/plain/doc/Build_DMM.md)
-
-# 4. Involved
- * [Bi-Weekly DMM Metting.](https://wiki.fd.io/view/DMM/Meettng)
- * [Join the DMM Mailing List.](https://lists.fd.io/g/dmm-dev)
- * [Join fdio-dmm IRC channel.](https://wiki.fd.io/view/IRC)
- * [Browse the code.](https://git.fd.io/dmm/tree/)
- * [18.10 Release Plan](https://wiki.fd.io/view/Projects/dmm/Release_Plans/Release_Plan_18.10)
-
-# 5. More Information
-- https://wiki.fd.io/view/DMM
-- https://wiki.fd.io/view/Project_Proposals/DMM
-- Enabling “Protocol Routingâ€: Revisiting Transport Layer Protocol Design in Internet
-Communications(http://ieeexplore.ieee.org/document/8114687/)
-
diff --git a/RELEASE.md b/RELEASE.md
deleted file mode 100644
index c678b3e..0000000
--- a/RELEASE.md
+++ /dev/null
@@ -1,34 +0,0 @@
-# Release Notes {#release_notes}
-
-* @subpage release_notes_1807
-* @subpage release_notes_1804
-
-@page release_notes_1807 Release notes for DMM 18.07
-
-TBD
-
-@page release_notes_1804 Release notes for VPP 18.04
-
-
-## Features
-- Initial commit
-- nsocket API support
-- nstack plugin
-- DPDK HAL
-- Kernel mode stack support
-- Sample APP (app_example)
-- Blackbox CI
-- Supported documents(doc)
-
-## Known issues
-
-For the full list of issues please refer to FD.io/DMM [JIRA](https://jira.fd.io/projects/DMM/issues/?filter=allopenissues).
-
-## Issues fixed
-
-For the full list of fixed issues please refer to:
-- FD.io/DMM [JIRA](https://jira.fd.io/projects/DMM/issues/?filter=allopenissues)
-- git [commit log](https://git.fd.io/dmm/)
-
-## API changes
-None
diff --git a/app_example/func-test/file_transfer/client_filetrans.c b/app_example/func-test/file_transfer/client_filetrans.c
deleted file mode 100644
index cc8386d..0000000
--- a/app_example/func-test/file_transfer/client_filetrans.c
+++ /dev/null
@@ -1,284 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <fcntl.h>
-#include <netdb.h>
-#include <ctype.h>
-char *END_FLAG = "=================END";
-#define HEXCONVERT_COLS 8
-#define HEX_CONVERT 1
-//#define DEBUG 1
-#define out(fmt, arg...) (void)printf(fmt, ##arg)
-
-#ifdef DEBUG
-#define DBG(fmt, arg...) do { \
- out("[Debug] " fmt, ##arg); \
- } while (0)
-#else
-#define DBG(fmt, arg...) ((void)0)
-#endif
-
-void
-error (const char *msg)
-{
- perror (msg);
- out
- ("./client_tcp [server_ip_address] [port number] [filename] [client_ip_address]\n");
- exit (1);
-}
-
-#if defined(HEX_CONVERT) && defined(DEBUG)
-void
-hexconvert (void *mem, unsigned int len)
-{
- unsigned int i;
-
- for (i = 0;
- i <
- len +
- ((len % HEXCONVERT_COLS) ? (HEXCONVERT_COLS -
- len % HEXCONVERT_COLS) : 0); i++)
- {
- /* print offset */
- if (i % HEXCONVERT_COLS == 0)
- {
- DBG ("\n0x%06x: ", i);
- }
-
- /*print hex data */
- if (i < len)
- {
- DBG ("%02x ", 0xFF & ((char *) mem)[i]);
- }
- else /* end of block, just aligning for ASCII dump */
- {
- DBG ("\n");
- }
- }
-}
-#endif
-
-void
-tcp (char **pArgv)
-{
-
- int sockfd, portno;
- char buff[1024];
-
- struct sockaddr_in serv_addr, cli_addr;
- struct hostent *server;
-
- sockfd = socket (AF_INET, SOCK_STREAM, 0);
- if (sockfd < 0)
- {
- error ("error in socket creation\n");
- }
- out ("socket create successful\n");
-
- portno = atoi (pArgv[2]);
- server = gethostbyname (pArgv[1]);
-
- if (server == NULL)
- {
- fprintf (stderr, "error no such host\n");
- }
-
- bzero ((char *) &serv_addr, sizeof (serv_addr));
- serv_addr.sin_family = AF_INET;
- bcopy ((char *) server->h_addr, (char *) &serv_addr.sin_addr,
- server->h_length);
- serv_addr.sin_port = htons (portno);
- bzero ((char *) &cli_addr, sizeof (serv_addr));
-
- cli_addr.sin_family = AF_INET;
- cli_addr.sin_addr.s_addr = inet_addr (pArgv[4]);
- cli_addr.sin_port = htons (portno);
- if (bind (sockfd, (struct sockaddr *) &cli_addr, sizeof (cli_addr)) < 0)
- {
- error ("bind fail");
- }
- out ("Bind successful\n");
-
- if (connect (sockfd, (struct sockaddr *) &serv_addr, sizeof (serv_addr)) <
- 0)
- {
- error ("connection fail");
- }
- out ("connection done\n");
-
- FILE *file;
- int filebyte = 0;
- int lsize, totalsize = 0;
-
- file = fopen (pArgv[3], "r");
- fseek (file, 0, SEEK_END);
- lsize = ftell (file);
- rewind (file);
- out ("Name of file: %s, Size of file : %d\n", pArgv[3], lsize);
- if (write (sockfd, &lsize, sizeof (int)) == -1)
- {
- out ("error executing write\n");
- }
- if (write (sockfd, pArgv[3], 255) == -1)
- {
- out ("error executing write\n");
- }
- while (lsize > totalsize)
- {
- bzero (buff, 1024);
- fseek (file, totalsize, SEEK_SET);
- filebyte = fread (buff, 1, sizeof (buff), file);
- if (filebyte == 0)
- {
- printf ("file End of file\n");
- break;
- }
-
- if (filebyte < 0)
- error ("error in reading file. \n");
-#if defined(HEX_CONVERT) && defined(DEBUG)
- DBG ("=========================================\n");
- hexconvert (buff, filebyte);
- DBG ("=========================================\n");
-#endif
-
- void *p = buff;
- totalsize += filebyte;
-
- while (filebyte > 0)
- {
-#ifdef DEBUG
- DBG ("=========================================\n");
- puts ((const char *) p);
- DBG ("=========================================\n");
-#endif
- int bytes_written = write (sockfd, p, filebyte);
- if (bytes_written <= 0)
- {
- error ("error in Socket write.\n");
- }
-
- filebyte -= bytes_written;
- p += bytes_written;
-//#if DEBUG
- DBG
- ("Total size of file = %d, Total Bytes sent to socket = %d, bytes_written in each step = %d\n",
- lsize, totalsize, bytes_written);
-//#endif
- }
- }
- out ("file has been sent successfully\n");
- out ("Final Total size of file = %d, Total Bytes sent to socket = %d\n",
- lsize, totalsize);
-
- fclose (file);
- sleep (60);
- close (sockfd);
- return;
-}
-
-void
-udp (char **pArgv)
-{
- int sockfd, n, fd, sz, portno, MAXLINE;
- FILE *fp;
- struct sockaddr_in servaddr, cliaddr;
- char *buf;
- char *target, *path;
- portno = atoi (pArgv[2]);
- bzero (&servaddr, sizeof (servaddr));
- servaddr.sin_family = AF_INET;
- servaddr.sin_port = htons (portno);
- servaddr.sin_addr.s_addr = inet_addr (pArgv[1]);
- bzero (&cliaddr, sizeof (servaddr));
- cliaddr.sin_family = AF_INET;
- cliaddr.sin_port = htons (portno);
- cliaddr.sin_addr.s_addr = inet_addr (pArgv[3]);
- sockfd = socket (AF_INET, SOCK_DGRAM, 0);
- if (sockfd < 0)
- {
- out ("error in socket creation\n");
- }
- out ("socket create successful\n");
-
- if (bind (sockfd, (struct sockaddr *) &cliaddr, sizeof (cliaddr)) < 0)
- {
- out ("bind fail");
- }
- out ("Bind successful\n");
-
- path = pArgv[4];
- target = pArgv[5];
- MAXLINE = atoi (pArgv[6]);
- buf = malloc (MAXLINE * sizeof (int));
- fp = fopen (path, "r");
- fseek (fp, 0L, SEEK_END);
- sz = ftell (fp);
- out ("The size of the path file is %d", sz);
- sendto (sockfd, target, strlen (target), 0,
- (struct sockaddr *) &servaddr, sizeof (servaddr));
- n = recvfrom (sockfd, buf, MAXLINE, 0, NULL, NULL);
- if (!strncmp (buf, "ok", 2))
- {
- out ("Filename sent.\n");
- }
-
- fd = open (path, O_RDONLY);
- while ((n = read (fd, buf, MAXLINE)) > 0)
- {
- sendto (sockfd, buf, n, 0, (struct sockaddr *) &servaddr,
- sizeof (servaddr));
- }
- sendto (sockfd, END_FLAG, strlen (END_FLAG), 0,
- (struct sockaddr *) &servaddr, sizeof (servaddr));
- fclose (fp);
- sleep (60);
- close (sockfd);
- return;
-}
-
-int
-main (int argc, char *argv[])
-{
- int i;
- char **pArgv, str[10];
- pArgv = (char **) malloc (sizeof (char *) * 10);
- for (i = 0; i < 10; i++)
- {
- pArgv[i] = (char *) malloc (sizeof (char) * 20);
- }
- printf ("%s", argv[1]);
-
- if (strcmp ("tcp", argv[1]) == 0)
- {
- strcpy (pArgv[0], "tcp");
- printf ("pArgv[0]=%s", pArgv[0]);
- /* The arguments of tcp are [server_ip_address] [port number] [filename] [client_ip_address] */
- for (i = 1; i < 5; i++)
- {
- strcpy (pArgv[i], argv[i + 1]);
- }
- tcp (pArgv);
- }
-
- else
- {
- strcpy (str, argv[1]);
- if (strcmp ("udp", str) == 0)
- {
- strcpy (pArgv[0], "udp");
- printf ("pArgv[0]=%s", pArgv[0]);
- /* The arguments of udp are [server_ip_address] [port number] [client_ip_address] [filename] [target_filename] [MAX_BUFFER_LENGTH] */
- for (i = 1; i < 7; i++)
- {
- strcpy (pArgv[i], argv[i + 1]);
- }
- udp (pArgv);
- }
- }
- return 0;
-}
diff --git a/app_example/func-test/file_transfer/server_filetrans.c b/app_example/func-test/file_transfer/server_filetrans.c
deleted file mode 100644
index 9463c70..0000000
--- a/app_example/func-test/file_transfer/server_filetrans.c
+++ /dev/null
@@ -1,344 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <ctype.h>
-#include <arpa/inet.h>
-#include <fcntl.h>
-char *END_FLAG = "=================END";
-#define HEXCONVERT_COLS 8
-#define HEX_CONVERT 1
-//#define DEBUG 1
-#define out(fmt, arg...) (void)printf(fmt, ##arg)
-
-#ifdef DEBUG
-#define DBG(fmt, arg...) do { \
- out("[Debug] " fmt, ##arg); \
- } while (0)
-#else
-#define DBG(fmt, arg...) ((void)0)
-#endif
-
-void
-error (const char *msg)
-{
- perror (msg);
- out ("./server_tcp [server_ip_address] [port number]\n");
- exit (1);
-}
-
-#if defined(HEX_CONVERT) && defined(DEBUG)
-void
-hexconvert (void *mem, unsigned int len)
-{
- unsigned int i;
-
- for (i = 0;
- i <
- len +
- ((len % HEXCONVERT_COLS) ? (HEXCONVERT_COLS -
- len % HEXCONVERT_COLS) : 0); i++)
- {
- /* print offset */
- if (i % HEXCONVERT_COLS == 0)
- {
- DBG ("\n0x%06x: ", i);
- }
-
- /*print hex data */
- if (i < len)
- {
- DBG ("%02x ", 0xFF & ((char *) mem)[i]);
- }
- else /* end of block, just aligning for ASCII dump */
- {
- DBG ("\n");
- }
- }
-}
-#endif
-int
-compareFiles (FILE * fp1, FILE * fp2)
-{
-
- char ch1 = getc (fp1);
- char ch2 = getc (fp2);
- int error = 0, pos = 0, line = 1;
-
- while (ch1 != EOF && ch2 != EOF)
- {
- pos++;
- if (ch1 == '\n' && ch2 == '\n')
- {
- line++;
- pos = 0;
- }
-
- if (ch1 != ch2)
- {
- error++;
- DBG ("Line Number : %d \tError" " Position :%d \n", line, pos);
- }
-
- ch1 = getc (fp1);
- ch2 = getc (fp2);
- }
-
- //printf("Total Errors : %d\t", error);
- return error;
-}
-
-void
-tcp (char **pArgv)
-{
-
- int sockfd, newsockfd, portno;
- char buff[1024], filename[255];
-
- struct sockaddr_in serv_addr, cli_addr;
- socklen_t clilen;
-
- sockfd = socket (AF_INET, SOCK_STREAM, 0);
- if (sockfd < 0)
- {
- error ("error in socket creation");
- }
- out ("socket create successful\n");
-
- bzero ((char *) &serv_addr, sizeof (serv_addr));
- portno = atoi (pArgv[2]);
-
- serv_addr.sin_family = AF_INET;
- serv_addr.sin_addr.s_addr = inet_addr (pArgv[1]);
- serv_addr.sin_port = htons (portno);
-
- if (bind (sockfd, (struct sockaddr *) &serv_addr, sizeof (serv_addr)) < 0)
- {
- error ("bind fail");
- }
- out ("Bind successful\n");
- listen (sockfd, 5);
- clilen = sizeof (cli_addr);
-
- newsockfd = accept (sockfd, (struct sockaddr *) &cli_addr, &clilen);
- if (newsockfd < 0)
- {
- error ("error in accept");
- }
- out ("socket accept succesful\n");
- bzero (buff, 1024);
-
- FILE *fp;
- int lSize = 0, totallSize = 0;
-
- bzero (filename, 255);
-
- fclose (fopen ("receive_file.txt", "w"));
- if (system ("chmod +x *") == -1)
- {
- out (" incorrect use of system\n");
- }
- fp = fopen ("receive_file.txt", "a");
-
- if (read (newsockfd, &lSize, sizeof (int)) == -1)
- {
- out ("error executing read\n");
- }
- if (read (newsockfd, filename, sizeof (filename)) == -1)
- {
- out ("error executing read\n");
- }
-
- while (lSize > totallSize)
- {
- int bytes_read = 0;
- bzero (buff, 1024);
-
- bytes_read = read (newsockfd, buff, 1024);
-
- if (bytes_read == 0)
- {
- break;
- }
-
- if (bytes_read < 0)
- {
- error ("error in Socket read.\n");
- }
-
-#if defined(HEX_CONVERT) && defined(DEBUG)
- DBG ("=========================================\n");
- hexconvert (buff, bytes_read);
- DBG ("=========================================\n");
-#endif
-#ifdef DEBUG
- DBG ("=========================================\n");
- puts ((const char *) buff);
- DBG ("=========================================\n");
-#endif
- totallSize += bytes_read;
-
- if (fwrite (buff, 1, bytes_read, fp) == -1)
- {
- error ("error in file write\n");
- }
-//#if DEBUG
- DBG
- ("Total size of file = %d, Total Bytes sent to socket = %d, bytes_read in each step = %d\n",
- lSize, totallSize, bytes_read);
-//#endif
- }
- out ("file name = %s\n", filename);
- out ("Final total size of file = %d, total read from socket = %d\n", lSize,
- totallSize);
- out ("copy complete\n");
- fclose (fp);
-
- FILE *fp1 = fopen ("receive_file.txt", "r");
- FILE *fp2 = fopen (filename, "r");
-
- fseek (fp2, 0L, SEEK_END);
- int lfile_size = ftell (fp2);
- rewind (fp2);
- if (lfile_size != lSize)
- {
- out ("Size unmatch...\n");
- }
- else
- {
- out ("Size match...\n");
- }
-
- if (compareFiles (fp1, fp2) > 0)
- {
- out ("file unmatch...\n");
- }
- else
- {
- out ("file match...\n");
- }
-
- close (newsockfd);
- close (sockfd);
- return;
-}
-
-void
-run (int sockfd, struct sockaddr *cliaddr, socklen_t clilen, char *res_buf,
- int MAXLINE)
-{
- int n, fd;
- socklen_t len;
- char *buf, *buf2;
- FILE *fp1, *fp2;
- buf = malloc (MAXLINE + 1);
- len = clilen;
- n = recvfrom (sockfd, buf, MAXLINE, 0, cliaddr, &len);
- buf[n] = 0;
- out ("Received from client:[%s] \n", buf);
- buf2 = malloc (MAXLINE);
- strcpy (buf2, buf);
- sendto (sockfd, "ok", strlen ("ok"), 0, cliaddr, len);
- fd = open (buf, O_RDWR | O_CREAT, 0666);
- while ((n = recvfrom (sockfd, buf, MAXLINE, 0, cliaddr, &len)))
- {
- buf[n] = 0;
- //out("%s", buf);
- if (!(strcmp (buf, END_FLAG)))
- {
- break;
- }
- if (write (fd, buf, n) == -1)
- {
- out ("error in executing write\n");
- }
- }
- fp1 = fopen (buf2, "r");
- fp2 = fopen (res_buf, "r");
-
- if (compareFiles (fp1, fp2) == 0)
- {
- out ("\nPass:The contents of the files are same");
- }
- else
- {
- out ("\nFail:The contents of the files are different");
- }
- close (fd);
-}
-
-void
-udp (char **pArgv)
-{
- int sockfd, portno, MAXLINE;
- struct sockaddr_in servaddr, cliaddr;
- char *res_buf;
- res_buf = pArgv[3];
-
- portno = atoi (pArgv[2]);
- MAXLINE = atoi (pArgv[4]);
- sockfd = socket (AF_INET, SOCK_DGRAM, 0);
- if (sockfd < 0)
- {
- out ("error in socket creation\n");
- }
- out ("socket create successful\n");
-
- bzero (&servaddr, sizeof (servaddr));
- servaddr.sin_family = AF_INET;
- servaddr.sin_addr.s_addr = inet_addr (pArgv[1]);
- servaddr.sin_port = htons (portno);
-
- if (bind (sockfd, (struct sockaddr *) &servaddr, sizeof (servaddr)) < 0)
- {
- out ("bind fail");
- }
- out ("Binded successfully\n");
- fd_set read_fds;
- FD_ZERO (&read_fds);
- FD_SET (sockfd, &read_fds);
- int fdmax = sockfd;
- if (FD_ISSET (sockfd, &read_fds))
- {
- run (fdmax, (struct sockaddr *) &cliaddr, sizeof (cliaddr), res_buf,
- MAXLINE);
- }
- return;
-}
-
-int
-main (int argc, char *argv[])
-{
- int i, j;
- char **pArgv;
- pArgv = (char **) malloc (sizeof (char *) * 10);
- for (i = 0; i < 10; i++)
- {
- pArgv[i] = (char *) malloc (sizeof (char) * 20);
- }
- if (strcmp ("tcp", argv[1]) == 0)
- {
- strcpy (pArgv[0], "tcp");
- /* The arguments of tcp are [server_ip_address] [port number] */
- for (i = 1; i < 3; i++)
- {
- strcpy (pArgv[i], argv[i + 1]);
- }
- tcp (pArgv);
- }
- else if (strcmp ("udp", argv[1]) == 0)
- {
- strcpy (pArgv[0], "udp");
- /* The arguments of udp are [server_ip_address] [port number] [filename] [MAX_BUFFER_LENGTH] */
- for (i = 1; i < 5; i++)
- {
- strcpy (pArgv[i], argv[i + 1]);
- }
- udp (pArgv);
- }
-
- return 0;
-}
diff --git a/app_example/func-test/fork/tcpclient.c b/app_example/func-test/fork/tcpclient.c
deleted file mode 100644
index 274dcbb..0000000
--- a/app_example/func-test/fork/tcpclient.c
+++ /dev/null
@@ -1,173 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#define DEBUG
-
-#ifdef DEBUG
-#define DBG(fmt, arg...) do { \
- printf(fmt, ##arg); \
-} while(0)
-#else
-#define DBG(fmt, arg...) ((void)0)
-#endif
-
-static struct sockaddr_in g_dest;
-static struct sockaddr_in g_src;
-int srcPort = 0;
-int destPort = 0;
-int times = 0;
-
-void
-random_str (char *str, const int len)
-{
- static const char alphaNum[] =
- "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789";
- int i = 0;
-
- for (i = 0; i < len; i++)
- {
- str[i] = alphaNum[rand () % (sizeof (alphaNum) - 1)];
- }
-
- str[len] = 0;
-}
-
-static void
-setArgsDefault ()
-{
-
- memset (&g_dest, 0, sizeof (g_dest));
- g_dest.sin_family = AF_INET;
- g_dest.sin_addr.s_addr = inet_addr ("127.0.0.1");
- g_dest.sin_port = htons (12345);
- bzero (&(g_dest.sin_zero), 8);
-
- memset (&g_src, 0, sizeof (g_src));
- g_src.sin_family = AF_INET;
- g_src.sin_addr.s_addr = inet_addr ("0.0.0.0");
- g_src.sin_port = htons (7895);
- bzero (&(g_src.sin_zero), 8);
-
- times = 1;
-}
-
-static int
-process_arg (int argc, char *argv[])
-{
- int opt = 0;
- int error = 0;
- const char *optstring = "p:d:s:a:t:";
-
- if (argc < 5)
- {
- DBG
- ("Param info :-p dest_portid; -d dest_serverIP; -a src_portid; -s src_clientIP; -t times; \n");
- return -1;
- }
- setArgsDefault ();
- while ((opt = getopt (argc, argv, optstring)) != -1)
- {
- switch (opt)
- {
- case 'p':
- g_dest.sin_port = htons (atoi (optarg));
- break;
- case 'd':
- g_dest.sin_addr.s_addr = inet_addr (optarg);
- break;
- case 's':
- g_src.sin_addr.s_addr = inet_addr (optarg);
- break;
- case 'a':
- g_src.sin_port = htons (atoi (optarg));
- break;
- case 't':
- times = atoi (optarg);
- break;
- }
- }
- return 0;
-}
-
-int
-main (int argc, char *argv[])
-{
-
- int clientSocket, ret, i;
- char sndbuffer[1024];
- char rcvbuffer[1024];
- int result = 0;
-
- /*
- * check command line arguments
- */
- if (0 != process_arg (argc, argv))
- {
- DBG ("Error in argument.%d\n", argc);
- exit (1);
- }
-
- clientSocket = socket (AF_INET, SOCK_STREAM, 0);
- if (clientSocket < 0)
- {
- DBG ("Error in connection.\n");
- exit (1);
- }
- DBG ("[INFO]Client Socket is created.\n");
-
- ret = bind (clientSocket, (struct sockaddr *) &g_src, sizeof (g_src));
- if (ret < 0)
- {
- DBG ("Error in binding.\n");
- exit (1);
- }
-
- DBG ("[INFO]Bind to client aaddress port 0\n");
-
- ret = connect (clientSocket, (struct sockaddr *) &g_dest, sizeof (g_dest));
- if (ret < 0)
- {
- DBG ("Error in connection.\n");
- exit (1);
- }
- DBG ("[INFO]Connected to Server.\n");
-
- memset (sndbuffer, '\0', 1024 * sizeof (char));
- memset (rcvbuffer, '\0', 1024 * sizeof (char));
-
- for (i = 1; i <= times; i++)
- {
- DBG ("Client: \t");
- random_str (sndbuffer, 50);
- send (clientSocket, sndbuffer, strlen (sndbuffer), 0);
-
- if (recv (clientSocket, rcvbuffer, 1024, 0) < 0)
- {
- DBG ("Error in receiving data.\n");
- }
- else
- {
- DBG ("Server: \t%s\n", rcvbuffer);
- }
- if (0 != strcmp (sndbuffer, rcvbuffer))
- {
- result = -1;
- break;
- }
- }
-
- /* Send exit message to server */
- strcpy (sndbuffer, "#exit");
- send (clientSocket, sndbuffer, strlen (sndbuffer), 0);
-
- DBG ("Result = %s\n", (result == 0) ? "Success" : "Fail");
- close (clientSocket);
- DBG ("Disconnecting from server.\n");
- return 0;
-}
diff --git a/app_example/func-test/fork/tcpserver.c b/app_example/func-test/fork/tcpserver.c
deleted file mode 100644
index 5474c35..0000000
--- a/app_example/func-test/fork/tcpserver.c
+++ /dev/null
@@ -1,161 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <sys/wait.h>
-
-static struct sockaddr_in g_src;
-int srcPort = 0;
-int destPort = 0;
-int times = 0;
-
-#ifdef DEBUG
-#define DBG(fmt, arg...) do { \
- DBG(fmt, ##arg); \
-} while(0)
-#else
-#define DBG(fmt, arg...) ((void)0)
-#endif
-
-static void
-setArgsDefault ()
-{
- memset (&g_src, 0, sizeof (g_src));
- g_src.sin_family = AF_INET;
- g_src.sin_addr.s_addr = inet_addr ("0.0.0.0");
- g_src.sin_port = htons (7895);
- bzero (&(g_src.sin_zero), 8);
-
- times = 1;
-}
-
-static int
-process_arg (int argc, char *argv[])
-{
- int opt = 0;
- int error = 0;
- const char *optstring = "s:a:t:";
-
- if (argc < 5)
- {
- DBG
- ("Param info :-p dest_portid; -d dest_serverIP; -a src_portid; -s src_clientIP; -t times; \n");
- return -1;
- }
- setArgsDefault ();
- while ((opt = getopt (argc, argv, optstring)) != -1)
- {
- switch (opt)
- {
- case 's':
- g_src.sin_addr.s_addr = inet_addr (optarg);
- break;
- case 'a':
- g_src.sin_port = htons (atoi (optarg));
- break;
- case 't':
- times = atoi (optarg);
- break;
- }
- }
- return 0;
-}
-
-int
-main (int argc, char *argv[])
-{
-
- int sockfd, ret;
- int newSocket;
- socklen_t addr_size;
- static struct sockaddr_in accept_addr;
- char buffer[1024];
- pid_t childpid;
-
- /*
- * check command line arguments
- */
- if (0 != process_arg (argc, argv))
- {
- DBG ("Error in argument.%d\n", argc);
- exit (1);
- }
-
- sockfd = socket (AF_INET, SOCK_STREAM, 0);
- if (sockfd < 0)
- {
- DBG ("Error in connection.\n");
- exit (1);
- }
- DBG ("Server Socket is created. %d\n", sockfd);
-
- ret = bind (sockfd, (struct sockaddr *) &g_src, sizeof (g_src));
- if (ret < 0)
- {
- DBG ("Error in binding.\n");
- exit (1);
- }
-
- DBG ("Bind sucess port %d\n", g_src.sin_port);
-
- if (listen (sockfd, 10) == 0)
- {
- DBG ("Listening on %s....\n", inet_ntoa (g_src.sin_addr));
- }
- else
- {
- DBG ("Error in binding.\n");
- }
-
- while (1)
- {
- newSocket =
- accept (sockfd, (struct sockaddr *) &accept_addr, &addr_size);
- if (newSocket < 0)
- {
- DBG ("Error: Exiting here pid %d", getpid ());
- exit (1);
- }
-
- DBG ("Connection accepted from %s:%d fd %d\n",
- inet_ntoa (accept_addr.sin_addr),
- ntohs (accept_addr.sin_port), newSocket);
- if ((childpid = fork ()) == 0)
- {
- DBG ("[ PID %d] Child process Created. Pid %d \r\n", getpid (),
- getpid ());
- DBG ("[ PID %d] Closing fd %d\n", getpid (), sockfd);
- close (sockfd);
-
- while (1)
- {
- memset (buffer, '\0', 1024 * sizeof (char));
- recv (newSocket, buffer, 1024, 0);
- if (strcmp (buffer, "#exit") == 0)
- {
- DBG ("Disconnected from %s:%d\n",
- inet_ntoa (newAddr.sin_addr),
- ntohs (newAddr.sin_port));
- break;
- }
- else
- {
- DBG ("[PID %d]Client: %s\n", getpid (), buffer);
- send (newSocket, buffer, strlen (buffer), 0);
- bzero (buffer, sizeof (buffer));
- }
- }
-
- DBG ("[PID %d]Closing socket %d\r\n", getpid (), newSocket);
- close (newSocket);
- }
-
- }
-
- DBG ("[PID %d]Process exiting... %d\r\n", getpid (), getpid ());
- return 0;
-}
diff --git a/app_example/perf-test/multi_tcp_common_Ser.c b/app_example/perf-test/multi_tcp_common_Ser.c
deleted file mode 100644
index 984052b..0000000
--- a/app_example/perf-test/multi_tcp_common_Ser.c
+++ /dev/null
@@ -1,544 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include <fcntl.h>
-#include <memory.h>
-#include <signal.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <netinet/in.h>
-#include <time.h>
-#include <linux/tcp.h>
-#define __USE_GNU
-#include <sched.h>
-#include <pthread.h>
-#include <arpa/inet.h>
-#include <sys/epoll.h>
-#include <errno.h>
-
-#define _BIND bind
-#define _LISTEN listen
-#define _SOCKET socket
-#define _ACCEPT accept
-#define _SEND send
-#define _RECV recv
-#define _CLOSE close
-#define _CONNECT connect
-#define _PROTOCOL IPPROTO_TCP
-
-#define MAX_TEST_TIME 1000
-#define MSG_LENGTH 256
-#define CORE_NUM 8
-#define START_CPU_ID 2
-#define MAX_CONN_LIMIT 256
-#define MAX_PORT_NUM 65535
-//1:A-B ;0:A-B-A
-#define SEND_RECV_MODE 1
-#define MAX_EVENTS 1000
-#define Default_PortID 12345
-#define Default_SleepCnt 10000
-#define Default_SleepTime 1000000
-#define Flag_Print 1
-#define Fd_Number 1
-
-static struct sockaddr_in g_dest;
-static struct sockaddr_in g_src;
-static struct sockaddr_in g_recv;
-
-int times = MAX_TEST_TIME;
-int msg_length = MSG_LENGTH;
-int coreNum = CORE_NUM;
-int startCPUId = START_CPU_ID;
-int connectNum = MAX_CONN_LIMIT;
-int msgMode = SEND_RECV_MODE;
-int sleepCnt = Default_SleepCnt;
-int sleepTime = Default_SleepTime; //us
-int fdNumber = Fd_Number;
-int flagPrint = Flag_Print;
-int unitPrint = 0;
-int waitTime = 0;
-
-int srcPort = Default_PortID;
-int destPort = 0;
-int recvPort = 0;
-char sendarr[256] = "";
-char recvarr[256] = "";
-char destarr[256] = "";
-
-static void
-setArgsDefault ()
-{
-
- memset (&g_dest, 0, sizeof (g_dest));
- g_dest.sin_family = AF_INET;
- g_dest.sin_addr.s_addr = inet_addr ("127.0.0.1");
- g_dest.sin_port = htons (12345);
- bzero (&(g_dest.sin_zero), 8);
-
- memset (&g_src, 0, sizeof (g_src));
- g_src.sin_family = AF_INET;
- g_src.sin_addr.s_addr = inet_addr ("0.0.0.0");
- g_src.sin_port = htons (7895);
- bzero (&(g_src.sin_zero), 8);
-
- memset (&g_recv, 0, sizeof (g_recv));
- g_recv.sin_family = AF_INET;
- g_recv.sin_addr.s_addr = inet_addr ("0.0.0.0");
- g_recv.sin_port = htons (7895);
- bzero (&(g_recv.sin_zero), 8);
-
-}
-
-static int
-process_arg (int argc, char *argv[])
-{
- int opt = 0;
- int error = 0;
- const char *optstring = "p:d:s:a:l:t:e:i:f:r:n:w:u:x:";
- int rw_mark = 0;
-
- if (argc < 4)
- {
- printf
- ("Param info :-p dest_portid; -d dest_serverIP; -a src_portid; -s src_clientIP; -l msg_length; \n");
- printf
- ("\t-t MAX_TEST_TIME; -i msg_interval ; -f client fd number ; -r receive port; -n connectNum(one server vs n client)\n");
- return 0;
- }
- while ((opt = getopt (argc, argv, optstring)) != -1)
- {
- switch (opt)
- {
- case 'p':
- destPort = atoi (optarg);
- g_dest.sin_port = htons (atoi (optarg));
- break;
- case 'd':
- stpcpy (destarr, optarg);
- g_dest.sin_addr.s_addr = inet_addr (optarg);
- break;
- case 's':
- stpcpy (sendarr, optarg);
- g_src.sin_addr.s_addr = inet_addr (optarg);
- g_recv.sin_addr.s_addr = inet_addr (optarg);
- break;
- case 'a':
- //g_src.sin_port = htons(atoi(optarg));
- srcPort = atoi (optarg);
- break;
- case 'l':
- msg_length = atoi (optarg);
- break;
- case 't':
- times = atoi (optarg);
- break;
- case 'e':
- sleepCnt = atoi (optarg);
- break;
- case 'i':
- sleepTime = atoi (optarg);
- break;
- case 'f':
- fdNumber = atoi (optarg);
- break;
- case 'r':
- recvPort = atoi (optarg);
- g_recv.sin_port = htons (atoi (optarg));
- break;
- case 'n':
- connectNum = atoi (optarg);
- break;
- case 'w':
- waitTime = atoi (optarg);
- break;
- case 'u':
- unitPrint = atoi (optarg);
- break;
- case 'x':
- flagPrint = atoi (optarg);
- break;
-
- }
- }
- return 1;
-}
-
-void
-process_client (void)
-{
- int sendLen = 0;
- int i = 0, t = 0, p = 0, optval = 0, ret = 0;
- char send_buf[1000] = "";
- int c_socketfd[100] = { 0 };
- int errbind[1000] = { 0 };
- int errconn[1000] = { 0 };
-
- int send_count[1000] = { 0 };
- int pps = 0;
- long pps_time = 0;
-
- struct timespec startTime, endTime;
- struct timespec countStart;
- struct timespec countEnd;
-
- memset (&countStart, 0, sizeof (countStart));
- memset (&countEnd, 0, sizeof (countEnd));
-
- for (i = 0; i < fdNumber; i++)
- {
- c_socketfd[i] = _SOCKET (PF_INET, SOCK_STREAM, _PROTOCOL);
- if (0 > c_socketfd[i])
- {
- printf ("client %d failed,err %d\n", i, errno);
- }
- else
- {
- printf ("client %d created success\n", i);
- }
- }
-
- for (i = 0; i < fdNumber; i++)
- {
- optval = 1;
- ret =
- setsockopt (c_socketfd[i], SOL_SOCKET, SO_REUSEADDR, (void *) &optval,
- sizeof (optval));
- if (ret == -1)
- {
- printf ("Couldn't setsockopt(SO_REUSEADDR)\n");
- break;
- }
- }
-
- for (i = 0; i < fdNumber; i++)
- {
- g_src.sin_port = htons (srcPort + i);
- errbind[i] =
- _BIND (c_socketfd[i], (struct sockaddr *) &g_src, sizeof (g_src));
- if (errbind[i] < 0)
- {
- printf ("client %d bind Failed %d\n", i, errno);
- _CLOSE (c_socketfd[i]);
- c_socketfd[i] = -1;
- continue;
- }
- else
- {
- printf ("client %d bind Success port:%d IP:%s\n", i,
- ntohs (g_src.sin_port),
- inet_ntoa (*((struct in_addr *) &(g_src.sin_addr.s_addr))));
- }
- }
- for (i = 0; i < fdNumber; i++)
- {
- if (errbind[i] >= 0)
- {
- errconn[i] =
- _CONNECT (c_socketfd[i], (struct sockaddr *) &g_dest,
- sizeof (g_dest));
- if (errconn[i] < 0)
- {
- printf ("client %d Connect Failed %d\n", i, errno);
- _CLOSE (c_socketfd[i]);
- c_socketfd[i] = -1;
- continue;
- }
- else
- {
- printf ("client %d Connect Success port:%d, IP:%s\n", i,
- ntohs (g_dest.sin_port),
- inet_ntoa (*
- ((struct in_addr *)
- &(g_dest.sin_addr.s_addr))));
- }
- }
- }
-
- sleep (1);
-
- clock_gettime (CLOCK_MONOTONIC, &startTime);
- clock_gettime (CLOCK_MONOTONIC, &countStart);
-
- for (t = 0; t < times; t++)
- {
- for (i = 0; i < fdNumber; i++)
- {
- if (c_socketfd[i] < 0)
- {
- continue;
- }
- do
- {
- sendLen = _SEND (c_socketfd[i], send_buf, msg_length, 0);
- }
- while (sendLen <= 0);
- send_count[i]++;
- }
-
- if (0 != sleepTime)
- {
- if ((t % sleepCnt) == 0)
- {
- usleep (sleepTime);
- }
- }
-
- if ((send_count[0] % unitPrint) == 0)
- {
- clock_gettime (CLOCK_MONOTONIC, &countEnd);
-
- pps_time =
- (countEnd.tv_sec - countStart.tv_sec) * 1000000000 +
- countEnd.tv_nsec - countStart.tv_nsec;
- pps = ((float) 1000000000 / pps_time) * unitPrint * fdNumber;
- if ((flagPrint != 0))
- {
- printf (" sendcount %d, time: %ld ns\n",
- send_count[0] * fdNumber, pps_time);
- }
- printf ("sendcount %d , pps=%d\n", send_count[0] * fdNumber, pps);
- clock_gettime (CLOCK_MONOTONIC, &countStart);
- }
- }
-
- clock_gettime (CLOCK_MONOTONIC, &endTime);
-
- for (i = 0; i < fdNumber; i++)
- {
- printf ("client %d send %d , sendtime :%ld s %ld ns\n", i,
- send_count[i], endTime.tv_sec - startTime.tv_sec,
- endTime.tv_nsec - startTime.tv_nsec);
- }
-
- for (i = 0; i < fdNumber; i++)
- {
- printf ("client %d close!\n", i);
- if (c_socketfd[i] > 0)
- _CLOSE (c_socketfd[i]);
- }
-
- pthread_exit (NULL);
-}
-
-/*
- using this thread to do recv msg;
-*/
-void *
-process_server_msg_thread (void *pArgv)
-{
- int recvLen = 0, recvLen2 = 0;
- char send_buf[1000];
- char recv_buf[1000];
- int recv_count = 0;
- long recv_ppstime = 0;
- int recv_pps = 0;
- int ret;
- struct timespec recvStart;
- struct timespec recvEnd;
- memset (&recvStart, 0, sizeof (recvStart));
- memset (&recvEnd, 0, sizeof (recvEnd));
-
- pthread_detach (pthread_self ());
-
- int msgFd = *(int *) pArgv;
- clock_gettime (CLOCK_MONOTONIC, &recvStart);
- while (recv_count < times)
- {
- recvLen = 0;
- recvLen2 = 0;
- while (1)
- {
- recvLen2 =
- recv (msgFd, recv_buf + recvLen, msg_length - recvLen, 0);
- if (recvLen2 <= 0)
- {
- break;
- }
- else if (recvLen2 == msg_length - recvLen)
- {
- recvLen = 0;
- recv_count++;
- if (msg_length != send (msgFd, send_buf, msg_length, 0))
- {
- printf ("send failed!====, need exit\n");
- }
-
- }
- else if (recvLen2 < msg_length - recvLen)
- {
- recvLen += recvLen2;
- }
- if ((flagPrint != 0) && ((recv_count % unitPrint) == 0))
- {
- clock_gettime (CLOCK_MONOTONIC, &recvEnd);
- recv_ppstime =
- (recvEnd.tv_sec - recvStart.tv_sec) * 1000000000 +
- recvEnd.tv_nsec - recvStart.tv_nsec;
- recv_pps = ((float) 1000000000 / recv_ppstime) * unitPrint;
- printf ("receive count:%d, receive time: %ld ns\n", recv_count,
- recv_ppstime);
- printf ("receive pps = %d\n", recv_pps);
- clock_gettime (CLOCK_MONOTONIC, &recvStart);
- }
- }
- }
- close (msgFd);
-}
-
-/*
- using this thread to do accept connect
-*/
-void *
-process_server_accept_thread (void *pArgv)
-{
- int listenFd = 0;
- int x, optval, ret, m = 0;
- int acpt_socketfd[1000] = { 0 };
-
- listenFd = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (0 > listenFd)
- {
- printf ("ERROR:socket failed,errno [%d]\n", errno);
- return;
- }
- else
- {
- printf ("INFO:Create listen socket Success, listenFd[%d]\n", listenFd);
- }
-
- if (0 > fcntl (listenFd, F_SETFL, O_NONBLOCK))
- {
- printf ("ERROR:fcntl failed. fd[%d], errno[%d]/n", listenFd, errno);
- close (listenFd);
- }
-
- optval = 1;
- ret =
- setsockopt (listenFd, SOL_SOCKET, SO_REUSEADDR, (void *) &optval,
- sizeof (optval));
- if (ret == -1)
- {
- printf ("ERROR:setsockopt failed. fd[%d], errno[%d]\n", listenFd,
- errno);
- close (listenFd);
- return;
- }
-
- if (0 !=
- bind (listenFd, (struct sockaddr *) &g_recv, sizeof (struct sockaddr)))
- {
- printf ("ERROR:bind failed. fd[%d] errno [%d]\n", listenFd, errno);
- printf ("INFO:Bind Failed, port %d IP:%s\n", ntohs (g_recv.sin_port),
- inet_ntoa (*((struct in_addr *) &(g_recv.sin_addr.s_addr))));
- close (listenFd);
- exit (-1);
- }
- else
- {
- printf ("Info Bind Success, port %d IP:%s\n", ntohs (g_recv.sin_port),
- inet_ntoa (*((struct in_addr *) &(g_recv.sin_addr.s_addr))));
- }
-
- if (0 != listen (listenFd, 100))
- {
- printf ("server socket listen failed. err %d\n", errno);
- close (listenFd);
- return;
- }
- printf ("Listen Success\n");
-
- int timeout = -1;
- int accpedNum = 0;
- while (accpedNum < connectNum)
- {
- while (1)
- {
- acpt_socketfd[accpedNum] =
- accept4 (listenFd, NULL, NULL, SOCK_NONBLOCK);
- if (acpt_socketfd[accpedNum] < 0)
- {
- break;
- }
-
- fcntl (acpt_socketfd[accpedNum], F_SETFL, 0);
-
- /*add new accptFd to MsgEpFD */
- pthread_t ser_rcv_thread_id;
- if (pthread_create
- (&ser_rcv_thread_id, NULL, process_server_msg_thread,
- (void *) &acpt_socketfd[accpedNum]) == -1)
- {
- printf ("create process_server_msg_thread fail\n");
- break;
- }
-
- printf ("accept cnt [%d], cur accept fd [%d]\n", accpedNum,
- acpt_socketfd[accpedNum]);
- accpedNum++;
- }
- }
- close (listenFd);
- while (1)
- {
- sleep (10);
- }
-
- pthread_exit (NULL);
-}
-
-void
-main (int argc, char *argv[])
-{
- socklen_t addrlen = sizeof (struct sockaddr);
- int err = 0, result = 0, ret = 0;
- int i = 0, j = 0, optval = 0, z = 0, x, listenfd;
- cpu_set_t mask;
-
- setArgsDefault ();
- ret = process_arg (argc, argv);
- if (ret != 1)
- {
- printf ("The param error\n");
- return;
- }
-
- pthread_t server_thread_id;
-
- if (pthread_create
- (&server_thread_id, NULL, process_server_accept_thread, NULL) == -1)
- {
- printf ("create process_server_accept_thread fail\n");
- return;
- }
-
- printf ("create process_server_accept_thread success\n");
-
- if (server_thread_id != 0)
- {
- printf ("Server Thread join\n");
- pthread_join (server_thread_id, NULL);
- }
-
- while (1)
- {
- sleep (10);
- }
-
- return;
-}
diff --git a/app_example/perf-test/multi_tcp_common_app_Cli.c b/app_example/perf-test/multi_tcp_common_app_Cli.c
deleted file mode 100644
index e395848..0000000
--- a/app_example/perf-test/multi_tcp_common_app_Cli.c
+++ /dev/null
@@ -1,396 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#define _GNU_SOURCE
-#include <sys/socket.h>
-#include <fcntl.h>
-#include <memory.h>
-#include <signal.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <netinet/in.h>
-#include <time.h>
-#include <linux/tcp.h>
-#include <sched.h>
-#include <pthread.h>
-#include <arpa/inet.h>
-#include <sys/epoll.h>
-#include <errno.h>
-
-#define _BIND bind
-#define _LISTEN listen
-#define _SOCKET socket
-#define _ACCEPT accept
-#define _SEND send
-#define _RECV recv
-#define _CLOSE close
-#define _CONNECT connect
-#define _PROTOCOL IPPROTO_TCP
-
-#define MAX_TEST_TIME 1000
-#define MSG_LENGTH 256
-#define CORE_NUM 8
-#define START_CPU_ID 2
-#define MAX_CONN_LIMIT 256
-#define MAX_PORT_NUM 65535
-//1:A-B ;0:A-B-A
-#define SEND_RECV_MODE 1
-#define MAX_EVENTS 1000
-#define Default_PortID 12345
-#define Default_SleepCnt 10000
-#define Default_SleepTime 1000000
-#define Flag_Print 1
-#define Fd_Number 1
-
-static struct sockaddr_in g_dest;
-static struct sockaddr_in g_src;
-static struct sockaddr_in g_recv;
-
-int times = MAX_TEST_TIME;
-int msg_length = MSG_LENGTH;
-int coreNum = CORE_NUM;
-int startCPUId = START_CPU_ID;
-int connectNum = MAX_CONN_LIMIT;
-int msgMode = SEND_RECV_MODE;
-int sleepCnt = Default_SleepCnt;
-int sleepTime = Default_SleepTime; //us
-int fdNumber = Fd_Number;
-int flagPrint = Flag_Print;
-int unitPrint = 0;
-int waitTime = 0;
-
-int srcPort = Default_PortID;
-int destPort = 0;
-int recvPort = 0;
-char sendarr[256] = "";
-char recvarr[256] = "";
-char destarr[256] = "";
-
-static void
-setArgsDefault ()
-{
-
- memset (&g_dest, 0, sizeof (g_dest));
- g_dest.sin_family = AF_INET;
- g_dest.sin_addr.s_addr = inet_addr ("127.0.0.1");
- g_dest.sin_port = htons (12345);
- bzero (&(g_dest.sin_zero), 8);
-
- memset (&g_src, 0, sizeof (g_src));
- g_src.sin_family = AF_INET;
- g_src.sin_addr.s_addr = inet_addr ("0.0.0.0");
- g_src.sin_port = htons (7895);
- bzero (&(g_src.sin_zero), 8);
-
- memset (&g_recv, 0, sizeof (g_recv));
- g_recv.sin_family = AF_INET;
- g_recv.sin_addr.s_addr = inet_addr ("0.0.0.0");
- g_recv.sin_port = htons (7895);
- bzero (&(g_recv.sin_zero), 8);
-
-}
-
-static int
-process_arg (int argc, char *argv[])
-{
- int opt = 0;
- int error = 0;
- const char *optstring = "p:d:s:a:l:t:e:i:f:r:n:w:u:x:";
- int rw_mark = 0;
-
- if (argc < 4)
- {
- printf
- ("Param info :-p dest_portid; -d dest_serverIP; -a src_portid; -s src_clientIP; -l msg_length; \n");
- printf
- ("\t-t MAX_TEST_TIME; -i msg_interval ; -f client fd number ; -r receive port; -n connectNum(one server vs n client)\n");
- return 0;
- }
- while ((opt = getopt (argc, argv, optstring)) != -1)
- {
- switch (opt)
- {
- case 'p':
- destPort = atoi (optarg);
- g_dest.sin_port = htons (atoi (optarg));
- break;
- case 'd':
- stpcpy (destarr, optarg);
- g_dest.sin_addr.s_addr = inet_addr (optarg);
- break;
- case 's':
- stpcpy (sendarr, optarg);
- g_src.sin_addr.s_addr = inet_addr (optarg);
- g_recv.sin_addr.s_addr = inet_addr (optarg);
- break;
- case 'a':
- //g_src.sin_port = htons(atoi(optarg));
- srcPort = atoi (optarg);
- break;
- case 'l':
- msg_length = atoi (optarg);
- break;
- case 't':
- times = atoi (optarg);
- break;
- case 'e':
- sleepCnt = atoi (optarg);
- break;
- case 'i':
- sleepTime = atoi (optarg);
- break;
- case 'f':
- fdNumber = atoi (optarg);
- break;
- case 'r':
- recvPort = atoi (optarg);
- g_recv.sin_port = htons (atoi (optarg));
- break;
- case 'n':
- connectNum = atoi (optarg);
- break;
- case 'w':
- waitTime = atoi (optarg);
- break;
- case 'u':
- unitPrint = atoi (optarg);
- break;
- case 'x':
- flagPrint = atoi (optarg);
- break;
-
- }
- }
- return 1;
-}
-
-void
-process_client (void)
-{
- int sendLen = 0;
- int i = 0, t = 0, p = 0, optval = 0, ret = 0;
- char send_buf[1000] = "";
- char recv_buf[1000] = "";
- int c_socketfd[100] = { 0 };
- int errbind[1000] = { 0 };
- int errconn[1000] = { 0 };
-
- int send_count[1000] = { 0 };
- int pps = 0;
- long pps_time = 0;
-
- struct timespec startTime, endTime;
- struct timespec countStart;
- struct timespec countEnd;
- memset (&countStart, 0, sizeof (countStart));
- memset (&countEnd, 0, sizeof (countEnd));
-
- for (i = 0; i < fdNumber; i++)
- {
- c_socketfd[i] = _SOCKET (PF_INET, SOCK_STREAM, _PROTOCOL);
- if (0 > c_socketfd[i])
- {
- printf ("client %d failed,err %d\n", i, errno);
- }
- else
- {
- printf ("client %d created success\n", i);
- }
- }
-
- for (i = 0; i < fdNumber; i++)
- {
- optval = 1;
- ret =
- setsockopt (c_socketfd[i], SOL_SOCKET, SO_REUSEADDR, (void *) &optval,
- sizeof (optval));
- if (ret == -1)
- {
- printf ("Couldn't setsockopt(SO_REUSEADDR)\n");
- break;
- }
- }
-
- for (i = 0; i < fdNumber; i++)
- {
- g_src.sin_port = htons (srcPort + i);
- errbind[i] =
- _BIND (c_socketfd[i], (struct sockaddr *) &g_src, sizeof (g_src));
- if (errbind[i] < 0)
- {
- printf ("client %d bind Failed %d\n", i, errno);
- _CLOSE (c_socketfd[i]);
- c_socketfd[i] = -1;
- continue;
- }
- else
- {
- printf ("client %d bind Success port:%d IP:%s\n", i,
- ntohs (g_src.sin_port),
- inet_ntoa (*((struct in_addr *) &(g_src.sin_addr.s_addr))));
- }
- }
- for (i = 0; i < fdNumber; i++)
- {
- if (errbind[i] >= 0)
- {
- errconn[i] =
- _CONNECT (c_socketfd[i], (struct sockaddr *) &g_dest,
- sizeof (g_dest));
- if (errconn[i] < 0)
- {
- printf ("client %d Connect Failed %s\n", i, strerror(errno));
- _CLOSE (c_socketfd[i]);
- c_socketfd[i] = -1;
- continue;
- }
- else
- {
- printf ("client %d Connect Success port:%d, IP:%s\n", i,
- ntohs (g_dest.sin_port),
- inet_ntoa (*
- ((struct in_addr *)
- &(g_dest.sin_addr.s_addr))));
- }
- }
- }
-
- sleep (1);
-
- clock_gettime (CLOCK_MONOTONIC, &startTime);
- clock_gettime (CLOCK_MONOTONIC, &countStart);
-
- int recvLen2, recvLen;
- for (t = 0; t < times; t++)
- {
- for (i = 0; i < fdNumber; i++)
- {
- if (c_socketfd[i] < 0)
- {
- continue;
- }
- do
- {
- sendLen = _SEND (c_socketfd[i], send_buf, msg_length, 0);
- }
- while (sendLen <= 0);
- send_count[i]++;
- recvLen = 0;
- do
- {
- recvLen2 =
- recv (c_socketfd[i], recv_buf + recvLen, msg_length - recvLen,
- 0);
- if (recvLen2 <= 0)
- {
- continue;
- }
- else if (recvLen2 == msg_length - recvLen)
- {
- recvLen = 0;
- break;
- }
- else if (recvLen2 < msg_length - recvLen)
- {
- recvLen += recvLen2;
- }
- }
- while (1);
- }
-
- if (0 != sleepTime)
- {
- if ((t % sleepCnt) == 0)
- {
- usleep (sleepTime);
- }
- }
-
- if ((send_count[0] % unitPrint) == 0 && send_count[0] > 0)
- {
- clock_gettime (CLOCK_MONOTONIC, &countEnd);
-
- pps_time =
- (countEnd.tv_sec - countStart.tv_sec) * 1000000000 +
- countEnd.tv_nsec - countStart.tv_nsec;
- pps = ((float) 1000000000 / pps_time) * unitPrint * fdNumber;
- if ((flagPrint != 0))
- {
- printf (" sendcount %d, time: %ld ns\n",
- send_count[0] * fdNumber, pps_time);
- }
- printf ("sendcount %d , pps=%d\n", send_count[0] * fdNumber, pps);
- clock_gettime (CLOCK_MONOTONIC, &countStart);
- }
- }
-
- clock_gettime (CLOCK_MONOTONIC, &endTime);
-
- for (i = 0; i < fdNumber; i++)
- {
- printf ("client %d send %d , sendtime :%ld s %ld ns\n", i,
- send_count[i], endTime.tv_sec - startTime.tv_sec,
- endTime.tv_nsec - startTime.tv_nsec);
- }
-
- for (i = 0; i < fdNumber; i++)
- {
- printf ("client %d close!\n", i);
- if (c_socketfd[i] > 0)
- _CLOSE (c_socketfd[i]);
- }
-
- pthread_exit (NULL);
-}
-
-void
-main (int argc, char *argv[])
-{
- socklen_t addrlen = sizeof (struct sockaddr);
- int err = 0, result = 0, ret = 0;
- int i = 0, j = 0, optval = 0, z = 0, x, listenfd;
- cpu_set_t mask;
-
- setArgsDefault ();
- ret = process_arg (argc, argv);
- if (ret != 1)
- {
- printf ("The param error\n");
- return;
- }
-
- pthread_t client_thread_id;
-
- if (pthread_create
- (&client_thread_id, NULL, (void *) (&process_client), NULL) == -1)
- {
- printf ("create client thread fail\n");
- return;
- }
-
- printf ("create client thread success\n");
-
- if (client_thread_id != 0)
- {
- printf ("Client Thread join\n");
- pthread_join (client_thread_id, NULL);
- }
-
- return;
-}
diff --git a/app_example/perf-test/multi_tcp_epoll_app_Ser.c b/app_example/perf-test/multi_tcp_epoll_app_Ser.c
deleted file mode 100644
index 270fbde..0000000
--- a/app_example/perf-test/multi_tcp_epoll_app_Ser.c
+++ /dev/null
@@ -1,632 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#define _GNU_SOURCE
-#include <sys/socket.h>
-#include <fcntl.h>
-#include <memory.h>
-#include <signal.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <netinet/in.h>
-#include <time.h>
-#include <linux/tcp.h>
-#include <sched.h>
-#include <pthread.h>
-#include <arpa/inet.h>
-#include <sys/epoll.h>
-#include <errno.h>
-
-#define _BIND bind
-#define _LISTEN listen
-#define _SOCKET socket
-#define _ACCEPT accept
-#define _SEND send
-#define _RECV recv
-#define _CLOSE close
-#define _CONNECT connect
-#define _PROTOCOL IPPROTO_TCP
-
-#define MAX_TEST_TIME 1000
-#define MSG_LENGTH 256
-#define CORE_NUM 8
-#define START_CPU_ID 2
-#define MAX_CONN_LIMIT 256
-#define MAX_PORT_NUM 65535
-//1:A-B ;0:A-B-A
-#define SEND_RECV_MODE 1
-#define MAX_EVENTS 1000
-#define Default_PortID 12345
-#define Default_SleepCnt 10000
-#define Default_SleepTime 1000000
-#define Flag_Print 1
-#define Fd_Number 1
-
-static struct sockaddr_in g_dest;
-static struct sockaddr_in g_src;
-static struct sockaddr_in g_recv;
-
-int times = MAX_TEST_TIME;
-int msg_length = MSG_LENGTH;
-int coreNum = CORE_NUM;
-int startCPUId = START_CPU_ID;
-int connectNum = MAX_CONN_LIMIT;
-int msgMode = SEND_RECV_MODE;
-int sleepCnt = Default_SleepCnt;
-int sleepTime = Default_SleepTime; //us
-int fdNumber = Fd_Number;
-int flagPrint = Flag_Print;
-int unitPrint = 0;
-int waitTime = 0;
-
-int srcPort = Default_PortID;
-int destPort = 0;
-int recvPort = 0;
-char sendarr[256] = "";
-char recvarr[256] = "";
-char destarr[256] = "";
-
-static void
-setArgsDefault ()
-{
-
- memset (&g_dest, 0, sizeof (g_dest));
- g_dest.sin_family = AF_INET;
- g_dest.sin_addr.s_addr = inet_addr ("127.0.0.1");
- g_dest.sin_port = htons (12345);
- bzero (&(g_dest.sin_zero), 8);
-
- memset (&g_src, 0, sizeof (g_src));
- g_src.sin_family = AF_INET;
- g_src.sin_addr.s_addr = inet_addr ("0.0.0.0");
- g_src.sin_port = htons (7895);
- bzero (&(g_src.sin_zero), 8);
-
- memset (&g_recv, 0, sizeof (g_recv));
- g_recv.sin_family = AF_INET;
- g_recv.sin_addr.s_addr = inet_addr ("0.0.0.0");
- g_recv.sin_port = htons (7895);
- bzero (&(g_recv.sin_zero), 8);
-
-}
-
-static int
-process_arg (int argc, char *argv[])
-{
- int opt = 0;
- int error = 0;
- const char *optstring = "p:d:s:a:l:t:e:i:f:r:n:w:u:x:";
- int rw_mark = 0;
-
- if (argc < 4)
- {
- printf
- ("Param info :-p dest_portid; -d dest_serverIP; -a src_portid; -s src_clientIP; -l msg_length; \n");
- printf
- ("\t-t MAX_TEST_TIME; -i msg_interval ; -f client fd number ; -r receive port; -n connectNum(one server vs n client)\n");
- return 0;
- }
- while ((opt = getopt (argc, argv, optstring)) != -1)
- {
- switch (opt)
- {
- case 'p':
- destPort = atoi (optarg);
- g_dest.sin_port = htons (atoi (optarg));
- break;
- case 'd':
- stpcpy (destarr, optarg);
- g_dest.sin_addr.s_addr = inet_addr (optarg);
- break;
- case 's':
- stpcpy (sendarr, optarg);
- g_src.sin_addr.s_addr = inet_addr (optarg);
- g_recv.sin_addr.s_addr = inet_addr (optarg);
- break;
- case 'a':
- //g_src.sin_port = htons(atoi(optarg));
- srcPort = atoi (optarg);
- break;
- case 'l':
- msg_length = atoi (optarg);
- break;
- case 't':
- times = atoi (optarg);
- break;
- case 'e':
- sleepCnt = atoi (optarg);
- break;
- case 'i':
- sleepTime = atoi (optarg);
- break;
- case 'f':
- fdNumber = atoi (optarg);
- break;
- case 'r':
- recvPort = atoi (optarg);
- g_recv.sin_port = htons (atoi (optarg));
- break;
- case 'n':
- connectNum = atoi (optarg);
- break;
- case 'w':
- waitTime = atoi (optarg);
- break;
- case 'u':
- unitPrint = atoi (optarg);
- break;
- case 'x':
- flagPrint = atoi (optarg);
- break;
-
- }
- }
- return 1;
-}
-
-void
-process_client (void)
-{
- int sendLen = 0;
- int i = 0, t = 0, p = 0, optval = 0, ret = 0;
- char send_buf[1000] = "";
- int c_socketfd[100] = { 0 };
- int errbind[1000] = { 0 };
- int errconn[1000] = { 0 };
-
- int send_count[1000] = { 0 };
- int pps = 0;
- long pps_time = 0;
-
- struct timespec startTime, endTime;
- struct timespec countStart;
- struct timespec countEnd;
- memset (&countStart, 0, sizeof (countStart));
- memset (&countEnd, 0, sizeof (countEnd));
-
- for (i = 0; i < fdNumber; i++)
- {
- c_socketfd[i] = _SOCKET (PF_INET, SOCK_STREAM, _PROTOCOL);
- if (0 > c_socketfd[i])
- {
- printf ("client %d failed,err %d\n", i, errno);
- }
- else
- {
- printf ("client %d created success\n", i);
- }
- }
-
- for (i = 0; i < fdNumber; i++)
- {
- optval = 1;
- ret =
- setsockopt (c_socketfd[i], SOL_SOCKET, SO_REUSEADDR, (void *) &optval,
- sizeof (optval));
- if (ret == -1)
- {
- printf ("Couldn't setsockopt(SO_REUSEADDR)\n");
- break;
- }
- }
-
- for (i = 0; i < fdNumber; i++)
- {
- g_src.sin_port = htons (srcPort + i);
- errbind[i] =
- _BIND (c_socketfd[i], (struct sockaddr *) &g_src, sizeof (g_src));
- if (errbind[i] < 0)
- {
- printf ("client %d bind Failed %d\n", i, errno);
- _CLOSE (c_socketfd[i]);
- c_socketfd[i] = -1;
- continue;
- }
- else
- {
- printf ("client %d bind Success port:%d IP:%s\n", i,
- ntohs (g_src.sin_port),
- inet_ntoa (*((struct in_addr *) &(g_src.sin_addr.s_addr))));
- }
- }
- for (i = 0; i < fdNumber; i++)
- {
- if (errbind[i] >= 0)
- {
- errconn[i] =
- _CONNECT (c_socketfd[i], (struct sockaddr *) &g_dest,
- sizeof (g_dest));
- if (errconn[i] < 0)
- {
- printf ("client %d Connect Failed %d\n", i, errno);
- _CLOSE (c_socketfd[i]);
- c_socketfd[i] = -1;
- continue;
- }
- else
- {
- printf ("client %d Connect Success port:%d, IP:%s\n", i,
- ntohs (g_dest.sin_port),
- inet_ntoa (*
- ((struct in_addr *)
- &(g_dest.sin_addr.s_addr))));
- }
- }
- }
-
- sleep (1);
-
- clock_gettime (CLOCK_MONOTONIC, &startTime);
- clock_gettime (CLOCK_MONOTONIC, &countStart);
-
- for (t = 0; t < times; t++)
- {
- for (i = 0; i < fdNumber; i++)
- {
- if (c_socketfd[i] < 0)
- {
- continue;
- }
- do
- {
- sendLen = _SEND (c_socketfd[i], send_buf, msg_length, 0);
- }
- while (sendLen <= 0);
- send_count[i]++;
- }
-
- if (0 != sleepTime)
- {
- if ((t % sleepCnt) == 0)
- {
- usleep (sleepTime);
- }
- }
-
- if ((send_count[0] % unitPrint) == 0)
- {
- clock_gettime (CLOCK_MONOTONIC, &countEnd);
-
- pps_time =
- (countEnd.tv_sec - countStart.tv_sec) * 1000000000 +
- countEnd.tv_nsec - countStart.tv_nsec;
- pps = ((float) 1000000000 / pps_time) * unitPrint * fdNumber;
- if ((flagPrint != 0))
- {
- printf (" sendcount %d, time: %ld ns\n",
- send_count[0] * fdNumber, pps_time);
- }
- printf ("sendcount %d , pps=%d\n", send_count[0] * fdNumber, pps);
- clock_gettime (CLOCK_MONOTONIC, &countStart);
- }
-
- }
-
- clock_gettime (CLOCK_MONOTONIC, &endTime);
-
- for (i = 0; i < fdNumber; i++)
- {
- printf ("client %d send %d , sendtime :%ld s %ld ns\n", i,
- send_count[i], endTime.tv_sec - startTime.tv_sec,
- endTime.tv_nsec - startTime.tv_nsec);
- }
-
- for (i = 0; i < fdNumber; i++)
- {
- printf ("client %d close!\n", i);
- if (c_socketfd[i] > 0)
- _CLOSE (c_socketfd[i]);
- }
-
- pthread_exit (NULL);
-}
-
-/*
- using this thread to do recv msg;
-*/
-void *
-process_server_msg_thread (void *pArgv)
-{
- int recvLen = 0, recvLen2 = 0;
- char send_buf[1000];
- char recv_buf[1000];
- int recv_count = 0;
- long recv_ppstime = 0;
- int recv_pps = 0;
- int ret;
- struct epoll_event event;
-
- struct epoll_event eventList[MAX_EVENTS];
-
- struct timespec recvStart;
- struct timespec recvEnd;
- memset (&recvStart, 0, sizeof (recvStart));
- memset (&recvEnd, 0, sizeof (recvEnd));
-
- pthread_detach (pthread_self ());
-
- int msgEpFd = epoll_create (100);
- int msgFd = *(int *) pArgv;
-
- event.events = EPOLLIN | EPOLLET;
- event.data.fd = msgFd;
- if (epoll_ctl (msgEpFd, EPOLL_CTL_ADD, msgFd, &event) < 0)
- {
- printf ("epoll add fd[%d] to msgEpfd:[%d] failed\n", msgFd, msgEpFd);
- close (msgEpFd);
- close (msgFd);
- return NULL;
- }
-
- clock_gettime (CLOCK_MONOTONIC, &recvStart);
- while (1)
- {
- int timeout = -1;
- int m;
- int sock;
- ret = epoll_wait (msgEpFd, eventList, MAX_EVENTS, timeout);
- if (ret == 0)
- continue;
-
- for (m = 0; m < ret; m++)
- {
- if ((eventList[m].events & EPOLLERR)
- || (eventList[m].events & EPOLLHUP)
- || !(eventList[m].events & EPOLLIN))
- {
- printf ("fd %d epoll error event:%d\n", eventList[m].data.fd,
- eventList[m].events);
- close (eventList[m].data.fd);
- continue;
- }
- else
- {
- recvLen = 0;
- recvLen2 = 0;
- sock = eventList[m].data.fd;
-
- do
- {
- recvLen2 =
- recv (sock, recv_buf + recvLen, msg_length - recvLen, 0);
- if (recvLen2 <= 0)
- {
- break;
- }
- else if (recvLen2 == msg_length - recvLen)
- {
- recvLen = 0;
- recv_count++;
- if (msg_length != send (sock, send_buf, msg_length, 0))
- {
- printf ("send failed!====, need exit\n");
- }
- }
- else if (recvLen2 < msg_length - recvLen)
- {
- recvLen += recvLen2;
- }
- if ((flagPrint != 0) && ((recv_count % unitPrint) == 0))
- {
- clock_gettime (CLOCK_MONOTONIC, &recvEnd);
- recv_ppstime =
- (recvEnd.tv_sec - recvStart.tv_sec) * 1000000000 +
- recvEnd.tv_nsec - recvStart.tv_nsec;
- recv_pps =
- ((float) 1000000000 / recv_ppstime) * unitPrint;
- printf ("receive count:%d, receive time: %ld ns\n",
- recv_count, recv_ppstime);
- printf ("receive pps = %d\n", recv_pps);
- clock_gettime (CLOCK_MONOTONIC, &recvStart);
- }
- }
- while (1);
- }
-
- }
-
- if (recv_count == times)
- {
- break;
- }
- }
- close (msgFd);
- close (msgEpFd);
-}
-
-/*
- using this thread to do accept connect
-*/
-void *
-process_server_accept_thread (void *pArgv)
-{
- int listenFd = 0;
- int x, optval, ret = 0;
- int acpt_socketfd[1000] = { 0 };
-
- listenFd = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (0 > listenFd)
- {
- printf ("ERROR:socket failed,errno [%d]\n", errno);
- return NULL;
- }
- else
- {
- printf ("INFO:Create listen socket Success, listenFd[%d]\n", listenFd);
- }
-
- if (0 > fcntl (listenFd, F_SETFL, O_NONBLOCK))
- {
- printf ("ERROR:fcntl failed. fd[%d], errno[%d]/n", listenFd, errno);
- close (listenFd);
- }
-
- optval = 1;
- ret =
- setsockopt (listenFd, SOL_SOCKET, SO_REUSEADDR, (void *) &optval,
- sizeof (optval));
- if (ret == -1)
- {
- printf ("ERROR:setsockopt failed. fd[%d], errno[%d]\n", listenFd,
- errno);
- close (listenFd);
- return NULL;
- }
-
- if (0 !=
- bind (listenFd, (struct sockaddr *) &g_recv, sizeof (struct sockaddr)))
- {
- printf ("ERROR:bind failed. fd[%d] errno [%d]\n", listenFd, errno);
- printf ("INFO:Bind Failed, port %d IP:%s\n", ntohs (g_recv.sin_port),
- inet_ntoa (*((struct in_addr *) &(g_recv.sin_addr.s_addr))));
- close (listenFd);
- //return NULL;
- exit (-1);
- }
- else
- {
- printf ("INFO:Bind Success, port %d IP:%s\n", ntohs (g_recv.sin_port),
- inet_ntoa (*((struct in_addr *) &(g_recv.sin_addr.s_addr))));
- }
-
- if (0 != listen (listenFd, 100))
- {
- printf ("server socket listen failed. err %d\n", errno);
- close (listenFd);
- return NULL;
- }
- printf ("Listen Success\n");
-
- int accEpFd;
- struct epoll_event eventList[100];
- accEpFd = epoll_create (100);
- struct epoll_event event;
- event.events = EPOLLIN | EPOLLET;
- event.data.fd = listenFd;
-
- if (epoll_ctl (accEpFd, EPOLL_CTL_ADD, listenFd, &event) < 0)
- {
- printf ("epoll_ctl add [%d] to epfd:%d failed\n", listenFd, accEpFd);
- exit (-1);
- }
-
- int timeout = -1;
- int accpedNum = 0;
- while (accpedNum < connectNum)
- {
- ret = epoll_wait (accEpFd, eventList, connectNum, timeout);
-
- if (ret < 0)
- {
- printf ("accept_thread epoll_wait error, epfd[%d], errno[%d]\n",
- accEpFd, errno);
- continue;
- }
- else if (ret == 0)
- continue;
-
- /*loop done ever Event */
- for (x = 0; x < ret; x++)
- {
- printf ("event:%d; ret:%d\n", eventList[x].events, ret);
- if ((eventList[x].events & EPOLLERR)
- || !(eventList[x].events & EPOLLIN))
- {
- printf ("epoll fd %d error\n", eventList[x].data.fd);
- close (eventList[x].data.fd);
- continue;
- }
-
- while (1)
- {
- acpt_socketfd[accpedNum] =
- accept4 (listenFd, NULL, NULL, SOCK_NONBLOCK);
- if (acpt_socketfd[accpedNum] < 0)
- {
- printf ("no more connect\n");
- break;
- }
- /*add new accptFd to MsgEpFD */
- pthread_t ser_rcv_thread_id;
- if (pthread_create
- (&ser_rcv_thread_id, NULL, process_server_msg_thread,
- (void *) &acpt_socketfd[accpedNum]) == -1)
- {
- printf ("create process_server_msg_thread fail\n");
- break;
- }
-
- printf ("accept cnt [%d], cur accept fd [%d]\n", accpedNum,
- acpt_socketfd[accpedNum]);
- accpedNum++;
- }
- }
- }
-
- close (listenFd);
- close (accEpFd);
-
- while (1)
- {
- sleep (10);
- }
-
- pthread_exit (NULL);
-}
-
-void
-main (int argc, char *argv[])
-{
- socklen_t addrlen = sizeof (struct sockaddr);
- int err = 0, result = 0, ret = 0;
- int i = 0, j = 0, optval = 0, z = 0, x, listenfd;
- cpu_set_t mask;
-
- setArgsDefault ();
- ret = process_arg (argc, argv);
- if (ret != 1)
- {
- printf ("The param error\n");
- return;
- }
-
- pthread_t server_thread_id;
-
- if (pthread_create
- (&server_thread_id, NULL, process_server_accept_thread, NULL) == -1)
- {
- printf ("create process_server_accept_thread fail\n");
- return;
- }
-
- printf ("create process_server_accept_thread success\n");
-
- if (server_thread_id != 0)
- {
- printf ("Server Thread join\n");
- pthread_join (server_thread_id, NULL);
- }
-
- while (1)
- {
- sleep (10);
- }
-
- return;
-}
diff --git a/app_example/perf-test/multi_tcp_select_app_Ser.c b/app_example/perf-test/multi_tcp_select_app_Ser.c
deleted file mode 100644
index c1afe62..0000000
--- a/app_example/perf-test/multi_tcp_select_app_Ser.c
+++ /dev/null
@@ -1,436 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#define _GNU_SOURCE
-#include <sys/socket.h>
-#include <fcntl.h>
-#include <memory.h>
-#include <signal.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <netinet/in.h>
-#include <time.h>
-#include <linux/tcp.h>
-#include <sched.h>
-#include <pthread.h>
-#include <arpa/inet.h>
-#include <sys/epoll.h>
-#include <errno.h>
-
-#define _BIND bind
-#define _LISTEN listen
-#define _SOCKET socket
-#define _ACCEPT accept
-#define _SEND send
-#define _RECV recv
-#define _CLOSE close
-#define _CONNECT connect
-#define _PROTOCOL IPPROTO_TCP
-
-#define MAX_TEST_TIME 1000
-#define MSG_LENGTH 256
-#define CORE_NUM 8
-#define START_CPU_ID 2
-#define MAX_CONN_LIMIT 256
-#define MAX_PORT_NUM 65535
-//1:A-B ;0:A-B-A
-#define SEND_RECV_MODE 1
-#define MAX_EVENTS 1000
-#define Default_PortID 12345
-#define Default_SleepCnt 10000
-#define Default_SleepTime 1000000
-#define Flag_Print 1
-#define Fd_Number 1
-
-static struct sockaddr_in g_dest;
-static struct sockaddr_in g_src;
-static struct sockaddr_in g_recv;
-
-int times = MAX_TEST_TIME;
-int msg_length = MSG_LENGTH;
-int coreNum = CORE_NUM;
-int startCPUId = START_CPU_ID;
-int connectNum = MAX_CONN_LIMIT;
-int msgMode = SEND_RECV_MODE;
-int sleepCnt = Default_SleepCnt;
-int sleepTime = Default_SleepTime; //us
-int fdNumber = Fd_Number;
-int flagPrint = Flag_Print;
-int unitPrint = 0;
-int waitTime = 0;
-
-int srcPort = Default_PortID;
-int destPort = 0;
-int recvPort = 0;
-char sendarr[256] = "";
-char recvarr[256] = "";
-char destarr[256] = "";
-
-static void
-setArgsDefault ()
-{
-
- memset (&g_dest, 0, sizeof (g_dest));
- g_dest.sin_family = AF_INET;
- g_dest.sin_addr.s_addr = inet_addr ("127.0.0.1");
- g_dest.sin_port = htons (12345);
- bzero (&(g_dest.sin_zero), 8);
-
- memset (&g_src, 0, sizeof (g_src));
- g_src.sin_family = AF_INET;
- g_src.sin_addr.s_addr = inet_addr ("0.0.0.0");
- g_src.sin_port = htons (7895);
- bzero (&(g_src.sin_zero), 8);
-
- memset (&g_recv, 0, sizeof (g_recv));
- g_recv.sin_family = AF_INET;
- g_recv.sin_addr.s_addr = inet_addr ("0.0.0.0");
- g_recv.sin_port = htons (7895);
- bzero (&(g_recv.sin_zero), 8);
-
-}
-
-static int
-process_arg (int argc, char *argv[])
-{
- int opt = 0;
- int error = 0;
- const char *optstring = "p:d:s:a:l:t:e:i:f:r:n:w:u:x:";
- int rw_mark = 0;
-
- if (argc < 4)
- {
- printf
- ("Param info :-p dest_portid; -d dest_serverIP; -a src_portid; -s src_clientIP; -l msg_length; \n");
- printf
- ("\t-t MAX_TEST_TIME; -i msg_interval ; -f client fd number ; -r receive port; -n connectNum(one server vs n client)\n");
- return 0;
- }
- while ((opt = getopt (argc, argv, optstring)) != -1)
- {
- switch (opt)
- {
- case 'p':
- destPort = atoi (optarg);
- g_dest.sin_port = htons (atoi (optarg));
- break;
- case 'd':
- stpcpy (destarr, optarg);
- g_dest.sin_addr.s_addr = inet_addr (optarg);
- break;
- case 's':
- stpcpy (sendarr, optarg);
- g_src.sin_addr.s_addr = inet_addr (optarg);
- g_recv.sin_addr.s_addr = inet_addr (optarg);
- break;
- case 'a':
- //g_src.sin_port = htons(atoi(optarg));
- srcPort = atoi (optarg);
- break;
- case 'l':
- msg_length = atoi (optarg);
- break;
- case 't':
- times = atoi (optarg);
- break;
- case 'e':
- sleepCnt = atoi (optarg);
- break;
- case 'i':
- sleepTime = atoi (optarg);
- break;
- case 'f':
- fdNumber = atoi (optarg);
- break;
- case 'r':
- recvPort = atoi (optarg);
- g_recv.sin_port = htons (atoi (optarg));
- break;
- case 'n':
- connectNum = atoi (optarg);
- break;
- case 'w':
- waitTime = atoi (optarg);
- break;
- case 'u':
- unitPrint = atoi (optarg);
- break;
- case 'x':
- flagPrint = atoi (optarg);
- break;
-
- }
- }
- return 1;
-}
-
-/*
- using this thread to do recv msg;
-*/
-void *
-process_server_msg_thread (void *pArgv)
-{
- int recvLen = 0, recvLen2 = 0;
- char send_buf[1000];
- char recv_buf[1000];
- int recv_count = 0;
- long recv_ppstime = 0;
- int recv_pps = 0;
- int ret;
- struct timeval timeout;
- fd_set rfds;
- int maxfd;
-
- struct timespec recvStart;
- struct timespec recvEnd;
- memset (&recvStart, 0, sizeof (recvStart));
- memset (&recvEnd, 0, sizeof (recvEnd));
-
- pthread_detach (pthread_self ());
-
- int msgFd = *(int *) pArgv;
-
- clock_gettime (CLOCK_MONOTONIC, &recvStart);
- while (1)
- {
- FD_ZERO (&rfds);
- FD_SET (msgFd, &rfds);
- maxfd = msgFd + 1;
- timeout.tv_sec = 10;
- timeout.tv_usec = 0;
- ret = select (maxfd, &rfds, NULL, NULL, &timeout);
-
- if (ret <= 0)
- {
- continue;
- }
-
- if (FD_ISSET (msgFd, &rfds) == 0)
- {
- continue;
- }
-
- recvLen = 0;
- recvLen2 = 0;
-
- do
- {
- recvLen2 =
- recv (msgFd, recv_buf + recvLen, msg_length - recvLen, 0);
- if (recvLen2 <= 0)
- {
- break;
- }
- else if (recvLen2 == msg_length - recvLen)
- {
- recvLen = 0;
- recv_count++;
- if (msg_length != send (msgFd, send_buf, msg_length, 0))
- {
- printf ("send failed!====, need exit\n");
- }
- }
- else if (recvLen2 < msg_length - recvLen)
- {
- recvLen += recvLen2;
- }
- if ((flagPrint != 0) && ((recv_count % unitPrint) == 0))
- {
- clock_gettime (CLOCK_MONOTONIC, &recvEnd);
- recv_ppstime =
- (recvEnd.tv_sec - recvStart.tv_sec) * 1000000000 +
- recvEnd.tv_nsec - recvStart.tv_nsec;
- recv_pps = ((float) 1000000000 / recv_ppstime) * unitPrint;
- printf ("receive count:%d, receive time: %ld ns\n",
- recv_count, recv_ppstime);
- printf ("receive pps = %d\n", recv_pps);
- clock_gettime (CLOCK_MONOTONIC, &recvStart);
- }
- }
- while (1);
-
- if (recv_count == times)
- {
- break;
- }
- }
- close (msgFd);
-}
-
-/*
- using this thread to do accept connect
-*/
-void *
-process_server_accept_thread (void *pArgv)
-{
- int listenFd = 0;
- int x, optval, ret, m = 0;
- int acpt_socketfd[1000] = { 0 };
- struct timeval timeout;
- fd_set rfds;
- int maxfd;
-
- listenFd = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (0 > listenFd)
- {
- printf ("ERROR:socket failed,errno [%d]\n", errno);
- return NULL;
- }
- else
- {
- printf ("INFO:Create listen socket Success, listenFd[%d]\n", listenFd);
- }
-
- if (0 > fcntl (listenFd, F_SETFL, O_NONBLOCK))
- {
- printf ("ERROR:fcntl failed. fd[%d], errno[%d]/n", listenFd, errno);
- close (listenFd);
- }
-
- optval = 1;
- ret =
- setsockopt (listenFd, SOL_SOCKET, SO_REUSEADDR, (void *) &optval,
- sizeof (optval));
- if (ret == -1)
- {
- printf ("ERROR:setsockopt failed. fd[%d], errno[%d]\n", listenFd,
- errno);
- close (listenFd);
- return NULL;
- }
-
- if (0 !=
- bind (listenFd, (struct sockaddr *) &g_recv, sizeof (struct sockaddr)))
- {
- printf ("ERROR:bind failed. fd[%d] errno [%d]\n", listenFd, errno);
- printf ("INFO:Bind Failed, port %d IP:%s\n", ntohs (g_recv.sin_port),
- inet_ntoa (*((struct in_addr *) &(g_recv.sin_addr.s_addr))));
- close (listenFd);
- //return NULL;
- exit (-1);
- }
- else
- {
- printf ("INFO:Bind Success, port %d IP:%s\n", ntohs (g_recv.sin_port),
- inet_ntoa (*((struct in_addr *) &(g_recv.sin_addr.s_addr))));
- }
-
- if (0 != listen (listenFd, 100))
- {
- printf ("server socket listen failed. err %d\n", errno);
- close (listenFd);
- return NULL;
- }
- printf ("Listen Success\n");
-
- int accpedNum = 0;
- while (accpedNum < connectNum)
- {
- FD_ZERO (&rfds);
- FD_SET (listenFd, &rfds);
- maxfd = listenFd + 1;
- timeout.tv_sec = 10;
- timeout.tv_usec = 0;
- ret = select (maxfd, &rfds, NULL, NULL, &timeout);
-
- if (ret <= 0)
- {
- continue;
- }
-
- if (FD_ISSET (listenFd, &rfds) == 0)
- {
- continue;
- }
-
- while (1)
- {
- acpt_socketfd[accpedNum] =
- accept4 (listenFd, NULL, NULL, SOCK_NONBLOCK);
- if (acpt_socketfd[accpedNum] < 0)
- {
- printf ("no more connect\n");
- break;
- }
- /*add new accptFd to MsgEpFD */
- pthread_t ser_rcv_thread_id;
- if (pthread_create
- (&ser_rcv_thread_id, NULL, process_server_msg_thread,
- (void *) &acpt_socketfd[accpedNum]) == -1)
- {
- printf ("create process_server_msg_thread fail\n");
- break;
- }
-
- printf ("accept cnt [%d], cur accept fd [%d]\n", accpedNum,
- acpt_socketfd[accpedNum]);
- accpedNum++;
- }
- }
-
- close (listenFd);
-
- while (1)
- {
- sleep (10);
- }
-
- pthread_exit (NULL);
-}
-
-void
-main (int argc, char *argv[])
-{
- socklen_t addrlen = sizeof (struct sockaddr);
- int err = 0, result = 0, ret = 0;
- int i = 0, j = 0, optval = 0, z = 0, x, listenfd;
- cpu_set_t mask;
-
- setArgsDefault ();
- ret = process_arg (argc, argv);
- if (ret != 1)
- {
- printf ("The param error\n");
- return;
- }
-
- pthread_t server_thread_id;
-
- if (pthread_create
- (&server_thread_id, NULL, process_server_accept_thread, NULL) == -1)
- {
- printf ("create process_server_accept_thread fail\n");
- return;
- }
-
- printf ("create process_server_accept_thread success\n");
-
- if (server_thread_id != 0)
- {
- printf ("Server Thread join\n");
- pthread_join (server_thread_id, NULL);
- }
-
- while (1)
- {
- sleep (10);
- }
-
- return;
-}
diff --git a/demo/nginx_proxy/README.md b/demo/nginx_proxy/README.md
deleted file mode 100644
index 4085cc9..0000000
--- a/demo/nginx_proxy/README.md
+++ /dev/null
@@ -1,24 +0,0 @@
-# Introduction
-DMM (Dual Mode, Multi-protocol, Multi-instance) is to implement a transport agnostic framework for network
-applications that can
-1. Work with both user space and kernel space network stacks
-2. Use different network protocol stacks based on their functional and performance requirements (QOS)
-3. Work with multiple instances of a transport protocol stack.
-
-Following demo directory demonstrates some of these features of DMM.
-Procedures and details of how to run this demo is inside each demo directory.
-
-##demo-1
-
-This demo use NGINX as a reverse proxy server. The server uses lwip as client facing stack and kernel tcp/ip
-stack as upstream server facing stack.
-
-##demo-2
-
-This demo NGINX as a reverse proxy server. The server uses lwip as client facing stack and kernel tcp/ip stack
-as upstream server facing stack for UDP, vpp-hoststack for another updtream server facing stack for TCP.
-
-##demo-3
-
-This demo NGINX as a reverse proxy server. The server uses kernel tcp/ip as client facing stack and rsocket
-stack as upstream server facing stack.
diff --git a/demo/nginx_proxy/demo-1/Vagrantfile b/demo/nginx_proxy/demo-1/Vagrantfile
deleted file mode 100644
index d3db5e5..0000000
--- a/demo/nginx_proxy/demo-1/Vagrantfile
+++ /dev/null
@@ -1,98 +0,0 @@
-# -*- mode: ruby -*-
-# vi: set ft=ruby :
-
-boxes = [
- {
- :name => "rproxy-client",
- :hostname => "rproxy-client",
- :mem => "1024",
- :cpu => "1"
- },
- {
- :name => "rproxy-server",
- :hostname => "rproxy-server",
- :mem => "1024",
- :cpu => "1"
- },
- {
- :name => "rproxy-proxy",
- :hostname => "rproxy-proxy",
- :mem => "10144",
- :cpu => "4"
- }
-]
-
-Vagrant.configure(2) do |config|
-
- # Pick the right distro and bootstrap, default is ubuntu1604
- distro = ( ENV['DMM_VAGRANT_DISTRO'] || "ubuntu")
- if distro == 'centos7'
- config.vm.box = "puppetlabs/centos-7.2-64-nocm"
- else
- config.vm.box = "puppetlabs/ubuntu-16.04-64-nocm"
- end
-
- config.vm.box_check_update = false
- #ddconfig.ssh.password = vagrant
- if Vagrant.has_plugin?("vagrant-cachier")
- config.cache.scope = :box
- end
-
- # Define some physical ports for your VMs to be used by DPDK
- #nics = (ENV['DMM_VAGRANT_NICS'] || "2").to_i(10)
- #for i in 1..nics
- # config.vm.network "private_network", type: "dhcp"
- #end
-
- if ENV['http_proxy'] && Vagrant.has_plugin?("vagrant-proxyconf")
- config.proxy.http = ENV['http_proxy']
- config.proxy.https = ENV['https_proxy']
- config.proxy.no_proxy = "localhost,127.0.0.1"
- end
-
- config.ssh.forward_agent = true
- config.ssh.forward_x11 = true
-
- boxes.each do |opts|
- config.vm.define opts[:name] do |srv|
- srv.vm.hostname = opts[:hostname]
- srv.vm.provider "virtualbox" do |vb|
- vb.customize ["modifyvm", :id, "--ioapic", "on"]
- vb.customize ["modifyvm", :id, "--memory", opts[:mem]]
- vb.customize ["modifyvm", :id, "--cpus", opts[:cpu]]
- end
- srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"../../../scripts/install_prereq.sh")
- puts ' '..srv.vm.hostname
-
- if opts[:name] == "rproxy-proxy"
- puts 'NGINX Proxy Server, Run nginx in below way '
- puts 'export LD_LIBRARY_PATH=/DMM/stacks/lwip_stack/release/lib64'
- puts './DMM/thirdparty/apps/nginx/release/nginx'
- srv.vm.synced_folder "../../../", "/DMM", type: "rsync"
- srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"adjust_hugepage.sh"), run: 'always'
- srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"apply_patch.sh"), run: 'always'
- srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"../../../stacks/lwip_stack/vagrant/build.sh"), :args => "/DMM vagrant"
- srv.vm.network "private_network", ip: "192.168.50.20"
- srv.vm.network "private_network", ip: "172.167.50.20"
- srv.vm.network "private_network", type: "dhcp"
- srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"../../../stacks/lwip_stack/vagrant/start_nstackMain.sh"), :args => "/DMM vagrant"
- #possibly overwrite by previous script so adjust again
- srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"adjust_hugepage.sh"), run: 'always'
- srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"setup_proxy.sh"), run: 'always'
- end
- if opts[:name] == "rproxy-client"
- puts 'Client use command: curl http://192.168.50.20'
- srv.vm.network "private_network", type: "dhcp"
- srv.vm.network "private_network", ip: "192.168.50.10"
- end
- if opts[:name] == "rproxy-server"
- puts 'Upstream server '
-
- srv.vm.synced_folder "./", "/NGINX", type: "rsync"
- srv.vm.network "private_network", type: "dhcp"
- srv.vm.provision "up", type: "shell", :path => File.join(File.dirname(__FILE__),"setup_upstream.sh"), run: 'always'
- srv.vm.network "private_network", ip: "172.167.50.30"
- end
- end
- end
-end
diff --git a/demo/nginx_proxy/demo-1/adjust_hugepage.sh b/demo/nginx_proxy/demo-1/adjust_hugepage.sh
deleted file mode 100644
index 282e3bd..0000000
--- a/demo/nginx_proxy/demo-1/adjust_hugepage.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash -x
-hugepagesize=$(cat /proc/meminfo | grep Hugepagesize | awk -F " " {'print$2'})
-if [ "$hugepagesize" == "2048" ]; then
- pages=3000
-elif [ "$hugepagesize" == "1048576" ]; then
- pages=5
-fi
-sudo sysctl -w vm.nr_hugepages=$pages
-HUGEPAGES=`sysctl -n vm.nr_hugepages`
-echo "Configured hugepages: $HUGEPAGE"
-if [ $HUGEPAGES != $pages ]; then
- echo "Warning: Unable to get $pages hugepages, only got $HUGEPAGES. Cannot finish."
-fi
-
diff --git a/demo/nginx_proxy/demo-1/apply_patch.sh b/demo/nginx_proxy/demo-1/apply_patch.sh
deleted file mode 100755
index 84ecc59..0000000
--- a/demo/nginx_proxy/demo-1/apply_patch.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/bash -x
-sudo apt-get install patch -y
-cd /DMM/src/
-sudo patch -p2 -i /DMM/demo/nginx_proxy/demo-1/demo_2stack.patch
-if [ $? -ne 0 ]; then
- echo "Patch Apply failed. Downlaod correct commit. Check README for details."
- exit -1
-fi
-cd -
diff --git a/demo/nginx_proxy/demo-1/demo_2stack.patch b/demo/nginx_proxy/demo-1/demo_2stack.patch
deleted file mode 100644
index f1bc8d3..0000000
--- a/demo/nginx_proxy/demo-1/demo_2stack.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-diff --git a/src/adapt/nstack_dmm_adpt.c b/src/adapt/nstack_dmm_adpt.c
-index d497b80..004975c 100644
---- a/src/adapt/nstack_dmm_adpt.c
-+++ b/src/adapt/nstack_dmm_adpt.c
-@@ -76,7 +76,7 @@ nstack_event_callback (void *pdata, int events)
- /*event should not notice other process */
- if ((ep->pid != get_sys_pid ()) && g_same_process)
- {
-- continue;
-+ //continue;
- }
-
- sys_arch_lock_with_pid (&ep->lock);
-diff --git a/src/nSocket/nstack/nstack_module.c b/src/nSocket/nstack/nstack_module.c
-index 9566ab8..f692225 100644
---- a/src/nSocket/nstack/nstack_module.c
-+++ b/src/nSocket/nstack/nstack_module.c
-@@ -60,6 +60,11 @@ nstack_get_deploy_type ()
- if (g_nstack_module_desc[icnt].deploytype > type)
- {
- type = g_nstack_module_desc[icnt].deploytype;
-+ if (NSTACK_MODEL_TYPE3 == type)
-+ {
-+ break;
-+ }
-+
- }
- }
- return type;
diff --git a/demo/nginx_proxy/demo-1/module_config.json b/demo/nginx_proxy/demo-1/module_config.json
deleted file mode 100644
index 5f9424f..0000000
--- a/demo/nginx_proxy/demo-1/module_config.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "default_stack_name": "kernel",
- "module_list": [
- {
- "stack_name": "kernel",
- "libname": "./",
- "deploytype": "1",
- "stackid": "0",
- },
- {
- "stack_name": "lwip",
- "libname": "liblwip_dpdk.so",
- "deploytype": "3",
- "stackid": "1",
- },
- {
- "stack_name": "vpp_hoststack",
- "libname": "./libdmm_vcl.so",
- "deploytype": "4",
- "stackid": "2",
- },
- ]
-}
diff --git a/demo/nginx_proxy/demo-1/proxy_nginx.conf b/demo/nginx_proxy/demo-1/proxy_nginx.conf
deleted file mode 100644
index 05d8d2a..0000000
--- a/demo/nginx_proxy/demo-1/proxy_nginx.conf
+++ /dev/null
@@ -1,81 +0,0 @@
-user root;
-worker_processes 1;
-daemon off;
-#error_log logs/error.log;
-#error_log logs/error.log notice;
-#error_log logs/error.log info;
-
-#pid logs/nginx.pid;
-
-
-events {
- worker_connections 1024;
-}
-
-
-http {
- include mime.types;
- default_type application/octet-stream;
-
- #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
- # '$status $body_bytes_sent "$http_referer" '
- # '"$http_user_agent" "$http_x_forwarded_for"';
-
- #access_log logs/access.log main;
-
- sendfile on;
- #tcp_nopush on;
-
- #keepalive_timeout 0;
- keepalive_timeout 65;
-
- #gzip on;
-
- server {
- listen 192.168.50.20:80 default_server;
- server_name 192.168.50.20;
-
- location / {
- proxy_bind 172.167.50.20:2020;
- proxy_pass http://172.167.50.30:80;
- proxy_set_header X-Real-IP $remote_addr;
- sendfile off;
- proxy_buffering off;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- }
-
- #error_page 404 /404.html;
-
- # redirect server error pages to the static page /50x.html
- #
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root html;
- }
-
- # proxy the PHP scripts to Apache listening on 127.0.0.1:80
- #
- #location ~ \.php$ {
- # proxy_pass http://127.0.0.1;
- #}
-
- # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
- #
- #location ~ \.php$ {
- # root html;
- # fastcgi_pass 127.0.0.1:9000;
- # fastcgi_index index.php;
- # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
- # include fastcgi_params;
- #}
-
- # deny access to .htaccess files, if Apache's document root
- # concurs with nginx's one
- #
- #location ~ /\.ht {
- # deny all;
- #}
- }
-
-
-}
diff --git a/demo/nginx_proxy/demo-1/rd_config.json b/demo/nginx_proxy/demo-1/rd_config.json
deleted file mode 100644
index 71f8919..0000000
--- a/demo/nginx_proxy/demo-1/rd_config.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "ip_route": [
- {
- "subnet": "192.168.50.20/32",
- "stack_name": "lwip",
- },
- {
- "subnet": "192.168.50.10/32",
- "stack_name": "kernel",
- },
- {
- "subnet": "172.167.50.20/24",
- "stack_name": "vpp_hoststack",
- }
- ],
- "prot_route": [
- {
- "proto_type": "1",
- "stack_name": "lwip",
- },
- {
- "proto_type": "2",
- "stack_name": "kernel",
- }
- ],
-}
-
diff --git a/demo/nginx_proxy/demo-1/setup_proxy.sh b/demo/nginx_proxy/demo-1/setup_proxy.sh
deleted file mode 100644
index bd0d030..0000000
--- a/demo/nginx_proxy/demo-1/setup_proxy.sh
+++ /dev/null
@@ -1,54 +0,0 @@
-#########################################################################
-# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-# 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.
-#########################################################################
-#!/bin/bash -x
-
-set -x
-sudo su
-# Clean up build NGINX
-cd /DMM/build/
-
-#Download and compile NGINX
-make NGINX
-#Download and compile vpp-stack
-make vpp-stack
-
-#cp vpp libs
-cp -r /DMM/stacks/vpp/vpp/build-root/install-vpp_debug-native/vpp/lib64/vpp_plugins /usr/lib/
-mkdir -p /etc/vpp/
-cp /DMM/demo/nginx_proxy/demo-1/startup.conf /etc/vpp/
-cp /DMM/demo/nginx_proxy/demo-1/vpp_config /etc/vpp/
-cd /DMM/stacks/vpp/vpp/build-root/install-vpp_debug-native/vpp/bin
-#run vpp
-sudo ifconfig enp0s9 down
-./vpp -c /etc/vpp/startup.conf
-
-#cp nginx libs
-cd /DMM/thirdparty/apps/nginx/release
-
-# Move the conf file.
-cp /DMM/demo/nginx_proxy/demo-1/module_config.json /DMM/thirdparty/apps/nginx/release/
-cp /DMM/stacks/lwip_stack/configure/nStackConfig.json /DMM/thirdparty/apps/nginx/release/
-cp /DMM/demo/nginx_proxy/demo-1/proxy_nginx.conf /DMM/thirdparty/apps/nginx/release/
-cp /DMM/demo/nginx_proxy/demo-1/rd_config.json /DMM/thirdparty/apps/nginx/release/
-mv /DMM/thirdparty/apps/nginx/release/proxy_nginx.conf /DMM/thirdparty/apps/nginx/release/nginx.conf
-
-sleep 5
-
-# Run nginx
-cp /DMM/stacks/vpp/vpp/build-root/install-vpp_debug-native/vpp/lib64/libdmm_vcl.so /DMM/thirdparty/apps/nginx/release/
-echo "export LD_LIBRARY_PATH=/DMM/stacks/lwip_stack/release/lib64"
-echo "./nginx"
-
-exit 0
diff --git a/demo/nginx_proxy/demo-1/setup_upstream.sh b/demo/nginx_proxy/demo-1/setup_upstream.sh
deleted file mode 100644
index 0c2c774..0000000
--- a/demo/nginx_proxy/demo-1/setup_upstream.sh
+++ /dev/null
@@ -1,45 +0,0 @@
-#########################################################################
-# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-# 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.
-#########################################################################
-#!/bin/bash -x
-
-set -x
-
-# Download nginx
-cd /NGINX
-wget http://nginx.org/download/nginx-1.14.0.tar.gz
-tar -zxf nginx-1.14.0.tar.gz
-
-#install supportive softwares
-apt-get install -yq libpcre3 libpcre3-dev zlibc zlib1g zlib1g-dev
-
-# Compile nginx
-cd nginx-1.14.0
-./configure
-make
-make install
-
-# Move the conf file.
-cd /usr/local/nginx/sbin
-cp -r * /usr/local/sbin
-cp /NGINX/upstream_nginx.conf /usr/local/nginx/conf/
-mv /usr/local/nginx/conf/upstream_nginx.conf /usr/local/nginx/conf/nginx.conf
-
-# Run nginx
-
-cd /usr/local/sbin
-./nginx
-echo "hi"
-exit 0
-
diff --git a/demo/nginx_proxy/demo-1/startup.conf b/demo/nginx_proxy/demo-1/startup.conf
deleted file mode 100644
index 616cd88..0000000
--- a/demo/nginx_proxy/demo-1/startup.conf
+++ /dev/null
@@ -1,20 +0,0 @@
-unix {
- log /var/log/vpp/vpp.log
- cli-listen localhost:5002
- exec /etc/vpp/vpp_config
-}
-
-api-trace {
- on
-}
-
-cpu {
- main-core 2
-}
-
-dpdk {
- socket-mem 1024
- uio-driver igb_uio
- dev 0000:00:09.0
-}
-
diff --git a/demo/nginx_proxy/demo-1/upstream_nginx.conf b/demo/nginx_proxy/demo-1/upstream_nginx.conf
deleted file mode 100644
index 3904197..0000000
--- a/demo/nginx_proxy/demo-1/upstream_nginx.conf
+++ /dev/null
@@ -1,80 +0,0 @@
-#user nobody;
-worker_processes 1;
-#daemon off;
-
-#error_log logs/error.log;
-#error_log logs/error.log notice;
-#error_log logs/error.log info;
-
-#pid logs/nginx.pid;
-
-
-events {
- worker_connections 1024;
-}
-
-
-http {
- include mime.types;
- default_type application/octet-stream;
-
- #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
- # '$status $body_bytes_sent "$http_referer" '
- # '"$http_user_agent" "$http_x_forwarded_for"';
-
- #access_log logs/access.log main;
-
- sendfile on;
- #tcp_nopush on;
-
- #keepalive_timeout 0;
- keepalive_timeout 65;
-
- #gzip on;
-
- server {
- listen 80;
- #server_name localhost;
-
- #charset koi8-r;
-
- #access_log logs/host.access.log main;
-
- location / {
- return 200 "Hello from upstream $hostname $server_addr:$server_port. Connect from $http_x_real_ip - $remote_user via $remote_addr:$remote_port at [$time_local] $request $status $body_bytes_sent $http_referer $http_user_agent\n";
- }
-
- #error_page 404 /404.html;
-
- # redirect server error pages to the static page /50x.html
- #
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root html;
- }
-
- # proxy the PHP scripts to Apache listening on 127.0.0.1:80
- #
- #location ~ \.php$ {
- # proxy_pass http://127.0.0.1;
- #}
-
- # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
- #
- #location ~ \.php$ {
- # root html;
- # fastcgi_pass 127.0.0.1:9000;
- # fastcgi_index index.php;
- # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
- # include fastcgi_params;
- #}
-
- # deny access to .htaccess files, if Apache's document root
- # concurs with nginx's one
- #
- #location ~ /\.ht {
- # deny all;
- #}
- }
-
-}
diff --git a/demo/nginx_proxy/demo-1/vpp_config b/demo/nginx_proxy/demo-1/vpp_config
deleted file mode 100644
index aaeadfb..0000000
--- a/demo/nginx_proxy/demo-1/vpp_config
+++ /dev/null
@@ -1,6 +0,0 @@
-set int state GigabitEthernet0/9/0 up
-set int ip addr GigabitEthernet0/9/0 172.167.50.20/24
-show version
-show version verbose
-show cpu
-show int
diff --git a/demo/nginx_proxy/demo-2/README.md b/demo/nginx_proxy/demo-2/README.md
deleted file mode 100644
index 7d6feb1..0000000
--- a/demo/nginx_proxy/demo-2/README.md
+++ /dev/null
@@ -1,69 +0,0 @@
-#demo-2
-## Introduction
-This demo NGINX as a reverse proxy server. The server uses "lwip" for client facing socket and "kernel tcp/ip stack "
-as upstream server facing socket for UDP, "vpp-hoststack" for another updtream server facing stack for TCP.
-
-## Topology
-![demo-2.png](demo-2.png)
-![dem-2-topo.png](dem-2-topo.png)
-## Steps
-####1. Create VMs using vagrant.
-Start demo VMs. Go to dmm/demo/nginx_proxy/demo-2 .
-```
-$ vagrant up
-```
-This command will create 4 VMs namely rproxy-client, rproxy-server1, rproxy-server2 and rproxy-proxy. The memory
-requirement for this demo is 13GB (approx).
-
-####2. Log in to VMs
-Open four terminal and login to VMs.
-```
-$ vagrant ssh <vm-name>
-```
-
-####3. Run Udp server Application at rproxy-server2
-```
-$ vagrant ssh rproxy-server2
-Inside VM
-vagrant@rproxy-server2:~$ sudo su
-root@rproxy-server2:/home/vagrant# cd /UDPSERVER/
-root@rproxy-server2:/UDPSERVER# ./udpserver
-```
-
-####4. Run NGINX proxy server at rproxy-proxy
-```
-$ vagrant ssh rproxy-proxy
-Inside VM
-vagrant@rproxy-proxy:~$ sudo su
-root@rproxy-proxy:/home/vagrant# cd /DMM/thirdparty/apps/nginx/release
-root@rproxy-proxy:/DMM/thirdparty/apps/nginx/release# export LD_LIBRARY_PATH=/DMM/stacks/lwip_stack/release/lib64
-root@rproxy-proxy:/DMM/thirdparty/apps/nginx/release# ./nginx
-```
-####5. Test TCP traffic
-```
-$ vagrant ssh rproxy-client
-vagrant@rproxy-client:~$ cd /CLIENT/
-vagrant@rproxy-client:/CLIENT$ curl http://192.168.50.20
-Hello from upstream rproxy-server1 172.167.50.30:80. Connect from - via 172.167.50.20:15140 at [12/Nov/2018:06:17:25 -0800] GET / HTTP/1.1 200 0 curl/7.47.0
-
-```
-
-####6. Test UDP traffic
-```
-$ vagrant ssh rproxy-client
-vagrant@rproxy-client:~$ cd /CLIENT/
-vagrant@rproxy-client:/CLIENT$ ./udpclient
-Hello message sent.
-Server : Hello from server
-```
-#### Notes:
-a. If enable debugs i.e. export NSTACK_LOG_ON=DBG before we run nginx in rroxy-proxy we can find below logs which suggest we use diffrent stack for diffrent ip/protoccol.
-```
-...
-nstack_bind<NSSOC>fd addr Select module]fd=18,addr=192.168.50.20,module=lwip
-...
-nstack_bind<NSSOC>fd addr Select module]fd=22,addr=172.167.50.20,module=vpp_hoststack
-...
-nstack_bind<NSSOC>fd addr Select module]fd=22,addr=182.167.50.20,module=kernel
-```
-b. This demo depends on commit of dmm. Please check commit version of your code.
diff --git a/demo/nginx_proxy/demo-2/Vagrantfile b/demo/nginx_proxy/demo-2/Vagrantfile
deleted file mode 100644
index dbd703a..0000000
--- a/demo/nginx_proxy/demo-2/Vagrantfile
+++ /dev/null
@@ -1,116 +0,0 @@
-# -*- mode: ruby -*-
-# vi: set ft=ruby :
-
-boxes = [
- {
- :name => "rproxy-client",
- :hostname => "rproxy-client",
- :mem => "1024",
- :cpu => "1"
- },
- {
- :name => "rproxy-server1",
- :hostname => "rproxy-server1",
- :mem => "1024",
- :cpu => "1"
- },
- {
- :name => "rproxy-server2",
- :hostname => "rproxy-server2",
- :mem => "1024",
- :cpu => "1"
- },
- {
- :name => "rproxy-proxy",
- :hostname => "rproxy-proxy",
- :mem => "10144",
- :cpu => "4"
- }
-]
-
-Vagrant.configure(2) do |config|
-
- # Pick the right distro and bootstrap, default is ubuntu1604
- distro = ( ENV['DMM_VAGRANT_DISTRO'] || "ubuntu")
- if distro == 'centos7'
- config.vm.box = "puppetlabs/centos-7.2-64-nocm"
- else
- config.vm.box = "puppetlabs/ubuntu-16.04-64-nocm"
- end
-
- config.vm.box_check_update = false
- #ddconfig.ssh.password = vagrant
- if Vagrant.has_plugin?("vagrant-cachier")
- config.cache.scope = :box
- end
-
- # Define some physical ports for your VMs to be used by DPDK
- #nics = (ENV['DMM_VAGRANT_NICS'] || "2").to_i(10)
- #for i in 1..nics
- # config.vm.network "private_network", type: "dhcp"
- #end
-
- if ENV['http_proxy'] && Vagrant.has_plugin?("vagrant-proxyconf")
- config.proxy.http = ENV['http_proxy']
- config.proxy.https = ENV['https_proxy']
- config.proxy.no_proxy = "localhost,127.0.0.1"
- end
-
- config.ssh.forward_agent = true
- config.ssh.forward_x11 = true
-
- boxes.each do |opts|
- config.vm.define opts[:name] do |srv|
- srv.vm.hostname = opts[:hostname]
- srv.vm.provider "virtualbox" do |vb|
- vb.customize ["modifyvm", :id, "--ioapic", "on"]
- vb.customize ["modifyvm", :id, "--memory", opts[:mem]]
- vb.customize ["modifyvm", :id, "--cpus", opts[:cpu]]
- end
- srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"../../../scripts/install_prereq.sh")
- puts ' '..srv.vm.hostname
-
- if opts[:name] == "rproxy-proxy"
- puts 'NGINX Proxy Server, Run nginx in below way '
- puts 'export LD_LIBRARY_PATH=/DMM/stacks/lwip_stack/release/lib64'
- puts './DMM/thirdparty/apps/nginx/release/nginx'
- srv.vm.synced_folder "../../../", "/DMM", type: "rsync"
- srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"adjust_hugepage.sh"), run: 'always'
- srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"apply_patch.sh"), run: 'always'
- srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"../../../stacks/lwip_stack/vagrant/build.sh"), :args => "/DMM vagrant"
- srv.vm.network "private_network", ip: "192.168.50.20"
- srv.vm.network "private_network", ip: "172.167.50.20"
- srv.vm.network "private_network", ip: "182.167.50.20"
- srv.vm.network "private_network", type: "dhcp"
- srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"../../../stacks/lwip_stack/vagrant/start_nstackMain.sh"), :args => "/DMM vagrant"
- #possibly overwrite by previous script so adjust again
- srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"adjust_hugepage.sh"), run: 'always'
- srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"setup_proxy.sh"), run: 'always'
- end
- if opts[:name] == "rproxy-client"
- puts 'Client use command for TCP: curl http://192.168.50.20'
- puts 'Client use command for UDP: ./udpclient'
- srv.vm.synced_folder "./", "/CLIENT", type: "rsync"
- srv.vm.network "private_network", type: "dhcp"
- srv.vm.network "private_network", ip: "192.168.50.10"
- srv.vm.provision "up", type: "shell", :path => File.join(File.dirname(__FILE__),"setup_client.sh"), run: 'always'
- end
- if opts[:name] == "rproxy-server1"
- puts 'Upstream server 1'
-
- srv.vm.synced_folder "./", "/NGINX", type: "rsync"
- srv.vm.network "private_network", type: "dhcp"
- srv.vm.provision "up", type: "shell", :path => File.join(File.dirname(__FILE__),"setup_upstream.sh"), run: 'always'
- srv.vm.network "private_network", ip: "172.167.50.30"
- end
- if opts[:name] == "rproxy-server2"
- puts 'Upstream server 2 '
-
- srv.vm.synced_folder "./", "/UDPSERVER", type: "rsync"
- srv.vm.network "private_network", type: "dhcp"
- srv.vm.provision "up", type: "shell", :path => File.join(File.dirname(__FILE__),"setup_udpserver.sh"), run: 'always'
- srv.vm.network "private_network", ip: "182.167.50.30"
- end
- end
- end
-end
diff --git a/demo/nginx_proxy/demo-2/adjust_hugepage.sh b/demo/nginx_proxy/demo-2/adjust_hugepage.sh
deleted file mode 100644
index 282e3bd..0000000
--- a/demo/nginx_proxy/demo-2/adjust_hugepage.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash -x
-hugepagesize=$(cat /proc/meminfo | grep Hugepagesize | awk -F " " {'print$2'})
-if [ "$hugepagesize" == "2048" ]; then
- pages=3000
-elif [ "$hugepagesize" == "1048576" ]; then
- pages=5
-fi
-sudo sysctl -w vm.nr_hugepages=$pages
-HUGEPAGES=`sysctl -n vm.nr_hugepages`
-echo "Configured hugepages: $HUGEPAGE"
-if [ $HUGEPAGES != $pages ]; then
- echo "Warning: Unable to get $pages hugepages, only got $HUGEPAGES. Cannot finish."
-fi
-
diff --git a/demo/nginx_proxy/demo-2/apply_patch.sh b/demo/nginx_proxy/demo-2/apply_patch.sh
deleted file mode 100755
index 05e8c66..0000000
--- a/demo/nginx_proxy/demo-2/apply_patch.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/bash -x
-sudo apt-get install patch -y
-cd /DMM/src/
-sudo patch -p2 -i /DMM/demo/nginx_proxy/demo-2/demo_2stack.patch
-if [ $? -ne 0 ]; then
- echo "Patch Apply failed. Downlaod correct commit. Check README for details."
- exit -1
-fi
-cd -
diff --git a/demo/nginx_proxy/demo-2/dem-2-topo.png b/demo/nginx_proxy/demo-2/dem-2-topo.png
deleted file mode 100644
index ad81372..0000000
--- a/demo/nginx_proxy/demo-2/dem-2-topo.png
+++ /dev/null
Binary files differ
diff --git a/demo/nginx_proxy/demo-2/demo-2.png b/demo/nginx_proxy/demo-2/demo-2.png
deleted file mode 100644
index 604c301..0000000
--- a/demo/nginx_proxy/demo-2/demo-2.png
+++ /dev/null
Binary files differ
diff --git a/demo/nginx_proxy/demo-2/demo_2stack.patch b/demo/nginx_proxy/demo-2/demo_2stack.patch
deleted file mode 100644
index f1bc8d3..0000000
--- a/demo/nginx_proxy/demo-2/demo_2stack.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-diff --git a/src/adapt/nstack_dmm_adpt.c b/src/adapt/nstack_dmm_adpt.c
-index d497b80..004975c 100644
---- a/src/adapt/nstack_dmm_adpt.c
-+++ b/src/adapt/nstack_dmm_adpt.c
-@@ -76,7 +76,7 @@ nstack_event_callback (void *pdata, int events)
- /*event should not notice other process */
- if ((ep->pid != get_sys_pid ()) && g_same_process)
- {
-- continue;
-+ //continue;
- }
-
- sys_arch_lock_with_pid (&ep->lock);
-diff --git a/src/nSocket/nstack/nstack_module.c b/src/nSocket/nstack/nstack_module.c
-index 9566ab8..f692225 100644
---- a/src/nSocket/nstack/nstack_module.c
-+++ b/src/nSocket/nstack/nstack_module.c
-@@ -60,6 +60,11 @@ nstack_get_deploy_type ()
- if (g_nstack_module_desc[icnt].deploytype > type)
- {
- type = g_nstack_module_desc[icnt].deploytype;
-+ if (NSTACK_MODEL_TYPE3 == type)
-+ {
-+ break;
-+ }
-+
- }
- }
- return type;
diff --git a/demo/nginx_proxy/demo-2/module_config.json b/demo/nginx_proxy/demo-2/module_config.json
deleted file mode 100644
index 5f9424f..0000000
--- a/demo/nginx_proxy/demo-2/module_config.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "default_stack_name": "kernel",
- "module_list": [
- {
- "stack_name": "kernel",
- "libname": "./",
- "deploytype": "1",
- "stackid": "0",
- },
- {
- "stack_name": "lwip",
- "libname": "liblwip_dpdk.so",
- "deploytype": "3",
- "stackid": "1",
- },
- {
- "stack_name": "vpp_hoststack",
- "libname": "./libdmm_vcl.so",
- "deploytype": "4",
- "stackid": "2",
- },
- ]
-}
diff --git a/demo/nginx_proxy/demo-2/proxy_nginx.conf b/demo/nginx_proxy/demo-2/proxy_nginx.conf
deleted file mode 100644
index 925e1a9..0000000
--- a/demo/nginx_proxy/demo-2/proxy_nginx.conf
+++ /dev/null
@@ -1,33 +0,0 @@
-user root;
-worker_processes 1;
-daemon off;
-#error_log logs/error.log;
-#error_log logs/error.log notice;
-#error_log logs/error.log info;
-
-#pid logs/nginx.pid;
-
-
-events {
- worker_connections 1024;
-}
-
-stream {
- upstream stream_tcp {
- server 172.167.50.30:80;
- }
- upstream stream_udp {
- server 182.167.50.30:53;
- }
- server {
- listen 192.168.50.20:80;
- proxy_bind 172.167.50.20:2020;
- proxy_pass stream_tcp;
- }
- server {
- listen 192.168.50.20:53 udp;
- proxy_bind 182.167.50.20:53;
- proxy_pass stream_udp;
- }
-}
-
diff --git a/demo/nginx_proxy/demo-2/rd_config.json b/demo/nginx_proxy/demo-2/rd_config.json
deleted file mode 100644
index 45ad585..0000000
--- a/demo/nginx_proxy/demo-2/rd_config.json
+++ /dev/null
@@ -1,31 +0,0 @@
-{
- "ip_route": [
- {
- "subnet": "192.168.50.20/32",
- "stack_name": "lwip",
- },
- {
- "subnet": "192.168.50.10/32",
- "stack_name": "kernel",
- },
- {
- "subnet": "172.167.50.20/24",
- "stack_name": "vpp_hoststack",
- },
- {
- "subnet": "182.167.50.20/32",
- "stack_name": "kernel",
- }
- ],
- "prot_route": [
- {
- "proto_type": "1",
- "stack_name": "lwip",
- },
- {
- "proto_type": "2",
- "stack_name": "kernel",
- }
- ],
-}
-
diff --git a/demo/nginx_proxy/demo-2/setup_client.sh b/demo/nginx_proxy/demo-2/setup_client.sh
deleted file mode 100644
index a0f4363..0000000
--- a/demo/nginx_proxy/demo-2/setup_client.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-#########################################################################
-# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-# 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.
-#########################################################################
-#!/bin/bash -x
-
-set -x
-
-# Download nginx
-cd /CLIENT
-
-gcc udpclient.c -o udpclient
-
-exit 0
-
diff --git a/demo/nginx_proxy/demo-2/setup_proxy.sh b/demo/nginx_proxy/demo-2/setup_proxy.sh
deleted file mode 100644
index 8c3d69a..0000000
--- a/demo/nginx_proxy/demo-2/setup_proxy.sh
+++ /dev/null
@@ -1,54 +0,0 @@
-#########################################################################
-# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-# 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.
-#########################################################################
-#!/bin/bash -x
-
-set -x
-sudo su
-# Clean up build NGINX
-cd /DMM/build/
-
-#Download and compile NGINX
-make NGINX
-#Download and compile vpp-stack
-make vpp-stack
-
-#cp vpp libs
-cp -r /DMM/stacks/vpp/vpp/build-root/install-vpp_debug-native/vpp/lib64/vpp_plugins /usr/lib/
-mkdir -p /etc/vpp/
-cp /DMM/demo/nginx_proxy/demo-2/startup.conf /etc/vpp/
-cp /DMM/demo/nginx_proxy/demo-2/vpp_config /etc/vpp/
-cd /DMM/stacks/vpp/vpp/build-root/install-vpp_debug-native/vpp/bin
-#run vpp
-sudo ifconfig enp0s9 down
-./vpp -c /etc/vpp/startup.conf
-
-#cp nginx libs
-cd /DMM/thirdparty/apps/nginx/release
-
-# Move the conf file.
-cp /DMM/demo/nginx_proxy/demo-2/module_config.json /DMM/thirdparty/apps/nginx/release/
-cp /DMM/stacks/lwip_stack/configure/nStackConfig.json /DMM/thirdparty/apps/nginx/release/
-cp /DMM/demo/nginx_proxy/demo-2/proxy_nginx.conf /DMM/thirdparty/apps/nginx/release/
-cp /DMM/demo/nginx_proxy/demo-2/rd_config.json /DMM/thirdparty/apps/nginx/release/
-mv /DMM/thirdparty/apps/nginx/release/proxy_nginx.conf /DMM/thirdparty/apps/nginx/release/nginx.conf
-
-sleep 5
-
-# Run nginx
-cp /DMM/stacks/vpp/vpp/build-root/install-vpp_debug-native/vpp/lib64/libdmm_vcl.so /DMM/thirdparty/apps/nginx/release/
-echo "export LD_LIBRARY_PATH=/DMM/stacks/lwip_stack/release/lib64"
-echo "./nginx"
-
-exit 0
diff --git a/demo/nginx_proxy/demo-2/setup_udpserver.sh b/demo/nginx_proxy/demo-2/setup_udpserver.sh
deleted file mode 100644
index d684286..0000000
--- a/demo/nginx_proxy/demo-2/setup_udpserver.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-#########################################################################
-# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-# 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.
-#########################################################################
-#!/bin/bash -x
-
-set -x
-
-# Download nginx
-cd /UDPSERVER
-
-gcc udpserver.c -o udpserver
-
-exit 0
-
diff --git a/demo/nginx_proxy/demo-2/setup_upstream.sh b/demo/nginx_proxy/demo-2/setup_upstream.sh
deleted file mode 100644
index ee7dbd4..0000000
--- a/demo/nginx_proxy/demo-2/setup_upstream.sh
+++ /dev/null
@@ -1,44 +0,0 @@
-#########################################################################
-# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-# 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.
-#########################################################################
-#!/bin/bash -x
-
-set -x
-
-# Download nginx
-cd /NGINX
-wget http://nginx.org/download/nginx-1.14.0.tar.gz
-tar -zxf nginx-1.14.0.tar.gz
-
-#install supportive softwares
-apt-get install -yq libpcre3 libpcre3-dev zlibc zlib1g zlib1g-dev
-
-# Compile nginx
-cd nginx-1.14.0
-./configure
-make
-make install
-
-# Move the conf file.
-cd /usr/local/nginx/sbin
-cp -r * /usr/local/sbin
-cp /NGINX/upstream_nginx.conf /usr/local/nginx/conf/
-mv /usr/local/nginx/conf/upstream_nginx.conf /usr/local/nginx/conf/nginx.conf
-
-# Run nginx
-
-cd /usr/local/sbin
-./nginx
-exit 0
-
diff --git a/demo/nginx_proxy/demo-2/startup.conf b/demo/nginx_proxy/demo-2/startup.conf
deleted file mode 100644
index 616cd88..0000000
--- a/demo/nginx_proxy/demo-2/startup.conf
+++ /dev/null
@@ -1,20 +0,0 @@
-unix {
- log /var/log/vpp/vpp.log
- cli-listen localhost:5002
- exec /etc/vpp/vpp_config
-}
-
-api-trace {
- on
-}
-
-cpu {
- main-core 2
-}
-
-dpdk {
- socket-mem 1024
- uio-driver igb_uio
- dev 0000:00:09.0
-}
-
diff --git a/demo/nginx_proxy/demo-2/udpclient.c b/demo/nginx_proxy/demo-2/udpclient.c
deleted file mode 100644
index 76e7b05..0000000
--- a/demo/nginx_proxy/demo-2/udpclient.c
+++ /dev/null
@@ -1,50 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-
-#define PORT 53
-#define MAXLINE 1024
-
-// Driver code
-int
-main ()
-{
- int sockfd;
- char buffer[MAXLINE];
- char *hello = "Hello from client";
- struct sockaddr_in servaddr;
-
- // Creating socket file descriptor
- if ((sockfd = socket (AF_INET, SOCK_DGRAM, 0)) < 0)
- {
- perror ("socket creation failed");
- exit (EXIT_FAILURE);
- }
-
- memset (&servaddr, 0, sizeof (servaddr));
-
- // Filling server information
- servaddr.sin_family = AF_INET;
- servaddr.sin_port = htons (PORT);
- servaddr.sin_addr.s_addr = inet_addr ("192.168.50.20");
-
- int n, len;
-
- sendto (sockfd, (const char *) hello, strlen (hello),
- MSG_CONFIRM, (const struct sockaddr *) &servaddr,
- sizeof (servaddr));
- printf ("Hello message sent.\n");
-
- n = recvfrom (sockfd, (char *) buffer, MAXLINE,
- MSG_WAITALL, (struct sockaddr *) &servaddr, &len);
- buffer[n] = '\0';
- printf ("Server : %s\n", buffer);
-
- close (sockfd);
- return 0;
-}
diff --git a/demo/nginx_proxy/demo-2/udpserver.c b/demo/nginx_proxy/demo-2/udpserver.c
deleted file mode 100644
index 456c7fc..0000000
--- a/demo/nginx_proxy/demo-2/udpserver.c
+++ /dev/null
@@ -1,55 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-
-#define PORT 53
-#define MAXLINE 1024
-
-int
-main ()
-{
- int sockfd;
- char buffer[MAXLINE];
- char *hello = "Hello from server";
-
- struct sockaddr_in servaddr, cliaddr;
- char name[128] = { 0 };
-
- // Creating socket file descriptor
- if ((sockfd = socket (AF_INET, SOCK_DGRAM, 0)) < 0)
- {
- perror ("socket creation failed");
- exit (EXIT_FAILURE);
- }
-
- memset (&servaddr, 0, sizeof (servaddr));
- memset (&cliaddr, 0, sizeof (cliaddr));
-
- // Filling server information
- servaddr.sin_family = AF_INET; // IPv4
- servaddr.sin_addr.s_addr = inet_addr ("182.167.50.30");
- servaddr.sin_port = htons (PORT);
-
- if (bind (sockfd, (const struct sockaddr *) &servaddr,
- sizeof (servaddr)) < 0)
- {
- perror ("bind failed");
- exit (EXIT_FAILURE);
- }
-
- int len, n;
- n = recvfrom (sockfd, (char *) buffer, MAXLINE,
- MSG_WAITALL, (struct sockaddr *) &cliaddr, &len);
- buffer[n] = '\0';
- (void) gethostname (name, 127);
- printf ("Client : %s \n", buffer);
- sendto (sockfd, (const char *) hello, strlen (hello),
- MSG_CONFIRM, (const struct sockaddr *) &cliaddr, len);
- printf ("%s\n", hello);
- return 0;
-}
diff --git a/demo/nginx_proxy/demo-2/upstream_nginx.conf b/demo/nginx_proxy/demo-2/upstream_nginx.conf
deleted file mode 100644
index 3904197..0000000
--- a/demo/nginx_proxy/demo-2/upstream_nginx.conf
+++ /dev/null
@@ -1,80 +0,0 @@
-#user nobody;
-worker_processes 1;
-#daemon off;
-
-#error_log logs/error.log;
-#error_log logs/error.log notice;
-#error_log logs/error.log info;
-
-#pid logs/nginx.pid;
-
-
-events {
- worker_connections 1024;
-}
-
-
-http {
- include mime.types;
- default_type application/octet-stream;
-
- #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
- # '$status $body_bytes_sent "$http_referer" '
- # '"$http_user_agent" "$http_x_forwarded_for"';
-
- #access_log logs/access.log main;
-
- sendfile on;
- #tcp_nopush on;
-
- #keepalive_timeout 0;
- keepalive_timeout 65;
-
- #gzip on;
-
- server {
- listen 80;
- #server_name localhost;
-
- #charset koi8-r;
-
- #access_log logs/host.access.log main;
-
- location / {
- return 200 "Hello from upstream $hostname $server_addr:$server_port. Connect from $http_x_real_ip - $remote_user via $remote_addr:$remote_port at [$time_local] $request $status $body_bytes_sent $http_referer $http_user_agent\n";
- }
-
- #error_page 404 /404.html;
-
- # redirect server error pages to the static page /50x.html
- #
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root html;
- }
-
- # proxy the PHP scripts to Apache listening on 127.0.0.1:80
- #
- #location ~ \.php$ {
- # proxy_pass http://127.0.0.1;
- #}
-
- # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
- #
- #location ~ \.php$ {
- # root html;
- # fastcgi_pass 127.0.0.1:9000;
- # fastcgi_index index.php;
- # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
- # include fastcgi_params;
- #}
-
- # deny access to .htaccess files, if Apache's document root
- # concurs with nginx's one
- #
- #location ~ /\.ht {
- # deny all;
- #}
- }
-
-}
diff --git a/demo/nginx_proxy/demo-2/vpp_config b/demo/nginx_proxy/demo-2/vpp_config
deleted file mode 100644
index aaeadfb..0000000
--- a/demo/nginx_proxy/demo-2/vpp_config
+++ /dev/null
@@ -1,6 +0,0 @@
-set int state GigabitEthernet0/9/0 up
-set int ip addr GigabitEthernet0/9/0 172.167.50.20/24
-show version
-show version verbose
-show cpu
-show int
diff --git a/demo/nginx_proxy/demo-3/NGINX_with_DMM_Demo.md b/demo/nginx_proxy/demo-3/NGINX_with_DMM_Demo.md
deleted file mode 100644
index 6deb348..0000000
--- a/demo/nginx_proxy/demo-3/NGINX_with_DMM_Demo.md
+++ /dev/null
@@ -1,26 +0,0 @@
-# Demo: NGINX working with multi-stack using DMM
-
-![image](rsocket.png)
-
-
-
-In above diagram NGINX box in the middle is working as reverse proxy.
-One of the NIC ( client facing) is using kernel tcp/ip stack whereas the
-other NIC is connected to upstream server using rsocket tcp/ip stack.
-
-you can use test.c to compile a server depend on libnStackAPI.so. It bind the
-port 8888 by default and you can change it to other port. Then copy the
-module_config.json rd_config.json to the folder of server. Then you can start the
-server as follow:
-./server 162.128.1.16
-
-####More Information:
-https://wiki.fd.io/view/DMM
-https://www.nginx.com/blog/ip-transparency-direct-server-return-nginx-plus-transparent-proxy/
-
-
-
-
-
-
-
diff --git a/demo/nginx_proxy/demo-3/proxy_nginx.conf b/demo/nginx_proxy/demo-3/proxy_nginx.conf
deleted file mode 100644
index fb085ac..0000000
--- a/demo/nginx_proxy/demo-3/proxy_nginx.conf
+++ /dev/null
@@ -1,81 +0,0 @@
-user root;
-worker_processes 1;
-daemon off;
-#error_log logs/error.log;
-#error_log logs/error.log notice;
-#error_log logs/error.log info;
-
-#pid logs/nginx.pid;
-
-
-events {
- worker_connections 1024;
-}
-
-
-http {
- include mime.types;
- default_type application/octet-stream;
-
- #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
- # '$status $body_bytes_sent "$http_referer" '
- # '"$http_user_agent" "$http_x_forwarded_for"';
-
- #access_log logs/access.log main;
-
- sendfile on;
- #tcp_nopush on;
-
- #keepalive_timeout 0;
- keepalive_timeout 65;
-
- #gzip on;
-
- server {
- listen 192.168.131.181:80 default_server;
- server_name 192.168.131.181;
-
- location / {
- proxy_bind 192.168.21.181;
- proxy_pass http://192.168.21.180:8888;
- proxy_set_header X-Real-IP $remote_addr;
- sendfile off;
- proxy_buffering off;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- }
-
- #error_page 404 /404.html;
-
- # redirect server error pages to the static page /50x.html
- #
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root html;
- }
-
- # proxy the PHP scripts to Apache listening on 127.0.0.1:80
- #
- #location ~ \.php$ {
- # proxy_pass http://127.0.0.1;
- #}
-
- # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
- #
- #location ~ \.php$ {
- # root html;
- # fastcgi_pass 127.0.0.1:9000;
- # fastcgi_index index.php;
- # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
- # include fastcgi_params;
- #}
-
- # deny access to .htaccess files, if Apache's document root
- # concurs with nginx's one
- #
- #location ~ /\.ht {
- # deny all;
- #}
- }
-
-
-}
diff --git a/demo/nginx_proxy/demo-3/rd_config.json b/demo/nginx_proxy/demo-3/rd_config.json
deleted file mode 100644
index 51fa4a5..0000000
--- a/demo/nginx_proxy/demo-3/rd_config.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "ip_route": [
- {
- "subnet": "192.168.131.1/24",
- "stack_name": "kernel",
- },
- {
- "subnet": "192.168.21.1/24",
- "stack_name": "rsocket",
- },
- ],
- "prot_route": [
- {
- "proto_type": "1",
- "stack_name": "rsocket",
- },
- {
- "proto_type": "2",
- "stack_name": "kernel",
- }
- ],
-}
-
diff --git a/demo/nginx_proxy/demo-3/rsocket.png b/demo/nginx_proxy/demo-3/rsocket.png
deleted file mode 100644
index 389ae19..0000000
--- a/demo/nginx_proxy/demo-3/rsocket.png
+++ /dev/null
Binary files differ
diff --git a/demo/nginx_proxy/demo-3/server/index.html b/demo/nginx_proxy/demo-3/server/index.html
deleted file mode 100644
index 9ab30e1..0000000
--- a/demo/nginx_proxy/demo-3/server/index.html
+++ /dev/null
@@ -1,31 +0,0 @@
-<!DOCTYPE html>
-
-<!--
-Copyright 2015 Google Inc.
-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.
--->
-
-<html>
-
-<head>
- <title>Hello, world</title>
- <link rel="stylesheet" href="/style.css">
- <script src="/script.js"></script>
-</head>
-
-<body>
- <h1>Hello, world</h1>
-
- <button onclick="fetchMessage()">Fetch Message</button>
- <p id="message">Click on the button to fetch the message.</p>
-</body>
-
-</html>
diff --git a/demo/nginx_proxy/demo-3/server/test.c b/demo/nginx_proxy/demo-3/server/test.c
deleted file mode 100644
index 9ffde09..0000000
--- a/demo/nginx_proxy/demo-3/server/test.c
+++ /dev/null
@@ -1,320 +0,0 @@
-/*
- * httpd.c
- *
- * Copyright Adin Scannell 2011
- *
- * This code is intended for demo purposes only,
- * please don't actually use it to do anything.
- *
- * To compile, use:
- * gcc -o httpd httpd.c
- * Then, create a file 'index.html' in the directory
- * that you are running the server from. Put stuff in
- * it.
- * Then go to http://localhost:8888 and see the file.
- */
-
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <sys/sendfile.h>
-#include <sys/stat.h>
-#include <arpa/inet.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <sys/mman.h>
-
-#define HTTP_BAD_REQUEST "HTTP/1.0 404 Not Found\r\n"
-#define HTTP_GOOD_REQUEST "HTTP/1.0 200\r\n"
-#define HTTP_CONTENT_TYPE "Content-Type: text/html\r\n"
-#define HTTP_CONTENT_LENGTH "Content-Length: %ld\r\n\r\n"
-#define MAX_REQUEST_SIZE 4096
-#define DEFAULT_PATH "index.html"
-
-#define DEBUG
-#ifdef DEBUG
-#define log(fmt, args...) fprintf(stderr, fmt "\n", ## args)
-#else
-#define log(fmt, args...)
-#endif
-
-int
-send_error (int fd)
-{
- write (fd, HTTP_BAD_REQUEST, strlen (HTTP_BAD_REQUEST));
- write (fd, HTTP_CONTENT_TYPE, strlen (HTTP_CONTENT_TYPE));
- return 0;
-}
-
-int
-send_file (int fd, char *path)
-{
- int iofd = open (path, O_RDONLY);
-
- int ret = 0;
- if (iofd < 0)
- {
- write (fd, HTTP_BAD_REQUEST, strlen (HTTP_BAD_REQUEST));
- write (fd, HTTP_CONTENT_TYPE, strlen (HTTP_CONTENT_TYPE));
- log ("error opening file");
- }
- else
- {
- char length[MAX_REQUEST_SIZE];
- struct stat statinfo;
- if (fstat (iofd, &statinfo) < 0)
- {
- /* Can't get the length. */
- write (fd, HTTP_BAD_REQUEST, strlen (HTTP_BAD_REQUEST));
- write (fd, HTTP_CONTENT_TYPE, strlen (HTTP_CONTENT_TYPE));
- log ("error fetching size");
- }
- else
- {
- ret = write (fd, HTTP_GOOD_REQUEST, strlen (HTTP_GOOD_REQUEST));
-
- log ("write HTTP_GOOD_REQUEST %s ret %d", HTTP_GOOD_REQUEST, ret);
- ret = write (fd, HTTP_CONTENT_TYPE, strlen (HTTP_CONTENT_TYPE));
- log ("write HTTP_CONTENT_TYPE %s ret %d", HTTP_CONTENT_TYPE, ret);
- snprintf (length, MAX_REQUEST_SIZE,
- HTTP_CONTENT_LENGTH, statinfo.st_size);
-
- ret = write (fd, length, strlen (length));
- log ("write %s ret %d", length, ret);
-
-#if 1
-#if 1
- //char *source = NULL;
- //source = malloc(sizeof(char) * (statinfo.st_size + 1));
- void *file_addr = NULL;
- file_addr =
- mmap (NULL, statinfo.st_size, PROT_READ, MAP_PRIVATE, iofd, 0);
-
- if (write (fd, file_addr, statinfo.st_size) < 0)
- {
- perror ("wyl new");
- }
-
-#else
-// if( write(fd, length, strlen(length)) < 0 ||
- if (sendfile (fd, iofd, NULL, statinfo.st_size) < 0)
- {
- /* Error sending the file. Nothing can be done. */
- perror ("error writing file");
- }
-#endif
-
-#endif
- close (fd);
- }
-
- close (iofd);
- }
-
- return 0;
-}
-
-int
-process (int fd, char *header)
-{
- char npath[MAX_REQUEST_SIZE];
-
- char *eol = strchr (header, '\r');
-
- /* Nuts to thread-safe, this demo uses it's own process :P */
- char *method = strtok (header, " ");
- char *path = strtok (NULL, " ");
- char *http = strtok (NULL, " ");
-
- if (eol != NULL)
- {
- *eol = '\0';
- }
-
- /* Debug output here, just in case anyone is watching. */
- log (" * method = %s", method);
- log (" * path = %s", path);
- log (" * http = %s", http);
-
- /* Ensure that we can process it. */
- if (strcmp (method, "GET") ||
- (strcmp (http, "HTTP/1.0") && strcmp (http, "HTTP/1.1")))
- {
- log ("bad request");
- return send_error (fd);
- }
- else
- {
- if (path[0] == '/' && path[1] == '\0')
- {
- path = DEFAULT_PATH;
- }
- else if (path[0] == '/')
- {
- snprintf (npath, MAX_REQUEST_SIZE, ".%s", path);
- path = npath;
- }
- log ("sending %s to %d", path, fd);
- return send_file (fd, path);
- }
-}
-
-int
-service (int fd)
-{
- char buffer[MAX_REQUEST_SIZE];
- int readbytes = 0, scanned = 0;
-
- /* Attempt to read a chunk of bytes, but not process forever. */
- while (readbytes < (MAX_REQUEST_SIZE - 1))
- {
- log ("read from %d", fd);
- int cur =
- read (fd, &(buffer[readbytes]), (MAX_REQUEST_SIZE - 1) - readbytes);
- if (cur < 0)
- {
- perror ("read failed");
- return -1;
- }
- else
- {
- buffer[readbytes + cur + 1] = '\0';
- readbytes += cur;
- }
-
- /* Check for the \n\n found at the end of the header. */
- for (; scanned < readbytes - 3; scanned++)
- {
- if (buffer[scanned] == '\r' && buffer[scanned + 1] == '\n' &&
- buffer[scanned + 2] == '\r' && buffer[scanned + 3] == '\n')
- {
- buffer[scanned] = '\0';
- return process (fd, buffer);
- }
- }
- }
-
- /* Failed to find the end of the header. */
- log ("header too long");
- return -1;
-}
-
-int
-main (int argc, char *argv[])
-{
-
- struct sockaddr_in servaddr;
- int serversock = socket (AF_INET, SOCK_STREAM, 0);
- int on = 1;
-
- if (NULL == argv[1])
- {
- log ("please set the ip argument");
- return 1;
- }
-
- /* Create socket. */
- if (serversock < 0)
- {
- perror ("error creating socket");
- return 1;
- }
-
- /* Tweak it for reuse. Not necessary for fork, just useful *
- * when one is killing and running this server a few times. */
- if (setsockopt (serversock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) < 0)
- {
- perror ("unable to tweak socket options");
- }
-
- /* Bind to port 8888. */
- memset (&servaddr, 0, sizeof (servaddr));
- servaddr.sin_family = AF_INET;
- //servaddr.sin_addr.s_addr = inet_addr("192.168.21.180");
- servaddr.sin_addr.s_addr = inet_addr (argv[1]);
- servaddr.sin_port = htons (8888);
- if (bind (serversock, (struct sockaddr *) &servaddr, sizeof (servaddr)) < 0)
- {
- perror ("couldn't bind to given address");
- return 1;
- }
- log ("bound to %s:8888", argv[1]);
-
- /* Start listening, queue size 10. */
- if (listen (serversock, 10) < 0)
- {
- perror ("listen failed");
- return 1;
- }
- log ("listening");
-
- /* Enter the service loop. */
- while (1)
- {
- int clientsock, pid, childstatus;
- log ("waiting for next request");
-
- /* Grab the next request. */
- clientsock = accept (serversock, NULL, NULL);
- if (clientsock < 0)
- {
- perror ("accept failed");
- break;
- }
- log ("accepted connection %d from %d, forking ", clientsock,
- serversock);
-
- /* Fork off a handler. */
- //pid = fork();
- pid = 0;
- if (pid < 0)
- {
- perror ("fork failed");
- close (clientsock);
- continue;
- }
- else if (pid > 0)
- {
- close (clientsock);
- }
- else
- {
- //close(serversock);
- log ("servicing connection (as child) sfd %d cfd %d", serversock,
- clientsock);
- service (clientsock);
- //return 0;
- }
-
- /* Collect any exit statuses (lazy). */
-
-#if 0
- while (1)
- {
- pid = waitpid (-1, &childstatus, WNOHANG);
- if (pid < 0)
- {
- perror ("waitpid error?");
- break;
- }
- else if (pid == 0)
- {
- break;
- }
- else if (WIFEXITED (childstatus))
- {
- log ("child %d exited with status %d", pid,
- WEXITSTATUS (childstatus));
- }
- }
-#endif
-
- }
-
- /* Should never arrive here. */
- return 254;
-}
diff --git a/doc/Build_DMM.md b/doc/Build_DMM.md
deleted file mode 100644
index fb35d2f..0000000
--- a/doc/Build_DMM.md
+++ /dev/null
@@ -1,111 +0,0 @@
-# 1. Introduction
-
- The purpose of this document is to illustrate how to build DMM and run applications on it.
-
-Note:
-
- Users can easily build DMM by running DMM/scripts/build.sh, which contains following steps.
-
-# 2. Build DPDK
-
- DPDK needs to be built first for DMM RTE memory dependency.
-
-- Steps:
-
- Download dpdk-18.02.tar.xz from DPDK release, you can get it from [http://static.dpdk.org/rel](http://static.dpdk.org/rel)
-
-```sh
- wget http://static.dpdk.org/rel/dpdk-18.02.tar.xz
- tar xvf dpdk-18.02.tar.xz
- vi dpdk-18.02/config/common_base
- //make CONFIG_RTE_BUILD_SHARED_LIB=y, CONFIG_RTE_EXEC_ENV=y, CONFIG_RTE_LIBRTE_EAL=y, CONFIG_RTE_EAL_PMD_PATH="/tmp/dpdk/drivers/"
- cd dpdk-18.02
- make install T=x86_64-native-linuxapp-gcc DESTDIR=/usr -j 4
- cd x86_64-native-linuxapp-gcc
- make # install the dpdk which will generate .so inside lib folder in the path.
- mkdir -p /tmp/dpdk/drivers/
- cp -f /usr/lib/librte_mempool_ring.so /tmp/dpdk/drivers/
-```
-
-Note:
- Under certain kernel versions (e.g. v3.10.0 adopted by CentOS 7.5), compiling DPDK with default
- configuration will encounter errors like below.
- `error: unknown field 'ndo_change_mtu' specified in initializer .no_change_mtu = kni_net_change_mtu`
- This is caused by `kni` compiling, disable `kni` in dpdk config file will figure it out.
- Actually, we have tested ubuntu 14.04 ~ 16.04, CentOS 7.2, and they worked well.
-
-# 3. Build DMM
-
-```sh
- cd $(DMM_DIR)/thirdparty/glog/glog-0.3.4/ && autoreconf -ivf
- cd $(DMM_DIR)/build
- cmake ..
-```
-
-Note:
- $(DMM_DIR) is the directory where dmm has been cloned.
- After cmake all the makefiles and dependent .sh files will be copied under build directory.
-
-```sh
- make -j 8
-```
-
- Then we can get libnStackAPI.so
-
- For centos we can use the command 'make pkg-rpm' to generate the rpm package in release/rpm.
-
-# 4. Build rsocket
-
-```sh
- cd $(DMM_DIR)/build
- make dmm_rsocket
-```
-
-Note:
- Make sure Mellanox OFED has been installed in your computer, or run the following command before compiling
-
-```sh
- cd $DMM_DIR/stacks/rsocket
- #Take ubuntu16.04 as an example, the tgz file has the format MLNX_OFED_LINUX-<ver>-<OS label><CPU arch>.tgz
- wget http://www.mellanox.com/downloads/ofed/MLNX_OFED-4.4-1.0.0.0/MLNX_OFED_LINUX-4.4-1.0.0.0-ubuntu16.04-x86_64.tgz
- tar -zxvf MLNX_OFED_LINUX-4.4-1.0.0.0-ubuntu16.04-x86_64.tgz
- cd MLNX_OFED_LINUX-4.4-1.0.0.0-ubuntu16.04-x86_64
- ./mlnxofedinstall --force
-```
-
-# 5. Env Setting
-
-- Hugepage setting:
-
-```sh
- sudo sysctl -w vm.nr_hugepages=1024
-```
-
-Check hugepage info
-
-```sh
- cat /proc/meminfo
-```
-
-- Mount hugepages:
-
-```sh
- sudo mkdir -p /mnt/nstackhuge/
- sudo mount -t hugetlbfs -o pagesize=2M none /mnt/nstackhuge/
- sudo mkdir -p /var/run/ip_module
-```
-
-# 6. Build and Run the APP
-
-- Link the app with the lib **libnStackAPI.so** first, you can refer to app_example/perf-test
-
-- Enable detail log of nstack by setting env var
-
-```sh
- export LD_LIBRARY_PATH=/dmm/release/lib64
- export NSTACK_LOG_ON=DBG
-```
-
-- Copy and update the module_config.json, rd_config.json into the same folder of app
-
-- Run your app
diff --git a/doc/DMM_DeveloperManual.md b/doc/DMM_DeveloperManual.md
deleted file mode 100644
index 51e4be5..0000000
--- a/doc/DMM_DeveloperManual.md
+++ /dev/null
@@ -1,1119 +0,0 @@
-![logo fd.io](../resources/logo_fdio-300x184.png)
-
-#**DMM Developer Manual**
-
-[**1. Introduction**](#1.-introduction)<br>
-[**2. DMM Overall Architecture**](#2.-dmm-overall-architecture)<br>
-[**3. Core Components**](#3.-Core-Components)<br>
-[**3.1 nSocket**](#3.1-nsocket)<br>
-[**3.2 Framework**](#3.2-framework)<br>
-[**3.3 Adapter**](#3.3-adapter)<br>
-[**3.4 nRD**](#3.4-nrd)<br>
-[**3.5 HAL**](#3.5-hal)<br>
-[**4 DMM Plug-in Architectures**](#4-dmm-plug-in-architectures)<br>
-[**4.1 Overview**](#4.1-overview)<br>
-[**4.2 Plug-in interface**](#4.2-plug-in-interface)<br>
-[**4.2.1 Interface of Stackx adapter APIs**](#4.2.1-interface-of-stackx-adapter-apis)<br>
-[**4.2.1.1 nstack\_stack\_register\_fn**](#4.2.1.1-nstack\_stack\_register\_fn)<br>
-[**4.2.2 Interface of DMM-adapter APIs**](#4.2.2-interface-of-dmm-adapter-apis)<br>
-[**4.2.2.1 nstack\_adpt\_init**](#4.2.2.1-nstack\_adpt\_init)<br>
-[**4.2.5 Multithreading**](#4.2.5-multithreading)<br>
-[**4.2.6 Resource recovery**](#**4.2.6-resource-recovery)<br>
-[**4.2.6.1 obj\_recycle\_reg**](#4.2.6.1-obj\_recycle\_reg)<br>
-[**4.2.6.2 obj\_recycle\_fun**](#4.2.6.2-obj\_recycle\_fun)<br>
-[**4.2.7 nRD**](#4.2.7-nrd)<br>
-[**5 Release file**](#5-release-file)<br>
-[**5.1 libs**](#5.1-libs)<br>
-[**5.2 Posix API of nSocket**](#5.2-posix-api-of-nsocket)<br>
-[**6 Log & Debug**](#6-log-debug)<br>
-[**7 How to use the incidental apps to test the protocol stack**](#7-how-to-use-the-incidental-apps-to-test-the-protocol-stack)<br>
-[**7.1 App introduction**](#7.1-app-introduction)<br>
-[**7.2 Test implementation**](#7.2-Test-implementation)<br>
-
-**1. Introduction**<br>
-============================
-
-This document is used to guide the user-mode protocol stack developers to use
-the DMM(Dual mode Multi protocol Multi instance) framework. The document defines the
-interface that need to be registered to the DMM when the protocol stack is integrated into the
-DMM and the interface that the DMM provides to the protocol stack. In the document as well
-as in the code, DMM is also referred as nStack(NeuroStack). The two names are interchangeable.
-
-**2. DMM Overall Architecture**<br>
-============================
-
-![nstack architecture](../resources/nStack_Architecture.png)
-
-Figure1. DMM bird's eye view.
-
-The DMM framework provides posix socket APIs to the application. A protocol stack could be
-plugged into the DMM. DMM will choose the most suitable stack according to the policy
-of nRD to application. nRD(Neuro Resource Discovery) is a control sub system which is used
-to choose a protocol stack for application based on certain rules, such
-as network information,
-SLA, security and so on. The mapping between apps (connections/sockets) and candidate
-networking stack instances is now use static configurations.
-
-**3. Core Components**<br>
-============================
-
-Figure1 shows an overview of the architecture design for DMM. DMM can be divided into
-five main components: nSocket, Framework (FW), adapters, nRD, and HAL.
-
-**3.1 nSocket**
------------
-
-“nSocket†provides user-friendly POSIX Compatible API of nStack, it intercepts the socket
-API calls from the user application via system call hijacking or the LD_PRELOAD mechanism.
-
-**3.2 Framework**
--------------
-
-Framework is a public framework module that includes shared-memory management, IPC-management,
-initialization framework, basic data structures and timer.
-
-**3.3 Adapter**
------------
-
-**nStack-adapter:** Used by protocol stack and implemented by DMM. Provides interfaces towards DMM.
-
-**Stack-x-adapter:** Used by DMM and implemented by protocol stack. Provides interfaces
-towards protocol stack.
-
-**Kernel-adapter:** Used and implemented by DMM. Help interact with kernel stack.
-
-**3.4 nRD**
--------
-![RD topology](../resources/RD_Topo.PNG)
-
-nStack provides dynamic mapping between apps (connections/sockets) and candidate
-networking stack instances. And this flexibility is achieved by the nRD.
-
-**3.5 HAL**
--------
-
-HAL (Hardware Abstraction Layer) layer provides the following functions for upper-layer
-protocol stack:
-- A unified user plane IO interface, shields the lower-level driver implementation differences.
-- Mask the port implementation differences between IO layer and Protocol stack. Initialize
-the network interface card.
-
-
-**4 DMM Plug-in Architectures**<br>
-=========================
-
-**4.1 Overview**
-------------
-
-DMM-Plug-in architecture is an attractive solution for developers seeking to build protocol
-stacks that are multi-functional, app independent, and easily extensible.
-![integration of DMM with protocol stack](../resources/Integration.png)
-
-Figure3. The Integration scheme
-
-Figure 3 shows a typical deployment mode that protocol stack and application process are
-deployed in a pipeline mode across processes. IPC is used for communication between them.
-
-+ DMM need to integrate the protocol stack adapter-library (Figure 3: stack-x adapter). The library
-should be developed by protocol stack, and the library implements the interfaces defined in
-the list1. The protocol stack adapter is used for communicating with protocol stack process.
-In addition to the function of the protocol stack, this module must implement the interfaces
-defined by DMM, including the socket APIs, epoll APIs, fork APIs and the resource recycle APIs.
-
-| Interface | detail |
-| --------- | ------ |
-| ep\_ctl | Section 4.2.2.1 |
-| ep\_getevt | Section 4.2.2.2 |
-| fork\_init\_child | Section 4.2.4.1 |
-| fork\_parent\_fd | Section 4.2.4.2 |
-| fork\_child\_fd | Section 4.2.4.3 |
-| fork\_free\_fd | Section 4.2.4.4 |
-| module\_init | Section 4.3.5.5 |
-
-List1. The function provided by protocol adapter.
-
-+ Protocol stack needs to integrate the DMM adapter-library(Figure 3: nstack adapter). This library
-will be developed by DMM. It creates and initializes shared-memory. The shared-memory
-is used as IPC to achieve high performance communication between nStack and protocol stack.
-The library utilizes the plug-in interface to provide rich features to the protocol stack, such as
-resource recycle and event management.
-
-+ Protocol stack needs to call the nstack\_adpt\_init (See section 4.2.1.6 for details) defined
-in the DMM adapter library to create and initialize the shared memory object used for IPC.
-DMM adapter library also provide functions to recycle shared memory objects (See section 4.2.6.2
-for details) to the protocol stack. When protocol stack receive the app exit signal, DMM adapter
-handle the exit signal, and trigger shared resource recovery action. Protocol stack does not
-need to focus on the exit of the application.
-
-+ In the dual process mode, protocol stack process creates shared memory and initialize
-it with the help of DMM adapter library where as application
- process looks up and
- attaches to the shared memory .
-
-+ nRD module reads the routing information from the configuration file to create a mapping
-system which used to make a decision as nSocket selects the protocol stack.
-
-With these modules, DMM provides a unified socket interface, and support epoll, select,
-fork, zero copy, resource recovery features.
-
-**4.2 Plug-in interface**
----------------------
-
-###**4.2.1 Interface of Stackx adapter APIs**
-
-The following adapter APIs must be implemented by the protocol stack as part of stackx adapter.
-Hook functions which will be initialize in this function will be used later to communicate with
-stackx later.
-
-**4.2.1.1 nstack\_stack\_register\_fn**
-
-Function prototype:
-
-```
-typedef int (*nstack_stack_registe_fn) (nstack_proc_cb *proc_fun, nstack_event_cb *event_ops);
-
-```
-There are two parameters in this function.
-
-nstack\_proc\_cb: Has two parts, socket operations, which is defined in declare\_syscalls.h.tmpl
-file and is same is in Posix, and nstack\_extern\_ops, are some other functionality like module
-initialization etc.
-```
-typedef struct __nstack_proc_cb
-{
- nstack_socket_ops socket_ops; /*posix socket api */
- nstack_extern_ops extern_ops; /*other proc callback */
-} nstack_proc_cb;
-
-typedef struct __nstack_extern_ops
-{
- int (*module_init) (void); /*stack module init */
- int (*fork_init_child) (pid_t p, pid_t c); /*after fork, stack child process init again if needed. */
- void (*fork_parent_fd) (int s, pid_t p); /*after fork, stack parent process proc again if needed. */
- void (*fork_child_fd) (int s, pid_t p, pid_t c); /*after fork, child record pid for recycle if needed. */
- void (*fork_free_fd) (int s, pid_t p, pid_t c); /*for SOCK_CLOEXEC when fork if needed. */
- unsigned int (*ep_ctl) (int epFD, int proFD, int ctl_ops, struct epoll_event * event, void *pdata); /*when fd add to epoll fd, triggle stack to proc if need */
- unsigned int (*ep_getevt) (int epFD, int profd, unsigned int events); /*check whether some events exist really */
- int (*ep_prewait_proc) (int epfd);
- int (*stack_fd_check) (int s, int flag); /*check whether fd belong to stack, if belong, return 1, else return 0 */
- int (*stack_alloc_fd) (); /*alloc a fd id for epoll */
- int (*peak) (int s); /*used for stack-x , isource maybe no need */
-} nstack_extern_ops;
-
-
-/*
- *Standard api interface definition.
- *these interface is provided by Protocol stack to nStack
- */
-typedef struct __nstack_socket_ops
-{
-#undef NSTACK_MK_DECL
-#define NSTACK_MK_DECL(ret, fn, args) ret (*pf##fn) args
-#include "declare_syscalls.h"
-} nstack_socket_ops;
-
-```
-nstack\_event\_cb:
-
-```
-typedef struct __nstack_event_cb
-{
- void *handle; /* current so file handler */
- int type; /* nstack is assigned to the protocol stack and needs to be passed to nstack when the event is reported */
- int (*event_cb) (void *pdata, int events);
-} nstack_event_cb;
-
-```
-
-When the protocol stack(a.k.a stackx) is integrated into DMM, there are some changes required
-to be done in DMM. These are as follows:
-
-The first step is adding new protocol stack module information into DMM. This information can be
-registed to DMM and **g\_nstack\_module\_desc** will store these configuration information,
-e.g. registration function name, lib path, etc.
-
-
-```
-nstack_module_keys g_nstack_module_desc[] ={};
-
-typedef struct _ nstack_module_keys {
- const ns_char* modName; /*stack name*/
- const ns_char* registe_fn_name; /*stack register func name*/
- const ns_char* libPath; /*if libtype is dynamic, it is the path of lib*/
- ns_char deploytype; /*depoly model type: model type1, model type2, model type3*/
- ns_char libtype; /*dynamic lib or static lib*/
- ns_char ep_free_ref; /*when epoll information free, need to wait that stack would not
- notify event */
- ns_char default_stack; /*whether is default stack: when don't know how to choose stack,
- just use default stack firstly*/
- ns_int32 priority; /*reserv*/
- ns_int32 maxfdid; /* the max fd id, just used to check*/
- ns_int32 minfdid; /* the min fd id, just used to check */
- ns_int32 modInx; /* This is alloced by nStack , not from configuration */
-} nstack_module_keys;
-
-
-typedef enum {
- NSTACK_MODEL_TYPE1, /*nSocket and stack belong to the same process*/
- NSTACK_MODEL_TYPE2, /*nSocket and stack belong to different processes,
- *and nStack don't take care the communication between stack and stack adpt*/
- NSTACK_MODEL_TYPE3, /*nSocket and stack belong to different processes, and stax-x-adapter was
- spplied to communicate whit stack*/
- NSTACK_MODEL_INVALID,
-} nstack_model_deploy_type;
-
-```
-Some important fields are:
-
-**ep\_free\_ref :**
-This field in data structure nstack\_module\_keys is used in pipe-line mode. When the application
-process exits, the socket resources in the application process are released, but the
-resources in the protocol stack are not released. At this time, the protocol stack needs
-to continue accessing the epoll shared resource to send events. So, you cannot free the resources
-of epoll immediately after the application exits. Only when the resources of the
-protocol stack are completely released, the epoll share resource can be released and it is
-done by the interface provided by the DMM adapter. This field marks whether the stack
-needs to release the epoll resources. If it is 1, DMM will not release resources when close
-is called, and the stack must calls the interface provided by DMM adapter to release
-after releasing its own resources. If it is 0, DMM(nSocket) released the source directly.
-
-**modInx :**
-Then module index unique number to identify the module.
-
-**maxfdid and minfdid:**
-Maximum and minimum FD supported.
-
-**libpath :**
-lib name with path provided by stack.
-
-**deploytype :**
-Indicating single or multi process deployment. Used during shared memory initialization.
-
-**libtype :**
-Indicates dynamic or static library.
-
-**default_stack :**
-During decision making of which stack to use if no stack is available default stack will be used.
-
-**registe_fn_name :**
-This is actual function name for nstack\_stack\_register\_fn and will be called by nstack,
-during protocol stack initialization.
-
-After calling the nstack\_stack\_registe_fn() (See section 4.2.1.1 for details) , the information
-initialized(e.g. hook function etc.) by the protocol stack adapter (stackx) will be stored in
-nstack\_module\_info along with other corresponding key stack information.
-
-```
-nstack_module_info g_nstack_modules;
-
-typedef struct{
- ns_int32 modNum; // Number of modules registered
- ns_int32 linuxmid;
- ns_int32 spmid; /* Stackx module index. */
- nstack_module *defMod; // The default module
- nstack_module modules[NSTACK_MAX_MODULE_NUM];
-} nstack_module_info;
-
-
-typedef struct __NSTACK_MODULE {
- char modulename[NSTACK_PLUGIN_NAME_LEN];
- ns_int32 priority;
- void* handle;
- nstack_proc_cb mops;
- ns_int32 ep_free_ref; //ep information need free with ref
- ns_int32 modInx; // The index of module
- ns_int32 maxfdid; //the max fd id
- ns_int32 minfdid; //the min fd id
-} nstack_module;
-
-```
-
-So far we discussed about stackx adapter and what change we need in DMM to integrate
-stackx with DMM. Now one thing is worth mentioning here, that how nstack implemented epoll
-mechanism, so that it will be easy to support epoll feature by protocol stack(stackx).
-
-###**epoll Architecture**
-When the application calls epoll\_create() or socket(), nstack first creates epoll info
-object of the data type of nsep\_epollInfo\_t. This structure stored the FD information of socket
-fd or epoll fd. fdtype denotes if this structure referring to an epoll or a socket.
-
-```
-typedef struct{
- int iindex;
- int iNext;
- int fd;
- i32 fdtype; /* 0: socket fd, 1: epoll fd */
- i32 rlfd; /* copy of fdInf->rlfd */
- i32 rmidx; /* copy of fdInf->rmidx */
- i32 protoFD[NSEP_SMOD_MAX];
- i32 epaddflag[NSEP_SMOD_MAX];
- struct eventpoll *ep;
- sys_sem_st epiLock;
- sys_sem_st freeLock;
- struct ep_list epiList; /* This restore the epitem of this file descriptor */
- u32 sleepTime; /* add for NSTACK_SEM_SLEEP */
- nsep_pidinfo pidinfo;
- nsfw_res res_chk;
- void* private_data;
- i32 reserv[4];
-} nsep_epollInfo_t;
-
-```
-
-For epoll then it creates an eventpoll (struct eventpoll) object.
-
-```
-struct eventpoll {
- sys_sem_st lock; /*eventpoll lock*/
- sys_sem_st sem; /* rdlist lock */
- sem_t waitSem; /*sem for epoll_wait */
- struct ep_hlist rdlist; /*ready epitem list*/
- struct ep_hlist txlist; /*pad*/
- struct ep_rb_root rbr; /* rbtree*/
- int epfd; /*epoll fd*/
- u32 pid; /* Pid of the process who creat the structure, the resources used to release */
- nsfw_res res_chk; /* Verify whether resources are repeatedly released */
-};
-```
-
-For the created nsep\_epollInfo\_t object, when the file descriptor is an epoll socket,
-ep(nsep_epollInfo_t) points to eventpoll. When the application calls epoll\_ctl() to add a
-socket to the epoll, nSocket allocates an epitem object. The fd is socket fd which need to add
-to epoll object.
-
-```
-struct epitem {
- struct ep_rb_node rbn;
- struct ep_hlist_node rdllink;
- struct ep_hlist_node lkFDllink;
- int nwait;
- struct eventpoll *ep;
- nsep_epollInfo_t *epInfo;
- struct epoll_event event;
- struct list_node fllink;
- struct ep_hlist_node txlink;
- unsigned int revents;
- int fd;
- u32 pid;
- void* private_data;
- nsfw_res res_chk;
-};
-
-```
-The epitem object is added to two places, rbr (a redblack tree of struct eventpoll) and
-also epList (nsep\_epollInfo\_t), which is created during epoll_create(basically this is
-of fdtype epoll) in the previous step. In the epitem object just allocated, nstack uses ep to
-point back to eventpoll, revents to store event that is produced by the protocol stack, epinfo
-to point to the epoll object in the data type of nsep\_epollInfo\_t. This is how DMM connects
-the epoll, event, and socket together.
-
-When the application calls epoll\_wait(), nSocket scans the rdlist in eventpoll to get
-events and return them to the application.
-
-Figure 3 is Runtime Graphs of nSocket in epoll function:
-
-![ePoll flow chart](../resources/Epoll_flwChart.png)
-
-Figure 4: flow chart of various epoll functions function:
-
-
-Below are the details of hook functions provided by protocol stack.
-
-###**ep\_ctl**
-```
-unsigned int (*ep_ctl) (int epFD, int proFD, int ctl_ops, struct epoll_event * event, void *pdata);
-```
-
-**Description:**
-1\. Called by the nstack to inform protocol stack to add/modify/delete file descriptor (FD)
-to/from epoll and monitor events.
-2\. When the application adds new events or modifies existing events, it gets prompt notification.
-3\. pdata stores the nsep_epollInfo_t corresponding to the FD. It is used to pass the
-value to the protocol stack event notification API when an event occurs.
-
-**Parameters:**
-
-*proFD*: sock file descriptor created by the protocol stack.
-*ctl\_ops*: 0 add, 1 modify, 2 delete.
-*event*: similar to Linux “struct epoll\_eventâ€.
-*pdata*: Private data (nsep_epollInfo_t ) that nstack passes to the protocol stack.
-
-**Interface implemented by:** Protocol stack.
-
-###**ep\_getevt**
-
-**Interface Definition:**
-
-```
-unsigned int (*ep_getevt) (int epFD, int profd, unsigned int events);
-```
-
-**Description:**
-
-To check if an event in protocol stack exist. Due to multi-threading or other reasons, it’s
-possible that protocol stack is busy and causes delay in event notification. Or event
-may be cleared by some application operation. Application may use the API to check whether
-the event still exists.
-
-**Parameters:**
-
-*epFD*: epoll FD.
-*proFD*: sock file descriptor created by the protocol stack.
-*event*: Events which need to check.
-
-**Interface implemented by:** Protocol stack.
-
-Similar to epoll, select functionality is also implemented by nstack.
-###**select**
-
-Select requires the protocol stack adapter module to provide a select API in order to query
-for existing events. When the application calls select(), nStack starts a separate thread to
-fetch the select event for each stack and sends it back to the application.
-
-![select flowchart](../resources/SelectFunc.png)
-
-Figure 6: flow chart of select function
-
-**pfselect**
-
-```
-int *pfselect(int s, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, struct timeval* timeout)
-```
-
-**Description:**
-
-Query whether there is a corresponding protocol stack event.
-
-**Parameters:**
-
-*s*: The maximum file descriptor value in the collection
-*readfds*: file descriptor set will be watched for read event
-*writefds*: file descriptor set will be watched for write event
-*exceptfds*: file descriptor set will be watched for exception cases
-
-**Interface implemented by:** Protocol Stack
-
-nStack also provide fork support. stackx adapter need to implement fork hook functions.
-###**fork**
-
-fork() creates a child process by making an exact duplicate of the calling process in a
-separate address spaces. Each process, parent and child, has its
-own process address
-space where memory segments, such as code segment, data segment, stack segment, etc.,
-are placed.
-
-There are few exceptions to this.
-
-1\. The fork system call duplicates all the file descriptors of the parent into the child,
-so that the file descriptors in the parent and child point to the same files.
-2\. The shared memory is still shared between parent and child process after fork ().
-3\. Child process clones only thread, which executed it.
-
-When parent process or child process releases the shared resources on process quit or
-kill, it affects the other process. Also if the child process wants to inherit other threads
-in the parent process, the child process needs to pull or create those threads after the
-fork. Both parent and child process can access the shared memory, it create conflicts.
-Because of these issues, DMM provides the fork APIs to take care of processing before
-and after calling the Linux fork interface. It includes interface lock and shared resource lock,
-reference count incrimination, saving the PID of the sub processes, reinitialization
-and SOCK\_CLOEXEC option in socket special handlings. Each shared memory data structure
-in nstack contains a reference count and a list of process pids, so that the shared memory
-can be managed between parent and child processes. On each fork, the reference count is
-increased by 1 and the child process id is added to the pid array.
-
-```
-typedef struct
-{
- u32 pid_used_size;
- u32 pid_array[NSTACK_FORK_NUM];
-} nsep_pidinfo;
-
-```
-
-DMM needs assistance from protocol stack to release or hold the shared resources. Protocol
-stack is to provide stack specific implementation on these DMM APIs.
-
-The following flow chart shows how fork process is handled:
-
-![fork process handling](../resources/ForkChild.png)
-
-###**fork\_init\_child**
-
-
-```
-int (* fork_init_child) (pid_t p, pid_t c)
-```
-
-**Description:**
-
-After fork, the API is used to add child process pid into the pid list in the share socket data
-structure. When the child process exits, only the resources in the child process are released
-unless the shared resource reference count reaches 0.
-
-**Parameters:**
-
-*p*: parent process pid
-
-*c*: child process pid
-
-
-**Interface Implemented by:** Protocol stack.
-
-###**fork\_parent\_fd**
-
-```
-void (* fork_parent_fd)(int s, pid_t p)
-```
-
-**Description:**
-
-For the socket with the SOCK_CLOEXEC flag on, when it is closed after fork, only the file
-descriptor is recycled, no other resource is released. It is a special treatment for SOCK_CLOEXEC.
-
-**Parameters:**
-
-*s*: socket fd
-
-*p*: parent process pid
-
-**Interface Implemented by:** Protocol stack.
-
-###**fork\_child\_fd**
-
-```
-void (* fork_child_fd) (int s, pid_t p, pid_t c);
-```
-
-**Description:**
-
-After fork, the API is used to add child process pid into the pid list in the share socket data
-structure. When the child process exits, only the resources in the child process are released
-unless the shared resource reference count reaches 0.
-
-**Parameter Description:**
-
-*s*: file descriptor of the socket to be operated
-
-*p*: parent process pid
-
-*c*: child process pid
-
-**Interface Implemented by:** Protocol stack.
-
-###**fork\_free\_fd**
-
-```
-void (* fork_free_fd) (int s, pid_t p, pid_t c);
-```
-
-**Description:**
-
-For the socket with the SOCK\_CLOEXEC flag on, when it is closed after fork, only the file
-descriptor is recycled, no other resource is released. It is a special treatment for SOCK\_CLOEXEC.
-
-**Parameters:**
-
-*s*: socket fd.
-
-*p*: parent process pid.
-
-*c*: child process pid.
-
-**Interface Implemented by:** Protocol stack
-
-###**4.2.2 Interface of DMM-adapter APIs**
-
-For the multi-process model, DMM provide a library with resource initialization, resource
-recycling, event notification and other functions to the
-protocol stack.
-nstack\_adpt\_init will initialize those functions which can be used by protocol stack(stakx).
-
-**4.2.2.1 nstack\_adpt\_init**
-
-Function prototype:
-
-```
-int nstack_adpt_init (nstack_dmm_para * para);
-
-```
-
-```
-typedef struct nsfw_com_attr
-{
- int policy;
- int pri;
-} nsfw_com_attr;
-
-typedef struct __nstack_dmm_para
-{
- nstack_model_deploy_type deploy_type;
- int proc_type;
- nsfw_com_attr attr;
- int argc;
- char **argv;
-} nstack_dmm_para;
-
-```
-
-Some important fields are:
-
-
-** deploy\_type : **
-Decides whether protocol stack is deployed in same process along with DMM or in a separate process.
-
-** proc_type: **
-In multi process environment, the process type will identify the process in framework.
-Framework may take different action for resource allocation/initialization based on process type.
-```
-
- typedef enum _fw_poc_type
-{
- NSFW_PROC_NULL = 0,
- NSFW_PROC_MAIN,
- NSFW_PROC_APP,
- NSFW_PROC_CTRL,
- NSFW_PROC_TOOLS,
- NSFW_PROC_ALARM,
- NSFW_PROC_MAX = 16
-} fw_poc_type;
-
-```
-DMM adapter also provides utility function to free shared epoll resource, in case APP process exit.
-
-**nsep\_force\_epinfo\_free**
-
-```
-int (*nsep_force_epinfo_free)(void *pdata)
-```
-
-**Description:**
-
-When closes fd, the protocol stack frees the resources related to fd. This API is called by
-the protocol stack to release private data of type nsep_epollInfo_t.
-
-**Precautions for use:**
-
-This API should only be called when ep\_free\_ref is configured 1 in
-nstack\_module\_keys.
-
-**Parameters:**
-
-*pdata*: pdata is the private data in ep\_ctl(), type nsep_epollInfo_t.
-
-**Interface implemented by:** DMM
-
-**nsep\_force\_epitem_free**
-
-```
-int (*nsep_force_epitem_free)(void *pdata)
-```
-
-**Description:**
-
-When closes fd, the protocol stack frees the resources related to fd. This API is called by the protocol stack to release private data of type struct epitem.
-
-**Precautions for use:**
-
-This API should only be called when ep\_free\_ref is configured 1 in
-nstack\_module\_keys.
-
-**Parameters:**
-
-*pdata*: pdata is the private data in ep\_ctl(), type epitem.
-
-**Interface implemented by:** DMM
-
-**nsep\_force\_epevent\_free**
-
-```
-int (*nsep_force_epitem_free)(void *pdata)
-```
-
-**Description:**
-
-When closes fd, the protocol stack frees the resources related to fd. This API is called by the
-protocol stack to release private data of type struct eventpoll.
-
-**Precautions for use:**
-
-This API should only be called when ep\_free\_ref is configured 1 in
-nstack\_module\_keys.
-
-**Parameters:**
-
-*pdata*: pdata is the private data in ep\_ctl(), type struct eventpoll.
-
-**Interface implemented by:** DMM
-
-
-### **4.2.5 Multithreading**
-
-nSocket supports multi-thread. nSocket uses a ref and state to support the feature.
-
-### **4.2.6 Resource recovery**
-
-Protocol stack must implement resource recovery. When the application crashes or exits,
-the resources allocated by protocol stack must be released, otherwise it causes resource leaking
-and can crash the system. DMM provides the following mechanism to support the feature.
-There is certain relationship between resource recovery and fork. Each fork increases
-the reference count by 1 and saves the child process PID to the corresponding shared resource.
-On exiting of the process, decreases the reference count by 1 if the exiting process PID
-equals to one of the saved PIDs and releases the shared resource if the reference count is 0,
-do not release the shared resource if the reference count in not zero.
-
-1. There are two kinds of resource recovery, normal exit and abnormal process exit. Resources
-are freed on normal exit operation. But on the abnormal process exits, there is no one to
-clean up the shared resources or decrease the reference count, so we rely on the separate
-process to monitor the processes and notify the stack process to release the resources.
-
-2. To support resource recovery, the protocol stack needs to define a resource object type
-in responding to DMM request and registers the recycle function at initialization time.
-
-**4.2.6.1 nsfw\_recycle\_reg\_obj**
-During initilization of stackx process, when calling nstack\_adpt\_init
-nsfw\_recycle\_reg\_obj will be called to register the object type that need to be recycled if the APP process exit.
-
-```
-typedef enum _nsfw_recycle_item_type
-{
- NSFW_REC_TYPE_NULL = 0,
- ...
- NSFW_REC_NSOCKET_START,
- NSFW_REC_NSOCKET_EPOLL,
- NSFW_REC_NSOCKET_END = NSFW_REC_NSOCKET_START + 63,
- NSFW_REC_TYPE_MAX = 512
-} nsfw_recycle_item_type;
-
-```
-For each item type a register function need to provide.
-**4.2.6.2 nsfw\_recycle\_reg_fun**
-Register recycle function for a record type.
-
-```
-u8 nsfw_recycle_reg_fun (u16 rec_type, nsfw_recycle_fun fun);
-
-typedef nsfw_rcc_stat (*nsfw_recycle_fun) (u32 exit_pid, void *pdata,
- u16 rec_type);
-```
-This function will be called when APP process exit notification will be send to StackX process.
-###**4.2.7 nRD**
-
-LRD function is mainly the protocol stack routing function, the internal storage of a protocol
-stack selection policy table. When multiple protocol stacks are integrated, according
-to the incoming IP address, protocol stack type and other information, you can select a suitable
-protocol stack from the protocol Stack selection policy table. During nSocket module
-initialization, it invokes the LRD module initialization API to register the protocol stack information
-and the protocol stack selection policy gets the interface. The initialization function
-for the LRD module is defined as follows.
-
-```
-int nstack_rd_init (nstack_stack_info *pstack, int num, nstack_get_route_data *pfun, int fun_num)
-
-typedef struct __nstack_rd_stack_info
-{
- /*stack name */
- rd_stack_plane_map stack;
- /*stack id */
- int stack_id;
- /*when route info not found, high priority stack was chose, same priority chose fist input one */
- int priority; /*0: highest: route info not found choose first */
-} nstack_rd_stack_info;
-
-/*rd local data*/
-typedef struct __rd_local_data {
- nstack_rd_stack_info *pstack_info;
- int stack_num;
- nstack_rd_list route_list[RD_DATA_TYPE_MAX]; /*route table */
- nstack_get_route_data sys_fun[NSTACK_SYS_FUN_MAX]; /*rd data sys proc function list */
- int fun_num;
-} rd_local_data;
-
-rd_local_data *g_rd_local_data = NULL;
-
-/*get rd info. if return ok, data callee alloc memory, caller free, else caller don't free*/
-int (*nstack_get_route_data)(rd_route_data **data, int *num);
-
-```
-
-When a new protocol stack is integrated into DMM, the protocol stack selection configuration
-file will not directly match with the protocol stack name, but
-with the plane name,
-which is more descriptive about stack and other interface
-technology, therefore
-the RD has a map between the protocols stack and plane name.
-
-```
-typedef struct __rd_stack_plane_map{
- char stackname[STACK_NAME_MAX]; /* Stack name */
- char planename[RD_PLANE_NAMELEN]; /* Plane name */
- int stackid; /*stack id */
-} rd_stack_plane_map;
-
-rd_stack_plane_map g_nstack_plane_info[] = {
- {{“stackxâ€}, {“nstack-dpdkâ€} , -1},
- {{“kernelâ€}, {“nstack-linuxâ€} , -1},
-};
-
-```
-When application calls the DMM socket, connect, sendto, sendmsg APIS, it triggers the nSocket
-module to invoke the nstack\_rd\_get\_stackid() API to get the route information. The protocol
-stack is then selected based on the returned protocol stack ID.
-
-**nstack\_rd\_init**
-
-```
-int nstack_rd_init (nstack_stack_info * pstack, int num, nstack_get_route_data *pfun, int fun_num)
-```
-
-**Description:**
-
-This function Initializes the RD module. When initialized, nStack passes all the integrated protocol
-stacks information to the RD module. The information includes the protocol stack name, stack id etc.
-The stack informations stored in g\_rd\_local\_data.
-
-**Parameters:**
-
-*pStack*: a list of the protocol stack info
-*num*: the number of protocol stack info passed in.
-*pfun*: function to get the protocol stack selection information.
-*fun_num*: the number of pfun passed in
-
-**Interface implemented by:** DMM
-
-**nstack\_get\_route\_data**
-
-```
-typedef int (*nstack_get_route_data) (rd_route_data ** data, int *num);
-```
-
-**Description:**
-
-Obtain the protocol stack selection information according to the protocol stack plane name.
-
-**Parameters:**
-
-*planename*: description on stack and other interface technology. nSocket provides
-the protocol stack name. The configuration file saves an outbound interface type, which
-is corresponding to a protocol stack.
-*data*: protocol stack selection information.
-
-```
-typedef enum __rd_data_type{
- RD_DATA_TYPE_IP, / * According to the ip address to select the protocol stack * /
- RD_DATA_TYPE_PROTO, / * Select protocol stack by protocol type * /
- RD_DATA_TYPE_MAX,
-}rd_data_type;
-
-typedef struct __rd_route_data{
- rd_data_type type; / * Stored protocol stack selection type * /
- char stack_name[RD_PLANE_NAMELEN]; / * Stack plane name */
- union {
- rd_ip_data ipdata; / * Select the IP address of the protocol stack type * /
- unsigned int proto_type; / * Select protocol information for this stack * /
- };
-} rd_route_data;
-
-```
-
-*num*: The number of routing information returned.
-
-**Interface implemented by:**DMM
-
-**nstack\_rd\_get\_stackid**
-
-```
-int nstack_rd_get_stackid(nstack_rd_key* pkey, int *stackid) ;
-```
-
-**Description:**
-
-Select parameters according to the protocol stack to obtain the protocol stack id corresponding to
-the parameter.
-
-**Parameter:**
-
-*pkey*: protocol stack selection key.
-
-```
-typedef struct __nstack_rd_key{
- rd_data_type type; / * Select protocol type parameters * /
- union {
- unsigned int ip_addr; / * This field is valid if the type is RD_DATA_TYPE_IP, which is
- the IP address of the connection to be initiated * /
- unsigned int proto_type; / * This field is valid if the type is RD_DATA_TYPE_PROTO, which
- is the protocol type of the socket created at the time * /
- };
-} nstack_rd_key;
-
-```
-
-*stackid*: output parameter; nStack internal number of the protocol stack id.
-
-**Interface implemented by:** DMM
-
-**5 Release file**<br>
-================
-
-**5.1 libs**
--------------------------
-**libnStackAPI.so:** The API library that DMM provides to the application. <br>
-**libnStackAdapt.so:** The adapter library that DMM provides to the stack developer
-connects the DMM and the protocal stack implementation.
-
-**5.2 Posix API of nSocket**
--------------------------
-DMM provides socket APIs and integrates various protocol stacks. DMM selects and invokes
-a specific protocol stack based on the information, such as IP and protocol type, from the
-application. The protocol stacks do not interact with the application. After the selection,
-what features an API supports are determined by the implementation provided by the protocol
-stack itself. The standard socket APIs defined by DMM are as follows:
-
- Interface definition | Interface Description
- -------------------- | ---------------------
- int socket(int, int, int) | same as corresponding POSIX apis
- int bind(int, const struct sockaddr\*, socklen\_t) | same as corresponding POSIX apis
- int listen(int, int) | same as corresponding POSIX apis
- int shutdown(int, int) | same as corresponding POSIX apis
- int getsockname(int, struct sockaddr\*, socklen\_t\*) | same as corresponding POSIX apis
- int getpeername(int, struct sockaddr\*, socklen\_t\*) | same as corresponding POSIX apis
- int getsockopt(int, int, int, void\*, socklen\_t\*) | same as corresponding POSIX apis
- int setsockopt(int, int, int, const void\*, socklen\_t) | same as corresponding POSIX apis
- int accept(int, struct sockaddr\*, socklen\_t\*) | same as corresponding POSIX apis
- int accept4(int, struct sockaddr\*, socklen\_t\*, int flags) | same as corresponding POSIX apis
- int connect(int, const struct sockaddr\*, socklen\_t) | same as corresponding POSIX apis
- ssize\_t recv(int , void\*, size\_t, int) | same as corresponding POSIX apis
- ssize\_t send(int, const void\*, size\_t, int) | same as corresponding POSIX apis
- ssize\_t read(int, void\*, size\_t) | same as corresponding POSIX apis
- ssize\_t write(int, const void\*, size\_t) | same as corresponding POSIX apis
- ssize\_t writev(int, const struct iovec \*, int) | same as corresponding POSIX apis
- ssize\_t readv(int, const struct iovec \*, int) | same as corresponding POSIX apis
- ssize\_t sendto(int, const void \*, size\_t, int, const struct sockaddr \*, socklen\_t) | same as corresponding POSIX apis
- ssize\_t recvfrom(int, void \*, size\_t, int, struct sockaddr \*, socklen\_t \*) | same as corresponding POSIX apis
- ssize\_t sendmsg(int, const struct msghdr \*, int flags) | same as corresponding POSIX apis
- ssize\_t recvmsg(int, struct msghdr \*, int flags) | same as corresponding POSIX apis
- int close(int) | same as corresponding POSIX apis
- int select(int, fd\_set\*, fd\_set\*, fd\_set\*, struct timeval\*) | same as corresponding POSIX apis
- int ioctl(int, unsigned long, unsigned long) | same as corresponding POSIX apis
- int fcntl(int, int, unsigned long) | same as corresponding POSIX apis
- int epoll\_create(int) | same as corresponding POSIX apis
- int epoll\_ctl(int, int, int, struct epoll\_event \*) | same as corresponding POSIX apis
- int epoll\_wait(int, struct epoll\_event \*, int, int) | same as corresponding POSIX apis
- pid\_t fork(void) | Before/after calling base fork() need to handle other processing like ref\_count etc.
-
- **6. Log & Debug**<br>
-============================
-nStack uses GLOG framework to provide multi level logs. Supported log levels are debug, info,
-warning, error and emergency. Logs will be stored at /var/log/nStack/. To enable log,
-need to set the environment variables NSTACK\_LOG\_ON
-```
-export NSTACK_LOG_ON=DBG
-```
-Log configuration will be stored in g\_nstack\_logs.
-```
-struct nstack_logs
-{
- uint32_t level; /**< Log level. */
- int pad64;
- int inited;
- int file_type;
-};
-
-struct nstack_logs g_nstack_logs[MAX_LOG_MODULE] = { {0, 0, 0, 0}, {0xFFFF, 0, 0, 0} }; /* Clear compile warning */
-
-Module types:
-typedef enum _LOG_MODULE
-{
- NSOCKET = 1,
- STACKX,
- OPERATION,
- ...
- LOGHAL,
- ...
- LOGFW,
- MAX_LOG_MODULE
-} LOG_MODULE;
-
-/* Log levels*/
-#define NSLOG_DBG 0x10
-#define NSLOG_INF 0x08
-#define NSLOG_WAR 0x04
-#define NSLOG_ERR 0x02
-#define NSLOG_EMG 0x01
-#define NSLOG_OFF 0x00
-
-```
-App logs stored in app_$pname_$pid.log. Stackx logs will be stored in running.log. Other operational
-logs will be stored in operation.log. App logs will be stored in file if following is set to 1.
-```
-export NSTACK_LOG_FILE_FLAG=1
-
-```
-Also we can memntioned the file name for App log.
-```
-export NSTACK_APP_LOG_PATH=/path_to_log
-```
-**7. How to use the incidental apps to test the protocol stack**<br>
-============================
-
-**7.1 App introduction**
--------------------------
-
-After building the DMM, test apps will be generated like below.The following table is the
-introduction of the client and server apps.
-
-
-| App name | client | server | use DMM |send/recv | s/r + epoll | s/r + select |
-| ------------ | ------------ | ------------ | ------------ | ------------ | ------------ | ------------ |
-| vc_common |Y | N |Y | send | N | N |
-| kc_common |Y | N | N | send |N | N |
-| vs_common |N | Y | Y |recv |N | N |
-| ks_common |N | Y | N |recv | N | N |
-| vs_epoll |N | Y | Y | recv | Y | N |
-| ks_epoll | N | Y | N | recv | Y | N |
-| vs_select | N | Y | Y | recv |N | Y |
-| ks_select | N | Y | N | recv |N | Y |
-Here, the app's name whose first letter is k means that it will run through the kernel.
-If the first letter is 'v', it will run through the dmm stack. If the second letter in the
-app's name is 's', which means it is the server app. If the second letter is 'c', it means it
-is the client app. The 'common' means that the app only implements the function of send or
-receive,no select or epoll. The 'select' means the app uses the select() function to
-implement the listening service.The 'epoll' means the app uses the epoll() function to
-implement the listening service.
-
-**7.2 Test implementation**
--------------------------
-Before testing, we need two servers, one for the client and one for the server.Then run the
-following codes. The following takes ks_common and vc_common as examples.
-**server**
-
- ```
-./ks_common -p 20000 -d <server ip> -a 10000 -s <client ip> -l 200 -t 5000000 -i 0 -f 1 -r 20000 -n 1 -w 10 -u 10000 -e 10 -x 1
- ```
-
-**client**
-
- ```
-./vc_common -p 20000 -d <client ip> -a 10000 -s <server ip> -l 200 -t 5000000 -i 0 -f 1 -r 20000 -n 1 -w 10 -u 10000 -e 10 -x 1
-```
-
-The following table is an introduction to some parameters in the code.
-
- parameter name | Functional description
- ------------------- | ---------------------
- -p | destination port number
- -d | dest severIP
- -a | src portid
- -s | src clientIP
- -l | msg length
- -t | max test time
- -i | msg interval
- -f | client fd number
- -r | receive port
- -n | connect number(one server vs n client)
- -w | wait time
- -u | unit print
- -e | sleep cut
- -x | flag print
-
-
-
diff --git a/doc/TestAppUserGuide.md b/doc/TestAppUserGuide.md
deleted file mode 100644
index ef118d2..0000000
--- a/doc/TestAppUserGuide.md
+++ /dev/null
@@ -1,188 +0,0 @@
-# 1. Introduction:
-
-This document will help to configure the stack module and protocol routing module,
-and run sample app with DMM.
-
-# 2. Configuration files:
-
-There are two configuration files need to modify for setting up the
-topology.
-
-release/configure
-
-**module_config.json** is the stack module config file.
-
-**rd_config.json** is the rd config file.
-
-Copy the two json files to release/bin and configure in next step.
-
-<!-- -->
-
-Note:
-
- If users have run scripts/build.sh, configuration files were generated in /dmm/config/app_test.
-
-# 3. JSON files configuration.
-
-We need to setup configuration as given below.
-
-# 3.1 module_config.json for example:
-
-```
-{
- "default_stack_name": "kernel", /*when rd can't be find maybe choose the defualt one*/
- "module_list": [
- {
- "stack_name": "kernel", /*stack name*/
- "function_name": "kernel_stack_register", /*function name*/
- "libname": "./", /*library name, if loadtype is static, this maybe
- null, else must give a library name*/
- "loadtype": "static", /*library load type: static or dynamic*/
- "deploytype": "1", /*deploy model type:model type1, model type2,
- model type3. Indicating single or multi process
- deployment. Used during shared memory initialization.*/
- "maxfd": "1024", /*the max fd supported*/
- "minfd": "0", /*the min fd supported*/
- "priorty": "1", /*priorty when executing, reserv*/
- "stackid": "0", /*stack id, this must be ordered and not be repeated*/
- },
-/***********************************
- {
- "stack_name": "stackx", /*this is not a real stack, just an example for multiple
- stack configurations*/
- "function_name": "stackx_register",
- "libname": "libstackx.so",
- "loadtype": "dynmic",
- "deploytype": "3",
- "maxfd": "1024",
- "minfd": "0",
- "priorty": "1",
- "stackid": "1",
- },
- ]
-}
-***********************************/
-```
-
-# 3.2 rd_config.json for example:
-
-```
-{
-"ip_route": [
- {
- "subnet": "192.165.1.1/16",
- "type": "nstack-kernel",
- /* output interface type,
- nstack-kernel: indicate this ip should go through kernel protocol
- nstack-dpdk: go through stackx protocol*/
- },
- {
- "subnet": "172.16.25.125/16",
- "type": "nstack-kernel",
- }
- ],
-"prot_route": [
- {
- "proto_type": "11",
- "type": "nstack-kernel",
- },
- ]
-}
-```
-# 4. Run sample APP:
-
-- **perf-test:**
-
- Add test code with kernel stack or userspace protocol stack
-
-
-Usage:
-
-After building the DMM, inside the DMM/release/bin directory below perf-test app will be generated.
-
-*kc_common, ks_epoll, ks_select, vc_common, vs_epoll, vs_select*
-
-The use of ks_epoll,ks_select,vs_epoll and vs_select are the same.
-
-Before executing the app, we should disable ASLR (Address space layout randomization).
- echo 0 > /proc/sys/kernel/randomize_va_space
-
-Examples:
-
-**With Kernel stack(With direct kernel stack):**
-
-server:
-```
- #./ks_epoll -p 20000 -d 172.16.25.125 -a 10000 -s 172.16.25.126 -l 200 -t 5000000 -i 0 -f 1 -r 20000 -n 1 -w 10 -u 10000 -e 10 -x 1
-```
-client:
-```
- #./kc_common -p 20000 -d 172.16.25.126 -a 10000 -s 172.16.25.125 -l 200 -t 5000000 -i 0 -f 1 -r 20000 -n 1 -w 10 -u 10000 -e 10 -x 1
-```
-
-**With DMM nStack(Stack is choosed by congfigure file):**
-Note:
-
- Currently DMM nstack only support kernel mode. please check the config file.
-
-server:
-```
- #./vs_epoll -p 20000 -d 172.16.25.125 -a 10000 -s 172.16.25.126 -l 200 -t 5000000 -i 0 -f 1 -r 20000 -n 1 -w 10 -u 10000 -e 10 -x 1
-```
-client:
-```
- #./vc_common -p 20000 -d 172.16.25.126 -a 10000 -s 172.16.25.125 -l 200 -t 5000000 -i 0 -f 1 -r 20000 -n 1 -w 10 -u 10000 -e 10 -x 1
-```
-
-- **NGNIX with DMM nStack**:
-
-Nginx build process:
-
-*step 1: Compile nginx code*
-
-```
- #wget "http://hg.nginx.org/nginx"
- #cd nginx-1.1.15
- #./configure --with-ld-opt="-L /root/Work/xxx/release/lib64/ -lnStackAPI"
- #make
- #make install
-```
-Note:
-
- a. ./configure **--with-ld-opt="-L /root/xxx/DMM/release/lib64/ -lnStackAPI"** can be done if you want to use nStack otherwise just give the ./configure.
- b. Make sure before building edit the configurtaion if you want specific server IP.
- For Ex:
- Server: ifconfig eth3 172.16.25.125 netmask 255.255.255.224 up
- Client: ifconfig eth3 172.16.25.126 netmask 255.255.255.224 up
-
- nginx.conf file modifiecations:
- listen 172.16.25.125:80
-
-*step 2: run the nginx code*
-
-```
- #cd /usr/local/nginx/sbin
- #cp -r * ../../sbin
- #cd ../../sbin
- #./nginx
-```
-Note:
-
- if you want to run ./nginx with nStack then perform following before run
- a. export LD_LIBRARY_PATH=/root/xxx/DMM/release/lib64/
- b. export NSTACK_LOG_ON=DBG ##to display nStack consol logs.
-
-*step 3: Check whether ngnix service is running.*
-
-```
- #ps -ax | grep nginx
-```
-*step 4: Test the nginx server is up or not!*
-
-At client board, perform below command and check the output:
-```
- #curl http://172.16.25.125:80/
-```
-Note:
-
- curl is the tool need to be installed to browse the html page in linux without GUI.
diff --git a/docker/dmm_image/README.md b/docker/dmm_image/README.md
deleted file mode 100644
index 0b674b2..0000000
--- a/docker/dmm_image/README.md
+++ /dev/null
@@ -1,13 +0,0 @@
-# How to build the image of dmm
-Note: Make sure your computer can connect to the network
-```sh
- #cd dmm/docker/dmm_image/centos
- #docker build -t "dmm:tag" .
-```
-
-# How to use the image of dmm
-```sh
- #docker run -i -t --network=host -v /sys/bus/pci/devices:/sys/bus/pci/devices -v /sys/devices/system/node:/sys/devices/system/node -v /mnt/nstackhuge:/mnt/nstackhuge -v /dev:/dev --privileged dmm:tag /bin/bash
-```
-
-Then we will enter a container and we can build dmm and run the app.
diff --git a/docker/dmm_image/centos/Dockerfile b/docker/dmm_image/centos/Dockerfile
deleted file mode 100644
index de772fe..0000000
--- a/docker/dmm_image/centos/Dockerfile
+++ /dev/null
@@ -1,17 +0,0 @@
-FROM docker.io/centos:latest
-
-RUN yum install -y git vim sudo ethtool
-
-RUN yum install -y kernel-devel-`uname -r`
-RUN yum install -y kernel-`uname -r`
-
-RUN git config --global http.sslVerify false
-RUN git config --global user.email "you@example.com"
-RUN git config --global user.name "Your Name"
-
-RUN git clone https://gerrit.fd.io/r/dmm
-
-RUN mkdir -p /var/run/ip_module/
-RUN mkdir -p /var/log/nStack/ip_module/
-
-RUN cd /dmm/scripts/ && bash -x build.sh && cd /dmm/ && git clean -dfx ./ && git checkout ./
diff --git a/license/Third_Party_Open_Source_Software_Notice b/license/Third_Party_Open_Source_Software_Notice
index 4595c7f..36338c4 100644
--- a/license/Third_Party_Open_Source_Software_Notice
+++ b/license/Third_Party_Open_Source_Software_Notice
@@ -11,11 +11,11 @@ THE OPEN SOURCE SOFTWARE IN THIS SOFTWARE IS DISTRIBUTED IN THE HOPE THAT IT WIL
Copyright Notice and License Texts
-Software: glog 0.3.4
+Software: glog 0.3.5
Copyright notice:
This software has been modified by Huawei Technologies Co.,Ltd.
-Copyright (C) 2018, Huawei.
+Copyright (C) 2018-2019, Huawei.
Copyright (c) 2008, Google Inc.
All rights reserved.
diff --git a/pkg/deb/control b/pkg/deb/control
deleted file mode 100644
index 24302e3..0000000
--- a/pkg/deb/control
+++ /dev/null
@@ -1,13 +0,0 @@
-Package: dmm
-Version: 18.10
-Section: tuils
-Priority: optional
-Depends: libc6, libstdc++6, libgcc1
-Suggests:
-Architecture: amd64
-Installed-Size:
-Maintainer: jorth
-Original-Maintainer:
-Provides:
-Description: DMM is a framework for protocol stack.
-Homepage: https://gerrit.fd.io/r/dmm
diff --git a/pkg/rpm/dmm.spec b/pkg/rpm/dmm.spec
deleted file mode 100644
index 51ebef1..0000000
--- a/pkg/rpm/dmm.spec
+++ /dev/null
@@ -1,50 +0,0 @@
-Name: dmm
-Version: 18.10
-Release: 1%{?dist}
-Summary: DMM Project
-
-License: GPL
-URL: https://gerrit.fd.io/r/dmm
-Source: %{name}-%{version}.tar.gz
-
-BuildRequires: glibc, libstdc++, libgcc, numactl-libs
-BuildRequires: dpdk >= 18.02, dpdk-devel >= 18.02
-
-%description
-The DMM framework provides posix socket APIs to the application. A protocol
-stack could be plugged into the DMM. DMM will choose the most suitable stack
-for the application.
-
-%prep
-%setup -q
-
-
-%build
-cd build/
-cmake ..
-make -j 8
-
-%install
-cd ../../BUILDROOT
-mkdir -p %{name}-%{version}-%{release}.x86_64/usr/bin
-mkdir -p %{name}-%{version}-%{release}.x86_64/usr/lib64
-
-install -c ../BUILD/%{name}-%{version}/release/bin/kc_common %{name}-%{version}-%{release}.x86_64/usr/bin
-install -c ../BUILD/%{name}-%{version}/release/bin/ks_epoll %{name}-%{version}-%{release}.x86_64/usr/bin
-install -c ../BUILD/%{name}-%{version}/release/bin/vc_common %{name}-%{version}-%{release}.x86_64/usr/bin
-install -c ../BUILD/%{name}-%{version}/release/bin/vs_epoll %{name}-%{version}-%{release}.x86_64/usr/bin
-install -c ../BUILD/%{name}-%{version}/release/bin/ks_select %{name}-%{version}-%{release}.x86_64/usr/bin
-install -c ../BUILD/%{name}-%{version}/release/bin/vs_select %{name}-%{version}-%{release}.x86_64/usr/bin
-install -c ../BUILD/%{name}-%{version}/release/bin/ks_common %{name}-%{version}-%{release}.x86_64/usr/bin
-install -c ../BUILD/%{name}-%{version}/release/bin/vs_common %{name}-%{version}-%{release}.x86_64/usr/bin
-
-install -c ../BUILD/%{name}-%{version}/release/lib64/libdmm_api.so %{name}-%{version}-%{release}.x86_64/usr/lib64
-install -c ../BUILD/%{name}-%{version}/release/lib64/libnStackAPI.so %{name}-%{version}-%{release}.x86_64/usr/lib64
-
-%files
-/usr/bin/*
-/usr/lib64/*
-%doc
-
-
-%changelog
diff --git a/stacks/lwip_stack/build/.gitkeep b/release/bin/.gitkeep
index e69de29..e69de29 100644
--- a/stacks/lwip_stack/build/.gitkeep
+++ b/release/bin/.gitkeep
diff --git a/release/configure/rd_config.json b/release/configure/rd_config.json
deleted file mode 100644
index 58a8da9..0000000
--- a/release/configure/rd_config.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "ip_route": [
- {
- "subnet": "192.168.1.1/24",
- "stack_name": "kernel",
- },
- {
- "subnet": "192.167.1.1/24",
- "stack_name": "kernel",
- },
- {
- "subnet": "192.166.1.1/24",
- "stack_name": "kernel",
- }
- ],
- "prot_route": [
- {
- "proto_type": "1",
- "stack_name": "kernel",
- },
- {
- "proto_type": "2",
- "stack_name": "kernel",
- }
- ],
-}
diff --git a/release/include/declare_syscalls.h b/release/include/declare_syscalls.h
deleted file mode 100644
index c4810f5..0000000
--- a/release/include/declare_syscalls.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-NSTACK_MK_DECL (int, socket, (int, int, int));
-NSTACK_MK_DECL (int, bind, (int, const struct sockaddr *, socklen_t));
-NSTACK_MK_DECL (int, listen, (int, int));
-NSTACK_MK_DECL (int, shutdown, (int, int));
-NSTACK_MK_DECL (int, getsockname, (int, struct sockaddr *, socklen_t *));
-NSTACK_MK_DECL (int, getpeername, (int, struct sockaddr *, socklen_t *));
-NSTACK_MK_DECL (int, getsockopt, (int, int, int, void *, socklen_t *));
-NSTACK_MK_DECL (int, setsockopt, (int, int, int, const void *, socklen_t));
-NSTACK_MK_DECL (int, accept, (int, struct sockaddr *, socklen_t *));
-NSTACK_MK_DECL (int, accept4,
- (int, struct sockaddr *, socklen_t *, int flags));
-NSTACK_MK_DECL (int, connect, (int, const struct sockaddr *, socklen_t));
-NSTACK_MK_DECL (ssize_t, recv, (int, void *, size_t, int));
-NSTACK_MK_DECL (ssize_t, send, (int, const void *, size_t, int));
-NSTACK_MK_DECL (ssize_t, read, (int, void *, size_t));
-NSTACK_MK_DECL (ssize_t, write, (int, const void *, size_t));
-NSTACK_MK_DECL (ssize_t, writev, (int, const struct iovec *, int));
-NSTACK_MK_DECL (ssize_t, readv, (int, const struct iovec *, int));
-NSTACK_MK_DECL (ssize_t, sendto,
- (int, const void *, size_t, int, const struct sockaddr *,
- socklen_t));
-NSTACK_MK_DECL (ssize_t, recvfrom,
- (int, void *, size_t, int, struct sockaddr *, socklen_t *));
-NSTACK_MK_DECL (ssize_t, sendmsg, (int, const struct msghdr *, int flags));
-NSTACK_MK_DECL (ssize_t, recvmsg, (int, struct msghdr *, int flags));
-NSTACK_MK_DECL (int, close, (int));
-NSTACK_MK_DECL (int, select,
- (int, fd_set *, fd_set *, fd_set *, struct timeval *));
-NSTACK_MK_DECL (int, ioctl, (int, unsigned long, unsigned long));
-NSTACK_MK_DECL (int, fcntl, (int, int, unsigned long));
-NSTACK_MK_DECL (int, epoll_create, (int));
-NSTACK_MK_DECL (int, epoll_ctl, (int, int, int, struct epoll_event *));
-NSTACK_MK_DECL (int, epoll_wait, (int, struct epoll_event *, int, int));
-NSTACK_MK_DECL (pid_t, fork, (void));
-#undef NSTACK_MK_DECL
diff --git a/resources/Epoll_flwChart.png b/resources/Epoll_flwChart.png
deleted file mode 100644
index 2aeff62..0000000
--- a/resources/Epoll_flwChart.png
+++ /dev/null
Binary files differ
diff --git a/resources/EvntNotify_StackX.png b/resources/EvntNotify_StackX.png
deleted file mode 100644
index 152091e..0000000
--- a/resources/EvntNotify_StackX.png
+++ /dev/null
Binary files differ
diff --git a/resources/ForkChild.png b/resources/ForkChild.png
deleted file mode 100644
index 2695b87..0000000
--- a/resources/ForkChild.png
+++ /dev/null
Binary files differ
diff --git a/resources/Integration.png b/resources/Integration.png
deleted file mode 100644
index 077cb2b..0000000
--- a/resources/Integration.png
+++ /dev/null
Binary files differ
diff --git a/resources/RD_Topo.PNG b/resources/RD_Topo.PNG
deleted file mode 100644
index 089de5b..0000000
--- a/resources/RD_Topo.PNG
+++ /dev/null
Binary files differ
diff --git a/resources/SelectFunc.png b/resources/SelectFunc.png
deleted file mode 100644
index 2810a5b..0000000
--- a/resources/SelectFunc.png
+++ /dev/null
Binary files differ
diff --git a/resources/extras/Vagrantfile b/resources/extras/Vagrantfile
deleted file mode 100644
index 969c91f..0000000
--- a/resources/extras/Vagrantfile
+++ /dev/null
@@ -1,62 +0,0 @@
-# -*- mode: ruby -*-
-# vi: set ft=ruby :
-
-Vagrant.configure(2) do |config|
-
- # Pick the right distro and bootstrap, default is ubuntu1604
- distro = ( ENV['DMM_VAGRANT_DISTRO'] || "ubuntu")
- if distro == 'centos7'
- config.vm.box = "puppetlabs/centos-7.2-64-nocm"
- else
- #config.vm.box = "fdio-csit/ubuntu-14.04.4_2016-05-25_1.0"
- config.vm.box = "puppetlabs/ubuntu-16.04-64-nocm"
- end
- config.vm.box_check_update = false
-
- # Create DMM client and server VM's
- config.vm.define "dmm-test-server" do |server|
- server.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"install_prereq.sh")
- server.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"../../scripts/build.sh"), :args => "/dmm vagrant"
- end
- config.vm.define "dmm-test-client" do |client|
- client.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"install_prereq.sh")
- client.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"../../scripts/build.sh"), :args => "/dmm vagrant"
- end
-
-
- # vagrant-cachier caches apt/yum etc to speed subsequent
- # vagrant up
- # to enable, run
- # vagrant plugin install vagrant-cachier
- #
- if Vagrant.has_plugin?("vagrant-cachier")
- config.cache.scope = :box
- end
-
- # Define some physical ports for your VMs to be used by DPDK
- nics = (ENV['DMM_VAGRANT_NICS'] || "2").to_i(10)
- for i in 1..nics
- config.vm.network "private_network", type: "dhcp"
- end
-
- # use http proxy if avaiable
- if ENV['http_proxy'] && Vagrant.has_plugin?("vagrant-proxyconf")
- config.proxy.http = ENV['http_proxy']
- config.proxy.https = ENV['https_proxy']
- config.proxy.no_proxy = "localhost,127.0.0.1"
- end
-
- vmcpu=(ENV['DMM_VAGRANT_VMCPU'] || 4)
- vmram=(ENV['DMM_VAGRANT_VMRAM'] || 4096)
-
- config.ssh.forward_agent = true
- config.ssh.forward_x11 = true
-
- config.vm.provider "virtualbox" do |vb|
- vb.customize ["modifyvm", :id, "--ioapic", "on"]
- vb.memory = "#{vmram}"
- vb.cpus = "#{vmcpu}"
-
- config.vm.synced_folder "../../", "/dmm", type: "rsync"
- end
-end
diff --git a/resources/extras/env.sh b/resources/extras/env.sh
deleted file mode 100644
index 96ad346..0000000
--- a/resources/extras/env.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/env bash
-
-#export DMM_VAGRANT_DISTRO="ubuntu1604"
-export DMM_VAGRANT_DISTRO="centos7"
-export DMM_VAGRANT_NICS=2
-export DMM_VAGRANT_VMCPU=4
-export DMM_VAGRANT_VMRAM=8192
diff --git a/resources/extras/install_prereq.sh b/resources/extras/install_prereq.sh
deleted file mode 100644
index f2413ea..0000000
--- a/resources/extras/install_prereq.sh
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/bin/bash -x
-log_file="/tmp/install_log.txt-`date +'%Y-%m-%d_%H-%M-%S'`"
-exec 1> >(tee -a "$log_file") 2>&1
-
-if [ "$(uname)" <> "Darwin" ]; then
- OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
- OS_VERSION_ID=$(grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
-fi
-
-if [ "$OS_ID" == "ubuntu" ]; then
- # Standard update + upgrade dance
- cat << EOF >> /etc/apt/sources.list
- deb http://in.archive.ubuntu.com/ubuntu/ trusty main restricted
- deb-src http://in.archive.ubuntu.com/ubuntu/ trusty main restricted
- deb http://in.archive.ubuntu.com/ubuntu/ trusty-updates main restricted
- deb-src http://in.archive.ubuntu.com/ubuntu/ trusty-updates main restricted
- deb http://in.archive.ubuntu.com/ubuntu/ trusty universe
- deb-src http://in.archive.ubuntu.com/ubuntu/ trusty universe
- deb http://in.archive.ubuntu.com/ubuntu/ trusty-updates universe
- deb-src http://in.archive.ubuntu.com/ubuntu/ trusty-updates universe
- deb http://in.archive.ubuntu.com/ubuntu/ trusty multiverse
- deb-src http://in.archive.ubuntu.com/ubuntu/ trusty multiverse
- deb http://in.archive.ubuntu.com/ubuntu/ trusty-updates multiverse
- deb-src http://in.archive.ubuntu.com/ubuntu/ trusty-updates multiverse
- deb http://in.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
- deb-src http://in.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
- deb http://security.ubuntu.com/ubuntu trusty-security main restricted
- deb-src http://security.ubuntu.com/ubuntu trusty-security main restricted
- deb http://security.ubuntu.com/ubuntu trusty-security universe
- deb-src http://security.ubuntu.com/ubuntu trusty-security universe
- deb http://security.ubuntu.com/ubuntu trusty-security multiverse
- deb-src http://security.ubuntu.com/ubuntu trusty-security multiverse
- deb http://extras.ubuntu.com/ubuntu trusty main
- deb-src http://extras.ubuntu.com/ubuntu trusty main
-EOF
-elif [ "$OS_ID" == "centos" ]; then
-
- echo centos
-fi
diff --git a/resources/logo_fdio-300x184.png b/resources/logo_fdio-300x184.png
deleted file mode 100644
index 0707f23..0000000
--- a/resources/logo_fdio-300x184.png
+++ /dev/null
Binary files differ
diff --git a/resources/nStack_Architecture.png b/resources/nStack_Architecture.png
deleted file mode 100644
index 6eaed04..0000000
--- a/resources/nStack_Architecture.png
+++ /dev/null
Binary files differ
diff --git a/scripts/build.sh b/scripts/build.sh
index eaa0f0e..c04b92c 100755
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -58,7 +58,7 @@ bash -x $DMM_DIR/scripts/compile_dmm.sh || exit 1
if [ "${BUILD_ALL}" == "YES" ]; then
#===========build LWIP================
- bash -x $DMM_DIR/stacks/lwip_stack/vagrant/build.sh "from-base-build" || exit 1
+ #bash -x $DMM_DIR/stacks/lwip_stack/vagrant/build.sh "from-base-build" || exit 1
#============build rsocket============================
bash -x $DMM_DIR/scripts/build_rsocket.sh || exit 1
#=======other new stacks build can be called from here
diff --git a/scripts/build_vpp.sh b/scripts/build_vpp.sh
index 555aa9f..fad02fc 100755
--- a/scripts/build_vpp.sh
+++ b/scripts/build_vpp.sh
@@ -20,10 +20,10 @@ set -x
cd ../stacks/vpp
git clone https://gerrit.fd.io/r/vpp
-
cd vpp
-git checkout origin/stable/1804 -b vpp_1804_br
+git fetch https://gerrit.fd.io/r/vpp refs/changes/39/18639/2 && git checkout FETCH_HEAD
cp ../adapt/* src/vcl/
-git am ../patch/*
+git apply --ignore-space-change --ignore-whitespace ../patch/vpp.patch
make UNATTENDED=yes install-dep
make build
+
diff --git a/scripts/checkstyle.sh b/scripts/checkstyle.sh
index 4f3c0a0..b6fced4 100755
--- a/scripts/checkstyle.sh
+++ b/scripts/checkstyle.sh
@@ -75,7 +75,7 @@ cd ${DMM_DIR}
if [ "${FULL}" == "1" ]; then
- FILELIST=$(git ls-tree -r HEAD --name-only)
+ FILELIST=$(git ls-tree -r HEAD --name-only | grep -v 'thirdparty\|testcode\|release\|platform')
else
FILELIST=$((git diff HEAD~1.. --name-only; git ls-files -m ) | sort -u)
fi
@@ -133,8 +133,8 @@ for i in ${FILELIST}; do
then
clang-format ${i} > ${i}.out2
else
- indent -gnu -nut ${i} -o ${i}.out1 > /dev/null 2>&1
- indent -gnu -nut ${i}.out1 -o ${i}.out2 > /dev/null 2>&1
+ indent -nut -sob -i4 -bli0 -npsl -cli4 -npcs ${i} -o ${i}.out1 > /dev/null 2>&1
+ indent -nut -sob -i4 -bli0 -npsl -cli4 -npcs ${i}.out1 -o ${i}.out2 > /dev/null 2>&1
fi
# Remove trailing whitespace
sed -i -e 's/[[:space:]]*$//' ${i}.out2
@@ -143,8 +143,8 @@ for i in ${FILELIST}; do
if [ "${CMD}" == "clang-format" ]; then
clang-format -i ${i} > /dev/null 2>&1
else
- indent -nut -sob ${i}
- indent -nut -sob ${i}
+ indent -nut -sob -i4 -bli0 -npsl -cli4 -npcs ${i}
+ indent -nut -sob -i4 -bli0 -npsl -cli4 -npcs ${i}
fi
# Remove trailing whitespace
sed -i -e 's/[[:space:]]*$//' ${i}
@@ -159,7 +159,6 @@ for i in ${FILELIST}; do
else
echo "Run indent (twice!) as shown to fix the problem:"
echo "indent ${DMM_DIR}${i}"
- echo "indent ${DMM_DIR}${i}"
fi
fi
if [ -f ${i}.out1 ]; then
diff --git a/set_permission.sh b/set_permission.sh
new file mode 100644
index 0000000..9f7a812
--- /dev/null
+++ b/set_permission.sh
@@ -0,0 +1,17 @@
+#! /bin/bash
+
+#dir:750,exec:550,else:640
+set_sec_permission()
+{
+ for var in $*
+ do
+ if [ -d "$var" ]
+ then
+ find "$var" -type d | xargs chmod 750
+ find "$var" -perm /+x -type f | xargs chmod 550
+ find "$var" ! -perm /+x -type f | xargs chmod 640
+ find "$var" -type f | grep -E "*\.so" | xargs chmod 640
+ find "$var" -type f | grep -E "*\.sh|*\.py" | xargs chmod 550
+ fi
+ done
+}
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 0eca7a1..952e2de 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -14,42 +14,24 @@
# limitations under the License.
#########################################################################
-if(WITH_HAL_LIB)
-else()
- SET(COMM_CONFIG ${PROJECT_SOURCE_DIR}/src/framework/common/base/include/common/common_sys_config.h)
- #SET(PRI_DIRECTORIES "framework/common/base/include/common/")
-endif()
-
INCLUDE_DIRECTORIES(
- framework/log/
- framework/mem
- framework/include/
- framework/common/include/
- framework/common/include/arch/${DMM_ARCH}
- framework/common/base/include/
- framework/common/base/include/common/
- ${PRI_DIRECTORIES}
- ../platform/SecureC/include/
- ../thirdparty/glog/glog-0.3.4/src/
+ ${CMAKE_CURRENT_LIST_DIR}/framework/include
+ ${CMAKE_CURRENT_LIST_DIR}/include
+ ${CMAKE_SOURCE_DIR}/platform/SecureC/include/
+ ${CMAKE_SOURCE_DIR}/thirdparty/glog/glog-0.3.5/src/
)
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g -fPIC -m64 -mssse3 -std=gnu89")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -g -fPIC -m64 -mssse3 -std=gnu89")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -Wshadow -Wfloat-equal -Wformat=2")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector -fstack-protector-all")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-all")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-z,relro,-z,now -Wl,--disable-new-dtags")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-z,noexecstack -mcmodel=medium")
-SET(COMPLE_CONFIG ${PROJECT_SOURCE_DIR}/src/framework/common/include/compile_config.h)
-ADD_DEFINITIONS(-include ${COMM_CONFIG})
+SET(COMPLE_CONFIG ${CMAKE_SOURCE_DIR}/src/framework/include/common/compile_config.h)
ADD_DEFINITIONS(-include ${COMPLE_CONFIG})
-ADD_DEFINITIONS(-D_GNU_SOURCE -DNSTACK_GETVER_VERSION="18.10")
-#LINK_DIRECTORIES(${LIB_PATH_SHARED} ${LIB_PATH_STATIC})
-
-if(WITH_SECUREC_LIB)
-LINK_LIBRARIES(pthread dl securec)
-else()
+ADD_DEFINITIONS(-D_GNU_SOURCE -D_FORTIFY_SOURCE=2)
+LINK_DIRECTORIES(${LIB_PATH_SHARED} ${LIB_PATH_STATIC})
LINK_LIBRARIES(pthread dl)
-endif()
ADD_SUBDIRECTORY(framework)
ADD_SUBDIRECTORY(nSocket)
diff --git a/src/adapt/nstack_dmm_adpt.c b/src/adapt/nstack_dmm_adpt.c
deleted file mode 100644
index d497b80..0000000
--- a/src/adapt/nstack_dmm_adpt.c
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif /* __cplusplus */
-
-#include "nsfw_init.h"
-#include "nsfw_mem_api.h"
-#include "nsfw_recycle_api.h"
-#include "nsfw_mgr_com_api.h"
-#include "nsfw_ps_mem_api.h"
-#include "nsfw_ps_api.h"
-#include "nsfw_recycle_api.h"
-#include "nsfw_fd_timer_api.h"
-#include "nsfw_maintain_api.h"
-#include "nstack_eventpoll.h"
-#include "nstack_dmm_api.h"
-#include "nstack_dmm_adpt.h"
-#include "mgr_com.h"
-
-int g_same_process = 1;
-
-extern int nsep_adpt_attach_memory ();
-extern int nstack_init_share_res ();
-extern int nstack_attach_share_res ();
-extern int nsep_adpt_reg_res_mgr ();
-
-/**
- * This just for linux kernel epoll thread
- */
-int
-nstack_event_callback (void *pdata, int events)
-{
- nsep_epollInfo_t *epInfo = (nsep_epollInfo_t *) pdata;
-
- if (!epInfo)
- {
- NSSOC_LOGWAR ("!!!!!!!err pdata=%p,get null epInfo", pdata);
- return -1;
- }
-
- NSSOC_LOGDBG ("Got one event]fd=%d,events=%u", epInfo->fd, events);
-
- sys_arch_lock_with_pid (&epInfo->epiLock);
- struct list_node *fdEpiHead =
- (struct list_node *) ADDR_SHTOL (epInfo->epiList.head);
- struct list_node *node = (struct list_node *) ADDR_SHTOL (fdEpiHead->next);
- struct epitem *epi = NULL;
- struct eventpoll *ep = NULL;
- while (node)
- {
-
- epi = (struct epitem *) ep_list_entry (node, struct epitem, fllink);
-
- node = (struct list_node *) ADDR_SHTOL (node->next);
- ep = (struct eventpoll *) ADDR_SHTOL (epi->ep);
- if (!(epi->event.events & events))
- continue;
-
- /*event should not notice other process */
- if ((ep->pid != get_sys_pid ()) && g_same_process)
- {
- continue;
- }
-
- sys_arch_lock_with_pid (&ep->lock);
-
- if (unlikely (ep->ovflist != NSEP_EP_UNACTIVE_PTR))
- {
- if (epi->next == NSEP_EP_UNACTIVE_PTR)
- {
- epi->next = ep->ovflist;
- ep->ovflist = (struct epitem *) ADDR_LTOSH (epi);
- }
- epi->ovf_revents |= events;
- NSSOC_LOGDBG ("Add to ovflist]protoFD=%d,event=%d", epInfo->fd,
- events);
- goto out_unlock;
- }
- if (!EP_HLIST_NODE_LINKED (&epi->rdllink))
- {
- ep_hlist_add_tail (&ep->rdlist, &epi->rdllink);
- sem_post (&ep->waitSem);
- }
- epi->revents |= (epi->event.events & events);
- out_unlock:
- sys_sem_s_signal (&ep->lock);
- }
- sys_sem_s_signal (&epInfo->epiLock);
- /* [Remove fdInf->event_sem post] */
- return 0;
-}
-
-int
-nstack_adpt_init (nstack_dmm_para * para)
-{
- nsfw_mem_para stinfo = { 0 };
- i32 init_ret = 0;
-
- if (!para)
- {
- return -1;
- }
- stinfo.iargsnum = para->argc;
- stinfo.pargs = para->argv;
- stinfo.enflag = para->proc_type;
- if (para->deploy_type != NSTACK_MODEL_TYPE1
- && para->deploy_type != NSTACK_MODEL_TYPE_SIMPLE_STACK)
- {
- g_same_process = 0;
- }
-
- nsfw_com_attr_set (para->attr.policy, para->attr.pri);
-
- (void) nstack_framework_setModuleParam (NSFW_MEM_MGR_MODULE, &stinfo);
- (void) nstack_framework_setModuleParam (NSFW_MGR_COM_MODULE,
- (void *) ((u64) para->proc_type));
- (void) nstack_framework_setModuleParam (NSFW_TIMER_MODULE,
- (void *) ((u64) para->proc_type));
- (void) nstack_framework_setModuleParam (NSFW_PS_MODULE,
- (void *) ((u64) para->proc_type));
- (void) nstack_framework_setModuleParam (NSFW_PS_MEM_MODULE,
- (void *) ((u64) para->proc_type));
- (void) nstack_framework_setModuleParam (NSFW_RECYCLE_MODULE,
- (void *) ((u64) para->proc_type));
- (void) nstack_framework_setModuleParam (NSFW_RES_MGR_MODULE,
- (void *) ((u64) para->proc_type));
- (void) nstack_framework_setModuleParam (NSFW_SOFT_PARAM_MODULE,
- (void *) ((u64) para->proc_type));
- (void) nstack_framework_setModuleParam (NSFW_LOG_CFG_MODULE,
- (void *) ((u64) para->proc_type));
-
- init_ret = nstack_framework_init ();
- if (init_ret < 0)
- {
- NSFW_LOGERR
- ("######################init failed!!!!######################");
- return -1;
- }
-
- if ((para->proc_type != NSFW_PROC_APP)
- && (para->proc_type != NSFW_PROC_MAIN))
- {
- return 0;
- }
-
- if (para->proc_type == NSFW_PROC_MAIN)
- {
- if (nstack_init_share_res () != 0)
- {
- NSFW_LOGERR ("nstack_init_share_res failed");
- return -1;
- }
- if (nsep_create_memory () != 0)
- {
- NSFW_LOGERR ("nsep_create_memory failed");
- return -1;
- }
- }
- else
- {
- if (nstack_attach_share_res () != 0)
- {
- NSFW_LOGERR ("nstack_attach_share_res failed");
- return -1;
- }
-
- /**
- * the share memory for epoll is created and used by app, don't clear
- * it in fault case.
- */
- if (0 != nsep_adpt_attach_memory ())
- {
- NSFW_LOGERR ("nsep_adpt_attach_memory failed");
- return -1;
- }
- }
-
- void *pret =
- nsfw_recycle_reg_obj (NSFW_REC_PRO_LOWEST, NSFW_REC_NSOCKET_EPOLL,
- NULL);
- if (!pret)
- {
- NSFW_LOGERR ("regist recycle failed");
- return -1;
- }
- (void) nsep_adpt_reg_res_mgr ();
-
- return 0;
-}
-
-/*just to used to dependence by other module*/
-int
-nstack_init_module (void *para)
-{
- return 0;
-}
-
-NSFW_MODULE_NAME (NSTACK_DMM_MODULE)
-NSFW_MODULE_PRIORITY (10)
-NSFW_MODULE_DEPENDS (NSFW_MEM_MGR_MODULE)
-NSFW_MODULE_DEPENDS (NSFW_MGR_COM_MODULE)
-NSFW_MODULE_DEPENDS (NSFW_TIMER_MODULE)
-NSFW_MODULE_DEPENDS (NSFW_PS_MODULE)
-NSFW_MODULE_DEPENDS (NSFW_PS_MEM_MODULE)
-NSFW_MODULE_DEPENDS (NSFW_RECYCLE_MODULE)
-NSFW_MODULE_DEPENDS (NSFW_LOG_CFG_MODULE)
-NSFW_MODULE_DEPENDS (NSFW_RES_MGR_MODULE)
-NSFW_MODULE_DEPENDS (NSFW_SOFT_PARAM_MODULE)
-NSFW_MODULE_INIT (nstack_init_module)
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif /* __cplusplus */
diff --git a/src/adapt/nstack_dmm_adpt.h b/src/adapt/nstack_dmm_adpt.h
deleted file mode 100644
index 1621475..0000000
--- a/src/adapt/nstack_dmm_adpt.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif /* __cplusplus */
-
-#ifndef __NSTACK_DMM_ADPT_H__
-#define __NSTACK_DMM_ADPT_H__
-
-typedef enum
-{
- NSTACK_MODEL_TYPE1 = 1, /*nSocket and stack belong to the same process */
- NSTACK_MODEL_TYPE2 = 2, /*nSocket and stack belong to different processes,
- *and nStack don't take care the communication between stack and stack adpt
- */
- NSTACK_MODEL_TYPE3 = 3, /*nSocket and stack belong to different processes, and sbr was supplied to communicate whit stack */
- NSTACK_MODEL_TYPE_SIMPLE_STACK = 4, /* like TYPE1, DMM will NOT provide SBR or pipeline mode, just allocate 32M, and use dpdk file
- * prefix to support multiple running app under DMM */
- NSTACK_MODEL_INVALID,
-} nstack_model_deploy_type;
-
-#define NSTACK_DMM_MODULE "nstack_dmm_module"
-
-typedef struct nsfw_com_attr
-{
- int policy;
- int pri;
-} nsfw_com_attr;
-
-typedef struct __nstack_dmm_para
-{
- nstack_model_deploy_type deploy_type;
- int proc_type;
- nsfw_com_attr attr;
- int argc;
- char **argv;
-} nstack_dmm_para;
-
-extern int nstack_adpt_init (nstack_dmm_para * para);
-extern int nstack_event_callback (void *pdata, int events);
-
-#endif
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif /* __cplusplus */
diff --git a/src/adapt/nstack_epoll_comm.c b/src/adapt/nstack_epoll_comm.c
deleted file mode 100644
index 219803c..0000000
--- a/src/adapt/nstack_epoll_comm.c
+++ /dev/null
@@ -1,1076 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "nstack_eventpoll.h"
-#include "nsfw_mem_api.h"
-#include "nstack_log.h"
-#include "nstack_securec.h"
-#include "nsfw_recycle_api.h"
-#include "nsfw_maintain_api.h"
-#include <stdio.h>
-#include <stdlib.h>
-
-nsep_epollManager_t g_epollMng = {
- .infoSockMap = NULL,
-};
-
-/*
- * This function will find the epitem of fd in eventpool ep
- * This is only used in epoll_ctl add
- */
-struct epitem *
-nsep_find_ep (struct eventpoll *ep, int fd)
-{
- struct ep_rb_node *rbp;
- struct epitem *epi, *epir = NULL;
- u32_t loopCnt = 0;
- for (rbp = ADDR_SHTOL (ep->rbr.rb_node); rbp;)
- {
- ++loopCnt;
- if (loopCnt > NSTACK_MAX_EPITEM_NUM)
- break;
-
- epi = (struct epitem *) ep_rb_entry (rbp, struct epitem, rbn);
- if (fd > epi->fd)
- {
- rbp = (struct ep_rb_node *) ADDR_SHTOL (rbp->rb_right);
- }
- else if (fd < epi->fd)
- {
- rbp = (struct ep_rb_node *) ADDR_SHTOL (rbp->rb_left);
- }
- else
- {
- epir = epi;
- break;
- }
- }
-
- if (loopCnt > NSTACK_MAX_EPITEM_NUM)
- {
- NSSOC_LOGERR ("Loop out of range!!!!");
- }
-
- return epir;
-}
-
-int
-nstack_ep_unlink (struct eventpoll *ep, struct epitem *epi)
-{
- int error = ENOENT;
-
- if (ep_rb_parent (&epi->rbn) ==
- (struct ep_rb_node *) ADDR_LTOSH_EXT (&epi->rbn))
- {
- NSSOC_LOGWAR ("ep_rb_parent == epi->rbn");
- return error;
- }
-
- epi->event.events = 0;
-
- ep_rb_erase (&epi->rbn, &ep->rbr);
- ep_rb_set_parent (&epi->rbn, &epi->rbn);
-
- if (EP_HLIST_NODE_LINKED (&epi->rdllink))
- {
- ep_hlist_del (&ep->rdlist, &epi->rdllink);
- }
-
- return 0;
-}
-
-/**
- * @Function nsep_free_epitem
- * @Description free nstack epitem
- * @param in data - the epitem to be free
- * @return 0 on success, -1 on error
- */
-int
-nsep_free_epitem (struct epitem *data)
-{
- struct epitem *epiEntry = (struct epitem *) data;
- struct epitem_pool *pool = &nsep_getManager ()->epitemPool;
- epiEntry->pid = 0;
- NSSOC_LOGDBG ("nsep_free_epitem data:%p", data);
- if (res_free (&epiEntry->res_chk))
- {
- NSFW_LOGERR ("epitem refree!]epitem=%p", epiEntry);
- return 0;
- }
-
- if (nsfw_mem_ring_enqueue (pool->ring, (void *) epiEntry) != 1)
- {
- NSSOC_LOGERR ("Error to free epitem");
- }
- return 0;
-}
-
-NSTACK_STATIC void
-nsep_initEpInfo (nsep_epollInfo_t * info)
-{
- int iindex = 0;
- EP_LIST_INIT (&info->epiList);
- NSTACK_SEM_MALLOC (info->epiLock, 1);
- NSTACK_SEM_MALLOC (info->freeLock, 1);
-
- info->rlfd = -1;
- info->rmidx = -1;
- info->fd = -1;
- info->ep = NULL;
- info->fdtype = 0;
- info->private_data = NULL;
- info->epaddflag = 0;
- for (iindex = 0; iindex < NSEP_SMOD_MAX; iindex++)
- {
- info->protoFD[iindex] = -1;
- }
- (void) nsep_for_pidinfo_init (&(info->pidinfo));
-}
-
-NSTACK_STATIC void
-nsep_destroy_epinfo (nsep_epollInfo_t * info)
-{
- return;
-}
-
-/**
- * @Function nstack_eventpoll_allocShareInfo
- * @Description alloc nstack share info
- * @param out data - the return value alloced
- * @return 0 on success, -1 on error
- */
-int
-nsep_alloc_epinfo (nsep_epollInfo_t ** data)
-{
- nsep_epollInfo_t *head_info = NULL;
-
- if (NULL == data)
- return -1;
- NSSOC_LOGDBG ("epinfo alloc begin");
-
- nsep_infoPool_t *pool = &nsep_getManager ()->infoPool;
- if (0 == nsfw_mem_ring_dequeue (pool->ring, (void *) &head_info)
- || NULL == head_info)
- {
- NSSOC_LOGERR ("epinfo ring alloc failed]pool->ring=%p", pool->ring);
- return -1;
- }
-
- res_alloc (&head_info->res_chk);
-
- nsep_initEpInfo (head_info);
- if (0 != nsep_add_pid (&head_info->pidinfo, get_sys_pid ()))
- {
- NSSOC_LOGERR ("epinfo pid add to headinfo failed]pid=%d,headinfo=%p",
- get_sys_pid (), head_info);
- }
- NSSOC_LOGDBG ("epinfo ring:%p alloc epinfo:%p end", pool->ring, head_info);
- *data = head_info;
- return 0;
-}
-
-/**
- * @Function nstack_eventpoll_freeShareInfo
- * @Description free nstack share info
- * @param in info - the info to be free
- * @return 0 on success, -1 on error
- */
-int
-nsep_free_epinfo (nsep_epollInfo_t * info)
-{
-
- if (NULL == info)
- return -1;
-
- nsep_infoPool_t *pool = &nsep_getManager ()->infoPool;
- NSSOC_LOGDBG ("nsep_free_epinfo info:%p, pool->ring:%p", info, pool->ring);
- nsep_destroy_epinfo (info);
-
- (void) nsep_for_pidinfo_init (&(info->pidinfo));
- if (res_free (&info->res_chk))
- {
- NSFW_LOGERR ("epinfo refree!]epitem=%p", info);
- return 0;
- }
-
- if (nsfw_mem_ring_enqueue (pool->ring, (void *) info) != 1)
- {
- NSSOC_LOGERR ("Error to free epinfo");
- }
-
- return 0;
-}
-
-int
-nsep_force_epinfo_free (void *data)
-{
- nsep_epollInfo_t *info = data;
- if (NULL == info)
- {
- return FALSE;
- }
-
- if (!nsep_is_pid_array_empty (&info->pidinfo))
- {
- return FALSE;
- }
-
- res_alloc (&info->res_chk);
- (void) nsep_free_epinfo (info);
- NSFW_LOGINF ("free epinfo]%p", data);
- return TRUE;
-}
-
-int
-nsep_force_epitem_free (void *data)
-{
- struct epitem *item = data;
- if (NULL == item)
- {
- return FALSE;
- }
-
- if (0 != item->pid)
- {
- return FALSE;
- }
-
- res_alloc (&item->res_chk);
- (void) nsep_free_epitem (item);
- NSFW_LOGINF ("free epitem]%p", data);
- return TRUE;
-}
-
-int
-nsep_force_epevent_free (void *data)
-{
- struct eventpoll *epevent = data;
- if (NULL == epevent)
- {
- return FALSE;
- }
-
- if (0 != epevent->pid)
- {
- return FALSE;
- }
-
- res_alloc (&epevent->res_chk);
- (void) nsep_free_eventpoll (epevent);
- NSFW_LOGINF ("free event pool]%p", data);
- return TRUE;
-}
-
-NSTACK_STATIC int
-nsep_init_eventpoll (struct eventpoll *ep)
-{
- if (0 != sem_init (&ep->waitSem, 1, 0))
- {
- return -1;
- }
-
- NSTACK_SEM_MALLOC (ep->lock, 1);
- NSTACK_SEM_MALLOC (ep->sem, 1);
-
- EP_HLIST_INIT (&ep->rdlist);
- ep->ovflist = NSEP_EP_UNACTIVE_PTR;
- ep->rbr.rb_node = NULL;
- ep->epfd = -1;
- return 0;
-}
-
-NSTACK_STATIC void
-nsep_destroy_eventpoll (struct eventpoll *ep)
-{
- (void) sem_destroy (&ep->waitSem);
-}
-
-/**
- * @Function nsep_free_eventpoll
- * @Description free nstack eventpoll
- * @param in ep - the eventpoll to be free
- * @return 0 on success, -1 on error
- */
-int
-nsep_free_eventpoll (struct eventpoll *ep)
-{
- if (!ep)
- return -1;
- struct eventpoll *epEntry = (struct eventpoll *) ep;
- struct eventpoll_pool *pool = &nsep_getManager ()->epollPool;
- NSSOC_LOGDBG ("nsep_free_eventpoll ep:%p, epollPool:%p", ep, pool);
- nsep_destroy_eventpoll (ep);
- ep->pid = 0;
- NSSOC_LOGDBG ("Free eventpool");
- if (res_free (&ep->res_chk))
- {
- NSFW_LOGERR ("ep refree!]epitem=%p", epEntry);
- return 0;
- }
-
- if (nsfw_mem_ring_enqueue (pool->ring, epEntry) != 1)
- {
- NSSOC_LOGERR ("Error to free eventpoll");
- }
-
- return 0;
-}
-
-/**
- * @Function nsep_alloc_eventpoll
- * @Description alloc nstack eventpoll
- * @param out data - the eventpoll alloced
- * @return 0 on success, -1 on error
- */
-int
-nsep_alloc_eventpoll (struct eventpoll **data)
-{
- struct eventpoll *p_head = NULL;
- struct eventpoll_pool *pool = &nsep_getManager ()->epollPool;
-
- NSSOC_LOGDBG ("ring:%p alloc eventpool begin", pool->ring);
- if (0 == nsfw_mem_ring_dequeue (pool->ring, (void *) &p_head)
- || NULL == p_head)
- {
- NSSOC_LOGERR ("ring alloc eventpool failed]ring=%p", pool->ring);
- return -1;
- }
-
- NSSOC_LOGDBG ("alloc eventpool, pid=%u", get_sys_pid ());
- res_alloc (&p_head->res_chk);
- p_head->pid = get_sys_pid ();
-
- if (0 != nsep_init_eventpoll ((struct eventpoll *) p_head))
- {
- NSSOC_LOGERR ("p_head init pid alloc failed]p_head=%p,pid=%d", p_head,
- get_sys_pid ());
- (void) nsep_free_eventpoll ((struct eventpoll *) p_head);
- return -1;
- }
-
- NSSOC_LOGDBG ("ring:%p eventpoll:%p alloc eventpool end", pool->ring,
- p_head);
- *data = p_head;
- return 0;
-}
-
-NSTACK_STATIC int
-nsep_init_epitem (struct epitem *epi)
-{
- int retVal;
- epi->rbn.rb_parent = (struct ep_rb_node *) ADDR_LTOSH_EXT (&epi->rbn);
- EP_HLIST_INIT_NODE (&epi->rdllink);
- EP_HLIST_INIT_NODE (&epi->lkFDllink);
- epi->nwait = 0;
- epi->ep = NULL;
- epi->next = NSEP_EP_UNACTIVE_PTR;
- retVal =
- MEMSET_S (&epi->event, sizeof (epi->event), 0, sizeof (epi->event));
- if (EOK != retVal)
- {
- NSSOC_LOGERR ("MEMSET_S failed]ret=%d", retVal);
- return -1;
- }
-
- EP_LIST_INIT_NODE (&epi->fllink);
- epi->revents = 0;
- epi->ovf_revents = 0;
- epi->fd = -1;
- epi->private_data = NULL;
-
- return 0;
-}
-
-/**
- * @Function nsep_alloc_epitem
- * @Description alloc nstack epitem
- * @param out data - the epitem alloced
- * @return 0 on success, -1 on error
- */
-int
-nsep_alloc_epitem (struct epitem **data)
-{
- struct epitem *p_head_entry = NULL;
- struct epitem_pool *pool = &nsep_getManager ()->epitemPool;
-
- NSSOC_LOGDBG ("epitem alloc begin..");
-
- if (0 == nsfw_mem_ring_dequeue (pool->ring, (void *) &p_head_entry)
- || NULL == p_head_entry)
- {
- NSSOC_LOGERR ("epitem ring alloc failed]ring=%p", pool->ring);
- return -1;
- }
-
- res_alloc (&p_head_entry->res_chk);
- p_head_entry->pid = get_sys_pid ();
-
- if (nsep_init_epitem ((struct epitem *) p_head_entry))
- {
- (void) nsep_free_epitem ((struct epitem *) p_head_entry);
- p_head_entry = NULL;
- NSSOC_LOGERR ("ring epitem init failed]ring=%p,epitem=%p", pool->ring,
- p_head_entry);
- return -1;
- }
-
- NSSOC_LOGDBG ("epitem alloc success..ring:%p head:%p", pool->ring,
- p_head_entry);
- *data = p_head_entry;
- return 0;
-}
-
-typedef int (*nsep_shem_initFn_t) (void *, size_t);
-
-NSTACK_STATIC int
-nsep_epPoolInit (void *addr, size_t length)
-{
- u32_t pos;
- int ret;
-
- NSSOC_LOGDBG ("Start to init eventpoll pool");
-
- ret = MEMSET_S (addr, length, 0, length);
- if (EOK != ret)
- {
- NSSOC_LOGERR ("MEMSET_S failed]ret=%d", ret);
- return -1;
- }
- struct eventpoll *pool = (struct eventpoll *) addr;
- nsep_epollManager_t *manager = nsep_getManager ();
- manager->epollPool.pool = pool;
-
- /* init g_nStackInfo.sockPool->nstack_block_array */
- for (pos = 0; pos < NSTACK_MAX_EPOLL_INFO_NUM; pos++)
- {
- pool[pos].pid = 0;
- if (-1 == nsfw_mem_ring_enqueue (manager->epollPool.ring, &pool[pos]))
- {
- NSSOC_LOGERR ("init fail to enqueue epitem]pos=%u", pos);
- return -1;
- }
- }
- return 0;
-}
-
-NSTACK_STATIC int
-nsep_epitemPoolInit (void *addr, size_t length)
-{
- u32_t pos;
- int ret;
-
- NSSOC_LOGDBG ("Start to init epitem pool");
-
- ret = MEMSET_S (addr, length, 0, length);
- if (EOK != ret)
- {
- NSSOC_LOGERR ("MEMSET_S failed]ret=%d", ret);
- return -1;
- }
- struct epitem *pool = (struct epitem *) addr;
- nsep_epollManager_t *manager = nsep_getManager ();
- manager->epitemPool.pool = pool;
-
- /* init g_nStackInfo.sockPool->nstack_block_array */
- for (pos = 0; pos < NSTACK_MAX_EPITEM_NUM; pos++)
- {
- pool[pos].pid = 0;
- if (-1 == nsfw_mem_ring_enqueue (manager->epitemPool.ring, &pool[pos]))
- {
- NSSOC_LOGERR ("init fail to enqueue epitem]pos=%u", pos);
- return -1;
- }
- }
- return 0;
-}
-
-NSTACK_STATIC int
-nsep_epInfoPoolInit (void *addr, size_t length)
-{
- u32_t pos;
- int ret;
-
- NSSOC_LOGDBG ("shmem info init start");
-
- ret = MEMSET_S (addr, length, 0, length);
- if (EOK != ret)
- {
- NSSOC_LOGERR ("MEMSET_S failed]ret=%d", ret);
- return -1;
- }
- nsep_epollInfo_t *pool = (nsep_epollInfo_t *) addr;
- nsep_epollManager_t *manager = nsep_getManager ();
- manager->infoPool.pool = pool;
-
- /* init g_nStackInfo.sockPool->nstack_block_array */
- for (pos = 0; pos < NSTACK_MAX_EPOLL_INFO_NUM; pos++)
- {
- if (nsep_for_pidinfo_init (&(pool[pos].pidinfo)))
- {
- NSSOC_LOGERR ("pid info init failed]pos=%u", pos);
- return -1;
- }
-
- if (-1 == nsfw_mem_ring_enqueue (manager->infoPool.ring, &pool[pos]))
- {
- NSSOC_LOGERR ("init fail to enqueue epInfo]pos=%u", pos);
- return -1;
- }
- }
-
- NSSOC_LOGDBG ("nstack_shmen_info_init success");
- return 0;
-}
-
-NSTACK_STATIC int
-nsep_create_shmem (size_t length, char *name, nsep_shem_initFn_t initFn)
-{
- nsfw_mem_zone pmeminfo;
- mzone_handle phandle;
- int ret;
-
- pmeminfo.ireserv = 0;
- pmeminfo.isocket_id = NSFW_SOCKET_ANY;
- pmeminfo.length = length;
- ret =
- STRCPY_S (pmeminfo.stname.aname, sizeof (pmeminfo.stname.aname), name);
- if (EOK != ret)
- {
- NSSOC_LOGERR ("STRCPY_S failed]name=%s,ret=%d", name, ret);
- return -1;
- }
- pmeminfo.stname.entype = NSFW_SHMEM;
-
- phandle = nsfw_mem_zone_create (&pmeminfo);
- if (NULL == phandle)
- {
- NSSOC_LOGERR ("create nstack epoll memory failed]name=%s", name);
- return -1;
- }
-
- if (0 != initFn ((void *) phandle, length))
- {
- NSSOC_LOGERR ("Fail to init memory]name=%s", name);
- return -1;
- }
-
- return 0;
-}
-
-NSTACK_STATIC int
-nsep_create_epInfoMem ()
-{
- nsfw_mem_mring pringinfo;
- pringinfo.enmptype = NSFW_MRING_MPMC;
- pringinfo.isocket_id = NSFW_SOCKET_ANY;
- pringinfo.stname.entype = NSFW_SHMEM;
- pringinfo.usnum = NSTACK_MAX_EPOLL_INFO_NUM;
-
- if (-1 ==
- SPRINTF_S (pringinfo.stname.aname, NSFW_MEM_NAME_LENGTH, "%s",
- MP_NSTACK_EPINFO_RING_NAME))
- {
- NSSOC_LOGERR ("Error to create ring]name=%s", pringinfo.stname.aname);
- return -1;
- }
-
- mring_handle ring_handle = nsfw_mem_ring_create (&pringinfo);
-
- if (NULL == ring_handle)
- {
- NSSOC_LOGERR ("Error to create ring]name=%s", pringinfo.stname.aname);
- return -1;
- }
-
- nsep_epollManager_t *manager = nsep_getManager ();
- manager->infoPool.ring = ring_handle;
-
- return nsep_create_shmem (sizeof (nsep_epollInfo_t) *
- NSTACK_MAX_EPOLL_INFO_NUM,
- MP_NSTACK_EPOLL_INFO_NAME, nsep_epInfoPoolInit);
-}
-
-NSTACK_STATIC int
-nsep_adpt_attach_epInfoMem ()
-{
- nsfw_mem_name name;
- name.entype = NSFW_SHMEM;
- name.enowner = NSFW_PROC_MAIN;
-
- if (-1 ==
- SPRINTF_S (name.aname, NSFW_MEM_NAME_LENGTH, "%s",
- MP_NSTACK_EPINFO_RING_NAME))
- {
- NSSOC_LOGERR ("Error to attach ring]name=%s", name.aname);
- return -1;
- }
- mring_handle ring_handle = nsfw_mem_ring_lookup (&name);
-
- if (NULL == ring_handle)
- {
- NSSOC_LOGERR ("Error to attach ring]name=%s", name.aname);
- return -1;
- }
-
- nsep_epollManager_t *manager = nsep_getManager ();
- manager->infoPool.ring = ring_handle;
-
- if (-1 ==
- SPRINTF_S (name.aname, NSFW_MEM_NAME_LENGTH, "%s",
- MP_NSTACK_EPOLL_INFO_NAME))
- {
- NSSOC_LOGERR ("SPRINTF_S failed]");
- return -1;
- }
- manager->infoPool.pool = nsfw_mem_zone_lookup (&name);
- if (NULL == manager->infoPool.pool)
- {
- NSSOC_LOGERR ("Error to attach memzone]name=%s",
- MP_NSTACK_EPOLL_INFO_NAME);
- return -1;
- }
- return 0;
-}
-
-NSTACK_STATIC int
-nsep_create_epItemMem ()
-{
- nsfw_mem_mring pringinfo;
- pringinfo.enmptype = NSFW_MRING_MPMC;
- pringinfo.isocket_id = NSFW_SOCKET_ANY;
- pringinfo.stname.entype = NSFW_SHMEM;
- pringinfo.usnum = NSTACK_MAX_EPITEM_NUM;
-
- if (-1 ==
- SPRINTF_S (pringinfo.stname.aname, NSFW_MEM_NAME_LENGTH, "%s",
- MP_NSTACK_EPITEM_RING_NAME))
- {
- NSSOC_LOGERR ("Error to create ring]name=%s", pringinfo.stname.aname);
- return -1;
- }
-
- mring_handle ring_handle = nsfw_mem_ring_create (&pringinfo);
-
- if (NULL == ring_handle)
- {
- NSSOC_LOGERR ("Error to create ring]name=%s", pringinfo.stname.aname);
- return -1;
- }
-
- nsep_epollManager_t *manager = nsep_getManager ();
- manager->epitemPool.ring = ring_handle;
-
- return nsep_create_shmem (sizeof (struct epitem) * NSTACK_MAX_EPITEM_NUM,
- MP_NSTACK_EPITEM_POOL, nsep_epitemPoolInit);
-}
-
-NSTACK_STATIC int
-nsep_adpt_attach_epItemMem ()
-{
- nsfw_mem_name name;
- name.entype = NSFW_SHMEM;
- name.enowner = NSFW_PROC_MAIN;
-
- if (-1 ==
- SPRINTF_S (name.aname, NSFW_MEM_NAME_LENGTH, "%s",
- MP_NSTACK_EPITEM_RING_NAME))
- {
- NSSOC_LOGERR ("Error to attach epItemMem]name=%s", name.aname);
- return -1;
- }
-
- mring_handle ring_handle = nsfw_mem_ring_lookup (&name);
-
- if (NULL == ring_handle)
- {
- NSSOC_LOGERR ("Error to attach ring]name=%s", name.aname);
- return -1;
- }
-
- nsep_epollManager_t *manager = nsep_getManager ();
- manager->epitemPool.ring = ring_handle;
-
- if (-1 ==
- SPRINTF_S (name.aname, NSFW_MEM_NAME_LENGTH, "%s",
- MP_NSTACK_EPITEM_POOL))
- {
- NSSOC_LOGERR ("SPRINTF_S failed]");
- return -1;
- }
- manager->epitemPool.pool = nsfw_mem_zone_lookup (&name);
- if (NULL == manager->epitemPool.pool)
- {
- NSSOC_LOGERR ("Error to attach memzone]name=%s", MP_NSTACK_EPITEM_POOL);
- return -1;
- }
- return 0;
-}
-
-NSTACK_STATIC int
-nsep_create_eventpollMem ()
-{
- nsfw_mem_mring pringinfo;
- pringinfo.enmptype = NSFW_MRING_MPMC;
- pringinfo.isocket_id = NSFW_SOCKET_ANY;
- pringinfo.stname.entype = NSFW_SHMEM;
- pringinfo.usnum = NSTACK_MAX_EPOLL_NUM;
-
- if (-1 ==
- SPRINTF_S (pringinfo.stname.aname, NSFW_MEM_NAME_LENGTH, "%s",
- MP_NSTACK_EVENTPOOL_RING_NAME))
- {
- NSSOC_LOGERR ("Error to create ring]name=%s", pringinfo.stname.aname);
- return -1;
- }
-
- mring_handle ring_handle = nsfw_mem_ring_create (&pringinfo);
-
- if (NULL == ring_handle)
- {
- NSSOC_LOGERR ("Error to create ring]name=%s", pringinfo.stname.aname);
- return -1;
- }
-
- nsep_epollManager_t *manager = nsep_getManager ();
- manager->epollPool.ring = ring_handle;
-
- return nsep_create_shmem (sizeof (struct eventpoll) * NSTACK_MAX_EPOLL_NUM,
- MP_NSTACK_EVENTPOLL_POOL, nsep_epPoolInit);
-}
-
-NSTACK_STATIC int
-nsep_adpt_attach_eventpollMem ()
-{
- nsfw_mem_name name;
- name.entype = NSFW_SHMEM;
- name.enowner = NSFW_PROC_MAIN;
-
- if (-1 ==
- SPRINTF_S (name.aname, NSFW_MEM_NAME_LENGTH, "%s",
- MP_NSTACK_EVENTPOOL_RING_NAME))
- {
- NSSOC_LOGERR ("Error to attach ring]name=%s", name.aname);
- return -1;
- }
-
- mring_handle ring_handle = nsfw_mem_ring_lookup (&name);
-
- if (NULL == ring_handle)
- {
- NSSOC_LOGERR ("Error to create ring]name=%s", name.aname);
- return -1;
- }
-
- nsep_epollManager_t *manager = nsep_getManager ();
- manager->epollPool.ring = ring_handle;
-
- int retVal = SPRINTF_S (name.aname, NSFW_MEM_NAME_LENGTH, "%s",
- MP_NSTACK_EVENTPOLL_POOL);
- if (-1 == retVal)
- {
- NSSOC_LOGERR ("SPRINTF_S failed]ret=%d", retVal);
- return -1;
- }
- manager->epollPool.pool = nsfw_mem_zone_lookup (&name);
- if (NULL == manager->epollPool.pool)
- {
- NSSOC_LOGERR ("Error to attach memzone]name=%s",
- MP_NSTACK_EVENTPOLL_POOL);
- return -1;
- }
-
- return 0;
-}
-
-int
-nsep_create_memory ()
-{
- typedef int (*nsep_createMemFunc_t) (void);
- nsep_createMemFunc_t createFuncs[] = { nsep_create_epInfoMem,
- nsep_create_epItemMem,
- nsep_create_eventpollMem
- };
-
- int i = 0;
- for (i = 0;
- i < (int) (sizeof (createFuncs) / sizeof (nsep_createMemFunc_t)); i++)
- {
- if (-1 == createFuncs[i] ())
- return -1;
- }
-
- return 0;
-}
-
-int
-nsep_adpt_attach_memory ()
-{
- typedef int (*nsep_attachMemFunc_t) (void);
- nsep_attachMemFunc_t attachFuncs[] = { nsep_adpt_attach_epInfoMem,
- nsep_adpt_attach_epItemMem,
- nsep_adpt_attach_eventpollMem
- };
-
- int i = 0;
- for (i = 0;
- i < (int) (sizeof (attachFuncs) / sizeof (nsep_attachMemFunc_t)); i++)
- {
- if (-1 == attachFuncs[i] ())
- {
- NSSOC_LOGERR ("mem attach fail]idx=%d", i);
- return -1;
- }
- }
-
- return 0;
-}
-
-int
-nsep_adpt_reg_res_mgr ()
-{
-
- nsep_epollManager_t *manager = nsep_getManager ();
-
- nsfw_res_scn_cfg scn_cfg_info = { NSFW_RES_SCAN_ARRAY, 90, 3, 16,
- NSTACK_MAX_EPOLL_INFO_NUM / 128, NSTACK_MAX_EPOLL_INFO_NUM,
- sizeof (nsep_epollInfo_t),
- offsetof (nsep_epollInfo_t, res_chk),
- manager->infoPool.pool,
- manager->infoPool.ring,
- nsep_force_epinfo_free
- };
-
- nsfw_res_scn_cfg scn_cfg_item = { NSFW_RES_SCAN_ARRAY, 90, 3, 16,
- NSTACK_MAX_EPITEM_NUM / 128, NSTACK_MAX_EPITEM_NUM,
- sizeof (struct epitem),
- offsetof (struct epitem, res_chk),
- manager->epitemPool.pool,
- manager->epitemPool.ring,
- nsep_force_epitem_free
- };
-
- nsfw_res_scn_cfg scn_cfg_event = { NSFW_RES_SCAN_ARRAY, 90, 3, 16,
- NSTACK_MAX_EPOLL_NUM / 128, NSTACK_MAX_EPOLL_NUM,
- sizeof (struct eventpoll),
- offsetof (struct eventpoll, res_chk),
- manager->epollPool.pool,
- manager->epollPool.ring,
- nsep_force_epevent_free
- };
-
- (void) nsfw_res_mgr_reg (&scn_cfg_info);
- (void) nsfw_res_mgr_reg (&scn_cfg_item);
- (void) nsfw_res_mgr_reg (&scn_cfg_event);
- return 0;
-}
-
-int
-nsep_epitem_remove (nsep_epollInfo_t * pinfo, u32 pid)
-{
- struct list_node *prenode = NULL;
- struct list_node *nextnode = NULL;
- struct epitem *epi = NULL;
- u32_t i = 0;
- int icnt = 0;
- (void) sys_arch_lock_with_pid (&pinfo->epiLock);
- /*list head must be not null */
- prenode = (struct list_node *) ADDR_SHTOL (pinfo->epiList.head);
- nextnode = (struct list_node *) ADDR_SHTOL (prenode->next);
- while ((nextnode) && (i++ <= NSTACK_MAX_EPOLL_INFO_NUM))
- {
- epi = ep_list_entry (nextnode, struct epitem, fllink);
- if (pid == epi->pid)
- {
- /*shmem equal to shmem */
- prenode->next = nextnode->next;
- nextnode->next = NULL;
- (void) nsep_free_epitem (epi);
- nextnode = ADDR_SHTOL (prenode->next);
- icnt++;
- continue;
- }
- prenode = nextnode;
- nextnode = ADDR_SHTOL (nextnode->next);
- }
- sys_sem_s_signal (&pinfo->epiLock);
- if (i >= NSTACK_MAX_EPOLL_INFO_NUM)
- {
- NSSOC_LOGERR ("free pinfo:%p pid:%u, error maybe happen", pinfo, pid);
- }
- return icnt;
-}
-
-void
-nsep_recycle_epfd (void *epinfo, u32 pid)
-{
- struct eventpoll *ep = NULL;
- nsep_epollInfo_t *info = (nsep_epollInfo_t *) epinfo;
- int ret = 0;
- int ileftcnt = 0;
- if (!epinfo)
- {
- NSSOC_LOGDBG ("input null, pid:%u", pid);
- return;
- }
- (void) sys_arch_lock_with_pid (&info->freeLock);
- ileftcnt = nsep_del_last_pid (&info->pidinfo, pid);
- sys_sem_s_signal (&info->freeLock);
- /*no pid exist */
- if (-1 == ileftcnt)
- {
- return;
- }
- if (NSTACK_EPOL_FD == info->fdtype)
- {
- NSSOC_LOGDBG ("recycle epfd:%d epinfo pid:%u begin...", info->fd, pid);
- if (0 == ileftcnt)
- {
- ep = ADDR_SHTOL (info->ep);
- info->ep = NULL;
- (void) nsep_free_eventpoll (ep);
- (void) nsep_free_epinfo (info);
- }
- return;
- }
-
- NSSOC_LOGDBG ("recycle fd:%d epinfo pid:%u begin...", info->fd, pid);
-
- ret = nsep_epitem_remove (info, pid);
- if (0 != ret)
- {
- NSSOC_LOGINF ("info:%p, fd:%d pid:%u, %d items was left", info,
- info->fd, pid, ret);
- }
-
- if (0 == ileftcnt)
- {
- NSSOC_LOGINF ("info:%p, fd:%d pid:%u was finally freed", info, info->fd,
- pid);
- (void) nsep_free_epinfo (info);
- }
- return;
-}
-
-int
-nsep_recycle_ep (u32 pid)
-{
- nsep_epollManager_t *manager = nsep_getManager ();
- nsep_epollInfo_t *pool = manager->infoPool.pool;
-
- u32_t pos;
- for (pos = 0; pos < NSTACK_MAX_EPOLL_INFO_NUM; pos++)
- {
- (void) nsep_recycle_epfd (&pool[pos], pid);
- }
- return 0;
-}
-
-NSTACK_STATIC int
-nsep_recycle_epItem (u32 pid)
-{
- nsep_epollManager_t *manager = nsep_getManager ();
- struct epitem *pool = manager->epitemPool.pool;
-
- u32_t pos;
- for (pos = 0; pos < NSTACK_MAX_EPITEM_NUM; pos++)
- {
- if (pool[pos].pid != pid)
- continue;
-
- if (-1 == nsep_free_epitem (&pool[pos]))
- return -1;
- }
-
- return 0;
-}
-
-NSTACK_STATIC int
-nsep_recycle_eventpoll (u32 pid)
-{
- nsep_epollManager_t *manager = nsep_getManager ();
- struct eventpoll *pool = manager->epollPool.pool;
-
- u32_t pos;
- for (pos = 0; pos < NSTACK_MAX_EPOLL_INFO_NUM; pos++)
- {
- if (pool[pos].pid != pid)
- continue;
-
- if (-1 == nsep_free_eventpoll (&pool[pos]))
- return -1;
- }
-
- return 0;
-}
-
-NSTACK_STATIC
- nsfw_rcc_stat nsep_recycle_resource (u32 exit_pid, void *pdata,
- u16 rec_type)
-{
- NSSOC_LOGINF ("pid:%u recycle", exit_pid);
- (void) nsep_recycle_epItem (exit_pid);
- (void) nsep_recycle_eventpoll (exit_pid);
- return NSFW_RCC_CONTINUE;
-}
-
-NSTACK_STATIC
- nsfw_rcc_stat nsep_recycle_lock (u32 pid, void *pdata, u16 rec_type)
-{
- nsep_epollManager_t *manager = nsep_getManager ();
- nsep_epollInfo_t *pool = manager->infoPool.pool;
- u32_t pos;
- if (NULL != pool)
- {
- for (pos = 0; pos < NSTACK_MAX_EPOLL_INFO_NUM; pos++)
- {
- if (pid == pool[pos].epiLock.locked)
- {
- pool[pos].epiLock.locked = 0;
- NSFW_LOGWAR ("epiLock locked]pos=%u,pid=%u", pos, pid);
- }
- if (pid == pool[pos].freeLock.locked)
- {
- pool[pos].freeLock.locked = 0;
- NSFW_LOGWAR ("freelock locked]pos=%u,pid=%u", pos, pid);
- }
- }
- }
-
- struct eventpoll *ev_pool = manager->epollPool.pool;
- if (NULL != ev_pool)
- {
- for (pos = 0; pos < NSTACK_MAX_EPOLL_NUM; pos++)
- {
- if (pid == ev_pool[pos].lock.locked)
- {
- ev_pool[pos].lock.locked = 0;
- NSFW_LOGWAR ("event_pollLock locked]pos=%u,pid=%u", pos, pid);
- }
-
- if (pid == ev_pool[pos].sem.locked)
- {
- ev_pool[pos].sem.locked = 0;
- NSFW_LOGWAR ("event_pollLock sem]pos=%u,pid=%u", pos, pid);
- }
- }
- }
-
- return NSFW_RCC_CONTINUE;
-}
-
-REGIST_RECYCLE_OBJ_FUN (NSFW_REC_NSOCKET_EPOLL,
- nsep_recycle_resource)
-REGIST_RECYCLE_LOCK_REL (nsep_recycle_lock, NULL, NSFW_PROC_NULL)
diff --git a/src/adapt/nstack_share_res.c b/src/adapt/nstack_share_res.c
deleted file mode 100644
index 9466145..0000000
--- a/src/adapt/nstack_share_res.c
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "nstack_share_res.h"
-#include "nsfw_mem_api.h"
-#include "types.h"
-#include "nsfw_recycle_api.h"
-#include "nstack_securec.h"
-#include "nstack_log.h"
-#include "nsfw_maintain_api.h"
-#include "nstack_types.h"
-
-#define NSTACK_SHARE_FORK_LOCK "share_fork_lock"
-
-typedef struct
-{
- common_mem_spinlock_t *fork_share_lock;
-} nstack_share_res;
-
-NSTACK_STATIC nstack_share_res g_nstack_share_res;
-
-/** global timer tick */
-nstack_tick_info_t g_nstack_timer_tick;
-
-NSTACK_STATIC int
-nstack_create_share_fork_lock ()
-{
- mzone_handle zone;
- nsfw_mem_zone param;
- int ret;
-
- param.isocket_id = -1;
- param.length = sizeof (common_mem_spinlock_t);
- param.stname.entype = NSFW_SHMEM;
-
- ret =
- STRCPY_S (param.stname.aname, NSFW_MEM_NAME_LENGTH,
- NSTACK_SHARE_FORK_LOCK);
- if (EOK != ret)
- {
- NSSOC_LOGERR ("STRCPY_S failed]name=%s,ret=%d", NSTACK_SHARE_FORK_LOCK,
- ret);
- return -1;
- }
-
- zone = nsfw_mem_zone_create (&param);
- if (!zone)
- {
- NSSOC_LOGERR ("nsfw_mem_zone_create failed]name=%s",
- NSTACK_SHARE_FORK_LOCK);
- return -1;
- }
-
- g_nstack_share_res.fork_share_lock = (common_mem_spinlock_t *) zone;
- common_mem_spinlock_init (g_nstack_share_res.fork_share_lock);
-
- NSSOC_LOGDBG ("ok");
- return 0;
-}
-
-NSTACK_STATIC int
-nstack_lookup_share_fork_lock ()
-{
- mzone_handle zone;
- nsfw_mem_name param;
-
- param.entype = NSFW_SHMEM;
- param.enowner = NSFW_PROC_MAIN;
- if (STRCPY_S (param.aname, NSFW_MEM_NAME_LENGTH, NSTACK_SHARE_FORK_LOCK) !=
- 0)
- {
- NSSOC_LOGERR ("STRCPY_S failed]name=%s", NSTACK_SHARE_FORK_LOCK);
- return -1;
- }
-
- zone = nsfw_mem_zone_lookup (&param);
- if (!zone)
- {
- NSSOC_LOGERR ("nsfw_mem_zone_lookup failed]name=%s",
- NSTACK_SHARE_FORK_LOCK);
- return -1;
- }
-
- g_nstack_share_res.fork_share_lock = (common_mem_spinlock_t *) zone;
-
- NSSOC_LOGDBG ("ok");
-
- return 0;
-}
-
-NSTACK_STATIC int
-nstack_lookup_share_global_tick ()
-{
- int ret;
- nsfw_mem_name name = {.entype = NSFW_SHMEM,.enowner = NSFW_PROC_MAIN };
-
- ret = STRCPY_S (name.aname, NSFW_MEM_NAME_LENGTH, NSTACK_GLOBAL_TICK_SHM);
- if (EOK != ret)
- {
- NSSOC_LOGERR ("STRCPY_S failed]name=%s,ret=%d", NSTACK_GLOBAL_TICK_SHM,
- ret);
- return -1;
- }
-
- g_nstack_timer_tick.tick_ptr = (u64_t *) nsfw_mem_zone_lookup (&name);
- if (NULL == g_nstack_timer_tick.tick_ptr)
- {
- NSPOL_LOGERR ("Failed to lookup global timer tick memory");
- return -1;
- }
-
- NSSOC_LOGDBG ("ok");
- return 0;
-}
-
-int
-nstack_init_share_res ()
-{
- if (nstack_create_share_fork_lock () != 0)
- {
- return -1;
- }
-
- return 0;
-}
-
-int
-nstack_attach_share_res ()
-{
- if (nstack_lookup_share_fork_lock () != 0)
- {
- return -1;
- }
-
- if (nstack_lookup_share_global_tick () != 0)
- {
- return -1;
- }
-
- return 0;
-}
-
-common_mem_spinlock_t *
-nstack_get_fork_share_lock ()
-{
- return g_nstack_share_res.fork_share_lock;
-}
-
-NSTACK_STATIC nsfw_rcc_stat
-nstack_recycle_fork_share_lock (u32 exit_pid, void *pdata, u16 rec_type)
-{
- NSSOC_LOGDBG ("recycle]pid=%u", exit_pid);
-
- if (g_nstack_share_res.fork_share_lock
- && (g_nstack_share_res.fork_share_lock->locked == exit_pid))
- {
- common_mem_spinlock_unlock (g_nstack_share_res.fork_share_lock);
- }
-
- return NSFW_RCC_CONTINUE;
-}
-
-REGIST_RECYCLE_LOCK_REL (nstack_recycle_fork_share_lock, NULL, NSFW_PROC_APP)
diff --git a/src/adapt/nstack_share_res.h b/src/adapt/nstack_share_res.h
deleted file mode 100644
index 2737730..0000000
--- a/src/adapt/nstack_share_res.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef NSTACK_SHARE_RES_H
-#define NSTACK_SHARE_RES_H
-
-#include <stdint.h>
-#include "common_mem_spinlock.h"
-#include "nstack_log.h"
-#include "common_func.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-#define NSTACK_VERSION_SHM "nstack_version"
-#define NSTACK_VERSION_LEN 128
-COMPAT_PROTECT (NSTACK_VERSION_LEN, 128);
-#define MAX_UNMATCH_VER_CNT 32
-COMPAT_PROTECT (MAX_UNMATCH_VER_CNT, 32);
-
-#define NSTACK_GLOBAL_TICK_SHM "nstack_global_tick"
-
-typedef struct unmatch_ver_info
-{
- int unmatch_count;
- char lib_version[NSTACK_VERSION_LEN];
- char first_time_stamp[LOG_TIME_STAMP_LEN];
-} unmatch_ver_info_t;
-
-#define DFX_TMR_INTERVAL 60000 /*60 seconds */
-typedef struct nstack_tick_info
-{
- uint64_t *tick_ptr; // tick from shared memory
- uint64_t interval; // tick interval, only used in stack process
- /* tick reference, updated periodically and read in tcpip_thread only */
- struct timeval ref_time; // ref tick time
- uint64_t ref_tick; // ref tick
-} nstack_tick_info_t;
-
-int nstack_init_share_res ();
-int nstack_attach_share_res ();
-common_mem_spinlock_t *nstack_get_fork_share_lock ();
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif
diff --git a/src/framework/CMakeLists.txt b/src/framework/CMakeLists.txt
index 6b22e51..138b45d 100644
--- a/src/framework/CMakeLists.txt
+++ b/src/framework/CMakeLists.txt
@@ -14,50 +14,34 @@
# limitations under the License.
#########################################################################
-if(WITH_HAL_LIB)
-else()
- SET(PAL_H_DIRECTORIES "/usr/include/dpdk/")
- FILE(GLOB_RECURSE LIBCOMM lib_common_mem/*.c)
-endif()
-
FILE(GLOB_RECURSE COMMON common/*.c)
FILE(GLOB INIT init/*.c)
FILE(GLOB_RECURSE IPC ipc/*.c)
FILE(GLOB LOG log/*.c)
FILE(GLOB SNAPSHOT snapshot/*.c)
-FILE(GLOB STARTUP startup/*.c)
FILE(GLOB MAINTAIN maintain/*.c)
+FILE(GLOB EVENT event/epoll/*.c)
FILE(GLOB HAL hal/*.c)
-FILE(GLOB DMM_ADPT ../adapt/*.c)
-FILE(GLOB MEM mem/*.c)
-
-ADD_LIBRARY(dmm_api SHARED
- ${COMMON} ${INIT} ${IPC} ${LOG} ${SNAPSHOT}
- ${STARTUP} ${MAINTAIN} ${TRACEING} ${HAL}
- ${DMM_ADPT} ${LIBCOMM} ${MEM})
-
-if(WITH_SECUREC_LIB)
-ADD_DEPENDENCIES(dmm_api SECUREC JSON GLOG)
-else()
-ADD_DEPENDENCIES(dmm_api JSON GLOG)
-endif()
+FILE(GLOB RD rd/*.c)
+FILE(GLOB RES res/*.c)
+FILE(GLOB_RECURSE MEM mem/*.c)
+FILE(GLOB RING ring/*.c)
+FILE(GLOB DFX dfx/*.c)
INCLUDE_DIRECTORIES(
- dmm_api
- PRIVATE
- ${JSON_C_SRC}
- ${GLOG_SRC}
- ${SECUREC_SRC_H}
- ipc/mgr_com/
- hal/
- include/
- common/base/include/generic
- common/base/include/
- ${PAL_H_DIRECTORIES}
- common/base/liblinuxapi/
- common/mem_mgr/include
- common/mem_mgr/nsfw_shmem/
- common/mem_mgr/nsfw_nshmem/
- ${CMAKE_CURRENT_LIST_DIR}/../nSocket/nstack/event/
- ${CMAKE_CURRENT_LIST_DIR}/../nSocket/nstack/event/epoll
- ${CMAKE_CURRENT_LIST_DIR}/../nSocket/include
+ nStackFw
+ PRIVATE
+ ${JSON_C_SRC}
+ ${GLOG_SRC}
+ ${CMAKE_SOURCE_DIR}/src/include
+ ${CMAKE_SOURCE_DIR}/src/nSocket/nstack
+ ${CMAKE_SOURCE_DIR}/src/nSocket/include
+ ${CMAKE_CURRENT_LIST_DIR}/ipc/mgr_com
+ ${CMAKE_CURRENT_LIST_DIR}/include/common/
+ ${CMAKE_CURRENT_LIST_DIR}/include/common/generic
+ ${CMAKE_CURRENT_LIST_DIR}/common/base/liblinuxapi
+ ${CMAKE_CURRENT_LIST_DIR}/dfx
+ ${CMAKE_CURRENT_LIST_DIR}/mem/basic_mem
+ ${CMAKE_SOURCE_DIR}/src/framework/event/epoll
)
+ADD_LIBRARY(nStackFw STATIC ${COMMON} ${INIT} ${IPC} ${LOG} ${SNAPSHOT} ${MAINTAIN} ${TRACEING} ${EVENT} ${RES} ${RD} ${HAL} ${MEM} ${RING} ${DFX})
+ADD_DEPENDENCIES(nStackFw JSON GLOG DPDK)
diff --git a/src/framework/common/base/include/common/common_func.h b/src/framework/common/base/include/common/common_func.h
deleted file mode 100644
index 2b84b7a..0000000
--- a/src/framework/common/base/include/common/common_func.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _RTE_COMM_FUNC_H_
-#define _RTE_COMM_FUNC_H_
-
-#ifdef HAL_LIB
-
-#else
-
-#define common_mem_rwlock_t rte_rwlock_t
-#define common_mem_spinlock_t rte_spinlock_t
- //typedef rte_rwlock_t common_mem_rwlock_t;
-
-#define nsfw_write_lock(plock) rte_rwlock_write_lock(plock)
-#define nsfw_write_unlock(plock) rte_rwlock_write_unlock(plock)
-#define nsfw_read_lock(plock) rte_rwlock_read_lock(plock)
-#define nsfw_read_unlock(plock) rte_rwlock_read_unlock(plock)
-
-#define common_mem_align32pow2 rte_align32pow2
-
-#define common_mem_atomic32_cmpset rte_atomic32_cmpset
-#define common_mem_pause rte_pause
-
-#define COMMON_MEM_MAX_MEMZONE RTE_MAX_MEMZONE
-
-#define common_mem_atomic32_t rte_atomic32_t
-
-#define common_mem_memseg rte_memseg
-#define common_mem_mem_config rte_mem_config
-
-#define common_mem_pal_get_configuration rte_eal_get_configuration
-
- //#define commem_mem_pal_module_info rte_eal_module_info
- //
-#define common_mem_pal_init rte_eal_init
-
-#define COMMON_MEM_MEMPOOL_NAMESIZE RTE_MEMPOOL_NAMESIZE
-
-#define common_mem_memzone_lookup rte_memzone_lookup
-#define common_mem_memzone rte_memzone
-#define common_mem_atomic32_add_return rte_atomic32_add_return
-
-#define common_mem_spinlock_init rte_spinlock_init
-#define common_mem_spinlock_lock rte_spinlock_lock
-#define common_mem_spinlock_unlock rte_spinlock_unlock
-
-#define common_mem_memzone_free rte_memzone_free
-#define common_mem_pktmbuf_pool_create rte_pktmbuf_pool_create
-
-#define common_mem_pktmbuf_alloc rte_pktmbuf_alloc
-
-#define common_mem_mempool rte_mempool
-
-#define common_mem_pktmbuf_free rte_pktmbuf_free
-#define common_mem_mbuf rte_mbuf
-
-#define common_mem_mempool_lookup rte_mempool_lookup
-
-#define common_mem_ring_get_memsize rte_ring_get_memsize
-#define common_mem_ring rte_ring
-
-#define COMMON_MEM_MAX_MEMSEG RTE_MAX_MEMSEG
-
-#define common_mem_memzone_reserve rte_memzone_reserve
-#define common_mem_rwlock_read_lock rte_rwlock_read_lock
-#define common_mem_rwlock_read_unlock rte_rwlock_read_unlock
-
-#define common_mem_rwlock_write_lock rte_rwlock_write_lock
-#define common_mem_rwlock_write_unlock rte_rwlock_write_unlock
-#define common_mem_spinlock_trylock rte_spinlock_trylock
-
-#define common_mem_socket_id rte_socket_id
-#define common_mem_malloc_socket_stats rte_malloc_socket_stats
-
-#define COMMON_MEM_MIN RTE_MIN
-
-#define common_pal_module_init nscomm_pal_module_init
-#define common_memzone_data_reserve_name nscomm_memzone_data_reserve_name
-#define common_memzone_data_lookup_name nscomm_memzone_data_lookup_name
-
-#define common_dump_stack rte_dump_stack
-#define COMMON_PKTMBUF_HEADROOM RTE_PKTMBUF_HEADROOM
-
-#define common_pktmbuf_mtod rte_pktmbuf_mtod
-#define common_memcpy rte_memcpy
-#define common_spinlock_try_lock_with_pid dmm_spinlock_try_lock_with_pid
-#define common_spinlock_unlock rte_spinlock_unlock
-#define common_atomic64_t rte_atomic64_t
-#define common_atomic64_inc rte_atomic64_inc
-#define common_atomic64_read rte_atomic64_read
-#define common_atomic64_dec rte_atomic64_dec
-#define common_mbuf_refcnt_set rte_mbuf_refcnt_set
-#define common_mbuf_refcnt_read rte_mbuf_refcnt_read
-#define common_exit rte_exit
-#define COMMON_CACHE_LINE_SIZE RTE_CACHE_LINE_SIZE
-#define common_eal_process_type rte_eal_process_type
-#define COMMON_PROC_PRIMARY RTE_PROC_PRIMARY
-
-#endif
-
-#endif // _RTE_COMM_FUNC_H_
diff --git a/src/framework/common/base/include/common/common_mem_api.h b/src/framework/common/base/include/common/common_mem_api.h
deleted file mode 100644
index 40b01b9..0000000
--- a/src/framework/common/base/include/common/common_mem_api.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef __COMMON_MEM_API_H__
-#define __COMMON_MEM_API_H__
-
-#ifdef HAL_LIB
-#else
-
-#include "rte_atomic.h"
-#include "common_mem_spinlock.h"
-#include <sys/types.h>
-#include <unistd.h>
-#include <semaphore.h>
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-#ifndef NSTACK_LINT_CODE_DISABLE
-#define NSTACK_LINT_CODE_DISABLE(code) /*lint -e#code */
-#endif
-
-#ifndef NSTACK_LINT_CODE_ENABLE
-#define NSTACK_LINT_CODE_ENABLE(code) /*lint +e#code */
-#endif
-
-#define SYS_MBOX_NULL (sys_mbox_t)0
-
-typedef sem_t *sys_sem_t_v1;
-typedef sem_t sys_sem_st_v1;
-typedef struct queue *sys_mbox_t;
-
-typedef rte_spinlock_t *sys_sem_t_v2;
-typedef rte_spinlock_t sys_sem_st_v2;
-
-#ifndef u32_t
-typedef uint32_t u32_t;
-#endif
-
-#ifndef u8_t
-typedef uint8_t u8_t;
-#endif
-
-#ifndef s8_t
-typedef int8_t s8_t;
-#endif
-
-#ifndef err_t
-typedef s8_t err_t;
-#endif
-
-/** Return code for timeouts from sys_arch_mbox_fetch and sys_arch_sem_wait */
-#define SYS_ARCH_TIMEOUT 0xffffffffUL
-
-/** sys_mbox_tryfetch() returns SYS_MBOX_EMPTY if appropriate.
- * For now we use the same magic value, but we allow this to change in future.
- */
-#define SYS_MBOX_EMPTY SYS_ARCH_TIMEOUT
-
-void sys_sem_signal_s_v2 (sys_sem_t_v2 sem);
-void sys_sem_init_v2 (sys_sem_t_v2 sem);
-u32_t sys_arch_sem_trywait_v2 (sys_sem_t_v2 * sem);
-
-u32_t sys_arch_sem_wait_s_v2 (sys_sem_t_v2 sem);
-
-#define SYS_HOST_INITIAL_PID 1
-extern volatile pid_t g_sys_host_pid;
-pid_t sys_get_hostpid_from_file (pid_t pid);
-static inline pid_t
-get_sys_pid ()
-{
- if (SYS_HOST_INITIAL_PID == g_sys_host_pid)
- (void) sys_get_hostpid_from_file (getpid ());
- return g_sys_host_pid;
-}
-
-pid_t update_sys_pid ();
-u32_t sys_now (void);
-
-#define sys_sem_t sys_sem_t_v2
-#define sys_sem_st sys_sem_st_v2
-#define sys_sem_new(sem, count) sys_sem_new_v2(sem, count)
-#define sys_sem_free(sem) sys_sem_free_v2(sem)
-#define sys_sem_signal(sem) sys_sem_signal_v2(sem)
-#define sys_arch_sem_wait(sem, timeout) sys_arch_sem_wait_v2(sem)
-#define sys_arch_sem_trywait(sem) sys_arch_sem_trywait_v2(sem)
-
-#define sys_sem_init(sem) sys_sem_init_v2(sem)
-#define sys_sem_s_signal(sem) sys_sem_signal_s_v2(sem)
-#define sys_arch_sem_s_wait(sem, timeout) sys_arch_sem_wait_s_v2(sem)
-#define sys_arch_lock_with_pid(sem) (void)sys_arch_lock_with_pid_v2(sem)
-
-#define BUF_SIZE_FILEPATH 256
-#define STR_PID "pid:"
-#define READ_FILE_BUFLEN 512
-
-extern pid_t sys_get_hostpid_from_file (pid_t pid);
-extern pid_t get_hostpid_from_file (u32_t pid);
-extern void get_exec_name_by_pid (pid_t pid, char *task_name,
- int task_name_len);
-
-static inline u32_t
-sys_arch_lock_with_pid_v2 (sys_sem_t_v2 sem)
-{
- if (SYS_HOST_INITIAL_PID == g_sys_host_pid)
- (void) sys_get_hostpid_from_file (getpid ());
- dmm_spinlock_lock_with_pid (sem, g_sys_host_pid);
- return 0;
-}
-
-#define NSTACK_SEM_MALLOC(sys_sem,count) \
-{ \
- rte_spinlock_init(&(sys_sem)); \
- if (!(count)) \
- { \
- rte_spinlock_lock(&(sys_sem)); \
- } \
-}
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-#endif
-
-#endif /* __COMMON_MEM_API_H__ */
diff --git a/src/framework/common/base/include/common/common_mem_base_type.h b/src/framework/common/base/include/common/common_mem_base_type.h
deleted file mode 100644
index 01707d9..0000000
--- a/src/framework/common/base/include/common/common_mem_base_type.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _COMMON_MEM_BASE_TYPE_H_
-#define _COMMON_MEM_BASE_TYPE_H_
-
-#ifdef HAL_LIB
-
-#else
-
-#define ALIGN_TYPE uint64_t
-#define PTR_ALIGN_TYPE uint64_t
-
-/*alignment define*/
-#define ALIGNMENT_DEF(name, type, aligntype) \
- union { \
- type name; \
- aligntype name##_align; \
- }
-
-#define PTR_ALIGNMENT_DEF(name, type) ALIGNMENT_DEF(name, type, PTR_ALIGN_TYPE)
-
-#define OTHER_ALIGNMENT_DEF(name, type) ALIGNMENT_DEF(name, type, ALIGN_TYPE)
-
-/*
- * * List definitions.
- * */
-#define DMM_LIST_HEAD(name, type) \
-struct name { \
- PTR_ALIGNMENT_DEF(lh_first, struct type *); /* first element */ \
-}
-
-#define DMM_LIST_ENTRY(type) \
-struct { \
- PTR_ALIGNMENT_DEF(le_next, struct type *); /* next element */\
- PTR_ALIGNMENT_DEF(le_prev, struct type **); /* address of previous next element */ \
-}
-
-/*
- * * Tail queue definitions.
- * */
-#define _DMM_TAILQ_HEAD(name, type, qual) \
-struct name { \
- PTR_ALIGNMENT_DEF(tqh_first, qual type *); /* first element */ \
- PTR_ALIGNMENT_DEF(tqh_last, qual type * qual *); /* addr of last next element */ \
-}
-
-#define DMM_TAILQ_HEAD(name, type) _DMM_TAILQ_HEAD(name, struct type,)
-
-#define _DMM_TAILQ_ENTRY(type, qual) \
-struct { \
- PTR_ALIGNMENT_DEF(tqe_next, qual type *); /* next element */\
- PTR_ALIGNMENT_DEF(tqe_prev, qual type * qual*); /* address of previous next element */\
-}
-#define DMM_TAILQ_ENTRY(type) _DMM_TAILQ_ENTRY(struct type,)
-
-/*
- * * Singly-linked Tail queue declarations.
- * */
-#define DMM_STAILQ_HEAD(name, type) \
- struct name { \
- PTR_ALIGNMENT_DEF(stqh_first, struct type *); /* first element */ \
- PTR_ALIGNMENT_DEF(stqh_last, struct type **); /* addr of last next element */ \
- }
-
-#define DMM_STAILQ_ENTRY(type) \
- struct { \
- PTR_ALIGNMENT_DEF(stqe_next, struct type *); /* next element */ \
- }
-#endif
-
-#endif
diff --git a/src/framework/common/base/include/common/common_mem_buf.h b/src/framework/common/base/include/common/common_mem_buf.h
deleted file mode 100644
index c9bb9fd..0000000
--- a/src/framework/common/base/include/common/common_mem_buf.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _COMMON_MEM_BUF_H_
-#define _COMMON_MEM_BUF_H_
-
-#ifdef HAL_LIB
-#else
-
-#include "nsfw_mem_api.h"
-#include "common_mem_base_type.h"
-#include "types.h"
-
-typedef enum __DMM_PROC_TYPE
-{
- DMM_PROC_T_AUTO = 0, /*auto detect */
- DMM_PROC_T_PRIMARY = 1, /* set to primary */
- DMM_PROC_T_SECONDARY = 2, /* set to secondary */
- DMM_PROC_T_INVALID
-} DMM_PROC_TYPE;
-
-#define DMM_MBUF_RET_OK 0
-#define DMM_MBUF_RET_ERR 1
-
-#define LCORE_MAX 128
-#define LCORE_MASK_PER (sizeof(int) * 8)
-#define LCORE_MASK_MAX (LCORE_MAX/LCORE_MASK_PER)
-
-#define LCORE_MASK_SET(ilcoremask, value) \
- if (value < LCORE_MAX) \
- { \
- ilcoremask[(value/LCORE_MASK_PER)] = (int) ( (ilcoremask[(value/LCORE_MASK_PER)]) | (1< (value%LCORE_MASK_PER))); \
- } \
-
-#define DMM_HUGTBL_ENABLE 0
-#define DMM_HUGTBL_DISABLE 1
-
-typedef struct __common_pal_module_info
-{
- int ishare_mem_size; /*shared memory size */
- int ilcoremask[LCORE_MASK_MAX];
- /**/ unsigned char uchugeflag;
- unsigned char ucproctype;
- unsigned char ucinstance;
- unsigned char ucresrv2;
-} common_mem_pal_module_info;
-
-/**
- * rte pal module init.
- *
- *
- * @param name
- * The name of the buf pool.
- */
-int nscomm_pal_module_init (nsfw_mem_para * para,
- common_mem_pal_module_info * pinfo, u8 app_mode);
-
-void *nscomm_memzone_data_reserve_name (const char *name, size_t len,
- int socket_id);
-
-void *nscomm_memzone_data_lookup_name (const char *name);
-
-#endif
-
-#endif /* _COMMON_MEM_BUF_H_ */
diff --git a/src/framework/common/base/include/common/common_mem_malloc.h b/src/framework/common/base/include/common/common_mem_malloc.h
deleted file mode 100644
index 68721cd..0000000
--- a/src/framework/common/base/include/common/common_mem_malloc.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _COMMON_MEM_MALLOC_H_
-#define _COMMON_MEM_MALLOC_H_
-
-#ifdef HAL_LIB
-#else
-#include "rte_malloc.h"
-#endif
-
-#endif /* _COMMON_MEM_MALLOC_H_ */
diff --git a/src/framework/common/base/include/common/common_mem_mbuf.h b/src/framework/common/base/include/common/common_mem_mbuf.h
deleted file mode 100644
index 0bb7696..0000000
--- a/src/framework/common/base/include/common/common_mem_mbuf.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-/*******************************************************************
- Copyright 2017 - 2047, Huawei Tech. Co., Ltd.
- ALL RIGHTS RESERVED
-
-Filename : common_mem_mbuf.h
-Description :
-Version : 1.1
-********************************************************************/
-
-#ifndef _COMMON_MEM_MBUF_H_
-#define _COMMON_MEM_MBUF_H_
-
-#ifdef HAL_LIB
-#else
-#include "rte_mbuf.h"
-#include "common_func.h"
-
-typedef uint32_t (*dmm_mbuf_item_fun) (void *data, void *argv);
-int32_t dmm_pktmbuf_pool_iterator (struct common_mem_mempool *mp,
- uint32_t start, uint32_t end,
- dmm_mbuf_item_fun fun, void *argv);
-#endif
-
-#endif /* _COMMON_MEM_MBUF_H_ */
diff --git a/src/framework/common/base/include/common/common_mem_mempool.h b/src/framework/common/base/include/common/common_mem_mempool.h
deleted file mode 100644
index 58a8e82..0000000
--- a/src/framework/common/base/include/common/common_mem_mempool.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _COMMON_MEM_MEMPOOL_H_
-#define _COMMON_MEM_MEMPOOL_H_
-
-#ifdef HAL_LIB
-#else
-#include "rte_mempool.h"
-#endif
-
-#endif /* _COMMON_MEM_MEMPOOL_H_ */
diff --git a/src/framework/common/base/include/common/common_mem_memzone.h b/src/framework/common/base/include/common/common_mem_memzone.h
deleted file mode 100644
index 20e18c2..0000000
--- a/src/framework/common/base/include/common/common_mem_memzone.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _COMMON_MEM_MEMZONE_H_
-#define _COMMON_MEM_MEMZONE_H_
-
-#ifdef HAL_LIB
-#else
-#include "rte_memzone.h"
-#endif
-
-#endif /* _COMMON_MEM_MEMZONE_H_ */
diff --git a/src/framework/common/base/include/common/common_mem_pal.h b/src/framework/common/base/include/common/common_mem_pal.h
deleted file mode 100644
index 209b8bd..0000000
--- a/src/framework/common/base/include/common/common_mem_pal.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _COMMON_MEM_PAL_H_
-#define _COMMON_MEM_PAL_H_
-
-#ifdef HAL_LIB
-#else
-
-#include "nsfw_base_linux_api.h"
-
-/*print the map address*/
-void dmm_addr_print (void);
-
-#endif
-
-#endif /* _COMMON_MEM_PAL_H_ */
diff --git a/src/framework/common/base/include/common/common_mem_spinlock.h b/src/framework/common/base/include/common/common_mem_spinlock.h
deleted file mode 100644
index 23f6b1e..0000000
--- a/src/framework/common/base/include/common/common_mem_spinlock.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _COMMON_MEM_SPINLOCK_X86_64_H_
-#define _COMMON_MEM_SPINLOCK_X86_64_H_
-
-#ifdef HAL_LIB
-#else
-#include "rte_spinlock.h"
-
-static inline void
-dmm_spinlock_lock_with_pid (rte_spinlock_t * sl, int pid)
-{
- while (!__sync_bool_compare_and_swap (&sl->locked, 0, pid))
- while (sl->locked)
- rte_pause ();
-}
-
-static inline int
-dmm_spinlock_try_lock_with_pid (rte_spinlock_t * sl, int pid)
-{
- return __sync_bool_compare_and_swap (&sl->locked, 0, pid);
-}
-
-#endif
-
-#endif /* _COMMON_MEM_SPINLOCK_X86_64_H_ */
diff --git a/src/framework/common/base/include/common/common_sys_config.h b/src/framework/common/base/include/common/common_sys_config.h
deleted file mode 100644
index 736c47b..0000000
--- a/src/framework/common/base/include/common/common_sys_config.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef __COMMON_SYS_CONFIG_H_
-#define __COMMON_SYS_CONFIG_H_
-
-/* Below compile macro is used only in UT makefile */
-#if (HAL_LIB)
-#else
-#undef RTE_CACHE_LINE_SIZE
-#define RTE_CACHE_LINE_SIZE 64 /* RTE_CACHE_LINE_SIZE */
-#undef RTE_MAX_LCORE
-#define RTE_MAX_LCORE 128 /* RTE_MAX_LCORE */
-#undef RTE_MAX_NUMA_NODES
-#define RTE_MAX_NUMA_NODES 8 /* RTE_MAX_NUMA_NODES */
-#undef RTE_MAX_MEMSEG
-#define RTE_MAX_MEMSEG 256 /* RTE_MAX_MEMSEG */
-#undef RTE_MAX_MEMZONE
-#define RTE_MAX_MEMZONE 2560 /* RTE_MAX_MEMZONE */
-#undef RTE_MAX_TAILQ
-#define RTE_MAX_TAILQ 32 /* RTE_MAX_TAILQ */
-#undef RTE_ARCH_X86
-#define RTE_ARCH_X86 1 /* RTE_ARCH_64 */
-#undef RTE_ARCH_64
-#define RTE_ARCH_64 1 /* RTE_ARCH_64 */
-#undef RTE_PKTMBUF_HEADROOM
-#define RTE_PKTMBUF_HEADROOM 128 /* RTE_PKTMBUF_HEADROOM */
-#undef RTE_MEMPOOL_CACHE_MAX_SIZE
-#define RTE_MEMPOOL_CACHE_MAX_SIZE 512 /* RTE_MEMPOOL_CACHE_MAX_SIZE */
-
-#endif
-
-#endif // __COMMON_SYS_CONFIG_H_
diff --git a/src/framework/common/base/include/common/generic/common_mem_rwlock.h b/src/framework/common/base/include/common/generic/common_mem_rwlock.h
deleted file mode 100644
index 2eed259..0000000
--- a/src/framework/common/base/include/common/generic/common_mem_rwlock.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _COMMON_MEM_RWLOCK_H_
-#define _COMMON_MEM_RWLOCK_H_
-
-#ifdef HAL_LIB
-#else
-#include "rte_rwlock.h"
-#endif
-
-#endif /* _COMMON_MEM_RWLOCK_H_ */
diff --git a/src/framework/common/base/include/common_pal_bitwide_adjust.h b/src/framework/common/base/include/common_pal_bitwide_adjust.h
deleted file mode 100644
index 0e68533..0000000
--- a/src/framework/common/base/include/common_pal_bitwide_adjust.h
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _COMMON_PAL_BITWIDE_ADJUST_H_
-#define _COMMON_PAL_BITWIDE_ADJUST_H_
-
-#ifdef HAL_LIB
-#include "pal_bitwide_adjust.h"
-#else
-#define MODULE(name) (1)
-
-#include "common_mem_common.h"
-
-#include "common_func.h"
-
-#define ALIGN_SIZET(size) ((uint64_t)(size))
-#define ALIGN_PTR(PTR) ((uint64_t)(PTR))
-
-extern struct common_mem_memseg *g_PMemSegArry;
-extern void **g_LMegAddrArry;
-
-/*get Local Seg addr by segIdx*/
-#define HMEM_SEG_LVADDR(segid) (g_LMegAddrArry[segid])
-/*get SegIDX by PrimSegAddr, just get the array Idx of g_PMemSegArry*/
-#define HMEM_SEGID(segaddr) ((struct common_mem_memseg*)segaddr - &(g_PMemSegArry[0]))
-
-/*****************************************************************
-Parameters : LMegAddrArry[] Local common_mem_memseg addr Array
- SegNum common_mem_memseg Num.
-Return :
-Description : init g_PrimAddr2LocalMap g_LocalAddr2PrimMap while the process start
-*****************************************************************/
-void *pal_shddr_to_laddr (uint64_t shaddr);
-uint64_t pal_laddr_to_shddr (void *laddr);
-int dmm_pal_addr_align ();
-
-extern int g_PrimSameFlg;
-
-/* if __NSTACK_MAIN__ is defined, no need do addr trans*/
-#ifndef __NSTACK_MAIN__
-/* g_PrimSameFlg check should be done before calling cast functions */
-
-/*share memory address to local virtual address*/
-#define ADDR_SHTOL(addr) (g_PrimSameFlg ? ((void*) (addr)) : pal_shddr_to_laddr((uint64_t)(addr)))
-
-/*local virtual address to share memory address according to memseg*/
-#define ADDR_LTOSH(addr) (g_PrimSameFlg ? ((uint64_t)(addr)) : pal_laddr_to_shddr((void*)(addr)))
-
-#define PTR_SHTOL(type, addr) ((type)ADDR_SHTOL(addr))
-
-/*local virtual address to share memory address; for compatible, not delete ADDR_LTOSH_EXT*/
-#define ADDR_LTOSH_EXT(addr) ADDR_LTOSH(addr)
-#else
-/*share memory address to local virtual address*/
-#define ADDR_SHTOL(addr) ((void*)(addr))
-
-/*local virtual address to share memory address according to memseg*/
-#define ADDR_LTOSH(addr) ((uint64_t)(addr))
-
-#define PTR_SHTOL(type, addr) ((type)(addr))
-
-/*local virtual address to share memory address; for compatible, not delete ADDR_LTOSH_EXT*/
-#define ADDR_LTOSH_EXT(addr) ADDR_LTOSH(addr)
-#endif
-
-#if MODULE("list")
-#define COMMON_LIST_INSERT_HEAD(lhead, lelm, field) do { \
- if (((lelm)->field.le_next_align = (lhead)->lh_first_align) != ((typeof((lhead)->lh_first_align))(long)NULL)) \
- ((typeof((lhead)->lh_first))ADDR_SHTOL((lhead)->lh_first_align))->field.le_prev_align = \
- ADDR_LTOSH(&(lelm)->field.le_next); \
- (lhead)->lh_first_align = ADDR_LTOSH(lelm); \
- (lelm)->field.le_prev_align = ADDR_LTOSH(&(lhead)->lh_first); \
-} while (/*CONSTCOND*/0)
-
-#define COMMON_LIST_REMOVE(lelm, field) do { \
- if ((lelm)->field.le_next_align != ((typeof((lelm)->field.le_next_align))ALIGN_PTR(NULL))) \
- ((typeof((lelm)->field.le_next))ADDR_SHTOL((lelm)->field.le_next_align))->field.le_prev_align = \
- (lelm)->field.le_prev_align; \
- if (EOK != (MEMCPY_S((typeof((lelm)->field.le_prev))ADDR_SHTOL((lelm)->field.le_prev_align), \
- sizeof((lelm)->field.le_next_align), \
- &((lelm)->field.le_next_align), \
- sizeof((lelm)->field.le_next_align)))) \
- {\
- NSCOMM_LOGERR("MEMCPY_S failed.");\
- return;\
- }\
-} while (/*CONSTCOND*/0)
-
-#define COMMON_LIST_EMPTY(lhead) ((typeof((lhead)->lh_first))ADDR_SHTOL((lhead)->lh_first_align) == NULL)
-#define COMMON_LIST_FIRST(lhead) ((typeof((lhead)->lh_first))ADDR_SHTOL((lhead)->lh_first_align))
-#define COMMON_LIST_NEXT(lelm, field) ((typeof((lelm)->field.le_next))ADDR_SHTOL((lelm)->field.le_next_align))
-
-#endif
-
-#if MODULE("tailq")
-
-#define COMMON_TAILQ_INSERT_TAIL(lhead, lelm, field) do { \
- (lelm)->field.tqe_next_align = (typeof((lelm)->field.tqe_next_align))NULL; \
- (lelm)->field.tqe_prev_align = (lhead)->tqh_last_align; \
- typeof((lhead)->tqh_last_align) tempelm = ADDR_LTOSH(lelm);\
- if (EOK != (MEMCPY_S(ADDR_SHTOL((lhead)->tqh_last_align), sizeof(tempelm), &tempelm, sizeof(tempelm)))) \
- {\
- NSCOMM_LOGERR("MEMCPY_S failed.");\
- }\
- (lhead)->tqh_last_align = ADDR_LTOSH(&(lelm)->field.tqe_next); \
-} while (/*CONSTCOND*/0)
-
-#define COMMON_TAILQ_FOREACH(lvar, lhead, field) \
- for ((lvar) = (typeof(lvar))ADDR_SHTOL((lhead)->tqh_first_align); \
- (lvar); \
- (lvar) = (typeof(lvar))ADDR_SHTOL((lvar)->field.tqe_next_align))
-
-#define COMMON_TAILQ_REMOVE(lhead, lelm, field) do { \
- if (((lelm)->field.tqe_next_align) != (typeof((lelm)->field.tqe_next_align))NULL) \
- ((typeof((lelm)->field.tqe_next))ADDR_SHTOL((lelm)->field.tqe_next_align))->field.tqe_prev_align = \
- (lelm)->field.tqe_prev_align; \
- else \
- (lhead)->tqh_last_align = (lelm)->field.tqe_prev_align; \
- if (EOK != (MEMCPY_S(ADDR_SHTOL((lelm)->field.tqe_prev_align), \
- sizeof((lelm)->field.tqe_next_align), \
- &((lelm)->field.tqe_next_align), \
- sizeof((lelm)->field.tqe_next_align)))) \
- {\
- NSCOMM_LOGERR("MEMCPY_S failed.");\
- }\
- } while (/*CONSTCOND*/0)
-
-/*
- * Tail queue functions.
- */
-#define COMMON_TAILQ_INIT(head) do { \
- (head)->tqh_first_align = (typeof((head)->tqh_first_align))NULL; \
- (head)->tqh_last_align = ADDR_LTOSH(&(head)->tqh_first); \
- } while (/*CONSTCOND*/0)
-
-/*
- * Tail queue access methods.
- */
-#define COMMON_TAILQ_EMPTY(head) ((head)->tqh_first_align == (typeof((head)->tqh_first_align))NULL)
-#define COMMON_TAILQ_FIRST(head) ((typeof((head)->tqh_first))ADDR_SHTOL((head)->tqh_first_align))
-#define COMMON_TAILQ_NEXT(elm, field) ((typeof((elm)->field.tqe_next))ADDR_SHTOL((elm)->field.tqe_next_align))
-
-#endif
-
-#if MODULE("stailq")
-/*
-* Singly-linked Tail queue functions.
-*/
-#define COMMON_STAILQ_INIT(head) do { \
- (head)->stqh_first_align = ALIGN_PTR(NULL); \
- (head)->stqh_last_align = ADDR_LTOSH(&(head)->stqh_first); \
-} while (/*CONSTCOND*/0)
-
-#define COMMON_STAILQ_INSERT_TAIL(head, elm, field) do { \
- (elm)->field.stqe_next_align = ALIGN_PTR(NULL); \
- typeof((head)->stqh_last_align) telm = ADDR_LTOSH(elm);\
- if (EOK != (MEMCPY_S(ADDR_SHTOL((head)->stqh_last_align), sizeof(telm), &telm, sizeof(telm))))\
- {\
- NSCOMM_LOGERR("MEMCPY_S failed.");\
- }\
- (head)->stqh_last_align = ADDR_LTOSH(&(elm)->field.stqe_next); \
-} while (/*CONSTCOND*/0)
-
-#define COMMON_STAILQ_REMOVE_HEAD(head, field) do { \
- if (((head)->stqh_first_align = \
- ((typeof((head)->stqh_first))ADDR_SHTOL((head)->stqh_first_align))->field.stqe_next_align) == \
- (PTR_ALIGN_TYPE)NULL) \
- (head)->stqh_last_align = ADDR_LTOSH(&(head)->stqh_first); \
-} while (/*CONSTCOND*/0)
-
-#define COMMON_STAILQ_FOREACH(var, head, field) \
- for ((var) = ADDR_SHTOL((head)->stqh_first_align); \
- (var); \
- (var) = ADDR_SHTOL((var)->field.stqe_next_align))
-
-/*
-* Singly-linked Tail queue access methods.
-*/
-
-#define COMMON_STAILQ_EMPTY(head) ((head)->stqh_first_align == (PTR_ALIGN_TYPE)NULL)
-
-#define COMMON_STAILQ_FIRST(head) (ADDR_SHTOL((head)->stqh_first_align))
-
-#define COMMON_STAILQ_NEXT(elm, field) (ADDR_SHTOL((elm)->field.stqe_next_align))
-#endif
-
-#endif
-
-#endif
diff --git a/src/framework/common/base/include/nsfw_base_linux_api.h b/src/framework/common/base/include/nsfw_base_linux_api.h
deleted file mode 100644
index 83b5a32..0000000
--- a/src/framework/common/base/include/nsfw_base_linux_api.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _NSFW_BASE_LINUX_API_H_
-#define _NSFW_BASE_LINUX_API_H_
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/epoll.h>
-#include <unistd.h>
-
-int nsfw_base_socket (int, int, int);
-int nsfw_base_bind (int, const struct sockaddr *, socklen_t);
-int nsfw_base_listen (int, int);
-int nsfw_base_shutdown (int, int);
-int nsfw_base_getsockname (int, struct sockaddr *, socklen_t *);
-int nsfw_base_getpeername (int, struct sockaddr *, socklen_t *);
-int nsfw_base_getsockopt (int, int, int, void *, socklen_t *);
-int nsfw_base_setsockopt (int, int, int, const void *, socklen_t);
-int nsfw_base_accept (int, struct sockaddr *, socklen_t *);
-int nsfw_base_accept4 (int, struct sockaddr *, socklen_t *, int flags);
-int nsfw_base_connect (int, const struct sockaddr *, socklen_t);
-ssize_t nsfw_base_recv (int, void *, size_t, int);
-ssize_t nsfw_base_send (int, const void *, size_t, int);
-ssize_t nsfw_base_read (int, void *, size_t);
-ssize_t nsfw_base_write (int, const void *, size_t);
-ssize_t nsfw_base_writev (int, const struct iovec *, int);
-ssize_t nsfw_base_readv (int, const struct iovec *, int);
-ssize_t nsfw_base_sendto (int, const void *, size_t, int,
- const struct sockaddr *, socklen_t);
-ssize_t nsfw_base_recvfrom (int, void *, size_t, int, struct sockaddr *,
- socklen_t *);
-ssize_t nsfw_base_sendmsg (int, const struct msghdr *, int flags);
-ssize_t nsfw_base_recvmsg (int, struct msghdr *, int flags);
-int nsfw_base_close (int);
-int nsfw_base_select (int, fd_set *, fd_set *, fd_set *, struct timeval *);
-int nsfw_base_ioctl (int, unsigned long, unsigned long);
-int nsfw_base_fcntl (int, int, unsigned long);
-int nsfw_base_epoll_create (int);
-int nsfw_base_epoll_create1 (int);
-int nsfw_base_epoll_ctl (int, int, int, struct epoll_event *);
-int nsfw_base_epoll_wait (int, struct epoll_event *, int, int);
-pid_t nsfw_base_fork (void);
-
-#endif
diff --git a/src/framework/common/base/liblinuxapi/base_linux_api_declare.h b/src/framework/common/base/liblinuxapi/base_linux_api_declare.h
index 943ae04..3f96e6c 100644
--- a/src/framework/common/base/liblinuxapi/base_linux_api_declare.h
+++ b/src/framework/common/base/liblinuxapi/base_linux_api_declare.h
@@ -14,38 +14,42 @@
* limitations under the License.
*/
-BASE_MK_DECL (int, socket, (int, int, int));
-BASE_MK_DECL (int, bind, (int, const struct sockaddr *, socklen_t));
-BASE_MK_DECL (int, listen, (int, int));
-BASE_MK_DECL (int, shutdown, (int, int));
-BASE_MK_DECL (int, getsockname, (int, struct sockaddr *, socklen_t *));
-BASE_MK_DECL (int, getpeername, (int, struct sockaddr *, socklen_t *));
-BASE_MK_DECL (int, getsockopt, (int, int, int, void *, socklen_t *));
-BASE_MK_DECL (int, setsockopt, (int, int, int, const void *, socklen_t));
-BASE_MK_DECL (int, accept, (int, struct sockaddr *, socklen_t *));
-BASE_MK_DECL (int, accept4, (int, struct sockaddr *, socklen_t *, int flags));
-BASE_MK_DECL (int, connect, (int, const struct sockaddr *, socklen_t));
-BASE_MK_DECL (ssize_t, recv, (int, void *, size_t, int));
-BASE_MK_DECL (ssize_t, send, (int, const void *, size_t, int));
-BASE_MK_DECL (ssize_t, read, (int, void *, size_t));
-BASE_MK_DECL (ssize_t, write, (int, const void *, size_t));
-BASE_MK_DECL (ssize_t, writev, (int, const struct iovec *, int));
-BASE_MK_DECL (ssize_t, readv, (int, const struct iovec *, int));
-BASE_MK_DECL (ssize_t, sendto,
- (int, const void *, size_t, int, const struct sockaddr *,
- socklen_t));
-BASE_MK_DECL (ssize_t, recvfrom,
- (int, void *, size_t, int, struct sockaddr *, socklen_t *));
-BASE_MK_DECL (ssize_t, sendmsg, (int, const struct msghdr *, int flags));
-BASE_MK_DECL (ssize_t, recvmsg, (int, struct msghdr *, int flags));
-BASE_MK_DECL (int, close, (int));
-BASE_MK_DECL (int, select,
- (int, fd_set *, fd_set *, fd_set *, struct timeval *));
-BASE_MK_DECL (int, ioctl, (int, unsigned long, unsigned long));
-BASE_MK_DECL (int, fcntl, (int, int, unsigned long));
-BASE_MK_DECL (int, epoll_create, (int));
-BASE_MK_DECL (int, epoll_create1, (int));
-BASE_MK_DECL (int, epoll_ctl, (int, int, int, struct epoll_event *));
-BASE_MK_DECL (int, epoll_wait, (int, struct epoll_event *, int, int));
-BASE_MK_DECL (pid_t, fork, (void));
+BASE_MK_DECL(int, socket, (int, int, int));
+BASE_MK_DECL(int, bind, (int, const struct sockaddr *, socklen_t));
+BASE_MK_DECL(int, listen, (int, int));
+BASE_MK_DECL(int, shutdown, (int, int));
+BASE_MK_DECL(int, getaddrinfo,
+ (const char *, const char *, const struct addrinfo *,
+ struct addrinfo **));
+BASE_MK_DECL(int, getsockname, (int, struct sockaddr *, socklen_t *));
+BASE_MK_DECL(int, getpeername, (int, struct sockaddr *, socklen_t *));
+BASE_MK_DECL(int, getsockopt, (int, int, int, void *, socklen_t *));
+BASE_MK_DECL(int, setsockopt, (int, int, int, const void *, socklen_t));
+BASE_MK_DECL(int, accept, (int, struct sockaddr *, socklen_t *));
+BASE_MK_DECL(int, accept4, (int, struct sockaddr *, socklen_t *, int flags));
+BASE_MK_DECL(int, connect, (int, const struct sockaddr *, socklen_t));
+BASE_MK_DECL(ssize_t, recv, (int, void *, size_t, int));
+BASE_MK_DECL(ssize_t, send, (int, const void *, size_t, int));
+BASE_MK_DECL(ssize_t, read, (int, void *, size_t));
+BASE_MK_DECL(ssize_t, write, (int, const void *, size_t));
+BASE_MK_DECL(ssize_t, writev, (int, const struct iovec *, int));
+BASE_MK_DECL(ssize_t, readv, (int, const struct iovec *, int));
+BASE_MK_DECL(ssize_t, sendto,
+ (int, const void *, size_t, int, const struct sockaddr *,
+ socklen_t));
+BASE_MK_DECL(ssize_t, recvfrom,
+ (int, void *, size_t, int, struct sockaddr *, socklen_t *));
+BASE_MK_DECL(ssize_t, sendmsg, (int, const struct msghdr *, int flags));
+BASE_MK_DECL(ssize_t, recvmsg, (int, struct msghdr *, int flags));
+BASE_MK_DECL(int, close, (int));
+BASE_MK_DECL(int, select,
+ (int, fd_set *, fd_set *, fd_set *, struct timeval *));
+BASE_MK_DECL(int, ioctl, (int, unsigned long, unsigned long));
+BASE_MK_DECL(int, fcntl, (int, int, unsigned long));
+BASE_MK_DECL(int, epoll_create, (int));
+BASE_MK_DECL(int, epoll_create1, (int));
+//BASE_MK_DECL(int , poll , (struct pollfd *, nfds_t, int));
+BASE_MK_DECL(int, epoll_ctl, (int, int, int, struct epoll_event *));
+BASE_MK_DECL(int, epoll_wait, (int, struct epoll_event *, int, int));
+BASE_MK_DECL(pid_t, fork, (void));
#undef BASE_MK_DECL
diff --git a/src/framework/common/base/liblinuxapi/nsfw_base_linux_api.c b/src/framework/common/base/liblinuxapi/nsfw_base_linux_api.c
index 4e59d68..734a09f 100644
--- a/src/framework/common/base/liblinuxapi/nsfw_base_linux_api.c
+++ b/src/framework/common/base/liblinuxapi/nsfw_base_linux_api.c
@@ -15,7 +15,6 @@
*/
#include "nsfw_base_linux_api.h"
-#include "nstack_log.h"
#include <pthread.h>
#include <stdio.h>
#include <errno.h>
@@ -39,9 +38,9 @@
typedef enum
{
- BASE_STATE_INIT,
- BASE_STATE_SUCCESS,
- BASE_STATE_FAIL
+ BASE_STATE_INIT,
+ BASE_STATE_SUCCESS,
+ BASE_STATE_FAIL
} nsfw_base_state;
typedef struct __base_linux_api
@@ -50,27 +49,24 @@ typedef struct __base_linux_api
#include "base_linux_api_declare.h"
} base_linux_api;
-nsfw_base_state g_nsfw_module_state = BASE_STATE_INIT;
+nsfw_base_state g_nsfw_mudule_state = BASE_STATE_INIT;
pthread_mutex_t g_nsfw_init_mutex = PTHREAD_MUTEX_INITIALIZER;
base_linux_api g_nsfw_posix_api = { 0 };
void *g_linux_lib_handle = (void *) 0;
-int
-nsfw_posix_symbol_load ()
+int nsfw_posix_symbol_load()
{
- g_linux_lib_handle = dlopen ("libc.so.6", RTLD_NOW | RTLD_GLOBAL);
- if ((void *) 0 == g_linux_lib_handle)
+ g_linux_lib_handle = dlopen("libc.so.6", RTLD_NOW | RTLD_GLOBAL);
+ if ((void *) 0 == g_linux_lib_handle)
{
- /* optimize dlopen err print */
- NSSOC_LOGERR ("cannot dlopen libc.so.6] err_string=%s", dlerror ());
- return NSFW_BASE_FAIL;
+ return NSFW_BASE_FAIL;
}
#define BASE_MK_DECL(ret, fn, args) \
g_nsfw_posix_api.pf##fn = (typeof(g_nsfw_posix_api.pf##fn))dlsym(g_linux_lib_handle, #fn);
#include <base_linux_api_declare.h>
- return NSFW_BASE_OK;
+ return NSFW_BASE_OK;
}
/*****************************************************************
@@ -78,549 +74,191 @@ Parameters : void
Return :
Description : linux posix api init with threadonce
*****************************************************************/
-static inline int
-nsfw_posix_api_init ()
+static inline int nsfw_posix_api_init()
{
- int iret = NSFW_BASE_OK;
+ int iret = NSFW_BASE_OK;
- /*if init already, just return success, if init fail before, just return err */
- if (BASE_STATE_INIT != g_nsfw_module_state)
+ /*if init already, just return success, if init fail before, just return err */
+ if (BASE_STATE_INIT != g_nsfw_mudule_state)
{
- return (BASE_STATE_SUCCESS ==
- g_nsfw_module_state ? NSFW_BASE_OK : NSFW_BASE_FAIL);
+ return (BASE_STATE_SUCCESS ==
+ g_nsfw_mudule_state ? NSFW_BASE_OK : NSFW_BASE_FAIL);
}
- (void) pthread_mutex_lock (&g_nsfw_init_mutex);
+ (void) pthread_mutex_lock(&g_nsfw_init_mutex);
- /*if init already, just return success, if init fail before, just return err */
- if (BASE_STATE_INIT != g_nsfw_module_state)
+ /*if init already, just return success, if init fail before, just return err */
+ if (BASE_STATE_INIT != g_nsfw_mudule_state)
{
- (void) pthread_mutex_unlock (&g_nsfw_init_mutex);
- return (BASE_STATE_SUCCESS ==
- g_nsfw_module_state ? NSFW_BASE_OK : NSFW_BASE_FAIL);
+ (void) pthread_mutex_unlock(&g_nsfw_init_mutex);
+ return (BASE_STATE_SUCCESS ==
+ g_nsfw_mudule_state ? NSFW_BASE_OK : NSFW_BASE_FAIL);
}
- iret = nsfw_posix_symbol_load ();
- if (NSFW_BASE_OK == iret)
+ iret = nsfw_posix_symbol_load();
+ if (NSFW_BASE_OK == iret)
{
- g_nsfw_module_state = BASE_STATE_SUCCESS;
+ g_nsfw_mudule_state = BASE_STATE_SUCCESS;
}
- else
+ else
{
- g_nsfw_module_state = BASE_STATE_FAIL;
+ g_nsfw_mudule_state = BASE_STATE_FAIL;
}
- (void) pthread_mutex_unlock (&g_nsfw_init_mutex);
- return iret;
+ (void) pthread_mutex_unlock(&g_nsfw_init_mutex);
+ return iret;
}
/* *INDENT-OFF* */
-/*****************************************************************************
-* Prototype : nsfw_base_socket
-* Description : linux socket api
-* Input : int a
-* int b
-* int c
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-
-*
-*****************************************************************************/
int nsfw_base_socket(int a, int b, int c)
{
nsfw_call_ret(socket, (a, b, c))
}
-/*****************************************************************************
-* Prototype : nsfw_base_bind
-* Description : linux fd bind api
-* Input : int a
-* const struct sockaddr* b
-* socklen_t c
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
int nsfw_base_bind(int a, const struct sockaddr* b, socklen_t c)
{
nsfw_call_ret(bind, (a, b, c))
}
-/*****************************************************************************
-* Prototype : nsfw_base_listen
-* Description : linux fd listen api
-* Input : int a
-* int b
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
int nsfw_base_listen(int a, int b)
{
nsfw_call_ret(listen, (a, b))
}
-/*****************************************************************************
-* Prototype : nsfw_base_shutdown
-* Description : linux shutdown api
-* Input : int a
-* int b
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*
-*****************************************************************************/
int nsfw_base_shutdown(int a, int b)
{
nsfw_call_ret(shutdown, (a, b))
}
-/*****************************************************************************
-* Prototype : nsfw_base_getsockname
-* Description : linux getsockname api
-* Input : int a
-* struct sockaddr* b
-* socklen_t* c
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
+int nsfw_base_getaddrinfo(const char *a, const char *b, const struct addrinfo *c, struct addrinfo **d)
+{
+ nsfw_call_ret(getaddrinfo, (a, b, c, d))
+}
+
int nsfw_base_getsockname(int a, struct sockaddr* b, socklen_t* c)
{
nsfw_call_ret(getsockname, (a, b, c))
}
-/*****************************************************************************
-* Prototype : nsfw_base_getpeername
-* Description : linux getpername api
-* Input : int a
-* struct sockaddr* b
-* socklen_t* c
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
int nsfw_base_getpeername(int a, struct sockaddr* b, socklen_t* c)
{
nsfw_call_ret(getpeername, (a, b, c))
}
-/*****************************************************************************
-* Prototype : nsfw_base_getsockopt
-* Description : linux getsockopt api
-* Input : int a
-* int b
-* int c
-* void* d
-* socklen_t* e
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
int nsfw_base_getsockopt(int a, int b, int c, void* d, socklen_t* e)
{
nsfw_call_ret(getsockopt, (a, b, c, d, e))
}
-/*****************************************************************************
-* Prototype : nsfw_base_setsockopt
-* Description : linux setsockopt api
-* Input : int a
-* int b
-* int c
-* const void* d
-* socklen_t e
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*****************************************************************************/
int nsfw_base_setsockopt(int a, int b, int c, const void* d, socklen_t e)
{
nsfw_call_ret(setsockopt, (a, b, c, d, e))
}
-/*****************************************************************************
-* Prototype : nsfw_base_accept
-* Description : linux accept api
-* Input : int a
-* struct sockaddr* b
-* socklen_t* c
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*****************************************************************************/
int nsfw_base_accept(int a, struct sockaddr* b, socklen_t* c)
{
nsfw_call_ret(accept, (a, b, c))
}
-/*****************************************************************************
-* Prototype : nsfw_base_accept4
-* Description : linux accept4 api
-* Input : int a
-* struct sockaddr* b
-* socklen_t* c
-* int flags
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*****************************************************************************/
int nsfw_base_accept4(int a, struct sockaddr* b, socklen_t* c, int flags)
{
nsfw_call_ret(accept4, (a, b, c, flags))
}
-/*****************************************************************************
-* Prototype : nsfw_base_connect
-* Description : linux connect api
-* Input : int a
-* const struct sockaddr* b
-* socklen_t c
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
int nsfw_base_connect(int a, const struct sockaddr* b, socklen_t c)
{
nsfw_call_ret(connect, (a, b, c))
}
-/*****************************************************************************
-* Prototype : nsfw_base_recv
-* Description : linux recv api
-* Input : int a
-* void* b
-* size_t c
-* int d
-* Output : None
-* Return Value : ssize_t
-* Calls :
-* Called By :
-*
-*****************************************************************************/
ssize_t nsfw_base_recv(int a, void* b, size_t c, int d)
{
nsfw_call_ret(recv, (a, b, c, d))
}
-/*****************************************************************************
-* Prototype : nsfw_base_send
-* Description : linux send api
-* Input : int a
-* const void* b
-* size_t c
-* int d
-* Output : None
-* Return Value : ssize_t
-* Calls :
-* Called By :
-*
-*****************************************************************************/
ssize_t nsfw_base_send(int a, const void* b, size_t c, int d)
{
nsfw_call_ret(send, (a, b, c, d))
}
-/*****************************************************************************
-* Prototype : nsfw_base_read
-* Description : linux read api
-* Input : int a
-* void* b
-* size_t c
-* Output : None
-* Return Value : ssize_t
-* Calls :
-* Called By :
-*
-*****************************************************************************/
ssize_t nsfw_base_read(int a, void* b, size_t c)
{
nsfw_call_ret(read, (a, b, c))
}
-/*****************************************************************************
-* Prototype : nsfw_base_write
-* Description : linux write api
-* Input : int a
-* const void* b
-* size_t c
-* Output : None
-* Return Value : ssize_t
-* Calls :
-* Called By :
-*
-*****************************************************************************/
ssize_t nsfw_base_write(int a, const void* b, size_t c)
{
nsfw_call_ret(write, (a, b, c))
}
-/*****************************************************************************
-* Prototype : nsfw_base_writev
-* Description : linux writev api
-* Input : int a
-* const struct iovec * b
-* int c
-* Output : None
-* Return Value : ssize_t
-* Calls :
-* Called By :
-*****************************************************************************/
ssize_t nsfw_base_writev(int a, const struct iovec * b, int c)
{
nsfw_call_ret(writev, (a, b, c))
}
-/*****************************************************************************
-* Prototype : nsfw_base_readv
-* Description : linux readv api
-* Input : int a
-* const struct iovec * b
-* int c
-* Output : None
-* Return Value : ssize_t
-* Calls :
-* Called By :
-*
-*****************************************************************************/
ssize_t nsfw_base_readv(int a, const struct iovec * b, int c)
{
nsfw_call_ret(readv, (a, b, c))
}
-/*****************************************************************************
-* Prototype : nsfw_base_sendto
-* Description : linux sendto api
-* Input : int a
-* const void * b
-* size_t c
-* int d
-* const struct sockaddr *e
-* socklen_t f
-* Output : None
-* Return Value : ssize_t
-* Calls :
-* Called By :
-*****************************************************************************/
ssize_t nsfw_base_sendto(int a, const void * b, size_t c, int d, const struct sockaddr *e, socklen_t f)
{
nsfw_call_ret(sendto, (a, b, c, d, e, f))
}
-/*****************************************************************************
-* Prototype : nsfw_base_recvfrom
-* Description : linux recvfrom api
-* Input : int a
-* void *b
-* size_t c
-* int d
-* struct sockaddr *e
-* socklen_t *f
-* Output : None
-* Return Value : ssize_t
-* Calls :
-* Called By :
-*****************************************************************************/
ssize_t nsfw_base_recvfrom(int a, void *b, size_t c, int d,struct sockaddr *e, socklen_t *f)
{
nsfw_call_ret(recvfrom, (a, b, c, d, e, f))
}
-/*****************************************************************************
-* Prototype : nsfw_base_sendmsg
-* Description : linux sendmsg api
-* Input : int a
-* const struct msghdr *b
-* int flags
-* Output : None
-* Return Value : ssize_t
-* Calls :
-* Called By :
-*
-*****************************************************************************/
ssize_t nsfw_base_sendmsg(int a, const struct msghdr *b, int flags)
{
nsfw_call_ret(sendmsg, (a, b, flags))
}
-/*****************************************************************************
-* Prototype : nsfw_base_recvmsg
-* Description : linux recvmsg api
-* Input : int a
-* struct msghdr *b
-* int flags
-* Output : None
-* Return Value : ssize_t
-* Calls :
-* Called By :
-*
-*****************************************************************************/
ssize_t nsfw_base_recvmsg(int a, struct msghdr *b, int flags)
{
nsfw_call_ret(recvmsg, (a, b, flags))
}
-/*****************************************************************************
-* Prototype : nsfw_base_close
-* Description : linux close api
-* Input : int a
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
int nsfw_base_close(int a)
{
nsfw_call_ret(close, (a))
}
-/*****************************************************************************
-* Prototype : nsfw_base_select
-* Description : linux select api
-* Input : int a
-* fd_set *b
-* fd_set *c
-* fd_set *d
-* struct timeval *e
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*****************************************************************************/
int nsfw_base_select(int a, fd_set *b, fd_set *c, fd_set *d, struct timeval *e)
{
nsfw_call_ret(select, (a, b, c, d, e))
}
-/*****************************************************************************
-* Prototype : nsfw_base_ioctl
-* Description : linux ioctl api
-* Input : int a
-* unsigned long b
-* unsigned long c
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
int nsfw_base_ioctl(int a, unsigned long b, unsigned long c)
{
nsfw_call_ret(ioctl, (a, b, c))
}
-/*****************************************************************************
-* Prototype : nsfw_base_fcntl
-* Description : linux fcntl api
-* Input : int a
-* int b
-* unsigned long c
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
int nsfw_base_fcntl(int a, int b, unsigned long c)
{
nsfw_call_ret(fcntl, (a, b, c))
}
-/*****************************************************************************
-* Prototype : nsfw_base_epoll_create
-* Description : linux epoll_create api
-* Input : int a
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
int nsfw_base_epoll_create(int a)
{
nsfw_call_ret(epoll_create, (a))
}
-/*****************************************************************************
-* Prototype : nsfw_base_epoll_create1
-* Description : linux epoll_create1 api
-* Input : int a
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
int nsfw_base_epoll_create1(int a)
{
nsfw_call_ret(epoll_create1, (a))
}
-/*****************************************************************************
-* Prototype : nsfw_base_epoll_ctl
-* Description : linux epoll_ctl api
-* Input : int a
-* int b
-* int c
-* struct epoll_event *d
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
int nsfw_base_epoll_ctl(int a, int b, int c, struct epoll_event *d)
{
nsfw_call_ret(epoll_ctl, (a, b, c, d))
}
-/*****************************************************************************
-* Prototype : nsfw_base_epoll_wait
-* Description : linux epoll_wait api
-* Input : int a
-* struct epoll_event *b
-* int c
-* int d
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
int nsfw_base_epoll_wait(int a, struct epoll_event *b, int c, int d)
{
nsfw_call_ret(epoll_wait, (a, b, c, d))
}
-/*****************************************************************************
-* Prototype : nsfw_base_fork
-* Description : linux fork api
-* Input : void
-* Output : None
-* Return Value : pid_t
-* Calls :
-* Called By :
-*
-*****************************************************************************/
pid_t nsfw_base_fork(void)
{
nsfw_call_ret(fork, ())
diff --git a/src/framework/common/base/liblinuxapi/nsfw_lock_file.c b/src/framework/common/base/liblinuxapi/nsfw_lock_file.c
deleted file mode 100644
index cef8d95..0000000
--- a/src/framework/common/base/liblinuxapi/nsfw_lock_file.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-#include "types.h"
-#include "nstack_securec.h"
-#include "nsfw_init.h"
-#include "common_mem_api.h"
-
-#include "nstack_log.h"
-#include "nsfw_maintain_api.h"
-#include "nsfw_mgr_com_api.h"
-
-#include "nsfw_base_linux_api.h"
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C"{
-/* *INDENT-ON* */
-#endif /* __cplusplus */
-
-#define NSFW_FILE_PATH_LEN 128
-#define LOCK_FOLDER "/ip_module/"
-#define LOCK_SUFFIX ".pid"
-
-#define read_lock(fd, offset, whence, len) nsfw_lock_reg((fd), F_SETLK, F_RDLCK, (offset), (whence), (len))
-#define readw_lock(fd, offset, whence, len) nsfw_lock_reg((fd), F_SETLKW, F_RDLCK, (offset), (whence), (len))
-#define write_lock(fd, offset, whence, len) nsfw_lock_reg((fd), F_SETLK, F_WRLCK, (offset), (whence), (len))
-#define writew_lock(fd, offset, whence, len) nsfw_lock_reg((fd), F_SETLKW, F_WRLCK, (offset), (whence), (len))
-#define un_lock(fd, offset, whence, len) nsfw_lock_reg((fd), F_SETLK, F_UNLCK, (offset), (whence), (len))
-
-i32
-nsfw_lock_reg (i32 fd, i32 cmd, i32 type, off_t offset, i32 whence, off_t len)
-{
- struct flock lock_file;
- lock_file.l_type = type;
- lock_file.l_start = offset;
- lock_file.l_whence = whence;
- lock_file.l_len = len;
- return (fcntl (fd, cmd, &lock_file));
-}
-
-/*****************************************************************************
-* Prototype : nsfw_proc_start_with_lock
-* Description : lock file start
-* Input : u8 proc_type
-* Output : None
-* Return Value : i32
-* Calls :
-* Called By :
-*****************************************************************************/
-i32
-nsfw_proc_start_with_lock (u8 proc_type)
-{
- NSFW_LOGINF ("lock_file init]type=%u", proc_type);
- char *module_name = nsfw_get_proc_name (proc_type);
- if (NULL == module_name)
- {
- NSFW_LOGERR ("proc type error]proc_type=%u", proc_type);
- return 0;
- }
-
- const char *directory = NSFW_DOMAIN_DIR;
- const char *home_dir = getenv ("HOME");
-
- if (getuid () != 0 && home_dir != NULL)
- {
- directory = home_dir;
- }
-
- int ret;
- char lock_fpath[NSFW_FILE_PATH_LEN] = { 0 };
- ret = STRCPY_S (lock_fpath, NSFW_FILE_PATH_LEN, directory);
- if (EOK != ret)
- {
- NSFW_LOGERR ("lock init STRCPY_S failed]ret=%d", ret);
- return -1;
- }
-
- nsfw_mgr_com_mkdir_domainpath (lock_fpath);
-
- ret = STRCAT_S (lock_fpath, NSFW_FILE_PATH_LEN, module_name);
- if (EOK != ret)
- {
- NSFW_LOGERR ("lock init STRCAT_S failed]ret=%d", ret);
- return -1;
- }
-
- ret = STRCAT_S (lock_fpath, NSFW_FILE_PATH_LEN, LOCK_SUFFIX);
- if (EOK != ret)
- {
- NSFW_LOGERR ("lock init STRCAT_S failed]ret=%d", ret);
- return -1;
- }
-
- i32 fd;
- if ((fd = open (lock_fpath, O_RDWR | O_CREAT, 0640)) == -1)
- { /* file permission no large than 0640 */
- NSFW_LOGERR ("open lock file error!]path=%s,error = %d", lock_fpath,
- errno);
- return -1;
- }
-
- int rc = nsfw_set_close_on_exec (fd);
- if (rc == -1)
- {
- (void) nsfw_base_close (fd);
- NSFW_LOGERR ("set exec err]fd=%d, errno=%d", fd, errno);
- return -1;
- }
-
- if (write_lock (fd, 0, SEEK_SET, 0) < 0)
- {
- (void) nsfw_base_close (fd);
- NSFW_LOGERR ("get lock file error!]path=%s,error = %d", lock_fpath,
- errno);
- return -1;
- }
-
- char buf[32] = { 0 };
- if (ftruncate (fd, 0) < 0)
- {
- (void) nsfw_base_close (fd);
- NSFW_LOGERR ("ftruncate file error!]path=%s,error = %d", lock_fpath,
- errno);
- return -1;
- }
-
- ret =
- SNPRINTF_S (buf, sizeof (buf), sizeof (buf) - 1, "%ld", (long) getpid ());
- if (-1 == ret)
- {
- NSTCP_LOGERR ("SNPRINTF_S failed]ret=%d", ret);
- (void) nsfw_base_close (fd);
- return -1;
- }
-
- if (write (fd, buf, strlen (buf) + 1) < 0)
- {
- (void) nsfw_base_close (fd);
- NSFW_LOGERR ("write file error!]path=%s,error = %d", lock_fpath, errno);
- return -1;
- }
-
- return 0;
-}
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif /* __cplusplus */
diff --git a/src/framework/common/data_struct/eprb_tree.c b/src/framework/common/data_struct/eprb_tree.c
index c8e616d..81ac846 100644
--- a/src/framework/common/data_struct/eprb_tree.c
+++ b/src/framework/common/data_struct/eprb_tree.c
@@ -15,6 +15,7 @@
*/
#include "eprb_tree.h"
+#include "nsfw_mem_api.h"
#ifdef __cplusplus
/* *INDENT-OFF* */
@@ -25,464 +26,455 @@ extern "C" {
/*
* This function returns the first node (in sort order) of the tree.
*/
-struct ep_rb_node *
-ep_rb_first (const struct ep_rb_root *root)
+struct ep_rb_node *ep_rb_first(const struct ep_rb_root *root)
{
- if (NULL == root)
- return NULL;
+ if (NULL == root)
+ return NULL;
- struct ep_rb_node *n;
- n = (struct ep_rb_node *) ADDR_SHTOL (root->rb_node);
+ struct ep_rb_node *n;
- if (!n)
+ n = (struct ep_rb_node *) SHMEM_ADDR_SHTOL(root->rb_node);
+
+ if (!n)
{
- return NULL;
+ return NULL;
}
- while (n->rb_left)
+ while (n->rb_left)
{
- n = (struct ep_rb_node *) ADDR_SHTOL (n->rb_left);
+ n = (struct ep_rb_node *) SHMEM_ADDR_SHTOL(n->rb_left);
}
- return n;
+ return n;
}
-void
-__ep_rb_rotate_left (struct ep_rb_node *X, struct ep_rb_root *root)
+void __ep_rb_rotate_left(struct ep_rb_node *X, struct ep_rb_root *root)
{
/**************************
* rotate Node X to left *
**************************/
- struct ep_rb_node *Y = (struct ep_rb_node *) ADDR_SHTOL (X->rb_right);
- /* establish X->Right link */
- X->rb_right = Y->rb_left;
+ struct ep_rb_node *Y =
+ (struct ep_rb_node *) SHMEM_ADDR_SHTOL(X->rb_right);
+
+ /* estblish X->Right link */
+ X->rb_right = Y->rb_left;
- if (Y->rb_left != NULL)
+ if (Y->rb_left != NULL)
{
- ((struct ep_rb_node *) ADDR_SHTOL (Y->rb_left))->rb_parent =
- (struct ep_rb_node *) ADDR_LTOSH_EXT (X);
+ ((struct ep_rb_node *) SHMEM_ADDR_SHTOL(Y->rb_left))->rb_parent =
+ (struct ep_rb_node *) SHMEM_ADDR_LTOSH_EXT(X);
}
- /* establish Y->Parent link */
- Y->rb_parent = X->rb_parent;
+ /* estblish Y->Parent link */
+ Y->rb_parent = X->rb_parent;
- if (X->rb_parent)
+ if (X->rb_parent)
{
- struct ep_rb_node *xParent =
- (struct ep_rb_node *) ADDR_SHTOL (X->rb_parent);
+ struct ep_rb_node *xParent =
+ (struct ep_rb_node *) SHMEM_ADDR_SHTOL(X->rb_parent);
- if (X == ADDR_SHTOL (xParent->rb_left))
+ if (X == SHMEM_ADDR_SHTOL(xParent->rb_left))
{
- xParent->rb_left = (struct ep_rb_node *) ADDR_LTOSH_EXT (Y);
+ xParent->rb_left = (struct ep_rb_node *) SHMEM_ADDR_LTOSH_EXT(Y);
}
- else
+ else
{
- xParent->rb_right = (struct ep_rb_node *) ADDR_LTOSH_EXT (Y);
+ xParent->rb_right = (struct ep_rb_node *) SHMEM_ADDR_LTOSH_EXT(Y);
}
}
- else
+ else
{
- root->rb_node = (struct ep_rb_node *) ADDR_LTOSH_EXT (Y);
+ root->rb_node = (struct ep_rb_node *) SHMEM_ADDR_LTOSH_EXT(Y);
}
- /* link X and Y */
- Y->rb_left = (struct ep_rb_node *) ADDR_LTOSH_EXT (X);
- X->rb_parent = (struct ep_rb_node *) ADDR_LTOSH_EXT (Y);
+ /* link X and Y */
+ Y->rb_left = (struct ep_rb_node *) SHMEM_ADDR_LTOSH_EXT(X);
+ X->rb_parent = (struct ep_rb_node *) SHMEM_ADDR_LTOSH_EXT(Y);
- return;
+ return;
}
-void
-__ep_rb_rotate_right (struct ep_rb_node *X, struct ep_rb_root *root)
+void __ep_rb_rotate_right(struct ep_rb_node *X, struct ep_rb_root *root)
{
/****************************
* rotate Node X to right *
****************************/
- struct ep_rb_node *Y = (struct ep_rb_node *) ADDR_SHTOL (X->rb_left);
- /* establish X->Left link */
- X->rb_left = Y->rb_right;
+ struct ep_rb_node *Y = (struct ep_rb_node *) SHMEM_ADDR_SHTOL(X->rb_left);
- if (Y->rb_right != NULL)
+ /* estblish X->Left link */
+ X->rb_left = Y->rb_right;
+
+ if (Y->rb_right != NULL)
{
- ((struct ep_rb_node *) ADDR_SHTOL (Y->rb_right))->rb_parent =
- (struct ep_rb_node *) ADDR_LTOSH_EXT (X);
+ ((struct ep_rb_node *) SHMEM_ADDR_SHTOL(Y->rb_right))->rb_parent =
+ (struct ep_rb_node *) SHMEM_ADDR_LTOSH_EXT(X);
}
- /* establish Y->Parent link */
- Y->rb_parent = X->rb_parent;
+ /* estblish Y->Parent link */
+ Y->rb_parent = X->rb_parent;
- if (X->rb_parent)
+ if (X->rb_parent)
{
- struct ep_rb_node *xParent =
- (struct ep_rb_node *) ADDR_SHTOL (X->rb_parent);
+ struct ep_rb_node *xParent =
+ (struct ep_rb_node *) SHMEM_ADDR_SHTOL(X->rb_parent);
- if (X == (struct ep_rb_node *) ADDR_SHTOL (xParent->rb_right))
+ if (X == (struct ep_rb_node *) SHMEM_ADDR_SHTOL(xParent->rb_right))
{
- xParent->rb_right = (struct ep_rb_node *) ADDR_LTOSH_EXT (Y);
+ xParent->rb_right = (struct ep_rb_node *) SHMEM_ADDR_LTOSH_EXT(Y);
}
- else
+ else
{
- xParent->rb_left = (struct ep_rb_node *) ADDR_LTOSH_EXT (Y);
+ xParent->rb_left = (struct ep_rb_node *) SHMEM_ADDR_LTOSH_EXT(Y);
}
}
- else
+ else
+ {
+ root->rb_node = (struct ep_rb_node *) SHMEM_ADDR_LTOSH_EXT(Y);
+ }
+
+ /* link X and Y */
+ Y->rb_right = (struct ep_rb_node *) SHMEM_ADDR_LTOSH_EXT(X);
+ X->rb_parent = (struct ep_rb_node *) SHMEM_ADDR_LTOSH_EXT(Y);
+
+ return;
+}
+
+static inline int __ep_rb_is_color_local(struct ep_rb_node *node, int color)
+{
+ return (!node || node->color == color);
+}
+
+static inline int __ep_rb_is_color(struct ep_rb_node *node, int color)
+{
+ return (!node
+ || ((struct ep_rb_node *) SHMEM_ADDR_SHTOL(node))->color ==
+ color);
+}
+
+static inline void __ep_rb_set_color(struct ep_rb_node *node, int color)
+{
+ if (node != NULL)
{
- root->rb_node = (struct ep_rb_node *) ADDR_LTOSH_EXT (Y);
+ ((struct ep_rb_node *) SHMEM_ADDR_SHTOL(node))->color = color;
}
+}
- /* link X and Y */
- Y->rb_right = (struct ep_rb_node *) ADDR_LTOSH_EXT (X);
- X->rb_parent = (struct ep_rb_node *) ADDR_LTOSH_EXT (Y);
+/* Oops... What's the proper name? */
+static inline void __ep_rb_adjust(struct ep_rb_node *X,
+ struct ep_rb_root *root,
+ struct ep_rb_node *node)
+{
+ struct ep_rb_node *Parent =
+ (struct ep_rb_node *) SHMEM_ADDR_SHTOL(node->rb_parent);
+ if (Parent)
+ {
+ if (Parent->rb_left ==
+ (struct ep_rb_node *) SHMEM_ADDR_LTOSH_EXT(node))
+ {
+ Parent->rb_left = (struct ep_rb_node *) SHMEM_ADDR_LTOSH_EXT(X);
+ }
+ else
+ {
+ Parent->rb_right = (struct ep_rb_node *) SHMEM_ADDR_LTOSH_EXT(X);
+ }
+ }
+ else
+ {
+ root->rb_node = (struct ep_rb_node *) SHMEM_ADDR_LTOSH_EXT(X);
+ }
- return;
}
-#define EP_RBTREE_PARENT(X) ((struct ep_rb_node*) ADDR_SHTOL((X)->rb_parent))
+#define EP_RBTREE_PARENT(X) ((struct ep_rb_node*) SHMEM_ADDR_SHTOL((X)->rb_parent))
#define EP_RBTREE_GRANDF(X) EP_RBTREE_PARENT(EP_RBTREE_PARENT(X))
/* X, Y are for application */
-void
-ep_rb_insert_color (struct ep_rb_node *X, struct ep_rb_root *root)
+void ep_rb_insert_color(struct ep_rb_node *X, struct ep_rb_root *root)
{
/*************************************
* maintain red-black tree balance *
* after inserting node X *
*************************************/
- /* check red-black properties */
- while (X != (struct ep_rb_node *) ADDR_SHTOL (root->rb_node)
- && EP_RBTREE_PARENT (X)->color == EP_RB_RED)
+
+ /* check red-black properties */
+ while (X != (struct ep_rb_node *) SHMEM_ADDR_SHTOL(root->rb_node)
+ && EP_RBTREE_PARENT(X)->color == EP_RB_RED)
{
- /* we have a violation */
- if (X->rb_parent == EP_RBTREE_GRANDF (X)->rb_left)
+ /* we have a violation */
+ if (X->rb_parent == EP_RBTREE_GRANDF(X)->rb_left)
{
- struct ep_rb_node *Y =
- (struct ep_rb_node *) ADDR_SHTOL (EP_RBTREE_GRANDF (X)->rb_right);
+ struct ep_rb_node *Y =
+ (struct ep_rb_node *)
+ SHMEM_ADDR_SHTOL(EP_RBTREE_GRANDF(X)->rb_right);
- if (Y && Y->color == EP_RB_RED)
+ if (!__ep_rb_is_color_local(Y, EP_RB_BLACK))
{
- /* uncle is red */
- EP_RBTREE_PARENT (X)->color = EP_RB_BLACK;
- Y->color = EP_RB_BLACK;
- EP_RBTREE_GRANDF (X)->color = EP_RB_RED;
- X = EP_RBTREE_GRANDF (X);
+ /* uncle is red */
+ EP_RBTREE_PARENT(X)->color = EP_RB_BLACK;
+ Y->color = EP_RB_BLACK;
+ EP_RBTREE_GRANDF(X)->color = EP_RB_RED;
+ X = EP_RBTREE_GRANDF(X);
}
- else
+ else
{
- /* uncle is black */
- if (X ==
- (struct ep_rb_node *)
- ADDR_SHTOL (EP_RBTREE_PARENT (X)->rb_right))
+ /* uncle is black */
+ if (X ==
+ (struct ep_rb_node *)
+ SHMEM_ADDR_SHTOL(EP_RBTREE_PARENT(X)->rb_right))
{
- /* make X a left child */
- X = EP_RBTREE_PARENT (X);
- __ep_rb_rotate_left (X, root);
+ /* make X a left child */
+ X = EP_RBTREE_PARENT(X);
+ __ep_rb_rotate_left(X, root);
}
- /* recolor and rotate */
- EP_RBTREE_PARENT (X)->color = EP_RB_BLACK;
- EP_RBTREE_GRANDF (X)->color = EP_RB_RED;
- __ep_rb_rotate_right (EP_RBTREE_GRANDF (X), root);
+ /* recolor and rotate */
+ EP_RBTREE_PARENT(X)->color = EP_RB_BLACK;
+ EP_RBTREE_GRANDF(X)->color = EP_RB_RED;
+ __ep_rb_rotate_right(EP_RBTREE_GRANDF(X), root);
}
}
- else
+ else
{
- /* mirror image of above code */
- struct ep_rb_node *Y =
- (struct ep_rb_node *) ADDR_SHTOL (EP_RBTREE_GRANDF (X)->rb_left);
+ /* miror image of above code */
+ struct ep_rb_node *Y =
+ (struct ep_rb_node *)
+ SHMEM_ADDR_SHTOL(EP_RBTREE_GRANDF(X)->rb_left);
- if (Y && (Y->color == EP_RB_RED))
+ if (!__ep_rb_is_color_local(Y, EP_RB_BLACK))
{
- /* uncle is red */
- EP_RBTREE_PARENT (X)->color = EP_RB_BLACK;
- Y->color = EP_RB_BLACK;
- EP_RBTREE_GRANDF (X)->color = EP_RB_RED;
- X = EP_RBTREE_GRANDF (X);
+ /* uncle is red */
+ EP_RBTREE_PARENT(X)->color = EP_RB_BLACK;
+ Y->color = EP_RB_BLACK;
+ EP_RBTREE_GRANDF(X)->color = EP_RB_RED;
+ X = EP_RBTREE_GRANDF(X);
}
- else
+ else
{
- /* uncle is black */
- if (X ==
- (struct ep_rb_node *)
- ADDR_SHTOL (EP_RBTREE_PARENT (X)->rb_left))
+ /* uncle is black */
+ if (X ==
+ (struct ep_rb_node *)
+ SHMEM_ADDR_SHTOL(EP_RBTREE_PARENT(X)->rb_left))
{
- X = EP_RBTREE_PARENT (X);
- __ep_rb_rotate_right (X, root);
+ X = EP_RBTREE_PARENT(X);
+ __ep_rb_rotate_right(X, root);
}
- EP_RBTREE_PARENT (X)->color = EP_RB_BLACK;
- EP_RBTREE_GRANDF (X)->color = EP_RB_RED;
- __ep_rb_rotate_left (EP_RBTREE_GRANDF (X), root);
+ EP_RBTREE_PARENT(X)->color = EP_RB_BLACK;
+ EP_RBTREE_GRANDF(X)->color = EP_RB_RED;
+ __ep_rb_rotate_left(EP_RBTREE_GRANDF(X), root);
}
}
}
- ((struct ep_rb_node *) ADDR_SHTOL (root->rb_node))->color = EP_RB_BLACK;
+ ((struct ep_rb_node *) SHMEM_ADDR_SHTOL(root->rb_node))->color =
+ EP_RB_BLACK;
- return;
+ return;
}
-void
-__ep_rb_erase_color (struct ep_rb_node *X, struct ep_rb_node *Parent,
- struct ep_rb_root *root)
+void __ep_rb_erase_color(struct ep_rb_node *X, struct ep_rb_node *Parent,
+ struct ep_rb_root *root)
{
/*************************************
* maintain red-black tree balance *
* after deleting node X *
*************************************/
- while (X != (struct ep_rb_node *) ADDR_SHTOL (root->rb_node)
- && (!X || X->color == EP_RB_BLACK))
+
+ while (X != (struct ep_rb_node *) SHMEM_ADDR_SHTOL(root->rb_node)
+ && __ep_rb_is_color_local(X, EP_RB_BLACK))
{
- if (Parent == NULL)
+ if (Parent == NULL)
{
- break;
+ break;
}
- if (X == (struct ep_rb_node *) ADDR_SHTOL (Parent->rb_left))
+ if (X == (struct ep_rb_node *) SHMEM_ADDR_SHTOL(Parent->rb_left))
{
- struct ep_rb_node *W =
- (struct ep_rb_node *) ADDR_SHTOL (Parent->rb_right);
+ struct ep_rb_node *W =
+ (struct ep_rb_node *) SHMEM_ADDR_SHTOL(Parent->rb_right);
- if (W->color == EP_RB_RED)
+ if (W->color == EP_RB_RED)
{
- W->color = EP_RB_BLACK;
- Parent->color = EP_RB_RED; /* Parent != NIL? */
- __ep_rb_rotate_left (Parent, root);
- W = (struct ep_rb_node *) ADDR_SHTOL (Parent->rb_right);
+ W->color = EP_RB_BLACK;
+ Parent->color = EP_RB_RED; /* Parent != NIL? */
+ __ep_rb_rotate_left(Parent, root);
+ W = (struct ep_rb_node *) SHMEM_ADDR_SHTOL(Parent->rb_right);
}
- if ((!W->rb_left
- || ((struct ep_rb_node *) ADDR_SHTOL (W->rb_left))->color ==
- EP_RB_BLACK) && (!W->rb_right
- || ((struct ep_rb_node *)
- ADDR_SHTOL (W->rb_right))->color ==
- EP_RB_BLACK))
+ if (__ep_rb_is_color(W->rb_left, EP_RB_BLACK)
+ && __ep_rb_is_color(W->rb_right, EP_RB_BLACK))
{
- W->color = EP_RB_RED;
- X = Parent;
- Parent = (struct ep_rb_node *) ADDR_SHTOL (X->rb_parent);
+ W->color = EP_RB_RED;
+ X = Parent;
+ Parent = (struct ep_rb_node *) SHMEM_ADDR_SHTOL(X->rb_parent);
}
- else
+ else
{
- if (!W->rb_right
- || ((struct ep_rb_node *) ADDR_SHTOL (W->rb_right))->color
- == EP_RB_BLACK)
+ if (__ep_rb_is_color(W->rb_right, EP_RB_BLACK))
{
- if (W->rb_left != NULL)
- {
- ((struct ep_rb_node *) ADDR_SHTOL (W->rb_left))->color
- = EP_RB_BLACK;
- }
-
- W->color = EP_RB_RED;
- __ep_rb_rotate_right (W, root);
- W = (struct ep_rb_node *) ADDR_SHTOL (Parent->rb_right);
+ __ep_rb_set_color(W->rb_left, EP_RB_BLACK);
+
+ W->color = EP_RB_RED;
+ __ep_rb_rotate_right(W, root);
+ W = (struct ep_rb_node *)
+ SHMEM_ADDR_SHTOL(Parent->rb_right);
}
- W->color = Parent->color;
- Parent->color = EP_RB_BLACK;
+ W->color = Parent->color;
+ Parent->color = EP_RB_BLACK;
- if (((struct ep_rb_node *) ADDR_SHTOL (W->rb_right))->color !=
- EP_RB_BLACK)
- {
- ((struct ep_rb_node *) ADDR_SHTOL (W->rb_right))->color =
- EP_RB_BLACK;
- }
+ ((struct ep_rb_node *) SHMEM_ADDR_SHTOL(W->rb_right))->color
+ = EP_RB_BLACK;
- __ep_rb_rotate_left (Parent, root);
- X = (struct ep_rb_node *) ADDR_SHTOL (root->rb_node);
- break;
+ __ep_rb_rotate_left(Parent, root);
+ X = (struct ep_rb_node *) SHMEM_ADDR_SHTOL(root->rb_node);
+ break;
}
}
- else
+ else
{
- struct ep_rb_node *W =
- (struct ep_rb_node *) ADDR_SHTOL (Parent->rb_left);
+ struct ep_rb_node *W =
+ (struct ep_rb_node *) SHMEM_ADDR_SHTOL(Parent->rb_left);
- if (W->color == EP_RB_RED)
+ if (W->color == EP_RB_RED)
{
- W->color = EP_RB_BLACK;
- Parent->color = EP_RB_RED; /* Parent != NIL? */
- __ep_rb_rotate_right (Parent, root);
- W = (struct ep_rb_node *) ADDR_SHTOL (Parent->rb_left);
+ W->color = EP_RB_BLACK;
+ Parent->color = EP_RB_RED; /* Parent != NIL? */
+ __ep_rb_rotate_right(Parent, root);
+ W = (struct ep_rb_node *) SHMEM_ADDR_SHTOL(Parent->rb_left);
}
- if ((!W->rb_left
- || (((struct ep_rb_node *) ADDR_SHTOL (W->rb_left))->color ==
- EP_RB_BLACK)) && (!W->rb_right
- ||
- (((struct ep_rb_node *)
- ADDR_SHTOL (W->rb_right))->color ==
- EP_RB_BLACK)))
+ if (__ep_rb_is_color(W->rb_left, EP_RB_BLACK)
+ && __ep_rb_is_color(W->rb_right, EP_RB_BLACK))
{
- W->color = EP_RB_RED;
- X = Parent;
- Parent = (struct ep_rb_node *) ADDR_SHTOL (X->rb_parent);
+ W->color = EP_RB_RED;
+ X = Parent;
+ Parent = (struct ep_rb_node *) SHMEM_ADDR_SHTOL(X->rb_parent);
}
- else
+ else
{
- if (!W->rb_left
- || ((struct ep_rb_node *) ADDR_SHTOL (W->rb_left))->color
- == EP_RB_BLACK)
+ if (__ep_rb_is_color(W->rb_left, EP_RB_BLACK))
{
- if (W->rb_right != NULL)
- {
- ((struct ep_rb_node *)
- ADDR_SHTOL (W->rb_right))->color = EP_RB_BLACK;
- }
-
- W->color = EP_RB_RED;
- __ep_rb_rotate_left (W, root);
- W = (struct ep_rb_node *) ADDR_SHTOL (Parent->rb_left);
+ __ep_rb_set_color(W->rb_right, EP_RB_BLACK);
+ W->color = EP_RB_RED;
+ __ep_rb_rotate_left(W, root);
+ W = (struct ep_rb_node *)
+ SHMEM_ADDR_SHTOL(Parent->rb_left);
}
- W->color = Parent->color;
- Parent->color = EP_RB_BLACK;
+ W->color = Parent->color;
+ Parent->color = EP_RB_BLACK;
- if (((struct ep_rb_node *) ADDR_SHTOL (W->rb_left))->color !=
- EP_RB_BLACK)
- {
- ((struct ep_rb_node *) ADDR_SHTOL (W->rb_left))->color =
+ ((struct ep_rb_node *) SHMEM_ADDR_SHTOL(W->rb_left))->color =
EP_RB_BLACK;
- }
- __ep_rb_rotate_right (Parent, root);
- X = (struct ep_rb_node *) ADDR_SHTOL (root->rb_node);
- break;
+ __ep_rb_rotate_right(Parent, root);
+ X = (struct ep_rb_node *) SHMEM_ADDR_SHTOL(root->rb_node);
+ break;
}
}
}
- if (X)
+ if (X)
{
- X->color = EP_RB_BLACK;
+ X->color = EP_RB_BLACK;
}
- return;
+ return;
}
-void
-ep_rb_erase (struct ep_rb_node *node, struct ep_rb_root *root)
+void ep_rb_erase(struct ep_rb_node *node, struct ep_rb_root *root)
{
- struct ep_rb_node *child, *parent;
- int color;
+ struct ep_rb_node *child, *parent;
+ int color;
- if (!node->rb_left)
+ if (!node->rb_left)
{
- child = (struct ep_rb_node *) ADDR_SHTOL (node->rb_right);
+ child = (struct ep_rb_node *) SHMEM_ADDR_SHTOL(node->rb_right);
}
- else if (!node->rb_right)
+ else if (!node->rb_right)
{
- child = (struct ep_rb_node *) ADDR_SHTOL (node->rb_left);
+ child = (struct ep_rb_node *) SHMEM_ADDR_SHTOL(node->rb_left);
}
- else
+ else
{
- struct ep_rb_node *old = node, *left;
+ struct ep_rb_node *old = node, *left;
- node = (struct ep_rb_node *) ADDR_SHTOL (node->rb_right);
+ node = (struct ep_rb_node *) SHMEM_ADDR_SHTOL(node->rb_right);
- while ((left =
- (struct ep_rb_node *) ADDR_SHTOL (node->rb_left)) != NULL)
+ while ((left =
+ (struct ep_rb_node *) SHMEM_ADDR_SHTOL(node->rb_left)) !=
+ NULL)
{
- node = left;
+ node = left;
}
- if (old->rb_parent)
- {
- struct ep_rb_node *oldParent =
- (struct ep_rb_node *) ADDR_SHTOL (old->rb_parent);
-
- if (oldParent->rb_left ==
- (struct ep_rb_node *) ADDR_LTOSH_EXT (old))
- {
- oldParent->rb_left =
- (struct ep_rb_node *) ADDR_LTOSH_EXT (node);
- }
- else
- {
- oldParent->rb_right =
- (struct ep_rb_node *) ADDR_LTOSH_EXT (node);
- }
- }
- else
- {
- root->rb_node = (struct ep_rb_node *) ADDR_LTOSH_EXT (node);
- }
+ __ep_rb_adjust(node, root, old);
- child = (struct ep_rb_node *) ADDR_SHTOL (node->rb_right);
- parent = (struct ep_rb_node *) ADDR_SHTOL (node->rb_parent);
- color = node->color;
+ child = (struct ep_rb_node *) SHMEM_ADDR_SHTOL(node->rb_right);
+ parent = (struct ep_rb_node *) SHMEM_ADDR_SHTOL(node->rb_parent);
+ color = node->color;
- if (parent == old)
+ if (parent == old)
{
- parent = node;
+ parent = node;
}
- else
+ else
{
- if (child)
+ if (child)
{
- child->rb_parent =
- (struct ep_rb_node *) ADDR_LTOSH_EXT (parent);
+ child->rb_parent =
+ (struct ep_rb_node *) SHMEM_ADDR_LTOSH_EXT(parent);
}
- parent->rb_left = (struct ep_rb_node *) ADDR_LTOSH_EXT (child);
+ parent->rb_left =
+ (struct ep_rb_node *) SHMEM_ADDR_LTOSH_EXT(child);
- node->rb_right = old->rb_right;
- ((struct ep_rb_node *) ADDR_SHTOL (old->rb_right))->rb_parent =
- (struct ep_rb_node *) ADDR_LTOSH_EXT (node);
+ node->rb_right = old->rb_right;
+ ((struct ep_rb_node *)
+ SHMEM_ADDR_SHTOL(old->rb_right))->rb_parent =
+(struct ep_rb_node *) SHMEM_ADDR_LTOSH_EXT(node);
}
- node->color = old->color;
- node->rb_parent = old->rb_parent;
- node->rb_left = old->rb_left;
- ((struct ep_rb_node *) ADDR_SHTOL (old->rb_left))->rb_parent =
- (struct ep_rb_node *) ADDR_LTOSH_EXT (node);
+ node->color = old->color;
+ node->rb_parent = old->rb_parent;
+ node->rb_left = old->rb_left;
+ ((struct ep_rb_node *) SHMEM_ADDR_SHTOL(old->rb_left))->rb_parent =
+ (struct ep_rb_node *) SHMEM_ADDR_LTOSH_EXT(node);
- if (color == EP_RB_BLACK)
+ if (color == EP_RB_BLACK)
{
- __ep_rb_erase_color (child, parent, root);
+ __ep_rb_erase_color(child, parent, root);
}
- return;
+ return;
}
- parent = (struct ep_rb_node *) ADDR_SHTOL (node->rb_parent);
- color = node->color;
+ parent = (struct ep_rb_node *) SHMEM_ADDR_SHTOL(node->rb_parent);
+ color = node->color;
- if (child)
+ if (child)
{
- child->rb_parent = (struct ep_rb_node *) ADDR_LTOSH_EXT (parent);
+ child->rb_parent = (struct ep_rb_node *) SHMEM_ADDR_LTOSH_EXT(parent);
}
- if (parent)
- {
- if (parent->rb_left == (struct ep_rb_node *) ADDR_LTOSH_EXT (node))
- {
- parent->rb_left = (struct ep_rb_node *) ADDR_LTOSH_EXT (child);
- }
- else
- {
- parent->rb_right = (struct ep_rb_node *) ADDR_LTOSH_EXT (child);
- }
- }
- else
- {
- root->rb_node = (struct ep_rb_node *) ADDR_LTOSH_EXT (child);
- }
+ __ep_rb_adjust(child, root, node);
- if (color == EP_RB_BLACK)
+ if (color == EP_RB_BLACK)
{
- __ep_rb_erase_color (child, parent, root);
+ __ep_rb_erase_color(child, parent, root);
}
- return;
+
+ return;
}
#ifdef __cplusplus
diff --git a/src/framework/common/data_struct/list.c b/src/framework/common/data_struct/list.c
index d9ea5a4..ccdb039 100644
--- a/src/framework/common/data_struct/list.c
+++ b/src/framework/common/data_struct/list.c
@@ -17,87 +17,80 @@
#include "list.h"
/**
- * function-name : list_empty
- * description : tests whether a list is empty
- * parameter @head : the list to test.
+ * list_empty - tests whether a list is empty
+ * @head: the list to test.
*/
-inline int
-list_empty (const struct list_head *head_of_list)
+inline int list_empty(const struct list_head *head)
{
- return head_of_list->next == head_of_list;
+ return head->next == head;
}
-inline void
-list_del (struct list_head *entry)
+inline void list_del(struct list_head *entry)
{
- if (entry->prev == NULL || entry->next == NULL)
+ if (entry->prev == NULL || entry->next == NULL)
{
- return;
+ return;
}
- entry->next->prev = entry->prev;
- entry->prev->next = entry->next;
- entry->next = NULL;
- entry->prev = NULL;
+ entry->next->prev = entry->prev;
+ entry->prev->next = entry->next;
+ entry->next = NULL;
+ entry->prev = NULL;
}
/*get the first element of the list, need to check if list empty or not before calling this.*/
-inline struct list_head *
-list_get_first (struct list_head *head)
+inline struct list_head *list_get_first(struct list_head *head)
{
- return head->next;
+ return head->next;
}
-inline void
-list_add (struct list_head *newp, struct list_head *head)
+inline void list_add(struct list_head *newp, struct list_head *head)
{
- head->next->prev = newp;
- newp->next = head->next;
- newp->prev = head;
- head->next = newp;
+ head->next->prev = newp;
+ newp->next = head->next;
+ newp->prev = head;
+ head->next = newp;
}
-inline void
-list_link (struct list_head *newhead, struct list_head *head)
+inline void list_link(struct list_head *newhead, struct list_head *head)
{
- struct list_head *tmp;
+ struct list_head *tmp;
- newhead->prev->next = head;
- head->prev->next = newhead;
+ newhead->prev->next = head;
+ head->prev->next = newhead;
- tmp = newhead->prev;
- newhead->prev = head->prev;
- head->prev = tmp;
+ tmp = newhead->prev;
+ newhead->prev = head->prev;
+ head->prev = tmp;
}
-inline void
-list_add_tail (struct list_head *newp, struct list_head *head)
+inline void list_add_tail(struct list_head *newp, struct list_head *head)
{
- list_add (newp, head->prev);
+ list_add(newp, head->prev);
}
-inline void
-hlist_del_init (struct hlist_node *n)
+inline void hlist_del_init(struct hlist_node *n)
{
- struct hlist_node *next_node = n->next;
- struct hlist_node **pprev = n->pprev;
+ struct hlist_node *next = n->next;
+ struct hlist_node **pprev = n->pprev;
- if (pprev == NULL && next_node == NULL)
+ if (pprev == NULL && next == NULL)
{
- return;
+ return;
}
- if (pprev)
+ /*null pointer validation already done. */
+ if (pprev)
{
- *pprev = next_node;
+ *pprev = next;
}
- if (next_node)
+ if (next)
{
- next_node->pprev = pprev;
+ next->pprev = pprev;
}
- n->next = NULL;
- n->pprev = NULL;
+ n->next = NULL;
+ n->pprev = NULL;
}
/**
@@ -107,13 +100,12 @@ hlist_del_init (struct hlist_node *n)
* @n: new node
* @next: node in the hlist
*/
-inline void
-hlist_add_before (struct hlist_node *node, struct hlist_node *next)
+inline void hlist_add_before(struct hlist_node *n, struct hlist_node *next)
{
- node->pprev = next->pprev;
- node->next = next;
- next->pprev = &node->next;
- *(node->pprev) = node;
+ n->pprev = next->pprev;
+ n->next = next;
+ next->pprev = &n->next;
+ *(n->pprev) = n;
}
/**
@@ -123,42 +115,38 @@ hlist_add_before (struct hlist_node *node, struct hlist_node *next)
* @n: node in the hlist
* @next: new node
*/
-inline void
-hlist_add_after (struct hlist_node *node, struct hlist_node *next)
+inline void hlist_add_after(struct hlist_node *n, struct hlist_node *next)
{
- next->next = node->next;
- node->next = next;
- next->pprev = &node->next;
- if (next->next)
+ next->next = n->next;
+ n->next = next;
+ next->pprev = &n->next;
+ if (next->next)
{
- next->next->pprev = &next->next;
+ next->next->pprev = &next->next;
}
}
/* add after the head */
-inline void
-hlist_add_head (struct hlist_node *node, struct hlist_head *h)
+inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
{
- struct hlist_node *first = h->first;
+ struct hlist_node *first = h->first;
- node->next = first;
- if (first)
+ n->next = first;
+ if (first)
{
- first->pprev = &node->next;
+ first->pprev = &n->next;
}
- h->first = node;
- node->pprev = &h->first;
+ h->first = n;
+ n->pprev = &h->first;
}
-inline int
-hlist_unhashed (const struct hlist_node *node)
+inline int hlist_unhashed(const struct hlist_node *h)
{
- return !node->pprev;
+ return !h->pprev;
}
-inline int
-hlist_empty (const struct hlist_head *node)
+inline int hlist_empty(const struct hlist_head *h)
{
- return !node->first;
+ return !h->first;
}
diff --git a/src/framework/common/data_struct/pidinfo.c b/src/framework/common/data_struct/pidinfo.c
index 08e551f..3095c0d 100644
--- a/src/framework/common/data_struct/pidinfo.c
+++ b/src/framework/common/data_struct/pidinfo.c
@@ -17,109 +17,105 @@
#include "pidinfo.h"
#include "nstack_securec.h"
-inline i32
-nsfw_pidinfo_init (nsfw_pidinfo * pidinfo)
+inline i32 nsfw_pidinfo_init(nsfw_pidinfo * pidinfo)
{
- int retVal =
- MEMSET_S (pidinfo, sizeof (nsfw_pidinfo), 0, sizeof (nsfw_pidinfo));
- if (EOK != retVal)
+ /*add return value check */
+ int retVal =
+ memset_s(pidinfo, sizeof(nsfw_pidinfo), 0, sizeof(nsfw_pidinfo));
+ if (EOK != retVal)
{
- return -1;
+ return -1;
}
- return 0;
+ return 0;
}
-inline int
-nsfw_add_pid (nsfw_pidinfo * pidinfo, u32 pid)
+inline int nsfw_add_pid(nsfw_pidinfo * pidinfo, u32 pid)
{
- u32 i;
+ u32 i;
- for (i = 0; i < NSFW_MAX_FORK_NUM; i++)
+ for (i = 0; i < NSFW_MAX_FORK_NUM; i++)
{
- if ((0 == pidinfo->apid[i])
- && (__sync_bool_compare_and_swap (&pidinfo->apid[i], 0, pid)))
+
+ if ((0 == pidinfo->apid[i])
+ && (__sync_bool_compare_and_swap(&pidinfo->apid[i], 0, pid)))
{
- if (pidinfo->used_size < i + 1)
+ if (pidinfo->used_size < i + 1)
{
- pidinfo->used_size = i + 1;
+ pidinfo->used_size = i + 1;
}
- return 0;
+ return 0;
}
}
- return -1;
+ return -1;
}
-inline int
-nsfw_del_pid (nsfw_pidinfo * pidinfo, u32 pid)
+inline int nsfw_del_pid(nsfw_pidinfo * pidinfo, u32 pid)
{
- u32 i;
+ u32 i;
- for (i = 0; i < pidinfo->used_size && i < NSFW_MAX_FORK_NUM; i++)
+ for (i = 0; i < pidinfo->used_size && i < NSFW_MAX_FORK_NUM; i++)
{
- if (pid == pidinfo->apid[i])
+ if (pid == pidinfo->apid[i])
{
- pidinfo->apid[i] = 0;
- return 0;
+ pidinfo->apid[i] = 0;
+ return 0;
}
}
- return -1;
+ return -1;
}
-inline int
-nsfw_del_last_pid (nsfw_pidinfo * pidinfo, u32 pid)
+inline int nsfw_del_last_pid(nsfw_pidinfo * pidinfo, u32 pid)
{
- u32 i;
- int count = 0;
- int deleted = 0;
- for (i = 0; i < pidinfo->used_size && i < NSFW_MAX_FORK_NUM; i++)
+ u32 i;
+ int count = 0;
+ int deleted = 0;
+ for (i = 0; i < pidinfo->used_size && i < NSFW_MAX_FORK_NUM; i++)
{
- if (pid == pidinfo->apid[i])
+ if (pid == pidinfo->apid[i])
{
- pidinfo->apid[i] = 0;
- deleted = 1;
- continue;
+ pidinfo->apid[i] = 0;
+ deleted = 1;
+ continue;
}
- if (pidinfo->apid[i] != 0)
+ if (pidinfo->apid[i] != 0)
{
- ++count;
+ ++count;
}
}
- if (!deleted)
+ if (!deleted)
{
- return -1;
+ return -1;
}
- return count;
+ return count;
}
-inline int
-nsfw_pid_exist (nsfw_pidinfo * pidinfo, u32 pid)
+inline int nsfw_pid_exist(nsfw_pidinfo * pidinfo, u32 pid)
{
- u32 i;
+ u32 i;
- for (i = 0; i < pidinfo->used_size && i < NSFW_MAX_FORK_NUM; i++)
+ for (i = 0; i < pidinfo->used_size && i < NSFW_MAX_FORK_NUM; i++)
{
- if (pid == pidinfo->apid[i])
+ if (pid == pidinfo->apid[i])
{
- return 1;
+ return 1;
}
}
- return 0;
+ return 0;
}
-inline int
-nsfw_pidinfo_empty (nsfw_pidinfo * pidinfo)
+inline int nsfw_pidinfo_empty(nsfw_pidinfo * pidinfo)
{
- u32 i;
- for (i = 0; i < pidinfo->used_size && i < NSFW_MAX_FORK_NUM; i++)
+ u32 i;
+ for (i = 0; i < pidinfo->used_size && i < NSFW_MAX_FORK_NUM; i++)
{
- if (pidinfo->apid[i] != 0)
+ if (pidinfo->apid[i] != 0)
{
- return 0;
+ return 0;
}
}
- return 1;
+ return 1;
}
diff --git a/src/framework/common/data_struct/sha256.c b/src/framework/common/data_struct/sha256.c
deleted file mode 100644
index f0773cf..0000000
--- a/src/framework/common/data_struct/sha256.c
+++ /dev/null
@@ -1,383 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-/*Possible access of out-of-bounds pointer:
- The algorithms has been tested on purify. So no
- out of bounds access possible.*/
-
-/*Possible creation of out-of-bounds pointer
- No Out of bounds pointers are created.- false positive.*/
-
-#include <string.h> /* for mem copy function etc. */
-#include "sha256.h"
-#include "nstack_securec.h"
-#include "types.h"
-#include "nstack_log.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-#define rotleft32(x,n) (((x) << n) | ((x) >> (32 - n)))
-#define rotright32(x,n) (((x) >> n) | ((x) << (32 - n)))
-
-#if !defined(bswap_32)
-#define bswap_32(x) ((rotright32((x), 24) & 0x00ff00ff) | (rotright32((x), 8) & 0xff00ff00))
-#endif
-
-#ifdef LITTLE_ENDIAN
-#define SWAP_THE_BYTES
-#else
-#undef SWAP_THE_BYTES
-#endif
-
-#define ch(a,b,c) ((c) ^ ((a) & ((b) ^ (c))))
-#define maj(a,b,c) (((a) & (b)) | ((c) & ((a) ^ (b))))
-
- /* round transforms for the SHA256 & SHA512 compression functions */
-
-#define vf(m,n) v[(m - n) & 7]
-
-#define hf(n) (p[n & 15] += \
- g_1(p[(n + 14) & 15]) + p[(n + 9) & 15] + g_0(p[(n + 1) & 15]))
-
-#define v_cycle(m,n) \
-{ \
- vf(7,m) += (n ? hf(m) : p[m]) + k_0[m+n] \
- + s_1(vf(4,m)) + ch(vf(4,m),vf(5,m),vf(6,m)); \
- vf(3,m) += vf(7,m); \
- vf(7,m) += s_0(vf(0,m))+ maj(vf(0,m),vf(1,m),vf(2,m)); \
-}
-
-#define SHA256_MASK (SHA256_BLOCK_SIZE - 1) /* SHA256_MASK */
-
-#if defined(SWAP_THE_BYTES)
-#define bsw_32(p,n) \
-{ \
- u32 _i = (n); \
- while (_i--) \
- { \
- ((u32*)p)[_i] = bswap_32(((u32*)p)[_i]); \
- } \
-}
-
-#else
-#define bsw_32(p,n)
-#endif
-
-#define s_0(x) (rotright32((x), 2) ^ rotright32((x), 13) ^ rotright32((x), 22))
-#define s_1(x) (rotright32((x), 6) ^ rotright32((x), 11) ^ rotright32((x), 25))
-#define g_0(x) (rotright32((x), 7) ^ rotright32((x), 18) ^ ((x) >> 3))
-#define g_1(x) (rotright32((x), 17) ^ rotright32((x), 19) ^ ((x) >> 10))
-#define k_0 k256
-
-/* rotated SHA256 round definition. Unlike swapping the variables as in */
-/* FIPS-180, different variables are being 'rotated' on each round, */
-/* returning to their starting positions every 8 rounds */
-
-#define q(i) v##i
-
-#define one_cycle(a,b,c,d,e,f,g,h,k,w) \
- q(h) += s_1(q(e)) + ch(q(e), q(f), q(g)) + k + w; \
- q(d) += q(h); q(h) += s_0(q(a)) + maj(q(a), q(b), q(c))
-
-/*
-Description: SHA256 mixing data
-Value Range: None
-Access: Used to mix with data to create SHA256 key.
-Remarks:
-*/
-static const u32 k256[64] = {
- 010242427630, 016115642221, 026560175717, 035155355645,
- 07125541133, 013174210761, 022217701244, 025307057325,
- 033001725230, 02240655401, 04414302676, 012503076703,
- 016257456564, 020067530776, 023367003247, 030146770564,
- 034446664701, 035757443606, 01760316706, 04403120714,
- 05572226157, 011235102252, 013454124734, 016676304332,
- 023017450522, 025014343155, 026000623710, 027726277707,
- 030670005763, 032551710507, 0662461521, 02412224547,
- 04755605205, 05606620470, 011513066774, 012316006423,
- 014502471524, 016632405273, 020160544456, 022234426205,
- 024257764241, 025006463113, 030222705560, 030733050643,
- 032144564031, 032646203044, 036403432605, 02032520160,
- 03151140426, 03615666010, 04722073514, 06454136265,
- 07107006263, 011666125112, 013347145117, 015013467763,
- 016443701356, 017051261557, 020462074024, 021461601010,
- 022057577772, 024424066353, 027676321767, 030634274362,
-};
-
-#define v_ v
-#define ptr p
-
-/*===========================================================================*\
- Function :Sha256_compile__
- Description : This function generates the digest value for SHA256.
- Compile 64 bytes of hash data into SHA256 digest value
- Calls : mem copy - Secure mem copy function.
- Called by :
- Return : This is a static internal function which doesn't return any value.
- Parameters :
- SHA256_CTX ctx[1] -
- Note : this routine assumes that the byte order in the
- ctx->wbuf[] at this point is such that low address bytes in
- the ORIGINAL byte stream will go into the high end of
- words on BOTH big and little endian systems.
-\*===========================================================================*/
-NSTACK_STATIC void
-Sha256_compile__ (SHA256_CTX ctx[1])
-{
-
- /* macros defined above to this function i.e. v_ and ptr should not be removed */
- /* v_cycle - for 0 to 15 */
- u32 i;
- u32 *ptr = ctx->wbuf;
- u32 v_[8];
-
- int ret = MEMCPY_S (v_, 8 * sizeof (u32), ctx->hash, 8 * sizeof (u32));
- if (EOK != ret)
- {
- NSPOL_LOGERR ("MEMCPY_S failed");
- return;
- }
-
- for (i = 0; i < 64; i += 16)
- {
- /*v_cycle operations from 0 to 15 */
- v_cycle (0, i);
- v_cycle (1, i);
- v_cycle (2, i);
- v_cycle (3, i);
- v_cycle (4, i);
- v_cycle (5, i);
- v_cycle (6, i);
- v_cycle (7, i);
- v_cycle (8, i);
- v_cycle (9, i);
- v_cycle (10, i);
- v_cycle (11, i);
- v_cycle (12, i);
- v_cycle (13, i);
- v_cycle (14, i);
- v_cycle (15, i);
- }
-
- /* update the context */
- ctx->hash[0] += v_[0];
- ctx->hash[1] += v_[1];
- ctx->hash[2] += v_[2];
- ctx->hash[3] += v_[3];
- ctx->hash[4] += v_[4];
- ctx->hash[5] += v_[5];
- ctx->hash[6] += v_[6];
- ctx->hash[7] += v_[7];
-
- return;
-}
-
-#undef v_
-#undef ptr
-
-/*===========================================================================*\
- Function :Sha256_upd
- Description :
- Calls :
- Called by :
- Return :void -
- Parameters :
- SHA256_CTX ctx[1] -
- const unsigned char data[] -
- size_t len -
- Note :
-\*===========================================================================*/
-void
-Sha256_upd (SHA256_CTX sha256_ctx[1], const u8 data[], size_t len)
-{
- u32 pos = (u32) (sha256_ctx->count[0] & SHA256_MASK);
- u32 capacity = SHA256_BLOCK_SIZE - pos;
- const u8 *sp = data;
- int ret;
-
- if ((sha256_ctx->count[0] += (u32) len) < len)
- {
- ++(sha256_ctx->count[1]);
- }
-
- while (len >= capacity)
- {
-
- /* tranfer whole blocks while possible */
- ret =
- MEMCPY_S (((u8 *) sha256_ctx->wbuf) + pos, capacity, sp, capacity);
- if (EOK != ret)
- {
- NSPOL_LOGERR ("MEMCPY_S failed");
- return;
- }
-
- sp += capacity;
- len -= capacity;
- capacity = SHA256_BLOCK_SIZE;
- pos = 0;
- bsw_32 (sha256_ctx->wbuf, SHA256_BLOCK_SIZE >> 2);
- Sha256_compile__ (sha256_ctx);
- }
-
- if (len != 0)
- {
- ret =
- MEMCPY_S (((u8 *) sha256_ctx->wbuf) + pos, (u32) len, sp, (u32) len);
- if (EOK != ret)
- {
- NSPOL_LOGERR ("MEMCPY_S failed");
- return;
- }
- }
-
- return;
-}
-
-/* the Final padding and digest calculation of SHA256 */
-
-/*===========================================================================*\
- Function :SHA_fin1
- Description :
- Calls :
- Called by :
- Return :void -
- Parameters :
- unsigned char hval[] -
- SHA256_CTX ctx[1] -
- const unsigned int hlen -
- Note :
-\*===========================================================================*/
-NSTACK_STATIC void
-SHA_fin1 (u8 hval[], SHA256_CTX ctx[1], const unsigned int hlen)
-{
- u32 i = (u32) (ctx->count[0] & SHA256_MASK);
-
- /* Not unusual shift operation. Checked with purify. */
-
- /*put bytes in the buffer in an order in which references to */
- /*32-bit words will put bytes with lower addresses into the */
- /*top of 32 bit words on BOTH big and little endian machines */
- bsw_32 (ctx->wbuf, (i + 3) >> 2);
-
- /*now it is needed to mask valid bytes and add padding which is */
- /*a single 1 bit and as many zero bits as necessary. Note that */
- /*we can always add the first padding byte here because the */
- /*buffer always has at least one empty slot */
- ctx->wbuf[i >> 2] &= (u32) 0xffffff80 << 8 * (~i & 3);
- ctx->wbuf[i >> 2] |= (u32) 0x00000080 << 8 * (~i & 3);
-
- if (i > SHA256_BLOCK_SIZE - 9)
- {
- if (i < 60)
- {
- ctx->wbuf[15] = 0;
- }
-
- Sha256_compile__ (ctx);
- i = 0;
- }
- else
- {
- /* compute a word index for the empty buffer positions */
- i = (i >> 2) + 1;
- }
-
- while (i < 14)
- {
- /* and zero pad all but last two positions */
- ctx->wbuf[i++] = 0;
- }
-
- ctx->wbuf[14] = (ctx->count[1] << 3) | (ctx->count[0] >> 29);
- ctx->wbuf[15] = ctx->count[0] << 3;
- Sha256_compile__ (ctx);
-
- for (i = 0; i < hlen; ++i)
- {
- hval[i] = (u8) (ctx->hash[i >> 2] >> (8 * (~i & 3)));
- }
-
- return;
-}
-
-/*
-Description: Internal data for SHA256 digest calculation
-Value Range: None
-Access: Used to store internal data for SHA256 digest calculation
-Remarks:
-*/
-static const u32 g_i256[] = {
- 0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A,
- 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19
-};
-
-/*===========================================================================*\
- Function :Sha256_set
- Description :
- Calls :
- Called by :
- Return :void -
- Parameters :
- SHA256_CTX ctx[1] -
- Note :
-\*===========================================================================*/
-void
-Sha256_set (SHA256_CTX sha256_ctx[1])
-{
- int ret;
- sha256_ctx->count[0] = sha256_ctx->count[1] = 0;
-
- ret =
- MEMCPY_S (sha256_ctx->hash, sizeof (sha256_ctx->hash), g_i256,
- sizeof (g_i256));
- if (EOK != ret)
- {
- NSPOL_LOGERR ("MEMCPY_S failed");
- return;
- }
-
- return;
-}
-
-/*===========================================================================*\
- Function :Sha256_fin
- Description :
- Calls :
- Called by :
- Return :void -
- Parameters :
- SHA256_CTX ctx[1] -
- unsigned char hval[] -
- Note :
-\*===========================================================================*/
-void
-Sha256_fin (SHA256_CTX ctx[1], u8 hval[])
-{
- SHA_fin1 (hval, ctx, SHA256_DIGEST_SIZE);
-
- return;
-}
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
diff --git a/src/framework/common/include/arch/x86/dmm_atomic.h b/src/framework/common/include/arch/x86/dmm_atomic.h
deleted file mode 100644
index fae99c2..0000000
--- a/src/framework/common/include/arch/x86/dmm_atomic.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-#ifndef _DMM_ATOMIC_H__ARCH_X86_
-#define _DMM_ATOMIC_H__ARCH_X86_
-
-#include "generic/dmm_atomic.h"
-
-#endif /* #ifndef _DMM_ATOMIC_H__ARCH_X86_ */
diff --git a/src/framework/common/include/arch/x86/dmm_barrier.h b/src/framework/common/include/arch/x86/dmm_barrier.h
deleted file mode 100644
index bf53650..0000000
--- a/src/framework/common/include/arch/x86/dmm_barrier.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-#ifndef _DMM_BARRIER_H__ARCH_X86_
-#define _DMM_BARRIER_H__ARCH_X86_
-
-#include "generic/dmm_barrier.h"
-
-#endif /* #ifndef _DMM_BARRIER_H__ARCH_X86_ */
diff --git a/src/framework/common/include/arch/x86/dmm_pause.h b/src/framework/common/include/arch/x86/dmm_pause.h
deleted file mode 100644
index 56c60f0..0000000
--- a/src/framework/common/include/arch/x86/dmm_pause.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-#ifndef _DMM_PAUSE_H_
-#define _DMM_PAUSE_H_
-
-#include <emmintrin.h>
-
-inline static void
-dmm_pause (void)
-{
- _mm_pause ();
-}
-
-#define DMM_PAUSE_WHILE(cond) do { dmm_pause(); } while (!!(cond))
-#define DMM_WHILE_PAUSE(cond) do { while (!!(cond)) dmm_pause(); } while (0)
-
-#endif /* #ifndef _DMM_PAUSE_H_ */
diff --git a/src/framework/common/include/arch/x86/dmm_rwlock.h b/src/framework/common/include/arch/x86/dmm_rwlock.h
deleted file mode 100644
index 0c31329..0000000
--- a/src/framework/common/include/arch/x86/dmm_rwlock.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-#ifndef _DMM_RWLOCK_H__ARCH_X86_
-#define _DMM_RWLOCK_H__ARCH_X86_
-
-#include "generic/dmm_rwlock.h"
-
-#endif /* #ifndef _DMM_RWLOCK_H__ARCH_X86_ */
diff --git a/src/framework/common/include/arch/x86/dmm_spinlock.h b/src/framework/common/include/arch/x86/dmm_spinlock.h
deleted file mode 100644
index 69ed9a6..0000000
--- a/src/framework/common/include/arch/x86/dmm_spinlock.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-#ifndef _DMM_SPINLOCK_H__ARCH_X86_
-#define _DMM_SPINLOCK_H__ARCH_X86_
-
-#include "generic/dmm_spinlock.h"
-
-#endif /* #ifndef _DMM_SPINLOCK_H__ARCH_X86_ */
diff --git a/src/framework/common/include/ephlist.h b/src/framework/common/include/ephlist.h
deleted file mode 100644
index 90491b0..0000000
--- a/src/framework/common/include/ephlist.h
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _EPHLIST_H_
-#define _EPHLIST_H_
-
-#include <stdio.h>
-#include "types.h"
-#include "common_mem_pal.h"
-#include "common_mem_buf.h"
-#include "common_pal_bitwide_adjust.h"
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-struct ep_hlist_node
-{
- struct ep_hlist_node *next, **pprev;
-};
-
-struct ep_node_list
-{
- struct ep_hlist_node *head;
- struct ep_hlist_node *tail;
-};
-
-struct ep_hlist
-{
- struct ep_hlist_node node;
- struct ep_hlist_node *head;
- struct ep_hlist_node *tail;
-};
-
-#define ep_hlist_entry(ptr, type, member) container_of(ptr, type, member)
-
-#define EP_HLIST_INIT_NODE(node) {\
- (node)->next = NULL;\
- (node)->pprev = NULL; \
- }
-
-#define EP_HLIST_INIT(ptr) {\
- EP_HLIST_INIT_NODE(&((ptr)->node)); \
- (ptr)->head = (struct ep_hlist_node*)ADDR_LTOSH_EXT(&((ptr)->node)); \
- (ptr)->tail = (struct ep_hlist_node*)ADDR_LTOSH_EXT(&((ptr)->node)); \
- }
-
-#define EP_HLIST_PREV(ptr) ((struct ep_hlist_node*)(ADDR_SHTOL((ptr)->pprev)))
-/* list check may below zero check header, because if app crash before
- do list->size++, it will lead problem */
-#define EP_HLIST_EMPTY(list) (NULL == ((struct ep_hlist_node*)ADDR_SHTOL((list)->head))->next)
-#define EP_HLIST_NODE_LINKED(node) (!(!(node)->pprev))
-
-static __inline void ep_hlist_del (struct ep_hlist *list,
- struct ep_hlist_node *n);
-static __inline void ep_hlist_add_tail (struct ep_hlist *list,
- struct ep_hlist_node *node);
-
-/*
- * list , n are local pointer, don't need to cast
- */
-static __inline void
-ep_hlist_del (struct ep_hlist *list, struct ep_hlist_node *n)
-{
- if (!EP_HLIST_NODE_LINKED (n))
- return;
- EP_HLIST_PREV (n)->next = n->next;
- if (n->next)
- {
- ((struct ep_hlist_node *) ADDR_SHTOL (n->next))->pprev = n->pprev;
- }
- else
- {
- list->tail = (struct ep_hlist_node *) (n->pprev);
- }
- EP_HLIST_INIT_NODE (n);
-}
-
-/**
- * list, node are local pointer , don't need to case
- */
-static __inline void
-ep_hlist_add_tail (struct ep_hlist *list, struct ep_hlist_node *node)
-{
- struct ep_hlist_node *tail =
- (struct ep_hlist_node *) ADDR_SHTOL (list->tail);
- EP_HLIST_INIT_NODE (node);
- node->pprev = (struct ep_hlist_node **) ADDR_LTOSH_EXT (&tail->next);
- tail->next = (struct ep_hlist_node *) ADDR_LTOSH_EXT (node);
- list->tail = (struct ep_hlist_node *) ADDR_LTOSH_EXT (node);
-}
-
-/*#########################################################*/
-struct list_node
-{
- struct list_node *next;
-};
-
-struct ep_list
-{
- struct list_node node;
- struct list_node *head;
-};
-
-#define ep_list_entry(ptr, type, member) container_of(ptr, type, member)
-
-#define EP_LIST_INIT_NODE(node) {\
- (node)->next = NULL;\
- }
-
-#define EP_LIST_INIT(ptr) {\
- EP_LIST_INIT_NODE(&((ptr)->node)); \
- (ptr)->head = (struct list_node*)ADDR_LTOSH_EXT(&((ptr)->node)); \
- }
-
-#define EP_LIST_EMPTY(list) (NULL == ((struct list_node*)ADDR_SHTOL((list)->head))->next)
-
-static __inline void ep_list_del (struct ep_list *list, struct list_node *n);
-static __inline void ep_list_add_tail (struct ep_list *list,
- struct list_node *node);
-
-/*
- * list , n are local pointer, don't need to cast
- */
-static __inline void
-ep_list_del (struct ep_list *list, struct list_node *n)
-{
- if (NULL == n)
- {
- return;
- }
-
- struct list_node *p_node;
- struct list_node *p_prev = NULL;
- p_node = ((struct list_node *) ADDR_SHTOL (list->head));
- while (NULL != p_node && p_node != n)
- {
- p_prev = p_node;
- p_node = ((struct list_node *) ADDR_SHTOL (p_node->next));
- }
-
- if (p_node != n || p_prev == NULL)
- {
- return;
- }
-
- p_prev->next = n->next;
-
- EP_LIST_INIT_NODE (n);
- return;
-}
-
-/**
- * list, node are local pointer , don't need to case
- */
-static __inline void
-ep_list_add_tail (struct ep_list *list, struct list_node *node)
-{
-
- struct list_node *p_node;
- struct list_node *p_prev = NULL;
- p_node = ((struct list_node *) ADDR_SHTOL (list->head));
- while (NULL != p_node)
- {
- p_prev = p_node;
- p_node = ((struct list_node *) ADDR_SHTOL (p_node->next));
- }
-
- if (NULL == p_prev)
- {
- return;
- }
-
- EP_LIST_INIT_NODE (node);
- p_prev->next = (struct list_node *) ADDR_LTOSH_EXT (node);
- return;
-}
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif /* _HLIST_H_ */
diff --git a/src/framework/common/include/generic/dmm_atomic.h b/src/framework/common/include/generic/dmm_atomic.h
deleted file mode 100644
index 637306b..0000000
--- a/src/framework/common/include/generic/dmm_atomic.h
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-#ifndef _DMM_ATOMIC_H_
-#define _DMM_ATOMIC_H_
-
-/* atomic 32 bit operation */
-
-typedef struct
-{
- volatile int cnt;
-} dmm_atomic_t;
-
-inline static int
-dmm_atomic_get (dmm_atomic_t * a)
-{
- return a->cnt;
-}
-
-inline static int
-dmm_atomic_add (dmm_atomic_t * a, int n)
-{
- return __sync_fetch_and_add (&a->cnt, n);
-}
-
-inline static int
-dmm_atomic_sub (dmm_atomic_t * a, int n)
-{
- return __sync_fetch_and_sub (&a->cnt, n);
-}
-
-inline static int
-dmm_atomic_and (dmm_atomic_t * a, int n)
-{
- return __sync_fetch_and_and (&a->cnt, n);
-}
-
-inline static int
-dmm_atomic_or (dmm_atomic_t * a, int n)
-{
- return __sync_fetch_and_or (&a->cnt, n);
-}
-
-inline static int
-dmm_atomic_xor (dmm_atomic_t * a, int n)
-{
- return __sync_fetch_and_xor (&a->cnt, n);
-}
-
-inline static int
-dmm_atomic_swap (dmm_atomic_t * a, int o, int n)
-{
- return __sync_val_compare_and_swap (&a->cnt, o, n);
-}
-
-inline static int
-dmm_atomic_add_return (dmm_atomic_t * a, int n)
-{
- return __sync_add_and_fetch (&a->cnt, n);
-}
-
-inline static int
-dmm_atomic_sub_return (dmm_atomic_t * a, int n)
-{
- return __sync_sub_and_fetch (&a->cnt, n);
-}
-
-inline static int
-dmm_atomic_and_return (dmm_atomic_t * a, int n)
-{
- return __sync_and_and_fetch (&a->cnt, n);
-}
-
-inline static int
-dmm_atomic_or_return (dmm_atomic_t * a, int n)
-{
- return __sync_or_and_fetch (&a->cnt, n);
-}
-
-inline static int
-dmm_atomic_xor_return (dmm_atomic_t * a, int n)
-{
- return __sync_xor_and_fetch (&a->cnt, n);
-}
-
-/* atomit 64bit operation */
-
-typedef struct
-{
- volatile long long int cnt;
-} dmm_atomic64_t;
-
-inline static long long int
-dmm_atomic64_get (dmm_atomic64_t * a)
-{
- return a->cnt;
-}
-
-inline static long long int
-dmm_atomic64_add (dmm_atomic64_t * a, int n)
-{
- return __sync_fetch_and_add (&a->cnt, n);
-}
-
-inline static long long int
-dmm_atomic64_sub (dmm_atomic64_t * a, int n)
-{
- return __sync_fetch_and_sub (&a->cnt, n);
-}
-
-inline static long long int
-dmm_atomic64_and (dmm_atomic64_t * a, int n)
-{
- return __sync_fetch_and_and (&a->cnt, n);
-}
-
-inline static long long int
-dmm_atomic64_or (dmm_atomic64_t * a, int n)
-{
- return __sync_fetch_and_or (&a->cnt, n);
-}
-
-inline static long long int
-dmm_atomic64_xor (dmm_atomic64_t * a, int n)
-{
- return __sync_fetch_and_xor (&a->cnt, n);
-}
-
-inline static long long int
-dmm_atomic64_swap (dmm_atomic_t * a, int o, int n)
-{
- return __sync_val_compare_and_swap (&a->cnt, o, n);
-}
-
-inline static long long int
-dmm_atomic64_add_return (dmm_atomic64_t * a, int n)
-{
- return __sync_add_and_fetch (&a->cnt, n);
-}
-
-inline static long long int
-dmm_atomic64_sub_return (dmm_atomic64_t * a, int n)
-{
- return __sync_sub_and_fetch (&a->cnt, n);
-}
-
-inline static long long int
-dmm_atomic64_and_return (dmm_atomic64_t * a, int n)
-{
- return __sync_and_and_fetch (&a->cnt, n);
-}
-
-inline static long long int
-dmm_atomic64_or_return (dmm_atomic64_t * a, int n)
-{
- return __sync_or_and_fetch (&a->cnt, n);
-}
-
-inline static long long int
-dmm_atomic64_xor_return (dmm_atomic64_t * a, int n)
-{
- return __sync_xor_and_fetch (&a->cnt, n);
-}
-
-#endif /* #ifndef _DMM_ATOMIC_H_ */
diff --git a/src/framework/common/include/generic/dmm_spinlock.h b/src/framework/common/include/generic/dmm_spinlock.h
deleted file mode 100644
index be183a6..0000000
--- a/src/framework/common/include/generic/dmm_spinlock.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-#ifndef _DMM_SPINLOCK_H_
-#define _DMM_SPINLOCK_H_
-
-#include "dmm_pause.h"
-
-typedef struct
-{
- volatile int lock;
-} dmm_spinlock_t;
-
-inline static void
-dmm_spin_init (dmm_spinlock_t * spinlock)
-{
- spinlock->lock = 0;
-}
-
-inline static void
-dmm_spin_lock (dmm_spinlock_t * spinlock)
-{
- while (0 != __sync_lock_test_and_set (&spinlock->lock, 1))
- {
- DMM_PAUSE_WHILE (spinlock->lock);
- }
-}
-
-inline static int
-dmm_spin_trylock (dmm_spinlock_t * spinlock)
-{
- return 0 == __sync_lock_test_and_set (&spinlock->lock, 1);
-}
-
-inline static void
-dmm_spin_unlock (dmm_spinlock_t * spinlock)
-{
- spinlock->lock = 0;
-}
-
-#endif /* #ifndef _DMM_SPINLOCK_H_ */
diff --git a/src/framework/common/include/sha256.h b/src/framework/common/include/sha256.h
deleted file mode 100644
index b1c7f3c..0000000
--- a/src/framework/common/include/sha256.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _SHA256_H_
-#define _SHA256_H_
-#include "types.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-/* Note that the following function prototypes are the same */
-/* for both the bit and byte oriented implementations. But */
-/* the length fields are in bytes or bits as is appropriate */
-/* for the version used. Bit sequences are arrays of bytes */
-/* in which bit sequence indexes increase from the most to */
-/* the least significant end of each byte */
-
-#define SHA256_DIGEST_SIZE 32 /* in bytes */
-#define SHA256_BLOCK_SIZE 64 /* in bytes */
-
-typedef struct
-{
- u32 count[2];
- u32 hash[8];
- u32 wbuf[16];
-} SHA256_CTX;
-
-/* SHA256 hash data in an array of bytes into hash buffer */
-/* and call the hash_compile function as required. */
-
-/*===========================================================================*\
- Function :Sha256_upd
- Description :
- Calls :
- Called by :
- Return :void -
- Parameters :
- SHA256_CTX ctx[1] -
- const unsigned char data[] -
- size_t len -
- Note :
-\*===========================================================================*/
-void Sha256_upd (SHA256_CTX ctx[1], const u8 data[], size_t len);
-
-/* SHA256 Final padding and digest calculation */
-
-/*===========================================================================*\
- Function :Sha256_set
- Description :
- Calls :
- Called by :
- Return :void -
- Parameters :
- SHA256_CTX ctx[1] -
- Note :
-\*===========================================================================*/
-void Sha256_set (SHA256_CTX ctx[1]);
-
-/*===========================================================================*\
- Function :Sha256_fin
- Description :
- Calls :
- Called by :
- Return :void -
- Parameters :
- SHA256_CTX ctx[1] -
- unsigned char hval[] -
- Note :
-\*===========================================================================*/
-void Sha256_fin (SHA256_CTX ctx[1], u8 hval[]);
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif /* _SHA256_H_ */
diff --git a/src/framework/common/include/types.h b/src/framework/common/include/types.h
deleted file mode 100644
index bd4d80b..0000000
--- a/src/framework/common/include/types.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef clib_types_h
-#define clib_types_h
-#include <stddef.h>
-
-/* Standard CLIB types. */
-
-/* Define signed and unsigned 8, 16, 32, and 64 bit types
- and machine signed/unsigned word for all architectures. */
-typedef char i8;
-typedef short i16;
-
-typedef unsigned char u8;
-typedef unsigned short u16;
-
-typedef int i32;
-typedef long long i64;
-
-typedef unsigned int u32;
-typedef unsigned long long u64;
-
-#ifndef bool
-#define bool int
-#endif
-
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#ifndef true
-#define true 1
-#endif
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-#ifndef false
-#define false 0
-#endif
-
-#ifndef NULL
-#define NULL ((void *)0)
-#endif
-
-#define PRIMARY_ADDR
-
-typedef struct _nsfw_res
-{
- u8 alloc_flag;
- u8 u8Reserve;
- u16 chk_count;
- u32 data;
-} nsfw_res;
-
-static inline void
-res_alloc (nsfw_res * res)
-{
- res->alloc_flag = TRUE;
- res->chk_count = 0;
- res->u8Reserve = 0;
-}
-
-static inline int
-res_free (nsfw_res * res)
-{
- if (TRUE != res->alloc_flag)
- {
- return -1;
- }
- res->chk_count = 0;
- res->alloc_flag = FALSE;
- return 0;
-}
-
-#define NSFW_THREAD __thread
-
-#endif /*clib_types_h */
diff --git a/src/framework/common/mem_mgr/include/nsfw_mem_desc.h b/src/framework/common/mem_mgr/include/nsfw_mem_desc.h
deleted file mode 100644
index 9a14c8d..0000000
--- a/src/framework/common/mem_mgr/include/nsfw_mem_desc.h
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _NSFW_MEM_DESC_H
-#define _NSFW_MEM_DESC_H
-#include <sys/types.h>
-#include <unistd.h>
-#include <string.h>
-#include "nsfw_mem_api.h"
-#include "nsfw_mgr_com_api.h"
-#include "nsfw_ring_data.h"
-
-#define NSFW_MEM_NOT_INIT (0)
-#define NSFW_MEM_INIT_ERR (1)
-#define NSFW_MEM_INIT_OK (2)
-
-#define NSFW_NAME_LENCHECK_RET(name, desc) \
- { \
- i32 inamelen = strlen(name); \
- if (inamelen >= NSFW_MEM_APPNAME_LENGTH) \
- { \
- NSCOMM_LOGERR("name length check fail] desc=%s, name len=%d, expected max=%d", \
- #desc, inamelen, NSFW_MEM_APPNAME_LENGTH); \
- return NSFW_MEM_ERR; \
- } \
- }
-
-#define NSFW_NAME_LENCHECK_RET_NULL(name, desc) \
- { \
- i32 inamelen = strlen(name); \
- if (inamelen >= NSFW_MEM_APPNAME_LENGTH) \
- { \
- NSCOMM_LOGERR("name length check fail] desc=%s, name len=%d, expected max=%d", \
- #desc, inamelen, NSFW_MEM_APPNAME_LENGTH); \
- return NULL; \
- } \
- }
-
-#define NSFW_MEM_PARA_CHECK_RET(handle, pdata, desc, num) {\
- if ((NULL == (handle)) || (NULL == (pdata)) || (num <= 0)\
- || (((struct nsfw_mem_ring*)(handle))->memtype >= NSFW_MEM_TYPEMAX)) \
- { \
- NSCOMM_LOGERR("input para error] desc=%s,mhandle=%p, pdata=%p, inum=%d", desc, (handle), (pdata), num); \
- return 0; \
- } \
- }
-
-#define NSFW_MEM_ENQ_PARA_CHECK_RET(handle, desc) {\
- if ((NULL == (handle)) \
- || (((struct nsfw_mem_ring*)(handle))->memtype >= NSFW_MEM_TYPEMAX)) \
- { \
- NSCOMM_LOGERR("input para error] desc=%s,mhandle=%p", desc, (handle)); \
- return 0; \
- } \
- }
-
-#define NSFW_MEM_NAME_CHECK_RET_ERR(pname, desc) {\
- if ((NULL == (pname)) || ((pname)->entype >= NSFW_MEM_TYPEMAX)) \
- { \
- NSCOMM_LOGERR("input para error] desc=%s, pname=%p, mtype=%d", desc, pname, (pname) ? (pname)->entype:-1); \
- return NSFW_MEM_ERR; \
- } \
- }
-
-#define NSFW_MEM_NAME_CHECK_RET_NULL(pname, desc) {\
- if ((NULL == (pname)) || ((pname)->entype >= NSFW_MEM_TYPEMAX)) \
- { \
- NSCOMM_LOGERR("input para error] desc=%s, pname=%p, mtype=%d", desc, pname, (pname) ? (pname)->entype:-1); \
- return NULL; \
- } \
- }
-
-#define NSFW_MEM_RING_CHECK_RET(pringinfo, pringhandle_array, iringnum) {\
- if ((NULL == pringinfo) || (NULL == pringhandle_array) || (pringinfo[0].stname.entype >= NSFW_MEM_TYPEMAX)) \
- { \
- NSCOMM_LOGERR("input para error] pringinfo=%p, iringnum=%d, pringhandle_array=%p, mtype=%d", \
- pringinfo, iringnum, pringhandle_array, pringinfo ? pringinfo[0].stname.entype : (-1)); \
- return NSFW_MEM_ERR; \
- } \
- }
-
-#define NSFW_MEM_RINGV_CHECK_RET(pmpinfo, inum, pringhandle_array, iarray_num) { \
- if ((NULL == pmpinfo) || (NULL == pringhandle_array) \
- || (inum != iarray_num) || (inum <= 0) || (pmpinfo[0].stname.entype >= NSFW_MEM_TYPEMAX)) \
- { \
- NSCOMM_LOGERR("input para error] pmpinfo=%p, inum=%d, pringhandle_array=%p, iarray_num=%d", \
- pmpinfo, inum, pringhandle_array, iarray_num, pmpinfo ? pmpinfo[0].stname.entype : (-1)); \
- return NSFW_MEM_ERR; \
- } \
- }
-
-#define NSFW_MEM_MBUF_CHECK_RET_ERR(mhandle, entype, desc) {\
- if ((NULL == mhandle) || (entype >= NSFW_MEM_TYPEMAX)) \
- { \
- NSCOMM_LOGERR("input para error] desc=%s, mhandle=%p, mtype=%d", desc, mhandle, entype); \
- return NSFW_MEM_ERR; \
- } \
- }
-
-#define NSFW_MEM_MBUF_CHECK_RET_NULL(mhandle, entype, desc) {\
- if ((NULL == mhandle) || (entype >= NSFW_MEM_TYPEMAX)) \
- { \
- NSCOMM_LOGERR("input para error] desc=%s, mhandle=%p, mtype=%d", desc, mhandle, entype); \
- return NULL; \
- } \
- }
-
-/*memory access inferface define*/
-typedef struct
-{
- i32 (*mem_ops_init) (nsfw_mem_para * para);
- void (*mem_ops_destroy) (void);
- mzone_handle (*mem_ops_zone_create) (nsfw_mem_zone * pinfo);
- i32 (*mem_ops_zone_createv) (nsfw_mem_zone * pmeminfo, i32 inum,
- mzone_handle * paddr_array, i32 iarray_num);
- mzone_handle (*mem_ops_zone_lookup) (nsfw_mem_name * pname);
- i32 (*mem_ops_mzone_release) (nsfw_mem_name * pname);
- mpool_handle (*mem_ops_mbfmp_create) (nsfw_mem_mbfpool * pbufinfo);
- i32 (*mem_ops_mbfmp_createv) (nsfw_mem_mbfpool * pmbfname, i32 inum,
- mpool_handle * phandle_array,
- i32 iarray_num);
- mbuf_handle (*mem_ops_mbf_alloc) (mpool_handle mhandle);
- i32 (*mem_ops_mbf_free) (mbuf_handle mhandle);
- mpool_handle (*mem_ops_mbfmp_lookup) (nsfw_mem_name * pmbfname);
- i32 (*mem_ops_mbfmp_release) (nsfw_mem_name * pname);
- mring_handle (*mem_ops_sp_create) (nsfw_mem_sppool * pmpinfo);
- i32 (*mem_ops_sp_createv) (nsfw_mem_sppool * pmpinfo, i32 inum,
- mring_handle * pringhandle_array,
- i32 iarray_num);
- i32 (*mem_ops_spring_create) (nsfw_mem_mring * prpoolinfo,
- mring_handle * pringhandle_array,
- i32 iringnum);
- i32 (*mem_ops_sp_release) (nsfw_mem_name * pname);
- mring_handle (*mem_ops_sp_lookup) (nsfw_mem_name * pname);
- mring_handle (*mem_ops_ring_create) (nsfw_mem_mring * pringinfo);
- mring_handle (*mem_ops_ring_lookup) (nsfw_mem_name * pname);
- i32 (*mem_ops_ring_release) (nsfw_mem_name * pname);
- ssize_t (*mem_ops_mem_statics) (void *handle, nsfw_mem_struct_type type);
- i32 (*mem_ops_mbuf_recycle) (mpool_handle handle);
- i32 (*mem_ops_sp_iterator) (mpool_handle handle, u32 start, u32 end,
- nsfw_mem_item_fun fun, void *argv);
- i32 (*mem_ops_mbuf_iterator) (mpool_handle handle, u32 start, u32 end,
- nsfw_mem_item_fun fun, void *argv);
-} nsfw_mem_ops;
-
-typedef struct
-{
- nsfw_mem_type entype;
- nsfw_mem_ops *stmemop;
-} nsfw_mem_attr;
-
-typedef struct
-{
- fw_poc_type enflag; /*app, nStackMain, Master */
-} nsfw_mem_localdata;
-
-extern nsfw_mem_attr g_nsfw_mem_ops[];
-extern i32 g_mem_type_num;
-#endif
diff --git a/src/framework/common/mem_mgr/include/nsfw_ring_data.h b/src/framework/common/mem_mgr/include/nsfw_ring_data.h
deleted file mode 100644
index e6007ab..0000000
--- a/src/framework/common/mem_mgr/include/nsfw_ring_data.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _NSFW_RING_DATA_H_
-#define _NSFW_RING_DATA_H_
-
-#include <stdint.h>
-#include "types.h"
-#include "common_mem_api.h"
-
-#define VALUE_LEN 40
-
-/*
-Ring Data has two part; Ver&Data
-val is a pointer offset base on rte_perf_ring::Addrbase, this struct support 1TB, it's enough now;
-future __int128 maybe used, this type can perfectly solve the version & address rang problem.
-*/
-union RingData_U
-{
- struct RingData_S
- {
- /*
- value of data, indeed it's a pointer offset base on rte_perf_ring::Addrbase;40bit is enough for user space addr
- ver must using 24bit, so val using 40bit; a CAS now just support 64bit; in future, we may using __int128,now __int128 not support well.
- */
- volatile unsigned long long val:VALUE_LEN;
- /*
- version of data, using 16b store version flg is more suitable for Address save, but using 16b version is too short, it's value range is [0-65535];
- between two cpu schedule time (TM-SPACE) of one process/thread, other processes/threads do N times queue oper. if N > 65535, still have a chance of ABA.
- if using a 24bit save version flg, if ABA happened, 16777216 times queue oper need done in one TM-SPACE, it's impossible for today cpu.
- */
- volatile unsigned long long ver:(64 - VALUE_LEN);
- } data_s;
- u64 data_l;
-};
-
-/*
- this high perf Ring rely on the init value of Ring Slot;
- Ring Must init using PerfRingInit, Pool Must init using PerfPoolInit
-
- the addrbase is base addr for all element; now we support 1024G offset;
- for nstack the Ring element is from hugepage, and the addr is in stack space.
-
- 1. not support a ring who's element space range bigger than 1024GB
- [if one element from heep, one from stack, range will bigger than 1024GB, we not support]
- 2. one more thing addr from mmap is in stack
- 3. rte_perf_ring must create by rte_perf_ring_create/rte_perf_pool_create
-*/
-struct nsfw_mem_ring
-{
- u8 memtype; //shared, no shared
- u8 ringflag; //scmp, scsp, mcsp,mcmp
- u16 reserv; //reserv data
- u32 size; //size of the Ring, must 2^n
- u32 eltsize; //for s-pool, it is the size of per buf, if is ring, eltsize is zero.
- u32 mask; //mask of the Ring, used mask mod Head/Tail to get real pos, must 2^n-1
- void *Addrbase; /*Cause the Addr we support just 40b(1024G), we using a basAddr+offset to get the real addr; ring[x].data_s.val just store offset;
- * not used when no shared mode
- */
- volatile u32_t prodhflag; //for nshmem fork recover
- volatile u32_t prodtflag; //for nshmem fork recover
- volatile u32_t conshflag; //for nshmem fork recover
- volatile u32_t constflag; //for nshmem fork recover
- nsfw_res res_chk;
-
- struct
- {
- volatile u32 head; //Head of the Ring, used to indicate pos where to pull a val
- volatile u32 tail; //for nshmem, shmem not used.
- } prod;
- struct
- {
- volatile u32 head; //for nshmem, shmem not used.
- volatile u32 tail; //Tail of the Ring, used to indicate pos where to push a val
- } cons;
- u32 uireserv[4]; //reserved for update
- union RingData_U ring[0]; //Value of Ring
-};
-
-#define PERFRING_ADDR_RANGE (0xFFFFFFFFFFL)
-
-#endif /*_NSFW_RING_DATA_H_*/
diff --git a/src/framework/common/mem_mgr/include/nsfw_ring_fun.h b/src/framework/common/mem_mgr/include/nsfw_ring_fun.h
deleted file mode 100644
index d74cc4b..0000000
--- a/src/framework/common/mem_mgr/include/nsfw_ring_fun.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _NSFW_RING_FUN_H_
-#define _NSFW_RING_FUN_H_
-
-#include <stdint.h>
-#include "common_pal_bitwide_adjust.h"
-#include "nsfw_mem_api.h"
-#include "nsfw_ring_data.h"
-
-/*
- for nstack I advise addrbase set to lowest of mmaped hugepage Addr.
- to simple:
- 1. ring element is from mmaped mem, set Addrbase to 0x7fffffffffff - 0xffffffffff is OK;
- 1. ring element is from heap, set Addrbase to NULL is ok;
-*/
-static inline void
-nsfw_mem_ring_init (struct nsfw_mem_ring *ring, unsigned int size,
- void *addrbase, unsigned char memtype, unsigned char flag)
-{
- unsigned int loop = 0;
-
- if (!ring)
- {
- return;
- }
-
- ring->prod.head = 0;
- ring->prod.tail = 0;
- ring->cons.head = 0;
- ring->cons.tail = 0;
- ring->size = size;
- ring->eltsize = 0;
- ring->mask = size - 1;
- ring->memtype = memtype;
- ring->ringflag = flag;
- ring->prodtflag = ring->prodhflag = get_sys_pid ();
- ring->conshflag = ring->constflag = get_sys_pid ();
- /*if shmem, addrbase already changed to primary memory address */
- ring->Addrbase = addrbase;
- ring->uireserv[0] = 0;
- ring->uireserv[1] = 0;
- ring->uireserv[2] = 0;
- ring->uireserv[3] = 0;
-
- /*init Ring */
- for (loop = 0; loop < size; loop++)
- {
- /*
- for a empty ring, version is the mapping head val - size
- so the empty ring's ver is loop-size;
- */
- ring->ring[loop].data_s.ver = (loop - size);
- ring->ring[loop].data_s.val = 0;
- }
-}
-
-/*
-another way to init Pool while no continuous space
-1. init a empty rte_perf_ring
-2. add element to PerRing.
-*/
-static inline void
-nsfw_mem_pool_head_init (struct nsfw_mem_ring *ring, unsigned int size,
- unsigned int eltsize, void *addrbase,
- nsfw_mem_type memtype, nsfw_mpool_type flag)
-{
- ring->prod.head = size;
- ring->prod.tail = size;
- ring->cons.head = 0;
- ring->cons.tail = 0;
- ring->size = size;
- ring->eltsize = eltsize;
- ring->mask = size - 1;
- ring->memtype = memtype;
- ring->ringflag = flag;
- ring->prodtflag = ring->prodhflag = get_sys_pid ();
- ring->conshflag = ring->constflag = get_sys_pid ();
- /*if shmem, addrbase already changed to primary memory address */
- ring->Addrbase = addrbase;
- ring->uireserv[0] = 0;
- ring->uireserv[1] = 0;
- ring->uireserv[2] = 0;
- ring->uireserv[3] = 0;
- return;
-}
-
-#define NSFW_RING_FLAG_CHECK_RET(handle, desc) {\
- if (((struct nsfw_mem_ring*)mhandle)->ringflag >= NSFW_MPOOL_TYPEMAX) \
- { \
- NSCOMM_LOGERR("invalid ring] desc=%s, ringflag=%d", desc, ((struct nsfw_mem_ring*)mhandle)->ringflag); \
- return 0; \
- } \
- }
-
-#endif /*_NSFW_RING_FUN_H_*/
diff --git a/src/framework/common/mem_mgr/nsfw_mem_api.c b/src/framework/common/mem_mgr/nsfw_mem_api.c
deleted file mode 100644
index c89ada1..0000000
--- a/src/framework/common/mem_mgr/nsfw_mem_api.c
+++ /dev/null
@@ -1,879 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include <sys/types.h>
-#include <unistd.h>
-#include "nsfw_mem_desc.h"
-#include "nstack_securec.h"
-
-#ifdef SYS_MEM_RES_STAT
-#include "common_mem_ring.h"
-#include "common_mem_mempool.h"
-#endif
-
-#define MEM_OP_CALL_OK_RET(mtype, fun, para) { \
- if (g_nsfw_mem_ops[mtype].stmemop->fun) \
- { \
- return g_nsfw_mem_ops[mtype].stmemop->fun para; \
- } \
- }
-
-/*****************************************************************************
-* Prototype : nsfw_mem_init
-* Description : memory mgr module init
-* Input : point to nstack_fwmem_para
-* Output : None
-* Return Value : i32
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-i32
-nsfw_mem_init (void *para)
-{
- nsfw_mem_para *ptempara = NULL;
- i32 iret = NSFW_MEM_OK;
- i32 icount = 0;
- i32 iindex = 0;
-
- if (NULL == para)
- {
- NSCOMM_LOGERR ("ns mem init input error");
- return NSFW_MEM_ERR;
- }
-
- ptempara = (nsfw_mem_para *) para;
-
- if (ptempara->enflag >= NSFW_PROC_MAX)
- {
- NSCOMM_LOGERR ("ns mem init input enflag invalid] enflag=%d",
- ptempara->enflag);
- return NSFW_MEM_ERR;
- }
-
- NSCOMM_LOGINF ("ns mem init begin] enflag=%d, iargsnum=%d",
- ptempara->enflag, ptempara->iargsnum);
-
- for (iindex = 0; iindex < ptempara->iargsnum; iindex++)
- {
- NSCOMM_LOGINF ("%s", ptempara->pargs[iindex]);
- }
-
- for (icount = 0; icount < g_mem_type_num; icount++)
- {
- if ((NULL != g_nsfw_mem_ops[icount].stmemop)
- && (NULL != g_nsfw_mem_ops[icount].stmemop->mem_ops_init))
- {
- iret = g_nsfw_mem_ops[icount].stmemop->mem_ops_init (ptempara);
-
- if (NSFW_MEM_OK != iret)
- {
- NSCOMM_LOGERR ("mem init failed]index=%d, memtype=%d", icount,
- g_nsfw_mem_ops[icount].entype);
- break;
- }
- }
- }
-
- /*if some module init fail, destory the modules that success */
- if (icount < g_mem_type_num)
- {
- for (iindex = 0; iindex < icount; iindex++)
- {
- if (g_nsfw_mem_ops[icount].stmemop->mem_ops_destroy)
- {
- g_nsfw_mem_ops[icount].stmemop->mem_ops_destroy ();
- }
- }
-
- return NSFW_MEM_ERR;
- }
-
- NSCOMM_LOGINF ("ns mem init end");
- return NSFW_MEM_OK;
-}
-
-/*****************************************************************************
-* Prototype : nsfw_mem_zone_create
-* Description : create a block memory with name
-* nsfw_mem_zone::stname
-* nsfw_mem_zone::isize
-* note : 1. the length of name must be less than NSFW_MEM_APPNAME_LENGTH.
-* Input : nsfw_mem_zone* pinfo
-* Output : None
-* Return Value : mzone_handle
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-mzone_handle
-nsfw_mem_zone_create (nsfw_mem_zone * pinfo)
-{
-
- if ((NULL == pinfo) || (pinfo->stname.entype >= NSFW_MEM_TYPEMAX))
- {
- NSCOMM_LOGERR ("zone create input para error] pinfo=%p, mtype=%d",
- pinfo, pinfo ? pinfo->stname.entype : (-1));
- return NULL;
- }
-
- MEM_OP_CALL_OK_RET (pinfo->stname.entype, mem_ops_zone_create, (pinfo));
- NSCOMM_LOGINF ("mem create fail] memtype=%d, name=%s, size=%zu",
- pinfo->stname.entype, pinfo->stname.aname, pinfo->length);
- return NULL;
-}
-
-/*****************************************************************************
-* Prototype : nsfw_mem_zone_createv
-* Description : create some memory blocks
-* note : 1. the length of name must be less than NSFW_MEM_APPNAME_LENGTH.
-* Input : nsfw_mem_zone* pmeminfo
-* i32 inum
-* mzone_handle* paddr_array
-* i32 iarray_num
-* Output : None
-* Return Value : i32
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-i32
-nsfw_mem_zone_createv (nsfw_mem_zone * pmeminfo, i32 inum,
- mzone_handle * paddr_array, i32 iarray_num)
-{
- if ((NULL == pmeminfo) || (NULL == paddr_array)
- || (inum != iarray_num) || (inum <= 0)
- || (pmeminfo[0].stname.entype >= NSFW_MEM_TYPEMAX))
- {
- NSCOMM_LOGERR
- ("input para error] pmeminfo=%p, inum=%d, paddr_array=%p, iarray_num=%d, mtype=%d",
- pmeminfo, inum, paddr_array, iarray_num,
- pmeminfo ? pmeminfo[0].stname.entype : (-1));
- return NSFW_MEM_ERR;
- }
-
- MEM_OP_CALL_OK_RET (pmeminfo[0].stname.entype, mem_ops_zone_createv,
- (pmeminfo, inum, paddr_array, iarray_num));
- NSCOMM_LOGINF ("mem create fail] memtype=%d", pmeminfo[0].stname.entype);
- return NSFW_MEM_ERR;
-}
-
-/*****************************************************************************
-* Prototype : nsfw_mem_zone_lookup
-* Description : look up a memory
-* 1. the length of name must be less than NSFW_MEM_APPNAME_LENGTH.
-* 2. if the memory is shared, pname->enowner indicate that who create this memory.
-* note : 1. when calling any shared memory create inferface, the name of memory end with _0 created by nStackMain,
-* end with none created by nStackMaster, and end with _<pid> created by other.
-* 2. pname->enowner is available only when call look up shared memory.
-* 3. if the roles of process is NSFW_PROC_MASTER but the memory was created by others, or pname->enowner is NSFW_PROC_NULL,
-* the name must be full name.
-* for examles if the memory was created by nStackMain and pname->enowner is NSFW_PROC_NULL,
-* must add '_0' at the end of name, if the memory was created by app and the role of process is NSFW_PROC_MASTER, must add
-* _(pid) at the end of name, nstack_123.
-* Input : nsfw_mem_name* pname
-* Output : None
-* Return Value : mzone_handle
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-mzone_handle
-nsfw_mem_zone_lookup (nsfw_mem_name * pname)
-{
- NSFW_MEM_NAME_CHECK_RET_NULL (pname, "mem zone look up");
- MEM_OP_CALL_OK_RET (pname->entype, mem_ops_zone_lookup, (pname));
- NSCOMM_LOGERR ("mem lookup fail] memtype=%d, name=%s ", pname->entype,
- pname->aname);
- return NULL;
-}
-
-/*****************************************************************************
-* Prototype : nsfw_mem_zone_release
-* Description : release a memory
-* Input : nsfw_mem_name* pname
-* Output : None
-* Return Value : i32
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-i32
-nsfw_mem_zone_release (nsfw_mem_name * pname)
-{
- NSFW_MEM_NAME_CHECK_RET_ERR (pname, "mem zone release");
- MEM_OP_CALL_OK_RET (pname->entype, mem_ops_mzone_release, (pname));
- NSCOMM_LOGERR ("mem release fail] memtype=%d, name=%s", pname->entype,
- pname->aname);
- return NSFW_MEM_ERR;
-
-}
-
-/*****************************************************************************
-* Prototype : nsfw_mem_mbfmp_create
-* Description : create a mbuf pool
-* Input : nsfw_mem_mbfpool* pbufinfo
-* Output : None
-* Return Value : mpool_handle
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-mpool_handle
-nsfw_mem_mbfmp_create (nsfw_mem_mbfpool * pbufinfo)
-{
- if ((NULL == pbufinfo) || (pbufinfo->stname.entype >= NSFW_MEM_TYPEMAX))
- {
- NSCOMM_LOGERR ("input para error] pbufinfo=%p, mtype=%d", pbufinfo,
- pbufinfo ? pbufinfo->stname.entype : (-1));
- return NULL;
- }
-
- MEM_OP_CALL_OK_RET (pbufinfo->stname.entype, mem_ops_mbfmp_create,
- (pbufinfo));
- NSCOMM_LOGERR ("mbufmp create fail] memtype=%d, name=%s ",
- pbufinfo->stname.entype, pbufinfo->stname.aname);
- return NULL;
-}
-
-/*****************************************************************************
-* Prototype : nsfw_mem_mbfmp_createv
-* Description : create some mbuf pools
-* 1. the name of length must be less than NSFW_MEM_APPNAME_LENGTH.
-* Input : nsfw_mem_mbfpool* pmbfname
-* i32 inum
-* mpool_handle* phandle_array
-* i32 iarray_num
-* Output : None
-* Return Value : i32
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-i32
-nsfw_mem_mbfmp_createv (nsfw_mem_mbfpool * pmbfname, i32 inum,
- mpool_handle * phandle_array, i32 iarray_num)
-{
- if ((NULL == pmbfname) || (NULL == phandle_array)
- || (inum != iarray_num) || (inum <= 0)
- || (pmbfname[0].stname.entype >= NSFW_MEM_TYPEMAX))
- {
- NSCOMM_LOGERR
- ("input para error] pmbfname=%p, inum=%d, phandle_array=%p, iarray_num=%d",
- pmbfname, inum, phandle_array, iarray_num,
- pmbfname ? pmbfname[0].stname.entype : (-1));
- return NSFW_MEM_ERR;
- }
-
- MEM_OP_CALL_OK_RET (pmbfname[0].stname.entype, mem_ops_mbfmp_createv,
- (pmbfname, inum, phandle_array, iarray_num));
- NSCOMM_LOGERR ("mbufmp createv fail] memtype=%d",
- pmbfname[0].stname.entype);
- return NSFW_MEM_ERR;
-}
-
-/*****************************************************************************
-* Prototype : nsfw_mem_mbf_alloc
-* Description : alloc a mbuf from mbuf pool
-* Input : mpool_handle mhandle
-* nsfw_mem_type entype
-* Output : None
-* Return Value : mbuf_handle
-* Calls :
-* Called By :
-*****************************************************************************/
-mbuf_handle
-nsfw_mem_mbf_alloc (mpool_handle mhandle, nsfw_mem_type entype)
-{
- NSFW_MEM_MBUF_CHECK_RET_NULL (mhandle, entype, "mbf alloc");
- MEM_OP_CALL_OK_RET (entype, mem_ops_mbf_alloc, (mhandle));
- NSCOMM_LOGERR ("mbf alloc fail] handle=%p, type=%d", mhandle, entype);
- return NULL;
-}
-
-/*****************************************************************************
-* Prototype : nsfw_mem_mbf_free
-* Description : put a mbuf backintp mbuf pool
-* Input : mbuf_handle mhandle
-* nsfw_mem_type entype
-* Output : None
-* Return Value : i32
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-i32
-nsfw_mem_mbf_free (mbuf_handle mhandle, nsfw_mem_type entype)
-{
- NSFW_MEM_MBUF_CHECK_RET_ERR (mhandle, entype, "mbuf free");
- MEM_OP_CALL_OK_RET (entype, mem_ops_mbf_free, (mhandle));
- NSCOMM_LOGERR ("mbf free fail] handle=%p, type=%d", mhandle, entype);
- return NSFW_MEM_ERR;
-
-}
-
-/*****************************************************************************
-* Prototype : nsfw_mem_mbfmp_lookup
-* Description : look up mbuf mpool
-* 1. the length of name must be less than NSFW_MEM_APPNAME_LENGTH.
-* 2. if the memory is shared, pname->enowner indicate that who create this memory.
-* note : 1. when calling any shared memory create inferface, the name of memory end with _0 created by nStackMain,
-* end with none created by nStackMaster, and end with _<pid> created by other.
-* 2. pname->enowner is available only when call look up shared memory.
-* 3. if the roles of process is NSFW_PROC_MASTER but the memory was created by others, or pname->enowner is NSFW_PROC_NULL,
-* the name must be full name.
-* for examles if the memory was created by nStackMain and pname->enowner is NSFW_PROC_NULL,
-* must add '_0' at the end of name, if the memory was created by app and the role of process is NSFW_PROC_MASTER, must add
-* _(pid) at the end of name, nstack_123.
-* Input : nsfw_mem_name* pmbfname
-* Output : None
-* Return Value : mpool_handle
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-mpool_handle
-nsfw_mem_mbfmp_lookup (nsfw_mem_name * pmbfname)
-{
- NSFW_MEM_NAME_CHECK_RET_NULL (pmbfname, "mbuf pool look up");
- MEM_OP_CALL_OK_RET (pmbfname->entype, mem_ops_mbfmp_lookup, (pmbfname));
- NSCOMM_LOGERR ("mbufmp lookup fail] memtype=%d, name=%s ", pmbfname->entype,
- pmbfname->aname);
- return NULL;
-}
-
-/*****************************************************************************
-* Prototype : nsfw_mem_mbfmp_release
-* Description : release mbuf pool
-* note : 1. the length of name must be less than NSFW_MEM_APPNAME_LENGTH.
-* Input : nsfw_mem_name* pname
-* Output : None
-* Return Value : i32
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-i32
-nsfw_mem_mbfmp_release (nsfw_mem_name * pname)
-{
- NSFW_MEM_NAME_CHECK_RET_ERR (pname, "mbuf mp release");
- MEM_OP_CALL_OK_RET (pname->entype, mem_ops_mbfmp_release, (pname));
- NSCOMM_LOGERR ("mbfmp release fail] memtype=%d, name=%s", pname->entype,
- pname->aname);
- return NSFW_MEM_ERR;
-}
-
-/*****************************************************************************
-* Prototype : nsfw_mem_sp_create
-* Description : create a simple pool
-* note : 1. the length of name must be less than NSFW_MEM_APPNAME_LENGTH.
-* Input : nsfw_mem_sppool* pmpinfo
-* Output : None
-* Return Value : mring_handle
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-mring_handle
-nsfw_mem_sp_create (nsfw_mem_sppool * pmpinfo)
-{
- if ((NULL == pmpinfo) || (pmpinfo->stname.entype >= NSFW_MEM_TYPEMAX))
- {
- NSCOMM_LOGERR ("input para error] pmpinfo=%p, mtype=%d", pmpinfo,
- pmpinfo ? pmpinfo->stname.entype : (-1));
- return NULL;
- }
-
- MEM_OP_CALL_OK_RET (pmpinfo->stname.entype, mem_ops_sp_create, (pmpinfo));
- NSCOMM_LOGERR ("sp create fail] memtype=%d, name=%s ",
- pmpinfo->stname.entype, pmpinfo->stname.aname);
- return NULL;
-
-}
-
-/*****************************************************************************
-* Prototype : nsfw_mem_sp_createv
-* Description : create some simple pools one time
-* note : 1. the length of name must be less than NSFW_MEM_APPNAME_LENGTH.
-* Input : nsfw_mem_sppool* pmpinfo
-* i32 inum
-* mring_handle* pringhandle_array
-* i32 iarray_num
-* Output : None
-* Return Value : i32
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-i32
-nsfw_mem_sp_createv (nsfw_mem_sppool * pmpinfo, i32 inum,
- mring_handle * pringhandle_array, i32 iarray_num)
-{
- NSFW_MEM_RINGV_CHECK_RET (pmpinfo, inum, pringhandle_array, iarray_num);
- MEM_OP_CALL_OK_RET (pmpinfo[0].stname.entype, mem_ops_sp_createv,
- (pmpinfo, inum, pringhandle_array, iarray_num));
- NSCOMM_LOGERR ("sp createv fail] memtype=%d", pmpinfo[0].stname.entype);
- return NSFW_MEM_ERR;
-
-}
-
-/*****************************************************************************
-* Prototype : nsfw_mem_sp_ring_create
-* Description : create a simple pool with many rings
-* note : 1. the length of name must be less than NSFW_MEM_APPNAME_LENGTH.
-* Input : nsfw_mem_mring* pringinfo
-* mring_handle* pringhandle_array
-* i32 iringnum
-* Output : None
-* Return Value : i32
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-i32
-nsfw_mem_sp_ring_create (nsfw_mem_mring * pringinfo,
- mring_handle * pringhandle_array, i32 iringnum)
-{
- NSFW_MEM_RING_CHECK_RET (pringinfo, pringhandle_array, iringnum);
- MEM_OP_CALL_OK_RET (pringinfo[0].stname.entype, mem_ops_spring_create,
- (pringinfo, pringhandle_array, iringnum));
- NSCOMM_LOGERR ("mppool spring creat fail] memtype=%d",
- pringinfo[0].stname.entype);
- return NSFW_MEM_ERR;
-
-}
-
-/*****************************************************************************
-* Prototype : nsfw_mem_sp_release
-* Description : release a simple mempool
-* note : 1. the length of name must be less than NSFW_MEM_APPNAME_LENGTH.
-* Input : nsfw_mem_name* pname
-* Output : None
-* Return Value : i32
-* Calls :
-* Called By :
-*****************************************************************************/
-i32
-nsfw_mem_sp_release (nsfw_mem_name * pname)
-{
- NSFW_MEM_NAME_CHECK_RET_ERR (pname, "sp release");
- MEM_OP_CALL_OK_RET (pname->entype, mem_ops_sp_release, (pname));
- NSCOMM_LOGERR ("sp release fail] memtype=%d, name=%s ", pname->entype,
- pname->aname);
- return NSFW_MEM_ERR;
-}
-
-/*****************************************************************************
-* Prototype : nsfw_mem_sp_lookup
-* Description : look up a simpile ring
-* 1. the length of name must be less than NSFW_MEM_APPNAME_LENGTH.
-* 2. if the memory is shared, pname->enowner indicate that who create this memory.
-* note : 1. when calling any shared memory create inferface, the name of memory end with _0 created by nStackMain,
-* end with none created by nStackMaster, and end with _<pid> created by other.
-* 2. pname->enowner is available only when call look up shared memory.
-* 3. if the roles of process is NSFW_PROC_MASTER but the memory was created by others, or pname->enowner is NSFW_PROC_NULL,
-* the name must be full name.
-* for examles if the memory was created by nStackMain and pname->enowner is NSFW_PROC_NULL,
-* must add '_0' at the end of name, if the memory was created by app and the role of process is NSFW_PROC_MASTER, must add
-* _(pid) at the end of name, nstack_123.
-* Input : nsfw_mem_name* pname
-* Output : None
-* Return Value : mring_handle
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-mring_handle
-nsfw_mem_sp_lookup (nsfw_mem_name * pname)
-{
- NSFW_MEM_NAME_CHECK_RET_NULL (pname, "sp look up");
- MEM_OP_CALL_OK_RET (pname->entype, mem_ops_sp_lookup, (pname));
- NSCOMM_LOGERR ("sp lookup fail] memtype=%d, name=%s", pname->entype,
- pname->aname);
- return NULL;
-
-}
-
-/*****************************************************************************
-* Prototype : nsfw_mem_ring_create
-* Description : create a ring
-* note : 1. the length of name must be less than NSFW_MEM_APPNAME_LENGTH.
-* 2. shared memory ring (NSFW_SHMEM) just can put a pointer into the queue, the queue also point to a shared block memory.
-* no shared memory ring(NSFW_NSHMEM) is other wise.
-* Input : nsfw_mem_mring* pringinfo
-* Output : None
-* Return Value : mring_handle
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-mring_handle
-nsfw_mem_ring_create (nsfw_mem_mring * pringinfo)
-{
- if ((NULL == pringinfo) || (pringinfo->stname.entype >= NSFW_MEM_TYPEMAX))
- {
- NSCOMM_LOGERR ("input para error] pmpinfo=%p, mtype=%d", pringinfo,
- pringinfo ? pringinfo->stname.entype : (-1));
- return NULL;
- }
-
- MEM_OP_CALL_OK_RET (pringinfo->stname.entype, mem_ops_ring_create,
- (pringinfo));
- NSCOMM_LOGERR ("ring create fail] memtype=%d, name=%s ",
- pringinfo->stname.entype, pringinfo->stname.aname);
- return NULL;
-
-}
-
-/*****************************************************************************
-* Prototype : nsfw_mem_ring_lookup
-* Description : look up a ring by name
-* 1. the length of name must be less than NSFW_MEM_APPNAME_LENGTH.
-* 2. if the memory is shared, pname->enowner indicate that who create this memory.
-* note:
-* 1. when calling any shared memory create inferface, the name of memory end with _0 created by nStackMain,
-* end with none created by nStackMaster, and end with _<pid> created by other.
-* 2. pname->enowner is available only when call look up shared memory.
-* 3. if the roles of process is NSFW_PROC_MASTER but the memory was created by others, or pname->enowner is NSFW_PROC_NULL,
-* the name must be full name.
-* for examles if the memory was created by nStackMain and pname->enowner is NSFW_PROC_NULL,
-* must add '_0' at the end of name, if the memory was created by app and the role of process is NSFW_PROC_MASTER, must add
-* _(pid) at the end of name, nstack_123.
-* Input : nsfw_mem_name* pname
-* Output : None
-* Return Value : mring_handle
-* Calls :
-* Called By :
-*
-*
-*****************************************************************************/
-mring_handle
-nsfw_mem_ring_lookup (nsfw_mem_name * pname)
-{
- NSFW_MEM_NAME_CHECK_RET_NULL (pname, "ring lookup");
- MEM_OP_CALL_OK_RET (pname->entype, mem_ops_ring_lookup, (pname));
- NSCOMM_LOGERR ("ring lookup fail] memtype=%d, name=%s", pname->entype,
- pname->aname);
- return NULL;
-}
-
-/*****************************************************************************
-* Prototype : nsfw_mem_ring_reset
-* Description : reset the number of producer and consumer, also, the
-* state of ring reset to empty
-* notes : must be called before doing any operations base on the ring
-* Input : mring_handle mhandle
-* nsfw_mpool_type entype
-* Output : None
-* Return Value : void
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-void
-nsfw_mem_ring_reset (mring_handle mhandle, nsfw_mpool_type entype)
-{
- u32 loop = 0;
- struct nsfw_mem_ring *ring = (struct nsfw_mem_ring *) mhandle;
-
- if (!ring)
- {
- return;
- }
-
- ring->prod.head = 0;
- ring->cons.tail = 0;
- ring->ringflag = (u8) entype;
-
- /*init Ring */
- for (loop = 0; loop < ring->size; loop++)
- {
- /*
- for a empty ring, version is the mapping head val - size
- so the empty ring's ver is loop-size;
- */
- ring->ring[loop].data_s.ver = (loop - ring->size);
- ring->ring[loop].data_s.val = 0;
- }
-
- return;
-}
-
-/*****************************************************************************
-* Prototype : nsfw_mem_ring_free_count
-* Description : get the free number of ring
-* Input : mring_handle mhandle
-* Output : None
-* Return Value : u32
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-u32
-nsfw_mem_ring_free_count (mring_handle mhandle)
-{
- struct nsfw_mem_ring *temp = NULL;
- u32 thead = 0;
- u32 ttail = 0;
- if (NULL == mhandle)
- {
- NSCOMM_LOGERR ("input para error] mhandle=%p", mhandle);
- return 0;
- }
-
- temp = (struct nsfw_mem_ring *) mhandle;
- thead = temp->prod.head;
- ttail = temp->cons.tail;
- return ttail + temp->size - thead;
-}
-
-/*****************************************************************************
-* Prototype : nsfw_mem_ring_using_count
-* Description : get the in using number of ring
-* Input : mring_handle mhandle
-* Output : None
-* Return Value : u32
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-u32
-nsfw_mem_ring_using_count (mring_handle mhandle)
-{
- struct nsfw_mem_ring *temp = NULL;
- u32 thead = 0;
- u32 ttail = 0;
- if (NULL == mhandle)
- {
- NSCOMM_LOGERR ("input para error] mhandle=%p", mhandle);
- return 0;
- }
-
- temp = (struct nsfw_mem_ring *) mhandle;
- thead = temp->prod.head;
- ttail = temp->cons.tail;
- return thead - ttail;
-}
-
-/*****************************************************************************
-* Prototype : nsfw_mem_ring_size
-* Description : get size of ring
-* Input : mring_handle mhandle
-* Output : None
-* Return Value : u32
-* Calls :
-* Called By :
-*****************************************************************************/
-u32
-nsfw_mem_ring_size (mring_handle mhandle)
-{
- struct nsfw_mem_ring *temp = NULL;
-
- if (NULL == mhandle)
- {
- NSCOMM_LOGERR ("input para error] mhandle=%p", mhandle);
- return 0;
- }
-
- temp = (struct nsfw_mem_ring *) mhandle;
-
- return temp->size;
-}
-
-#ifdef SYS_MEM_RES_STAT
-/*****************************************************************************
-* Prototype : nsfw_mem_mbfpool_free_count
-* Description : get the free mbuf count of a mbuf pool
-* Input : mpool_handle mhandle
-* Output : None
-* Return Value : u32
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-u32
-nsfw_mem_mbfpool_free_count (mpool_handle mhandle)
-{
- if (!mhandle)
- {
- NSCOMM_LOGERR ("input para error] mhandle=%p", mhandle);
- return 0;
- }
- struct common_mem_mempool *mp = (struct common_mem_mempool *) mhandle;
- struct common_mem_ring *mp_ring =
- (struct common_mem_ring *) (mp->ring_align);
- if (!mp_ring)
- {
- NSCOMM_LOGERR ("ring is null");
- return 0;
- }
- u32 p_head = mp_ring->prod.head;
- u32 c_tail = mp_ring->cons.tail;
-
- return p_head - c_tail;
-}
-#endif /* SYS_MEM_RES_STAT */
-
-/*****************************************************************************
-* Prototype : nsfw_mem_ring_release
-* Description : release a ring memory
-* notes : the length of name must be less than NSFW_MEM_APPNAME_LENGTH
-* Input : nsfw_mem_name* pname
-* Output : None
-* Return Value : i32
-* Calls :
-* Called By :
-*****************************************************************************/
-i32
-nsfw_mem_ring_release (nsfw_mem_name * pname)
-{
- NSFW_MEM_NAME_CHECK_RET_ERR (pname, "ring release");
- MEM_OP_CALL_OK_RET (pname->entype, mem_ops_ring_release, (pname));
- NSCOMM_LOGERR ("ring release fail] name=%s, type=%d", pname->aname,
- pname->entype);
- return NSFW_MEM_ERR;
-
-}
-
-/*****************************************************************************
-* Prototype : nsfw_mem_get_len
-* Description : statics mbufpool, sppool, ring mem size.
-* return: <=0, err happen, >0 mem size
-* NSFW_MEM_MZONE: not surport because you already know the length when create
-* Input : void * handle
-* nsfw_mem_struct_type type
-* Output : None
-* Return Value : ssize_t
-* Calls :
-* Called By :
-*****************************************************************************/
-ssize_t
-nsfw_mem_get_len (void *handle, nsfw_mem_struct_type type)
-{
- if (NULL == handle)
- {
- NSCOMM_LOGERR ("input para error] handle=%p", handle);
- return -1;
- }
- if ((NSFW_MEM_SPOOL == type) || (NSFW_MEM_RING == type))
- {
- struct nsfw_mem_ring *ring = (struct nsfw_mem_ring *) handle;
- if (ring->memtype >= NSFW_MEM_TYPEMAX)
- {
- NSCOMM_LOGERR ("invalid ring] ring type=%u ,handle=%p",
- ring->memtype, handle);
- return -1;
- }
- MEM_OP_CALL_OK_RET (ring->memtype, mem_ops_mem_statics, (handle, type));
- }
- else
- {
- MEM_OP_CALL_OK_RET (NSFW_SHMEM, mem_ops_mem_statics, (handle, type));
- }
- return -1;
-}
-
-/*****************************************************************************
-* Prototype : nsfw_mem_mbuf_pool_recycle
-* Description : recycle mbuf
-* Input : mpool_handle handle
-* Output : None
-* Return Value : i32
-* Calls :
-* Called By :
-*****************************************************************************/
-i32
-nsfw_mem_mbuf_pool_recycle (mpool_handle handle)
-{
- MEM_OP_CALL_OK_RET (NSFW_SHMEM, mem_ops_mbuf_recycle, (handle));
- return -1;
-}
-
-/*****************************************************************************
-* Prototype : nsfw_mem_sp_iterator
-* Description : spool iterator
-* Input : mpool_handle handle
-* u32 start
-* u32 end
-* nsfw_mem_item_fun fun
-* void *argv
-* Output : None
-* Return Value : i32
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-i32
-nsfw_mem_sp_iterator (mpool_handle handle, u32 start, u32 end,
- nsfw_mem_item_fun fun, void *argv)
-{
- MEM_OP_CALL_OK_RET (NSFW_SHMEM, mem_ops_sp_iterator,
- (handle, start, end, fun, argv));
- return -1;
-}
-
-/*****************************************************************************
-* Prototype : nsfw_mem_mbuf_iterator
-* Description : mbuf iterator
-* Input : mpool_handle handle
-* u32 start
-* u32 end
-* nsfw_mem_item_fun fun
-* void *argv
-* Output : None
-* Return Value : i32
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-i32
-nsfw_mem_mbuf_iterator (mpool_handle handle, u32 start, u32 end,
- nsfw_mem_item_fun fun, void *argv)
-{
- MEM_OP_CALL_OK_RET (NSFW_SHMEM, mem_ops_mbuf_iterator,
- (handle, start, end, fun, argv));
- return -1;
-}
-
-/*****************************************************************************
-* Prototype : nsfw_mem_dfx_ring_print
-* Description : print ring info
-* Input : mring_handle mhandle
-* Output : None
-* Return Value : if no err happen, return the length of string print, 0 or -1 maybe err happen
-* Calls :
-* Called By :
-*****************************************************************************/
-i32
-nsfw_mem_dfx_ring_print (mring_handle mhandle, char *pbuf, int length)
-{
- struct nsfw_mem_ring *temp = (struct nsfw_mem_ring *) mhandle;
- u32 head = 0;
- u32 tail = 0;
- int ret = 0;
- if ((!temp) || (!pbuf) || (length <= 0))
- {
- return 0;
- }
- head = temp->prod.head;
- tail = temp->cons.tail;
- ret =
- SPRINTF_S (pbuf, length,
- "[.Head=%u,\n .Tail=%u,\n .(|Tail-Head|)=%u,\n .size=%u,\n .mask=%u]\n",
- head, tail, (tail >= head) ? (tail - head) : (head - tail),
- temp->size, temp->mask);
- return ret;
-}
diff --git a/src/framework/common/mem_mgr/nsfw_mem_construct.c b/src/framework/common/mem_mgr/nsfw_mem_construct.c
deleted file mode 100644
index ed6fe27..0000000
--- a/src/framework/common/mem_mgr/nsfw_mem_construct.c
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "nsfw_init.h"
-#include "nsfw_mem_api.h"
-
-NSFW_MODULE_NAME (NSFW_MEM_MGR_MODULE)
-NSFW_MODULE_PRIORITY (10) NSFW_MODULE_INIT (nsfw_mem_init)
diff --git a/src/framework/common/mem_mgr/nsfw_mem_desc.c b/src/framework/common/mem_mgr/nsfw_mem_desc.c
deleted file mode 100644
index d0fbfd3..0000000
--- a/src/framework/common/mem_mgr/nsfw_mem_desc.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include <sys/types.h>
-#include <unistd.h>
-#include "nsfw_mem_desc.h"
-#include "nsfw_shmem_mdesc.h"
-#include "nsfw_nshmem_mdesc.h"
-#include "nsfw_shmem_ring.h"
-#include "nsfw_nshmem_ring.h"
-
-/* *INDENT-OFF* */
-/*the order you add must be NSFW_SHMEM, NSFW_NSHMEM*/
-nsfw_mem_attr g_nsfw_mem_ops[] =
-{
- {NSFW_SHMEM, &g_shmem_ops},
- {NSFW_NSHMEM, &g_nshmem_ops},
-};
-
-i32 g_mem_type_num = sizeof(g_nsfw_mem_ops) / sizeof(nsfw_mem_attr);
-
-
-nsfw_ring_ops g_ring_ops_arry[NSFW_MEM_TYPEMAX][NSFW_MPOOL_TYPEMAX] = {
- {
- {
- (nsfw_mem_ring_enqueue_fun)nsfw_shmem_ring_sp_enqueue, \
- (nsfw_mem_ring_dequeue_fun)nsfw_shmem_ring_sc_dequeue, \
- (nsfw_mem_ring_dequeuev_fun)nsfw_shmem_ring_sc_dequeuev
- },
- {
- (nsfw_mem_ring_enqueue_fun)nsfw_shmem_ring_mp_enqueue, \
- (nsfw_mem_ring_dequeue_fun)nsfw_shmem_ring_sc_dequeue, \
- (nsfw_mem_ring_dequeuev_fun)nsfw_shmem_ring_sc_dequeuev
- },
- {
- (nsfw_mem_ring_enqueue_fun)nsfw_shmem_ring_sp_enqueue, \
- (nsfw_mem_ring_dequeue_fun)nsfw_shmem_ring_mc_dequeue, \
- (nsfw_mem_ring_dequeuev_fun)nsfw_shmem_ring_mc_dequeuev
- },
- {
- (nsfw_mem_ring_enqueue_fun)nsfw_shmem_ring_mp_enqueue, \
- (nsfw_mem_ring_dequeue_fun)nsfw_shmem_ring_mc_dequeue, \
- (nsfw_mem_ring_dequeuev_fun)nsfw_shmem_ring_mc_dequeuev
- },
- {
- (nsfw_mem_ring_enqueue_fun)nsfw_shmem_ring_singlethread_enqueue, \
- (nsfw_mem_ring_dequeue_fun)nsfw_shmem_ring_singlethread_dequeue, \
- (nsfw_mem_ring_dequeuev_fun)nsfw_shmem_ring_singlethread_dequeuev
- }
- },
- {
- {
- (nsfw_mem_ring_enqueue_fun)nsfw_nshmem_ring_sp_enqueue, \
- (nsfw_mem_ring_dequeue_fun)nsfw_nshmem_ring_sc_dequeue, \
- (nsfw_mem_ring_dequeuev_fun)nsfw_nshmem_ring_sc_dequeuev
- },
- {
- (nsfw_mem_ring_enqueue_fun)nsfw_nshmem_ring_mp_enqueue, \
- (nsfw_mem_ring_dequeue_fun)nsfw_nshmem_ring_sc_dequeue, \
- (nsfw_mem_ring_dequeuev_fun)nsfw_nshmem_ring_sc_dequeuev
- },
- {
- (nsfw_mem_ring_enqueue_fun)nsfw_nshmem_ring_sp_enqueue, \
- (nsfw_mem_ring_dequeue_fun)nsfw_nshmem_ring_mc_dequeue, \
- (nsfw_mem_ring_dequeuev_fun)nsfw_nshmem_ring_mc_dequeuev
- },
- {
- (nsfw_mem_ring_enqueue_fun)nsfw_nshmem_ring_mp_enqueue, \
- (nsfw_mem_ring_dequeue_fun)nsfw_nshmem_ring_mc_dequeue, \
- (nsfw_mem_ring_dequeuev_fun)nsfw_nshmem_ring_mc_dequeuev
- },
- {
- (nsfw_mem_ring_enqueue_fun)nsfw_nshmem_ring_singlethread_enqueue, \
- (nsfw_mem_ring_dequeue_fun)nsfw_nshmem_ring_singlethread_dequeue, \
- (nsfw_mem_ring_dequeuev_fun)nsfw_nshmem_ring_singlethread_dequeuev
- }
- }
-};
-/* *INDENT-ON* */
diff --git a/src/framework/common/mem_mgr/nsfw_mem_stat.c b/src/framework/common/mem_mgr/nsfw_mem_stat.c
deleted file mode 100644
index f7a1f41..0000000
--- a/src/framework/common/mem_mgr/nsfw_mem_stat.c
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include <stdlib.h>
-#include "types.h"
-#include "nstack_securec.h"
-#include "nsfw_init.h"
-
-#include "nstack_log.h"
-#include "nsfw_maintain_api.h"
-#include "nsfw_mem_api.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C"{
-/* *INDENT-ON* */
-#endif /* __cplusplus */
-
-#define NSFW_MEM_STAT_NUM 512
-
-#define NSFW_MEM_STAT_MODULE "nsfw_mem_stat_module"
-
-typedef struct _nsfw_mem_stat
-{
- u8 mem_type;
- u8 alloc_flag;
- char module[NSFW_MEM_MODULE_LEN];
- char mem_name[NSFW_MEM_NAME_LEN];
- u32 mem_size;
-} nsfw_mem_stat_t;
-
-nsfw_mem_stat_t g_mem_stat[NSFW_MEM_STAT_NUM];
-
-#ifdef SYS_MEM_RES_STAT
-#define MAX_STAT_ITEM_NUM 20
-typedef struct _mem_stat_item_t
-{
- char name[32];
- u64 size;
-} mem_stat_item_t;
-
-typedef struct _mem_stat_mgr_t
-{
- u32 item_num;
- mem_stat_item_t item[MAX_STAT_ITEM_NUM];
-} mem_stat_mgr;
-
-mem_stat_mgr g_max_mem_list;
-#endif
-
-/*****************************************************************************
-* Prototype : nsfw_mem_stat
-* Description : add memory stat
-* Input : char *module
-* char *mem_name
-* u8 mem_type
-* u32 mem_size
-* Output : None
-* Return Value : void
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-void
-nsfw_mem_stat (char *module, char *mem_name, u8 mem_type, u32 mem_size)
-{
- if (NULL == module || NULL == mem_name)
- {
- NSFW_LOGERR ("argv err]module=%p,mem_name=%p", module, mem_name);
- return;
- }
-
- int i;
- nsfw_mem_stat_t *mem_stat_item = NULL;
- for (i = 0; i < NSFW_MEM_STAT_NUM; i++)
- {
- if (FALSE == g_mem_stat[i].alloc_flag)
- {
- g_mem_stat[i].alloc_flag = TRUE;
- mem_stat_item = &g_mem_stat[i];
- break;
- }
- }
-
- if (NULL == mem_stat_item)
- {
- NSFW_LOGERR ("mem stat full]module=%s,type=%u,name=%s,size=%u",
- module, mem_type, mem_name, mem_size);
- return;
- }
-
- mem_stat_item->mem_type = mem_type;
- mem_stat_item->mem_size = mem_size;
-
- if (EOK != STRCPY_S (mem_stat_item->module, NSFW_MEM_MODULE_LEN, module))
- {
- NSFW_LOGERR ("STRNCPY_S failed");
- return;
- }
- if (EOK != STRCPY_S (mem_stat_item->mem_name, NSFW_MEM_NAME_LEN, mem_name))
- {
- NSFW_LOGERR ("STRNCPY_S failed");
- return;
- }
-
- return;
-}
-
-/*****************************************************************************
-* Prototype : nsfw_mem_stat_print
-* Description : print all memory info
-* Input : None
-* Output : None
-* Return Value : void
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-void
-nsfw_mem_stat_print ()
-{
- int i;
- for (i = 0; i < NSFW_MEM_STAT_NUM; i++)
- {
- if (TRUE == g_mem_stat[i].alloc_flag)
- {
- NSFW_LOGINF ("mem_module=%s,name=%s,type=%u,size=%u",
- g_mem_stat[i].module, g_mem_stat[i].mem_name,
- g_mem_stat[i].mem_type, g_mem_stat[i].mem_size);
- }
- }
-
-}
-
-#ifdef SYS_MEM_RES_STAT
-void
-clear_mem_stat_item ()
-{
- if (EOK != MEMSET_S ((char *) &g_max_mem_list, sizeof (mem_stat_mgr),
- 0, sizeof (mem_stat_mgr)))
- {
- NSFW_LOGERR ("MEMSET_S failed");
- }
-}
-
-void
-insert_mem_stat_item (char *name, u64 len)
-{
- int j, temp;
-
- if (g_max_mem_list.item_num == 0)
- {
- if (EOK !=
- STRCPY_S (g_max_mem_list.item[0].name,
- sizeof (g_max_mem_list.item[0].name), name))
- {
- NSFW_LOGERR ("STRCPY_S failed");
- }
- g_max_mem_list.item[0].size = len;
- g_max_mem_list.item_num++;
- return;
- }
- else if (g_max_mem_list.item_num < MAX_STAT_ITEM_NUM)
- {
- if (len <= g_max_mem_list.item[g_max_mem_list.item_num - 1].size)
- {
- if (EOK !=
- STRCPY_S (g_max_mem_list.item[g_max_mem_list.item_num].name,
- sizeof (g_max_mem_list.item
- [g_max_mem_list.item_num].name), name))
- {
- NSFW_LOGERR ("STRCPY_S failed");
- }
- g_max_mem_list.item[g_max_mem_list.item_num].size = len;
- g_max_mem_list.item_num++;
- return;
- }
- j = 0;
- temp = g_max_mem_list.item_num;
- while (j < temp)
- {
- if (len >= g_max_mem_list.item[j].size)
- {
- goto insert_it;
- }
- j++;
- }
- if (j == temp)
- {
- if (EOK !=
- STRCPY_S (g_max_mem_list.item[j].name,
- sizeof (g_max_mem_list.item[j].name), name))
- {
- NSFW_LOGERR ("STRCPY_S failed");
- }
- g_max_mem_list.item[j].size = len;
- g_max_mem_list.item_num++;
- return;
- }
- }
- else
- {
- j = 0;
- temp = MAX_STAT_ITEM_NUM - 1;
- while (j < MAX_STAT_ITEM_NUM)
- {
- if (len >= g_max_mem_list.item[j].size)
- {
- goto insert_it;
- }
- j++;
- }
- }
-
- return;
-
-insert_it:
- while (temp - 1 >= j)
- {
- if (EOK !=
- STRCPY_S (g_max_mem_list.item[temp].name,
- sizeof (g_max_mem_list.item[temp].name),
- g_max_mem_list.item[temp - 1].name))
- {
- NSFW_LOGERR ("STRCPY_S failed");
- }
- g_max_mem_list.item[temp].size = g_max_mem_list.item[temp - 1].size;
- temp--;
- }
- if (EOK !=
- STRCPY_S (g_max_mem_list.item[j].name,
- sizeof (g_max_mem_list.item[j].name), name))
- {
- NSFW_LOGERR ("STRCPY_S failed");
- }
- g_max_mem_list.item[j].size = len;
- g_max_mem_list.item_num++;
- return;
-}
-
-int
-get_mem_stat_item (int idx, char **name, u64 * len)
-{
- if (idx < 0 || idx >= MAX_STAT_ITEM_NUM)
- {
- return -1;
- }
-
- *name = g_max_mem_list.item[idx].name;
- *len = g_max_mem_list.item[idx].size;
-
- return 0;
-}
-#endif
-
-static int nsfw_mem_stat_init (void *param);
-static int
-nsfw_mem_stat_init (void *param)
-{
- MEM_STAT (NSFW_MEM_STAT_MODULE, "g_mem_stat", NSFW_NSHMEM,
- sizeof (g_mem_stat));
- nsfw_mem_stat_print ();
-#ifdef SYS_MEM_RES_STAT
- clear_mem_stat_item ();
-#endif
- return 0;
-}
-
-/* *INDENT-OFF* */
-NSFW_MODULE_NAME (NSFW_MEM_STAT_MODULE)
-NSFW_MODULE_PRIORITY (99)
-NSFW_MODULE_INIT (nsfw_mem_stat_init)
-/* *INDENT-ON* */
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif /* __cplusplus */
diff --git a/src/framework/common/mem_mgr/nsfw_nshmem/nsfw_nshmem_mdesc.c b/src/framework/common/mem_mgr/nsfw_nshmem/nsfw_nshmem_mdesc.c
deleted file mode 100644
index fdb2079..0000000
--- a/src/framework/common/mem_mgr/nsfw_nshmem/nsfw_nshmem_mdesc.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "nsfw_mem_desc.h"
-#include "nsfw_nshmem_mng.h"
-#include "nsfw_nshmem_mdesc.h"
-
-/*no share memory access inferface*/
-nsfw_mem_ops g_nshmem_ops = {
- nsfw_nshmem_init,
- nsfw_nshmem_destory,
- nsfw_nshmem_create,
- NULL,
- nsfw_nshmem_lookup,
- nsfw_nshmem_release,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- nsfw_nshmem_spcreate,
- NULL,
- NULL,
- nsfw_nshmem_sprelease,
- nsfw_nshmem_sp_lookup,
- nsfw_nshmem_ringcreate,
- NULL,
- nsfw_nshmem_ringrelease,
- nsfw_nshmem_static,
- NULL,
- NULL, /*mem_ops_sp_iterator */
- NULL, /*mem_ops_mbuf_iterator */
-};
diff --git a/src/framework/common/mem_mgr/nsfw_nshmem/nsfw_nshmem_mdesc.h b/src/framework/common/mem_mgr/nsfw_nshmem/nsfw_nshmem_mdesc.h
deleted file mode 100644
index 1b63520..0000000
--- a/src/framework/common/mem_mgr/nsfw_nshmem/nsfw_nshmem_mdesc.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _NSFW_NSHMEM_MDESC_H
-#define _NSFW_NSHMEM_MDESC_H
-
-extern nsfw_mem_ops g_nshmem_ops;
-
-#endif
diff --git a/src/framework/common/mem_mgr/nsfw_nshmem/nsfw_nshmem_mng.c b/src/framework/common/mem_mgr/nsfw_nshmem/nsfw_nshmem_mng.c
deleted file mode 100644
index 49e3769..0000000
--- a/src/framework/common/mem_mgr/nsfw_nshmem/nsfw_nshmem_mng.c
+++ /dev/null
@@ -1,544 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include <stdlib.h>
-#include "nstack_log.h"
-#include "nstack_securec.h"
-#include "nsfw_mem_desc.h"
-#include "nsfw_ring_fun.h"
-#include "nsfw_nshmem_ring.h"
-#include "nsfw_nshmem_mng.h"
-
-#include "common_func.h"
-
-#define nsfw_get_glb_lock() (&g_nshmem_internal_cfg->mlock)
-
-#define NSFW_NSHMEM_INIT_CHK_RET_NULL() \
- if ((!g_nshmem_internal_cfg) || (!g_nshmem_localdata)) \
- { \
- NSCOMM_LOGDBG("Error] g_nshmem_internal_cfg=%p, g_nshmem_localdata=%p", g_nshmem_internal_cfg, g_nshmem_localdata); \
- return NULL; \
- }
-
-#define NSFW_NSHMEM_INIT_CHK_RET() \
- if ((!g_nshmem_internal_cfg) || (!g_nshmem_localdata)) \
- { \
- NSCOMM_LOGDBG("Error] g_nshmem_internal_cfg=%p, g_nshmem_localdata=%p", g_nshmem_internal_cfg, g_nshmem_localdata); \
- return NSFW_MEM_ERR; \
- }
-
-nsfw_mem_localdata *g_nshmem_localdata = NULL;
-nsfw_nshmem_cfg *g_nshmem_internal_cfg = NULL;
-
-/*look up a mem zone*/
-NSTACK_STATIC inline nsfw_nshmem_mzone *
-nsfw_nshmem_get_free_zone (void)
-{
- int icnt = 0;
-
- /*g_nshmem_internal_cfg must not be null if come here */
- for (icnt = 0; icnt < COMMON_MEM_MAX_MEMZONE; icnt++)
- {
- if (g_nshmem_internal_cfg->amemzone[icnt].addr == NULL)
- {
- return &g_nshmem_internal_cfg->amemzone[icnt];
- }
- }
-
- return NULL;
-}
-
-NSTACK_STATIC inline void
-nsfw_nshmem_free_zone (nsfw_nshmem_mzone * pzone)
-{
- nsfw_nshmem_mzone *pzonebase = &g_nshmem_internal_cfg->amemzone[0];
- nsfw_nshmem_mzone *pzoneend =
- &g_nshmem_internal_cfg->amemzone[NSFW_NSHMEM_ZONE_MAX - 1];
-
- if ((((int) ((char *) pzone - (char *) pzonebase) < 0)
- || ((int) ((char *) pzone - (char *) pzoneend) > 0))
- && ((unsigned int) ((char *) pzone - (char *) pzonebase) %
- sizeof (nsfw_nshmem_mzone) != 0))
- {
- NSCOMM_LOGERR ("nshmem free fail] mem=%p", pzone);
- return;
- }
- if (pzone->addr)
- {
- free (pzone->addr);
- }
- pzone->addr = NULL;
-
- int ret = MEMSET_S ((void *) pzone, sizeof (nsfw_nshmem_mzone), 0,
- sizeof (nsfw_nshmem_mzone));
- if (EOK != ret)
- {
- NSCOMM_LOGERR ("MEMSET_S failed] mem=%p, ret=%d", pzone, ret);
- }
- return;
-}
-
-/*****************************************************************************
-* Prototype : nsfw_nshmem_init
-* Description : nsh module init
-* Input : nsfw_mem_para* para
-* Output : None
-* Return Value : i32
-* Calls :
-* Called By :
-*****************************************************************************/
-i32
-nsfw_nshmem_init (nsfw_mem_para * para)
-{
- i32 iret = NSFW_MEM_OK;
- NSCOMM_LOGINF ("nsfw nshmem init begin");
- g_nshmem_localdata =
- (nsfw_mem_localdata *) malloc (sizeof (nsfw_mem_localdata));
-
- if (NULL == g_nshmem_localdata)
- {
- NSCOMM_LOGERR ("nshmem init g_nshmem_localdata malloc fail");
- return NSFW_MEM_ERR;
- }
-
- iret =
- MEMSET_S (g_nshmem_localdata, sizeof (nsfw_mem_localdata), 0,
- sizeof (nsfw_mem_localdata));
-
- if (EOK != iret)
- {
- NSCOMM_LOGERR ("nshmem init g_nshmem_localdata MEMSET_S fail");
- goto ERROR;
- }
-
- g_nshmem_internal_cfg =
- (nsfw_nshmem_cfg *) malloc (sizeof (nsfw_nshmem_cfg));
-
- if (NULL == g_nshmem_internal_cfg)
- {
- NSCOMM_LOGERR ("nshmem init g_nshmem_internal_cfg malloc fail");
- goto ERROR;
- }
-
- iret =
- MEMSET_S (g_nshmem_internal_cfg, sizeof (nsfw_nshmem_cfg), 0,
- sizeof (nsfw_nshmem_cfg));
-
- if (EOK != iret)
- {
- NSCOMM_LOGERR ("nshmem init g_nshmem_internal_cfg MEMSET_S fail");
- goto ERROR;
- }
-
- g_nshmem_localdata->enflag = para->enflag;
- NSCOMM_LOGINF ("nsfw nshmem init end");
- goto OK;
-
-ERROR:
- iret = NSFW_MEM_ERR;
- nsfw_nshmem_destory ();
- return iret;
-OK:
- iret = NSFW_MEM_OK;
- return iret;
-}
-
-/*
- * memory destory
- */
-void
-nsfw_nshmem_destory (void)
-{
- if (g_nshmem_localdata)
- {
- free (g_nshmem_localdata);
- g_nshmem_localdata = NULL;
- }
-
- if (g_nshmem_internal_cfg)
- {
- free (g_nshmem_internal_cfg);
- g_nshmem_internal_cfg = NULL;
- }
-
- return;
-}
-
-/*****************************************************************************
-* Prototype : nsfw_nshmem_reserv_safe
-* Description : malloc a memory and save to memzone
-* Input : const char* name
-* size_t length
-* Output : None
-* Return Value : mzone_handle
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-mzone_handle
-nsfw_nshmem_reserv_safe (const char *name, size_t length)
-{
- void *addr = NULL;
- i32 iret = NSFW_MEM_OK;
- nsfw_nshmem_mzone *pmemzone = NULL;
-
- if (length <= 0)
- {
- return NULL;
- }
-
- nsfw_write_lock (nsfw_get_glb_lock ());
-
- addr = malloc (length);
- if (!addr)
- {
- NSCOMM_LOGERR ("nshmem malloc addr fail] addr=%p", addr);
- nsfw_write_unlock (nsfw_get_glb_lock ());
- return NULL;
- }
-
- iret = MEMSET_S (addr, length, 0, length);
- if (EOK != iret)
- {
- NSCOMM_LOGERR ("nshmem malloc addr MEMSET_S fail] addr=%p", addr);
- free (addr);
- nsfw_write_unlock (nsfw_get_glb_lock ());
- return NULL;
- }
-
- pmemzone = nsfw_nshmem_get_free_zone ();
-
- if (!pmemzone)
- {
- NSCOMM_LOGERR ("nshmem get free zone fail");
- free (addr);
- nsfw_write_unlock (nsfw_get_glb_lock ());
- return NULL;
- }
-
- pmemzone->addr = addr;
- pmemzone->length = length;
- /*name must be less than NSFW_MEM_APPNAME_LENGTH */
- if (EOK !=
- STRCPY_S ((char *) pmemzone->aname, sizeof (pmemzone->aname), name))
- {
- NSCOMM_LOGERR ("STRCPY_S failed]name=%s", name);
- free (addr);
- nsfw_write_unlock (nsfw_get_glb_lock ());
- return NULL;
- }
-
- nsfw_write_unlock (nsfw_get_glb_lock ());
- return addr;
-}
-
-/*
- * create no shared memory
- * nsfw_mem_zone::stname no shared memory name
- * nsfw_mem_zone::isize memory size
- */
-mzone_handle
-nsfw_nshmem_create (nsfw_mem_zone * pinfo)
-{
-
- NSFW_NAME_LENCHECK_RET_NULL (pinfo->stname.aname, "nshmem create");
- NSFW_NSHMEM_INIT_CHK_RET_NULL ();
- return nsfw_nshmem_reserv_safe (pinfo->stname.aname, pinfo->length);
-}
-
-/*****************************************************************************
-* Prototype : nsfw_nshmem_lookup
-* Description : find a block memory by name
-* Input : nsfw_mem_name* pname
-* Output : None
-* Return Value : mzone_handle
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-mzone_handle
-nsfw_nshmem_lookup (nsfw_mem_name * pname)
-{
- int icnt = 0;
- nsfw_nshmem_mzone *mz = NULL;
-
- NSFW_NAME_LENCHECK_RET_NULL (pname->aname, "nshmem lookup");
- NSFW_NSHMEM_INIT_CHK_RET_NULL ();
- nsfw_read_lock (nsfw_get_glb_lock ());
-
- for (icnt = 0; icnt < NSFW_NSHMEM_ZONE_MAX; icnt++)
- {
- mz = &g_nshmem_internal_cfg->amemzone[icnt];
-
- if (mz->addr != NULL
- && !strncmp (pname->aname, mz->aname, NSFW_MEM_NAME_LENGTH))
- {
- nsfw_read_unlock (nsfw_get_glb_lock ());
- return mz->addr;
- }
- }
-
- nsfw_read_unlock (nsfw_get_glb_lock ());
- return NULL;
-}
-
-/*****************************************************************************
-* Prototype : nsfw_nshmem_release
-* Description : free a block memory
-* Input : nsfw_mem_name* pname
-* Output : None
-* Return Value : i32
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-i32
-nsfw_nshmem_release (nsfw_mem_name * pname)
-{
- int icnt = 0;
- nsfw_nshmem_mzone *mz = NULL;
-
- NSFW_NAME_LENCHECK_RET (pname->aname, "nshmem release");
- NSFW_NSHMEM_INIT_CHK_RET ();
- nsfw_read_lock (nsfw_get_glb_lock ());
-
- for (icnt = 0; icnt < NSFW_NSHMEM_ZONE_MAX; icnt++)
- {
- mz = &g_nshmem_internal_cfg->amemzone[icnt];
-
- if (mz->addr != NULL
- && !strncmp (pname->aname, mz->aname, NSFW_MEM_NAME_LENGTH))
- {
- nsfw_nshmem_free_zone (mz);
- nsfw_read_unlock (nsfw_get_glb_lock ());
- return NSFW_MEM_OK;
- }
- }
-
- nsfw_read_unlock (nsfw_get_glb_lock ());
- return NSFW_MEM_OK;
-
-}
-
-/*****************************************************************************
-* Prototype : nsfw_nshmem_spcreate
-* Description : create a memory pool by ring
-* Input : nsfw_mem_sppool* pmpinfo
-* Output : None
-* Return Value : mring_handle
-* Calls :
-* Called By :
-*****************************************************************************/
-mring_handle
-nsfw_nshmem_spcreate (nsfw_mem_sppool * pmpinfo)
-{
- size_t len = 0;
- unsigned int usnum = common_mem_align32pow2 (pmpinfo->usnum + 1);
- unsigned int uselt_size = pmpinfo->useltsize;
- struct nsfw_mem_ring *pringhead = NULL;
- unsigned int uscnt = 0;
- char *pmz = NULL;
- NSFW_NAME_LENCHECK_RET_NULL (pmpinfo->stname.aname, "nshmem sp create");
- NSFW_NSHMEM_INIT_CHK_RET_NULL ();
-
- len =
- sizeof (struct nsfw_mem_ring) +
- (size_t) usnum *sizeof (union RingData_U) + (size_t) usnum *uselt_size;
- pringhead =
- (struct nsfw_mem_ring *) nsfw_nshmem_reserv_safe (pmpinfo->stname.aname,
- len);
-
- if (!pringhead)
- {
- NSCOMM_LOGERR ("nshmem sp create mzone reserv fail");
- return NULL;
- }
-
- nsfw_mem_ring_init (pringhead, usnum, pringhead, NSFW_NSHMEM,
- pmpinfo->enmptype);
- pmz =
- ((char *) pringhead + sizeof (struct nsfw_mem_ring) +
- usnum * sizeof (union RingData_U));
-
- for (uscnt = 0; uscnt < usnum; uscnt++)
- {
- if (0 ==
- g_ring_ops_arry[pringhead->memtype][pringhead->
- ringflag].ring_ops_enqueue
- (pringhead, (void *) pmz))
- {
- NSCOMM_LOGERR ("nsfw_nshmem_ringenqueue enqueue fail] uscnt=%u",
- uscnt);
- }
-
- pmz = pmz + uselt_size;
- }
-
- return pringhead;
-}
-
-/*****************************************************************************
-* Prototype : nsfw_nshmem_sp_lookup
-* Description : look up a sppool memory
-* Input : nsfw_mem_name* pname
-* Output : None
-* Return Value : mring_handle
-* Calls :
-* Called By :
-*****************************************************************************/
-mring_handle
-nsfw_nshmem_sp_lookup (nsfw_mem_name * pname)
-{
- return nsfw_nshmem_lookup (pname);
-}
-
-/*****************************************************************************
-* Prototype : nsfw_nshmem_sprelease
-* Description : release a sp pool
-* Input : nsfw_mem_name* pname
-* Output : None
-* Return Value : i32
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-i32
-nsfw_nshmem_sprelease (nsfw_mem_name * pname)
-{
- NSFW_NAME_LENCHECK_RET (pname->aname, "nshmem sp mempool release");
- NSFW_NSHMEM_INIT_CHK_RET ();
- return nsfw_nshmem_release (pname);
-}
-
-/*****************************************************************************
-* Prototype : nsfw_nshmem_ringcreate
-* Description : create a ring
-* Input : nsfw_mem_mring* pringinfo
-* Output : None
-* Return Value : mring_handle
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-mring_handle
-nsfw_nshmem_ringcreate (nsfw_mem_mring * pringinfo)
-{
- size_t len = 0;
- unsigned int usnum = common_mem_align32pow2 (pringinfo->usnum + 1);
- struct nsfw_mem_ring *pringhead = NULL;
- NSFW_NAME_LENCHECK_RET_NULL (pringinfo->stname.aname, "nshmem ring create");
- NSFW_NSHMEM_INIT_CHK_RET_NULL ();
-
- len = sizeof (struct nsfw_mem_ring) + usnum * sizeof (union RingData_U);
- pringhead =
- (struct nsfw_mem_ring *) nsfw_nshmem_reserv_safe (pringinfo->stname.aname,
- len);
-
- if (!pringhead)
- {
- NSCOMM_LOGERR ("nshmem ring create mzone reserv fail");
- return NULL;
- }
-
- nsfw_mem_ring_init (pringhead, usnum, (void *) pringhead, NSFW_NSHMEM,
- pringinfo->enmptype);
- return pringhead;
-
-}
-
-/*****************************************************************************
-* Prototype : nsfw_nshmem_ringrelease
-* Description : release a nsh ring memory
-* Input : nsfw_mem_name* pname
-* Output : None
-* Return Value : i32
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-i32
-nsfw_nshmem_ringrelease (nsfw_mem_name * pname)
-{
- NSFW_NAME_LENCHECK_RET (pname->aname, "nshmem ring mempool release");
- NSFW_NSHMEM_INIT_CHK_RET ();
- return nsfw_nshmem_release (pname);
-}
-
-/*****************************************************************************
-* Prototype : nsfw_nshmem_sppool_statics
-* Description : static the memory size of sppool
-* Input : mring_handle sppool
-* Output : None
-* Return Value : ssize_t
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-ssize_t
-nsfw_nshmem_sppool_statics (mring_handle sppool)
-{
- struct nsfw_mem_ring *phead = (struct nsfw_mem_ring *) sppool;
-
- return sizeof (struct nsfw_mem_ring) +
- (ssize_t) phead->size * sizeof (union RingData_U) +
- (ssize_t) phead->size * phead->eltsize;
-}
-
-/*****************************************************************************
-* Prototype : nsfw_nshmem_ring_statics
-* Description : static the memory size of ring
-* Input : mring_handle handle
-* Output : None
-* Return Value : ssize_t
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-ssize_t
-nsfw_nshmem_ring_statics (mring_handle handle)
-{
- struct nsfw_mem_ring *ring = (struct nsfw_mem_ring *) handle;
- return ring->size * sizeof (union RingData_U) +
- sizeof (struct nsfw_mem_ring);
-}
-
-/*****************************************************************************
-* Prototype : nsfw_nshmem_static
-* Description : static the memory size according to mem type
-* Input : void* handle
-* nsfw_mem_struct_type type
-* Output : None
-* Return Value : ssize_t
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-ssize_t
-nsfw_nshmem_static (void *handle, nsfw_mem_struct_type type)
-{
- switch (type)
- {
- case NSFW_MEM_MBUF:
- return -1;
- case NSFW_MEM_SPOOL:
- return nsfw_nshmem_sppool_statics (handle);
- case NSFW_MEM_RING:
- return nsfw_nshmem_ring_statics (handle);
- default:
- break;
- }
- return -1;
-}
diff --git a/src/framework/common/mem_mgr/nsfw_nshmem/nsfw_nshmem_mng.h b/src/framework/common/mem_mgr/nsfw_nshmem/nsfw_nshmem_mng.h
deleted file mode 100644
index 06ab562..0000000
--- a/src/framework/common/mem_mgr/nsfw_nshmem/nsfw_nshmem_mng.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _NSFW_NSHMEM_MNG_H_
-#define _NSFW_NSHMEM_MNG_H_
-
-#include "generic/common_mem_rwlock.h"
-
-#include "common_func.h"
-
-#define NSFW_NSHMEM_ZONE_MAX 2560
-
-typedef struct
-{
- i8 aname[NSFW_MEM_NAME_LENGTH];
- void *addr;
- int length;
-} nsfw_nshmem_mzone;
-
-typedef struct
-{
- nsfw_nshmem_mzone amemzone[NSFW_NSHMEM_ZONE_MAX];
- common_mem_rwlock_t mlock;
-} nsfw_nshmem_cfg;
-
-/*
- * no share memory module init
- */
-i32 nsfw_nshmem_init (nsfw_mem_para * para);
-
-/*
- * no share memory module destory
- */
-void nsfw_nshmem_destory (void);
-
-/*
- * create a no shared memory
- */
-mzone_handle nsfw_nshmem_create (nsfw_mem_zone * pinfo);
-
-mzone_handle nsfw_nshmem_lookup (nsfw_mem_name * pname);
-
-i32 nsfw_nshmem_release (nsfw_mem_name * pname);
-
-mring_handle nsfw_nshmem_spcreate (nsfw_mem_sppool * pmpinfo);
-
-i32 nsfw_nshmem_sprelease (nsfw_mem_name * pname);
-
-mring_handle nsfw_nshmem_sp_lookup (nsfw_mem_name * pname);
-
-mring_handle nsfw_nshmem_ringcreate (nsfw_mem_mring * pringinfo);
-
-i32 nsfw_nshmem_ringrelease (nsfw_mem_name * pname);
-
-ssize_t nsfw_nshmem_static (void *handle, nsfw_mem_struct_type type);
-
-#endif
diff --git a/src/framework/common/mem_mgr/nsfw_nshmem/nsfw_nshmem_ring.c b/src/framework/common/mem_mgr/nsfw_nshmem/nsfw_nshmem_ring.c
deleted file mode 100644
index 7e56f3c..0000000
--- a/src/framework/common/mem_mgr/nsfw_nshmem/nsfw_nshmem_ring.c
+++ /dev/null
@@ -1,437 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include <string.h>
-#include <sched.h>
-#include "nstack_securec.h"
-
-#include "nsfw_mem_desc.h"
-#include "nsfw_nshmem_ring.h"
-#include "nsfw_ring_fun.h"
-#include "common_func.h"
-
-/*copy the data to obj*/
-NSTACK_STATIC inline void
-nsfw_nshmem_ring_obj_copy (struct nsfw_mem_ring *r, uint32_t cons_head,
- void **obj_table, unsigned n)
-{
- uint32_t idx = cons_head & r->mask;
- unsigned i = 0;
- const uint32_t size = r->size;
-
- if (likely (idx + n < size))
- {
- for (i = 0; i < (n & (~(unsigned) 0x3)); i += 4, idx += 4)
- {
- obj_table[i] = (void *) r->ring[idx].data_l;
- obj_table[i + 1] = (void *) r->ring[idx + 1].data_l;
- obj_table[i + 2] = (void *) r->ring[idx + 2].data_l;
- obj_table[i + 3] = (void *) r->ring[idx + 3].data_l;
- }
- switch (n & 0x3)
- {
- case 3:
- obj_table[i++] = (void *) r->ring[idx++].data_l;
-
- case 2:
- obj_table[i++] = (void *) r->ring[idx++].data_l;
-
- case 1:
- obj_table[i++] = (void *) r->ring[idx++].data_l;
- }
- }
- else
- {
- for (i = 0; idx < size; i++, idx++)
- {
- obj_table[i] = (void *) r->ring[idx].data_l;
- }
-
- for (idx = 0; i < n; i++, idx++)
- {
- obj_table[i] = (void *) r->ring[idx].data_l;
- }
- }
-}
-
-/*fork recover*/
-NSTACK_STATIC inline void
-nsfw_nshmem_enqueue_fork_recov (struct nsfw_mem_ring *r)
-{
- u32_t pidflag = 0;
- u32_t curpid = get_sys_pid ();
- int success = 0;
- /*if pid is not the same, maybe mult thread fork happen */
- pidflag = r->prodhflag;
-
- if (unlikely (pidflag != curpid))
- {
- success = common_mem_atomic32_cmpset (&r->prodhflag, pidflag, curpid);
-
- if (unlikely (success != 0))
- {
- /*recover it */
- if (r->prod.tail != r->prod.head)
- {
- r->prod.head = r->prod.tail;
- }
-
- r->prodtflag = curpid;
- }
- }
-
- return;
-}
-
-NSTACK_STATIC inline void
-nsfw_nshmem_dequeue_fork_recov (struct nsfw_mem_ring *r)
-{
- u32_t pidflag = 0;
- u32_t curpid = get_sys_pid ();
- int success = 0;
- /*if pid is not the same, maybe mult thread fork happen */
- pidflag = r->conshflag;
-
- if (unlikely (pidflag != curpid))
- {
- success = common_mem_atomic32_cmpset (&r->conshflag, pidflag, curpid);
-
- if (unlikely (success != 0))
- {
- /*recover it */
- if (r->cons.tail != r->cons.head)
- {
- r->cons.head = r->cons.tail;
- }
-
- r->constflag = curpid;
- }
- }
-
- return;
-}
-
-/*
-this is a multi thread/process enqueue function, please pay attention to the bellow point
-1. while Enqueue corrupt, we may lose one element; because no one to add the Head
-*/
-int
-nsfw_nshmem_ring_mp_enqueue (struct nsfw_mem_ring *mem_ring, void *obj_table)
-{
- uint32_t producer_head, producer_next;
- uint32_t consumer_tail, free_entries;
- int success;
- unsigned rep = 0;
- uint32_t mask = mem_ring->mask;
- uint32_t size = mem_ring->size;
- uint32_t n = 1;
-
- /* move prod.head atomically */
- do
- {
-
- producer_head = mem_ring->prod.head;
- consumer_tail = mem_ring->cons.tail;
- /* The subtraction is done between two unsigned 32bits value
- * (the result is always modulo 32 bits even if we have
- * producer_head > consumer_tail). So 'free_entries' is always between 0
- * and size(ring)-1. */
- free_entries = (size + consumer_tail - producer_head);
-
- /* check that we have enough room in ring */
- if (unlikely (n > free_entries))
- {
- return 0;
- /* Below code is commented currenlty as its a dead code. */
- }
-
- /*if pid is not the same, maybe mult thread fork happen */
- nsfw_nshmem_enqueue_fork_recov (mem_ring);
-
- while (unlikely
- ((mem_ring->prod.tail != mem_ring->prod.head)
- || (mem_ring->prodtflag != mem_ring->prodhflag)))
- {
- common_mem_pause ();
- }
-
- producer_next = producer_head + n;
- success =
- common_mem_atomic32_cmpset (&mem_ring->prod.head, producer_head,
- producer_next);
- }
- while (unlikely (success == 0));
-
- mem_ring->ring[producer_head & mask].data_l = (u64) obj_table;
-
- /*
- * If there are other enqueues in progress that preceded us,
- * we need to wait for them to complete
- */
- while (unlikely (mem_ring->prod.tail != producer_head))
- {
- common_mem_pause ();
-
- /* Set COMMON_RING_PAUSE_REP_COUNT to avoid spin too long waiting
- * for other thread finish. It gives pre-emptied thread a chance
- * to proceed and finish with ring dequeue operation. */
- /* check the queue can be operate */
- if (++rep == 5)
- {
- rep = 0;
- (void) sched_yield ();
- }
- }
-
- mem_ring->prod.tail = producer_next;
- return (int) n;
-}
-
-/*
- this is a single thread/process enqueue function
- */
-int
-nsfw_nshmem_ring_sp_enqueue (struct nsfw_mem_ring *r, void *obj_table)
-{
- uint32_t producer_head, consumer_tail;
- uint32_t producer_next, free_entries;
- uint32_t mask = r->mask;
- uint32_t n = 1;
- uint32_t size = r->size;
-
- producer_head = r->prod.head;
- consumer_tail = r->cons.tail;
- /* The subtraction is done between two unsigned 32bits value
- * (the result is always modulo 32 bits even if we have
- * producer_head > consumer_tail). So 'free_entries' is always between 0
- * and size(ring)-1. */
- free_entries = size + consumer_tail - producer_head;
-
- /* check that we have enough room in ring */
- if (unlikely (n > free_entries))
- {
- return 0;
- }
-
- nsfw_nshmem_enqueue_fork_recov (r);
-
- producer_next = producer_head + n;
- r->prod.head = producer_next;
-
- r->ring[producer_head & mask].data_l = (u64) obj_table;
-
- r->prod.tail = producer_next;
- return (int) n;
-}
-
-/*
- this is enhanced mc_ring_dequeue, support dequeue multi element one time.
-*/
-int
-nsfw_nshmem_ring_mc_dequeuev (struct nsfw_mem_ring *r, void **obj_table,
- unsigned int n)
-{
- uint32_t consumer_head, producer_tail;
- uint32_t consumer_next, entries;
- int success;
- unsigned rep = 0;
- uint32_t num = n;
-
- /* Avoid the unnecessary cmpset operation below, which is also
- * potentially harmful when n equals 0. */
- if (unlikely (num == 0))
- {
- return 0;
- }
-
- nsfw_nshmem_dequeue_fork_recov (r);
-
- /* move cons.head atomically */
- do
- {
- num = n;
- consumer_head = r->cons.head;
- producer_tail = r->prod.tail;
- /* The subtraction is done between two unsigned 32bits value
- * (the result is always modulo 32 bits even if we have
- * cons_head > prod_tail). So 'entries' is always between 0
- * and size(ring)-1. */
- entries = (producer_tail - consumer_head);
-
- /* Set the actual entries for dequeue */
- if (unlikely (num > entries))
- {
- if (likely (entries > 0))
- {
- num = entries;
- }
- else
- {
- return 0;
- }
- }
-
- /* check the queue can be operate */
- while (unlikely
- ((r->cons.tail != r->cons.head)
- || (r->conshflag != r->constflag)))
- {
- common_mem_pause ();
- }
-
- consumer_next = consumer_head + num;
-
- success =
- common_mem_atomic32_cmpset (&r->cons.head, consumer_head,
- consumer_next);
- }
- while (unlikely (success == 0));
-
- nsfw_nshmem_ring_obj_copy (r, consumer_head, obj_table, num);
-
- /*
- * If there are other dequeues in progress that preceded us,
- * we need to wait for them to complete
- */
- while (unlikely (r->cons.tail != consumer_head))
- {
- common_mem_pause ();
-
- /* Set COMMON_RING_PAUSE_REP_COUNT to avoid spin too long waiting
- * for other thread finish. It gives pre-emptied thread a chance
- * to proceed and finish with ring dequeue operation. */
- /* check the queue can be operate */
- if (++rep == 5)
- {
- rep = 0;
- (void) sched_yield ();
- }
- }
-
- r->cons.tail = consumer_next;
-
- return (int) num;
-}
-
-/*this is a multi thread/process dequeue function, please pay attention to the bellow point
-1. while dequeue corrupt, the tail no one added, may multi the try times.
-*/
-int
-nsfw_nshmem_ring_mc_dequeue (struct nsfw_mem_ring *ring, void **box)
-{
- return nsfw_nshmem_ring_mc_dequeuev (ring, box, 1);
-}
-
-/*
- this is a single thread/process dequeue function
-*/
-int
-nsfw_nshmem_ring_sc_dequeuev (struct nsfw_mem_ring *r, void **obj_table,
- unsigned int n)
-{
- uint32_t consumer_head, producer_tail;
- uint32_t consumer_next, entries;
- uint32_t inum = n;
- consumer_head = r->cons.head;
- producer_tail = r->prod.tail;
- /* The subtraction is done between two unsigned 32bits value
- * (the result is always modulo 32 bits even if we have
- * cons_head > prod_tail). So 'entries' is always between 0
- * and size(ring)-1. */
- entries = producer_tail - consumer_head;
-
- if (unlikely (inum > entries))
- {
- if (likely (entries > 0))
- {
- inum = entries;
- }
- else
- {
- return 0;
- }
- }
-
- nsfw_nshmem_dequeue_fork_recov (r);
-
- consumer_next = consumer_head + inum;
- r->cons.head = consumer_next;
-
- nsfw_nshmem_ring_obj_copy (r, consumer_head, obj_table, inum);
-
- r->cons.tail = consumer_next;
- return (int) inum;
-}
-
-/*
- this is enhanced mc_ring_dequeue, support dequeue multi element one time.
-*/
-int
-nsfw_nshmem_ring_sc_dequeue (struct nsfw_mem_ring *ring, void **box)
-{
- return nsfw_nshmem_ring_sc_dequeuev (ring, box, 1);
-}
-
-/*stack just using one thread, for performance using que not support multi thread*/
-int
-nsfw_nshmem_ring_singlethread_enqueue (struct nsfw_mem_ring *ring, void *box)
-{
- u32 head = 0;
-
- /*if queue is full, just return 0 */
- if (unlikely (ring->prod.head >= (ring->size + ring->cons.tail)))
- {
- return 0;
- }
-
- head = ring->prod.head;
- ring->ring[head & ring->mask].data_l = (u64) box;
- ring->prod.head++;
- return 1;
-}
-
-/*stack just using one thread, for performance using que not support multi thread*/
-int
-nsfw_nshmem_ring_singlethread_dequeue (struct nsfw_mem_ring *ring, void **box)
-{
- return nsfw_nshmem_ring_singlethread_dequeuev (ring, box, 1);
-}
-
-/*stack just using one thread, for performance using que not support multi thread*/
-int
-nsfw_nshmem_ring_singlethread_dequeuev (struct nsfw_mem_ring *ring,
- void **box, unsigned int n)
-{
- u32 tail = 0;
- u32 num = 0;
-
- while (num < n)
- {
- tail = ring->cons.tail;
-
- /* if all entries are dequeued return 0 */
- if (unlikely (ring->prod.head == ring->cons.tail))
- {
- return num;
- }
-
- box[num] = (void *) ring->ring[tail & ring->mask].data_l;
- ring->cons.tail++;
- num++;
- }
-
- return num;
-}
diff --git a/src/framework/common/mem_mgr/nsfw_nshmem/nsfw_nshmem_ring.h b/src/framework/common/mem_mgr/nsfw_nshmem/nsfw_nshmem_ring.h
deleted file mode 100644
index 93a4d4a..0000000
--- a/src/framework/common/mem_mgr/nsfw_nshmem/nsfw_nshmem_ring.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _NSFW_NSHMEM_RING_H_
-#define _NSFW_NSHMEM_RING_H_
-
-#include <stdint.h>
-
-int nsfw_nshmem_ring_mp_enqueue (struct nsfw_mem_ring *ring, void *box);
-int nsfw_nshmem_ring_sp_enqueue (struct nsfw_mem_ring *ring, void *box);
-int nsfw_nshmem_ring_mc_dequeue (struct nsfw_mem_ring *ring, void **box);
-int nsfw_nshmem_ring_mc_dequeuev (struct nsfw_mem_ring *ring, void **box,
- unsigned int n);
-int nsfw_nshmem_ring_sc_dequeue (struct nsfw_mem_ring *ring, void **box);
-int nsfw_nshmem_ring_sc_dequeuev (struct nsfw_mem_ring *ring, void **box,
- unsigned int n);
-int nsfw_nshmem_ring_singlethread_enqueue (struct nsfw_mem_ring *ring,
- void *box);
-int nsfw_nshmem_ring_singlethread_dequeue (struct nsfw_mem_ring *ring,
- void **box);
-int nsfw_nshmem_ring_singlethread_dequeuev (struct nsfw_mem_ring *ring,
- void **box, unsigned int n);
-
-#endif /*_NSFW_NSHMEM_RING_H_*/
diff --git a/src/framework/common/mem_mgr/nsfw_res_mgr.c b/src/framework/common/mem_mgr/nsfw_res_mgr.c
deleted file mode 100644
index c4d8010..0000000
--- a/src/framework/common/mem_mgr/nsfw_res_mgr.c
+++ /dev/null
@@ -1,429 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-/*==============================================*
- * include header files *
- *----------------------------------------------*/
-
-/*==============================================*
- * constants or macros define *
- *----------------------------------------------*/
-
-/*==============================================*
- * project-wide global variables *
- *----------------------------------------------*/
-
-/*==============================================*
- * routines' or functions' implementations *
- *----------------------------------------------*/
-
-#include <stdlib.h>
-#include "types.h"
-#include "nstack_securec.h"
-#include "nsfw_init.h"
-#include "common_mem_mbuf.h"
-
-#include "nstack_log.h"
-#include "nsfw_maintain_api.h"
-
-#include "nsfw_mem_api.h"
-#include "nsfw_fd_timer_api.h"
-#include "nsfw_ring_data.h"
-
-#include "common_func.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C"{
-/* *INDENT-ON* */
-#endif /* __cplusplus */
-
-nsfw_res_mgr_item_cfg g_all_res_can[NSFW_MAX_RES_SCAN_COUNT];
-
-#define NSFW_RES_SCAN_TVLAUE_DEF 60
-#define NSFW_RES_SCAN_TVLAUE (g_scan_cfg.scan_tvalue)
-
-typedef struct _nsfw_res_scan_init_cfg
-{
- nsfw_timer_info *scan_timer;
- u16 scan_tvalue;
-} nsfw_res_scan_init_cfg;
-nsfw_res_scan_init_cfg g_scan_cfg;
-
-u8
-nsfw_res_mgr_reg (nsfw_res_scn_cfg * cfg)
-{
- if (NULL == cfg)
- {
- NSFW_LOGERR ("argv err!");
- return FALSE;
- }
-
- u32 i;
- for (i = 0; i < NSFW_MAX_RES_SCAN_COUNT; i++)
- {
- if ((NULL == g_all_res_can[i].scn_cfg.free_fun)
- &&
- (__sync_bool_compare_and_swap
- (&g_all_res_can[i].scn_cfg.free_fun, 0, cfg->free_fun)))
- {
- g_all_res_can[i].scn_cfg = *cfg;
- NSFW_LOGINF ("reg res_mgr fun suc]fun=%p,data=%p", cfg->free_fun,
- cfg->data);
- return TRUE;
- }
- }
-
- NSFW_LOGERR
- ("reg]type=%u,per=%u,chk=%u,cyc=%u,total=%u,size=%u,offset=%u,fun=%p,data=%p",
- cfg->type, cfg->force_free_percent, cfg->force_free_chk_num,
- cfg->num_per_cyc, cfg->total_num, cfg->elm_size, cfg->res_mem_offset,
- cfg->res_mem_offset, cfg->free_fun, cfg->data);
- return FALSE;
-}
-
-static inline u32
-nsfw_get_alloc_count (u32 head, u32 tail)
-{
- if (head >= tail)
- {
- return head - tail;
- }
-
- return head + (0xFFFFFFFF - tail);
-}
-
-int
-nsfw_res_sp_item_chk (void *data, void *argv)
-{
- nsfw_res_mgr_item_cfg *res_scn_item = (nsfw_res_mgr_item_cfg *) argv;
- nsfw_res_scn_cfg *scn_cfg = &res_scn_item->scn_cfg;
- char *elm = (char *) data;
-
- if (NULL == scn_cfg || NULL == elm)
- {
- return FALSE;
- }
-
- nsfw_res *res_item = NULL;
- res_item = (nsfw_res *) (elm + scn_cfg->res_mem_offset);
- if (0 == res_item->chk_count)
- {
- res_item->data = res_scn_item->cons_head;
- }
- res_item->chk_count++;
-
- if (res_item->chk_count < scn_cfg->force_free_chk_num)
- {
- return FALSE;
- }
-
- if (res_scn_item->free_percent > scn_cfg->force_free_percent)
- {
- return FALSE;
- }
-
- if (scn_cfg->total_num * scn_cfg->alloc_speed_factor >
- nsfw_get_alloc_count (res_scn_item->cons_head, res_item->data))
- {
- return FALSE;
- }
-
- if (NULL == scn_cfg->free_fun)
- {
- return FALSE;
- }
-
- if (TRUE == scn_cfg->free_fun ((void *) elm))
- {
- res_scn_item->force_count++;
- }
-
- res_item->chk_count = 0;
- return TRUE;
-}
-
-int
-nsfw_res_flash_data (nsfw_res_mgr_item_cfg * res_scn_item)
-{
- nsfw_res_scn_cfg *scn_cfg = &res_scn_item->scn_cfg;
-
- u32 cur_head = 0;
- u32 cur_tail = 0;
- u32 elm_num = 0;
- u32 free_count = 0;
-
- switch (scn_cfg->type)
- {
- case NSFW_RES_SCAN_MBUF:
- {
- struct common_mem_ring *ring =
- (struct common_mem_ring *) scn_cfg->mgr_ring;
- struct common_mem_mempool *mp =
- (struct common_mem_mempool *) scn_cfg->data;
- if (NULL == ring)
- {
- ring = mp->pool_data;
- if (NULL == ring)
- return FALSE;
- }
- cur_head = ring->prod.head;
- cur_tail = ring->cons.head;
- elm_num = mp->size;
- }
- break;
- case NSFW_RES_SCAN_SPOOL:
- {
- struct nsfw_mem_ring *mem_ring =
- (struct nsfw_mem_ring *) scn_cfg->mgr_ring;
- if (NULL == mem_ring)
- {
- mem_ring = (struct nsfw_mem_ring *) scn_cfg->data;
- if (NULL == mem_ring)
- return FALSE;
- }
-
- cur_head = mem_ring->prod.head;
- cur_tail = mem_ring->cons.tail;
- elm_num = mem_ring->size;
- }
- break;
- case NSFW_RES_SCAN_ARRAY:
- {
- struct nsfw_mem_ring *mem_ring =
- (struct nsfw_mem_ring *) scn_cfg->mgr_ring;
- if (NULL == mem_ring)
- {
- return FALSE;
- }
-
- cur_head = mem_ring->prod.head;
- cur_tail = mem_ring->cons.tail;
- elm_num = scn_cfg->total_num;
- }
- break;
- default:
- return FALSE;
- }
-
- free_count = nsfw_get_alloc_count (cur_head, cur_tail);
-
- res_scn_item->cons_head = cur_head;
- res_scn_item->prod_head = cur_tail;
- if (0 != elm_num)
- {
- res_scn_item->free_percent = free_count * 100 / elm_num;
- }
- else
- {
- res_scn_item->free_percent = 100;
- }
-
- scn_cfg->total_num = elm_num;
- return TRUE;
-}
-
-void
-nsfw_res_scan_mem (nsfw_res_mgr_item_cfg * res_scn_item)
-{
- if (NULL == res_scn_item)
- {
- return;
- }
-
- nsfw_res_scn_cfg *scn_cfg = &res_scn_item->scn_cfg;
- if (NULL == scn_cfg->data)
- {
- return;
- }
-
- u32 start = res_scn_item->last_scn_idx;
- u32 end = start + scn_cfg->num_per_cyc;
- int res_chk_number = 0;
- if (NSFW_RES_SCAN_SPOOL == scn_cfg->type)
- {
- res_chk_number =
- nsfw_mem_sp_iterator (scn_cfg->data, start, end,
- nsfw_res_sp_item_chk, (void *) res_scn_item);
- }
- else
- {
- res_chk_number =
- nsfw_mem_mbuf_iterator (scn_cfg->data, start, end,
- nsfw_res_sp_item_chk, (void *) res_scn_item);
- }
-
- if (0 == res_chk_number)
- {
- res_scn_item->last_scn_idx = 0;
- start = res_scn_item->last_scn_idx;
- end = start + scn_cfg->num_per_cyc;
- if (NSFW_RES_SCAN_SPOOL == scn_cfg->type)
- {
- res_chk_number =
- nsfw_mem_sp_iterator (scn_cfg->data, start, end,
- nsfw_res_sp_item_chk,
- (void *) res_scn_item);
- }
- else
- {
- res_chk_number =
- nsfw_mem_mbuf_iterator (scn_cfg->data, start, end,
- nsfw_res_sp_item_chk,
- (void *) res_scn_item);
- }
- }
-
- if (res_chk_number + start < end)
- {
- res_scn_item->last_scn_idx = 0;
- }
- else
- {
- res_scn_item->last_scn_idx += res_chk_number;
- }
-
- return;
-}
-
-void
-nsfw_res_scan_array (nsfw_res_mgr_item_cfg * res_scn_item)
-{
- if (NULL == res_scn_item)
- {
- return;
- }
-
- nsfw_res_scn_cfg *scn_cfg = &res_scn_item->scn_cfg;
- if (NULL == scn_cfg->data)
- {
- return;
- }
-
- u32 i;
- char *elm =
- (char *) scn_cfg->data + (res_scn_item->last_scn_idx * scn_cfg->elm_size);
- for (i = res_scn_item->last_scn_idx; i < scn_cfg->total_num; i++)
- {
- if (i >= res_scn_item->last_scn_idx + scn_cfg->num_per_cyc)
- {
- break;
- }
-
- if (TRUE == nsfw_res_sp_item_chk (elm, (void *) res_scn_item))
- {
- NSFW_LOGINF ("force free item]data=%p,cfg=%p", elm, res_scn_item);
- }
-
- elm += scn_cfg->elm_size;
- }
-
- if (i >= scn_cfg->total_num)
- {
- res_scn_item->last_scn_idx = 0;
- }
- else
- {
- res_scn_item->last_scn_idx = i;
- }
-
- return;
-}
-
-void
-nsfw_res_scan_proc (nsfw_res_mgr_item_cfg * res_scn_item)
-{
- (void) nsfw_res_flash_data (res_scn_item);
- switch (res_scn_item->scn_cfg.type)
- {
- case NSFW_RES_SCAN_ARRAY:
- nsfw_res_scan_array (res_scn_item);
- break;
- case NSFW_RES_SCAN_SPOOL:
- case NSFW_RES_SCAN_MBUF:
- nsfw_res_scan_mem (res_scn_item);
- break;
- default:
- break;
- }
-}
-
-int
-nsfw_res_scan_all (u32 timer_type, void *data)
-{
- NSFW_LOGDBG ("scan start!");
- struct timespec time_left = { NSFW_RES_SCAN_TVLAUE, 0 };
- g_scan_cfg.scan_timer =
- nsfw_timer_reg_timer (0, NULL, nsfw_res_scan_all, time_left);
-
- if (g_hbt_switch)
- {
- return TRUE;
- }
-
- int i;
- for (i = 0; i < NSFW_MAX_RES_SCAN_COUNT; i++)
- {
- /*last fun */
- if (NULL == g_all_res_can[i].scn_cfg.data)
- {
- break;
- }
-
- nsfw_res_scan_proc (&g_all_res_can[i]);
- }
-
- return TRUE;
-}
-
-static int nsfw_resmgr_module_init (void *param);
-static int
-nsfw_resmgr_module_init (void *param)
-{
- u8 proc_type = (u8) ((long long) param);
- NSFW_LOGINF ("res mgr module init]type=%u", proc_type);
- g_scan_cfg.scan_tvalue = NSFW_RES_SCAN_TVLAUE_DEF;
- switch (proc_type)
- {
- case NSFW_PROC_MAIN:
- {
- struct timespec time_left = { NSFW_RES_SCAN_TVLAUE, 0 };
- g_scan_cfg.scan_timer =
- nsfw_timer_reg_timer (0, NULL, nsfw_res_scan_all, time_left);
- return 0;
- }
- default:
- if (proc_type < NSFW_PROC_MAX)
- {
- break;
- }
- return -1;
- }
-
- return 0;
-}
-
-/* *INDENT-OFF* */
-NSFW_MODULE_NAME(NSFW_RES_MGR_MODULE)
-NSFW_MODULE_PRIORITY(99)
-NSFW_MODULE_INIT(nsfw_resmgr_module_init)
-/* *INDENT-ON* */
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif /* __cplusplus */
diff --git a/src/framework/common/mem_mgr/nsfw_shmem/nsfw_rshmem_mng.c b/src/framework/common/mem_mgr/nsfw_shmem/nsfw_rshmem_mng.c
deleted file mode 100644
index c29b108..0000000
--- a/src/framework/common/mem_mgr/nsfw_shmem/nsfw_rshmem_mng.c
+++ /dev/null
@@ -1,987 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include <stdint.h>
-#include "nstack_securec.h"
-#include "nstack_log.h"
-#include "nsfw_ring_fun.h"
-#include "nsfw_shmem_ring.h"
-#include "nsfw_shmem_mng.h"
-#include "common_mem_buf.h"
-#include "common_mem_common.h"
-
-#include "common_func.h"
-
-/*get the base address of msg data */
-#define NSFW_SHMEM_GET_DATA(pmsg, type) (type *)&((pmsg)->aidata[0])
-
-/*if input point is nun, just return null*/
-#define NSFW_POINT_CHK_RET_NULL(p, desc) \
- if (NULL == (p)) \
- { \
- NSCOMM_LOGERR("point check fail] desc_para=%s", desc); \
- return NULL; \
- }
-
-/*if input point is nun, just return err num*/
-#define NSFW_POINT_CHK_RET_ERR(p, desc) \
- if (NULL == (p)) \
- { \
- NSCOMM_LOGDBG("point check fail] desc_para=%s", desc); \
- return NSFW_MEM_ERR; \
- }
-
-/*if input point is nun, goto flag*/
-#define NSFW_POINT_CHK_RET_GOTO(p, gotoflag, desc) \
- if (NULL == (p)) \
- { \
- NSCOMM_LOGERR("point check fail] desc_para=%s", desc); \
- goto gotoflag; \
- }
-
-/*init the msg head*/
-#define NSFW_SHMEM_MSG_HEAD_INIT(pmsg, type, length) { \
- (pmsg)->usmsg_type = (type); \
- (pmsg)->uslength = (length); \
- }
-
-/*rsp msg head check, and if err goto*/
-#define NSFW_SHMEM_MSGHEAD_CHK_GOTO(pmsg, type, length, gotoflag) { \
- if (((type) != pmsg->usmsg_type) && ((length) != pmsg->uslength)) \
- { \
- NSCOMM_LOGERR("check fail] msgtype=%d, type_para=%d, len=%d", (pmsg->usmsg_type), (type), (length)); \
- goto gotoflag; \
- } \
- }
-
-/*rsp check the state*/
-#define NSFW_SHMEM_ACKSTATE_CHK_GOTO(expret, ret, expseg, seg, gotoflag) { \
- if (((ret) != (expret)) || ((expseg) != (seg))) \
- { \
- NSCOMM_LOGERR("ackstate check fail]msgack exp=%d, real=%d,eseg=%d, rseg=%d", (expret), (ret), (expseg), (seg)); \
- goto gotoflag; \
- } \
- }
-
-/*mzone msg init*/
-#define NSFW_SHMEM_MZONE_DATA_INIT(pdata, slength, seg, socketid) { \
- (pdata)->isocket_id = (socketid); \
- (pdata)->length = (slength); \
- (pdata)->usseq = (seg); \
- (pdata)->ireserv = 0; \
- }
-
-/*mbuf msg init*/
-#define NSFW_SHMEM_MBUF_DATA_INIT(pdata, seg, num, cashsize, priv_size, data_room, flag, socketid) { \
- (pdata)->usseq = (seg); \
- (pdata)->usnum = (num); \
- (pdata)->uscash_size = (cashsize); \
- (pdata)->uspriv_size = (priv_size); \
- (pdata)->usdata_room = (data_room); \
- (pdata)->enmptype = (flag); \
- (pdata)->isocket_id = (socketid); \
- (pdata)->ireserv = 0; \
- }
-
-/*mpool msg init*/
-#define NSFW_SHMEM_MPOOL_DATA_INIT(pdata, seg, num, eltsize, flag, socketid) { \
- (pdata)->usseq = (seg); \
- (pdata)->usnum = (num); \
- (pdata)->useltsize = (eltsize); \
- (pdata)->enmptype = (flag); \
- (pdata)->isocket_id = (socketid); \
- (pdata)->ireserv = 0; \
- }
-
-/*mring msg init*/
-#define NSFW_SHMEM_MRING_DATA_INIT(pdata, seg, num, flag, socketid) { \
- (pdata)->usseq = (seg); \
- (pdata)->usnum = (num); \
- (pdata)->enmptype = (flag); \
- (pdata)->isocket_id = (socketid); \
- (pdata)->ireserv = 0; \
- }
-
-#define NSFW_SHMEM_MSG_FREE(pmsg, prsp_msg) {\
- if (pmsg) \
- { \
- nsfw_mgr_msg_free(pmsg); \
- } \
- if (prsp_msg) \
- { \
- nsfw_mgr_msg_free(prsp_msg); \
- } \
-}
-
-/*
- * create a block memory by send a msg
- *
- */
-mzone_handle
-nsfw_memzone_remote_reserv (const i8 * name, size_t mlen, i32 socket_id)
-{
- /*msg point define */
- nsfw_mgr_msg *pmsg = NULL;
- nsfw_mgr_msg *prsp_msg = NULL;
-
- /*msg head point define */
- nsfw_shmem_msg_head *pdata_head = NULL;
-
- /*msg data point define */
- nsfw_shmem_reserv_req *pdata = NULL;
- nsfw_shmem_msg_head *pack_head = NULL;
-
- /*ack msg define */
- nsfw_shmem_ack *pack_data = NULL;
-
- mzone_handle hhandle = NULL;
- u8 ucret = TRUE;
- i32 iretval = NSFW_MEM_OK;
-
- //pmsg = nsfw_mgr_msg_alloc(MGR_MSG_MEM_ALLOC_REQ, NSFW_PROC_MASTER);
- pmsg = nsfw_mgr_msg_alloc (MGR_MSG_MEM_ALLOC_REQ, NSFW_PROC_MAIN);
- NSFW_POINT_CHK_RET_NULL (pmsg, "remote reserv pmsg alloc");
-
- prsp_msg = nsfw_mgr_null_rspmsg_alloc ();
- NSFW_POINT_CHK_RET_GOTO (prsp_msg, release, "remote reserv rspmsg alloc");
-
- /*msg head init */
- pdata_head = GET_USER_MSG (nsfw_shmem_msg_head, pmsg);
- NSFW_SHMEM_MSG_HEAD_INIT (pdata_head, NSFW_RESERV_REQ_MSG,
- sizeof (nsfw_shmem_reserv_req));
-
- /*msg data init */
- pdata = NSFW_SHMEM_GET_DATA (pdata_head, nsfw_shmem_reserv_req);
- iretval = STRCPY_S (pdata->aname, sizeof (pdata->aname), name);
- if (EOK != iretval)
- {
- NSCOMM_LOGERR ("reserv mem copy name fail] ret=%d", iretval);
- goto release;
- }
-
- /*fill msg data */
- NSFW_SHMEM_MZONE_DATA_INIT (pdata, mlen, (u16) 0, socket_id);
-
- ucret = nsfw_mgr_send_req_wait_rsp (pmsg, prsp_msg);
-
- if (FALSE == ucret)
- {
- NSCOMM_LOGERR ("reserv mem req rsp fail] ret=%u", ucret);
- goto release;
- }
-
- /*interrupt msg head */
- pack_head = GET_USER_MSG (nsfw_shmem_msg_head, prsp_msg);
- NSFW_SHMEM_MSGHEAD_CHK_GOTO (pack_head, NSFW_RESERV_ACK_MSG,
- sizeof (nsfw_shmem_ack), release);
-
- pack_data = NSFW_SHMEM_GET_DATA (pack_head, nsfw_shmem_ack);
- NSFW_SHMEM_ACKSTATE_CHK_GOTO (NSFW_MEM_ALLOC_SUCC, pack_data->cstate, 0,
- pack_data->usseq, release);
-
- hhandle = (mzone_handle) ADDR_SHTOL (pack_data->pbase_addr);
- NSCOMM_LOGDBG ("mem reserve] name=%s, handle=%p, seg=%u", name, hhandle,
- pack_data->usseq);
-release:
- NSFW_SHMEM_MSG_FREE (pmsg, prsp_msg);
- return hhandle;
-}
-
-/*
- *create some memories by send a msg
- */
-i32
-nsfw_memzone_remote_reserv_v (nsfw_mem_zone * pmeminfo,
- mzone_handle * paddr_array, i32 inum, pid_t pid)
-{
- /*msg point define */
- nsfw_mgr_msg *pmsg = NULL;
- nsfw_mgr_msg *prsp_msg = NULL;
- nsfw_shmem_msg_head *pdata_head = NULL;
- nsfw_shmem_reserv_req *pdata = NULL;
- nsfw_shmem_reserv_req *ptempdata = NULL;
- nsfw_shmem_msg_head *pack_head = NULL;
-
- nsfw_shmem_ack *pack_data = NULL;
- u8 ucret = TRUE;
- i32 iretval = NSFW_MEM_OK;
- i32 icount = 0;
- i32 itindex = 0;
- i32 iindex = 0;
- u16 ussegbase = 0;
- u16 ustempv = 0;
- i32 ieltnum = 0;
- i32 ieltnum_max =
- (NSFW_MGR_MSG_BODY_LEN -
- sizeof (nsfw_shmem_msg_head)) / sizeof (nsfw_shmem_reserv_req);
-
- //pmsg = nsfw_mgr_msg_alloc(MGR_MSG_MEM_ALLOC_REQ, NSFW_PROC_MASTER);
- pmsg = nsfw_mgr_msg_alloc (MGR_MSG_MEM_ALLOC_REQ, NSFW_PROC_MAIN);
- NSFW_POINT_CHK_RET_GOTO (pmsg, err, "remote reserv_v msg alloc");
-
- prsp_msg = nsfw_mgr_null_rspmsg_alloc ();
- NSFW_POINT_CHK_RET_GOTO (prsp_msg, err, "remote reserv_v rspmsg alloc");
-
- pdata_head = GET_USER_MSG (nsfw_shmem_msg_head, pmsg);
-
- ptempdata = pdata = NSFW_SHMEM_GET_DATA (pdata_head, nsfw_shmem_reserv_req);
-
- do
- {
- icount++;
- ieltnum++;
-
- if (((icount % ieltnum_max) == 0) || (icount >= inum))
- {
- NSFW_SHMEM_MSG_HEAD_INIT (pdata_head, NSFW_RESERV_REQ_MSG,
- ieltnum * sizeof (nsfw_shmem_reserv_req));
-
- itindex = icount - 1;
- int retVal =
- SPRINTF_S (ptempdata->aname, sizeof (ptempdata->aname), "%s_%x",
- pmeminfo[itindex].stname.aname, pid);
- if (-1 == retVal)
- {
- NSCOMM_LOGERR ("SPRINTF_S failed]ret=%d", retVal);
- }
- NSFW_SHMEM_MZONE_DATA_INIT (ptempdata, pmeminfo[itindex].length,
- (u16) itindex,
- pmeminfo[itindex].isocket_id);
-
- ucret = nsfw_mgr_send_req_wait_rsp (pmsg, prsp_msg);
-
- if (FALSE == ucret)
- {
- NSCOMM_LOGERR ("reserv v mem req rsp fail] ret=%u", ucret);
- goto err;
- }
-
- pack_head = GET_USER_MSG (nsfw_shmem_msg_head, prsp_msg);
- NSFW_SHMEM_MSGHEAD_CHK_GOTO (pack_head, NSFW_RESERV_ACK_MSG,
- ieltnum * sizeof (nsfw_shmem_ack),
- err);
-
- pack_data = NSFW_SHMEM_GET_DATA (pack_head, nsfw_shmem_ack);
-
- for (iindex = 0; iindex < ieltnum; iindex++)
- {
- ustempv = ussegbase + iindex;
-
- NSFW_SHMEM_ACKSTATE_CHK_GOTO (NSFW_MEM_ALLOC_SUCC,
- pack_data->cstate, ustempv,
- (u16) pack_data->usseq, err);
-
- paddr_array[ustempv] = ADDR_SHTOL (pack_data->pbase_addr);
- NSCOMM_LOGDBG ("remote reserve]index=%u, seg=%u, handle=%p",
- ustempv, pack_data->usseq, paddr_array[ustempv]);
- pack_data++;
- }
-
- ussegbase = icount;
- ieltnum = 0;
- ptempdata = pdata;
- }
- else
- {
- itindex = icount - 1;
- int retVal =
- SPRINTF_S (ptempdata->aname, sizeof (ptempdata->aname), "%s_%x",
- pmeminfo[itindex].stname.aname, pid);
- if (-1 == retVal)
- {
- NSCOMM_LOGERR ("SPRINTF_S failed]ret=%d", retVal);
- }
- NSFW_SHMEM_MZONE_DATA_INIT (ptempdata, pmeminfo[itindex].length,
- (u16) itindex,
- pmeminfo[itindex].isocket_id);
- ptempdata++;
- }
- }
- while (icount < inum);
-
- iretval = NSFW_MEM_OK;
- goto free;
-
-err:
- iretval = NSFW_MEM_ERR;
-free:
- NSFW_SHMEM_MSG_FREE (pmsg, prsp_msg);
- return iretval;
-}
-
-/*
- *release a block memory with name by send msg
- */
-i32
-nsfw_remote_free (const i8 * name, nsfw_mem_struct_type entype)
-{
- /*msg point define */
- nsfw_mgr_msg *pmsg = NULL;
- nsfw_mgr_msg *prsp_msg = NULL;
-
- nsfw_shmem_msg_head *pdata_head = NULL;
-
- nsfw_shmem_free_req *pdata = NULL;
-
- nsfw_shmem_msg_head *pack_head = NULL;
- nsfw_shmem_ack *pack_data = NULL;
- u8 ucret = TRUE;
- i32 iretval = NSFW_MEM_OK;
-
- pmsg = nsfw_mgr_msg_alloc (MGR_MSG_MEM_ALLOC_REQ, NSFW_PROC_MAIN);
- NSFW_POINT_CHK_RET_ERR (pmsg, "remote free msg alloc");
-
- prsp_msg = nsfw_mgr_null_rspmsg_alloc ();
- NSFW_POINT_CHK_RET_GOTO (prsp_msg, terr, "remote free rspmsg alloc");
-
- pdata_head = GET_USER_MSG (nsfw_shmem_msg_head, pmsg);
- NSFW_SHMEM_MSG_HEAD_INIT (pdata_head, NSFW_RELEASE_REQ_MSG,
- sizeof (nsfw_shmem_free_req));
-
- pdata = NSFW_SHMEM_GET_DATA (pdata_head, nsfw_shmem_free_req);
- if (EOK != STRCPY_S (pdata->aname, sizeof (pdata->aname), name))
- {
- NSCOMM_LOGERR ("STRCPY_S failed]name=%s", name);
- }
- pdata->usseq = 0;
- pdata->ustype = entype;
- pdata->ireserv = 0;
-
- ucret = nsfw_mgr_send_req_wait_rsp (pmsg, prsp_msg);
-
- if (FALSE == ucret)
- {
- NSCOMM_LOGERR ("free mem req rsp fail] ret=%u", ucret);
- goto release;
- }
-
- pack_head = GET_USER_MSG (nsfw_shmem_msg_head, prsp_msg);
- NSFW_SHMEM_MSGHEAD_CHK_GOTO (pack_head, NSFW_RELEASE_ACK_MSG,
- sizeof (nsfw_shmem_ack), terr);
-
- pack_data = NSFW_SHMEM_GET_DATA (pack_head, nsfw_shmem_ack);
- NSFW_SHMEM_ACKSTATE_CHK_GOTO (NSFW_MEM_ALLOC_SUCC, pack_data->cstate, 0,
- pack_data->usseq, terr);
-
- iretval = NSFW_MEM_OK;
- goto release;
-terr:
- iretval = NSFW_MEM_ERR;
-release:
- NSFW_SHMEM_MSG_FREE (pmsg, prsp_msg);
- return iretval;
-}
-
-/*
- *create a mbuf pool by send a msg
- */
-mpool_handle
-nsfw_remote_shmem_mbf_create (const i8 * name, unsigned n,
- unsigned cache_size, unsigned priv_size,
- unsigned data_room_size, i32 socket_id,
- nsfw_mpool_type entype)
-{
- /*msg point define */
- nsfw_mgr_msg *pmsg = NULL;
- nsfw_mgr_msg *prsp_msg = NULL;
- nsfw_shmem_msg_head *pdata_head = NULL;
- nsfw_shmem_mbuf_req *pdata = NULL;
- nsfw_shmem_msg_head *tpack_head = NULL;
- nsfw_shmem_ack *tpack_data = NULL;
- mpool_handle hhandle = NULL;
- u8 ucret = TRUE;
- i32 iretval = NSFW_MEM_OK;
-
- pmsg = nsfw_mgr_msg_alloc (MGR_MSG_MEM_ALLOC_REQ, NSFW_PROC_MAIN);
- NSFW_POINT_CHK_RET_NULL (pmsg, "remote mbf create pmsg alloc");
-
- prsp_msg = nsfw_mgr_null_rspmsg_alloc ();
- NSFW_POINT_CHK_RET_GOTO (prsp_msg, release, "remote mbf create msg alloc");
-
- pdata_head = GET_USER_MSG (nsfw_shmem_msg_head, pmsg);
- NSFW_SHMEM_MSG_HEAD_INIT (pdata_head, NSFW_MBUF_REQ_MSG,
- sizeof (nsfw_shmem_mbuf_req));
-
- pdata = NSFW_SHMEM_GET_DATA (pdata_head, nsfw_shmem_mbuf_req);
- iretval = STRCPY_S (pdata->aname, sizeof (pdata->aname), name);
- if (EOK != iretval)
- {
- NSCOMM_LOGERR ("mbf create name cpy fail] ret=%d", iretval);
- goto release;
- }
-
- NSFW_SHMEM_MBUF_DATA_INIT (pdata, 0, n, cache_size, priv_size,
- data_room_size, (u16) entype, socket_id);
-
- ucret = nsfw_mgr_send_req_wait_rsp (pmsg, prsp_msg);
-
- if (FALSE == ucret)
- {
- NSCOMM_LOGERR ("mbf create mem req rsp fail] ret=%u", ucret);
- goto release;
- }
-
- tpack_head = GET_USER_MSG (nsfw_shmem_msg_head, prsp_msg);
- NSFW_SHMEM_MSGHEAD_CHK_GOTO (tpack_head, NSFW_MBUF_ACK_MSG,
- sizeof (nsfw_shmem_ack), release);
-
- tpack_data = NSFW_SHMEM_GET_DATA (tpack_head, nsfw_shmem_ack);
- NSFW_SHMEM_ACKSTATE_CHK_GOTO (NSFW_MEM_ALLOC_SUCC, tpack_data->cstate, 0,
- tpack_data->usseq, release);
-
- hhandle = ADDR_SHTOL (tpack_data->pbase_addr);
- NSCOMM_LOGDBG ("mbf create] name=%s, handle=%p, seg=%u", name, hhandle,
- tpack_data->usseq);
-release:
- NSFW_SHMEM_MSG_FREE (pmsg, prsp_msg);
- return hhandle;
-}
-
-/*
- *create some mbuf pools
- */
-i32
-nsfw_remote_shmem_mbf_createv (nsfw_mem_mbfpool * pmbfname,
- mpool_handle * phandle_array, i32 inum,
- pid_t pid)
-{
- /*msg point define */
- nsfw_mgr_msg *mbpmsg = NULL;
- nsfw_mgr_msg *prsp_msg = NULL;
- nsfw_shmem_msg_head *pdata_head = NULL;
-
- nsfw_shmem_mbuf_req *pdata = NULL;
- nsfw_shmem_mbuf_req *ptempdata = NULL;
-
- nsfw_shmem_msg_head *pack_head = NULL;
-
- nsfw_shmem_ack *pack_data = NULL;
- mpool_handle hhandle = NULL;
- u8 ucret = TRUE;
- i32 iretval = NSFW_MEM_OK;
- i32 icount = 0;
- i32 itindex = 0;
- i32 iindex = 0;
- i32 isegbase = 0;
- i32 ieltnum = 0;
- i32 ieltnum_max =
- (NSFW_MGR_MSG_BODY_LEN -
- sizeof (nsfw_shmem_msg_head)) / sizeof (nsfw_shmem_mbuf_req);
-
- mbpmsg = nsfw_mgr_msg_alloc (MGR_MSG_MEM_ALLOC_REQ, NSFW_PROC_MAIN);
- NSFW_POINT_CHK_RET_GOTO (mbpmsg, lerr, "remote mbf createv msg alloc");
-
- prsp_msg = nsfw_mgr_null_rspmsg_alloc ();
- NSFW_POINT_CHK_RET_GOTO (prsp_msg, lerr, "remote mbf createv rspmsg alloc");
-
- pdata_head = GET_USER_MSG (nsfw_shmem_msg_head, mbpmsg);
-
- ptempdata = pdata = NSFW_SHMEM_GET_DATA (pdata_head, nsfw_shmem_mbuf_req);
-
- do
- {
- icount++;
- ieltnum++;
-
- if (((icount % ieltnum_max) == 0) || (icount >= inum))
- {
- NSFW_SHMEM_MSG_HEAD_INIT (pdata_head, NSFW_MBUF_REQ_MSG,
- ieltnum * sizeof (nsfw_shmem_mbuf_req));
-
- /*fill msg data */
- itindex = icount - 1;
- if (-1 ==
- SPRINTF_S (ptempdata->aname, sizeof (ptempdata->aname), "%s_%x",
- pmbfname[itindex].stname.aname, pid))
- {
- NSCOMM_LOGERR ("SPRINTF_S failed]");
- goto lerr;
- }
- NSFW_SHMEM_MBUF_DATA_INIT (ptempdata, (u16) itindex,
- pmbfname[itindex].usnum,
- pmbfname[itindex].uscash_size,
- pmbfname[itindex].uspriv_size,
- pmbfname[itindex].usdata_room,
- pmbfname[itindex].enmptype,
- pmbfname[itindex].isocket_id);
-
- ucret = nsfw_mgr_send_req_wait_rsp (mbpmsg, prsp_msg);
-
- if (FALSE == ucret)
- {
- NSCOMM_LOGERR ("mbf createv mem req rsp fail] ret=%d", ucret);
- goto lerr;
- }
-
- /*interrupt msg head */
- pack_head = GET_USER_MSG (nsfw_shmem_msg_head, prsp_msg);
- NSFW_SHMEM_MSGHEAD_CHK_GOTO (pack_head, NSFW_MBUF_ACK_MSG,
- ieltnum * sizeof (nsfw_shmem_ack),
- lerr);
-
- pack_data = NSFW_SHMEM_GET_DATA (pack_head, nsfw_shmem_ack);
-
- for (iindex = 0; iindex < ieltnum; iindex++)
- {
- NSFW_SHMEM_ACKSTATE_CHK_GOTO (NSFW_MEM_ALLOC_SUCC,
- pack_data->cstate,
- (isegbase + iindex),
- (u16) pack_data->usseq, lerr);
- phandle_array[isegbase + iindex] =
- ADDR_SHTOL (pack_data->pbase_addr);
- NSCOMM_LOGDBG ("mbf createv] seg=%d, handle=%p",
- pack_data->usseq, hhandle);
- pack_data++;
- }
-
- isegbase = icount;
- ieltnum = 0;
- ptempdata = pdata;
- }
- else
- {
- itindex = icount - 1;
- if (-1 ==
- SPRINTF_S (ptempdata->aname, sizeof (ptempdata->aname), "%s_%x",
- pmbfname[itindex].stname.aname, pid))
- {
- NSCOMM_LOGERR ("SPRINTF_S failed]");
- goto lerr;
- }
- NSFW_SHMEM_MBUF_DATA_INIT (ptempdata, (u16) itindex,
- pmbfname[itindex].usnum,
- pmbfname[itindex].uscash_size,
- pmbfname[itindex].uspriv_size,
- pmbfname[itindex].usdata_room,
- pmbfname[itindex].enmptype,
- pmbfname[itindex].isocket_id);
- ptempdata++;
- }
- }
- while (icount < inum);
-
- /*release memory */
- iretval = NSFW_MEM_OK;
- goto release;
-
-lerr:
- iretval = NSFW_MEM_ERR;
-release:
- NSFW_SHMEM_MSG_FREE (mbpmsg, prsp_msg);
- return iretval;
-}
-
-/*
- *create a simpile pool
- */
-mring_handle
-nsfw_remote_shmem_mpcreate (const char *name, unsigned int n,
- unsigned int elt_size, i32 socket_id,
- nsfw_mpool_type entype)
-{
- /*msg point define */
- nsfw_mgr_msg *pmsg = NULL;
- nsfw_mgr_msg *prsp_msg = NULL;
- nsfw_shmem_msg_head *pdata_head = NULL;
- nsfw_shmem_sppool_req *pdata = NULL;
- nsfw_shmem_msg_head *mppack_head = NULL;
- nsfw_shmem_ack *mppack_data = NULL;
- mring_handle hhandle = NULL;
- u8 ucret = TRUE;
- i32 iretval = NSFW_MEM_OK;
-
- pmsg = nsfw_mgr_msg_alloc (MGR_MSG_MEM_ALLOC_REQ, NSFW_PROC_MAIN);
- NSFW_POINT_CHK_RET_NULL (pmsg, "remote mbf mpcreate pmsg alloc");
-
- prsp_msg = nsfw_mgr_null_rspmsg_alloc ();
- NSFW_POINT_CHK_RET_GOTO (prsp_msg, release, "remote mpcreate rspmsg alloc");
-
- /*init msg head */
- pdata_head = GET_USER_MSG (nsfw_shmem_msg_head, pmsg);
- NSFW_SHMEM_MSG_HEAD_INIT (pdata_head, NSFW_SPPOOL_REQ_MSG,
- sizeof (nsfw_shmem_sppool_req));
-
- /*fill msg data */
- pdata = NSFW_SHMEM_GET_DATA (pdata_head, nsfw_shmem_sppool_req);
- iretval = STRCPY_S (pdata->aname, sizeof (pdata->aname), name);
- if (EOK != iretval)
- {
- NSCOMM_LOGERR ("mp create copy name fail] ret=%d", iretval);
- goto release;
- }
-
- /*fill msg data */
- NSFW_SHMEM_MPOOL_DATA_INIT (pdata, 0, n, elt_size, entype, socket_id);
-
- ucret = nsfw_mgr_send_req_wait_rsp (pmsg, prsp_msg);
-
- if (FALSE == ucret)
- {
- NSCOMM_LOGERR ("mp create rsp fail] ret=%d", ucret);
- goto release;
- }
-
- /*get msg head */
- mppack_head = GET_USER_MSG (nsfw_shmem_msg_head, prsp_msg);
- NSFW_SHMEM_MSGHEAD_CHK_GOTO (mppack_head, NSFW_SPPOOL_ACK_MSG,
- sizeof (nsfw_shmem_ack), release);
-
- mppack_data = NSFW_SHMEM_GET_DATA (mppack_head, nsfw_shmem_ack);
- NSFW_SHMEM_ACKSTATE_CHK_GOTO (NSFW_MEM_ALLOC_SUCC, mppack_data->cstate, 0,
- mppack_data->usseq, release);
-
- hhandle = ADDR_SHTOL (mppack_data->pbase_addr);
- NSCOMM_LOGDBG ("mpcreate] name=%s, handle=%p, seg=%d", name, hhandle,
- mppack_data->usseq);
-release:
- NSFW_SHMEM_MSG_FREE (pmsg, prsp_msg);
- return hhandle;
-}
-
-/*
- *create some simpile pools by send a msg
- */
-i32
-nsfw_remote_shmem_mpcreatev (nsfw_mem_sppool * pmpinfo,
- mring_handle * pringhandle_array, i32 inum,
- pid_t pid)
-{
- /*msg point define */
- nsfw_mgr_msg *pmsg = NULL;
- nsfw_mgr_msg *prsp_msg = NULL;
-
- /*msg head define */
- nsfw_shmem_msg_head *pdata_head = NULL;
-
- /*msg data define */
- nsfw_shmem_sppool_req *pdata = NULL;
- nsfw_shmem_sppool_req *ptempdata = NULL;
-
- /*ack msg define */
- nsfw_shmem_msg_head *pack_head = NULL;
-
- nsfw_shmem_ack *pack_data = NULL;
- mring_handle hhandle = NULL;
- u8 ucret = TRUE;
- i32 iretval = NSFW_MEM_OK;
- i32 icount = 0;
- i32 itindex = 0;
- i32 iindex = 0;
- i32 isegbase = 0;
- i32 ieltnum = 0;
- /*the max members that a msg can take */
- i32 ieltnum_max =
- (NSFW_MGR_MSG_BODY_LEN -
- sizeof (nsfw_shmem_msg_head)) / sizeof (nsfw_shmem_sppool_req);
-
- /*alloc a msg */
- //pmsg = nsfw_mgr_msg_alloc(MGR_MSG_MEM_ALLOC_REQ, NSFW_PROC_MASTER);
- pmsg = nsfw_mgr_msg_alloc (MGR_MSG_MEM_ALLOC_REQ, NSFW_PROC_MAIN);
- NSFW_POINT_CHK_RET_GOTO (pmsg, mperr, "remote mpcreatev pmsg alloc");
-
- /*alloc rsp msg */
- prsp_msg = nsfw_mgr_null_rspmsg_alloc ();
- NSFW_POINT_CHK_RET_GOTO (prsp_msg, mperr, "remote mpcreatev rspmsg alloc");
-
- pdata_head = GET_USER_MSG (nsfw_shmem_msg_head, pmsg);
-
- ptempdata = pdata = NSFW_SHMEM_GET_DATA (pdata_head, nsfw_shmem_sppool_req);
-
- do
- {
- icount++;
- ieltnum++;
-
- /*if the element num reach the bigest, or already send all, just deal */
- if (((icount % ieltnum_max) == 0) || (icount >= inum))
- {
- /*init msg header */
- NSFW_SHMEM_MSG_HEAD_INIT (pdata_head, NSFW_SPPOOL_REQ_MSG,
- ieltnum * sizeof (nsfw_shmem_sppool_req));
-
- /*fill the msg data */
- itindex = icount - 1;
-
- int retVal =
- SPRINTF_S (ptempdata->aname, sizeof (ptempdata->aname), "%s_%x",
- pmpinfo[itindex].stname.aname, pid);
- if (-1 == retVal)
- {
- NSCOMM_LOGERR ("SPRINTF_S fail]ret=%d", retVal);
- goto mperr;
- }
- NSFW_SHMEM_MPOOL_DATA_INIT (ptempdata, itindex,
- pmpinfo[itindex].usnum,
- pmpinfo[itindex].useltsize,
- pmpinfo[itindex].enmptype,
- pmpinfo[itindex].isocket_id);
-
- ucret = nsfw_mgr_send_req_wait_rsp (pmsg, prsp_msg);
-
- if (FALSE == ucret)
- {
- NSCOMM_LOGERR ("mpcreatev create fail] ret=%u", ucret);
- goto mperr;
- }
-
- /*interrupt mgs head */
- pack_head = GET_USER_MSG (nsfw_shmem_msg_head, prsp_msg);
- NSFW_SHMEM_MSGHEAD_CHK_GOTO (pack_head, NSFW_SPPOOL_ACK_MSG,
- ieltnum * sizeof (nsfw_shmem_ack),
- mperr);
-
- pack_data = NSFW_SHMEM_GET_DATA (pack_head, nsfw_shmem_ack);
-
- for (iindex = 0; iindex < ieltnum; iindex++)
- {
- NSFW_SHMEM_ACKSTATE_CHK_GOTO (NSFW_MEM_ALLOC_SUCC,
- pack_data->cstate,
- (isegbase + iindex),
- (u16) pack_data->usseq, mperr);
- pringhandle_array[isegbase + iindex] =
- ADDR_SHTOL (pack_data->pbase_addr);
- NSCOMM_LOGDBG ("mpcreatev] seg=%u, handle=%p", pack_data->usseq,
- hhandle);
- pack_data++;
- }
-
- isegbase = icount;
- ieltnum = 0;
- ptempdata = pdata;
- }
- else
- {
- itindex = icount - 1;
- int retVal =
- SPRINTF_S (ptempdata->aname, sizeof (ptempdata->aname), "%s_%x",
- pmpinfo[itindex].stname.aname, pid);
- if (-1 == retVal)
- {
- NSCOMM_LOGERR ("SPRINTF_S fail]ret=%d", retVal);
- goto mperr;
- }
- NSFW_SHMEM_MPOOL_DATA_INIT (ptempdata, itindex,
- pmpinfo[itindex].usnum,
- pmpinfo[itindex].useltsize,
- pmpinfo[itindex].enmptype,
- pmpinfo[itindex].isocket_id);
-
- ptempdata++;
- }
- }
- while (icount < inum);
-
- /*release the memory */
- iretval = NSFW_MEM_OK;
- goto release;
-
-mperr:
- iretval = NSFW_MEM_ERR;
-release:
- NSFW_SHMEM_MSG_FREE (pmsg, prsp_msg);
- return iretval;
-}
-
-/*
- *create a ring
- */
-mring_handle
-nsfw_remote_shmem_ringcreate (const char *name, unsigned int n, i32 socket_id,
- nsfw_mpool_type entype)
-{
- /*msg point define */
- nsfw_mgr_msg *pmsg = NULL;
- nsfw_mgr_msg *prsp_msg = NULL;
-
- /*msg head define */
- nsfw_shmem_msg_head *pdata_head = NULL;
-
- /*msg data define */
- nsfw_shmem_ring_req *pdata = NULL;
- /*ack msg define */
- nsfw_shmem_msg_head *pack_head = NULL;
- nsfw_shmem_ack *ppack_data = NULL;
- mring_handle hhandle = NULL;
- u8 ucret = TRUE;
- i32 iretval = NSFW_MEM_OK;
-
- //pmsg = nsfw_mgr_msg_alloc(MGR_MSG_MEM_ALLOC_REQ, NSFW_PROC_MASTER);
- pmsg = nsfw_mgr_msg_alloc (MGR_MSG_MEM_ALLOC_REQ, NSFW_PROC_MAIN);
- NSFW_POINT_CHK_RET_NULL (pmsg, "remote ringcreate pmsg alloc");
-
- prsp_msg = nsfw_mgr_null_rspmsg_alloc ();
- NSFW_POINT_CHK_RET_GOTO (prsp_msg, release,
- "remote ringcreate rspmsg alloc");
-
- /*fill msg head */
- pdata_head = GET_USER_MSG (nsfw_shmem_msg_head, pmsg);
- NSFW_SHMEM_MSG_HEAD_INIT (pdata_head, NSFW_RING_REQ_MSG,
- sizeof (nsfw_shmem_ring_req));
-
- /*fill msg data */
- pdata = NSFW_SHMEM_GET_DATA (pdata_head, nsfw_shmem_ring_req);
- iretval = STRCPY_S (pdata->aname, sizeof (pdata->aname), name);
- if (EOK != iretval)
- {
- NSCOMM_LOGERR ("ring create cpy name fail] ret=%d", iretval);
- goto release;
- }
-
- /*fill msg data */
- NSFW_SHMEM_MRING_DATA_INIT (pdata, 0, n, entype, socket_id);
-
- ucret = nsfw_mgr_send_req_wait_rsp (pmsg, prsp_msg);
-
- if (FALSE == ucret)
- {
- NSCOMM_LOGERR ("ring create rsp fail] ret=%d", ucret);
- goto release;
- }
-
- /*interrupt mgs head */
- pack_head = GET_USER_MSG (nsfw_shmem_msg_head, prsp_msg);
- NSFW_SHMEM_MSGHEAD_CHK_GOTO (pack_head, NSFW_RING_ACK_MSG,
- sizeof (nsfw_shmem_ack), release);
-
- ppack_data = NSFW_SHMEM_GET_DATA (pack_head, nsfw_shmem_ack);
- NSFW_SHMEM_ACKSTATE_CHK_GOTO (NSFW_MEM_ALLOC_SUCC, ppack_data->cstate, 0,
- ppack_data->usseq, release);
-
- hhandle = ADDR_SHTOL (ppack_data->pbase_addr);
- NSCOMM_LOGDBG ("ring create] name=%s, handle=%p, seg=%u", name, hhandle,
- ppack_data->usseq);
-release:
- NSFW_SHMEM_MSG_FREE (pmsg, prsp_msg);
- return hhandle;
-}
-
-/*
- *create a mem pool that the members are rings by send a msg
- *ieltnum:the num of ring member
- *iringnum:the num of ring in simple mem pool
- *entype:the default the of ring
- */
-i32
-nsfw_remote_shmem_ringcreatev (const char *name, i32 ieltnum,
- mring_handle * pringhandle_array, i32 iringnum,
- i32 socket_id, nsfw_mpool_type entype)
-{
- unsigned int useltsize = 0;
- mring_handle nhandle = NULL;
- i32 icount = 0;
- i32 n = 0;
- uint64_t baseaddr = 0;
- uint64_t endaddr = 0;
- /*the num of ring member must be power of 2 */
- unsigned int usnum = common_mem_align32pow2 (ieltnum + 1);
-
- useltsize =
- sizeof (struct nsfw_mem_ring) + usnum * sizeof (union RingData_U);
- nhandle =
- nsfw_remote_shmem_mpcreate (name, iringnum, useltsize, socket_id,
- NSFW_MRING_SPSC);
- NSFW_POINT_CHK_RET_ERR (nhandle, "remote ringcreatev msg alloc");
-
- n =
- nsfw_shmem_ring_sc_dequeuev (nhandle, (void **) pringhandle_array,
- iringnum);
-
- if (n != iringnum)
- {
- NSCOMM_LOGERR ("ring dequeue fail] ringnum=%d, retnum=%d", iringnum, n);
- return NSFW_MEM_ERR;
- }
-
- nsfw_shmem_ring_baseaddr_query (&baseaddr, &endaddr);
-
- for (icount = 0; icount < iringnum; icount++)
- {
- nsfw_mem_ring_init (pringhandle_array[icount], usnum, (void *) baseaddr,
- NSFW_SHMEM, entype);
- }
-
- return NSFW_MEM_OK;
-}
-
-/*
- *look up a msg by send a msg
- */
-void *
-nsfw_remote_shmem_lookup (const i8 * name, nsfw_mem_struct_type entype)
-{
- /*msg point define */
- nsfw_mgr_msg *pmsg = NULL;
- nsfw_mgr_msg *prsp_msg = NULL;
- void *addr = NULL;
- /*msg head data define */
- nsfw_shmem_msg_head *pdata_head = NULL;
-
- /*msg data define */
- nsfw_shmem_lookup_req *pdata = NULL;
-
- /*ack msg define */
- nsfw_shmem_msg_head *pack_head = NULL;
- nsfw_shmem_ack *lpack_data = NULL;
- u8 ucret = TRUE;
-
- pmsg = nsfw_mgr_msg_alloc (MGR_MSG_MEM_ALLOC_REQ, NSFW_PROC_MAIN);
- NSFW_POINT_CHK_RET_NULL (pmsg, "remote lookup pmsg alloc");
-
- prsp_msg = nsfw_mgr_null_rspmsg_alloc ();
- NSFW_POINT_CHK_RET_GOTO (prsp_msg, perr, "remote lookup rspmsg alloc");
-
- /*msg head init */
- pdata_head = GET_USER_MSG (nsfw_shmem_msg_head, pmsg);
- NSFW_SHMEM_MSG_HEAD_INIT (pdata_head, NSFW_MEM_LOOKUP_REQ_MSG,
- sizeof (nsfw_shmem_lookup_req));
-
- pdata = NSFW_SHMEM_GET_DATA (pdata_head, nsfw_shmem_lookup_req);
- if (EOK != STRCPY_S (pdata->aname, sizeof (pdata->aname), name))
- {
- NSCOMM_LOGERR ("STRCPY_S failed]name=%s", name);
- }
- pdata->usseq = 0;
- pdata->ustype = entype;
- pdata->ireserv = 0;
-
- ucret = nsfw_mgr_send_req_wait_rsp (pmsg, prsp_msg);
-
- if (FALSE == ucret)
- {
- NSCOMM_LOGERR ("mem lookup fail] ret=%u", ucret);
- goto release;
- }
-
- /*interrupt mgs head */
- pack_head = GET_USER_MSG (nsfw_shmem_msg_head, prsp_msg);
- NSFW_SHMEM_MSGHEAD_CHK_GOTO (pack_head, NSFW_MEM_LOOKUP_ACK_MSG,
- sizeof (nsfw_shmem_ack), perr);
-
- lpack_data = NSFW_SHMEM_GET_DATA (pack_head, nsfw_shmem_ack);
- NSFW_SHMEM_ACKSTATE_CHK_GOTO (NSFW_MEM_ALLOC_SUCC, lpack_data->cstate, 0,
- lpack_data->usseq, perr);
-
- addr = ADDR_SHTOL (lpack_data->pbase_addr);
- NSCOMM_LOGDBG ("shmem lookup] name=%s, handle=%p, seg=%u", name, addr,
- lpack_data->usseq);
- goto release;
-perr:
- addr = NULL;
-
-release:
- NSFW_SHMEM_MSG_FREE (pmsg, prsp_msg);
- return addr;
-}
diff --git a/src/framework/common/mem_mgr/nsfw_shmem/nsfw_rshmem_mng.h b/src/framework/common/mem_mgr/nsfw_shmem/nsfw_rshmem_mng.h
deleted file mode 100644
index 60c4115..0000000
--- a/src/framework/common/mem_mgr/nsfw_shmem/nsfw_rshmem_mng.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _NSFW_RSHMEM_MNG_H
-#define _NSFW_RSHMEM_MNG_H
-
-mzone_handle nsfw_memzone_remote_reserv (const i8 * name, size_t mlen,
- i32 socket_id);
-i32 nsfw_memzone_remote_reserv_v (nsfw_mem_zone * pmeminfo,
- mzone_handle * paddr_array, i32 inum,
- pid_t pid);
-i32 nsfw_remote_free (const i8 * name, nsfw_mem_struct_type entype);
-mpool_handle nsfw_remote_shmem_mbf_create (const i8 * name, unsigned int n,
- unsigned cache_size,
- unsigned priv_size,
- unsigned data_room_size,
- i32 socket_id,
- nsfw_mpool_type entype);
-i32 nsfw_remote_shmem_mbf_createv (nsfw_mem_mbfpool * pmbfname,
- mpool_handle * phandle_array, i32 inum,
- pid_t pid);
-mring_handle nsfw_remote_shmem_mpcreate (const char *name, unsigned int n,
- unsigned int elt_size, i32 socket_id,
- nsfw_mpool_type entype);
-i32 nsfw_remote_shmem_mpcreatev (nsfw_mem_sppool * pmpinfo,
- mring_handle * pringhandle_array, i32 inum,
- pid_t pid);
-mring_handle nsfw_remote_shmem_ringcreate (const char *name, unsigned int n,
- i32 socket_id,
- nsfw_mpool_type entype);
-i32 nsfw_remote_shmem_ringcreatev (const char *name, i32 ieltnum,
- mring_handle * pringhandle_array,
- i32 iringnum, i32 socket_id,
- nsfw_mpool_type entype);
-
-void *nsfw_remote_shmem_lookup (const i8 * name, nsfw_mem_struct_type entype);
-
-#endif
diff --git a/src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_mdesc.c b/src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_mdesc.c
deleted file mode 100644
index 2e9c969..0000000
--- a/src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_mdesc.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "nsfw_mem_desc.h"
-#include "nsfw_shmem_mng.h"
-#include "nsfw_shmem_mdesc.h"
-
-/*the inferaces accessing memory*/
-nsfw_mem_ops g_shmem_ops = {
- nsfw_shmem_init,
- nsfw_shmem_destroy,
- nsfw_shmem_create,
- nsfw_shmem_createv,
- nsfw_shmem_lookup,
- nsfw_shmem_release,
- nsfw_shmem_mbfmpcreate,
- nsfw_shmem_mbfmpcreatev,
- nsfw_shmem_mbfalloc,
- nsfw_shmem_mbffree,
- nsfw_shmem_mbfmplookup,
- nsfw_shmem_mbfmprelease,
- nsfw_shmem_spcreate,
- nsfw_shmem_spcreatev,
- nswf_shmem_sp_ringcreate,
- nsfw_shmem_sprelease,
- nsfw_shmem_sp_lookup,
- nsfw_shmem_ringcreate,
- nsfw_shmem_ring_lookup,
- nsfw_shmem_ringrelease,
- nsfw_shmem_static,
- nsfw_shmem_mbuf_recycle,
- nsfw_shmem_sp_iterator,
- nsfw_shmem_mbuf_iterator
-};
diff --git a/src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_mdesc.h b/src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_mdesc.h
deleted file mode 100644
index afd9e29..0000000
--- a/src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_mdesc.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _NSFW_SHMEM_MDESC_H_
-#define _NSFW_SHMEM_MDESC_H_
-
-extern nsfw_mem_ops g_shmem_ops;
-
-#endif
diff --git a/src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_mng.c b/src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_mng.c
deleted file mode 100644
index 77ffd19..0000000
--- a/src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_mng.c
+++ /dev/null
@@ -1,814 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "nstack_securec.h"
-#include "nstack_log.h"
-#include "nsfw_mem_desc.h"
-#include "nsfw_ring_fun.h"
-#include "nsfw_shmem_ring.h"
-#include "nsfw_shmem_mng.h"
-#include "common_mem_mempool.h"
-#include "common_mem_memzone.h"
-#include "common_mem_buf.h"
-#include "common_mem_mbuf.h"
-#include "nsfw_rshmem_mng.h"
-#include "common_mem_api.h"
-#include "common_sys_config.h"
-#include "nsfw_maintain_api.h"
-#include "common_pal_bitwide_adjust.h"
-
-#include "common_mem_pal.h"
-
-#include "common_func.h"
-
-#define NSFW_SHMEM_PID (get_sys_pid())
-#define NSFW_SHMEM_FLAG (g_shmem_localdata->enflag)
-
-/* app_mode 1: simple stack with APP*/
-extern u8 app_mode;
-u8 app_mode = 0;
-
-nsfw_mem_localdata *g_shmem_localdata = NULL;
-
-/*check g_mem_localdata*/
-#define NSFW_INIT_CHK_RET() \
- if (!g_shmem_localdata) \
- { \
- return NSFW_MEM_ERR; \
- }
-
-#define NSFW_INIT_CHK_RET_NULL() \
- if (!g_shmem_localdata) \
- { \
- return NULL; \
- }
-
-/*
- *share memory mng module init
- *
- */
-i32
-nsfw_shmem_init (nsfw_mem_para * para)
-{
- common_mem_pal_module_info rteinfo = { 0 };
- i32 iret = NSFW_MEM_ERR;
- int flag = 0;
- if (!para)
- {
- return NSFW_MEM_ERR;
- }
-
- NSCOMM_LOGINF ("nsfw shmem init begin");
-
- LCORE_MASK_SET (rteinfo.ilcoremask, 1);
- rteinfo.ucproctype = DMM_PROC_T_SECONDARY;
- iret = common_pal_module_init (para, &rteinfo, app_mode);
-
- if (DMM_MBUF_RET_OK != iret)
- {
- NSCOMM_LOGERR ("rte init fail] ret=0x%x", iret);
- return NSFW_MEM_ERR;
- }
-
- flag = dmm_pal_addr_align ();
- if ((0 == flag) && (NSFW_PROC_MAIN == para->enflag))
- {
- dmm_addr_print ();
- NSCOMM_LOGERR
- ("rte init addr is not the same with primary] nstackmain flag=%d",
- flag);
- return NSFW_MEM_ERR;
- }
-
- g_shmem_localdata =
- (nsfw_mem_localdata *) malloc (sizeof (nsfw_mem_localdata));
-
- if (NULL == g_shmem_localdata)
- {
- NSCOMM_LOGERR ("g_shmem_localdata malloc fail");
- return NSFW_MEM_ERR;
- }
-
- iret =
- MEMSET_S (g_shmem_localdata, sizeof (nsfw_mem_localdata), 0,
- sizeof (nsfw_mem_localdata));
- if (EOK != iret)
- {
- NSCOMM_LOGERR ("memset fail] g_shmem_localdata=%p ", g_shmem_localdata);
- free (g_shmem_localdata);
- g_shmem_localdata = NULL;
- return NSFW_MEM_ERR;
- }
-
- g_shmem_localdata->enflag = para->enflag;
-
- NSCOMM_LOGINF ("nsfw shmem init end] enflag=%d", para->enflag);
- return NSFW_MEM_OK;
-
-}
-
-/*
- *module destroy
- */
-void
-nsfw_shmem_destroy (void)
-{
- if (g_shmem_localdata)
- {
- free (g_shmem_localdata);
- g_shmem_localdata = NULL;
- }
-
- return;
-}
-
-/*
- * create a shared memory
- * nsfw_mem_zone::stname memory name
- * nsfw_mem_zone::isize
- */
-mzone_handle
-nsfw_shmem_create (nsfw_mem_zone * pinfo)
-{
- i8 aname[COMMON_MEM_MEMPOOL_NAMESIZE] = { 0 };
-
- NSFW_INIT_CHK_RET_NULL ()if (NSFW_PROC_MAIN == NSFW_SHMEM_FLAG)
- {
- return common_memzone_data_reserve_name (pinfo->stname.aname,
- pinfo->length,
- pinfo->isocket_id);
- }
- else
- {
- /*app must less than NSFW_MEM_APPNAME_LENGTH */
- NSFW_NAME_LENCHECK_RET_NULL (pinfo->stname.aname, "shmem create")
- if (-1 ==
- SPRINTF_S (aname, COMMON_MEM_MEMPOOL_NAMESIZE, "%s_%x",
- pinfo->stname.aname, NSFW_SHMEM_PID))
- {
- NSCOMM_LOGERR ("SPRINTF_S failed]");
- return NULL;
- }
- }
-
- return nsfw_memzone_remote_reserv ((char *) &aname[0], pinfo->length,
- SOCKET_ID_ANY);
-}
-
-/*
- *create some memory
- *inum must be equal iarray_num
- */
-i32
-nsfw_shmem_createv (nsfw_mem_zone * pmeminfo, i32 inum,
- mzone_handle * paddr_array, i32 iarray_num)
-{
- NSFW_INIT_CHK_RET ();
-
- if (NSFW_PROC_MAIN == NSFW_SHMEM_FLAG)
- {
- return nsfw_memzone_remote_reserv_v (pmeminfo, paddr_array, iarray_num,
- 0);
- }
- else
- {
- return nsfw_memzone_remote_reserv_v (pmeminfo, paddr_array, iarray_num,
- NSFW_SHMEM_PID);
- }
- return NSFW_MEM_ERR;
-}
-
-mzone_handle
-nsfw_shmem_lookup (nsfw_mem_name * pname)
-{
- i8 aname[COMMON_MEM_MEMPOOL_NAMESIZE] = { 0 };
- NSFW_INIT_CHK_RET_NULL ();
-
- if (NSFW_PROC_MAIN == NSFW_SHMEM_FLAG)
- {
- return common_memzone_data_lookup_name (pname->aname);
- }
-
- if ((NSFW_PROC_NULL == pname->enowner)
- || (NSFW_PROC_MAIN == pname->enowner))
- {
- int retVal =
- SPRINTF_S (aname, COMMON_MEM_MEMPOOL_NAMESIZE, "%s", pname->aname);
- if (-1 == retVal)
- {
- NSCOMM_LOGERR ("SPRINTF_S failed");
- return NULL;
- }
- }
- else
- {
- /*app must less than NSFW_MEM_APPNAME_LENGTH */
- NSFW_NAME_LENCHECK_RET_NULL (pname->aname, "shmem lookup")
- int retVal =
- SPRINTF_S (aname, COMMON_MEM_MEMPOOL_NAMESIZE, "%s_%x", pname->aname,
- NSFW_SHMEM_PID);
- if (-1 == retVal)
- {
- NSCOMM_LOGERR ("SPRINTF_S failed");
- return NULL;
- }
- }
-
- return nsfw_remote_shmem_lookup (aname, NSFW_MEM_MZONE);
-}
-
-i32
-nsfw_shmem_release (nsfw_mem_name * pname)
-{
- i8 aname[COMMON_MEM_MEMPOOL_NAMESIZE] = { 0 };
- const struct common_mem_memzone *pmzone = NULL;
- NSFW_INIT_CHK_RET ();
-
- if (NSFW_PROC_MAIN == NSFW_SHMEM_FLAG)
- {
- pmzone = common_mem_memzone_lookup (pname->aname);
-
- if (pmzone)
- {
- common_mem_memzone_free (pmzone);
- }
- return NSFW_MEM_OK;
- }
- else
- {
- NSFW_NAME_LENCHECK_RET (pname->aname, "shmem free")
- if (-1 ==
- SPRINTF_S (aname, COMMON_MEM_MEMPOOL_NAMESIZE, "%s_%x",
- pname->aname, NSFW_SHMEM_PID))
- {
- NSCOMM_LOGERR ("SPRINTF_S failed");
- return NSFW_MEM_ERR;
- }
- }
-
- return nsfw_remote_free (aname, NSFW_MEM_MZONE);
-}
-
-mpool_handle
-nsfw_shmem_mbfmpcreate (nsfw_mem_mbfpool * pbufinfo)
-{
- i8 aname[COMMON_MEM_MEMPOOL_NAMESIZE] = { 0 };
-
- NSFW_INIT_CHK_RET_NULL ();
-
- if (NSFW_PROC_MAIN == NSFW_SHMEM_FLAG)
- {
- return common_mem_pktmbuf_pool_create (pbufinfo->stname.aname,
- pbufinfo->usnum,
- pbufinfo->uscash_size,
- pbufinfo->uspriv_size,
- pbufinfo->usdata_room,
- pbufinfo->isocket_id);
- }
- else
- {
- /*app must less than NSFW_MEM_APPNAME_LENGTH */
- NSFW_NAME_LENCHECK_RET_NULL (pbufinfo->stname.aname, "mbufpool create")
- if (-1 ==
- SPRINTF_S (aname, COMMON_MEM_MEMPOOL_NAMESIZE, "%s_%x",
- pbufinfo->stname.aname, NSFW_SHMEM_PID))
- {
- NSCOMM_LOGERR ("SPRINTF_S failed]");
- }
- }
-
- return nsfw_remote_shmem_mbf_create (aname, pbufinfo->usnum,
- pbufinfo->uscash_size,
- pbufinfo->uspriv_size,
- pbufinfo->usdata_room, SOCKET_ID_ANY,
- pbufinfo->enmptype);
-}
-
-/*
- *create some mbuf pools
- */
-i32
-nsfw_shmem_mbfmpcreatev (nsfw_mem_mbfpool * pmbfname, i32 inum,
- mpool_handle * phandle_array, i32 iarray_num)
-{
- NSFW_INIT_CHK_RET ();
-
- if (NSFW_PROC_MAIN == NSFW_SHMEM_FLAG)
- {
- return nsfw_remote_shmem_mbf_createv (pmbfname, phandle_array,
- iarray_num, 0);
- }
- else
- {
- return nsfw_remote_shmem_mbf_createv (pmbfname, phandle_array,
- iarray_num, NSFW_SHMEM_PID);
- }
-
- return NSFW_MEM_ERR;
-}
-
-mbuf_handle
-nsfw_shmem_mbfalloc (mpool_handle mhandle)
-{
- return (mbuf_handle) common_mem_pktmbuf_alloc ((struct common_mem_mempool *)
- mhandle);
-}
-
-i32
-nsfw_shmem_mbffree (mbuf_handle mhandle)
-{
- common_mem_pktmbuf_free ((struct common_mem_mbuf *) mhandle);
- return NSFW_MEM_OK;
-}
-
-i32
-nsfw_shmem_mbfmprelease (nsfw_mem_name * pname)
-{
- return NSFW_MEM_OK;
-}
-
-mpool_handle
-nsfw_shmem_mbfmplookup (nsfw_mem_name * pmbfname)
-{
- i8 aname[COMMON_MEM_MEMPOOL_NAMESIZE] = { 0 };
-
- NSFW_INIT_CHK_RET_NULL ();
-
- if (NSFW_PROC_MAIN == NSFW_SHMEM_FLAG)
- {
- return common_mem_mempool_lookup (pmbfname->aname);
- }
-
- if ((NSFW_PROC_NULL == pmbfname->enowner)
- || (NSFW_PROC_MAIN == pmbfname->enowner))
- {
- if (-1 ==
- SPRINTF_S (aname, COMMON_MEM_MEMPOOL_NAMESIZE, "%s",
- pmbfname->aname))
- {
- NSCOMM_LOGERR ("SPRINTF_S failed]");
- }
- }
- else
- {
- /*app must less than NSFW_MEM_APPNAME_LENGTH */
- NSFW_NAME_LENCHECK_RET_NULL (pmbfname->aname, "shmem lookup")
- if (-1 ==
- SPRINTF_S (aname, COMMON_MEM_MEMPOOL_NAMESIZE, "%s_%x",
- pmbfname->aname, NSFW_SHMEM_PID))
- {
- NSCOMM_LOGERR ("SPRINTF_S failed]");
- }
- }
-
- return nsfw_remote_shmem_lookup (aname, NSFW_MEM_MBUF);
-}
-
-mring_handle
-nsfw_shmem_spcreate (nsfw_mem_sppool * pmpinfo)
-{
- i8 aname[COMMON_MEM_MEMPOOL_NAMESIZE] = { 0 };
-
- NSFW_INIT_CHK_RET_NULL ();
-
- if (NSFW_PROC_MAIN == NSFW_SHMEM_FLAG)
- {
- return nsfw_shmem_pool_create (pmpinfo->stname.aname, pmpinfo->usnum,
- pmpinfo->useltsize, pmpinfo->isocket_id,
- pmpinfo->enmptype);
- }
- else
- {
- NSFW_NAME_LENCHECK_RET_NULL (pmpinfo->stname.aname, "mpool create")
- if (-1 ==
- SPRINTF_S (aname, COMMON_MEM_MEMPOOL_NAMESIZE, "%s_%x",
- pmpinfo->stname.aname, NSFW_SHMEM_PID))
- {
- NSCOMM_LOGERR ("SPRINTF_S failed]");
- }
- }
-
- return nsfw_remote_shmem_mpcreate (aname, pmpinfo->usnum,
- pmpinfo->useltsize, SOCKET_ID_ANY,
- pmpinfo->enmptype);
-}
-
-i32
-nsfw_shmem_spcreatev (nsfw_mem_sppool * pmpinfo, i32 inum,
- mring_handle * pringhandle_array, i32 iarray_num)
-{
- NSFW_INIT_CHK_RET ();
-
- if (NSFW_PROC_MAIN == NSFW_SHMEM_FLAG)
- {
- return nsfw_remote_shmem_mpcreatev (pmpinfo, pringhandle_array, inum,
- 0);
- }
- else
- {
- return nsfw_remote_shmem_mpcreatev (pmpinfo, pringhandle_array, inum,
- NSFW_SHMEM_PID);
- }
- return NSFW_MEM_ERR;
-}
-
-i32
-nsfw_lshmem_ringcreatev (const char *name, i32 ieltnum,
- mring_handle * pringhandle_array, i32 iringnum,
- i32 socket_id, nsfw_mpool_type entype)
-{
- i32 useltsize = 0;
- mring_handle nhandle = NULL;
- i32 icount = 0;
- i32 n = 0;
- uint64_t baseaddr = 0;
- uint64_t endaddr = 0;
- i32 usnum = common_mem_align32pow2 (ieltnum + 1);
-
- useltsize =
- sizeof (struct nsfw_mem_ring) + usnum * sizeof (union RingData_U);
- nhandle =
- nsfw_shmem_pool_create (name, iringnum, useltsize, socket_id,
- NSFW_MRING_SPSC);
- if (NULL == (nhandle))
- {
- return NSFW_MEM_ERR;
- }
-
- n =
- nsfw_shmem_ring_sc_dequeuev (nhandle, (void **) pringhandle_array,
- iringnum);
-
- if (n != iringnum)
- {
- NSCOMM_LOGERR
- ("ring dequeuev failed] ring=%p, dequeue num=%d, expect num=%d",
- nhandle, n, iringnum);
- return NSFW_MEM_ERR;
- }
-
- nsfw_shmem_ring_baseaddr_query (&baseaddr, &endaddr);
-
- for (icount = 0; icount < iringnum; icount++)
- {
- nsfw_mem_ring_init (pringhandle_array[icount], usnum, (void *) baseaddr,
- NSFW_SHMEM, entype);
- }
-
- return NSFW_MEM_OK;
-}
-
-i32
-nswf_shmem_sp_ringcreate (nsfw_mem_mring * prpoolinfo,
- mring_handle * pringhandle_array, i32 iringnum)
-{
- i8 aname[COMMON_MEM_MEMPOOL_NAMESIZE] = { 0 };
-
- NSFW_INIT_CHK_RET ();
-
- if (NSFW_PROC_MAIN == NSFW_SHMEM_FLAG)
- {
- return nsfw_lshmem_ringcreatev (prpoolinfo->stname.aname,
- prpoolinfo->usnum, pringhandle_array,
- iringnum, SOCKET_ID_ANY,
- prpoolinfo->enmptype);
- }
- else
- {
- NSFW_NAME_LENCHECK_RET (prpoolinfo->stname.aname, "ring pool")
- int retVal = SPRINTF_S (aname, COMMON_MEM_MEMPOOL_NAMESIZE, "%s_%x",
- prpoolinfo->stname.aname, NSFW_SHMEM_PID);
- if (-1 == retVal)
- {
- NSCOMM_LOGERR ("SPRINTF_S failed]");
- }
- }
-
- return nsfw_remote_shmem_ringcreatev (aname, prpoolinfo->usnum,
- pringhandle_array, iringnum,
- SOCKET_ID_ANY, prpoolinfo->enmptype);
-}
-
-i32
-nsfw_shmem_sprelease (nsfw_mem_name * pname)
-{
- i8 aname[COMMON_MEM_MEMPOOL_NAMESIZE] = { 0 };
- void *mz_mem = NULL;
- struct nsfw_mem_ring *ring_ptr = NULL;
- NSFW_INIT_CHK_RET ();
-
- if (NSFW_PROC_MAIN == NSFW_SHMEM_FLAG)
- {
- mz_mem = common_memzone_data_lookup_name (pname->aname);
-
- if (mz_mem)
- {
- ring_ptr =
- (struct nsfw_mem_ring *) ((char *) mz_mem +
- sizeof (struct nsfw_shmem_ring_head));
- nsfw_shmem_pool_free (ring_ptr);
- }
- return NSFW_MEM_OK;
- }
- else
- {
- NSFW_NAME_LENCHECK_RET (pname->aname, "shmem free")
- if (-1 ==
- SPRINTF_S (aname, COMMON_MEM_MEMPOOL_NAMESIZE, "%s_%x",
- pname->aname, NSFW_SHMEM_PID))
- {
- NSCOMM_LOGERR ("SPRINTF_S failed]");
- }
- }
-
- return nsfw_remote_free (aname, NSFW_MEM_SPOOL);
-}
-
-mring_handle
-nsfw_shmem_sp_lookup (nsfw_mem_name * pname)
-{
- i8 aname[COMMON_MEM_MEMPOOL_NAMESIZE] = { 0 };
- void *mz_mem = NULL;
- struct nsfw_mem_ring *ring_ptr = NULL;
- NSFW_INIT_CHK_RET_NULL ();
-
- if (NSFW_PROC_MAIN == NSFW_SHMEM_FLAG)
- {
- mz_mem = common_memzone_data_lookup_name (pname->aname);
-
- if (mz_mem)
- {
- ring_ptr =
- (struct nsfw_mem_ring *) ((char *) mz_mem +
- sizeof (struct nsfw_shmem_ring_head));
- return ring_ptr;
- }
- return mz_mem;
- }
-
- if ((NSFW_PROC_NULL == pname->enowner)
- || (NSFW_PROC_MAIN == pname->enowner))
- {
- if (-1 ==
- SPRINTF_S (aname, COMMON_MEM_MEMPOOL_NAMESIZE, "%s", pname->aname))
- {
- NSCOMM_LOGERR ("SPRINTF_S fails]");
- }
- }
- else
- {
- /*app's name can not over NSFW_MEM_APPNAME_LENGTH */
- NSFW_NAME_LENCHECK_RET_NULL (pname->aname, "shmem lookup")
- if (-1 ==
- SPRINTF_S (aname, COMMON_MEM_MEMPOOL_NAMESIZE, "%s_%x",
- pname->aname, NSFW_SHMEM_PID))
- {
- NSCOMM_LOGERR ("SPRINTF_S failed]");
- }
- }
-
- return nsfw_remote_shmem_lookup (aname, NSFW_MEM_SPOOL);
-}
-
-mring_handle
-nsfw_shmem_ringcreate (nsfw_mem_mring * pringinfo)
-{
- i8 aname[COMMON_MEM_MEMPOOL_NAMESIZE] = { 0 };
-
- NSFW_INIT_CHK_RET_NULL ();
-
- if (NSFW_PROC_MAIN == NSFW_SHMEM_FLAG)
- {
- return nsfw_shmem_ring_create (pringinfo->stname.aname,
- pringinfo->usnum, pringinfo->isocket_id,
- pringinfo->enmptype);
- }
- else
- {
- NSFW_NAME_LENCHECK_RET_NULL (pringinfo->stname.aname, "ring create")
- if (-1 ==
- SPRINTF_S (aname, COMMON_MEM_MEMPOOL_NAMESIZE, "%s_%x",
- pringinfo->stname.aname, NSFW_SHMEM_PID))
- {
- NSCOMM_LOGERR ("SPRINTF_S failed]");
- }
- }
-
- return nsfw_remote_shmem_ringcreate (aname, pringinfo->usnum, SOCKET_ID_ANY,
- pringinfo->enmptype);
-}
-
-mring_handle
-nsfw_shmem_ring_lookup (nsfw_mem_name * pname)
-{
- return nsfw_shmem_lookup (pname);
-}
-
-i32
-nsfw_shmem_ringrelease (nsfw_mem_name * pname)
-{
- return nsfw_shmem_release (pname);
-}
-
-size_t
-nsfw_shmem_mbufpool_statics (mpool_handle mbufpool)
-{
- struct common_mem_mempool *mp = (struct common_mem_mempool *) mbufpool;
- return (size_t) mp->size * (mp->header_size + mp->elt_size +
- mp->trailer_size) +
- (size_t) mp->private_data_size +
- (size_t)
- common_mem_ring_get_memsize (common_mem_align32pow2 (mp->size + 1));
-}
-
-size_t
-nsfw_shmem_sppool_statics (mring_handle sppool)
-{
- struct nsfw_shmem_ring_head *temp = NULL;
- size_t lent = 0;
- temp =
- (struct nsfw_shmem_ring_head *) ((char *) sppool -
- sizeof (struct nsfw_shmem_ring_head));
-
- while (temp)
- {
- lent += temp->mem_zone->len;
- temp = temp->next;
- }
-
- return lent;
-}
-
-size_t
-nsfw_shmem_ring_statics (mring_handle handle)
-{
- struct nsfw_mem_ring *ring = (struct nsfw_mem_ring *) handle;
- return ring->size * sizeof (union RingData_U) +
- sizeof (struct nsfw_mem_ring);
-}
-
-ssize_t
-nsfw_shmem_static (void *handle, nsfw_mem_struct_type type)
-{
- switch (type)
- {
- case NSFW_MEM_MBUF:
- return nsfw_shmem_mbufpool_statics (handle);
- case NSFW_MEM_SPOOL:
- return nsfw_shmem_sppool_statics (handle);
- case NSFW_MEM_RING:
- return nsfw_shmem_ring_statics (handle);
- default:
- break;
- }
- return -1;
-}
-
-i32
-nsfw_shmem_mbuf_recycle (mpool_handle handle)
-{
- return NSFW_MEM_OK;
-}
-
-/*****************************************************************************
-* Prototype : nsfw_shmem_sp_iterator
-* Description : sp pool iterator
-* Input : mpool_handle handle
-* u32 start
-* u32 end
-* nsfw_mem_item_fun fun
-* void *argv
-* Output : None
-* Return Value : i32
-* Calls :
-* Called By :
-*****************************************************************************/
-i32
-nsfw_shmem_sp_iterator (mpool_handle handle, u32 start, u32 end,
- nsfw_mem_item_fun fun, void *argv)
-{
- struct nsfw_mem_ring *perfring_ptr = (struct nsfw_mem_ring *) handle;
- if (NULL == perfring_ptr || NULL == fun)
- {
- return 0;
- }
-
- if (0 == perfring_ptr->eltsize)
- {
- return 0;
- }
-
- int num = perfring_ptr->size;
- if (start >= (u32) num || end <= start)
- {
- return 0;
- }
-
- struct nsfw_shmem_ring_head *ring_head =
- (struct nsfw_shmem_ring_head *) ((char *) handle -
- sizeof (struct nsfw_shmem_ring_head));
- void *mz =
- (void *) ((char *) perfring_ptr + sizeof (struct nsfw_mem_ring) +
- num * sizeof (union RingData_U));
-
- if (ring_head->mem_zone->len <
- sizeof (struct nsfw_shmem_ring_head) + sizeof (struct nsfw_mem_ring) +
- num * sizeof (union RingData_U))
- {
- return 0;
- }
-
- u32 mz_len =
- ring_head->mem_zone->len - sizeof (struct nsfw_shmem_ring_head) -
- sizeof (struct nsfw_mem_ring) - num * sizeof (union RingData_U);
-
- u32 start_idx = 0;
- u32 elm_num = 0;
- elm_num = mz_len / perfring_ptr->eltsize;
- while (start > start_idx + elm_num)
- {
- if (NULL == ring_head->next || NULL == ring_head->next->mem_zone
- || 0 == elm_num)
- {
- return 0;
- }
-
- ring_head =
- (struct nsfw_shmem_ring_head *) ring_head->next->mem_zone->addr_64;
- mz_len =
- ring_head->mem_zone->len - sizeof (struct nsfw_shmem_ring_head);
-
- elm_num = mz_len / perfring_ptr->eltsize;
- mz =
- (void *) ((char *) ring_head + sizeof (struct nsfw_shmem_ring_head));
- start_idx += elm_num;
- }
-
- u32 cur_idx = start - start_idx;
- char *cur_elm = NULL;
- int proc_count = 0;
- while (cur_idx + start_idx < end && cur_idx + start_idx < (u32) num)
- {
- if (cur_idx >= elm_num)
- {
- if (NULL == ring_head->next || NULL == ring_head->next->mem_zone
- || 0 == elm_num)
- {
- break;
- }
-
- ring_head =
- (struct nsfw_shmem_ring_head *) ring_head->next->
- mem_zone->addr_64;
- mz_len =
- ring_head->mem_zone->len - sizeof (struct nsfw_shmem_ring_head);
-
- elm_num = mz_len / perfring_ptr->eltsize;
- mz =
- (void *) ((char *) ring_head +
- sizeof (struct nsfw_shmem_ring_head));
- start_idx += elm_num;
-
- cur_idx = 0;
- cur_elm = NULL;
- continue;
- }
-
- if (NULL == cur_elm)
- {
- cur_elm = ((char *) mz + cur_idx * perfring_ptr->eltsize);
- }
- else
- {
- cur_elm += perfring_ptr->eltsize;
- }
-
- cur_idx++;
- proc_count++;
- (void) fun (cur_elm, argv);
- }
-
- return proc_count;
-}
-
-i32
-nsfw_shmem_mbuf_iterator (mpool_handle handle, u32 start, u32 end,
- nsfw_mem_item_fun fun, void *argv)
-{
- return dmm_pktmbuf_pool_iterator ((struct common_mem_mempool *) handle,
- start, end, (dmm_mbuf_item_fun) fun,
- argv);
-}
diff --git a/src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_mng.h b/src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_mng.h
deleted file mode 100644
index d489525..0000000
--- a/src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_mng.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _NSFW_SHMEM_MNG_H
-#define _NSFW_SHMEM_MNG_H
-
-/*
- * mem mgr module init
- * para:point to nstack_fwmem_para
- */
-i32 nsfw_shmem_init (nsfw_mem_para * para);
-
-/*
- * mem mgr module destory
- *
- */
-void nsfw_shmem_destroy (void);
-
-/*
- * create a block memory with name
- * fw_mem_zone::stname name of memory
- * fw_mem_zone::isize memory size
- */
-mzone_handle nsfw_shmem_create (nsfw_mem_zone * pinfo);
-
-/*
- *create some blocks memory
- */
-i32 nsfw_shmem_createv (nsfw_mem_zone * pmeminfo, i32 inum,
- mzone_handle * paddr_array, i32 iarray_num);
-
-/*
- *lookup a memory
- */
-mzone_handle nsfw_shmem_lookup (nsfw_mem_name * pname);
-
-/*release the memory*/
-i32 nsfw_shmem_release (nsfw_mem_name * pname);
-
-/*
- *create mbuf pool
- */
-mpool_handle nsfw_shmem_mbfmpcreate (nsfw_mem_mbfpool * pbufinfo);
-
-/*
- *create some mbuf pool
- */
-i32 nsfw_shmem_mbfmpcreatev (nsfw_mem_mbfpool * pmbfname, i32 inum,
- mpool_handle * phandle_array, i32 iarray_num);
-
-/*
- *alloc a mbuf from mbuf pool
- */
-mbuf_handle nsfw_shmem_mbfalloc (mpool_handle mhandle);
-
-/*
- *release a mbuf pool
- */
-i32 nsfw_shmem_mbffree (mbuf_handle mhandle);
-
-/*
- *put mbuf back to mbuf pool
- */
-i32 nsfw_shmem_mbfmprelease (nsfw_mem_name * pname);
-
-/*look up mbuf mpool*/
-mpool_handle nsfw_shmem_mbfmplookup (nsfw_mem_name * pmbfname);
-
-/*
- *create simple pool
- */
-mring_handle nsfw_shmem_spcreate (nsfw_mem_sppool * pmpinfo);
-
-/*
- *create some simple pools
- */
-i32 nsfw_shmem_spcreatev (nsfw_mem_sppool * pmpinfo, i32 inum,
- mring_handle * pringhandle_array, i32 iarray_num);
-
-/*
- *create a simple pool that members are rings
- */
-i32 nswf_shmem_sp_ringcreate (nsfw_mem_mring * prpoolinfo,
- mring_handle * pringhandle_array, i32 iringnum);
-
-/*
- *release a simple pool
- */
-i32 nsfw_shmem_sprelease (nsfw_mem_name * pname);
-
-/*
- *look up a simple pool
- */
-mring_handle nsfw_shmem_sp_lookup (nsfw_mem_name * pname);
-
-/*
- *create a ring with name
- */
-mring_handle nsfw_shmem_ringcreate (nsfw_mem_mring * pringinfo);
-
-/*
- *look up a ring with name
- */
-mring_handle nsfw_shmem_ring_lookup (nsfw_mem_name * pname);
-
-/*
- *release ring
- */
-i32 nsfw_shmem_ringrelease (nsfw_mem_name * pname);
-
-ssize_t nsfw_shmem_static (void *handle, nsfw_mem_struct_type type);
-
-i32 nsfw_shmem_mbuf_recycle (mpool_handle handle);
-
-i32 nsfw_shmem_sp_iterator (mpool_handle handle, u32 start, u32 end,
- nsfw_mem_item_fun fun, void *argv);
-i32 nsfw_shmem_mbuf_iterator (mpool_handle handle, u32 start, u32 end,
- nsfw_mem_item_fun fun, void *argv);
-
-#endif
diff --git a/src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_ring.c b/src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_ring.c
deleted file mode 100644
index c42c840..0000000
--- a/src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_ring.c
+++ /dev/null
@@ -1,839 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include <string.h>
-#include <common_sys_config.h>
-
-#include "common_mem_pal.h"
-#include "common_mem_pal_memconfig.h"
-#include "nstack_securec.h"
-#include "nsfw_shmem_ring.h"
-#include "nsfw_ring_fun.h"
-#include "common_mem_buf.h"
-#include "common_func.h"
-
-void
-nsfw_shmem_ring_baseaddr_query (uint64_t * rte_lowest_addr,
- uint64_t * rte_highest_addr)
-{
- struct common_mem_mem_config *pMemCfg =
- common_mem_pal_get_configuration ()->mem_config;
- struct common_mem_memseg *PMemSegArry = pMemCfg->memseg;
-
- *rte_lowest_addr = PMemSegArry[0].addr_64;
- *rte_highest_addr = PMemSegArry[0].addr_64 + PMemSegArry[0].len;
-
- int s = 1;
-
- while (s < COMMON_MEM_MAX_MEMSEG && PMemSegArry[s].len > 0)
- {
- if (*rte_lowest_addr > PMemSegArry[s].addr_64)
- {
- *rte_lowest_addr = PMemSegArry[s].addr_64;
- }
-
- if (*rte_highest_addr < PMemSegArry[s].addr_64 + PMemSegArry[s].len)
- {
- *rte_highest_addr = PMemSegArry[s].addr_64 + PMemSegArry[s].len;
- }
-
- s++;
- }
-
-}
-
-static unsigned
-nsfw_shmem_pool_node_alloc (struct nsfw_mem_ring *perfring_ptr,
- unsigned alloc_index, unsigned max_index,
- void *mz, size_t mz_len, unsigned elt_size)
-{
- size_t alloc_size = 0;
- unsigned offset_idx = 0;
- NSTCP_LOGINF ("mz(%p), mz_len = 0x%x", mz, mz_len);
-
- while (alloc_size + elt_size <= mz_len)
- {
- perfring_ptr->ring[alloc_index + offset_idx].data_s.ver =
- alloc_index + offset_idx;
- perfring_ptr->ring[alloc_index + offset_idx].data_s.val =
- ADDR_LTOSH_EXT (mz) - ((uint64_t) perfring_ptr->Addrbase);
- mz = (char *) mz + elt_size;
- alloc_size += elt_size;
- offset_idx++;
-
- if (alloc_index + offset_idx == max_index)
- {
- break;
- }
- }
-
- return offset_idx;
-}
-
-void
-nsfw_shmem_pool_free (struct nsfw_mem_ring *perfring_ptr)
-{
- struct nsfw_shmem_ring_head *ptemp;
-
- if (NULL == perfring_ptr)
- {
- return;
- }
-
- struct nsfw_shmem_ring_head *pnode =
- (struct nsfw_shmem_ring_head *) ((char *) perfring_ptr -
- sizeof (struct nsfw_shmem_ring_head));
-
- while (pnode)
- {
- // phead is involved in phead->mem_zone
- ptemp = pnode->next;
- common_mem_memzone_free (pnode->mem_zone);
- pnode = ptemp;
- }
-}
-
-struct nsfw_mem_ring *
-nsfw_shmem_pool_create (const char *name, unsigned int n,
- unsigned int elt_size, int socket_id,
- unsigned char flag)
-{
- struct nsfw_mem_ring *perfring_ptr = NULL;
- struct common_mem_memzone *mz_mem;
- void *mz = NULL;
-
- /*get pool size, pool size must pow of 2 */
- unsigned int num = common_mem_align32pow2 (n + 1);
-
- struct nsfw_shmem_ring_head *pcur = NULL;
- /*calculate the empty rte_perf_ring Size */
- size_t len =
- sizeof (struct nsfw_shmem_ring_head) + sizeof (struct nsfw_mem_ring) +
- (size_t) num * sizeof (union RingData_U) + (size_t) num * elt_size;
- size_t alloc_len = len;
- unsigned int alloc_num = 0;
- unsigned int alloc_index = 0;
-
- size_t mz_len = 0;
-
- unsigned int mz_index = 1;
- char mz_name[128] = { 0 };
- int retVal;
- /*we'd better use `strlen(src)` or `sizeof(dst)` to explain copying length of src string.
- it's meaningless using `sizeof(dst) - 1` to reserve 1 byte for '\0'.
- if copying length equals to or bigger than dst length, just let STRNCPY_S() returns failure. */
- retVal = STRNCPY_S (mz_name, sizeof (mz_name), name, sizeof (mz_name));
-
- if (EOK != retVal)
- {
- NSTCP_LOGERR ("STRNCPY_S failed]ret=%d", retVal);
- return NULL;
- }
-
- mz_mem = common_memzone_data_lookup_name (name);
- NSTCP_LOGINF ("memzone data look up] n=%u,num=%u,len=%zu", n, num, len);
-
- if (mz_mem)
- {
- perfring_ptr =
- (struct nsfw_mem_ring *) ((char *) mz_mem +
- sizeof (struct nsfw_shmem_ring_head));
- return perfring_ptr;
- }
-
- while (alloc_len > 0)
- {
- if (NULL != perfring_ptr)
- {
- retVal =
- SPRINTF_S (mz_name, sizeof (mz_name), "%s_%03d", name, mz_index);
-
- if (-1 == retVal)
- {
- NSCOMM_LOGERR ("SPRINTF_S failed]ret=%d", retVal);
- nsfw_shmem_pool_free (perfring_ptr);
- return NULL;
- }
- }
-
- mz_mem =
- (struct common_mem_memzone *) common_mem_memzone_reserve (mz_name,
- alloc_len,
- socket_id,
- 0);
-
- if (mz_mem == NULL)
- {
- mz_mem =
- (struct common_mem_memzone *) common_mem_memzone_reserve (mz_name,
- 0,
- socket_id,
- 0);
- }
-
- if (mz_mem == NULL)
- {
- nsfw_shmem_pool_free (perfring_ptr);
- return NULL;
- }
-
- if (NULL == perfring_ptr
- && (mz_mem->len <
- sizeof (struct nsfw_shmem_ring_head) +
- sizeof (struct nsfw_mem_ring) +
- num * sizeof (union RingData_U)))
- {
- common_mem_memzone_free (mz_mem);
- return NULL;
- }
-
- if (NULL == perfring_ptr)
- {
- pcur = (struct nsfw_shmem_ring_head *) ADDR_SHTOL (mz_mem->addr_64);
- pcur->mem_zone = mz_mem;
- pcur->next = NULL;
-
- perfring_ptr =
- (struct nsfw_mem_ring *) ((char *) pcur +
- sizeof (struct nsfw_shmem_ring_head));
-
- mz =
- (void *) ((char *) perfring_ptr + sizeof (struct nsfw_mem_ring) +
- num * sizeof (union RingData_U));
- mz_len =
- mz_mem->len - sizeof (struct nsfw_shmem_ring_head) -
- sizeof (struct nsfw_mem_ring) - num * sizeof (union RingData_U);
-
- uint64_t rte_base_addr;
- uint64_t rte_highest_addr;
- nsfw_shmem_ring_baseaddr_query (&rte_base_addr, &rte_highest_addr);
- nsfw_mem_pool_head_init (perfring_ptr, num, elt_size,
- (void *) rte_base_addr, NSFW_SHMEM,
- (nsfw_mpool_type) flag);
- }
- else
- {
- if (pcur)
- {
- pcur->next =
- (struct nsfw_shmem_ring_head *) ADDR_SHTOL (mz_mem->addr_64);
- pcur = pcur->next;
- pcur->mem_zone = mz_mem;
- pcur->next = NULL;
-
- if (mz_mem->len < sizeof (struct nsfw_shmem_ring_head))
- {
- NSCOMM_LOGERR ("mz_len error %d", mz_mem->len);
- nsfw_shmem_pool_free (perfring_ptr);
- return NULL;
- }
-
- mz =
- (void *) ((char *) pcur +
- sizeof (struct nsfw_shmem_ring_head));
- mz_len = mz_mem->len - sizeof (struct nsfw_shmem_ring_head);
- }
- }
-
- alloc_num =
- nsfw_shmem_pool_node_alloc (perfring_ptr, alloc_index, num, mz,
- mz_len, elt_size);
- alloc_index += alloc_num;
-
- if (alloc_index >= num)
- {
- break;
- }
-
- // second time allocate should not contained all ring head
- alloc_len =
- (size_t) (num - alloc_index) * elt_size +
- sizeof (struct nsfw_shmem_ring_head);
- mz_index++;
- }
-
- return perfring_ptr;
-}
-
-/*ring create*/
-struct nsfw_mem_ring *
-nsfw_shmem_ring_create (const char *name, unsigned int n, int socket_id,
- unsigned char flag)
-{
- struct nsfw_mem_ring *perfring_ptr;
- struct common_mem_memzone *mz;
- uint64_t rte_base_addr;
- uint64_t rte_highest_addr;
-
- unsigned int num = common_mem_align32pow2 (n);
-
- mz =
- (struct common_mem_memzone *) common_mem_memzone_reserve (name,
- sizeof (struct
- nsfw_mem_ring)
- +
- num *
- sizeof (union
- RingData_U),
- socket_id, 0);
-
- if (mz == NULL)
- {
- return NULL;
- }
-
- perfring_ptr = mz->addr;
-
- nsfw_shmem_ring_baseaddr_query (&rte_base_addr, &rte_highest_addr);
- nsfw_mem_ring_init (perfring_ptr, num, (void *) rte_base_addr, NSFW_SHMEM,
- flag);
-
- return perfring_ptr;
-}
-
-/*
-this is a multi thread/process enqueue function, please pay attention to the bellow point
-1. while Enqueue corrupt, we may lose one element; because no one to add the Head
-*/
-int
-nsfw_shmem_ring_mp_enqueue (struct nsfw_mem_ring *ring, void *box)
-{
- union RingData_U expectPostVal;
- union RingData_U curVal;
- unsigned int tmpHead;
- unsigned int tmpTail;
- unsigned int CurHead = ring->prod.head;
- unsigned int mask = ring->mask;
- unsigned int size = ring->size;
- void *prmBox = NULL;
-
- prmBox = (void *) ADDR_LTOSH_EXT (box);
-
- /*do box range check */
- if ((char *) prmBox <= (char *) ring->Addrbase
- || (char *) prmBox > (char *) ring->Addrbase + PERFRING_ADDR_RANGE)
- {
- /*invalid addr of box, can't put in rte_perf_ring, maybe should set a errno here */
- return -1;
- }
-
- do
- {
- /*
- if the ring is Full return directly; this not a exact check, cause we made tail++ after dequeue success.
- the thing we could make sure is ring[ring->Tail&mask] already dequeue
- */
- tmpTail = ring->cons.tail;
-
- if (tmpTail + size - CurHead == 0)
- {
- /*
- here we give enqueue a chance to recorrect the Tail, if tail not has Data let tail++
- */
- if (ring->ring[tmpTail & mask].data_s.val == 0)
- {
- (void) __sync_bool_compare_and_swap (&ring->cons.tail, tmpTail,
- tmpTail + 1);
- }
- else
- {
- return 0;
- }
- }
-
- /*
- the old version of ring->ring[CurHead&mask] must CurHead - size, which enqueue set to this pos lasttime
- & the val must already dequeue. otherwise this pos can't enqueue;
- */
- expectPostVal.data_l =
- (((unsigned long long) (CurHead - size)) << VALUE_LEN);
-
- /*
- the new version of ring->ring[CurHead&mask] must CurHead, which enqueue set to this pos this time.
- */
- curVal.data_l =
- ((((unsigned long long) CurHead) << VALUE_LEN) |
- ((char *) prmBox - (char *) ring->Addrbase));
- if (ring->ring[CurHead & mask].data_s.ver == expectPostVal.data_s.ver
- && __sync_bool_compare_and_swap (&ring->ring[CurHead & mask].data_l,
- expectPostVal.data_l,
- curVal.data_l))
- {
- /*
- enqueue success, add Head Value now
- here we using CAS set instead __sync_fetch_and_add(&ring->Head, 1) to assume that, if one process enqueue success && been killed before
- add Head, other process can recorrect the Head Value;
- one more thing the direction of Tail must been add-direction, so we using the condition (ring->Head - CurHead >0x80000000);
- while many thread do enqueue at same time, Head may not correct,exp:
- thread A get old head 10, thread A want set head to 11
- thread B get old head 10, thread B want set head to 12
- thread A do CAS && thread B do CAS at same time, thread A do CAS success;
- the result of head is 11, but the correct Value should be 12;
-
- then thread C get old head 11, thread C will set head to 13[cause pos 12 already has value, thread C will skill 12],
- the head will be recorrect by thread C.
- if no thread C, thread A& B are the last enqueue thread; the head must recorrect by the deque function.
- */
- tmpHead = ring->prod.head;
-
- if (0 == (CurHead & 0x03) && tmpHead - CurHead > 0x80000000)
- {
- (void) __sync_bool_compare_and_swap (&ring->prod.head, tmpHead,
- CurHead + 1);
- }
-
- break;
- }
-
- /*
- CurHead++ here;
- may be cpu slice is end here; while re-sched CurHead < ring->Tail < ring->Head; to avoid multi try
- we using a cmp & CurHead++ instead CurHead++ directly.
- if using CurHead++ will amplify the probability of ABA problem
- */
- /*CurHead++; */
- tmpHead = ring->prod.head;
- CurHead = CurHead - tmpHead < mask - 1 ? CurHead + 1 : tmpHead;
- }
- while (1);
-
- return 1;
-}
-
-/*
- this is a single thread/process enqueue function
- */
-int
-nsfw_shmem_ring_sp_enqueue (struct nsfw_mem_ring *ring, void *box)
-{
- union RingData_U texpectPostVal;
- union RingData_U curVal;
- unsigned int tmpTail;
- unsigned int CurHead = ring->prod.head;
- unsigned int mask = ring->mask;
- unsigned int uisize = ring->size;
- void *prmBox = NULL;
-
- prmBox = (void *) ADDR_LTOSH_EXT (box);
-
- if ((char *) prmBox <= (char *) ring->Addrbase
- || (char *) prmBox > (char *) ring->Addrbase + PERFRING_ADDR_RANGE)
- {
- return -1;
- }
-
- do
- {
- tmpTail = ring->cons.tail;
- if (tmpTail + uisize - CurHead == 0)
- {
- /*
- *here we give enqueue a chance to recorrect the Tail, if tail not has Data let tail++
- */
- if (ring->ring[tmpTail & mask].data_s.val == 0)
- {
- (void) __sync_bool_compare_and_swap (&ring->cons.tail, tmpTail,
- tmpTail + 1);
- }
- else
- {
- return 0;
- }
- }
- texpectPostVal.data_l =
- (((unsigned long long) (CurHead - uisize)) << VALUE_LEN);
-
- curVal.data_l =
- ((((unsigned long long) CurHead) << VALUE_LEN) |
- ((char *) prmBox - (char *) ring->Addrbase));
-
- if (ring->ring[CurHead & mask].data_l == texpectPostVal.data_l)
- {
- ring->ring[CurHead & mask].data_l = curVal.data_l;
- ring->prod.head = CurHead + 1;
- break;
- }
-
- CurHead++;
- }
- while (1);
- return 1;
-}
-
-/*this is a multi thread/process dequeue function, please pay attention to the bellow point
-*/
-int
-nsfw_shmem_ring_mc_dequeue (struct nsfw_mem_ring *ring, void **box)
-{
- unsigned int CurTail;
- unsigned int tmpTail;
- unsigned int tmpHead;
- unsigned int mask = ring->mask;
- union RingData_U curNullVal;
- union RingData_U ExcpRingVal;
-
- CurTail = ring->cons.tail;
- do
- {
- /*if ring is empty return directly */
- tmpHead = ring->prod.head;
-
- if (CurTail == tmpHead)
- {
- /*
- here we give deque a chance to recorrect the Head, if head has Data let Head++
- */
- if (ring->ring[tmpHead & mask].data_s.val != 0)
- {
- (void) __sync_bool_compare_and_swap (&ring->prod.head, tmpHead,
- tmpHead + 1);
- }
- else
- {
- return 0;
- }
- }
- curNullVal.data_l = (((unsigned long long) CurTail) << VALUE_LEN);
- ExcpRingVal = ring->ring[CurTail & mask];
- /*
- *the version of ring->ring[CurTail&mask] must CurTail&0xFFFFFF
- */
- if ((curNullVal.data_s.ver == ExcpRingVal.data_s.ver)
- && (ExcpRingVal.data_s.val)
- && __sync_bool_compare_and_swap (&ring->ring[CurTail & mask].data_l,
- ExcpRingVal.data_l,
- curNullVal.data_l))
- {
-
- *box =
- ADDR_SHTOL (((char *) ring->Addrbase + ExcpRingVal.data_s.val));
-
- /*
- enqueue success, add Tail Value now
- here we using CAS set instead __sync_fetch_and_add(&ring->Tail, 1) to assume that, if one process dequeue success && been killed before
- add Tail, other process can recorrect the Tail Value;
- one more thing the direction of Tail must been add-direction, so we using the condition (rlTail - CurTail >0x80000000);
- while multi CAS done the result value of CurTail may not correct, but we don't care, it will be recorrect while next deque done.
-
- avg CAS cost 200-300 Cycles, so we using cache loop to instead some CAS;[head&tail not exact guide, so no need Do CAS evertime]
- here we using 0 == (CurTail&0x11) means we only do CAS while head/tail low bit is 0x11; four times do one CAS.
- */
- tmpTail = ring->cons.tail;
-
- if (0 == (CurTail & 0x03) && tmpTail - CurTail > 0x80000000)
- {
- (void) __sync_bool_compare_and_swap (&ring->cons.tail, tmpTail,
- CurTail + 1);
- }
- break;
- }
-
- /*
- CurTail++ here;
- may be cpu slice is end here; while re-sched CurTail < ring->Tail < ring->Head; to avoid multi try
- we using a cmp & CurTail++ instead CurTail++ directly.
- if using CurTail++ will amplify the probability of ABA problem
- */
- /*CurTail++; */
- tmpTail = ring->cons.tail;
- CurTail = CurTail - tmpTail < mask - 1 ? CurTail + 1 : tmpTail;
- }
- while (1);
-
- return 1;
-}
-
-/*
- this is enhanced mc_ring_dequeue, support dequeue multi element one time.
-*/
-int
-nsfw_shmem_ring_mc_dequeuev (struct nsfw_mem_ring *ring, void **box,
- unsigned int n)
-{
- unsigned int uiCurTail;
- unsigned int tmpTail;
- unsigned int tmpHead;
- unsigned int uimask = ring->mask;
- union RingData_U curNullVal;
- union RingData_U ExcpRingVal;
- unsigned int deqNum = 0;
- uiCurTail = ring->cons.tail;
- do
- {
- /*if ring is empty return directly */
- tmpHead = ring->prod.head;
- if (uiCurTail == tmpHead)
- {
- /*
- here we give deque a chance to recorrect the Head, if head has Data let Head++;
- here must done to avoid some msg can't deque.
- */
- if (deqNum == 0 && ring->ring[tmpHead & uimask].data_s.val != 0)
- {
- (void) __sync_bool_compare_and_swap (&ring->prod.head, tmpHead,
- tmpHead + 1);
- }
- else
- {
- return deqNum;
- }
- }
-
- curNullVal.data_l = (((unsigned long long) uiCurTail) << VALUE_LEN);
- ExcpRingVal = ring->ring[uiCurTail & uimask];
-
- /*
- *the version of ring->ring[CurTail&mask] must CurTail&0xFFFFFF
- */
- if ((curNullVal.data_s.ver == ExcpRingVal.data_s.ver)
- && (ExcpRingVal.data_s.val)
- && __sync_bool_compare_and_swap (&ring->
- ring[uiCurTail & uimask].data_l,
- ExcpRingVal.data_l,
- curNullVal.data_l))
- {
-
- box[deqNum] =
- ADDR_SHTOL (((char *) ring->Addrbase + ExcpRingVal.data_s.val));
-
- /*
- enqueue success, add Tail Value now
- here we using CAS set instead __sync_fetch_and_add(&ring->Tail, 1) to assume that, if one process dequeue success && been killed before
- add Tail, other process can recorrect the Tail Value;
- one more thing the direction of Tail must been add-direction, so we using the condition (rlTail - CurTail >0x80000000);
-
- avg CAS cost 200-300 Cycles, so we using cache loop to instead some CAS;[head&tail not exact guide, so no need Do CAS evertime]
- here we using 0 == (CurTail&0x11) means we only do CAS while head/tail low bit is 0x11; four times do one CAS.
- */
- tmpTail = ring->cons.tail;
-
- if (0 == (uiCurTail & 0x03) && tmpTail - uiCurTail > 0x80000000)
- {
- (void) __sync_bool_compare_and_swap (&ring->cons.tail, tmpTail,
- uiCurTail + 1);
- }
-
- deqNum++;
- }
-
- /*
- CurTail++ here;
- may be cpu slice is end here; while re-sched CurTail < ring->Tail < ring->Head; to avoid multi try
- we using a cmp & CurTail++ instead CurTail++ directly.
- if using CurTail++ will amplify the probability of ABA problem
- */
- /*CurTail++; */
- tmpTail = ring->cons.tail;
- uiCurTail = uiCurTail - tmpTail < uimask - 1 ? uiCurTail + 1 : tmpTail;
-
- }
- while (n > deqNum);
-
- return deqNum;
-}
-
-/*
- this is enhanced mc_ring_dequeue, support dequeue multi element one time.
-*/
-int
-nsfw_shmem_ring_sc_dequeue (struct nsfw_mem_ring *ring, void **box)
-{
- unsigned int CurTail;
- unsigned int mask = ring->mask;
- union RingData_U curNullVal;
- union RingData_U ExcpRingVal;
- unsigned int uitmpHead;
-
- CurTail = ring->cons.tail;
-
- do
- {
- /*if ring is empty return directly */
- uitmpHead = ring->prod.head;
- if (CurTail == uitmpHead)
- {
- /*
- here we give deque a chance to recorrect the Head, if head has Data let Head++
- */
- if (ring->ring[uitmpHead & mask].data_s.val != 0)
- {
- (void) __sync_bool_compare_and_swap (&ring->prod.head,
- uitmpHead, uitmpHead + 1);
- }
- else
- {
- return 0;
- }
- }
- curNullVal.data_l = (((unsigned long long) CurTail) << VALUE_LEN);
- ExcpRingVal = ring->ring[CurTail & mask];
-
- if ((curNullVal.data_s.ver == ExcpRingVal.data_s.ver)
- && (ExcpRingVal.data_s.val))
- {
- ring->ring[CurTail & mask].data_l = curNullVal.data_l;
-
- *box =
- ADDR_SHTOL (((char *) ring->Addrbase + ExcpRingVal.data_s.val));
-
- ring->cons.tail = CurTail + 1;
- break;
- }
-
- CurTail++;
- }
- while (1);
-
- return 1;
-}
-
-/*
- this is a single thread/process dequeue function
-*/
-int
-nsfw_shmem_ring_sc_dequeuev (struct nsfw_mem_ring *ring, void **box,
- unsigned int n)
-{
- unsigned int CurTail;
- unsigned int tmpHead;
- unsigned int mask = ring->mask;
- union RingData_U curNullVal;
- union RingData_U ExcpRingVal;
- unsigned int usdeqNum = 0;
-
- CurTail = ring->cons.tail;
-
- do
- {
- /*if ring is empty return directly */
- tmpHead = ring->prod.head;
- if (CurTail == tmpHead)
- {
- /*
- here we give deque a chance to recorrect the Head, if head has Data let Head++;
- here must done to avoid some msg can't deque.
- */
- if (usdeqNum == 0 && ring->ring[tmpHead & mask].data_s.val != 0)
- {
- (void) __sync_bool_compare_and_swap (&ring->prod.head, tmpHead,
- tmpHead + 1);
- }
- else
- {
- return usdeqNum;
- }
- }
- curNullVal.data_l = (((unsigned long long) CurTail) << VALUE_LEN);
- ExcpRingVal = ring->ring[CurTail & mask];
-
- /*
- the version of ring->ring[CurTail&mask] must CurTail&0xFFFFFF
- */
- if ((curNullVal.data_s.ver == ExcpRingVal.data_s.ver)
- && (ExcpRingVal.data_s.val))
- {
- ring->ring[CurTail & mask].data_l = curNullVal.data_l;
-
- box[usdeqNum] =
- ADDR_SHTOL (((char *) ring->Addrbase + ExcpRingVal.data_s.val));
-
- ring->cons.tail = CurTail + 1;
- usdeqNum++;
- }
-
- CurTail++;
- }
- while (n > usdeqNum);
-
- return usdeqNum;
-}
-
-/* nstack just using one thread, for performance using que not support multi thread*/
-int
-nsfw_shmem_ring_singlethread_enqueue (struct nsfw_mem_ring *ring, void *box)
-{
- u32 head = 0;
- void *prmBox = NULL;
-
- /*if queue is full, just return 0 */
- if (ring->prod.head >= (ring->size + ring->cons.tail))
- {
- return 0;
- }
-
- prmBox = (void *) ADDR_LTOSH_EXT (box);
-
- head = ring->prod.head;
- ring->prod.head = head + 1;
- ring->ring[head & ring->mask].data_s.ver = head;
- ring->ring[head & ring->mask].data_s.val =
- (char *) prmBox - (char *) ring->Addrbase;
- return 1;
-}
-
-/* nstack just using one thread, for performance using que not support multi thread*/
-int
-nsfw_shmem_ring_singlethread_dequeue (struct nsfw_mem_ring *ring, void **box)
-{
- u32 tail = 0;
-
- /* if all entries are dequeued return 0 */
- if (unlikely (ring->prod.head == ring->cons.tail))
- {
- return 0;
- }
-
- tail = ring->cons.tail;
- *box =
- ADDR_SHTOL ((char *) ring->Addrbase +
- ring->ring[tail & ring->mask].data_s.val);
- ring->ring[tail & ring->mask].data_s.val = 0;
- ring->ring[tail & ring->mask].data_s.ver = tail;
- ring->cons.tail++;
- return 1;
-}
-
-/* nstack just using one thread, for performance using que not support multi thread*/
-int
-nsfw_shmem_ring_singlethread_dequeuev (struct nsfw_mem_ring *ring, void **box,
- unsigned int n)
-{
- u32 tail = 0;
- u32 num = 0;
-
- while (num < n)
- {
- tail = ring->cons.tail;
-
- /* if all entries are dequeued return 0 */
- if (unlikely (ring->prod.head == ring->cons.tail))
- {
- return num;
- }
-
- ring->cons.tail = tail + 1;
-
- box[num] =
- ADDR_SHTOL ((char *) ring->Addrbase +
- ring->ring[tail & ring->mask].data_s.val);
-
- ring->ring[tail & ring->mask].data_s.val = 0;
- ring->ring[tail & ring->mask].data_s.ver = tail;
- num++;
- }
-
- return num;
-}
diff --git a/src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_ring.h b/src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_ring.h
deleted file mode 100644
index 15cd1dd..0000000
--- a/src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_ring.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _NSFW_SHMEM_RING_H_
-#define _NSFW_SHMEM_RING_H_
-
-#include <stdint.h>
-
-#include "common_func.h"
-
-struct nsfw_shmem_ring_head
-{
- struct common_mem_memzone *mem_zone;
- struct nsfw_shmem_ring_head *next;
- unsigned int uireserv[4];
-};
-
-void nsfw_shmem_ring_baseaddr_query (uint64_t * rte_lowest_addr,
- uint64_t * rte_highest_addr);
-struct nsfw_mem_ring *nsfw_shmem_pool_create (const char *name,
- unsigned int n,
- unsigned int elt_size,
- int socket_id,
- unsigned char flag);
-struct nsfw_mem_ring *nsfw_shmem_ring_create (const char *name,
- unsigned int n, int socket_id,
- unsigned char flag);
-
-void nsfw_shmem_pool_free (struct nsfw_mem_ring *perfring_ptr);
-
-void nsfw_shmem_ring_reset (struct nsfw_mem_ring *ring, unsigned char flag);
-int nsfw_shmem_ring_mp_enqueue (struct nsfw_mem_ring *ring, void *box);
-int nsfw_shmem_ring_sp_enqueue (struct nsfw_mem_ring *ring, void *box);
-int nsfw_shmem_ring_mc_dequeue (struct nsfw_mem_ring *ring, void **box);
-int nsfw_shmem_ring_mc_dequeuev (struct nsfw_mem_ring *ring, void **box,
- unsigned int n);
-int nsfw_shmem_ring_sc_dequeue (struct nsfw_mem_ring *ring, void **box);
-int nsfw_shmem_ring_sc_dequeuev (struct nsfw_mem_ring *ring, void **box,
- unsigned int n);
-int nsfw_shmem_ring_singlethread_enqueue (struct nsfw_mem_ring *ring,
- void *box);
-int nsfw_shmem_ring_singlethread_dequeue (struct nsfw_mem_ring *ring,
- void **box);
-int nsfw_shmem_ring_singlethread_dequeuev (struct nsfw_mem_ring *ring,
- void **box, unsigned int n);
-
-#endif /*_NSFW_SHMEM_RING_H_*/
diff --git a/src/framework/common/pid_common.c b/src/framework/common/pid_common.c
new file mode 100644
index 0000000..16f5c5e
--- /dev/null
+++ b/src/framework/common/pid_common.c
@@ -0,0 +1,167 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#include <string.h>
+#include <time.h>
+#include <errno.h>
+#include "nstack_log.h"
+#include "nstack_securec.h"
+#include "pid_common.h"
+
+volatile pid_t g_sys_host_pid = SYS_HOST_INITIAL_PID;
+
+/*****************************************************************************
+* Prototype : get_hostpid_from_file
+* Description : get host pid by sub namespace pid in docker
+* Input : uint32_t pid
+* Output : None
+* Return Value : uint32_t
+* Calls :
+* Called By :
+*****************************************************************************/
+pid_t sys_get_hostpid_from_file(pid_t pid)
+{
+ g_sys_host_pid = get_hostpid_from_file(pid);
+ NSRTP_LOGDBG("ok]cur pid=%d, input pid=%d", g_sys_host_pid, pid);
+ return g_sys_host_pid;
+}
+
+pid_t get_hostpid_from_file(u32_t pid)
+{
+ pid_t ret_pid = SYS_HOST_INITIAL_PID;
+ int i = 0;
+ ret_pid = get_hostpid_from_file_one_time(pid);
+ while (0 == ret_pid || ret_pid == SYS_HOST_INITIAL_PID)
+ {
+ i++;
+ if (i > MAX_GET_PID_TIME)
+ {
+ NSFW_LOGERR("get pid failed]pid=%u,hostpid=%d", pid, ret_pid);
+ break;
+ }
+ sys_sleep_ns(0, 5000000);
+ ret_pid = get_hostpid_from_file_one_time(pid);
+ }
+
+ return ret_pid;
+}
+
+pid_t get_hostpid_from_file_one_time(u32_t pid)
+{
+ int retVal;
+ char path[READ_FILE_BUFLEN] = { 0 };
+ char buf[READ_FILE_BUFLEN] = { 0 };
+ char fmt[READ_FILE_BUFLEN] = { 0 };
+ char out[READ_FILE_BUFLEN] = { 0 };
+ char task_name[BUF_SIZE_FILEPATH] = { 0 };
+ pid_t hostpid = SYS_HOST_INITIAL_PID; //init to an invalid value
+ /*There are some unsafe function ,need to be replace with safe function */
+ get_exec_name_by_pid(pid, task_name, BUF_SIZE_FILEPATH);
+
+ /* adjust the position of HAVE_STACKTRACE and modify to snprintf_s */
+ if (0 == task_name[0])
+ {
+ NSRTP_LOGERR("get task_name failed");
+ return hostpid;
+ }
+
+ /*There are some unsafe function ,need to be replace with safe function */
+ retVal = sprintf_s(fmt, sizeof(fmt), "%s%s", task_name, " (%s");
+ if (-1 == retVal)
+ {
+ NSRTP_LOGERR("sprintf_s failed]ret=%d", retVal);
+ return hostpid;
+ }
+ retVal = sprintf_s(path, sizeof(path), "/proc/%u/sched", pid);
+ if (-1 == retVal)
+ {
+ NSRTP_LOGERR("sprintf_s failed]ret=%d", retVal);
+ return hostpid;
+ }
+ FILE *fp = fopen(path, "r");
+ if (NULL != fp)
+ {
+ if (fgets(buf, READ_FILE_BUFLEN - 1, fp) == NULL)
+ {
+ fclose(fp);
+ return hostpid;
+ }
+ fclose(fp);
+ /* Compiler needs "fmt" to be like "%s%s" to
+ understand. But we have "fmt" already prepared and used here. It can
+ be suppressed, not an issue
+ */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+ /*There are some unsafe function ,need to be replace with safe function */
+ retVal = sscanf_s(buf, fmt, out, READ_FILE_BUFLEN);
+#pragma GCC diagnostic pop
+ if (-1 == retVal)
+ {
+ NSPOL_LOGERR("sscanf_s failed]ret=%d", retVal);
+ return hostpid;
+ }
+ /*There are some unsafe function ,need to be replace with safe function */
+ }
+
+ hostpid = (pid_t) strtol(out, NULL, 0);
+ if (hostpid == 0)
+ {
+ hostpid = 1;
+ }
+
+ return hostpid;
+}
+
+void get_exec_name_by_pid(pid_t pid, char *task_name, int task_name_len)
+{
+ int retVal;
+ char path[READ_FILE_BUFLEN] = { 0 };
+ char buf[READ_FILE_BUFLEN] = { 0 };
+ /* There are some unsafe function ,need to be replace with safe function */
+ retVal = sprintf_s(path, sizeof(path), "/proc/%d/status", pid);
+ if (-1 == retVal)
+ {
+ NSRTP_LOGERR("sprintf_s failed]ret=%d", retVal);
+ return;
+ }
+ FILE *fp = fopen(path, "r");
+ if (NULL != fp)
+ {
+ if (fgets(buf, READ_FILE_BUFLEN - 1, fp) == NULL)
+ {
+ fclose(fp);
+ return;
+ }
+ fclose(fp);
+ /*There are some unsafe function ,need to be replace with safe function */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-extra-args"
+ retVal = sscanf_s(buf, "%*s %s", task_name, task_name_len);
+#pragma GCC diagnostic pop
+ if (1 != retVal)
+ {
+ NSSOC_LOGERR("sscanf_s failed]ret=%d", retVal);
+ return;
+ }
+ }
+}
+
+pid_t updata_sys_pid()
+{
+ g_sys_host_pid = SYS_HOST_INITIAL_PID;
+ return get_sys_pid();
+}
diff --git a/src/framework/dfx/nstack_dmm_dfx.c b/src/framework/dfx/nstack_dmm_dfx.c
new file mode 100644
index 0000000..3fe1aa4
--- /dev/null
+++ b/src/framework/dfx/nstack_dmm_dfx.c
@@ -0,0 +1,161 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#include "nstack_dmm_dfx.h"
+#include "nstack_securec.h"
+#include "nstack_module.h"
+#include "nstack_log.h"
+
+nstack_dmm_stack_ops_t *g_nstack_dmm_dfx_ops;
+
+#define nstack_dfx_calculate_elapse(a, b) ((a)>(b)?((((a)-(b))<0XFFFF)?(a)-(b):0XFFFF): 0)
+nstack_fd_dfx_t *dmm_fd_dfx_pool = NULL;
+
+void nstack_dfx_state_update(u64 fd, int midx, nstack_dmm_type_t type,
+ void *data)
+{
+ if (midx < 0 ||
+ !g_nstack_dmm_dfx_ops ||
+ !(g_nstack_dmm_dfx_ops[midx].update_dfx_data))
+ {
+ return;
+ }
+
+ midx = g_nstack_dmm_dfx_ops[0].type ? 0 : midx;
+ g_nstack_dmm_dfx_ops[midx].update_dfx_data(fd, type, data);
+}
+
+void nstack_fd_dfx_update_dfx_data(int fd, int protoFd, int midx, int type,
+ void *info)
+{
+ u16 data = 0;
+ if (midx < 0 || fd < 0 || protoFd < 0)
+ return;
+
+ if (!dmm_fd_dfx_pool ||
+ !g_nstack_dmm_dfx_ops ||
+ !(g_nstack_dmm_dfx_ops[midx].update_dfx_data))
+ {
+ return;
+ }
+
+ switch (type)
+ {
+ case DMM_STAT_LONGEST_SEND_INTERVAL:
+ if (dmm_fd_dfx_pool[fd].last_send_out_tick)
+ {
+ data =
+ nstack_dfx_calculate_elapse(dmm_fd_dfx_pool
+ [fd].last_send_in_tick,
+ dmm_fd_dfx_pool
+ [fd].last_send_out_tick);
+ nstack_dfx_state_update((u64) protoFd, midx,
+ DMM_STAT_LONGEST_SEND_INTERVAL,
+ &data);
+ }
+ break;
+ case DMM_STAT_LONGEST_SEND_COST:
+ data =
+ nstack_dfx_calculate_elapse(dmm_fd_dfx_pool
+ [fd].last_send_out_tick,
+ dmm_fd_dfx_pool
+ [fd].last_send_in_tick);
+ nstack_dfx_state_update((u64) protoFd, midx,
+ DMM_STAT_LONGEST_SEND_COST, &data);
+ break;
+ case DMM_STAT_LONGEST_RECV_INTERVAL:
+ if (dmm_fd_dfx_pool[fd].last_recv_out_tick)
+ {
+ data =
+ nstack_dfx_calculate_elapse(dmm_fd_dfx_pool
+ [fd].last_recv_in_tick,
+ dmm_fd_dfx_pool
+ [fd].last_recv_out_tick);
+ nstack_dfx_state_update((u64) protoFd, midx,
+ DMM_STAT_LONGEST_RECV_INTERVAL,
+ &data);
+ }
+ break;
+ case DMM_STAT_LONGEST_RECV_COST:
+ data =
+ nstack_dfx_calculate_elapse(dmm_fd_dfx_pool
+ [fd].last_recv_out_tick,
+ dmm_fd_dfx_pool
+ [fd].last_recv_in_tick);
+ nstack_dfx_state_update((u64) protoFd, midx,
+ DMM_STAT_LONGEST_RECV_COST, &data);
+ break;
+ default:
+ nstack_dfx_state_update((u64) protoFd, midx,
+ DMM_STAT_LONGEST_RECV_COST, info);
+ break;
+ }
+}
+
+int nstack_dfx_init_ops(nstack_dmm_stack_ops_t * ops)
+{
+ int i;
+
+ if (!ops)
+ return -1;
+
+ g_nstack_dmm_dfx_ops =
+ malloc(sizeof(nstack_dmm_stack_ops_t) * NSTACK_MAX_MODULE_NUM);
+ if (!g_nstack_dmm_dfx_ops)
+ {
+ NSSOC_LOGERR("alloc dfx ops failed");
+ return -1;
+ }
+ if (EOK !=
+ memset_s(g_nstack_dmm_dfx_ops,
+ sizeof(nstack_dmm_stack_ops_t) * NSTACK_MAX_MODULE_NUM, 0,
+ sizeof(nstack_dmm_stack_ops_t) * NSTACK_MAX_MODULE_NUM))
+ {
+ NSSOC_LOGERR("memory set failed");
+ return -1;
+ }
+ switch (ops[0].type)
+ {
+ case 0: //nsocket
+ for (i = 0; i < NSTACK_MAX_MODULE_NUM; i++)
+ {
+ g_nstack_dmm_dfx_ops[i].update_dfx_data =
+ ops[i].update_dfx_data;
+ g_nstack_dmm_dfx_ops[i].type = ops[i].type;
+ }
+
+ /*all stack just use the same time tick (default is used the first one) */
+ for (i = 0; i < NSTACK_MAX_MODULE_NUM; i++)
+ {
+ if (ops[i].get_stack_tick)
+ {
+ g_nstack_dmm_dfx_ops[0].get_stack_tick =
+ ops[i].get_stack_tick;
+ break;
+ }
+ }
+
+ break;
+ default:
+ for (i = 0; i < NSTACK_MAX_MODULE_NUM; i++)
+ {
+ g_nstack_dmm_dfx_ops[i] = *ops;
+ }
+ break;
+ }
+
+ return 0;
+}
diff --git a/src/framework/dfx/nstack_dmm_dfx.h b/src/framework/dfx/nstack_dmm_dfx.h
new file mode 100644
index 0000000..ef9d762
--- /dev/null
+++ b/src/framework/dfx/nstack_dmm_dfx.h
@@ -0,0 +1,69 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#ifndef __NSTACK_DMM_DFX_H__
+#define __NSTACK_DMM_DFX_H__
+#include <time.h>
+#include "types.h"
+#include "nsfw_dfx_api.h"
+#include "nstack_callback_ops.h"
+
+typedef struct nstack_fd_dfx_s
+{
+ u64 last_send_out_tick;
+ u64 last_send_in_tick;
+ u64 last_recv_out_tick;
+ u64 last_recv_in_tick;
+ int send_stat_count;
+ int recv_stat_count;
+} nstack_fd_dfx_t;
+
+extern nstack_dmm_stack_ops_t *g_nstack_dmm_dfx_ops;
+
+#define NSTACK_GET_SYS_TICK(data) if(g_nstack_dmm_dfx_ops && g_nstack_dmm_dfx_ops[0].get_stack_tick) g_nstack_dmm_dfx_ops[0].get_stack_tick(data);
+
+#define NSTACK_FD_DFX_LAST_SEND_TICK_IN(fd, tick) \
+if (dmm_fd_dfx_pool) \
+{ \
+ dmm_fd_dfx_pool[fd].last_send_in_tick = tick; \
+ dmm_fd_dfx_pool[fd].send_stat_count++; \
+ /* todo stat longest send */ \
+}
+
+#define NSTACK_FD_DFX_LAST_SEND_TICK_OUT(fd, tick) \
+if (dmm_fd_dfx_pool) \
+{ \
+ dmm_fd_dfx_pool[fd].last_send_out_tick = tick; \
+ /* todo stat longest send */ \
+}
+
+#define NSTACK_FD_DFX_LAST_RECV_TICK_IN(fd, tick) \
+if (dmm_fd_dfx_pool) \
+{ \
+ dmm_fd_dfx_pool[fd].last_recv_in_tick = tick; \
+ dmm_fd_dfx_pool[fd].recv_stat_count++; \
+ /* todo stat longest send */ \
+}
+
+#define NSTACK_FD_DFX_LAST_RECV_TICK_OUT(fd, tick) \
+if (dmm_fd_dfx_pool) \
+{ \
+ dmm_fd_dfx_pool[fd].last_recv_out_tick = tick; \
+ /* todo stat longest send */ \
+}
+
+extern nstack_fd_dfx_t *dmm_fd_dfx_pool;
+#endif
diff --git a/src/framework/event/epoll/ephlist.h b/src/framework/event/epoll/ephlist.h
new file mode 100644
index 0000000..07861b5
--- /dev/null
+++ b/src/framework/event/epoll/ephlist.h
@@ -0,0 +1,203 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#ifndef _EPHLIST_H_
+#define _EPHLIST_H_
+
+#include <stdio.h>
+#include "types.h"
+#include "nsfw_mem_api.h"
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
+struct ep_hlist_node
+{
+ struct ep_hlist_node *next, **pprev;
+};
+
+struct ep_node_list
+{
+ struct ep_hlist_node *head;
+ struct ep_hlist_node *tail;
+};
+
+struct ep_hlist
+{
+ struct ep_hlist_node node;
+ struct ep_hlist_node *head;
+ struct ep_hlist_node *tail;
+};
+
+#define ep_hlist_entry(ptr, type, member) container_of(ptr, type, member)
+
+#define EP_HLIST_INIT_NODE(node) {\
+ (node)->next = NULL;\
+ (node)->pprev = NULL; \
+ }
+
+#define EP_HLIST_INIT(ptr) {\
+ EP_HLIST_INIT_NODE(&((ptr)->node)); \
+ (ptr)->head = (struct ep_hlist_node*)SHMEM_ADDR_LTOSH_EXT(&((ptr)->node)); \
+ (ptr)->tail = (struct ep_hlist_node*)SHMEM_ADDR_LTOSH_EXT(&((ptr)->node)); \
+ }
+
+#define EP_HLIST_PREV(ptr) ((struct ep_hlist_node*)(SHMEM_ADDR_SHTOL((ptr)->pprev)))
+/* list check may below zero mod Begin
+ Modifed to check header, because if app crash before do list->size++, it will lead problem */
+#define EP_HLIST_EMPTY(list) (NULL == ((struct ep_hlist_node*)SHMEM_ADDR_SHTOL((list)->head))->next)
+#define EP_HLIST_NODE_LINKED(node) (!(!(node)->pprev))
+
+static __inline void ep_hlist_del(struct ep_hlist *list,
+ struct ep_hlist_node *n);
+static __inline void ep_hlist_add_tail(struct ep_hlist *list,
+ struct ep_hlist_node *node);
+
+/*
+ * list , n are local pointer, don't need to cast
+ */
+static __inline void ep_hlist_del(struct ep_hlist *list,
+ struct ep_hlist_node *n)
+{
+ if (!EP_HLIST_NODE_LINKED(n))
+ return;
+ EP_HLIST_PREV(n)->next = n->next;
+ if (n->next)
+ {
+ ((struct ep_hlist_node *) SHMEM_ADDR_SHTOL(n->next))->pprev =
+ n->pprev;
+ }
+ else
+ {
+ list->tail = (struct ep_hlist_node *) (n->pprev);
+ }
+ EP_HLIST_INIT_NODE(n);
+}
+
+/**
+ * list, node are local pointer , don't need to case
+ */
+static __inline void ep_hlist_add_tail(struct ep_hlist *list,
+ struct ep_hlist_node *node)
+{
+ struct ep_hlist_node *tail =
+ (struct ep_hlist_node *) SHMEM_ADDR_SHTOL(list->tail);
+ EP_HLIST_INIT_NODE(node);
+ node->pprev = (struct ep_hlist_node **) SHMEM_ADDR_LTOSH_EXT(&tail->next);
+ tail->next = (struct ep_hlist_node *) SHMEM_ADDR_LTOSH_EXT(node);
+ list->tail = (struct ep_hlist_node *) SHMEM_ADDR_LTOSH_EXT(node);
+}
+
+/*#########################################################*/
+struct list_node
+{
+ struct list_node *next;
+};
+
+struct ep_list
+{
+ struct list_node node;
+ struct list_node *head;
+ //struct list_node *tail;
+};
+
+#define ep_list_entry(ptr, type, member) container_of(ptr, type, member)
+
+#define EP_LIST_INIT_NODE(node) {\
+ (node)->next = NULL;\
+ }
+
+#define EP_LIST_INIT(ptr) {\
+ EP_LIST_INIT_NODE(&((ptr)->node)); \
+ (ptr)->head = (struct list_node*)SHMEM_ADDR_LTOSH_EXT(&((ptr)->node)); \
+ }
+
+#define EP_LIST_EMPTY(list) (NULL == ((struct list_node*)SHMEM_ADDR_SHTOL((list)->head))->next)
+
+static __inline void ep_list_del(struct ep_list *list, struct list_node *n);
+static __inline void ep_list_add_tail(struct ep_list *list,
+ struct list_node *node);
+
+/*
+ * list , n are local pointer, don't need to cast
+ */
+static __inline void ep_list_del(struct ep_list *list, struct list_node *n)
+{
+ if (NULL == n || NULL == list)
+ {
+ return;
+ }
+
+ struct list_node *p_node;
+ struct list_node *p_prev = NULL;
+ p_node = ((struct list_node *) SHMEM_ADDR_SHTOL(list->head));
+ while (NULL != p_node && p_node != n)
+ {
+ p_prev = p_node;
+ p_node = ((struct list_node *) SHMEM_ADDR_SHTOL(p_node->next));
+ }
+
+ if (p_node != n || p_prev == NULL)
+ {
+ return;
+ }
+
+ p_prev->next = n->next;
+
+ EP_LIST_INIT_NODE(n);
+ return;
+}
+
+/**
+ * list, node are local pointer , don't need to case
+ */
+static __inline void ep_list_add_tail(struct ep_list *list,
+ struct list_node *node)
+{
+ /*3th round code security review fix, */
+ if (NULL == list || NULL == node)
+ {
+ return;
+ }
+
+ struct list_node *p_node;
+ struct list_node *p_prev = NULL;
+ p_node = ((struct list_node *) SHMEM_ADDR_SHTOL(list->head));
+ while (NULL != p_node)
+ {
+ p_prev = p_node;
+ p_node = ((struct list_node *) SHMEM_ADDR_SHTOL(p_node->next));
+ }
+
+ if (NULL == p_prev)
+ {
+ return;
+ }
+
+ EP_LIST_INIT_NODE(node);
+ p_prev->next = (struct list_node *) SHMEM_ADDR_LTOSH_EXT(node);
+ return;
+}
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif
+
+#endif /* _HLIST_H_ */
diff --git a/src/framework/common/include/eprb_tree.h b/src/framework/event/epoll/eprb_tree.h
index 558ab2d..e23e91c 100644
--- a/src/framework/common/include/eprb_tree.h
+++ b/src/framework/event/epoll/eprb_tree.h
@@ -20,9 +20,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "types.h"
-#include "common_mem_pal.h"
-#include "common_mem_buf.h"
-#include "common_pal_bitwide_adjust.h"
+#include "nsfw_mem_api.h"
#ifdef __cplusplus
/* *INDENT-OFF* */
extern "C" {
@@ -34,44 +32,44 @@ extern "C" {
struct ep_rb_node
{
- int color;
+ int color;
- struct ep_rb_node *rb_parent;
- struct ep_rb_node *rb_right;
- struct ep_rb_node *rb_left;
+ struct ep_rb_node *rb_parent;
+ struct ep_rb_node *rb_right;
+ struct ep_rb_node *rb_left;
};
/* The alignment might seem pointless, but allegedly CRIS needs it */
struct ep_rb_root
{
- struct ep_rb_node *rb_node;
+ struct ep_rb_node *rb_node;
};
#define ep_rb_parent(r) ((struct ep_rb_node *)((r)->rb_parent))
-static inline void
-ep_rb_set_parent (struct ep_rb_node *rb, struct ep_rb_node *p)
+static inline void ep_rb_set_parent(struct ep_rb_node *rb,
+ struct ep_rb_node *p)
{
- rb->rb_parent = (struct ep_rb_node *) ADDR_LTOSH_EXT (p);
+ rb->rb_parent = (struct ep_rb_node *) SHMEM_ADDR_LTOSH_EXT(p);
}
#define ep_rb_entry(ptr, type, member) container_of(ptr, type, member)
-extern void ep_rb_insert_color (struct ep_rb_node *, struct ep_rb_root *);
-extern void ep_rb_erase (struct ep_rb_node *, struct ep_rb_root *);
-struct ep_rb_node *ep_rb_first (const struct ep_rb_root *);
+extern void ep_rb_insert_color(struct ep_rb_node *, struct ep_rb_root *);
+extern void ep_rb_erase(struct ep_rb_node *, struct ep_rb_root *);
+struct ep_rb_node *ep_rb_first(const struct ep_rb_root *);
-static inline void
-ep_rb_link_node (struct ep_rb_node *node,
- struct ep_rb_node *parent, struct ep_rb_node **rb_link)
+static inline void ep_rb_link_node(struct ep_rb_node *node,
+ struct ep_rb_node *parent,
+ struct ep_rb_node **rb_link)
{
- node->rb_parent = (struct ep_rb_node *) ADDR_LTOSH_EXT (parent);
- node->rb_left = node->rb_right = NULL;
+ node->rb_parent = (struct ep_rb_node *) SHMEM_ADDR_LTOSH_EXT(parent);
+ node->rb_left = node->rb_right = NULL;
- *rb_link = (struct ep_rb_node *) ADDR_LTOSH_EXT (node);
- node->color = EP_RB_RED;
+ *rb_link = (struct ep_rb_node *) SHMEM_ADDR_LTOSH_EXT(node);
+ node->color = EP_RB_RED;
}
diff --git a/src/framework/event/epoll/nstack_epoll_api.c b/src/framework/event/epoll/nstack_epoll_api.c
new file mode 100644
index 0000000..0db6a16
--- /dev/null
+++ b/src/framework/event/epoll/nstack_epoll_api.c
@@ -0,0 +1,192 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#include "nstack_eventpoll.h"
+#include "nsfw_mem_api.h"
+#include "nstack_log.h"
+#include "nstack_securec.h"
+#include "nsfw_recycle_api.h"
+#include "nsfw_maintain_api.h"
+#include "nstack_epoll_api.h"
+#include "nstack_sem.h"
+#include "dmm_spinlock.h"
+#include "nstack_dmm_dfx.h"
+
+extern int nstack_adpt_init(int flag);
+
+i32 nstack_epoll_init(int flag, int ns_sync_mod)
+{
+ i32 ret;
+
+ nstack_adpt_init(flag);
+
+ ret = ns_sync_sem_module_init(flag, ns_sync_mod);
+
+ return ret;
+}
+
+/* add parameter 'postFlag':
+ * 0, do not post ep->waitSem
+ * 1, post ep->waitSem
+ * Support: sometimes APP wants to get all of events generated by one operation
+ * Usage: When multi events continuously reportted, caller need to set postFlag as 1 on the last event.
+ * Note: epif should be local addr.
+***/
+void nstack_epoll_event_enqueue(void *epif, int event, int postFlag)
+{
+ nsep_epollInfo_t *epInfo;
+ mring_handle ring_hd = NULL;
+ struct spl_conn_pool *ep_spl = NULL;
+ u64 rpt_epfd_cnt = 0;
+
+ struct epitem *epi = NULL;
+ struct eventpoll *ep = NULL;
+ int enQueRet;
+ int protoFD;
+ struct list_node *node = NULL;
+ int lock_flag = 0;
+ int retVal = -1;
+ int new_event = 0;
+
+ if (NULL == epif)
+ {
+ return;
+ }
+
+ epInfo = (nsep_epollInfo_t *) (epif);
+ protoFD = epInfo->fd;
+
+ NSFW_LOGDBG("]protoFD=%d,event=%d,postFlag=%d", protoFD, event, postFlag);
+
+ /* solve issue: epoll global lock in daemon-stack
+ cause daemon-stack message handle slowing */
+ /* if this epInfo is from new nstackversion that support ep_conn */
+ if (1 == epInfo->ep_conn_flag)
+ {
+
+ lock_flag =
+ dmm_spin_trylock_with_pid((dmm_spinlock_t *) (&epInfo->epiLock),
+ 0);
+
+ if (0 != lock_flag)
+ {
+ NSFW_LOGINF("not lock]protoFD=%d,event=%d,postFlag=%d,epInfo=%p",
+ protoFD, event, postFlag, epInfo);
+ return;
+ }
+ }
+ else
+ {
+ dmm_spin_lock_with_pid((dmm_spinlock_t *) (&epInfo->epiLock));
+ }
+ struct list_node *fdEpiHead =
+ (struct list_node *) SHMEM_ADDR_SHTOL(epInfo->epiList.head);
+ node = (struct list_node *) SHMEM_ADDR_SHTOL(fdEpiHead->next);
+
+ while (node)
+ {
+ rpt_epfd_cnt++;
+ epi = ep_hlist_entry(node, struct epitem, fllink);
+ node = (struct list_node *) SHMEM_ADDR_SHTOL(node->next);
+
+ ep = (struct eventpoll *) SHMEM_ADDR_SHTOL(epi->ep);
+ if (NULL != epi->ep_spl)
+ {
+ ep_spl = (struct spl_conn_pool *) SHMEM_ADDR_SHTOL(epi->ep_spl);
+ ring_hd = (mring_handle) SHMEM_ADDR_SHTOL(ep_spl->ring_hd);
+ }
+
+ new_event = epi->event.events & event;
+ if ((!new_event) && EVENT_MUST_INFORM_APP != postFlag)
+ {
+ continue;
+ }
+
+ /* solve issue: epoll global lock in daemon-stack
+ cause daemon-stack message handle slowing */
+ /* if it use ep ring */
+
+ NSFW_LOGDBG("]protoFD=%d,event=%d,epi->event.events=%u", protoFD,
+ event, epi->event.events);
+
+ if (NULL != epi->ep_spl)
+ {
+ /* if it is fault restart, then need clear epi from queue firstly */
+ if (EVENT_MUST_INFORM_APP == postFlag)
+ {
+ retVal = nstack_epoll_event_dequeue(epi, 0);
+ }
+
+ epi->revents |= new_event & (EPOLLERR | EPOLLHUP | EPOLLRDHUP);
+ NSFW_LOGDBG("spl_count = %d poll_count = %d",
+ (int) epi->spl_enter_count, epi->app_poll_count);
+ if (((epi->spl_enter_count == epi->app_poll_count)
+ && (EVENT_NO_INFORM_APP != postFlag))
+ || (EVENT_MUST_INFORM_APP == postFlag))
+ {
+ epi->spl_enter_count++;
+ enQueRet = nsfw_mem_ring_enqueue(ring_hd, epi);
+ if (1 != enQueRet)
+ {
+ NSFW_LOGERR
+ ("]ring_hd=%p,spl_enter_count=%u,app_poll_count=%u",
+ ring_hd, epi->spl_enter_count, epi->app_poll_count);
+ dmm_spin_unlock((dmm_spinlock_t *) (&epInfo->epiLock));
+ return;
+ }
+
+ if (-1 == retVal)
+ {
+ nstack_dfx_state_update((u64) epInfo->rlfd, epInfo->rmidx, DMM_MAIN_REPORT_EVENT_TICK, NULL); //need to transform 'event' as pointer to the calling func //Add epoll report stat
+ }
+ NSFW_LOGDBG("protoFD=%d weak up epoll waite renevts = %d",
+ protoFD, epi->revents);
+ g_ns_sync_ops.ns_sync_sem_post(&ep->waitSem); /*do not need return value */
+ }
+
+ continue;
+ }
+
+ dmm_spin_lock_with_pid((dmm_spinlock_t *) (&ep->lock));
+ epi->revents |= new_event;
+ NSFW_LOGDBG("]epi->revents=%u,epi->rdllink=%p", epi->revents,
+ EP_HLIST_NODE_LINKED(&epi->rdllink));
+
+ if (!EP_HLIST_NODE_LINKED(&epi->rdllink)
+ && (EVENT_NO_INFORM_APP != postFlag))
+ {
+ ep_hlist_add_tail(&ep->rdlist, &epi->rdllink);
+ NSFW_LOGDBG("Add to tail]protoFD=%d,event=%d", protoFD, event);
+ nstack_dfx_state_update((u64) epInfo->rlfd, epInfo->rmidx,
+ DMM_MAIN_REPORT_EVENT_TICK, NULL);
+ // SPL_RTI_STAT_MACRO(TYPE_MAIN_REPORT_EVENT_TICK_EPOLL, epInfo->private_data, NULL); //need to transform 'event' as pointer to the calling func //Add epoll report stat
+ g_ns_sync_ops.ns_sync_sem_post(&ep->waitSem); /*do not need return value */
+ }
+ else
+ {
+ NSFW_LOGDBG("No need to add to tail]protoFD=%d,event=%d",
+ protoFD, event);
+ }
+ dmm_spin_unlock((dmm_spinlock_t *) (&ep->lock));
+ }
+
+ nstack_dfx_state_update((u64) epInfo->rlfd, epInfo->rmidx,
+ DMM_MAIN_REPORT_EP_CNT,
+ (void *) (u64) rpt_epfd_cnt);
+ dmm_spin_unlock((dmm_spinlock_t *) (&epInfo->epiLock));
+
+ return;
+}
diff --git a/src/framework/event/epoll/nstack_epoll_comm.c b/src/framework/event/epoll/nstack_epoll_comm.c
new file mode 100644
index 0000000..b90094d
--- /dev/null
+++ b/src/framework/event/epoll/nstack_epoll_comm.c
@@ -0,0 +1,1757 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#include "nstack_eventpoll.h"
+#include "nsfw_mem_api.h"
+#include "nstack_log.h"
+#include "nstack_securec.h"
+#include "nsfw_recycle_api.h"
+#include "nsfw_maintain_api.h"
+#include <stdio.h>
+#include <stdlib.h>
+//#include "nstack.h"
+#include "nstack_epoll_api.h"
+#include "nstack_share_res.h"
+#include "dmm_spinlock.h"
+
+nsep_epollManager_t g_epollMng = {
+ .infoSockMap = NULL,
+ .checkEpollFD = -1
+};
+
+extern int nsfw_ps_check_pid_nstack_status(int pid);
+
+/* after close fd in epfd, epfd still can epoll_wait EPOLLIN event for these fd
+ NOTE: 1.this func must be called in pinfo->epiLock, or else it is possible that there are multi epi in same ep ring_hd
+ 2. epi_addr should be local addr.
+*/
+int nstack_epoll_event_dequeue(void *epi_addr, int events)
+{
+
+ struct epitem *epi;
+ struct epitem *tmp_epi = NULL;
+ int enQueRet = 0, enQueRet_2 = 0;
+ u32 queue_use_count = 0, tmp_count = 0;
+ mring_handle mr_hand = NULL;
+ struct spl_conn_pool *ep_spl = NULL;
+ struct eventpoll *ep = NULL;
+ int retVal = -1;
+
+ epi = (struct epitem *) (epi_addr);
+ if (events & epi->event.events)
+ return 0;
+
+ if (NULL != epi->ep_spl)
+ {
+ ep = (struct eventpoll *) SHMEM_ADDR_SHTOL(epi->ep);
+ ep_spl = (struct spl_conn_pool *) SHMEM_ADDR_SHTOL(epi->ep_spl);
+ mr_hand = (mring_handle) SHMEM_ADDR_SHTOL(ep_spl->ring_hd);
+ /* dont clear epi successfully, it cause app coredump */
+ queue_use_count = nsfw_mem_ring_using_count(mr_hand) + 4; /* for perfring, it only add head and tail PERFRING_HEAD_INCRASE_MASK */
+
+ while (tmp_count < queue_use_count)
+ {
+ enQueRet = nsfw_mem_ring_dequeue(mr_hand, (void **) &tmp_epi);
+ if ((enQueRet > 0) && (epi == tmp_epi))
+ {
+ /* queue success */
+ retVal = 0;
+ epi->spl_enter_count--;
+ return retVal;
+ }
+ else if (enQueRet > 0)
+ {
+ enQueRet_2 = nsfw_mem_ring_enqueue(mr_hand, tmp_epi);
+ if (1 != enQueRet_2)
+ {
+ NSPOL_LOGERR("]mr_hand=%p,tmp_epi=%p", mr_hand, tmp_epi);
+ return retVal;
+ }
+ g_ns_sync_ops.ns_sync_sem_post(&ep->waitSem); /*do not need return value */
+ }
+ else
+ {
+ /* have finish all dequeue, return call */
+ return retVal;
+ }
+ tmp_count++;
+ }
+
+ /* in queue, don't have this epi */
+ }
+ return retVal;
+}
+
+/* epoll global lock in daemon-stack
+ cause daemon-stack message handle slowing */
+void nsep_recycle_upgrade_resource(void)
+{
+ /* if app use new version, daemon-stack use old version, then conn_pool resource that
+ app apply willn't recycle by old daemon-stack version, so when upgrade daemon-stack to new vesion,
+ it need recycle these resource;
+ */
+ nsep_epollManager_t *manager = nsep_get_manager();
+ struct spl_conn_pool *pool = manager->ep_connPoll.pool;
+
+ u32_t pos;
+ u32_t free_count = 0;
+ int tmp_pid = 0;
+ for (pos = 0; pos < NSTACK_MAX_EPOLL_FD_NUM - 1; pos++)
+ {
+ if (pool[pos].pid == 0)
+ {
+ continue;
+ }
+ tmp_pid = pool[pos].pid;
+
+ if (0 == nsfw_ps_check_pid_nstack_status(tmp_pid))
+ {
+ continue;
+ }
+
+ if (-1 == nsep_free_ep_spl_conn_ring(&pool[pos]))
+ {
+ NSFW_LOGWAR("spl_conn_ring]pid=%d,pool=%p,pos=%u,ring_hd=%p",
+ tmp_pid, &pool[pos], pos, pool[pos].ring_hd);
+ break;
+ }
+ else
+ {
+ free_count++;
+ }
+ }
+ if (free_count > 0)
+ {
+ NSFW_LOGINF("spl_conn_ring]pid=%d,free_count=%u", tmp_pid,
+ free_count);
+ }
+ return;
+}
+
+/*
+ * This function will find the epitem of fd in eventpool ep
+ * This is only used in epoll_ctl add
+ */
+struct epitem *nsep_find_ep(struct eventpoll *ep, int fd)
+{
+ struct ep_rb_node *rbp;
+ struct epitem *epi, *epir = NULL;
+ u32_t loopCnt = 0;
+
+ for (rbp = SHMEM_ADDR_SHTOL(ep->rbr.rb_node); rbp;)
+ {
+ ++loopCnt;
+ if (loopCnt > NSTACK_MAX_EPITEM_NUM)
+ break;
+
+ epi = (struct epitem *) ep_rb_entry(rbp, struct epitem, rbn);
+
+ if (fd > epi->fd)
+ {
+ rbp = (struct ep_rb_node *) SHMEM_ADDR_SHTOL(rbp->rb_right);
+ }
+ else if (fd < epi->fd)
+ {
+ rbp = (struct ep_rb_node *) SHMEM_ADDR_SHTOL(rbp->rb_left);
+ }
+ else
+ {
+ epir = epi;
+ break;
+ }
+ }
+
+ if (loopCnt > NSTACK_MAX_EPITEM_NUM)
+ {
+ NSSOC_LOGERR("Loop out of range!!!!");
+ }
+
+ return epir;
+}
+
+int nstack_ep_unlink(struct eventpoll *ep, struct epitem *epi)
+{
+ int error = ENOENT;
+
+ if (ep_rb_parent(&epi->rbn) == (struct ep_rb_node *) SHMEM_ADDR_LTOSH_EXT(&epi->rbn)) /* if (!ep_rb_linked(&epi->rbn)) */
+ {
+ NSSOC_LOGWAR("ep_rb_parent == epi->rbn");
+ return error;
+ }
+
+ epi->event.events = 0;
+
+ ep_rb_erase(&epi->rbn, &ep->rbr);
+ ep_rb_set_parent(&epi->rbn, &epi->rbn);
+
+ if (EP_HLIST_NODE_LINKED(&epi->rdllink))
+ {
+ ep_hlist_del(&ep->rdlist, &epi->rdllink);
+ }
+
+ return 0;
+}
+
+/**
+ * @Function nsep_free_epitem
+ * @Description free nstack epitem
+ * @param in data - the epitem to be free
+ * @return 0 on success, -1 on error
+ */
+int nsep_free_epitem(struct epitem *data)
+{
+
+ struct epitem *epiEntry = (struct epitem *) data;
+ struct epitem_pool *pool = &nsep_get_manager()->epitemPool;
+ epiEntry->pid = 0;
+ NSSOC_LOGDBG("nsep_free_epitem data:%p", data);
+ if (res_free(&epiEntry->res_chk))
+ {
+ NSFW_LOGERR("epitem refree!]epitem=%p", epiEntry);
+ return -1; //3th round code security review fix
+ }
+
+ /* dont clear epi successfully, it cause app coredump */
+ epiEntry->ep = NULL;
+ epiEntry->epInfo = NULL;
+ epiEntry->private_data = NULL;
+ epiEntry->ep_spl = NULL;
+ epiEntry->revents = 0;
+ if (nsfw_mem_ring_enqueue(pool->ring, (void *) epiEntry) != 1)
+ {
+ NSSOC_LOGERR("Error to free epitem");
+ return -1; //3th round code security review fix
+ }
+ return 0;
+}
+
+NSTACK_STATIC void nsep_init_epinfo(nsep_epollInfo_t * info)
+{
+ int iindex = 0;
+ EP_LIST_INIT(&info->epiList);
+ DMM_SPINLOCK_MALLOC(info->epiLock, 1);
+ DMM_SPINLOCK_MALLOC(info->freeLock, 1);
+
+ info->rlfd = -1;
+ info->rmidx = -1;
+ info->fd = -1;
+ info->ep = NULL;
+ info->fdtype = 0;
+ info->ep_conn = NULL; /* for epoll d use, when create epoll fd, it will set this to valid pointer */
+ info->ep_conn_flag = 1; /* if this */
+ info->private_data = NULL;
+ for (iindex = 0; iindex < NSEP_SMOD_MAX; iindex++)
+ {
+ info->protoFD[iindex] = -1;
+ info->epaddflag[iindex] = 0;
+ }
+ if (nsep_for_pidinfo_init(&(info->pidinfo)))
+ {
+ NSSOC_LOGERR("pid info init failed]epitem=%p", info);
+ }
+}
+
+NSTACK_STATIC void nsep_destroy_epinfo(nsep_epollInfo_t * info)
+{
+ if (NULL == info)
+ {
+ return;
+ }
+ info->ep_conn = NULL; /* must set to NULL when free , it impact new old nstackverion compatible */
+ info->ep_conn_flag = 0;
+ // TODO: Here we need to free the semaphore
+ return;
+}
+
+/**
+ * @Function nstack_eventpoll_allocShareInfo
+ * @Description alloc nstack share info
+ * @param out data - the return value alloced
+ * @return 0 on success, -1 on error
+ */
+int nsep_alloc_epinfo(nsep_epollInfo_t ** data)
+{
+ nsep_epollInfo_t *head_info = NULL;
+
+ if (NULL == data)
+ return -1;
+ NSSOC_LOGDBG("epinfo alloc begin");
+
+ nsep_infoPool_t *pool = &nsep_get_manager()->infoPool;
+ if (0 == nsfw_mem_ring_dequeue(pool->ring, (void *) &head_info)
+ || NULL == head_info)
+ {
+ NSSOC_LOGERR("epinfo ring alloc failed]pool->ring=%p", pool->ring);
+ return -1;
+ }
+
+ res_alloc(&head_info->res_chk);
+
+ nsep_init_epinfo(head_info);
+ if (0 != nsep_add_pid(&head_info->pidinfo, get_sys_pid()))
+ {
+ NSSOC_LOGERR("epinfo pid add to headinfo failed]pid=%d,headinfo=%p",
+ get_sys_pid(), head_info);
+ }
+ NSSOC_LOGDBG("epinfo ring:%p alloc epinfo:%p end", pool->ring, head_info);
+ *data = head_info;
+ return 0;
+}
+
+/* epoll global lock in daemon-stack
+ cause daemon-stack message handle slowing */
+NSTACK_STATIC int nsep_lookup_ep_spl_conn(void)
+{
+
+ nsfw_mem_name mem_name;
+ mzone_handle mz_handle = NULL;
+ nsep_epollManager_t *manager = nsep_get_manager();
+
+ int retVal = strcpy_s(mem_name.aname, sizeof(mem_name.aname),
+ MP_NSTACK_SPL_CONN_RING_NAME);
+ if (EOK != retVal)
+ {
+ NSSOC_LOGERR("strcpy_s failed]");
+ return -1;
+ }
+
+ mem_name.enowner = NSFW_PROC_MAIN;
+ mem_name.entype = NSFW_SHMEM;
+ mz_handle = nsfw_mem_zone_lookup(&mem_name);
+ if (NULL == mz_handle)
+ {
+ return -1;
+ }
+
+ manager->ep_connPoll.ring = mz_handle;
+
+ retVal =
+ strcpy_s(mem_name.aname, sizeof(mem_name.aname),
+ MP_NSTACK_SPL_CONN_ARRAY_NAME);
+ if (EOK != retVal)
+ {
+ NSSOC_LOGERR("strcpy_s failed]");
+ return -1;
+ }
+
+ mz_handle = nsfw_mem_zone_lookup(&mem_name);
+ manager->ep_connPoll.pool = mz_handle;
+ if (NULL == mz_handle)
+ {
+ return -1;
+ }
+
+ return 0;
+}
+
+/* epoll global lock in daemon-stack
+ cause daemon-stack message handle slowing */
+int nsep_alloc_ep_spl_conn_ring(struct spl_conn_pool **data)
+{
+ struct spl_conn_pool *head_info = NULL;
+ i32 enQueRet = 0;
+ struct epitem *epi = NULL;
+
+ if (NULL == data)
+ return -1;
+ NSSOC_LOGDBG("epinfo alloc begin");
+
+ struct ep_conn_pool *pool = &nsep_get_manager()->ep_connPoll;
+
+ /* support upgrade, if daemon-stack is old version, then here will fail */
+ if (NULL == pool->ring)
+ {
+ /* check whether daemon-stack is new version, if it use new version, then use ring epoll */
+ if (-1 == nsep_lookup_ep_spl_conn())
+ {
+ return -1;
+ }
+ }
+
+ if (0 == nsfw_mem_ring_dequeue(pool->ring, (void *) &head_info)
+ || NULL == head_info)
+ {
+ NSSOC_LOGERR("ep_spl_conn_ring alloc failed]pool->ring=%p",
+ pool->ring);
+ return -1;
+ }
+ res_alloc(&head_info->res_chk);
+ head_info->pid = get_sys_pid();
+ head_info->revents = 0;
+
+ /* clear the ring_hd before use */
+ do
+ {
+ enQueRet =
+ nsfw_mem_ring_dequeue(SHMEM_ADDR_SHTOL(head_info->ring_hd),
+ (void **) &epi);
+ /* when free ep_con, it have clean ring_hd, if here find it still have epi in this ring, it indicate that it still use it after ep_conn was freed,
+ it need check the reason */
+ if (enQueRet > 0)
+ {
+ NSSOC_LOGERR
+ ("fine have epi in ep_spl ring]head_info=%p,ring_hd=%p,epi=%p",
+ head_info, head_info->ring_hd, epi);
+ }
+
+ }
+ while (enQueRet > 0);
+
+ NSSOC_LOGDBG("spl_conn_ring]head_info=%p,ring_hd=%p,pid=%d", head_info,
+ head_info->ring_hd, head_info->pid);
+
+ NSSOC_LOGDBG("epinfo ring:%p alloc epinfo:%p end", pool->ring, head_info);
+ *data = head_info;
+ return 0;
+}
+
+int nsep_free_ep_spl_conn_ring(struct spl_conn_pool *data)
+{
+ struct spl_conn_pool *head_info = data;
+ struct epitem *epi = NULL;
+ i32 enQueRet = 0;
+ unsigned int total_count = 0;
+
+ if (NULL == data)
+ return -1;
+ NSSOC_LOGDBG("nsep_free_ep_spl_conn_ring begin");
+
+ struct ep_conn_pool *pool = &nsep_get_manager()->ep_connPoll;
+ /* clear the ring_hd before free */
+ do
+ {
+ enQueRet =
+ nsfw_mem_ring_dequeue(SHMEM_ADDR_SHTOL(head_info->ring_hd),
+ (void **) &epi);
+ if (enQueRet > 0)
+ {
+ total_count += enQueRet;
+ }
+ }
+ while (enQueRet > 0);
+
+ head_info->pid = 0;
+ head_info->revents = 0;
+
+ if (res_free(&head_info->res_chk))
+ {
+ NSFW_LOGERR
+ ("ep_spl_conn refree!]spl_conn=%p,ring_hd=%p,total_count=%u",
+ head_info, head_info->ring_hd, total_count);
+ return -1; // 3th round code security review fix
+ }
+
+ if (0 == nsfw_mem_ring_enqueue(pool->ring, (void *) head_info))
+ {
+ NSSOC_LOGERR("spl_conn_ring free failed]pool->ring=%p,head_info=%p",
+ pool->ring, head_info);
+ return -1;
+ }
+
+ NSSOC_LOGDBG("spl_conn_ring]head_info=%p,ring_hd=%p,pid=%d", head_info,
+ head_info->ring_hd, head_info->pid);
+
+ return 0;
+}
+
+/**
+ * @Function nstack_eventpoll_freeShareInfo
+ * @Description free nstack share info
+ * @param in info - the info to be free
+ * @return 0 on success, -1 on error
+ */
+int nsep_free_epinfo(nsep_epollInfo_t * info)
+{
+
+ if (NULL == info)
+ return -1;
+
+ nsep_infoPool_t *pool = &nsep_get_manager()->infoPool;
+ NSSOC_LOGDBG("nsep_free_epinfo info:%p, pool->ring:%p", info, pool->ring);
+ nsep_destroy_epinfo(info);
+
+ if (nsep_for_pidinfo_init(&(info->pidinfo)))
+ {
+ NSSOC_LOGERR("pid info init failed]epitem=%p", info);
+ return -1;
+ }
+
+ if (res_free(&info->res_chk))
+ {
+ NSFW_LOGERR("epinfo refree!]epitem=%p", info);
+ return -1; // 3th round code security review fix
+ }
+
+ if (nsfw_mem_ring_enqueue(pool->ring, (void *) info) != 1)
+ {
+ NSSOC_LOGERR("Errot to free epinfo");
+ return -1; // 3th round code security review fix
+ }
+
+ return 0;
+}
+
+int nsep_force_epinfo_free(void *data)
+{
+ nsep_epollInfo_t *info = data;
+ if (NULL == info)
+ {
+ return FALSE;
+ }
+
+ if (!nsep_is_pid_array_empty(&info->pidinfo))
+ {
+ return FALSE;
+ }
+
+ res_alloc(&info->res_chk);
+ (void) nsep_free_epinfo(info);
+ NSFW_LOGINF("free epinfo]%p", data);
+ return TRUE;
+}
+
+int nsep_force_epitem_free(void *data)
+{
+ struct epitem *item = data;
+ if (NULL == item)
+ {
+ return FALSE;
+ }
+
+ if (0 != item->pid)
+ {
+ return FALSE;
+ }
+
+ res_alloc(&item->res_chk);
+ (void) nsep_free_epitem(item);
+ NSFW_LOGINF("free epitem]%p", data);
+ return TRUE;
+}
+
+int nsep_force_epevent_free(void *data)
+{
+ struct eventpoll *epevent = data;
+ if (NULL == epevent)
+ {
+ return FALSE;
+ }
+
+ if (0 != epevent->pid)
+ {
+ return FALSE;
+ }
+
+ res_alloc(&epevent->res_chk);
+ (void) nsep_free_eventpoll(epevent);
+ NSFW_LOGINF("free event pool]%p", data);
+ return TRUE;
+}
+
+int nsep_force_ep_spl_conn_free(void *data)
+{
+ struct spl_conn_pool *epConnPool = data;
+ if (NULL == epConnPool)
+ {
+ return FALSE;
+ }
+
+ if (0 != epConnPool->pid)
+ {
+ return FALSE;
+ }
+
+ res_alloc(&epConnPool->res_chk);
+ (void) nsep_free_ep_spl_conn_ring(epConnPool);
+ NSFW_LOGINF("free spl conn pool]%p", data);
+ return TRUE;
+}
+
+NSTACK_STATIC int nsep_init_eventpoll(struct eventpoll *ep, int idx)
+{
+ int *args;
+
+ args = (int *) ep->waitSem.args;
+ *args = idx;
+ if (0 != g_ns_sync_ops.ns_sync_sem_init(&ep->waitSem, 1, 0))
+ {
+ return -1;
+ }
+
+ DMM_SPINLOCK_MALLOC(ep->lock, 1);
+ DMM_SPINLOCK_MALLOC(ep->sem, 1);
+
+ EP_HLIST_INIT(&ep->rdlist);
+
+ ep->rbr.rb_node = NULL;
+ ep->epfd = -1;
+ //ep->pid = 0;
+ return 0;
+}
+
+NSTACK_STATIC void nsep_destroy_eventpoll(struct eventpoll *ep)
+{
+ (void) g_ns_sync_ops.ns_sync_sem_destroy(&ep->waitSem);
+}
+
+/**
+ * @Function nsep_free_eventpoll
+ * @Description free nstack eventpoll
+ * @param in ep - the eventpoll to be free
+ * @return 0 on success, -1 on error
+ */
+int nsep_free_eventpoll(struct eventpoll *ep)
+{
+
+ if (!ep)
+ return -1;
+ struct eventpoll *epEntry = (struct eventpoll *) ep;
+ struct eventpoll_pool *pool = &nsep_get_manager()->epollPool;
+ NSSOC_LOGDBG("nsep_free_eventpoll ep:%p, epollPool:%p", ep, pool);
+ nsep_destroy_eventpoll(ep);
+ ep->pid = 0;
+ NSSOC_LOGDBG("Free eventpool");
+ if (res_free(&ep->res_chk))
+ {
+ NSFW_LOGERR("ep refree!]epitem=%p", epEntry);
+ return -1; // 3th round code security review fix
+ }
+
+ if (nsfw_mem_ring_enqueue(pool->ring, epEntry) != 1)
+ {
+ NSSOC_LOGERR("Errot to free eventpoll");
+ return -1; // 3th round code security review fix
+ }
+
+ return 0;
+}
+
+/**
+ * @Function nsep_alloc_eventpoll
+ * @Description alloc nstack eventpoll
+ * @param out data - the eventpoll alloced
+ * @return 0 on success, -1 on error
+ */
+int nsep_alloc_eventpoll(struct eventpoll **data)
+{
+ struct eventpoll *p_head = NULL;
+ struct eventpoll_pool *pool = &nsep_get_manager()->epollPool;
+ int idx;
+
+ NSSOC_LOGDBG("ring:%p alloc eventpool begin", pool->ring);
+ if (0 == nsfw_mem_ring_dequeue(pool->ring, (void *) &p_head)
+ || NULL == p_head)
+ {
+ NSSOC_LOGERR("ring alloc eventpool failed]ring=%p", pool->ring);
+ return -1;
+ }
+
+ NSSOC_LOGDBG("alloc eventpool, pid=%d", get_sys_pid());
+ res_alloc(&p_head->res_chk);
+ p_head->pid = get_sys_pid();
+
+ idx =
+ ((unsigned long) p_head -
+ (unsigned long) (pool->pool)) / sizeof(struct eventpoll);
+ if (0 != nsep_init_eventpoll((struct eventpoll *) p_head, idx))
+ {
+ NSSOC_LOGERR("p_head init pid alloc failed]p_head=%p,pid=%d", p_head,
+ get_sys_pid());
+ (void) nsep_free_eventpoll((struct eventpoll *) p_head);
+ return -1;
+ }
+
+ NSSOC_LOGDBG("ring:%p eventpoll:%p alloc eventpool end", pool->ring,
+ p_head);
+ *data = p_head;
+
+ return 0;
+}
+
+NSTACK_STATIC int nsep_init_epitem(struct epitem *epi)
+{
+ int retVal;
+ epi->rbn.rb_parent =
+ (struct ep_rb_node *) SHMEM_ADDR_LTOSH_EXT(&epi->rbn);
+ EP_HLIST_INIT_NODE(&epi->rdllink);
+
+ epi->ptr_reserve = NULL;
+ epi->ep_spl = NULL;
+ epi->ep = NULL;
+ epi->app_poll_count = 0;
+ epi->spl_enter_count = 0;
+ epi->reserve = 0;
+
+ //epi->pid = 0;
+ /* There are some unsafe function ,need to be replace with safe function */
+ retVal = memset_s(&epi->event, sizeof(epi->event), 0, sizeof(epi->event));
+ if (EOK != retVal)
+ {
+ NSSOC_LOGERR("memset_s failed]ret=%d", retVal);
+ return -1;
+ }
+
+ EP_LIST_INIT_NODE(&epi->fllink);
+ EP_HLIST_INIT_NODE(&epi->txlink);
+ epi->revents = 0;
+ epi->fd = -1;
+ epi->private_data = NULL;
+
+ return 0;
+}
+
+/**
+ * @Function nsep_alloc_epitem
+ * @Description alloc nstack epitem
+ * @param out data - the epitem alloced
+ * @return 0 on success, -1 on error
+ */
+int nsep_alloc_epitem(struct epitem **data)
+{
+ struct epitem *p_head_entry = NULL;
+ struct epitem_pool *pool = &nsep_get_manager()->epitemPool;
+
+ NSSOC_LOGDBG("epitem alloc begin..");
+
+ if (0 == nsfw_mem_ring_dequeue(pool->ring, (void *) &p_head_entry)
+ || NULL == p_head_entry)
+ {
+ NSSOC_LOGERR("epitem ring alloc failed]ring=%p", pool->ring);
+ return -1;
+ }
+
+ res_alloc(&p_head_entry->res_chk);
+ p_head_entry->pid = get_sys_pid();
+
+ if (nsep_init_epitem((struct epitem *) p_head_entry))
+ {
+ (void) nsep_free_epitem((struct epitem *) p_head_entry);
+ p_head_entry = NULL;
+ NSSOC_LOGERR("ring epitem init failed]ring=%p,epitem=%p", pool->ring,
+ p_head_entry);
+ return -1;
+ }
+
+ NSSOC_LOGDBG("epitem alloc success..ring:%p head:%p", pool->ring,
+ p_head_entry);
+ *data = p_head_entry;
+ return 0;
+}
+
+typedef int (*nsep_shem_initFn_t) (void *, size_t);
+
+/*****************************************************************************
+* Prototype : sbr_create_mzone
+* Description : create mzone
+* Input : const char* name
+* size_t size
+* Output : None
+* Return Value : mzone_handle
+* Calls :
+* Called By :
+*****************************************************************************/
+mzone_handle nsep_create_mzone(const char *name, size_t size)
+{
+ if (!name)
+ {
+ NSFW_LOGERR("name is NULL");
+ return NULL;
+ }
+
+ mzone_handle zone;
+ nsfw_mem_zone param;
+
+ param.isocket_id = -1;
+ param.lenth = size;
+ param.stname.entype = NSFW_SHMEM;
+
+ if (strcpy_s(param.stname.aname, NSFW_MEM_NAME_LENTH, name) != 0)
+ {
+ NSFW_LOGERR("strcpy_s failed]name=%s", name);
+ return NULL;
+ }
+
+ zone = nsfw_mem_zone_create(&param);
+ if (!zone)
+ {
+ NSFW_LOGERR("nsfw_mem_zone_create failed]name=%s, size:%zu", name,
+ size);
+ return NULL;
+ }
+
+ return zone;
+}
+
+/*****************************************************************************
+* Prototype : sbr_create_multi_ring
+* Description : create multi ring
+* Input : const char* name
+* u32 ring_size
+* i32 ring_num
+* mring_handle* array
+* nsfw_mpool_type type
+* Output : None
+* Return Value : int
+* Calls :
+* Called By :
+*****************************************************************************/
+int nsep_create_multi_ring(const char *name, u32 ring_size, i32 ring_num,
+ mring_handle * array, nsfw_mpool_type type)
+{
+ if (!name)
+ {
+ NSFW_LOGERR("name is NULL");
+ return -1;
+ }
+
+ if (!array)
+ {
+ NSFW_LOGERR("array is NULL");
+ return -1;
+ }
+
+ nsfw_mem_mring param;
+
+ if (EOK != memset_s(&param, sizeof(param), 0, sizeof(param)))
+ {
+ NSSBR_LOGERR("Error to memset]name=%s", name);
+ return -1;
+ }
+
+ param.enmptype = type;
+ param.stname.entype = NSFW_SHMEM;
+ if (strcpy_s(param.stname.aname, NSFW_MEM_NAME_LENTH, name) != 0)
+ {
+ NSSBR_LOGERR("strcpy_s failed]name=%s", name);
+ return -1;
+ }
+
+ param.usnum = ring_size - 1;
+ param.isocket_id = -1;
+ if (nsfw_mem_sp_ring_create(&param, array, ring_num) != 0)
+ {
+ NSSBR_LOGERR
+ ("Create ring pool failed]name=%s, ring_num=%d, ring_size=%u",
+ name, ring_num, ring_size);
+ return -1;
+ }
+
+ return 0;
+}
+
+NSTACK_STATIC int nsep_ep_conn_pool_create(void)
+{
+ u32_t pos;
+ int ret;
+
+ nsep_epollManager_t *manager = nsep_get_manager();
+
+ struct spl_conn_pool *conn_pool_array =
+ (struct spl_conn_pool *)
+ nsep_create_mzone(MP_NSTACK_SPL_CONN_ARRAY_NAME,
+ (size_t) sizeof(struct spl_conn_pool) *
+ NSTACK_MAX_EPOLL_FD_NUM);
+
+ if (!conn_pool_array)
+ {
+ NSSBR_LOGERR
+ ("Create tx_msg_array zone fail]name=%s, num=%u, size=%lu",
+ MP_NSTACK_SPL_CONN_ARRAY_NAME, NSTACK_MAX_EPOLL_FD_NUM,
+ (size_t) sizeof(struct spl_conn_pool) * NSTACK_MAX_EPOLL_FD_NUM);
+ return -1;
+ }
+
+ MEM_STAT(MP_NSTACK_SPL_CONN_POOL, MP_NSTACK_SPL_CONN_ARRAY_NAME,
+ NSFW_SHMEM,
+ (size_t) sizeof(struct spl_conn_pool) * NSTACK_MAX_EPOLL_FD_NUM);
+ NSSBR_LOGINF
+ ("Create tx_msg_array zone ok]name=%s, ptr=%p, num=%u, size=%lu",
+ MP_NSTACK_SPL_CONN_ARRAY_NAME, conn_pool_array,
+ NSTACK_MAX_EPOLL_FD_NUM,
+ sizeof(struct spl_conn_pool) * NSTACK_MAX_EPOLL_FD_NUM);
+
+ mring_handle *array =
+ (mring_handle *) malloc(NSTACK_MAX_EPOLL_FD_NUM *
+ sizeof(mring_handle));
+ if (NULL == array)
+ {
+ NSSOC_LOGERR("malloc failed");
+ return -1;
+ }
+
+ ret =
+ memset_s(array, NSTACK_MAX_EPOLL_FD_NUM * sizeof(mring_handle), 0,
+ NSTACK_MAX_EPOLL_FD_NUM * sizeof(mring_handle));
+ if (EOK != ret)
+ {
+ NSSOC_LOGERR("memset_s failed]ret=%d", ret);
+ free(array);
+ return -1;
+ }
+ if (nsep_create_multi_ring
+ (MP_NSTACK_SPL_CONN_POOL, NSTACK_MAX_EPOLL_INFO_NUM - 1,
+ NSTACK_MAX_EPOLL_FD_NUM - 1, (mring_handle *) array,
+ NSFW_MRING_MPMC) != 0)
+ {
+ free(array);
+ return -1;
+ }
+
+ for (pos = 0; pos < NSTACK_MAX_EPOLL_FD_NUM - 1; pos++)
+ {
+ conn_pool_array[pos].pid = 0;
+ conn_pool_array[pos].revents = 0;
+ conn_pool_array[pos].res_chk.alloc_flag = 0;
+ conn_pool_array[pos].res_chk.chk_count = 0;
+ conn_pool_array[pos].res_chk.data = 0;
+ conn_pool_array[pos].res_chk.u8Reserve = 0;
+ conn_pool_array[pos].ring_hd = array[pos];
+ if (-1 ==
+ nsfw_mem_ring_enqueue(manager->ep_connPoll.ring,
+ &conn_pool_array[pos]))
+ {
+ free(array);
+ NSSOC_LOGERR("init fail to enqueue epitem]pos=%u", pos);
+ return -1;
+ }
+ }
+ manager->ep_connPoll.pool = &conn_pool_array[0];
+ free(array);
+
+ return 0;
+}
+
+NSTACK_STATIC int nsep_ep_pool_init(void *addr, size_t lenth)
+{
+ u32_t pos;
+ int ret;
+
+ NSSOC_LOGDBG("Start to init eventpoll pool");
+
+ /* add return value check */
+ ret = memset_s(addr, lenth, 0, lenth);
+ if (EOK != ret)
+ {
+ NSSOC_LOGERR("memset_s failed]ret=%d", ret);
+ return -1;
+ }
+ struct eventpoll *pool = (struct eventpoll *) addr;
+ nsep_epollManager_t *manager = nsep_get_manager();
+ manager->epollPool.pool = pool;
+
+ /* init g_nStackInfo.sockPool->nstack_block_array */
+ for (pos = 0; pos < NSTACK_MAX_EPOLL_FD_NUM; pos++)
+ {
+ pool[pos].pid = 0;
+ if (-1 == nsfw_mem_ring_enqueue(manager->epollPool.ring, &pool[pos]))
+ {
+ NSSOC_LOGERR("init fail to enqueue epitem]pos=%u", pos);
+ return -1;
+ }
+ }
+
+ ret = nsep_ep_conn_pool_create();
+
+ if (0 != ret)
+ {
+ NSSOC_LOGERR("nsep_ep_conn_pool_create failed]ret=%d", ret);
+ return -1;
+ }
+
+ return 0;
+}
+
+NSTACK_STATIC int nsep_epitem_pool_init(void *addr, size_t lenth)
+{
+ u32_t pos;
+ int ret;
+
+ NSSOC_LOGDBG("Start to init epitem pool");
+
+ /* add return value check */
+ ret = memset_s(addr, lenth, 0, lenth);
+ if (EOK != ret)
+ {
+ NSSOC_LOGERR("memset_s failed]ret=%d", ret);
+ return -1;
+ }
+ struct epitem *pool = (struct epitem *) addr;
+ nsep_epollManager_t *manager = nsep_get_manager();
+ manager->epitemPool.pool = pool;
+
+ /* init g_nStackInfo.sockPool->nstack_block_array */
+ for (pos = 0; pos < NSTACK_MAX_EPITEM_NUM; pos++)
+ {
+ pool[pos].pid = 0;
+ pool[pos].ep_spl = NULL;
+ pool[pos].ptr_reserve = NULL;
+ if (-1 == nsfw_mem_ring_enqueue(manager->epitemPool.ring, &pool[pos]))
+ {
+ NSSOC_LOGERR("init fail to enqueue epitem]pos=%u", pos);
+ return -1;
+ }
+ }
+ return 0;
+}
+
+NSTACK_STATIC int nsep_epinfo_pool_init(void *addr, size_t lenth)
+{
+ u32_t pos;
+ int ret;
+
+ NSSOC_LOGDBG("shmem info init start");
+
+ /* add return value check */
+ ret = memset_s(addr, lenth, 0, lenth);
+ if (EOK != ret)
+ {
+ NSSOC_LOGERR("memset_s failed]ret=%d", ret);
+ return -1;
+ }
+ nsep_epollInfo_t *pool = (nsep_epollInfo_t *) addr;
+ nsep_epollManager_t *manager = nsep_get_manager();
+ manager->infoPool.pool = pool;
+
+ /* init g_nStackInfo.sockPool->nstack_block_array */
+ for (pos = 0; pos < NSTACK_MAX_EPOLL_INFO_NUM; pos++)
+ {
+ if (nsep_for_pidinfo_init(&(pool[pos].pidinfo)))
+ {
+ NSSOC_LOGERR("pid info init failed]pos=%u", pos);
+ return -1;
+ }
+
+ if (-1 == nsfw_mem_ring_enqueue(manager->infoPool.ring, &pool[pos]))
+ {
+ NSSOC_LOGERR("init fail to enqueue epInfo]pos=%u", pos);
+ return -1;
+ }
+ }
+
+ NSSOC_LOGDBG("nstack_shmen_info_init success");
+ return 0;
+}
+
+NSTACK_STATIC
+ int nsep_create_shmem(size_t length, char *name,
+ nsep_shem_initFn_t initFn)
+{
+ nsfw_mem_zone pmeminfo;
+ mzone_handle phandle;
+ int ret;
+
+ pmeminfo.ireserv = 0;
+ pmeminfo.isocket_id = NSFW_SOCKET_ANY;
+ pmeminfo.lenth = length;
+ ret =
+ strcpy_s(pmeminfo.stname.aname, sizeof(pmeminfo.stname.aname), name);
+ if (EOK != ret)
+ {
+ NSSOC_LOGERR("strcpy_s failed]name=%s,ret=%d", name, ret);
+ return -1;
+ }
+ pmeminfo.stname.entype = NSFW_SHMEM;
+
+ phandle = nsfw_mem_zone_create(&pmeminfo);
+ if (NULL == phandle)
+ {
+ NSSOC_LOGERR("create nstack epoll memory failed]name=%s", name);
+ return -1;
+ }
+
+ if (0 != initFn((void *) phandle, length))
+ {
+ NSSOC_LOGERR("Fail to init memory]name=%s", name);
+ (void) nsfw_mem_zone_release(&pmeminfo.stname); //3th round code security review fix
+ return -1;
+ }
+
+ return 0;
+}
+
+NSTACK_STATIC int nsep_create_epinfo_mem()
+{
+ nsfw_mem_mring pringinfo;
+ pringinfo.enmptype = NSFW_MRING_MPMC;
+ pringinfo.isocket_id = NSFW_SOCKET_ANY;
+ pringinfo.stname.entype = NSFW_SHMEM;
+ pringinfo.usnum = NSTACK_MAX_EPOLL_INFO_NUM - 1;
+
+ if (-1 ==
+ sprintf_s(pringinfo.stname.aname, NSFW_MEM_NAME_LENTH, "%s",
+ MP_NSTACK_EPINFO_RING_NAME))
+ {
+ NSSOC_LOGERR("Error to create ring]name=%s", pringinfo.stname.aname);
+ return -1;
+ }
+
+ mring_handle ring_handle = nsfw_mem_ring_create(&pringinfo);
+
+ if (NULL == ring_handle)
+ {
+ NSSOC_LOGERR("Error to create ring]name=%s", pringinfo.stname.aname);
+ return -1;
+ }
+
+ nsep_epollManager_t *manager = nsep_get_manager();
+ manager->infoPool.ring = ring_handle;
+
+ return nsep_create_shmem(sizeof(nsep_epollInfo_t) *
+ NSTACK_MAX_EPOLL_INFO_NUM,
+ MP_NSTACK_EPOLL_INFO_NAME,
+ nsep_epinfo_pool_init);
+}
+
+NSTACK_STATIC int nsep_adpt_attach_epinfo_mem()
+{
+ nsfw_mem_name name;
+ name.entype = NSFW_SHMEM;
+ name.enowner = NSFW_PROC_MAIN;
+
+ if (-1 ==
+ sprintf_s(name.aname, NSFW_MEM_NAME_LENTH, "%s",
+ MP_NSTACK_EPINFO_RING_NAME))
+ {
+ NSSOC_LOGERR("Error to attach ring]name=%s", name.aname);
+ return -1;
+ }
+ mring_handle ring_handle = nsfw_mem_ring_lookup(&name);
+
+ if (NULL == ring_handle)
+ {
+ NSSOC_LOGERR("Error to attach ring]name=%s", name.aname);
+ return -1;
+ }
+
+ nsep_epollManager_t *manager = nsep_get_manager();
+ manager->infoPool.ring = ring_handle;
+
+ if (-1 ==
+ sprintf_s(name.aname, NSFW_MEM_NAME_LENTH, "%s",
+ MP_NSTACK_EPOLL_INFO_NAME))
+ {
+ NSSOC_LOGERR("sprintf_s failed]");
+ return -1;
+ }
+ manager->infoPool.pool = nsfw_mem_zone_lookup(&name);
+ if (NULL == manager->infoPool.pool)
+ {
+ NSSOC_LOGERR("Error to attach memzone]name=%s",
+ MP_NSTACK_EPOLL_INFO_NAME);
+ return -1;
+ }
+ return 0;
+}
+
+NSTACK_STATIC int nsep_create_epitem_mem()
+{
+ nsfw_mem_mring pringinfo;
+ pringinfo.enmptype = NSFW_MRING_MPMC;
+ pringinfo.isocket_id = NSFW_SOCKET_ANY;
+ pringinfo.stname.entype = NSFW_SHMEM;
+ pringinfo.usnum = NSTACK_MAX_EPITEM_NUM - 1;
+
+ if (-1 ==
+ sprintf_s(pringinfo.stname.aname, NSFW_MEM_NAME_LENTH, "%s",
+ MP_NSTACK_EPITEM_RING_NAME))
+ {
+ NSSOC_LOGERR("Error to create ring]name=%s", pringinfo.stname.aname);
+ return -1;
+ }
+
+ mring_handle ring_handle = nsfw_mem_ring_create(&pringinfo);
+
+ if (NULL == ring_handle)
+ {
+ NSSOC_LOGERR("Error to create ring]name=%s", pringinfo.stname.aname);
+ return -1;
+ }
+
+ nsep_epollManager_t *manager = nsep_get_manager();
+ manager->epitemPool.ring = ring_handle;
+
+ return nsep_create_shmem(sizeof(struct epitem) * NSTACK_MAX_EPITEM_NUM,
+ MP_NSTACK_EPITEM_POOL, nsep_epitem_pool_init);
+
+}
+
+NSTACK_STATIC int nsep_adpt_attach_epitem_mem()
+{
+ nsfw_mem_name name;
+ name.entype = NSFW_SHMEM;
+ name.enowner = NSFW_PROC_MAIN;
+
+ if (-1 ==
+ sprintf_s(name.aname, NSFW_MEM_NAME_LENTH, "%s",
+ MP_NSTACK_EPITEM_RING_NAME))
+ {
+ NSSOC_LOGERR("Error to attach epItemMem]name=%s", name.aname);
+ return -1;
+ }
+
+ mring_handle ring_handle = nsfw_mem_ring_lookup(&name);
+
+ if (NULL == ring_handle)
+ {
+ NSSOC_LOGERR("Error to attach ring]name=%s", name.aname);
+ return -1;
+ }
+
+ nsep_epollManager_t *manager = nsep_get_manager();
+ manager->epitemPool.ring = ring_handle;
+
+ if (-1 ==
+ sprintf_s(name.aname, NSFW_MEM_NAME_LENTH, "%s",
+ MP_NSTACK_EPITEM_POOL))
+ {
+ NSSOC_LOGERR("sprintf_s failed]");
+ return -1;
+ }
+
+ manager->epitemPool.pool = nsfw_mem_zone_lookup(&name);
+ if (NULL == manager->epitemPool.pool)
+ {
+ NSSOC_LOGERR("Error to attach memzone]name=%s",
+ MP_NSTACK_EPITEM_POOL);
+ return -1;
+ }
+ return 0;
+}
+
+NSTACK_STATIC int nsep_create_eventpoll_mem()
+{
+ nsfw_mem_mring pringinfo;
+ pringinfo.enmptype = NSFW_MRING_MPMC;
+ pringinfo.isocket_id = NSFW_SOCKET_ANY;
+ pringinfo.stname.entype = NSFW_SHMEM;
+ pringinfo.usnum = NSTACK_MAX_EPOLL_FD_NUM - 1;
+
+ if (-1 ==
+ sprintf_s(pringinfo.stname.aname, NSFW_MEM_NAME_LENTH, "%s",
+ MP_NSTACK_EVENTPOOL_RING_NAME))
+ {
+ NSSOC_LOGERR("Error to create ring]name=%s", pringinfo.stname.aname);
+ return -1;
+ }
+
+ mring_handle ring_handle = nsfw_mem_ring_create(&pringinfo);
+
+ if (NULL == ring_handle)
+ {
+ NSSOC_LOGERR("Error to create ring]name=%s", pringinfo.stname.aname);
+ return -1;
+ }
+
+ nsep_epollManager_t *manager = nsep_get_manager();
+ manager->epollPool.ring = ring_handle;
+
+ pringinfo.usnum = NSTACK_MAX_EPOLL_FD_NUM - 1;
+ if (-1 ==
+ sprintf_s(pringinfo.stname.aname, NSFW_MEM_NAME_LENTH, "%s",
+ MP_NSTACK_SPL_CONN_RING_NAME))
+ {
+ NSSOC_LOGERR("Error to create ring]name=%s", pringinfo.stname.aname);
+ return -1;
+ }
+
+ ring_handle = nsfw_mem_ring_create(&pringinfo);
+
+ if (NULL == ring_handle)
+ {
+ NSSOC_LOGERR("Error to create ring]name=%s", pringinfo.stname.aname);
+ return -1;
+ }
+
+ manager->ep_connPoll.ring = ring_handle;
+
+ return nsep_create_shmem(sizeof(struct eventpoll) *
+ NSTACK_MAX_EPOLL_FD_NUM,
+ MP_NSTACK_EVENTPOLL_POOL, nsep_ep_pool_init);
+}
+
+NSTACK_STATIC int nsep_adpt_attach_eventpoll_mem()
+{
+ nsfw_mem_name name;
+ u32 tmp_count = 0;
+ name.entype = NSFW_SHMEM;
+ name.enowner = NSFW_PROC_MAIN;
+
+ if (-1 ==
+ sprintf_s(name.aname, NSFW_MEM_NAME_LENTH, "%s",
+ MP_NSTACK_EVENTPOOL_RING_NAME))
+ {
+ NSSOC_LOGERR("Error to attach ring]name=%s", name.aname);
+ return -1;
+ }
+
+ mring_handle ring_handle = nsfw_mem_ring_lookup(&name);
+
+ if (NULL == ring_handle)
+ {
+ NSSOC_LOGERR("Error to create ring]name=%s", name.aname);
+ return -1;
+ }
+
+ nsep_epollManager_t *manager = nsep_get_manager();
+ manager->epollPool.ring = ring_handle;
+
+ int retVal = sprintf_s(name.aname, NSFW_MEM_NAME_LENTH, "%s",
+ MP_NSTACK_EVENTPOLL_POOL);
+ if (-1 == retVal)
+ {
+ NSSOC_LOGERR("sprintf_s faild]ret=%d", retVal);
+ return -1;
+ }
+ manager->epollPool.pool = nsfw_mem_zone_lookup(&name);
+ if (NULL == manager->epollPool.pool)
+ {
+ NSSOC_LOGERR("Error to attach memzone]name=%s",
+ MP_NSTACK_EVENTPOLL_POOL);
+ return -1;
+ }
+
+ retVal =
+ sprintf_s(name.aname, NSFW_MEM_NAME_LENTH, "%s",
+ MP_NSTACK_SPL_CONN_RING_NAME);
+ if (-1 == retVal)
+ {
+ NSSOC_LOGERR("sprintf_s faild]ret=%d", retVal);
+ return -1;
+ }
+
+ manager->ep_connPoll.ring = nsfw_mem_zone_lookup(&name);
+ if (NULL == manager->ep_connPoll.ring)
+ {
+
+ nsfw_mem_mring pringinfo;
+ pringinfo.enmptype = NSFW_MRING_MPMC;
+ pringinfo.isocket_id = NSFW_SOCKET_ANY;
+ pringinfo.stname.entype = NSFW_SHMEM;
+ pringinfo.usnum = NSTACK_MAX_EPOLL_FD_NUM;
+ if (-1 ==
+ sprintf_s(pringinfo.stname.aname, NSFW_MEM_NAME_LENTH, "%s",
+ MP_NSTACK_SPL_CONN_RING_NAME))
+ {
+ NSSOC_LOGERR("Error to create ring]name=%s",
+ pringinfo.stname.aname);
+ return -1;
+ }
+
+ ring_handle = nsfw_mem_ring_create(&pringinfo);
+
+ if (NULL == ring_handle)
+ {
+ NSSOC_LOGERR("Error to create ring]name=%s",
+ pringinfo.stname.aname);
+ return -1;
+ }
+
+ manager->ep_connPoll.ring = ring_handle;
+
+ }
+
+ retVal =
+ sprintf_s(name.aname, NSFW_MEM_NAME_LENTH, "%s",
+ MP_NSTACK_SPL_CONN_ARRAY_NAME);
+ if (-1 == retVal)
+ {
+ NSSOC_LOGERR("sprintf_s faild]ret=%d", retVal);
+ return -1;
+ }
+
+ manager->ep_connPoll.pool = nsfw_mem_zone_lookup(&name);
+ if (NULL == manager->ep_connPoll.pool)
+ {
+ retVal = nsep_ep_conn_pool_create();
+ if (0 != retVal)
+ {
+ NSSOC_LOGERR("nsep_ep_conn_pool_create failed]ret=%d", retVal);
+ return -1;
+ }
+ }
+ else
+ {
+ /* epoll global lock in daemon-stack cause daemon-stack message handle slowing */
+ nsep_recycle_upgrade_resource();
+ tmp_count = nsfw_mem_ring_using_count(manager->ep_connPoll.ring);
+ NSSOC_LOGINF("ep_connPoll.ring]ring=%p,free_num=%u",
+ manager->ep_connPoll.ring, tmp_count);
+ }
+
+ return 0;
+}
+
+int nsep_create_memory()
+{
+ typedef int (*nsep_createMemFunc_t) (void);
+ nsep_createMemFunc_t createFuncs[] = { nsep_create_epinfo_mem,
+ nsep_create_epitem_mem,
+ nsep_create_eventpoll_mem
+ };
+
+ int i = 0;
+ for (i = 0;
+ i < (int) (sizeof(createFuncs) / sizeof(nsep_createMemFunc_t)); i++)
+ {
+ if (-1 == createFuncs[i] ())
+ return -1;
+ }
+
+ return 0;
+}
+
+int nsep_adpt_attach_memory()
+{
+ typedef int (*nsep_attachMemFunc_t) (void);
+ nsep_attachMemFunc_t attachFuncs[] = { nsep_adpt_attach_epinfo_mem,
+ nsep_adpt_attach_epitem_mem,
+ nsep_adpt_attach_eventpoll_mem
+ };
+
+ int i = 0;
+ for (i = 0;
+ i < (int) (sizeof(attachFuncs) / sizeof(nsep_attachMemFunc_t)); i++)
+ {
+ if (-1 == attachFuncs[i] ())
+ {
+ NSSOC_LOGERR("mem attach fail]idx=%d", i);
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+int nsep_adpt_reg_res_mgr()
+{
+ nsep_epollManager_t *manager = nsep_get_manager();
+
+ nsfw_res_scn_cfg scn_cfg_info = { NSFW_RES_SCAN_ARRAY, 90, 3, 16,
+ NSTACK_MAX_EPOLL_INFO_NUM / 128, NSTACK_MAX_EPOLL_INFO_NUM,
+ sizeof(nsep_epollInfo_t),
+
+ offsetof(nsep_epollInfo_t, res_chk),
+
+ manager->infoPool.pool,
+ manager->infoPool.ring,
+ nsep_force_epinfo_free
+ };
+
+ nsfw_res_scn_cfg scn_cfg_item = { NSFW_RES_SCAN_ARRAY, 90, 3, 16,
+ NSTACK_MAX_EPITEM_NUM / 128, NSTACK_MAX_EPITEM_NUM,
+ sizeof(struct epitem),
+
+ offsetof(struct epitem, res_chk),
+
+ manager->epitemPool.pool,
+ manager->epitemPool.ring,
+ nsep_force_epitem_free
+ };
+
+ nsfw_res_scn_cfg scn_cfg_event = { NSFW_RES_SCAN_ARRAY, 90, 3, 16,
+ NSTACK_MAX_EPOLL_FD_NUM / 16, NSTACK_MAX_EPOLL_FD_NUM,
+ sizeof(struct eventpoll),
+
+ offsetof(struct eventpoll, res_chk),
+
+ manager->epollPool.pool,
+ manager->epollPool.ring,
+ nsep_force_epevent_free
+ };
+
+ /* solve epoll_wait hangup issue, because force free invalid ep_conn */
+ nsfw_res_scn_cfg scn_cfg_spl_conn = { NSFW_RES_SCAN_ARRAY, 90, 3, 16,
+ NSTACK_MAX_EPOLL_FD_NUM / 16, NSTACK_MAX_EPOLL_FD_NUM,
+ sizeof(struct spl_conn_pool),
+
+ offsetof(struct spl_conn_pool, res_chk),
+
+ manager->ep_connPoll.pool,
+ manager->ep_connPoll.ring,
+ nsep_force_ep_spl_conn_free
+ };
+
+ (void) nsfw_res_mgr_reg(&scn_cfg_info);
+ (void) nsfw_res_mgr_reg(&scn_cfg_item);
+ (void) nsfw_res_mgr_reg(&scn_cfg_event);
+ (void) nsfw_res_mgr_reg(&scn_cfg_spl_conn);
+ return 0;
+}
+
+int nsep_epitem_remove(nsep_epollInfo_t * pinfo, u32 pid)
+{
+ struct list_node *prenode = NULL;
+ struct list_node *nextnode = NULL;
+ struct epitem *epi = NULL;
+ u32_t i = 0;
+ int icnt = 0;
+
+ (void) dmm_spin_lock_with_pid(&pinfo->epiLock);
+ /*list head must be not null */
+ prenode = (struct list_node *) SHMEM_ADDR_SHTOL(pinfo->epiList.head);
+ nextnode = (struct list_node *) SHMEM_ADDR_SHTOL(prenode->next);
+ /* Change "<=" to "<" */
+ while ((nextnode) && (i++ < NSTACK_MAX_EPOLL_INFO_NUM))
+ {
+
+ epi = ep_list_entry(nextnode, struct epitem, fllink);
+ if (pid == epi->pid)
+ {
+ /*shmem equal to shmem */
+ prenode->next = nextnode->next;
+ nextnode->next = NULL;
+ /* after close fd in epfd, epfd still can epoll_wait EPOLLIN event for these fd */
+ (void) nstack_epoll_event_dequeue(epi, 0);
+ (void) nsep_free_epitem(epi);
+ nextnode = SHMEM_ADDR_SHTOL(prenode->next);
+ icnt++;
+ continue;
+ }
+ prenode = nextnode;
+ nextnode = SHMEM_ADDR_SHTOL(nextnode->next);
+ }
+ dmm_spin_unlock(&pinfo->epiLock);
+ if (i >= NSTACK_MAX_EPOLL_INFO_NUM)
+ {
+ NSSOC_LOGERR("free pinfo:%p pid:%u, error maybe happen", pinfo, pid);
+ }
+ /* needn't call:nsep_epctl_triggle(NULL, epInfo, nstack_ep_triggle_inform), because here is called by daemon-stack */
+ return icnt;
+}
+
+void nsep_recycle_epfd(void *epinfo, u32 pid)
+{
+ struct eventpoll *ep = NULL;
+ struct spl_conn_pool *ep_conn = NULL;
+ nsep_epollInfo_t *info = (nsep_epollInfo_t *) SHMEM_ADDR_SHTOL(epinfo);
+ int ret = 0;
+ int ileftcnt = 0;
+ if (!epinfo)
+ {
+ NSSOC_LOGDBG("input null, pid:%u", pid);
+ return;
+ }
+ (void) dmm_spin_lock_with_pid(&info->freeLock);
+ ileftcnt = nsep_del_last_pid(&info->pidinfo, pid);
+ dmm_spin_unlock(&info->freeLock);
+ /*no pid exist */
+ if (-1 == ileftcnt)
+ {
+ return;
+ }
+ if (NSTACK_EPOL_FD == info->fdtype)
+ {
+ NSSOC_LOGDBG("recycle epfd:%d epinfo pid:%u begin...", info->fd, pid);
+ if (0 == ileftcnt)
+ {
+ ep = SHMEM_ADDR_SHTOL(info->ep);
+ ep_conn = SHMEM_ADDR_SHTOL(info->ep_conn);
+ info->ep = NULL;
+ (void) nsep_free_eventpoll(ep);
+ (void) nsep_free_ep_spl_conn_ring(ep_conn);
+ info->ep_conn = NULL;
+ (void) nsep_free_epinfo(info);
+ }
+ return;
+ }
+
+ NSSOC_LOGDBG("recycle fd:%d epinfo pid:%u begin...", info->fd, pid);
+
+ ret = nsep_epitem_remove(info, pid);
+ if (0 != ret)
+ {
+ NSSOC_LOGDBG("info:%p, fd:%d pid:%u, %d items was left", info,
+ info->fd, pid, ret);
+ }
+
+ if (0 == ileftcnt)
+ {
+ NSSOC_LOGDBG("info:%p, fd:%d pid:%u was finally freed", info,
+ info->fd, pid);
+ (void) nsep_free_epinfo(info);
+ }
+ return;
+}
+
+int nsep_recyle_ep(u32 pid)
+{
+ nsep_epollManager_t *manager = nsep_get_manager();
+ nsep_epollInfo_t *pool = manager->infoPool.pool;
+
+ u32_t pos;
+ for (pos = 0; pos < NSTACK_MAX_EPOLL_INFO_NUM; pos++)
+ {
+ (void) nsep_recycle_epfd(&pool[pos], pid);
+ }
+ return 0;
+}
+
+NSTACK_STATIC int nsep_recyle_epitem(u32 pid)
+{
+ nsep_epollManager_t *manager = nsep_get_manager();
+ struct epitem *pool = manager->epitemPool.pool;
+
+ u32_t pos;
+ for (pos = 0; pos < NSTACK_MAX_EPITEM_NUM; pos++)
+ {
+ if (pool[pos].pid != pid)
+ continue;
+
+ if (-1 == nsep_free_epitem(&pool[pos]))
+ return -1;
+ }
+
+ return 0;
+}
+
+NSTACK_STATIC int nsep_recyle_eventpoll(u32 pid)
+{
+ nsep_epollManager_t *manager = nsep_get_manager();
+ struct eventpoll *pool = manager->epollPool.pool;
+
+ u32_t pos;
+ for (pos = 0; pos < NSTACK_MAX_EPOLL_INFO_NUM; pos++)
+ {
+ if (pool[pos].pid != pid)
+ continue;
+
+ if (-1 == nsep_free_eventpoll(&pool[pos]))
+ return -1;
+ }
+
+ return 0;
+}
+
+NSTACK_STATIC int nsep_recyle_spl_conn_pool(u32 pid)
+{
+ nsep_epollManager_t *manager = nsep_get_manager();
+ struct spl_conn_pool *pool = manager->ep_connPoll.pool;
+
+ u32_t pos;
+ for (pos = 0; pos < NSTACK_MAX_EPOLL_FD_NUM - 1; pos++)
+ {
+ if (pool[pos].pid != pid)
+ continue;
+
+ if (-1 == nsep_free_ep_spl_conn_ring(&pool[pos]))
+ {
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+nsfw_rcc_stat nsep_recycle_resource(u32 exit_pid, void *pdata, u16 rec_type)
+{
+ NSSOC_LOGINF("pid:%u recycle", exit_pid);
+ //nsep_recyle_epInfo(exit_pid);
+ (void) nsep_recyle_epitem(exit_pid);
+ (void) nsep_recyle_eventpoll(exit_pid);
+ (void) nsep_recyle_spl_conn_pool(exit_pid);
+ return NSFW_RCC_CONTINUE;
+}
+
+NSTACK_STATIC
+ nsfw_rcc_stat nsep_recyle_lock(u32 pid, void *pdata, u16 rec_type)
+{
+ nsep_epollManager_t *manager = nsep_get_manager();
+ nsep_epollInfo_t *pool = manager->infoPool.pool;
+ u32_t pos;
+ if (NULL != pool)
+ {
+ for (pos = 0; pos < NSTACK_MAX_EPOLL_INFO_NUM; pos++)
+ {
+ if (pid == pool[pos].epiLock.lock)
+ {
+ pool[pos].epiLock.lock = 0;
+ NSFW_LOGWAR("epiLock locked]pos=%u,pid=%u", pos, pid);
+ }
+ if (pid == pool[pos].freeLock.lock)
+ {
+ pool[pos].freeLock.lock = 0;
+ NSFW_LOGWAR("freelock locked]pos=%u,pid=%u", pos, pid);
+ }
+ }
+ }
+
+ struct eventpoll *ev_pool = manager->epollPool.pool;
+ if (NULL != ev_pool)
+ {
+ for (pos = 0; pos < NSTACK_MAX_EPOLL_FD_NUM; pos++)
+ {
+ if (pid == ev_pool[pos].lock.lock)
+ {
+ ev_pool[pos].lock.lock = 0;
+ NSFW_LOGWAR("event_pollLock locked]pos=%u,pid=%u", pos, pid);
+ }
+
+ if (pid == ev_pool[pos].sem.lock)
+ {
+ ev_pool[pos].sem.lock = 0;
+ NSFW_LOGWAR("event_pollLock sem]pos=%u,pid=%u", pos, pid);
+ }
+ }
+ }
+
+ return NSFW_RCC_CONTINUE;
+}
+
+int nstack_adpt_init(int flag)
+{
+ int ret;
+ if (0 == flag)
+ {
+ if (nstack_init_share_res() != 0)
+ {
+ return -1;
+ }
+
+ ret = nsep_create_memory();
+ }
+ else
+ {
+ if (nstack_attach_share_res() != 0)
+ {
+ return -1;
+ }
+
+ /**
+ * the share memory for epoll is created and usedy be app, don't clear
+ * it in fault case.
+ */
+ ret = nsep_adpt_attach_memory();
+ }
+
+ if (ret)
+ {
+ return ret;
+ }
+ void *pret =
+ nsfw_recycle_reg_obj(NSFW_REC_PRO_LOWEST, NSFW_REC_NSOCKET_EPOLL,
+ NULL);
+ if (!pret)
+ {
+ NSFW_LOGERR("regist recycle failed");
+ return -1;
+ }
+
+ (void) nsep_adpt_reg_res_mgr(); // not implemented now, no need to check return value
+ return 0;
+}
+
+REGIST_RECYCLE_OBJ_FUN(NSFW_REC_NSOCKET_EPOLL, nsep_recycle_resource)
+REGIST_RECYCLE_LOCK_REL(nsep_recyle_lock, NULL, NSFW_PROC_NULL)
diff --git a/src/framework/event/epoll/nstack_eventpoll.c b/src/framework/event/epoll/nstack_eventpoll.c
new file mode 100644
index 0000000..60fa8b4
--- /dev/null
+++ b/src/framework/event/epoll/nstack_eventpoll.c
@@ -0,0 +1,391 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#include "nstack_eventpoll.h"
+#include "nstack_log.h"
+#include "nsfw_recycle_api.h"
+#include "nstack_securec.h"
+//#include "nstack_module.h"
+//#include "nstack_sockops.h"
+#include "nsfw_mem_api.h"
+//#include "nstack_fd_mng.h"
+//#include "nstack.h"
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C"{
+/* *INDENT-ON* */
+#endif /* __cplusplus */
+
+static uint32_t g_nstack_epoll_fd_max = 0;
+static uint32_t g_nstack_epoll_module_max = 0;
+
+#define EP_CHECK_SOCK_VALID(_sock) ((_sock) >= 0 && (u32_t)(_sock) < g_nstack_epoll_fd_max)
+
+void nsep_set_info_sock_map(int sock, nsep_epollInfo_t * info)
+{
+ nsep_epollManager_t *manager = nsep_get_manager();
+ if (NULL == manager->infoSockMap)
+ return;
+
+ if (sock < 0 || (u32_t) sock >= g_nstack_epoll_fd_max)
+ return;
+
+ manager->infoSockMap[sock] = info;
+}
+
+nsep_epollInfo_t *nsep_get_info_by_sock(int sock)
+{
+ nsep_epollManager_t *manager = nsep_get_manager();
+ if ((NULL == manager) || (NULL == manager->infoSockMap))
+ return NULL;
+
+ if (sock < 0 || (u32_t) sock >= g_nstack_epoll_fd_max)
+ return NULL;
+
+ return manager->infoSockMap[sock];
+}
+
+int nsep_alloc_info_with_sock(int nfd)
+{
+
+ nsep_epollInfo_t *epInfo = NULL;
+
+ if (!EP_CHECK_SOCK_VALID(nfd))
+ {
+ return -1;
+ }
+
+ if (-1 == nsep_alloc_epinfo(&epInfo))
+ {
+ NSSOC_LOGERR("Alloc share info fail,[return]");
+ return -1;
+ }
+
+ epInfo->fd = nfd;
+
+ nsep_set_info_sock_map(nfd, epInfo);
+
+ return 0;
+}
+
+void nsep_set_info_proto_fd(int fd, int modInx, int protoFD)
+{
+ nsep_epollInfo_t *epInfo = nsep_get_info_by_sock(fd);
+
+ if (NULL == epInfo)
+ return;
+
+ if (modInx < 0 || modInx >= g_nstack_epoll_module_max)
+ return;
+
+ epInfo->protoFD[modInx] = protoFD;
+}
+
+int nsep_get_info_proto_fd(int fd, int modInx)
+{
+ nsep_epollInfo_t *epInfo = nsep_get_info_by_sock(fd);
+
+ if (NULL == epInfo)
+ return -1;
+
+ return epInfo->protoFD[modInx];
+}
+
+void nsep_set_infomdix(int fd, int rmidx)
+{
+ nsep_epollInfo_t *epInfo = nsep_get_info_by_sock(fd);
+
+ if (NULL == epInfo)
+ return;
+
+ epInfo->rmidx = rmidx;
+}
+
+int nsep_get_info_midx(int fd)
+{
+ nsep_epollInfo_t *epInfo = nsep_get_info_by_sock(fd);
+
+ if (NULL == epInfo)
+ return -1;
+
+ return epInfo->rmidx;
+}
+
+void nsep_set_info_rlfd(int fd, int rlfd)
+{
+ nsep_epollInfo_t *epInfo = nsep_get_info_by_sock(fd);
+
+ if (NULL == epInfo)
+ return;
+
+ epInfo->rlfd = rlfd;
+}
+
+int nsep_get_info_rlfd(int fd)
+{
+ nsep_epollInfo_t *epInfo = nsep_get_info_by_sock(fd);
+
+ if (NULL == epInfo)
+ return -1;
+
+ return epInfo->rlfd;
+}
+
+void nsep_set_info_sleep_time(int fd, u32 sleepTime)
+{
+ nsep_epollInfo_t *epInfo = nsep_get_info_by_sock(fd);
+
+ if (NULL == epInfo)
+ return;
+
+ epInfo->sleepTime = sleepTime;
+}
+
+int nsep_get_info_sleep_time(int fd)
+{
+ nsep_epollInfo_t *epInfo = nsep_get_info_by_sock(fd);
+
+ if (NULL == epInfo)
+ return -1;
+
+ return epInfo->sleepTime;
+}
+
+/* if APP got killed while ep and
+ fdtype has been assigned but ep_conn not, the daemon-stack will trigger cordump when recycling
+ APP's ep resource. So we must make sure ep and ep_conn has been assigned before fdtype get NSTACK_EPOL_FD,
+ and combine them both to single function */
+void nsep_set_info_ep_resource(int fd, struct eventpoll *ep,
+ struct spl_conn_pool *ep_spl_conn)
+{
+ nsep_epollInfo_t *epInfo = nsep_get_info_by_sock(fd);
+
+ if (NULL == epInfo)
+ return;
+
+ epInfo->ep_conn = (struct spl_conn_pool *) SHMEM_ADDR_LTOSH(ep_spl_conn);
+ epInfo->ep = (struct eventpoll *) SHMEM_ADDR_LTOSH(ep);
+
+ epInfo->fdtype = NSTACK_EPOL_FD;
+}
+
+struct eventpoll *nsep_get_info_ep(int fd)
+{
+ nsep_epollInfo_t *epInfo = nsep_get_info_by_sock(fd);
+
+ if (NULL == epInfo)
+ return NULL;
+
+ return (struct eventpoll *) SHMEM_ADDR_SHTOL(epInfo->ep);
+}
+
+int nsep_free_info_with_sock(int nfd)
+{
+ if ((u32_t) nfd >= g_nstack_epoll_fd_max || nfd < 0)
+ return -1;
+
+ nsep_epollInfo_t *info = nsep_get_info_by_sock(nfd);
+
+ if (NULL == info)
+ return 0;
+
+ nsep_set_info_sock_map(nfd, NULL);
+
+ NSSOC_LOGDBG("nsep_free_info_with_sock info:%p, nfd:%d", info, nfd);
+ /* If this not just used by linux, it should be freed in stackpool */
+ if (-1 == nsep_free_epinfo(info))
+ {
+ NSSOC_LOGERR("Error to free ep info");
+ return -1;
+ }
+ return 0;
+}
+
+/**
+ * @Function nsep_init_info_sock_map
+ * @Description initial map of epoll info and socket
+ * @param none
+ * @return 0 on success, -1 on error
+ */
+int nsep_init_info_sock_map(uint32_t epoll_fd_max, uint32_t module_max)
+{
+ nsep_epollManager_t *manager = nsep_get_manager();
+ /*this function is necessary */
+
+ g_nstack_epoll_fd_max = epoll_fd_max;
+ g_nstack_epoll_module_max = module_max;
+ nsep_epollInfo_t **map =
+ (nsep_epollInfo_t **) malloc(g_nstack_epoll_fd_max *
+ sizeof(nsep_epollInfo_t *));
+
+ if (!map)
+ {
+ NSSOC_LOGERR("malloc epInfoPool fail");
+ return -1;
+ }
+
+ u32_t iindex;
+ for (iindex = 0; iindex < g_nstack_epoll_fd_max; iindex++)
+ {
+ map[iindex] = NULL;
+ }
+
+ manager->infoSockMap = map;
+
+ return 0;
+}
+
+NSTACK_STATIC mzone_handle nsep_ring_lookup(char *name)
+{
+ if (NULL == name)
+ {
+ NSSOC_LOGERR("param error]name=%p", name);
+ return NULL;
+ }
+
+ nsfw_mem_name mem_name;
+ /*modify strncpy to strcpy, because strlen(name) with strncpy is meaningless */
+ if (EOK != strcpy_s(mem_name.aname, sizeof(mem_name.aname), name))
+ { /*not null here */
+ NSSOC_LOGERR("Error to lookup ring by name, strcpy fail]name=%s",
+ name);
+ return NULL;
+ }
+ mem_name.enowner = NSFW_PROC_MAIN;
+ mem_name.entype = NSFW_SHMEM;
+
+ return nsfw_mem_ring_lookup(&mem_name);
+}
+
+NSTACK_STATIC mzone_handle nsep_attach_shmem(char *name)
+{
+ if (NULL == name)
+ {
+ NSSOC_LOGERR("param error]name=%p", name);
+ return NULL;
+ }
+
+ nsfw_mem_name mem_name;
+ /*add return value check */
+ int retVal = strcpy_s(mem_name.aname, sizeof(mem_name.aname), name);
+ if (EOK != retVal)
+ {
+ NSSOC_LOGERR("strcpy_s failed]");
+ return NULL;
+ }
+ mem_name.enowner = NSFW_PROC_MAIN;
+ mem_name.entype = NSFW_SHMEM;
+
+ return nsfw_mem_zone_lookup(&mem_name);
+}
+
+NSTACK_STATIC int nsep_attach_info_mem()
+{
+ mzone_handle hdl = nsep_attach_shmem(MP_NSTACK_EPOLL_INFO_NAME);
+ if (NULL == hdl)
+ return -1;
+
+ nsep_epollManager_t *manager = nsep_get_manager();
+ manager->infoPool.pool = (nsep_epollInfo_t *) hdl;
+
+ hdl = nsep_ring_lookup(MP_NSTACK_EPINFO_RING_NAME);
+ if (NULL == hdl)
+ {
+ NSSOC_LOGERR("Fail to loock up epoll info ring]name=%s",
+ MP_NSTACK_EPINFO_RING_NAME);
+ return -1;
+ }
+
+ manager->infoPool.ring = hdl;
+
+ return 0;
+}
+
+NSTACK_STATIC int nsep_attach_epitem_mem()
+{
+ mzone_handle hdl = nsep_attach_shmem(MP_NSTACK_EPITEM_POOL);
+ if (NULL == hdl)
+ return -1;
+
+ nsep_epollManager_t *manager = nsep_get_manager();
+ manager->epitemPool.pool = (struct epitem *) hdl;
+
+ hdl = nsep_ring_lookup(MP_NSTACK_EPITEM_RING_NAME);
+ if (NULL == hdl)
+ {
+ NSSOC_LOGERR("Fail to loock up epoll info ring]name=%s",
+ MP_NSTACK_EPITEM_RING_NAME);
+ return -1;
+ }
+
+ manager->epitemPool.ring = hdl;
+
+ return 0;
+}
+
+NSTACK_STATIC int nsep_attach_eventpoll_mem()
+{
+ mzone_handle hdl = nsep_attach_shmem(MP_NSTACK_EVENTPOLL_POOL);
+ if (NULL == hdl)
+ return -1;
+
+ nsep_epollManager_t *manager = nsep_get_manager();
+ manager->epollPool.pool = (struct eventpoll *) hdl;
+
+ hdl = nsep_ring_lookup(MP_NSTACK_EVENTPOOL_RING_NAME);
+ if (NULL == hdl)
+ {
+ NSSOC_LOGERR("Fail to loock up epoll info ring]name=%s",
+ MP_NSTACK_EVENTPOOL_RING_NAME);
+ return -1;
+ }
+
+ manager->epollPool.ring = hdl;
+
+ hdl = nsep_ring_lookup(MP_NSTACK_SPL_CONN_RING_NAME);
+ manager->ep_connPoll.ring = hdl;
+
+ hdl = nsep_attach_shmem(MP_NSTACK_SPL_CONN_ARRAY_NAME);
+ manager->ep_connPoll.pool = hdl;
+
+ return 0;
+}
+
+int nsep_attach_memory()
+{
+ typedef int (*nsep_attachMemFunc_t) (void);
+ nsep_attachMemFunc_t attachFuncs[] = { nsep_attach_info_mem,
+ nsep_attach_epitem_mem,
+ nsep_attach_eventpoll_mem
+ };
+
+ int i = 0;
+ for (i = 0;
+ i < (int) (sizeof(attachFuncs) / sizeof(nsep_attachMemFunc_t)); i++)
+ {
+ if (-1 == attachFuncs[i] ())
+ return -1;
+ }
+
+ return 0;
+}
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif /* __cplusplus */
diff --git a/src/framework/event/epoll/nstack_eventpoll.h b/src/framework/event/epoll/nstack_eventpoll.h
new file mode 100644
index 0000000..42e516a
--- /dev/null
+++ b/src/framework/event/epoll/nstack_eventpoll.h
@@ -0,0 +1,384 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#ifndef _NSTACK_EVENTPOOL_H
+#define _NSTACK_EVENTPOOL_H
+
+#include "ephlist.h"
+#include "eprb_tree.h"
+#include "types.h"
+#include <semaphore.h>
+#include <sys/epoll.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "nstack_securec.h"
+#include "nsfw_maintain_api.h"
+#include "nstack_log.h"
+#include "nsfw_mem_api.h"
+
+#include "nstack_sem.h"
+#include "dmm_spinlock.h"
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C"{
+/* *INDENT-ON* */
+#endif /* __cplusplus */
+
+#define NSTACK_MAX_EPOLL_INFO_NUM CUR_CFG_SOCKET_NUM
+#define NSTACK_MAX_EPITEM_NUM (NSTACK_MAX_EPOLL_INFO_NUM*2)
+#define NSTACK_MAX_EPOLL_FD_NUM 1024U
+
+#define MP_NSTACK_EPOLL_INFO_NAME "nsep_info"
+#define MP_NSTACK_EVENTPOLL_POOL "nsep_eventpoll" /* Pool of struct eventpoll */
+#define MP_NSTACK_EPITEM_POOL "nsep_epitem" /* Pool of struct epitem */
+#define MP_NSTACK_SPL_CONN_POOL "nsep_spl_conn_pool"
+#define MP_NSTACK_SPL_CONN_ARRAY_NAME "nsep_spl_conn_pool_array"
+
+#define MP_NSTACK_EPINFO_RING_NAME "nsep_info_ring"
+#define MP_NSTACK_EPITEM_RING_NAME "nsep_item_ring"
+#define MP_NSTACK_EVENTPOOL_RING_NAME "nsep_event_ring"
+#define MP_NSTACK_SPL_CONN_RING_NAME "nsep_spl_conn_ring"
+
+#define NSTACK_FORK_NUM 32
+#define NSTACK_EPOL_FD 1
+
+#define NSEP_SMOD_MAX 8
+
+/* *INDENT-OFF* */
+COMPAT_PROTECT_RETURN (NSEP_SMOD_MAX, 8)
+/* *INDENT-ON* */
+
+typedef struct
+{
+ u32 pid_used_size;
+ u32 pid_array[NSTACK_FORK_NUM];
+} nsep_pidinfo;
+
+struct eventpoll
+{
+
+ /*
+ * Protect the this structure access
+ * This is for event add to ready list and poll out
+ */
+ dmm_spinlock_t lock;
+
+ /*
+ * This semaphore is used to ensure that files are not removed
+ * while epoll is using them. This is read-held during the event
+ * processing loop and it is write-held during the file cleanup
+ * path, the epoll file exit code and the ctl operations.
+ * When we do epoll_ctl, we write lock
+ * When we collecting data , we read lock
+ */
+ dmm_spinlock_t sem;
+
+ /*
+ * This sempaphore is used to block epoll_wait function
+ */
+ ns_sem_type_t waitSem;
+
+ /* List of ready file descriptors */
+ struct ep_hlist rdlist;
+
+ /* When poll data out, we need this list to store tmp epitems */
+ u8 epoll_wait_pending;
+ u8 epoll_fork_flag;
+ u8 reserver_u8[6];
+
+ u64 epoll_wait_tick;
+ void *reserve[2];
+
+ /* RB-Tree root used to store mastered fd structs */
+ struct ep_rb_root rbr;
+
+ /* This specifies the file descriptor value of epoll instance, currenlty it is just used for debugging */
+ int epfd;
+ u32 pid;
+ nsfw_res res_chk;
+};
+
+/* solve issue: epoll global lock in daemon-stack
+ cause daemon-stack message handle slowing */
+struct spl_conn_pool
+{
+ void *ring_hd;
+ nsfw_res res_chk;
+ pid_t pid;
+ u32 revents;
+ void *ring_reserve;
+};
+
+struct eventpoll_pool
+{
+ void *ring;
+ struct eventpoll *pool;
+};
+
+struct ep_conn_pool
+{
+ void *ring;
+ struct spl_conn_pool *pool;
+};
+
+typedef struct
+{
+ int iindex;
+ int iNext;
+ int fd;
+ i32 fdtype; /*0: socket fd, 1: epoll fd */
+ i32 rlfd; /* copy of fdInf->rlfd */
+ i32 rmidx; /* copy of fdInf->rmidx */
+ i32 protoFD[NSEP_SMOD_MAX]; /* copy of fdInf->protoFD */// Here we need to set router infomations dependency
+ i32 epaddflag[NSEP_SMOD_MAX];
+ struct eventpoll *ep;
+ dmm_spinlock_t epiLock;
+ dmm_spinlock_t freeLock;
+ struct ep_list epiList; /* This restore the epitem of this file descriptor */
+ u32 sleepTime; //add for NSTACK_SEM_SLEEP
+ nsep_pidinfo pidinfo;
+ nsfw_res res_chk;
+ void *private_data; /*add for degbu, just used to record extern infomation, for example sbr conn */
+ union
+ {
+ struct spl_conn_pool *ep_conn;
+ char ep_conn_flag;
+ };
+ i32 reserv[2];
+} nsep_epollInfo_t;
+
+typedef struct
+{
+ void *ring;
+ nsep_epollInfo_t *pool;
+ char last_reserve[8]; //reserve for update
+} nsep_infoPool_t;
+
+struct epitem
+{
+ struct ep_rb_node rbn;
+
+ struct ep_hlist_node rdllink;
+
+ struct spl_conn_pool *ep_spl;
+ void *ptr_reserve;
+
+ volatile char app_poll_count;
+ volatile char spl_enter_count;
+ u16 reserve;
+
+ struct eventpoll *ep;
+
+ nsep_epollInfo_t *epInfo;
+
+ struct epoll_event event;
+
+ struct list_node fllink;
+ struct ep_hlist_node txlink;
+
+ unsigned int revents;
+
+ int fd;
+ u32 pid;
+ void *private_data;
+ nsfw_res res_chk;
+};
+
+struct epitem_pool
+{
+ void *ring;
+ struct epitem *pool;
+};
+
+typedef struct
+{
+ struct eventpoll_pool epollPool;
+ struct epitem_pool epitemPool;
+ struct ep_conn_pool ep_connPoll;
+ nsep_infoPool_t infoPool;
+ nsep_epollInfo_t **infoSockMap; // The map of epInfo and socket
+
+ int checkEpollFD;
+} nsep_epollManager_t;
+extern nsep_epollManager_t g_epollMng;
+#define nsep_get_manager() (&g_epollMng)
+
+extern int nsep_alloc_eventpoll(struct eventpoll **data);
+extern int nsep_free_eventpoll(struct eventpoll *ep);
+extern int nsep_alloc_epitem(struct epitem **data);
+extern int nsep_free_epitem(struct epitem *data);
+extern int nsep_alloc_epinfo(nsep_epollInfo_t ** data);
+extern int nsep_free_epinfo(nsep_epollInfo_t * info);
+extern int nsep_free_ep_spl_conn_ring(struct spl_conn_pool *data);
+extern int nsep_alloc_ep_spl_conn_ring(struct spl_conn_pool **data);
+extern int nsep_epitem_remove(nsep_epollInfo_t * pinfo, u32 pid);
+extern void nsep_epctl_triggle(struct epitem *epi, nsep_epollInfo_t * info,
+ int triggle_ops);
+extern struct epitem *nsep_find_ep(struct eventpoll *ep, int fd);
+extern int nsep_epctl_add(struct eventpoll *ep,
+ nsep_epollInfo_t * epfd_epInfo, int fd,
+ struct epoll_event *events);
+extern int nsep_epctl_del(struct eventpoll *ep, struct epitem *epi);
+extern int nsep_epctl_mod(struct eventpoll *ep,
+ nsep_epollInfo_t * epInfo,
+ struct epitem *epi, struct epoll_event *events);
+extern int nsep_ep_poll(struct eventpoll *ep, struct epoll_event *events,
+ int maxevents, struct spl_conn_pool *ep_conn);
+extern void nsep_remove_epfd(nsep_epollInfo_t * info);
+extern void nsep_close_epfd(struct eventpoll *ep);
+
+/**
+ * @Function nsep_init_info_sock_map
+ * @Description initial map of epoll info and socket
+ * @param none
+ * @return 0 on success, -1 on error
+ */
+extern int nsep_init_info_sock_map(uint32_t epoll_fd_max,
+ uint32_t module_max);
+extern void nsep_set_info_sock_map(int sock, nsep_epollInfo_t * info);
+extern nsep_epollInfo_t *nsep_get_info_by_sock(int sock);
+extern int nsep_alloc_info_with_sock(int nfd);
+extern void nsep_set_info_proto_fd(int fd, int modInx, int protoFD);
+extern int nsep_get_info_proto_fd(int fd, int modInx);
+extern void nsep_set_infomdix(int fd, int rmidx);
+extern int nsep_get_info_midx(int fd);
+extern void nsep_set_info_rlfd(int fd, int rlfd);
+extern int nsep_get_info_rlfd(int fd);
+extern void nsep_set_info_sleep_time(int fd, u32 sleepTime);
+extern int nsep_get_info_sleep_time(int fd);
+extern void nsep_set_info_ep_resource(int fd, struct eventpoll *ep,
+ struct spl_conn_pool *ep_spl_conn);
+extern struct eventpoll *nsep_get_info_ep(int fd);
+extern int nsep_free_info_with_sock(int sock);
+extern int nstack_ep_unlink(struct eventpoll *ep, struct epitem *epi);
+extern int nstack_epoll_event_dequeue(void *epi_addr, int events);
+
+/* Attach shared memory */
+extern int nsep_create_memory();
+extern int nsep_attach_memory();
+extern int nsep_ep_fdinfo_release(int sock);
+extern int nsep_epoll_close(int sock);
+extern void nsep_fork(u32_t ppid);
+
+static inline i32 nsep_for_pidinfo_init(nsep_pidinfo * pidinfo)
+{
+ int ret;
+ ret = memset_s(pidinfo, sizeof(*pidinfo), 0, sizeof(*pidinfo));
+ if (EOK != ret)
+ {
+ NSSOC_LOGERR("memset_s failed]ret=%d", ret);
+ return -1;
+ }
+ return 0;
+}
+
+static inline int nsep_add_pid(nsep_pidinfo * pidinfo, pid_t pid)
+{
+ int i;
+
+ for (i = 0; i < NSTACK_FORK_NUM; i++)
+ {
+ if ((0 == pidinfo->pid_array[i])
+ && (__sync_bool_compare_and_swap(&pidinfo->pid_array[i], 0, pid)))
+ {
+ if (pidinfo->pid_used_size < i + 1)
+ {
+ pidinfo->pid_used_size = i + 1;
+ }
+ return 0;
+ }
+ }
+ return -1;
+}
+
+static inline int nsep_del_pid(nsep_pidinfo * pidinfo, pid_t pid)
+{
+ int i;
+
+ for (i = 0; i < pidinfo->pid_used_size && i < NSTACK_FORK_NUM; i++)
+ {
+ if (pid == pidinfo->pid_array[i])
+ {
+ pidinfo->pid_array[i] = 0;
+ return 0;
+ }
+ }
+ return -1;
+}
+
+static inline int nsep_del_last_pid(nsep_pidinfo * pidinfo, pid_t pid)
+{
+ int i;
+ int count = 0;
+ int deleted = 0;
+ for (i = 0; i < pidinfo->pid_used_size && i < NSTACK_FORK_NUM; i++)
+ {
+ if (pid == pidinfo->pid_array[i])
+ {
+ pidinfo->pid_array[i] = 0;
+ deleted = 1;
+ continue;
+ }
+
+ if (pidinfo->pid_array[i] != 0)
+ {
+ ++count;
+ }
+ }
+
+ if (!deleted)
+ {
+ return -1;
+ }
+
+ return count;
+}
+
+static inline int nsep_is_pid_exist(nsep_pidinfo * epinf, pid_t pid)
+{
+ int i;
+
+ for (i = 0; i < epinf->pid_used_size && i < NSTACK_FORK_NUM; i++)
+ {
+ if (pid == epinf->pid_array[i])
+ {
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static inline int nsep_is_pid_array_empty(nsep_pidinfo * epinf)
+{
+ int i;
+ for (i = 0; i < epinf->pid_used_size && i < NSTACK_FORK_NUM; i++)
+ {
+ if (epinf->pid_array[i] != 0)
+ {
+ return 0;
+ }
+ }
+ return 1;
+}
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif /* __cplusplus */
+
+#endif /* _NSTACK_EVENTPOLL_H */
diff --git a/src/framework/event/epoll/nstack_sem.c b/src/framework/event/epoll/nstack_sem.c
new file mode 100644
index 0000000..c457f32
--- /dev/null
+++ b/src/framework/event/epoll/nstack_sem.c
@@ -0,0 +1,433 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#include <errno.h>
+#include "nstack_securec.h"
+#include "types.h"
+#include "nsfw_init_api.h"
+#include "nsfw_maintain_api.h"
+#include "nsfw_mgr_com_api.h"
+#include "nsfw_mem_api.h"
+#include "nstack_log.h"
+#include "nstack_sem.h"
+#include "nstack_epoll_api.h"
+
+i32 ns_semphore_init(ns_sem_type_t * sem, i32 pshared, u32 value);
+i32 ns_semphore_sem_timewait(ns_sem_type_t * sem, i32 timeout, u32 sleeptime);
+i32 ns_semphore_sem_post(ns_sem_type_t * sem);
+i32 ns_semphore_sem_destory(ns_sem_type_t * sem);
+i32 ns_sysv_msg_init(ns_sem_type_t * sem, i32 pshared, u32 value);
+i32 ns_sysv_msg_timewait(ns_sem_type_t * sem, i32 timeout, u32 sleeptime); /* milliseconds */
+i32 ns_sysv_msg_post(ns_sem_type_t * sem);
+i32 ns_sysv_msg_destory(ns_sem_type_t * sem);
+
+#define NS_SYNC_SEM_SHARED_ARGS_MAX_SIZE 1024
+#define NS_SYNC_SEM_SHARED_MEM_NAME "NSTACK_FW_NS_SYNC_SEM_SHARED"
+#define NSFW_SYNC_SEM_MODULE "nsfw_sync_sem"
+
+typedef struct ns_sync_mem_ifno_s
+{
+ ns_sync_type_t mode;
+ char parm[NS_SYNC_SEM_SHARED_ARGS_MAX_SIZE];
+} ns_sync_mem_ifno_t;
+
+ns_sync_sem_fun_t g_ns_sync_ops = {
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+ns_sync_mem_ifno_t *g_sync_shared_args = NULL;
+
+int sem_current_time2msec(u64 * msec)
+{
+#define SEM_MAX_U64_NUM ((u64)0xffffffffffffffff)
+
+ struct timespec tout;
+
+ if (0 != clock_gettime(CLOCK_MONOTONIC, &tout))
+ {
+ NSSOC_LOGERR("Failed to get time, errno = %d", errno);
+ }
+
+ if (SEM_MAX_U64_NUM / 1000 < (u64) tout.tv_sec)
+ {
+ NSSOC_LOGERR("tout.tv_sec is too large]tout.tv_sec=%ld", tout.tv_sec);
+ return -1;
+ }
+
+ u64 sec2msec = 1000 * tout.tv_sec;
+ u64 nsec2msec = (u64) tout.tv_nsec / 1000000;
+ if (SEM_MAX_U64_NUM - sec2msec < nsec2msec)
+ {
+ NSSOC_LOGERR
+ ("nsec2msec plus sec2usec is too large]nsec2msec=%llu,usec2msec=%llu",
+ nsec2msec, sec2msec);
+ return -1;
+ }
+
+ *msec = sec2msec + nsec2msec;
+
+ return 0;
+}
+
+/*****************************************************************************
+* Prototype : ns_sync_mem_create
+* Description : create a share mem with nstack and app
+* Input : ns_sync_mem_ifno_t **mem
+* Output : None
+* Return Value : int
+* Calls :
+* Called By :
+*****************************************************************************/
+mzone_handle ns_sync_mem_create(size_t size)
+{
+ nsfw_mem_zone pmeminfo;
+ mzone_handle phandle;
+ int ret;
+
+ pmeminfo.ireserv = 0;
+ pmeminfo.isocket_id = NSFW_SOCKET_ANY;
+ pmeminfo.lenth = size;
+
+ ret =
+ strcpy_s(pmeminfo.stname.aname, sizeof(pmeminfo.stname.aname),
+ NS_SYNC_SEM_SHARED_MEM_NAME);
+ if (EOK != ret)
+ {
+ NSSOC_LOGERR("strcpy_s failed]name=%s,ret=%d",
+ NS_SYNC_SEM_SHARED_MEM_NAME, ret);
+ return NULL;
+ }
+ pmeminfo.stname.entype = NSFW_SHMEM;
+
+ phandle = nsfw_mem_zone_create(&pmeminfo);
+ if (NULL == phandle)
+ {
+ NSSOC_LOGERR("create nstack sync memory failed]name=%s",
+ NS_SYNC_SEM_SHARED_MEM_NAME);
+ return NULL;
+ }
+
+ return phandle;
+
+}
+
+/*****************************************************************************
+* Prototype : ns_sync_mem_lookup
+* Description : app look up the shared mem ,create by nstack
+* Input : ns_sync_mem_ifno_t **mem
+* Output : None
+* Return Value : int
+* Calls :
+* Called By :
+*****************************************************************************/
+mzone_handle ns_sync_mem_lookup(char *str)
+{
+ nsfw_mem_name name;
+
+ name.entype = NSFW_SHMEM;
+ name.enowner = NSFW_PROC_MAIN;
+ mzone_handle phandle;
+
+ if (-1 == sprintf_s(name.aname, NSFW_MEM_NAME_LENTH, "%s", str))
+ {
+ NSSOC_LOGERR("Error to attach sync]name=%s", str);
+ return NULL;
+ }
+
+ phandle = nsfw_mem_zone_lookup(&name);
+ if (NULL == phandle)
+ {
+ NSSOC_LOGERR("create nstack sync memory failed]name=%s", str);
+ return NULL;
+ }
+
+ return phandle;
+}
+
+/*****************************************************************************
+* Prototype : ns_sync_func_init
+* Description : init function
+* Input : u32 mode
+* Output : None
+* Return Value : NSTACK_STATIC void
+* Calls :
+* Called By :
+*****************************************************************************/
+NSTACK_STATIC void ns_sync_func_init(u32 mode)
+{
+ switch (mode)
+ {
+ case NS_SYNC_SYSV_MSG:
+ g_ns_sync_ops.ns_sync_sem_init = ns_sysv_msg_init;
+ g_ns_sync_ops.ns_sync_sem_post = ns_sysv_msg_post;
+ g_ns_sync_ops.ns_sync_sem_timedwait = ns_sysv_msg_timewait;
+ g_ns_sync_ops.ns_sync_sem_destroy = ns_sysv_msg_destory;
+ break;
+ case NS_SYNC_SEM_TRY:
+ default:
+ g_ns_sync_ops.ns_sync_sem_init = ns_semphore_init;
+ g_ns_sync_ops.ns_sync_sem_post = ns_semphore_sem_post;
+ g_ns_sync_ops.ns_sync_sem_timedwait = ns_semphore_sem_timewait;
+ g_ns_sync_ops.ns_sync_sem_destroy = ns_semphore_sem_destory;
+ break;
+ }
+
+}
+
+/*****************************************************************************
+* Prototype : ns_sync_sem_module_init
+* Description : read config file and shared mem
+* Input : void * args
+* Output : None
+* Return Value : i32
+* Calls :
+* Called By :
+*****************************************************************************/
+i32 ns_sync_sem_module_init(int type, ns_sync_type_t mode)
+{
+ i32 ret = 0;
+
+ switch (type)
+ {
+
+ case 0:
+ g_sync_shared_args =
+ ns_sync_mem_create(sizeof(ns_sync_mem_ifno_t));
+ if (NULL == g_sync_shared_args)
+ {
+ NSFW_LOGERR("%s create share mem failed",
+ NSFW_SYNC_SEM_MODULE);
+ ret = -1;
+ break;
+ }
+ g_sync_shared_args->mode = mode;
+
+ ns_sync_func_init(g_sync_shared_args->mode);
+ break;
+ case 1:
+ g_sync_shared_args =
+ ns_sync_mem_lookup(NS_SYNC_SEM_SHARED_MEM_NAME);
+ if (NULL == g_sync_shared_args)
+ {
+ NSFW_LOGERR("%s lookup shared mem failed",
+ NSFW_SYNC_SEM_MODULE);
+ ret = -1;
+ break;
+ }
+
+ ns_sync_func_init(g_sync_shared_args->mode);
+ break;
+ default:
+ if (type < NSFW_PROC_MAX)
+ {
+ NSFW_LOGERR("%s outof type", NSFW_SYNC_SEM_MODULE);
+ break;
+ }
+ ret = -1;
+ }
+
+ NSFW_LOGDBG("%s init ret = %d", NSFW_SYNC_SEM_MODULE, ret);
+ return ret;
+}
+
+/****************************************************************/
+
+/* semaphore mode functions*/
+i32 ns_semphore_init(ns_sem_type_t * sem, i32 pshared, u32 value)
+{
+ return sem_init(&sem->semphore, pshared, value);
+}
+
+/*****************************************************************************
+* Prototype : ns_semphore_sem_timewait
+* Description : semaphore wait
+* Input : ns_sem_type_t *sem
+* i32 timeout used ms, block if < 0
+* u32 sleeptime if timeout > 0, and sleeptime > 0 used sleep(sleeptime) and try agin
+* ns_sem_process_type_t type
+* Output : None
+* Return Value : i32
+* Calls :
+* Called By :
+*****************************************************************************/
+i32 ns_semphore_sem_timewait(ns_sem_type_t * sem, i32 timeout, u32 sleeptime)
+{
+#define FAST_SLEEP_TIME 10000
+#define SLOW_SLEEP_TIME 500000
+#define FAST_RETRY_COUNT 100
+
+ i32 retVal = 0;
+ u64 starttime;
+ u64 endtime;
+ u32 retry_count = 0;
+
+ /* trywait */
+ if (timeout == 0)
+ {
+ return sem_trywait(&sem->semphore);
+ }
+
+ /* block when no event recv */
+ if (timeout < 0)
+ {
+ return sem_wait(&sem->semphore);
+ }
+
+ /* for timeout */
+ if (sem_current_time2msec(&starttime))
+ {
+ errno = ETIMEDOUT;
+ return -1;
+ }
+ while (1)
+ {
+ retVal = sem_trywait(&sem->semphore);
+
+ if (retVal == 0)
+ {
+ break;
+ }
+
+ if (sem_current_time2msec(&endtime))
+ {
+ errno = ETIMEDOUT;
+ return -1;
+ }
+
+ if (endtime < starttime || (endtime - starttime) > timeout)
+ {
+ errno = ETIMEDOUT;
+ return -1;
+ }
+
+ /*app calling setsockopt to set time */
+ if (sleeptime > 0)
+ {
+ long wait_sec;
+ long wait_nsec;
+ wait_sec = sleeptime / 1000000;
+ wait_nsec = 1000 * (sleeptime % 1000000);
+ sys_sleep_ns(wait_sec, wait_nsec); //g_sem_sleep_time
+ }
+ else if (retry_count < FAST_RETRY_COUNT)
+ {
+ sys_sleep_ns(0, FAST_SLEEP_TIME);
+ retry_count++;
+ }
+ else
+ {
+ sys_sleep_ns(0, SLOW_SLEEP_TIME);
+ }
+ }
+
+ return retVal;
+
+}
+
+/* semaphore post */
+i32 ns_semphore_sem_post(ns_sem_type_t * sem)
+{
+ return sem_post(&sem->semphore);
+}
+
+/*semaphore destory*/
+i32 ns_semphore_sem_destory(ns_sem_type_t * sem)
+{
+ return sem_destroy(&sem->semphore);
+}
+
+/*****************************************************************************
+* Prototype : ns_sysv_msg_init
+* Description : init a system V msg
+* Input : ns_sem_type_t *sem
+* u32 pshared
+* u32 value
+* Output : None
+* Return Value : i32
+* Calls :
+* Called By :
+*****************************************************************************/
+i32 ns_sysv_msg_init(ns_sem_type_t * sem, i32 pshared, u32 value)
+{
+#define KEY_START 30000
+
+ unsigned short semInit = 0;
+ key_t key;
+ u32 *args;
+
+ args = (u32 *) sem->args;
+ value = *args;
+ key = KEY_START + value;
+ sem->sysv.key = key;
+ sem->sysv.sock_id = semget(key, 1, IPC_CREAT | 0660);
+ sem->sysv.stack_id = -1;
+
+ semctl(sem->sysv.sock_id, 0, SETALL, &semInit);
+
+ return 0;
+}
+
+/* system V timewait */
+i32 ns_sysv_msg_timewait(ns_sem_type_t * sem, i32 timeout, u32 sleeptime) /* milliseconds */
+{
+ struct timespec tmout;
+ struct sembuf operations = { 0, -1, 0 };
+ int id;
+
+ id = semget(sem->sysv.key, 1, 0660);
+ if (-1 == id)
+ {
+ errno = EIDRM;
+ return -1;
+ }
+
+ if (timeout < 0)
+ {
+ return semop(id, &operations, 1);
+ }
+
+ tmout.tv_sec = timeout / 1000;
+ tmout.tv_nsec = (timeout % 1000) * 1000 * 1000;
+ return semtimedop(id, &operations, 1, &tmout);
+}
+
+/* system V post */
+i32 ns_sysv_msg_post(ns_sem_type_t * sem)
+{
+ struct sembuf operations = { 0, 1, 0 };
+ int id;
+
+ id = semget(sem->sysv.key, 1, 0660);
+ if (-1 == id)
+ {
+ errno = EIDRM;
+ return -1;
+ }
+
+ return semop(id, &operations, 1);
+}
+
+/* destory system V msg */
+i32 ns_sysv_msg_destory(ns_sem_type_t * sem)
+{
+ key_t key;
+
+ key = semget(sem->sysv.key, 1, 0660);
+ return semctl(key, 0, IPC_RMID);
+}
diff --git a/src/framework/event/epoll/nstack_sem.h b/src/framework/event/epoll/nstack_sem.h
new file mode 100644
index 0000000..3f17667
--- /dev/null
+++ b/src/framework/event/epoll/nstack_sem.h
@@ -0,0 +1,74 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#ifndef __NSTACK_SYNC_H__
+#define __NSTACK_SYNC_H__
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
+#include <sys/ipc.h>
+#include <sys/sem.h>
+#include <semaphore.h>
+#include "types.h"
+#include "nsfw_mgr_com_api.h"
+
+#define NS_SEM_ARGS_SIZE 8
+
+typedef enum ns_sync_type_e
+{
+ NS_SYNC_SEM_TRY,
+ NS_SYNC_SYSV_MSG,
+ NS_SYNC_UNIX, /*need to do */
+ NS_SYNC_MAX
+} ns_sync_type_t;
+
+typedef struct ns_sysv_type_s
+{
+ key_t key;
+ i32 sock_id;
+ i32 stack_id;
+} ns_sysv_t;
+
+typedef struct ns_sem_type_s
+{
+ sem_t semphore;
+ ns_sysv_t sysv;
+ char args[NS_SEM_ARGS_SIZE];
+
+} ns_sem_type_t;
+
+typedef struct ns_sync_sem_fun_s
+{
+ i32(*ns_sync_sem_init) (ns_sem_type_t * sem, i32 pshared, u32 value);
+ i32(*ns_sync_sem_timedwait) (ns_sem_type_t * sem, i32 timeout, u32 sleeptime); /* milliseconds */
+ i32(*ns_sync_sem_post) (ns_sem_type_t * sem);
+ i32(*ns_sync_sem_destroy) (ns_sem_type_t * sem);
+} ns_sync_sem_fun_t;
+
+extern ns_sync_sem_fun_t g_ns_sync_ops;
+extern i32 ns_sync_sem_module_init(int type, ns_sync_type_t mode);
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif
+
+#endif
diff --git a/src/framework/hal/hal.c b/src/framework/hal/hal.c
index 49b1fb7..c9e31cf 100644
--- a/src/framework/hal/hal.c
+++ b/src/framework/hal/hal.c
@@ -14,14 +14,14 @@
* limitations under the License.
*/
-#include "common_sys_config.h"
-#include "common_mem_mbuf.h"
+#include <errno.h>
#include "nstack_log.h"
#include "nstack_securec.h"
#include "hal.h"
-#include "hal_api.h"
+#include "nsfw_hal_api.h"
#define HAL_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
+
/* *INDENT-OFF* */
static char hal_invalid_char_script[] = {'|', ';', '&', '$', '>', '<', '`', '\\', '\"', '\'',
'(', ')', '[', ']', '~', '?', '*'
@@ -39,26 +39,25 @@ static int netif_ops_init_flag = 0;
netif_inst_t netif_tbl[HAL_MAX_NIC_NUM];
/* *INDENT-ON* */
-void
-hal_io_adpt_register (const netif_ops_t * ops)
+void hal_io_adpt_register(const netif_ops_t * ops)
{
- int icnt = 0;
- if (netif_ops_init_flag == 0)
+ int icnt = 0;
+ if (netif_ops_init_flag == 0)
{
- (void) MEMSET_S (&netif_ops_table[0], sizeof (netif_ops_table), 0,
- sizeof (netif_ops_table));
- netif_ops_init_flag = 1;
+ (void) memset_s(&netif_ops_table[0], sizeof(netif_ops_table), 0,
+ sizeof(netif_ops_table));
+ netif_ops_init_flag = 1;
}
- for (icnt = 0; icnt < HAL_DRV_MAX; icnt++)
+ for (icnt = 0; icnt < HAL_DRV_MAX; icnt++)
{
- if (netif_ops_table[icnt] == 0)
+ if (netif_ops_table[icnt] == NULL)
{
- netif_ops_table[icnt] = ops;
- break;
+ netif_ops_table[icnt] = ops;
+ break;
}
}
- return;
+ return;
}
/*****************************************************************************
@@ -73,43 +72,43 @@ hal_io_adpt_register (const netif_ops_t * ops)
Calls :
Called By :
*****************************************************************************/
-int
-hal_snprintf (char *buffer, size_t buflen, const char *format, ...)
+int hal_snprintf(char *buffer, size_t buflen, const char *format, ...)
{
- int len;
- va_list ap;
+ int len;
+ va_list ap;
- /* check buffer validity */
- if (NULL == buffer || 0 == buflen)
+ /* need check buffer validity */
+ if (NULL == buffer || 0 == buflen)
{
- goto einval_error;
+ goto einval_error;
}
- if (format == NULL)
+ if (format == NULL)
{
- buffer[0] = '\0';
+ buffer[0] = '\0';
- goto einval_error;
+ goto einval_error;
}
- (void) va_start (ap, format);
- len = VSNPRINTF_S (buffer, buflen, buflen - 1, format, ap);
+ (void) va_start(ap, format); /*no need to init */
+ /*There are some unsafe function ,need to be replace with safe function */
+ len = vsnprintf_s(buffer, buflen, buflen - 1, format, ap);
- if (-1 == len)
+ if (-1 == len)
{
- va_end (ap);
- goto einval_error;
+ va_end(ap);
+ goto einval_error;
}
- va_end (ap);
+ va_end(ap);
- buffer[buflen - 1] = '\0';
+ buffer[buflen - 1] = '\0';
- return len;
+ return len;
-einval_error:
- errno = EINVAL;
- return -1;
+ einval_error:
+ errno = EINVAL;
+ return -1;
}
/*****************************************************************************
@@ -121,99 +120,100 @@ einval_error:
Calls :
Called By :
*****************************************************************************/
-int
-hal_is_script_valid (const char *cmd)
+int hal_is_script_valid(const char *cmd)
{
- unsigned int i;
+ unsigned int i;
- if (cmd)
+ if (cmd)
{
- char *cmd_str = (char *) cmd;
+ char *cmd_str = (char *) cmd;
- /* skip space */
- while (*cmd_str == ' ' || *cmd_str == '\t')
+ /* skip space */
+ while (*cmd_str == ' ' || *cmd_str == '\t')
{
- cmd_str++;
+ cmd_str++;
}
- /* cmd can not start with ./ and ../ */
- for (i = 0; i < HAL_ARRAY_SIZE (hal_invalid_str_script_begin); i++)
+ /* cmd can not start with ./ and ../ */
+ for (i = 0; i < HAL_ARRAY_SIZE(hal_invalid_str_script_begin); i++)
{
- if (strstr (cmd_str, hal_invalid_str_script_begin[i]) == cmd_str)
+ if (strstr(cmd_str, hal_invalid_str_script_begin[i]) == cmd_str)
{
- return 0;
+ return 0;
}
}
- /* cmd can not include | ; $ and so on */
- for (i = 0; i < HAL_ARRAY_SIZE (hal_invalid_char_script); i++)
+ /* cmd can not include | ; $ and so on */
+ for (i = 0; i < HAL_ARRAY_SIZE(hal_invalid_char_script); i++)
{
- if (strchr (cmd, hal_invalid_char_script[i]))
+ if (strchr(cmd, hal_invalid_char_script[i]))
{
- return 0;
+ return 0;
}
}
- /* cmd can not include && || >> and so on */
- for (i = 0; i < HAL_ARRAY_SIZE (hal_invalid_str_script); i++)
+ /* cmd can not include && || >> and so on */
+ for (i = 0; i < HAL_ARRAY_SIZE(hal_invalid_str_script); i++)
{
- if (strstr (cmd, hal_invalid_str_script[i]))
+ if (strstr(cmd, hal_invalid_str_script[i]))
{
- return 0;
+ return 0;
}
}
- return 1;
+ return 1;
}
- return 0;
+ return 0;
}
-/*****************************************************************************
- Prototype : hal_run_script
- Description : run shell script
- Input : const char* cmd
- char* result_buf
- size_t max_result_len
- Output : None
- Return Value :
- Calls :
- Called By :
-*****************************************************************************/
-int
-hal_run_script (const char *cmd, char *result_buf, size_t max_result_len)
+int hal_run_script(const char *cmd, char *result_buf, size_t max_result_len)
{
- size_t n;
- if (!cmd || !result_buf || max_result_len <= 1)
+ size_t n;
+ if (!cmd || !result_buf || max_result_len <= 1)
{
- return -1;
+ return -1;
}
- FILE *fd = popen (cmd, "r");
+ FILE *fd = popen(cmd, "r");
- if (fd != NULL)
+ if (fd != NULL)
{
- n = fread (result_buf, sizeof (char), max_result_len - 1, fd);
+ n = fread(result_buf, sizeof(char), max_result_len - 1, fd);
- if (n == 0)
+ if (n == 0)
{
- result_buf[0] = '\0';
+ result_buf[0] = '\0';
}
- else if ('\n' == result_buf[n - 1])
+ else if ('\n' == result_buf[n - 1])
{
- result_buf[n - 1] = '\0';
+ result_buf[n - 1] = '\0';
}
- /* make it null terminated */
- else
+ /* to make it null terminated */
+ else
{
- result_buf[n] = '\0';
+ result_buf[n] = '\0';
}
- (void) pclose (fd);
- return n;
+ (void) pclose(fd);
+ return n;
}
- return -1;
+ return -1;
+}
+
+/* whether the nstack config file enable tso feature or not */
+static int config_enable_tso()
+{
+ /* tso not support for now */
+ return 0;
+}
+
+/* whether the nstack config file enable rx offload feature or not */
+static int config_enable_rx_offload()
+{
+ /* rx_offload enabled by config file */
+ return 1;
}
/*****************************************************************************
@@ -226,35 +226,34 @@ hal_run_script (const char *cmd, char *result_buf, size_t max_result_len)
Calls :
Called By :
*****************************************************************************/
-int
-hal_init_global (int argc, char **argv)
+int hal_init_global(int argc, char **argv)
{
- int ret;
- int netif_type;
+ int ret;
+ int netif_type;
- ret =
- MEMSET_S (netif_tbl, HAL_MAX_NIC_NUM * sizeof (netif_inst_t), 0,
- HAL_MAX_NIC_NUM * sizeof (netif_inst_t));
- if (EOK != ret)
+ ret =
+ memset_s(netif_tbl, HAL_MAX_NIC_NUM * sizeof(netif_inst_t), 0,
+ HAL_MAX_NIC_NUM * sizeof(netif_inst_t));
+ if (EOK != ret)
{
- NSHAL_LOGERR ("MEMSET_S failed");
- return -1;
+ NSHAL_LOGERR("memset_s failed");
+ return -1;
}
- for (netif_type = 0; netif_ops_table[netif_type]; ++netif_type)
+ for (netif_type = 0; netif_ops_table[netif_type]; ++netif_type)
{
- if (netif_ops_table[netif_type]->init_global)
+ if (netif_ops_table[netif_type]->init_global)
{
- if (netif_ops_table[netif_type]->init_global (argc, argv))
+ if (netif_ops_table[netif_type]->init_global(argc, argv))
{
- NSHAL_LOGERR ("failed to init global]netif type=%d",
- netif_type);
- return -1;
+ NSHAL_LOGERR("failed to init global]netif type=%d",
+ netif_type);
+ return -1;
}
}
}
- return 0;
+ return 0;
}
/*****************************************************************************
@@ -266,24 +265,24 @@ hal_init_global (int argc, char **argv)
Calls :
Called By :
*****************************************************************************/
-int
-hal_init_local ()
+int hal_init_local()
{
- int netif_type;
+ int netif_type;
- for (netif_type = 0; netif_ops_table[netif_type]; ++netif_type)
+ for (netif_type = 0; netif_ops_table[netif_type]; ++netif_type)
{
- if (netif_ops_table[netif_type]->init_local)
+ if (netif_ops_table[netif_type]->init_local)
{
- if (netif_ops_table[netif_type]->init_local ())
+ if (netif_ops_table[netif_type]->init_local())
{
- NSHAL_LOGERR ("failed to init local]netif type=%d", netif_type);
- return -1;
+ NSHAL_LOGERR("failed to init local]netif type=%d",
+ netif_type);
+ return -1;
}
}
}
- return 0;
+ return 0;
}
/*****************************************************************************
@@ -295,96 +294,113 @@ hal_init_local ()
Calls :
Called By :
*****************************************************************************/
-hal_hdl_t
-hal_get_invalid_hdl ()
+hal_hdl_t hal_get_invalid_hdl()
{
- return hal_invaldi_hdl;
+ return hal_invaldi_hdl;
}
-/*****************************************************************************
- Prototype : hal_create
- Description : create hal object
- Input : const char* name
- hal_netif_config_t* conf
- Output : None
- Return Value :
- Calls :
- Called By :
-*****************************************************************************/
-hal_hdl_t
-hal_create (const char *name, const char *nic_type, hal_netif_config_t * conf)
+hal_hdl_t hal_create(const char *name, const char *nic_type,
+ hal_netif_config_t * conf)
{
- int ret = -1;
- uint32_t netif_type;
- netif_inst_t *inst;
+ int ret = -1;
+ uint32_t netif_type;
+ netif_inst_t *inst;
+
+ /* which features netif support */
+ struct hal_netif_hw_feature port_capa;
- if ((NULL == name) || (NULL == conf))
+ if ((NULL == name) || (NULL == conf))
{
- NSHAL_LOGERR ("invalid para]name=%p,conf=%p", name, conf);
- return hal_get_invalid_hdl ();
+ NSHAL_LOGERR("invalid para]name=%p,conf=%p", name, conf);
+ return hal_get_invalid_hdl();
}
- inst = alloc_netif_inst ();
+ inst = alloc_netif_inst();
- if (NULL == inst)
+ if (NULL == inst)
{
- NSHAL_LOGERR ("failed to alloc netif inst]netif name=%s", name);
+ NSHAL_LOGERR("failed to alloc netif inst]netif name=%s", name);
- return hal_get_invalid_hdl ();
+ return hal_get_invalid_hdl();
}
- /*open */
- for (netif_type = 0; NULL != netif_ops_table[netif_type]; ++netif_type)
+ /*open */
+ for (netif_type = 0; NULL != netif_ops_table[netif_type]; ++netif_type)
{
- ret = netif_ops_table[netif_type]->open (inst, name, nic_type);
+ ret = netif_ops_table[netif_type]->open(inst, name, nic_type);
- if (0 == ret)
+ if (0 == ret)
{
- inst->ops = netif_ops_table[netif_type];
+ inst->ops = netif_ops_table[netif_type];
- NSHAL_LOGINF ("netif ops]netif type=%u, netif name=%s", netif_type,
- inst->ops->name);
+ NSHAL_LOGINF("netif ops]netif type=%u, netif name=%s",
+ netif_type, inst->ops->name);
- break;
+ break;
}
}
- if (ret != 0)
+ if (ret != 0)
{
- inst->state = NETIF_STATE_FREE;
+ inst->state = NETIF_STATE_FREE;
- inst->ops = NULL;
+ inst->ops = NULL;
- NSHAL_LOGERR ("open fail]netif name=%s", name);
+ NSHAL_LOGERR("open fail]netif name=%s", name);
- return hal_get_invalid_hdl ();
+ return hal_get_invalid_hdl();
}
- /*config */
- ret = inst->ops->config (inst, conf);
+ /* make sure which capabilities nic hardware support */
+ ret = inst->ops->capability(inst, &port_capa);
+ if (ret != 0)
+ {
+ inst->state = NETIF_STATE_FREE;
+
+ NSHAL_LOGERR("config fail]netif name=%s", name);
+
+ return hal_get_invalid_hdl();
+ }
+
+ /* set port config per port capabilities */
+ conf->hw_config.rx_csum_ip_flag = port_capa.rx_csum_ip
+ && config_enable_rx_offload()? 1 : 0;
+ conf->hw_config.rx_csum_l4_flag = port_capa.rx_csum_l4
+ && config_enable_rx_offload()? 1 : 0;
+ conf->hw_config.tx_csum_ip_flag = port_capa.tx_csum_ip;
+ conf->hw_config.tx_csum_l4_flag = port_capa.tx_csum_tcp
+ && port_capa.tx_csum_udp;
+ conf->hw_config.tx_tso_flag = port_capa.tx_tso
+ && config_enable_tso()? 1 : 0;
+
+ /*config */
+ ret = inst->ops->config(inst, conf);
- if (ret != 0)
+ if (ret != 0)
{
- inst->state = NETIF_STATE_FREE;
+ inst->state = NETIF_STATE_FREE;
- NSHAL_LOGERR ("config fail]netif name=%s", name);
+ NSHAL_LOGERR("config fail]netif name=%s", name);
- return hal_get_invalid_hdl ();
+ return hal_get_invalid_hdl();
}
- /*start */
- ret = inst->ops->start (inst);
+ /* update netif offload value per config */
+ inst->hw_config = conf->hw_config;
- if (ret != 0)
+ /*start */
+ ret = inst->ops->start(inst);
+
+ if (ret != 0)
{
- inst->state = NETIF_STATE_FREE;
+ inst->state = NETIF_STATE_FREE;
- NSHAL_LOGERR ("start fail]netif name=%s", name);
+ NSHAL_LOGERR("start fail]netif name=%s", name);
- return hal_get_invalid_hdl ();
+ return hal_get_invalid_hdl();
}
- return inst->hdl;
+ return inst->hdl;
}
/*****************************************************************************
@@ -398,328 +414,229 @@ hal_create (const char *name, const char *nic_type, hal_netif_config_t * conf)
Calls :
Called By :
*****************************************************************************/
-hal_hdl_t
-hal_bond (const char *bond_name, uint8_t slave_num, hal_hdl_t slave_hdl[])
+hal_hdl_t hal_bond(const char *bond_name, uint8_t slave_num,
+ hal_hdl_t slave_hdl[])
{
- int i, ret;
- netif_inst_t *inst;
- netif_inst_t *slave_inst[HAL_MAX_SLAVES_PER_BOND];
+ int i, ret;
+ netif_inst_t *inst;
+ netif_inst_t *slave_inst[HAL_MAX_SLAVES_PER_BOND];
- if ((0 == slave_num) || (HAL_MAX_SLAVES_PER_BOND < slave_num)
- || (NULL == bond_name) || (NULL == slave_hdl))
+ if ((0 == slave_num) || (HAL_MAX_SLAVES_PER_BOND < slave_num)
+ || (NULL == bond_name) || (NULL == slave_hdl))
{
- NSHAL_LOGERR ("invalid para]bond_name=%p,slave_num=%u,slave_hdl=%p,",
- bond_name, slave_num, slave_hdl);
+ NSHAL_LOGERR("invalid para]bond_name=%p,slave_num=%u,slave_hdl=%p,",
+ bond_name, slave_num, slave_hdl);
- return hal_get_invalid_hdl ();
+ return hal_get_invalid_hdl();
}
- for (i = 0; i < slave_num; i++)
+ for (i = 0; i < slave_num; i++)
{
- slave_inst[i] = get_netif_inst (slave_hdl[i]);
+ slave_inst[i] = get_netif_inst(slave_hdl[i]);
- if (NULL == slave_inst[i])
+ if (NULL == slave_inst[i])
{
- NSHAL_LOGERR ("invalid para slave_hdl]index=%d, slave_inst=%d", i,
- slave_hdl[i].id);
- return hal_get_invalid_hdl ();
+ NSHAL_LOGERR("invalid para slave_hdl]index=%d, slave_inst=%d", i,
+ slave_hdl[i].id);
+ return hal_get_invalid_hdl();
}
}
- inst = alloc_netif_inst ();
+ inst = alloc_netif_inst();
- if (NULL == inst)
+ if (NULL == inst)
{
- NSHAL_LOGERR ("failed to alloc nic inst]bond_name=%s", bond_name);
- return hal_get_invalid_hdl ();
+ NSHAL_LOGERR("failed to alloc nic inst]bond_name=%s", bond_name);
+ return hal_get_invalid_hdl();
}
- inst->ops = slave_inst[0]->ops;
+ inst->ops = slave_inst[0]->ops;
+ inst->hw_config = slave_inst[0]->hw_config;
- ret = inst->ops->bond (inst, bond_name, slave_num, slave_inst);
+ ret = inst->ops->bond(inst, bond_name, slave_num, slave_inst);
- if (0 != ret)
+ if (0 != ret)
{
- inst->state = NETIF_STATE_FREE;
+ inst->state = NETIF_STATE_FREE;
- inst->ops = NULL;
+ inst->ops = NULL;
- NSHAL_LOGERR ("bond netif fail]bond_name=%s", bond_name);
+ NSHAL_LOGERR("bond netif fail]bond_name=%s", bond_name);
- return hal_get_invalid_hdl ();
+ return hal_get_invalid_hdl();
}
- return inst->hdl;
+ return inst->hdl;
}
-/*****************************************************************************
- Prototype : hal_close
- Description : destroy hal object
- Input : hal_hdl_t hdl
- Output : None
- Return Value :
- Calls :
- Called By :
-*****************************************************************************/
-int
-hal_close (hal_hdl_t hdl)
+int hal_close(hal_hdl_t hdl)
{
- netif_inst_t *inst;
+ netif_inst_t *inst;
- inst = get_netif_inst (hdl);
+ inst = get_netif_inst(hdl);
- if (inst == NULL)
+ if (inst == NULL)
{
- NSHAL_LOGERR ("netif does not exist]inst=%i", HAL_HDL_TO_ID (hdl));
- return -1;
+ NSHAL_LOGERR("netif does not exist]inst=%i", HAL_HDL_TO_ID(hdl));
+ return -1;
}
- inst->state = NETIF_STATE_FREE;
+ inst->state = NETIF_STATE_FREE;
- return inst->ops->close (inst);
+ return inst->ops->close(inst);
}
-/*****************************************************************************
- Prototype : hal_stop
- Description : stop recv packet
- Input : hal_hdl_t hdl
- Output : None
- Return Value :
- Calls :
- Called By :
-*****************************************************************************/
-int
-hal_stop (hal_hdl_t hdl)
+int hal_stop(hal_hdl_t hdl)
{
- netif_inst_t *inst;
+ netif_inst_t *inst;
- inst = get_netif_inst (hdl);
+ inst = get_netif_inst(hdl);
- if (inst == NULL)
+ if (inst == NULL)
{
- NSHAL_LOGERR ("netif does not exist]inst=%i", HAL_HDL_TO_ID (hdl));
- return -1;
+ NSHAL_LOGERR("netif does not exist]inst=%i", HAL_HDL_TO_ID(hdl));
+ return -1;
}
- return inst->ops->stop (inst);
+ return inst->ops->stop(inst);
}
-/*****************************************************************************
- Prototype : hal_get_mtu
- Description : get the mtu from nic
- Input : hal_hdl_t hdl
- Output : None
- Return Value :
- Calls :
- Called By :
-*****************************************************************************/
-uint32_t
-hal_get_mtu (hal_hdl_t hdl)
+uint32_t hal_get_mtu(hal_hdl_t hdl)
{
- netif_inst_t *inst;
+ netif_inst_t *inst;
- inst = get_netif_inst (hdl);
+ inst = get_netif_inst(hdl);
- if (inst == NULL)
+ if (inst == NULL)
{
- NSHAL_LOGERR ("netif does not exist]inst=%i", HAL_HDL_TO_ID (hdl));
- return 0;
+ NSHAL_LOGERR("netif does not exist]inst=%i", HAL_HDL_TO_ID(hdl));
+ return 0;
}
- return inst->ops->mtu (inst);
+ return inst->ops->mtu(inst);
}
-/*****************************************************************************
- Prototype : hal_get_macaddr
- Description : in normal mode, get the mac addr from nic
- in bond mode1, get the mac addr from primary nic
- Input : hal_hdl_t hdl
- void* mac_addr
- Output : None
- Return Value :
- Calls :
- Called By :
-*****************************************************************************/
-void
-hal_get_macaddr (hal_hdl_t hdl, void *mac_addr)
+void hal_get_macaddr(hal_hdl_t hdl, void *mac_addr)
{
- netif_inst_t *inst;
+ netif_inst_t *inst;
- inst = get_netif_inst (hdl);
+ inst = get_netif_inst(hdl);
- if (inst == NULL)
+ if (inst == NULL)
{
- NSHAL_LOGERR ("netif does not exist]inst=%i", HAL_HDL_TO_ID (hdl));
- return;
+ NSHAL_LOGERR("netif does not exist]inst=%i", HAL_HDL_TO_ID(hdl));
+ return;
}
- (void) inst->ops->macaddr (inst, mac_addr);
+ (void) inst->ops->macaddr(inst, mac_addr);
}
/*****************************************************************************
Prototype : hal_get_capability
Description : get offload capability from nic
Input : hal_hdl_t hdl
- hal_netif_capa_t* info
+ strcuct hal_netif_hw_feature* info
Output : None
Return Value :
Calls :
Called By :
*****************************************************************************/
-void
-hal_get_capability (hal_hdl_t hdl, hal_netif_capa_t * info)
+void hal_get_capability(hal_hdl_t hdl, struct hal_netif_hw_feature *info)
{
- netif_inst_t *inst;
+ netif_inst_t *inst;
- inst = get_netif_inst (hdl);
+ inst = get_netif_inst(hdl);
- if (inst == NULL)
+ if (inst == NULL)
{
- NSHAL_LOGERR ("netif does not exist]inst=%i", HAL_HDL_TO_ID (hdl));
- return;
+ NSHAL_LOGERR("netif does not exist]inst=%i", HAL_HDL_TO_ID(hdl));
+ return;
}
- (void) inst->ops->capability (inst, info);
+ (void) inst->ops->capability(inst, info);
}
-/*****************************************************************************
- Prototype : hal_recv_packet
- Description : recv packet from nic
- Input : hal_hdl_t hdl
- uint16_t queue_id
- struct common_mem_mbuf** rx_pkts
- uint16_t nb_pkts
- Output : None
- Return Value :
- Calls :
- Called By :
-*****************************************************************************/
-uint16_t
-hal_recv_packet (hal_hdl_t hdl, uint16_t queue_id,
- hal_mbuf_t ** rx_pkts, uint16_t nb_pkts)
+uint16_t hal_recv_packet(hal_hdl_t hdl, uint16_t queue_id,
+ void **rx_pkts, uint16_t nb_pkts)
{
- netif_inst_t *inst;
+ netif_inst_t *inst;
- inst = get_netif_inst (hdl);
+ inst = get_netif_inst(hdl);
- if (inst == NULL)
+ if (inst == NULL)
{
- NSHAL_LOGERR ("netif does not exist]inst=%i", HAL_HDL_TO_ID (hdl));
- return 0;
+ NSHAL_LOGERR("netif does not exist]inst=%i", HAL_HDL_TO_ID(hdl));
+ return 0;
}
- return inst->ops->recv (inst, queue_id, rx_pkts, nb_pkts);
+ return inst->ops->recv(inst, queue_id, rx_pkts, nb_pkts);
}
-/*****************************************************************************
- Prototype : hal_send_packet
- Description : send packet to nic
- Input : hal_hdl_t hdl
- uint16_t queue_id
- struct common_mem_mbuf** tx_pkts
- uint16_t nb_pkts
- Output : None
- Return Value :
- Calls :
- Called By :
-*****************************************************************************/
-uint16_t
-hal_send_packet (hal_hdl_t hdl, uint16_t queue_id,
- hal_mbuf_t ** tx_pkts, uint16_t nb_pkts)
+uint16_t hal_send_packet(hal_hdl_t hdl, uint16_t queue_id,
+ void **tx_pkts, uint16_t nb_pkts)
{
- netif_inst_t *inst;
+ netif_inst_t *inst;
- inst = get_netif_inst (hdl);
+ inst = get_netif_inst(hdl);
- if (inst == NULL)
+ if (inst == NULL)
{
- NSHAL_LOGERR ("netif does not exist]inst=%i", HAL_HDL_TO_ID (hdl));
- return 0;
+ NSHAL_LOGERR("netif does not exist]inst=%i", HAL_HDL_TO_ID(hdl));
+ return 0;
}
- return inst->ops->send (inst, queue_id, tx_pkts, nb_pkts);
+ return inst->ops->send(inst, queue_id, tx_pkts, nb_pkts);
}
-/*****************************************************************************
- Prototype : hal_link_status
- Description : get link status form nic
- Input : hal_hdl_t hdl
- Output : None
- Return Value :
- Calls :
- Called By :
-*****************************************************************************/
-uint32_t
-hal_link_status (hal_hdl_t hdl)
+uint32_t hal_link_status(hal_hdl_t hdl)
{
- netif_inst_t *inst;
+ netif_inst_t *inst;
- inst = get_netif_inst (hdl);
+ inst = get_netif_inst(hdl);
- if (inst == NULL)
+ if (inst == NULL)
{
- NSHAL_LOGERR ("netif does not exist]inst=%i", HAL_HDL_TO_ID (hdl));
- return 0;
+ NSHAL_LOGERR("netif does not exist]inst=%i", HAL_HDL_TO_ID(hdl));
+ return 0;
}
- return inst->ops->link_status (inst);
+ return inst->ops->link_status(inst);
}
-/*****************************************************************************
- Prototype : hal_stats
- Description : get link statistics form nic
- Input : hal_hdl_t hdl
- hal_netif_stats_t* stats
- Output : None
- Return Value :
- Calls :
- Called By :
-*****************************************************************************/
-int
-hal_stats (hal_hdl_t hdl, hal_netif_stats_t * stats)
+int hal_stats(hal_hdl_t hdl, hal_netif_stats_t * stats)
{
- netif_inst_t *inst;
+ netif_inst_t *inst;
- if (NULL == stats)
+ if (NULL == stats)
{
- NSHAL_LOGERR ("invalid para");
- return -1;
+ NSHAL_LOGERR("invalid para");
+ return -1;
}
- inst = get_netif_inst (hdl);
+ inst = get_netif_inst(hdl);
- if (inst == NULL)
+ if (inst == NULL)
{
- NSHAL_LOGERR ("netif does not exist]inst=%i", HAL_HDL_TO_ID (hdl));
- return -1;
+ NSHAL_LOGERR("netif does not exist]inst=%i", HAL_HDL_TO_ID(hdl));
+ return -1;
}
- return inst->ops->stats (inst, stats);
+ return inst->ops->stats(inst, stats);
}
-/*****************************************************************************
- Prototype : hal_stats_reset
- Description : reset link statistics to nic
- Input : hal_hdl_t hdl
- Output : None
- Return Value :
- Calls :
- Called By :
-*****************************************************************************/
-void
-hal_stats_reset (hal_hdl_t hdl)
+void hal_stats_reset(hal_hdl_t hdl)
{
- netif_inst_t *inst;
+ netif_inst_t *inst;
- inst = get_netif_inst (hdl);
+ inst = get_netif_inst(hdl);
- if (inst == NULL)
+ if (inst == NULL)
{
- NSHAL_LOGERR ("netif does not exist]inst=%i", HAL_HDL_TO_ID (hdl));
- return;
+ NSHAL_LOGERR("netif does not exist]inst=%i", HAL_HDL_TO_ID(hdl));
+ return;
}
- (void) inst->ops->stats_reset (inst);
+ (void) inst->ops->stats_reset(inst);
}
/*****************************************************************************
@@ -734,28 +651,27 @@ hal_stats_reset (hal_hdl_t hdl)
Calls :
Called By :
*****************************************************************************/
-int
-hal_add_mcastaddr (hal_hdl_t hdl, void *mc_addr_set,
- void *mc_addr, uint32_t nb_mc_addr)
+int hal_add_mcastaddr(hal_hdl_t hdl, void *mc_addr_set,
+ void *mc_addr, uint32_t nb_mc_addr)
{
- int ret;
- netif_inst_t *inst;
+ int ret;
+ netif_inst_t *inst;
- inst = get_netif_inst (hdl);
+ inst = get_netif_inst(hdl);
- if (inst == NULL)
+ if (inst == NULL)
{
- NSHAL_LOGERR ("netif does not exist]inst=%i", HAL_HDL_TO_ID (hdl));
- return -1;
+ NSHAL_LOGERR("netif does not exist]inst=%i", HAL_HDL_TO_ID(hdl));
+ return -1;
}
- ret = inst->ops->mcastaddr (inst, mc_addr_set, mc_addr, nb_mc_addr);
- /* if set mcast addr failed, we have to manually add the mac addr to nic. */
- if (ret < 0)
+ ret = inst->ops->mcastaddr(inst, mc_addr_set, mc_addr, nb_mc_addr);
+ /* if set mcast addr failed, we have to manually add the mac addr to nic. */
+ if (ret < 0)
{
- ret = inst->ops->add_mac (inst, mc_addr);
+ ret = inst->ops->add_mac(inst, mc_addr);
}
- return ret;
+ return ret;
}
/*****************************************************************************
@@ -770,28 +686,27 @@ hal_add_mcastaddr (hal_hdl_t hdl, void *mc_addr_set,
Calls :
Called By :
*****************************************************************************/
-int
-hal_del_mcastaddr (hal_hdl_t hdl, void *mc_addr_set,
- void *mc_addr, uint32_t nb_mc_addr)
+int hal_del_mcastaddr(hal_hdl_t hdl, void *mc_addr_set,
+ void *mc_addr, uint32_t nb_mc_addr)
{
- int ret;
- netif_inst_t *inst;
+ int ret;
+ netif_inst_t *inst;
- inst = get_netif_inst (hdl);
+ inst = get_netif_inst(hdl);
- if (inst == NULL)
+ if (inst == NULL)
{
- NSHAL_LOGERR ("netif does not exist]inst=%i", HAL_HDL_TO_ID (hdl));
- return -1;
+ NSHAL_LOGERR("netif does not exist]inst=%i", HAL_HDL_TO_ID(hdl));
+ return -1;
}
- ret = inst->ops->mcastaddr (inst, mc_addr_set, mc_addr, nb_mc_addr);
- /* if set mcast addr failed, we have to manually delete the mac addr from nic. */
- if (ret < 0)
+ ret = inst->ops->mcastaddr(inst, mc_addr_set, mc_addr, nb_mc_addr);
+ /* if set mcast addr failed, we have to manually delete the mac addr from nic. */
+ if (ret < 0)
{
- ret = inst->ops->rmv_mac (inst, mc_addr);
+ ret = inst->ops->rmv_mac(inst, mc_addr);
}
- return ret;
+ return ret;
}
/*****************************************************************************
@@ -804,20 +719,19 @@ hal_del_mcastaddr (hal_hdl_t hdl, void *mc_addr_set,
Calls :
Called By :
*****************************************************************************/
-void
-hal_set_allmulti_mode (hal_hdl_t hdl, uint8_t enable)
+void hal_set_allmulti_mode(hal_hdl_t hdl, uint8_t enable)
{
- netif_inst_t *inst;
+ netif_inst_t *inst;
- inst = get_netif_inst (hdl);
+ inst = get_netif_inst(hdl);
- if (inst == NULL)
+ if (inst == NULL)
{
- NSHAL_LOGERR ("netif does not exist]inst=%i", HAL_HDL_TO_ID (hdl));
- return;
+ NSHAL_LOGERR("netif does not exist]inst=%i", HAL_HDL_TO_ID(hdl));
+ return;
}
- (void) inst->ops->allmcast (inst, enable);
+ (void) inst->ops->allmcast(inst, enable);
}
/*****************************************************************************
@@ -829,35 +743,154 @@ hal_set_allmulti_mode (hal_hdl_t hdl, uint8_t enable)
Calls :
Called By :
*****************************************************************************/
-uint32_t
-hal_is_nic_exist (const char *name)
+uint32_t hal_is_nic_exist(const char *name)
{
- char script_cmmd[HAL_SCRIPT_LENGTH];
- char result_buf[HAL_SCRIPT_LENGTH];
- int len_out;
- int retval;
+ char script_cmmd[HAL_SCRIPT_LENGTH];
+ char result_buf[HAL_SCRIPT_LENGTH];
+ int len_out;
+ int retval;
- if (!hal_is_script_valid (name))
+ if (!hal_is_script_valid(name))
{
- NSHAL_LOGERR ("nic name is not valid");
- return 0;
+ NSHAL_LOGERR("nic name is not valid");
+ return 0;
}
- retval =
- hal_snprintf (script_cmmd, sizeof (script_cmmd),
- "sudo ifconfig -a | grep -w \"%s[ :]\"", name);
- if (-1 == retval)
+ // no need to use sudo, as inquire has no need of high permission
+ retval =
+ hal_snprintf(script_cmmd, sizeof(script_cmmd),
+ "ifconfig -a | grep \"%s[ :]\"", name);
+ /* check return value */
+ if (-1 == retval)
{
- NSHAL_LOGERR ("rte_snprintf failed]retval=%d", retval);
- return 0;
+ NSHAL_LOGERR("hal_snprintf failed]retval=%d", retval);
+ return 0;
}
- len_out = hal_run_script (script_cmmd, result_buf, sizeof (result_buf) - 1);
- /* buffer not initialized, should take length as decision */
- if (0 != len_out)
+ len_out = hal_run_script(script_cmmd, result_buf, sizeof(result_buf) - 1);
+ /* buffer not initialized, should take length as decision */
+ if (0 >= len_out)
+ {
+ NSHAL_LOGERR("hal_run_script fail]len_out=%d", len_out);
+ return 0;
+ }
+
+ return 1;
+}
+
+int hal_check_rss(hal_hdl_t hdl, uint32_t saddr, uint32_t daddr,
+ uint16_t sport, uint16_t dport, uint16_t * thread_index)
+{
+ if (!thread_index)
+ {
+ NSHAL_LOGERR("thread_index is null");
+ return -1;
+ }
+
+ netif_inst_t *inst;
+ inst = get_netif_inst(hdl);
+ if (inst == NULL)
+ {
+ NSHAL_LOGERR("inst is null]inst=%d", HAL_HDL_TO_ID(hdl));
+ return -1;
+ }
+
+ return inst->ops->check_rss(inst, saddr, daddr, sport, dport,
+ thread_index);
+}
+
+/*****************************************************************************
+* Prototype : hal_bond_switch
+* Description : bond switch API of hal layer
+* Input :
+* Output : None
+* Return Value : int
+* Calls :
+* Called By :
+*****************************************************************************/
+int hal_bond_switch(const char *bond_name)
+{
+ netif_inst_t *inst = get_netif_inst_by_name(bond_name);
+ if (!inst)
+ {
+ NSHAL_LOGERR("fail to get netif]name=%s", bond_name);
+ return -1;
+ }
+
+ return inst->ops->port_switch(inst);
+}
+
+/*****************************************************************************
+* Prototype : hal_get_bond_primary
+* Description : get bond primary API of hal layer
+* Input :
+* Output : None
+* Return Value : int
+* Calls :
+* Called By :
+*****************************************************************************/
+int hal_get_bond_primary(const char *bond_name)
+{
+ netif_inst_t *inst = get_netif_inst_by_name(bond_name);
+ if (!inst)
+ {
+ NSHAL_LOGERR("fail to get netif]name=%s", bond_name);
+ return -1;
+ }
+
+ int primary_id = inst->ops->get_bond_primary(inst);
+ if (primary_id < 0)
+ {
+ NSHAL_LOGERR("get_bond_primary id fail]name=%s", bond_name);
+ return -1;
+ }
+
+ int i;
+ for (i = 0; i < HAL_MAX_SLAVES_PER_BOND; i++)
+ {
+ if (primary_id == inst->data.dpdk_if.slave_port[i])
+ {
+ return i; //found it!
+ }
+ }
+
+ NSHAL_LOGERR
+ ("not found primary_id from slave_port array]primary_id=%d,slave[0]=%u,slave[1]=%u",
+ primary_id, inst->data.dpdk_if.slave_port[0],
+ inst->data.dpdk_if.slave_port[1]);
+ return -1;
+}
+
+int hal_check_rss6(hal_hdl_t hdl, uint32_t saddr[4], uint32_t daddr[4],
+ uint16_t sport, uint16_t dport, uint16_t * thread_index)
+{
+ if (!thread_index)
+ {
+ NSHAL_LOGERR("thread_index is null");
+ return -1;
+ }
+
+ netif_inst_t *inst;
+ inst = get_netif_inst(hdl);
+ if (inst == NULL)
+ {
+ NSHAL_LOGERR("inst is null]inst=%d", HAL_HDL_TO_ID(hdl));
+ return -1;
+ }
+
+ return inst->ops->check_rss6(inst, saddr, daddr, sport, dport,
+ thread_index);
+}
+
+struct hal_netif_hw_config *hal_get_netif_hw_config(hal_hdl_t hdl)
+{
+ netif_inst_t *inst;
+ inst = get_netif_inst(hdl);
+ if (inst == NULL)
{
- return 1;
+ NSHAL_LOGERR("inst is null]inst=%d", HAL_HDL_TO_ID(hdl));
+ return NULL;
}
- return 0;
+ return &inst->hw_config;
}
diff --git a/src/framework/hal/hal.h b/src/framework/hal/hal.h
index 5a8f51e..9d41bc2 100644
--- a/src/framework/hal/hal.h
+++ b/src/framework/hal/hal.h
@@ -18,8 +18,7 @@
#define _HAL_H_
#include <stdint.h>
-#include "hal_api.h"
-#include "nstack_log.h"
+#include "nsfw_hal_api.h"
#ifdef __cplusplus
/* *INDENT-OFF* */
@@ -29,150 +28,86 @@ extern "C" {
#define HAL_DRV_MAX 32
-#define HAL_IO_REGISTER(name, ops) \
- static __attribute__((__constructor__)) void __hal_register##name(void) \
- {\
- hal_io_adpt_register(ops); \
- } \
-
-
#define HAL_MAX_PCI_ADDR_LEN 16
-#define HAL_MAX_DRIVER_NAME_LEN 128
-
-#define HAL_MAX_PATH_LEN 4096 //max path length on linux is 4096
-
#define HAL_SCRIPT_LENGTH 256
#define HAL_HDL_TO_ID(hdl) (hdl.id)
-/* IO using DPDK interface */
-typedef struct dpdk_if
-{
- uint8_t port_id; /**< DPDK port identifier */
- uint8_t slave_num;
- uint8_t slave_port[HAL_MAX_SLAVES_PER_BOND];
-
- uint32_t hw_vlan_filter:1;
- uint32_t hw_vlan_strip:1;
- uint32_t rsv30:30;
-
- uint32_t rx_queue_num;
- uint32_t rx_ring_size[HAL_ETH_MAX_QUEUE_NUM];
- hal_mempool_t *rx_pool[HAL_ETH_MAX_QUEUE_NUM];
-
- uint32_t tx_queue_num;
- uint32_t tx_ring_size[HAL_ETH_MAX_QUEUE_NUM];
-
- char pci_addr[HAL_MAX_PCI_ADDR_LEN];
- char nic_name[HAL_MAX_NIC_NAME_LEN];
- char nic_type[HAL_MAX_NIC_NAME_LEN];
- char driver_name[HAL_MAX_DRIVER_NAME_LEN];
-} dpdk_if_t;
+extern netif_inst_t netif_tbl[HAL_MAX_NIC_NUM];
-typedef struct netif_inst
+static inline netif_inst_t *alloc_netif_inst()
{
- enum
- {
- NETIF_STATE_FREE = 0,
- NETIF_STATE_ACTIVE
- } state;
+ int i;
+ netif_inst_t *inst;
- hal_hdl_t hdl;
+ for (i = 0; i < HAL_MAX_NIC_NUM; ++i)
+ {
+ inst = &netif_tbl[i];
- const struct netif_ops *ops; /**< Implementation specific methods */
+ if (NETIF_STATE_FREE == inst->state)
+ {
+ inst->state = NETIF_STATE_ACTIVE;
- union
- {
- dpdk_if_t dpdk_if; /**< using DPDK for IO */
- } data;
+ inst->hdl.id = i;
-} netif_inst_t;
+ return inst;
+ }
+ }
-typedef struct netif_ops
-{
- const char *name;
- int (*init_global) (int argc, char **argv);
- int (*init_local) (void);
- int (*open) (netif_inst_t * inst, const char *name, const char *type);
- int (*close) (netif_inst_t * inst);
- int (*start) (netif_inst_t * inst);
- int (*stop) (netif_inst_t * inst);
- int (*bond) (netif_inst_t * inst, const char *bond_name,
- uint8_t slave_num, netif_inst_t * slave[]);
- uint32_t (*mtu) (netif_inst_t * inst);
- int (*macaddr) (netif_inst_t * inst, void *mac_addr);
- int (*capability) (netif_inst_t * inst, hal_netif_capa_t * info);
- uint16_t (*recv) (netif_inst_t * inst, uint16_t queue_id,
- hal_mbuf_t ** rx_pkts, uint16_t nb_pkts);
- uint16_t (*send) (netif_inst_t * inst, uint16_t queue_id,
- hal_mbuf_t ** tx_pkts, uint16_t nb_pkts);
- uint32_t (*link_status) (netif_inst_t * inst);
- int (*stats) (netif_inst_t * inst, hal_netif_stats_t * stats);
- int (*stats_reset) (netif_inst_t * inst);
- int (*config) (netif_inst_t * inst, hal_netif_config_t * conf);
- int (*mcastaddr) (netif_inst_t * inst, void *mc_addr_set,
- void *mc_addr, uint32_t nb_mc_addr);
- int (*add_mac) (netif_inst_t * inst, void *mc_addr);
- int (*rmv_mac) (netif_inst_t * inst, void *mc_addr);
- int (*allmcast) (netif_inst_t * inst, uint8_t enable);
-} netif_ops_t;
+ return NULL;
-extern netif_inst_t netif_tbl[HAL_MAX_NIC_NUM];
+}
-static inline netif_inst_t *
-alloc_netif_inst ()
+static inline netif_inst_t *get_netif_inst(hal_hdl_t hdl)
{
- int i;
- netif_inst_t *inst;
+ netif_inst_t *inst;
- for (i = 0; i < HAL_MAX_NIC_NUM; ++i)
+ if (unlikely(!hal_is_valid(hdl)))
{
- inst = &netif_tbl[i];
+ NSHAL_LOGERR("inst id is not valid]inst=%i, HAL_MAX_NIC_NUM=%d",
+ HAL_HDL_TO_ID(hdl), HAL_MAX_NIC_NUM);
- if (NETIF_STATE_FREE == inst->state)
- {
- inst->state = NETIF_STATE_ACTIVE;
+ return NULL;
+ }
- inst->hdl.id = i;
+ inst = &netif_tbl[HAL_HDL_TO_ID(hdl)];
- return inst;
- }
- }
+ if (unlikely((NETIF_STATE_ACTIVE != inst->state) || (NULL == inst->ops)))
+ {
+ NSHAL_LOGERR("netif is not active]inst=%i", HAL_HDL_TO_ID(hdl));
- return NULL;
+ return NULL;
+ }
+ return inst;
}
-static inline netif_inst_t *
-get_netif_inst (hal_hdl_t hdl)
+static inline netif_inst_t *get_netif_inst_by_name(const char *name)
{
- netif_inst_t *inst;
+ int i;
+ netif_inst_t *inst;
- if (unlikely (!hal_is_valid (hdl)))
+ if (!name)
{
- NSHAL_LOGERR ("inst id is not valid]inst=%i, HAL_MAX_NIC_NUM=%d",
- HAL_HDL_TO_ID (hdl), HAL_MAX_NIC_NUM);
-
- return NULL;
+ return NULL;
}
- inst = &netif_tbl[HAL_HDL_TO_ID (hdl)];
-
- if (unlikely ((NETIF_STATE_ACTIVE != inst->state) || (NULL == inst->ops)))
+ for (i = 0; i < HAL_MAX_NIC_NUM; ++i)
{
- NSHAL_LOGERR ("netif is not active]inst=%i", HAL_HDL_TO_ID (hdl));
+ inst = &netif_tbl[i];
- return NULL;
+ if (NETIF_STATE_ACTIVE == inst->state
+ && 0 == strncmp(name, inst->data.dpdk_if.nic_name,
+ HAL_MAX_NIC_NAME_LEN))
+ {
+ return inst;
+ }
}
- return inst;
-}
+ return NULL;
-int hal_snprintf (char *buffer, size_t buflen, const char *format, ...);
-int hal_is_script_valid (const char *cmd);
-int hal_run_script (const char *cmd, char *result_buf, size_t max_result_len);
-void hal_io_adpt_register (const netif_ops_t * ops);
+}
#ifdef __cplusplus
/* *INDENT-OFF* */
diff --git a/src/framework/common/include/compile_config.h b/src/framework/include/common/compile_config.h
index 2ec5373..2ec5373 100644
--- a/src/framework/common/include/compile_config.h
+++ b/src/framework/include/common/compile_config.h
diff --git a/src/framework/common/include/compiling_check.h b/src/framework/include/common/compiling_check.h
index e4a7538..41858b9 100644
--- a/src/framework/common/include/compiling_check.h
+++ b/src/framework/include/common/compiling_check.h
@@ -18,14 +18,16 @@
#define COMPILING_CHECK_H
/* protect the value of macro whose value impacts the version
- * compatibility, can't be changed!!! */
-#define COMPAT_PROTECT(name, value) \
-static inline char value_of_##name##_equal_to() \
-{ \
- char __dummy1[(name) - (value)]; \
- char __dummy2[(value) - (name)]; \
- return __dummy1[-1] + __dummy2[-1]; \
-}
+ * compatibility, can't be changed!!! */
+
+#define COMPAT_PROTECT_RETURN(name, value) \
+ \
+ static inline char value_of_##name##_equal_to() \
+ { \
+ char __dummy1[(name) - (value)]; \
+ char __dummy2[(value) - (name)]; \
+ return __dummy1[-1] + __dummy2[-1]; \
+ }
/* check whether struct size is equal to a special value */
#define SIZE_OF_TYPE_EQUAL_TO(type, size) \
@@ -37,7 +39,7 @@ static inline char size_of_##type##_equal_to_##size() \
}
/* check whether struct size is not equal to a special value */
-#define SIZE_OF_TYPE_UNEQUAL_TO(type, size) \
+#define SIZE_OF_TYPE_UNEQUAL_TO_RETURN(type, size) \
static inline char size_of_##type##_unequal_to_##size() \
{ \
char __dummy1[0==(10/(sizeof(type)-size))]; \
@@ -45,7 +47,7 @@ static inline char size_of_##type##_unequal_to_##size() \
}
/* check whether struct size is not larger than a special value */
-#define SIZE_OF_TYPE_NOT_LARGER_THAN(type, size) \
+#define SIZE_OF_TYPE_NOT_LARGER_THAN_RETURN(type, size) \
static inline char size_of_##type##_not_larger_than_##size() \
{ \
char __dummy1[size - sizeof(type)]; \
@@ -54,7 +56,7 @@ static inline char size_of_##type##_not_larger_than_##size() \
/* check whether struct size + sizeof(void*) is not larger than a special value */
/* reserve 8 bytes for 64 bits pointers */
-#define SIZE_OF_TYPE_PLUS8_NOT_LARGER_THAN(type, size) \
+#define SIZE_OF_TYPE_PLUS8_NOT_LARGER_THAN_RETURN(type, size) \
static inline char size_of_##type##_not_larger_than_##size() \
{ \
char __dummy1[size - sizeof(type) - sizeof(void*)]; \
@@ -62,7 +64,7 @@ static inline char size_of_##type##_not_larger_than_##size() \
}
/* check whether struct size is not smaller than a special value */
-#define SIZE_OF_TYPE_NOT_SMALLER_THAN(type, size) \
+#define SIZE_OF_TYPE_NOT_SMALLER_THAN_RETURN(type, size) \
static inline char size_of_##type##_not_smaller_than_##size() \
{ \
char __dummy1[sizeof(type) - size]; \
@@ -71,13 +73,13 @@ static inline char size_of_##type##_not_smaller_than_##size() \
/* check whether struct size is smaller than a special value */
#define SIZE_OF_TYPE_SMALLER_THAN(type, size) \
- SIZE_OF_TYPE_NOT_LARGER_THAN(type, size) \
- SIZE_OF_TYPE_UNEQUAL_TO(type, size)
+ SIZE_OF_TYPE_NOT_LARGER_THAN_RETURN(type, size) \
+ SIZE_OF_TYPE_UNEQUAL_TO_RETURN(type, size)
/* check whether struct size is larger than a special value */
#define SIZE_OF_TYPE_LARGER_THAN(type, size) \
- SIZE_OF_TYPE_NOT_SMALLER_THAN(type, size) \
- SIZE_OF_TYPE_UNEQUAL_TO(type, size)
+ SIZE_OF_TYPE_NOT_SMALLER_THAN_RETURN(type, size) \
+ SIZE_OF_TYPE_UNEQUAL_TO_RETURN(type, size)
/* check whether struct size is smaller than a special value, version 2 */
#define SIZE_OF_TYPE_SMALLER_THAN2(type, size) \
diff --git a/src/framework/common/include/dmm_fs.h b/src/framework/include/common/dmm_fs.h
index 8fd9cd0..3a63550 100644
--- a/src/framework/common/include/dmm_fs.h
+++ b/src/framework/include/common/dmm_fs.h
@@ -13,20 +13,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
#ifndef _DMM_FS_H_
#define _DMM_FS_H_
-
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
-static size_t
-dmm_file_size (int fd)
+static inline size_t dmm_file_size(int fd)
{
- struct stat st;
- if (fstat (fd, &st) < 0)
- return 0;
- return st.st_size;
+ struct stat st;
+ if (fstat(fd, &st) < 0)
+ return 0;
+ return (size_t) st.st_size;
}
#endif /* _DMM_FS_H_ */
diff --git a/src/framework/include/common/generic/dmm_atomic.h b/src/framework/include/common/generic/dmm_atomic.h
new file mode 100644
index 0000000..0778e4a
--- /dev/null
+++ b/src/framework/include/common/generic/dmm_atomic.h
@@ -0,0 +1,184 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#ifndef _DMM_ATOMIC_H_
+#define _DMM_ATOMIC_H_
+
+/* atomic 32 bit operation */
+
+typedef struct
+{
+ volatile int cnt;
+} dmm_atomic_t;
+
+inline static void dmm_atomic_set(dmm_atomic_t * a, int n)
+{
+ a->cnt = n;
+}
+
+inline static int dmm_atomic_get(dmm_atomic_t * a)
+{
+ return a->cnt;
+}
+
+inline static int dmm_atomic_add(dmm_atomic_t * a, int n)
+{
+ return __sync_fetch_and_add(&a->cnt, n);
+}
+
+inline static int dmm_atomic_inc(dmm_atomic_t * a)
+{
+ return dmm_atomic_add(a, 1);
+}
+
+inline static int dmm_atomic_sub(dmm_atomic_t * a, int n)
+{
+ return __sync_fetch_and_sub(&a->cnt, n);
+}
+
+inline static int dmm_atomic_dec(dmm_atomic_t * a)
+{
+ return dmm_atomic_sub(a, 1);
+}
+
+inline static int dmm_atomic_and(dmm_atomic_t * a, int n)
+{
+ return __sync_fetch_and_and(&a->cnt, n);
+}
+
+inline static int dmm_atomic_or(dmm_atomic_t * a, int n)
+{
+ return __sync_fetch_and_or(&a->cnt, n);
+}
+
+inline static int dmm_atomic_xor(dmm_atomic_t * a, int n)
+{
+ return __sync_fetch_and_xor(&a->cnt, n);
+}
+
+inline static int dmm_atomic_swap(dmm_atomic_t * a, int o, int n)
+{
+ return __sync_bool_compare_and_swap(&a->cnt, o, n);
+}
+
+inline static int dmm_atomic_add_return(dmm_atomic_t * a, int n)
+{
+ return __sync_add_and_fetch(&a->cnt, n);
+}
+
+inline static int dmm_atomic_sub_return(dmm_atomic_t * a, int n)
+{
+ return __sync_sub_and_fetch(&a->cnt, n);
+}
+
+inline static int dmm_atomic_and_return(dmm_atomic_t * a, int n)
+{
+ return __sync_and_and_fetch(&a->cnt, n);
+}
+
+inline static int dmm_atomic_or_return(dmm_atomic_t * a, int n)
+{
+ return __sync_or_and_fetch(&a->cnt, n);
+}
+
+inline static int dmm_atomic_xor_return(dmm_atomic_t * a, int n)
+{
+ return __sync_xor_and_fetch(&a->cnt, n);
+}
+
+/* atomit 64bit operation */
+
+typedef struct
+{
+ volatile long long int cnt;
+} dmm_atomic64_t;
+
+inline static long long int dmm_atomic64_get(dmm_atomic64_t * a)
+{
+ return a->cnt;
+}
+
+inline static void dmm_atomic64_set(dmm_atomic64_t * a, int n)
+{
+ a->cnt = n;
+}
+
+inline static long long int dmm_atomic64_add(dmm_atomic64_t * a, int n)
+{
+ return __sync_fetch_and_add(&a->cnt, n);
+}
+
+inline static int dmm_atomic64_inc(dmm_atomic64_t * a)
+{
+ return dmm_atomic64_add(a, 1);
+}
+
+inline static long long int dmm_atomic64_sub(dmm_atomic64_t * a, int n)
+{
+ return __sync_fetch_and_sub(&a->cnt, n);
+}
+
+inline static int dmm_atomic64_dec(dmm_atomic64_t * a)
+{
+ return dmm_atomic64_sub(a, 1);
+}
+
+inline static long long int dmm_atomic64_and(dmm_atomic64_t * a, int n)
+{
+ return __sync_fetch_and_and(&a->cnt, n);
+}
+
+inline static long long int dmm_atomic64_or(dmm_atomic64_t * a, int n)
+{
+ return __sync_fetch_and_or(&a->cnt, n);
+}
+
+inline static long long int dmm_atomic64_xor(dmm_atomic64_t * a, int n)
+{
+ return __sync_fetch_and_xor(&a->cnt, n);
+}
+
+inline static long long int dmm_atomic64_swap(dmm_atomic_t * a, int o, int n)
+{
+ return __sync_bool_compare_and_swap(&a->cnt, o, n);
+}
+
+inline static long long int dmm_atomic64_add_return(dmm_atomic64_t * a, int n)
+{
+ return __sync_add_and_fetch(&a->cnt, n);
+}
+
+inline static long long int dmm_atomic64_sub_return(dmm_atomic64_t * a, int n)
+{
+ return __sync_sub_and_fetch(&a->cnt, n);
+}
+
+inline static long long int dmm_atomic64_and_return(dmm_atomic64_t * a, int n)
+{
+ return __sync_and_and_fetch(&a->cnt, n);
+}
+
+inline static long long int dmm_atomic64_or_return(dmm_atomic64_t * a, int n)
+{
+ return __sync_or_and_fetch(&a->cnt, n);
+}
+
+inline static long long int dmm_atomic64_xor_return(dmm_atomic64_t * a, int n)
+{
+ return __sync_xor_and_fetch(&a->cnt, n);
+}
+
+#endif /* #ifndef _DMM_ATOMIC_H_ */
diff --git a/src/framework/common/include/generic/dmm_barrier.h b/src/framework/include/common/generic/dmm_barrier.h
index b70fe85..5076702 100644
--- a/src/framework/common/include/generic/dmm_barrier.h
+++ b/src/framework/include/common/generic/dmm_barrier.h
@@ -13,13 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
#ifndef _DMM_BARRIER_H_
#define _DMM_BARRIER_H_
-inline static void
-dmm_barrier (void)
+inline static void dmm_barrier(void)
{
- __sync_synchronize ();
+ __sync_synchronize();
}
#endif /* #ifndef _DMM_BARRIER_H_ */
diff --git a/src/framework/include/common/generic/dmm_common.h b/src/framework/include/common/generic/dmm_common.h
new file mode 100644
index 0000000..344f47e
--- /dev/null
+++ b/src/framework/include/common/generic/dmm_common.h
@@ -0,0 +1,68 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#ifndef _DMM_COMMON_H_
+#define _DMM_COMMON_H_
+
+#include "dmm_config.h"
+
+#ifndef likely
+#define likely(x) __builtin_expect(!!(x), 1)
+#endif
+#ifndef unlikely
+#define unlikely(x) __builtin_expect(!!(x), 0)
+#endif
+
+#define _dmm_packed __attribute__((__packed__))
+#define _dmm_aliened(a) __attribute__((__aligned__(a)))
+#define _dmm_cache_aligned _dmm_aliened(DMM_CACHE_LINE_SIZE)
+
+#define DMM_ALIGN(x, a) (((x) + ((a) - 1)) / (a) * (a))
+#define dmm_align(x, a) ({ \
+ typeof(x) _a = (a); \
+ ((x) + (_a - 1)) / _a * _a; \
+})
+
+#ifndef offsetof
+#define offsetof(type, member) ((size_t)((type *)0)->member)
+#endif
+
+inline static unsigned int dmm_align32pow2(unsigned int v)
+{
+ v--;
+ v |= v >> 1;
+ v |= v >> 2;
+ v |= v >> 4;
+ v |= v >> 8;
+ v |= v >> 16;
+
+ return v + 1;
+}
+
+inline static unsigned long long dmm_align64pow2(unsigned long long v)
+{
+ v--;
+ v |= v >> 1;
+ v |= v >> 2;
+ v |= v >> 4;
+ v |= v >> 8;
+ v |= v >> 16;
+ v |= v >> 32;
+
+ return v + 1;
+}
+
+#endif
diff --git a/src/framework/include/dmm_config.h b/src/framework/include/common/generic/dmm_config.h
index 43a06ab..657ecd8 100644
--- a/src/framework/include/dmm_config.h
+++ b/src/framework/include/common/generic/dmm_config.h
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
#ifndef _DMM_CONFIG_H_
#define _DMM_CONFIG_H_
@@ -21,23 +22,31 @@
#endif
#ifndef DMM_MAIN_SHARE_TYPE
-#define DMM_MAIN_SHARE_TYPE DMM_SHARE_FSHM /* 1 */
+#define DMM_MAIN_SHARE_TYPE DMM_SHARE_FSHM
#endif
#ifndef DMM_MAIN_SHARE_SIZE
#define DMM_MAIN_SHARE_SIZE 1024 /* Megabyte */
#endif
+#ifndef DMM_MAIN_SHARE_BASE
+#define DMM_MAIN_SHARE_BASE 0x700080000000 /* fixed base address */
+#endif
+
#ifndef DMM_SHARE_TYPE
-#define DMM_SHARE_TYPE DMM_SHARE_FSHM /* 1 */
+#define DMM_SHARE_TYPE DMM_SHARE_FSHM
#endif
#ifndef DMM_SHARE_SIZE
-#define DMM_SHARE_SIZE 16 /* Megabyte */
+#define DMM_SHARE_SIZE 8 /* Megabyte */
#endif
#ifndef DMM_HUGE_DIR
-#define DMM_HUGE_DIR "/mnt/dmm-huge"
+#define DMM_HUGE_DIR "/mnt/nstackhuge"
+#endif
+
+#ifndef DMM_CACHE_LINE_SIZE
+#define DMM_CACHE_LINE_SIZE 64
#endif
#endif /* _DMM_CONFIG_H_ */
diff --git a/src/framework/common/include/generic/dmm_pause.h b/src/framework/include/common/generic/dmm_pause.h
index 56c60f0..65b60db 100644
--- a/src/framework/common/include/generic/dmm_pause.h
+++ b/src/framework/include/common/generic/dmm_pause.h
@@ -13,15 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
#ifndef _DMM_PAUSE_H_
#define _DMM_PAUSE_H_
#include <emmintrin.h>
-inline static void
-dmm_pause (void)
+inline static void dmm_pause(void)
{
- _mm_pause ();
+ _mm_pause();
}
#define DMM_PAUSE_WHILE(cond) do { dmm_pause(); } while (!!(cond))
diff --git a/src/framework/common/include/generic/dmm_rwlock.h b/src/framework/include/common/generic/dmm_rwlock.h
index 93570f1..2b9ec8b 100644
--- a/src/framework/common/include/generic/dmm_rwlock.h
+++ b/src/framework/include/common/generic/dmm_rwlock.h
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
#ifndef _DMM_RWLOCK_H_
#define _DMM_RWLOCK_H_
@@ -20,57 +21,52 @@
typedef struct
{
- volatile int lock;
+ volatile int lock;
} dmm_rwlock_t;
#define DMM_RWLOCK_INIT { 0 }
-inline static void
-dmm_rwlock_init (dmm_rwlock_t * rwlock)
+inline static void dmm_rwlock_init(dmm_rwlock_t * rwlock)
{
- rwlock->lock = 0;
+ rwlock->lock = 0;
}
-inline static void
-dmm_read_lock (dmm_rwlock_t * rwlock)
+inline static void dmm_read_lock(dmm_rwlock_t * rwlock)
{
- int val;
+ int val;
- do
+ do
{
- if ((val = rwlock->lock) < 0)
+ if ((val = rwlock->lock) < 0)
{
- dmm_pause ();
- continue;
+ dmm_pause();
+ continue;
}
}
- while (!__sync_bool_compare_and_swap (&rwlock->lock, val, val + 1));
+ while (!__sync_bool_compare_and_swap(&rwlock->lock, val, val + 1));
}
-inline static void
-dmm_read_unlock (dmm_rwlock_t * rwlock)
+inline static void dmm_read_unlock(dmm_rwlock_t * rwlock)
{
- __sync_sub_and_fetch (&rwlock->lock, 1);
+ __sync_sub_and_fetch(&rwlock->lock, 1);
}
-inline static void
-dmm_write_lock (dmm_rwlock_t * rwlock)
+inline static void dmm_write_lock(dmm_rwlock_t * rwlock)
{
- do
+ do
{
- if (rwlock->lock != 0)
+ if (rwlock->lock != 0)
{
- dmm_pause ();
- continue;
+ dmm_pause();
+ continue;
}
}
- while (!__sync_bool_compare_and_swap (&rwlock->lock, 0, -1));
+ while (!__sync_bool_compare_and_swap(&rwlock->lock, 0, -1));
}
-inline static void
-dmm_write_unlock (dmm_rwlock_t * rwlock)
+inline static void dmm_write_unlock(dmm_rwlock_t * rwlock)
{
- rwlock->lock = 0;
+ rwlock->lock = 0;
}
#endif /* #ifndef _DMM_RWLOCK_H_ */
diff --git a/src/framework/include/common/generic/dmm_spinlock.h b/src/framework/include/common/generic/dmm_spinlock.h
new file mode 100644
index 0000000..5723ecf
--- /dev/null
+++ b/src/framework/include/common/generic/dmm_spinlock.h
@@ -0,0 +1,119 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#ifndef _DMM_SPINLOCK_H_
+#define _DMM_SPINLOCK_H_
+
+#include "dmm_pause.h"
+#include "pid_common.h"
+#include "nsfw_branch_prediction.h"
+#include "nstack_log.h"
+
+#define DMM_SPINLOCK_MALLOC(sys_sem,count) \
+{ \
+ dmm_spin_init(&(sys_sem)); \
+ /*not problem*/\
+ if (!(count)) \
+ /*not problem*/\
+ { \
+ dmm_spin_lock(&(sys_sem)); \
+ } \
+}
+
+typedef struct
+{
+ volatile int lock;
+} dmm_spinlock_t;
+
+inline static void dmm_spin_init(dmm_spinlock_t * spinlock)
+{
+ spinlock->lock = 0;
+}
+
+static inline int dmm_spin_trylock_with(dmm_spinlock_t * spinlock, int value)
+{
+ return __sync_bool_compare_and_swap(&spinlock->lock, 0, value);
+}
+
+static inline void dmm_spin_lock_with(dmm_spinlock_t * spinlock, int value)
+{
+ while (!dmm_spin_trylock_with(spinlock, value))
+ {
+ DMM_PAUSE_WHILE(spinlock->lock);
+ }
+}
+
+inline static void dmm_spin_lock(dmm_spinlock_t * spinlock)
+{
+ dmm_spin_lock_with(spinlock, 1);
+}
+
+inline static int dmm_spin_trylock(dmm_spinlock_t * spinlock)
+{
+ return dmm_spin_trylock_with(spinlock, 1);
+}
+
+//replace sys_sem_s_signal
+inline static void dmm_spin_unlock(dmm_spinlock_t * spinlock)
+{
+ __sync_lock_release(&spinlock->lock);
+}
+
+//replace sys_arch_trylock_with_pid
+static inline int dmm_spin_trylock_with_pid(dmm_spinlock_t * sem, int t_us)
+{
+ if (unlikely(SYS_HOST_INITIAL_PID == g_sys_host_pid))
+ (void) sys_get_hostpid_from_file(getpid());
+
+ if (dmm_spin_trylock_with(sem, g_sys_host_pid))
+ {
+ return 0;
+ }
+
+ while (t_us > 0)
+ {
+ --t_us;
+ sys_sleep_ns(0, 1000);
+ if (dmm_spin_trylock_with(sem, g_sys_host_pid))
+ {
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
+//replace sys_arch_sem_trywait_s_v2
+static inline int dmm_spinlock_trylock(dmm_spinlock_t * sl)
+{
+ int lockval = 1;
+
+ asm volatile ("xchg %[locked], %[lockval]":[locked] "=m"(sl->lock),
+ [lockval] "=q"(lockval):"[lockval]"(lockval):"memory");
+
+ return lockval == 0;
+}
+
+static inline u32_t dmm_spin_lock_with_pid(dmm_spinlock_t * sem)
+{
+ if (SYS_HOST_INITIAL_PID == g_sys_host_pid)
+ {
+ (void) sys_get_hostpid_from_file(getpid());
+ }
+ dmm_spin_lock_with(sem, g_sys_host_pid);
+ return 0;
+}
+#endif /* #ifndef _DMM_SPINLOCK_H_ */
diff --git a/src/framework/common/include/list.h b/src/framework/include/common/list.h
index 01860bc..06b558b 100644
--- a/src/framework/common/include/list.h
+++ b/src/framework/include/common/list.h
@@ -32,15 +32,15 @@ extern "C" {
struct list_head
{
- union
- {
- struct list_head *next;
- };
-
- union
- {
- struct list_head *prev;
- };
+ union
+ {
+ struct list_head *next;
+ };
+
+ union
+ {
+ struct list_head *prev;
+ };
};
struct hlist_node
@@ -48,32 +48,30 @@ struct hlist_node
/**
* @pprev: point the previous node's next pointer
*/
- union
- {
- struct hlist_node *next;
- };
-
- union
- {
- struct hlist_node **pprev;
- };
+ union
+ {
+ struct hlist_node *next;
+ };
+
+ union
+ {
+ struct hlist_node **pprev;
+ };
};
struct hlist_head
{
- struct hlist_node *first;
+ struct hlist_node *first;
};
#define list_entry(ptr, type, member) \
- container_of(ptr, type, member)
+ container_of(ptr, type, member)
#define list_for_each_entry_type(tpos, typeof_tpos,pos, head, member) \
for (pos = ((head)->next); \
pos && pos != (head) && ({tpos = list_entry(pos, typeof_tpos, member); 1;}); \
pos = ((pos)->next))
-#define LINT_LIST()
-
#define list_for_each_entry(tpos, pos, head, member) \
for (pos = ((head)->next); \
pos && pos != (head) && ({tpos = list_entry(pos, typeof(*tpos), member); 1;}); \
@@ -93,28 +91,28 @@ struct hlist_head
/*
* @head: the list to test.
*/
-inline void list_add (struct list_head *newp, struct list_head *head);
-inline void list_link (struct list_head *newhead, struct list_head *head);
-inline void list_add_tail (struct list_head *newp, struct list_head *head);
-inline int list_empty (const struct list_head *head);
-inline void list_del (struct list_head *entry);
-inline struct list_head *list_get_first (struct list_head *head);
-inline void hlist_del_init (struct hlist_node *n);
+inline void list_add(struct list_head *newp, struct list_head *head);
+inline void list_link(struct list_head *newhead, struct list_head *head);
+inline void list_add_tail(struct list_head *newp, struct list_head *head);
+inline int list_empty(const struct list_head *head);
+inline void list_del(struct list_head *entry);
+inline struct list_head *list_get_first(struct list_head *head);
+inline void hlist_del_init(struct hlist_node *n);
struct hlist_tail
{
- struct hlist_node *end;
+ struct hlist_node *end;
};
struct hlist_ctl
{
- struct hlist_head head;
- struct hlist_tail tail;
+ struct hlist_head head;
+ struct hlist_tail tail;
};
#define INIT_HLIST_CTRL(ptr) {(ptr)->head.first = NULL; (ptr)->tail.end = NULL;}
-inline int hlist_empty (const struct hlist_head *h);
-inline void hlist_add_head (struct hlist_node *n, struct hlist_head *h);
+inline int hlist_empty(const struct hlist_head *h);
+inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h);
#define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL)
#define INIT_HLIST_NODE(ptr) {(ptr)->next = NULL; (ptr)->pprev = NULL;}
@@ -145,7 +143,7 @@ inline void hlist_add_head (struct hlist_node *n, struct hlist_head *h);
pos && ({tpos = hlist_entry(pos, typeof_tpos, member); 1;}); \
pos = pos->next)
-inline void hlist_del_init (struct hlist_node *n);
+inline void hlist_del_init(struct hlist_node *n);
/**
* next must be != NULL
@@ -154,7 +152,7 @@ inline void hlist_del_init (struct hlist_node *n);
* @n: new node
* @next: node in the hlist
*/
-inline void hlist_add_before (struct hlist_node *n, struct hlist_node *next);
+inline void hlist_add_before(struct hlist_node *n, struct hlist_node *next);
/**
* next must be != NULL
@@ -163,14 +161,14 @@ inline void hlist_add_before (struct hlist_node *n, struct hlist_node *next);
* @n: node in the hlist
* @next: new node
*/
-inline void hlist_add_after (struct hlist_node *n, struct hlist_node *next);
+inline void hlist_add_after(struct hlist_node *n, struct hlist_node *next);
/* add after the head */
-inline void hlist_add_head (struct hlist_node *n, struct hlist_head *h);
+inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h);
-inline int hlist_unhashed (const struct hlist_node *h);
+inline int hlist_unhashed(const struct hlist_node *h);
-inline int hlist_empty (const struct hlist_head *h);
+inline int hlist_empty(const struct hlist_head *h);
#ifdef __cplusplus
/* *INDENT-OFF* */
diff --git a/src/framework/include/common/pid_common.h b/src/framework/include/common/pid_common.h
new file mode 100644
index 0000000..a8f5572
--- /dev/null
+++ b/src/framework/include/common/pid_common.h
@@ -0,0 +1,82 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#ifndef _PIA_COMMON_H_
+#define _PIA_COMMON_H_
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <unistd.h>
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
+#ifndef u32_t
+typedef uint32_t u32_t;
+#endif
+
+#define SYS_HOST_INITIAL_PID 1
+
+#define READ_FILE_BUFLEN 512
+#define BUF_SIZE_FILEPATH 256
+
+#define MAX_GET_PID_TIME 10
+
+extern volatile pid_t g_sys_host_pid;
+
+pid_t sys_get_hostpid_from_file(pid_t pid);
+pid_t get_hostpid_from_file(u32_t pid);
+pid_t get_hostpid_from_file_one_time(u32_t pid);
+void get_exec_name_by_pid(pid_t pid, char *task_name, int task_name_len);
+pid_t updata_sys_pid();
+
+static inline pid_t get_sys_pid()
+{
+ if (SYS_HOST_INITIAL_PID == g_sys_host_pid)
+ (void) sys_get_hostpid_from_file(getpid());
+ return g_sys_host_pid;
+}
+
+#ifndef u64
+typedef unsigned long long u64;
+#endif
+
+typedef struct nsfw_app_info
+{
+ int nsocket_fd;
+ int sbr_fd;
+
+ int hostpid;
+ int pid;
+ int ppid;
+ int tid;
+ u64 extend_member_bit;
+} nsfw_app_info_t;
+
+#define _dmm_packed __attribute__((__packed__))
+#define _dmm_aliened(a) __attribute__((__aligned__(a)))
+#define _dmm_cache_aligned _dmm_aliened(DMM_CACHE_LINE_SIZE)
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif
+
+#endif
diff --git a/src/framework/common/include/pidinfo.h b/src/framework/include/common/pidinfo.h
index 7438756..d97fa1d 100644
--- a/src/framework/common/include/pidinfo.h
+++ b/src/framework/include/common/pidinfo.h
@@ -26,18 +26,19 @@ extern "C" {
#endif
#define NSFW_MAX_FORK_NUM 32
+
typedef struct
{
- u32 used_size;
- u32 apid[NSFW_MAX_FORK_NUM];
+ u32 used_size;
+ u32 apid[NSFW_MAX_FORK_NUM];
} nsfw_pidinfo;
-inline i32 nsfw_pidinfo_init (nsfw_pidinfo * pidinfo);
-inline int nsfw_add_pid (nsfw_pidinfo * pidinfo, u32 pid);
-inline int nsfw_del_pid (nsfw_pidinfo * pidinfo, u32 pid);
-inline int nsfw_del_last_pid (nsfw_pidinfo * pidinfo, u32 pid);
-inline int nsfw_pid_exist (nsfw_pidinfo * pidinfo, u32 pid);
-inline int nsfw_pidinfo_empty (nsfw_pidinfo * pidinfo);
+inline i32 nsfw_pidinfo_init(nsfw_pidinfo * pidinfo);
+inline int nsfw_add_pid(nsfw_pidinfo * pidinfo, u32 pid);
+inline int nsfw_del_pid(nsfw_pidinfo * pidinfo, u32 pid);
+inline int nsfw_del_last_pid(nsfw_pidinfo * pidinfo, u32 pid);
+inline int nsfw_pid_exist(nsfw_pidinfo * pidinfo, u32 pid);
+inline int nsfw_pidinfo_empty(nsfw_pidinfo * pidinfo);
#ifdef __cplusplus
/* *INDENT-OFF* */
diff --git a/src/framework/include/dmm_ring.h b/src/framework/include/dmm_ring.h
new file mode 100644
index 0000000..003f0ac
--- /dev/null
+++ b/src/framework/include/dmm_ring.h
@@ -0,0 +1,100 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#ifndef _DMM_RING_H_
+#define _DMM_RING_H_
+
+#include <stdint.h>
+
+#include "dmm_atomic.h"
+#include "dmm_pause.h"
+#include "dmm_barrier.h"
+#include "dmm_common.h"
+#include "types.h"
+
+#define DMM_RING_MAX_NUM 0x7FFFFFFE /* 2,147,483,646 */
+
+#define DMM_RING_INIT_SP 0x0001
+#define DMM_RING_INIT_SC 0x0002
+#define DMM_RING_INIT_MPMC 0
+#define DMM_RING_INIT_SPSC (DMM_RING_INIT_SP | DMM_RING_INIT_SC)
+
+struct dmm_ring
+{
+ u8 memtype; //share, no share
+ u8 ringflag; //scmp, scsp, mcsp,mcmp
+ int size; //size of ring
+ size_t eltsize; //for sppool, it is the size of per buf, if is ring, eltsize is zero.
+ uint32_t flag;
+
+ volatile int prod_head;
+ volatile int prod_tail;
+ int is_sp;
+ int _prod_pad;
+
+ volatile int cons_head;
+ volatile int cons_tail;
+ int is_sc;
+ int _cons_pad;
+} _dmm_cache_aligned;
+
+void dmm_ring_dump(struct dmm_ring *ring, int list);
+int dmm_ring_init(struct dmm_ring *ring, int num, size_t eltsize, int flag,
+ unsigned char memtype);
+int dmm_pool_init(struct dmm_ring *pool, size_t elt_size, int num, int flag,
+ unsigned char memtype);
+int dmm_mem_enqueue(void *ring, void *p);
+int dmm_mem_dequeue(void *ring, void **p);
+
+inline static size_t dmm_ring_bufsize(int num)
+{
+ size_t size = sizeof(struct dmm_ring);
+
+ size += (sizeof(void *) * (num + 1));
+
+ return dmm_align(size, DMM_CACHE_LINE_SIZE);
+}
+
+inline static size_t dmm_pool_arraysize(int num, size_t elt_size)
+{
+ const size_t size = elt_size * num;
+ return dmm_align(size, DMM_CACHE_LINE_SIZE);
+}
+
+inline static size_t dmm_pool_bufsize(int num, size_t elt_size)
+{
+ return dmm_ring_bufsize(num) + dmm_pool_arraysize(num, elt_size);
+}
+
+inline static int dmm_ring_count(struct dmm_ring *ring)
+{
+ const int count = ring->prod_tail - ring->cons_head;
+
+ if (count >= 0)
+ return count;
+ return count + ring->size;
+}
+
+inline static int dmm_ring_free_count(struct dmm_ring *ring)
+{
+ const int count = ring->cons_tail - ring->prod_head;
+
+ if (count >= 0)
+ return count;
+ return count + ring->size;
+}
+
+#endif
diff --git a/src/framework/include/hal_api.h b/src/framework/include/hal_api.h
deleted file mode 100644
index a5d7725..0000000
--- a/src/framework/include/hal_api.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _HAL_API_H_
-#define _HAL_API_H_
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-typedef void hal_mempool_t;
-typedef void hal_mbuf_t;
-
-#define HAL_ETH_MAX_QUEUE_NUM 4
-
-#define HAL_ETH_QUEUE_STAT_CNTRS 16
-
-#define HAL_MAX_NIC_NUM 4096
-COMPAT_PROTECT (HAL_MAX_NIC_NUM, 4096);
-
-#define HAL_MAX_SLAVES_PER_BOND 2
-
-#define HAL_MAX_NIC_NAME_LEN 256
-
-/**
- * TX offload capabilities of a device.
- */
-#define HAL_ETH_TX_OFFLOAD_IPV4_CKSUM 0x00000002
-#define HAL_ETH_TX_OFFLOAD_UDP_CKSUM 0x00000004
-#define HAL_ETH_TX_OFFLOAD_TCP_CKSUM 0x00000008
-
-/**
- * Hal Instance Handler
- */
-typedef struct hal_hdl
-{
- int id;
-} hal_hdl_t;
-
-/**
- * Ethernet device capability
- */
-typedef struct hal_netif_capa
-{
- uint32_t tx_offload_capa; /**< Device TX offload capabilities. */
-} hal_netif_capa_t;
-
-/**
- * A structure used to retrieve statistics for an Ethernet port.
- */
-typedef struct hal_netif_stats
-{
- uint64_t ipackets; /**< Total no.of packets that are successfully received . */
- uint64_t opackets; /**< Total no.of packets that are successfully transmitted .*/
- uint64_t ibytes; /**< Total no.of bytes that are successfully received . */
- uint64_t obytes; /**< Total no.of bytes that are successfully transmitted . */
- uint64_t imissed; /**< Total no.of RX packets that are dropped by the HW. */
- uint64_t ierrors; /**< Total no.of packets that are received as erroneous. */
- uint64_t oerrors; /**< Total no.of failed transmitted packets. */
- uint64_t rx_nombuf; /**< Total no.of RX mbuf allocation failures. */
-
- uint64_t q_ipackets[HAL_ETH_QUEUE_STAT_CNTRS]; /**< Total no.of queue RX packets. */
- uint64_t q_opackets[HAL_ETH_QUEUE_STAT_CNTRS]; /**< Total no.of queue TX packets. */
- uint64_t q_ibytes[HAL_ETH_QUEUE_STAT_CNTRS]; /**< Total no.of successfully received queue bytes. */
- uint64_t q_obytes[HAL_ETH_QUEUE_STAT_CNTRS]; /**< Total no.of successfully transmitted queue bytes. */
- uint64_t q_errors[HAL_ETH_QUEUE_STAT_CNTRS]; /**< Total no.of queue packets received that are dropped. */
-} hal_netif_stats_t;
-
-/**
- * Ethernet device config
- */
-typedef struct hal_netif_config
-{
- struct
- {
- uint32_t hw_vlan_filter:1;
- uint32_t hw_vlan_strip:1;
- uint32_t rsv30:30;
- } bit;
-
- struct
- {
- uint32_t queue_num;
- uint32_t ring_size[HAL_ETH_MAX_QUEUE_NUM];
- hal_mempool_t *ring_pool[HAL_ETH_MAX_QUEUE_NUM];
- } rx;
-
- struct
- {
- uint32_t queue_num;
- uint32_t ring_size[HAL_ETH_MAX_QUEUE_NUM];
- } tx;
-
-} hal_netif_config_t;
-
-int hal_init_global (int argc, char **argv);
-int hal_init_local ();
-hal_hdl_t hal_create (const char *name, const char *nic_type,
- hal_netif_config_t * conf);
-hal_hdl_t hal_bond (const char *bond_name, uint8_t slave_num,
- hal_hdl_t slave_hdl[]);
-
-#define hal_is_valid(hdl) ((hdl.id >= 0) && (hdl.id < HAL_MAX_NIC_NUM))
-
-#define hal_is_equal(hdl_left, hdl_right) (hdl_left.id == hdl_right.id)
-
-int hal_close (hal_hdl_t hdl);
-int hal_stop (hal_hdl_t hdl);
-uint32_t hal_get_mtu (hal_hdl_t hdl);
-void hal_get_macaddr (hal_hdl_t hdl, void *mac_addr);
-void hal_get_capability (hal_hdl_t hdl, hal_netif_capa_t * info);
-uint16_t hal_recv_packet (hal_hdl_t hdl, uint16_t queue_id,
- hal_mbuf_t ** rx_pkts, uint16_t nb_pkts);
-uint16_t hal_send_packet (hal_hdl_t hdl, uint16_t queue_id,
- hal_mbuf_t ** tx_pkts, uint16_t nb_pkts);
-uint32_t hal_link_status (hal_hdl_t hdl);
-int hal_stats (hal_hdl_t hdl, hal_netif_stats_t * stats);
-void hal_stats_reset (hal_hdl_t hdl);
-int hal_add_mcastaddr (hal_hdl_t hdl, void *mc_addr_set,
- void *mc_addr, uint32_t nb_mc_addr);
-int hal_del_mcastaddr (hal_hdl_t hdl, void *mc_addr_set,
- void *mc_addr, uint32_t nb_mc_addr);
-void hal_set_allmulti_mode (hal_hdl_t hdl, uint8_t enable);
-uint32_t hal_is_nic_exist (const char *name);
-hal_hdl_t hal_get_invalid_hdl ();
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif
diff --git a/src/framework/include/nsfw_alarm_api.h b/src/framework/include/nsfw_alarm_api.h
new file mode 100644
index 0000000..54cbde2
--- /dev/null
+++ b/src/framework/include/nsfw_alarm_api.h
@@ -0,0 +1,61 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#ifndef _NSFW_ALARM_API_H_
+#define _NSFW_ALARM_API_H_
+
+//#include <sys/types.h>
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
+#define ALARM_RESEND_TIMER_LENGTH 10
+
+#define ALARM_ID_BASE_VALUE 27000
+
+/* alarm ID for every event, when need add new alarm, here add a alarm_id define */
+typedef enum _alarm_id
+{
+ ALARM_EVENT_BASE,
+ ALARM_EVENT_NSTACK_RESOURCE_ALARM,
+ ALARM_EVENT_NSTACK_NO_USE_1,
+ ALARM_EVENT_NSTACK_MAIN_ABNORMAL_RESTART_FAIL, /* daemon-stack exit, nStackMaster can't successfully restart */
+ ALARM_EVENT_NSTACK_NO_USE_2,
+ ALARM_EVENT_NSTACK_MAIN_EXIT_CAUSE_FD_FAIL, /* daemon-stack exit cause fd report err event */
+ ALARM_EVENT_NSTACK_HOTFIX_ALM_ID = 1006, /* used for hotfix activate */
+ ALARM_EVENT_MAX
+} enum_alarm_id;
+
+typedef enum _alarm_flag
+{
+ ALARM_PRODUCT,
+ ALARM_CLEAN,
+ ALARM_HOTFIX,
+ ALARM_MAX
+} alarm_flag;
+
+#define ALARM_ID_NOT_VALID(alarmId) (((alarmId) <= ALARM_EVENT_BASE) || ((alarmId) >= ALARM_EVENT_MAX))
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif
+
+#endif
diff --git a/src/framework/include/nsfw_base_linux_api.h b/src/framework/include/nsfw_base_linux_api.h
new file mode 100644
index 0000000..bfa98b8
--- /dev/null
+++ b/src/framework/include/nsfw_base_linux_api.h
@@ -0,0 +1,61 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#ifndef _NSFW_BASE_LINUX_API_H_
+#define _NSFW_BASE_LINUX_API_H_
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/epoll.h>
+#include <unistd.h>
+#include <netdb.h>
+
+int nsfw_base_socket(int, int, int);
+int nsfw_base_bind(int, const struct sockaddr *, socklen_t);
+int nsfw_base_listen(int, int);
+int nsfw_base_shutdown(int, int);
+int nsfw_base_getsockname(int, struct sockaddr *, socklen_t *);
+int nsfw_base_getpeername(int, struct sockaddr *, socklen_t *);
+int nsfw_base_getaddrinfo(const char *, const char *,
+ const struct addrinfo *, struct addrinfo **);
+int nsfw_base_getsockopt(int, int, int, void *, socklen_t *);
+int nsfw_base_setsockopt(int, int, int, const void *, socklen_t);
+int nsfw_base_accept(int, struct sockaddr *, socklen_t *);
+int nsfw_base_accept4(int, struct sockaddr *, socklen_t *, int flags);
+int nsfw_base_connect(int, const struct sockaddr *, socklen_t);
+ssize_t nsfw_base_recv(int, void *, size_t, int);
+ssize_t nsfw_base_send(int, const void *, size_t, int);
+ssize_t nsfw_base_read(int, void *, size_t);
+ssize_t nsfw_base_write(int, const void *, size_t);
+ssize_t nsfw_base_writev(int, const struct iovec *, int);
+ssize_t nsfw_base_readv(int, const struct iovec *, int);
+ssize_t nsfw_base_sendto(int, const void *, size_t, int,
+ const struct sockaddr *, socklen_t);
+ssize_t nsfw_base_recvfrom(int, void *, size_t, int, struct sockaddr *,
+ socklen_t *);
+ssize_t nsfw_base_sendmsg(int, const struct msghdr *, int flags);
+ssize_t nsfw_base_recvmsg(int, struct msghdr *, int flags);
+int nsfw_base_close(int);
+int nsfw_base_select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
+int nsfw_base_ioctl(int, unsigned long, unsigned long);
+int nsfw_base_fcntl(int, int, unsigned long);
+int nsfw_base_epoll_create(int);
+int nsfw_base_epoll_create1(int);
+int nsfw_base_epoll_ctl(int, int, int, struct epoll_event *);
+int nsfw_base_epoll_wait(int, struct epoll_event *, int, int);
+pid_t nsfw_base_fork(void);
+
+#endif
diff --git a/src/framework/common/base/include/common/common_mem_pal_memconfig.h b/src/framework/include/nsfw_branch_prediction.h
index 65b6e04..0bfae52 100644
--- a/src/framework/common/base/include/common/common_mem_pal_memconfig.h
+++ b/src/framework/include/nsfw_branch_prediction.h
@@ -14,13 +14,15 @@
* limitations under the License.
*/
-#ifndef _COMMON_MEM_PAL_MEMCONFIG_H_
-#define _COMMON_MEM_PAL_MEMCONFIG_H_
+#ifndef _NSFW_BRANCH_PREDICTION_H_
+#define _NSFW_BRANCH_PREDICTION_H_
-#ifdef HAL_LIB
-#else
-#include "rte_eal_memconfig.h"
+#ifndef likely
+#define likely(x) __builtin_expect(!!(x), 1)
+#endif
+#ifndef unlikely
+#define unlikely(x) __builtin_expect(!!(x), 0)
#endif
#endif
diff --git a/stacks/lwip_stack/lwip_src/include/stackx/spl_err.h b/src/framework/include/nsfw_common_defs.h
index a0188be..187f8c0 100644
--- a/stacks/lwip_stack/lwip_src/include/stackx/spl_err.h
+++ b/src/framework/include/nsfw_common_defs.h
@@ -14,27 +14,23 @@
* limitations under the License.
*/
-#ifndef __STACKX_ERR_H__
-#define __STACKX_ERR_H__
+#ifndef _NSFW_COMMON_DEFS_H_
+#define _NSFW_COMMON_DEFS_H_
-#include "spl_opt.h"
-#include "lwip/arch.h"
-#include "stackx_err.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
+#ifndef NSTACK_MAX_MODULE_NUM
+#define NSTACK_MAX_MODULE_NUM 8
#endif
-typedef s8_t err_t;
+#ifndef NSTACK_LIB_LOAD_DYN
+#define NSTACK_LIB_LOAD_DYN 0
+#endif
-/* Definitions for error constants. */
+#ifndef NSTACK_LIB_LOAD_STATIC
+#define NSTACK_LIB_LOAD_STATIC 1
+#endif
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
+#ifndef NSTACK_MODULE_NAME_MAX
+#define NSTACK_MODULE_NAME_MAX 64
#endif
-#endif /* __LWIP_ERR_H__ */
+#endif // _NSFW_COMMON_DEFS_H_
diff --git a/src/framework/include/nsfw_dfx_api.h b/src/framework/include/nsfw_dfx_api.h
new file mode 100644
index 0000000..99a5ab7
--- /dev/null
+++ b/src/framework/include/nsfw_dfx_api.h
@@ -0,0 +1,74 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#ifndef __NSTACK_DMM_DFX_API_H__
+#define __NSTACK_DMM_DFX_API_H__
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h> /* See NOTES */
+#include <sys/socket.h>
+#include<netinet/in.h>
+#include <sys/epoll.h>
+#include "types.h"
+
+struct stat_epfd_info
+{
+ u64 epoll_wait_tick;
+ i32 epfd;
+ pid_t hhpid;
+ u8 epoll_fork_flag;
+ u8 reserve_8[3];
+ u32 ep_sleepTime;
+};
+
+typedef struct stat_epitem_info
+{
+ struct epoll_event event;
+ int is_linked;
+} stat_epitem_info_t;
+
+typedef struct __ns_udp_route_info
+{
+ struct sockaddr_in iaddr;
+ int selectmod;
+} ns_udp_route_Inf;
+
+typedef enum nstack_dmm_type_e
+{
+ DMM_STAT_LONGEST_SEND_INTERVAL = 0,
+ DMM_STAT_LONGEST_SEND_COST,
+ DMM_STAT_LONGEST_RECV_INTERVAL,
+ DMM_STAT_LONGEST_RECV_COST,
+ DMM_STAT_ROUTE_INFO,
+ DMM_APP_EPOLL_WAIT_EVENT,
+ DMM_APP_EPOLL_WAIT_FAIL,
+ DMM_APP_EPOLL_WAIT_GET_TICK,
+ DMM_APP_EPOLL_ADD_TICK,
+ DMM_APP_EPOLL_MOD_TICK,
+ DMM_APP_EPOLL_WAIT_CALL_TICK,
+ DMM_APP_EPOLL_DEL_TICK,
+ DMM_APP_SELECT_FAIL,
+ DMM_MAIN_REPORT_EVENT_TICK,
+ DMM_MAIN_REPORT_EP_CNT,
+
+ DMM_DFX_MAX = 64
+} nstack_dmm_type_t;
+
+void nstack_dfx_state_update(u64 fd, int midx, nstack_dmm_type_t type,
+ void *data);
+void nstack_fd_dfx_update_dfx_data(int fd, int protoFd, int midx, int type,
+ void *info);
+#endif
diff --git a/src/framework/include/nsfw_fd_timer_api.h b/src/framework/include/nsfw_fd_timer_api.h
index 0b42fe0..3cef663 100644
--- a/src/framework/include/nsfw_fd_timer_api.h
+++ b/src/framework/include/nsfw_fd_timer_api.h
@@ -19,6 +19,7 @@
#include "list.h"
#include <time.h>
+#include "dmm_spinlock.h"
#ifdef __cplusplus
/* *INDENT-OFF* */
@@ -30,30 +31,32 @@ extern "C"{
typedef struct _nsfw_timer_init_cfg
{
- u32 timer_info_size;
- void *timer_info_pool;
- struct list_head timer_head;
- struct list_head exp_timer_head;
+ u32 timer_info_size;
+ void *timer_info_pool;
+ struct list_head timer_head;
+ struct list_head exp_timer_head;
+ dmm_spinlock_t timer_lock; /* it can start timer after only finish all timer reg, or else it have multi-thread issue */
+ struct itimerspec ts;
} nsfw_timer_init_cfg;
typedef int (*nsfw_timer_proc_fun) (u32 timer_type, void *argv);
typedef struct _nsfw_timer_info
{
- struct list_head node;
- nsfw_timer_proc_fun fun;
- void *argv;
- struct timespec time_left;
- u32 timer_type;
- u8 alloc_flag;
+ struct list_head node;
+ nsfw_timer_proc_fun fun;
+ void *argv;
+ struct timespec time_left;
+ u32 timer_type;
+ u8 alloc_flag;
} nsfw_timer_info;
-extern nsfw_timer_info *nsfw_timer_reg_timer (u32 timer_type, void *data,
- nsfw_timer_proc_fun fun,
- struct timespec time_left);
-extern void nsfw_timer_rmv_timer (nsfw_timer_info * tm_info);
+extern nsfw_timer_info *nsfw_timer_reg_timer(u32 timer_type, void *data,
+ nsfw_timer_proc_fun fun,
+ struct timespec time_left);
+extern void nsfw_timer_rmv_timer(nsfw_timer_info * tm_info);
extern u8 g_hbt_switch;
-extern int nsfw_timer_module_init (void *param);
+extern int nsfw_timer_module_init(void *param);
#ifdef __cplusplus
/* *INDENT-OFF* */
diff --git a/src/framework/include/nsfw_hal_api.h b/src/framework/include/nsfw_hal_api.h
new file mode 100644
index 0000000..4669d44
--- /dev/null
+++ b/src/framework/include/nsfw_hal_api.h
@@ -0,0 +1,275 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#ifndef _HAL_API_H_
+#define _HAL_API_H_
+
+#include "nsfw_branch_prediction.h"
+#include "nsfw_maintain_api.h"
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
+#define HAL_IO_REGISTER(name, ops) \
+ static __attribute__((__constructor__)) void __hal_register_##name(void) \
+ {\
+ hal_io_adpt_register(ops); \
+ } \
+
+#define HAL_ETH_MAX_QUEUE_NUM MAX_THREAD_NUM
+
+#define HAL_ETH_QUEUE_STAT_CNTRS 16
+
+#define HAL_MAX_NIC_NUM 4096
+COMPAT_PROTECT_RETURN(HAL_MAX_NIC_NUM, 4096);
+
+#define HAL_MAX_SLAVES_PER_BOND 2
+
+#define HAL_MAX_NIC_NAME_LEN 256
+
+#define HAL_MAX_PCI_ADDR_LEN 16
+
+#define HAL_SCRIPT_LENGTH 256
+
+#define HAL_MAX_DRIVER_NAME_LEN 128
+
+#define HAL_MAX_PATH_LEN 4096 //max path length on linux is 4096
+
+/**
+ * TX offload capabilities of a device.
+ */
+#define HAL_ETH_TX_OFFLOAD_IPV4_CKSUM 0x00000002
+#define HAL_ETH_TX_OFFLOAD_UDP_CKSUM 0x00000004
+#define HAL_ETH_TX_OFFLOAD_TCP_CKSUM 0x00000008
+
+/**
+ * Hal Instance Handler
+ */
+typedef struct hal_hdl
+{
+ int id;
+} hal_hdl_t;
+
+/**
+ * Ethernet device capability
+ */
+struct hal_netif_hw_feature
+{
+ uint8_t rx_csum_ip;
+ uint8_t rx_csum_l4;
+ uint8_t rx_lro;
+ uint8_t tx_csum_ip;
+ uint8_t tx_csum_udp;
+ uint8_t tx_csum_tcp;
+ uint8_t tx_tso;
+};
+
+struct lwip_pci_zone
+{
+ char pci_addr[HAL_MAX_PCI_ADDR_LEN];
+ char nic_name[HAL_MAX_NIC_NAME_LEN];
+};
+
+typedef struct hal_netif_stats
+{
+ uint64_t ipackets; /**< Number of successfully received packets. */
+ uint64_t opackets; /**< Number of successfully transmitted packets.*/
+ uint64_t ibytes; /**< Number of successfully received bytes. */
+ uint64_t obytes; /**< Number of successfully transmitted bytes. */
+ uint64_t imissed; /**< Total of RX packets dropped by the HW. */
+ uint64_t ierrors; /**< Number of erroneous received packets. */
+ uint64_t oerrors; /**< Number of failed transmitted packets. */
+ uint64_t rx_nombuf; /**< Number of RX mbuf allocation failures. */
+
+ uint64_t q_ipackets[HAL_ETH_QUEUE_STAT_CNTRS]; /**< Total number of queue RX packets. */
+ uint64_t q_opackets[HAL_ETH_QUEUE_STAT_CNTRS]; /**< Total number of queue TX packets. */
+ uint64_t q_ibytes[HAL_ETH_QUEUE_STAT_CNTRS]; /**< Total number of successfully received queue bytes. */
+ uint64_t q_obytes[HAL_ETH_QUEUE_STAT_CNTRS]; /**< Total number of successfully transmitted queue bytes. */
+ uint64_t q_errors[HAL_ETH_QUEUE_STAT_CNTRS]; /**< Total number of queue packets received that are dropped. */
+} hal_netif_stats_t;
+
+struct hal_netif_hw_config
+{
+ uint32_t rx_csum_ip_flag:1,
+ rx_csum_l4_flag:1,
+ rx_lro_flag:1, tx_csum_ip_flag:1, tx_csum_l4_flag:1, tx_tso_flag:1;
+};
+extern struct hal_netif_hw_config spl_hal_port_hw_config[HAL_MAX_NIC_NUM];
+/**
+ * Ethernet device config
+ */
+typedef struct hal_netif_config
+{
+ struct hal_netif_hw_config hw_config;
+ struct
+ {
+ uint32_t hw_vlan_filter:1;
+ uint32_t hw_vlan_strip:1;
+ uint32_t rsv30:30;
+ } bit;
+
+ struct
+ {
+ uint32_t queue_num;
+ uint32_t ring_size[HAL_ETH_MAX_QUEUE_NUM];
+ void *ring_pool[HAL_ETH_MAX_QUEUE_NUM];
+ } rx;
+
+ struct
+ {
+ uint32_t queue_num;
+ uint32_t ring_size[HAL_ETH_MAX_QUEUE_NUM];
+ } tx;
+
+ uint8_t is_slave;
+} hal_netif_config_t;
+
+/* IO using DPDK interface */
+typedef struct dpdk_if
+{
+ uint8_t port_id; /**< DPDK port identifier */
+ uint8_t is_slave;
+ uint8_t slave_num;
+ uint8_t slave_port[HAL_MAX_SLAVES_PER_BOND];
+
+ uint32_t hw_vlan_filter:1;
+ uint32_t hw_vlan_strip:1;
+ uint32_t rsv30:30;
+
+ uint32_t rx_queue_num;
+ uint32_t rx_ring_size[HAL_ETH_MAX_QUEUE_NUM];
+ void *rx_pool[HAL_ETH_MAX_QUEUE_NUM];
+
+ uint32_t tx_queue_num;
+ uint32_t tx_ring_size[HAL_ETH_MAX_QUEUE_NUM];
+
+ char pci_addr[HAL_MAX_PCI_ADDR_LEN];
+ char nic_name[HAL_MAX_NIC_NAME_LEN];
+ char nic_type[HAL_MAX_NIC_NAME_LEN];
+ char driver_name[HAL_MAX_DRIVER_NAME_LEN];
+} dpdk_if_t;
+
+typedef struct netif_inst
+{
+ enum
+ {
+ NETIF_STATE_FREE = 0,
+ NETIF_STATE_ACTIVE
+ } state;
+
+ hal_hdl_t hdl;
+ struct hal_netif_hw_config hw_config;
+ const struct netif_ops *ops; /**< Implementation specific methods */
+
+ union
+ {
+ dpdk_if_t dpdk_if; /**< using DPDK for IO */
+ } data;
+
+} netif_inst_t;
+
+typedef struct netif_ops
+{
+ const char *name;
+ int (*init_global) (int argc, char **argv);
+ int (*init_local) (void);
+ int (*open) (netif_inst_t * inst, const char *name, const char *type);
+ int (*close) (netif_inst_t * inst);
+ int (*start) (netif_inst_t * inst);
+ int (*stop) (netif_inst_t * inst);
+ int (*bond) (netif_inst_t * inst, const char *bond_name,
+ uint8_t slave_num, netif_inst_t * slave[]);
+ uint32_t(*mtu) (netif_inst_t * inst);
+ int (*macaddr) (netif_inst_t * inst, void *mac_addr);
+ int (*capability) (netif_inst_t * inst,
+ struct hal_netif_hw_feature * info);
+ uint16_t(*recv) (netif_inst_t * inst, uint16_t queue_id,
+ void **rx_pkts, uint16_t nb_pkts);
+ uint16_t(*send) (netif_inst_t * inst, uint16_t queue_id,
+ void **tx_pkts, uint16_t nb_pkts);
+ uint32_t(*link_status) (netif_inst_t * inst);
+ int (*stats) (netif_inst_t * inst, hal_netif_stats_t * stats);
+ int (*stats_reset) (netif_inst_t * inst);
+ int (*config) (netif_inst_t * inst, hal_netif_config_t * conf);
+ int (*mcastaddr) (netif_inst_t * inst, void *mc_addr_set,
+ void *mc_addr, uint32_t nb_mc_addr);
+ int (*add_mac) (netif_inst_t * inst, void *mc_addr);
+ int (*rmv_mac) (netif_inst_t * inst, void *mc_addr);
+ int (*allmcast) (netif_inst_t * inst, uint8_t enable);
+ int (*port_switch) (netif_inst_t * inst);
+ int (*get_bond_primary) (netif_inst_t * inst);
+ int (*check_rss) (netif_inst_t * inst, uint32_t saddr, uint32_t daddr,
+ uint16_t sport, uint16_t dport,
+ uint16_t * thread_index);
+ int (*check_rss6) (netif_inst_t * inst, uint32_t saddr[4],
+ uint32_t daddr[4], uint16_t sport, uint16_t dport,
+ uint16_t * thread_index);
+} netif_ops_t;
+
+int hal_init_global(int argc, char **argv);
+int hal_init_local();
+hal_hdl_t hal_create(const char *name, const char *nic_type,
+ hal_netif_config_t * conf);
+hal_hdl_t hal_bond(const char *bond_name, uint8_t slave_num,
+ hal_hdl_t slave_hdl[]);
+
+#define hal_is_valid(hdl) ((hdl.id >= 0) && (hdl.id < HAL_MAX_NIC_NUM))
+
+#define hal_is_equal(hdl_left, hdl_right) (hdl_left.id == hdl_right.id)
+
+int hal_close(hal_hdl_t hdl);
+int hal_stop(hal_hdl_t hdl);
+uint32_t hal_get_mtu(hal_hdl_t hdl);
+void hal_get_macaddr(hal_hdl_t hdl, void *mac_addr);
+void hal_get_capability(hal_hdl_t hdl, struct hal_netif_hw_feature *info);
+uint16_t hal_recv_packet(hal_hdl_t hdl, uint16_t queue_id, void **rx_pkts,
+ uint16_t nb_pkts);
+uint16_t hal_send_packet(hal_hdl_t hdl, uint16_t queue_id, void **tx_pkts,
+ uint16_t nb_pkts);
+uint32_t hal_link_status(hal_hdl_t hdl);
+int hal_stats(hal_hdl_t hdl, hal_netif_stats_t * stats);
+void hal_stats_reset(hal_hdl_t hdl);
+int hal_add_mcastaddr(hal_hdl_t hdl, void *mc_addr_set,
+ void *mc_addr, uint32_t nb_mc_addr);
+int hal_del_mcastaddr(hal_hdl_t hdl, void *mc_addr_set,
+ void *mc_addr, uint32_t nb_mc_addr);
+void hal_set_allmulti_mode(hal_hdl_t hdl, uint8_t enable);
+uint32_t hal_is_nic_exist(const char *name);
+hal_hdl_t hal_get_invalid_hdl();
+int hal_bond_switch(const char *bond_name);
+int hal_get_bond_primary(const char *bond_name);
+int hal_snprintf(char *buffer, size_t buflen, const char *format, ...);
+int hal_run_script(const char *cmd, char *result_buf, size_t max_result_len);
+int hal_is_script_valid(const char *cmd);
+void hal_io_adpt_register(const netif_ops_t * ops);
+
+int hal_check_rss(hal_hdl_t hdl, uint32_t saddr, uint32_t daddr,
+ uint16_t sport, uint16_t dport, uint16_t * thread_index);
+int hal_check_rss6(hal_hdl_t hdl, uint32_t saddr[4], uint32_t daddr[4],
+ uint16_t sport, uint16_t dport, uint16_t * thread_index);
+
+struct hal_netif_hw_config *hal_get_netif_hw_config(hal_hdl_t hdl);
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif
+
+#endif
diff --git a/src/framework/include/nsfw_init.h b/src/framework/include/nsfw_init_api.h
index 0237060..924865b 100644
--- a/src/framework/include/nsfw_init.h
+++ b/src/framework/include/nsfw_init_api.h
@@ -16,6 +16,7 @@
#ifndef _FW_INIT_H
#define _FW_INIT_H
+#include <pthread.h>
#ifdef __cplusplus
/* *INDENT-OFF* */
@@ -30,20 +31,79 @@ extern "C"{
#define NSFW_INIT_MODULE_PRIORITY_BASE 1
#define NSFW_INIT_MODULE_PRIORITY(x) (NSFW_INIT_MODULE_PRIORITY_BASE + x)
+#define NSFW_MAX_STRING_LENGTH 128
+
+typedef int (*nsfw_module_init_fn) (void *);
+
+typedef struct _nsfw_module_depends
+{
+ char name[NSFW_MAX_STRING_LENGTH];
+ int isReady;
+ struct _nsfw_module_depends *next; /* It is a list, not just only one */
+} nsfw_module_depends_t;
+
+extern nsfw_module_depends_t *nsfw_module_create_depends(char *name);
+
+typedef enum
+{
+ NSFW_INST_STAT_CHECKING, /* Not check yet */
+ NSFW_INST_STAT_DEPENDING, /* Blocked, waiting for other module instances */
+ NSFW_INST_STAT_DONE, /* Check done */
+ NSFW_INST_STAT_FAIL /* Check Fail */
+} nsfw_module_instance_stat_t;
+
+typedef struct _nsfw_module_instance
+{
+ nsfw_module_init_fn fnInit;
+ char name[NSFW_MAX_STRING_LENGTH];
+ char fatherName[NSFW_MAX_STRING_LENGTH];
+ int priority;
+ nsfw_module_depends_t *depends;
+ nsfw_module_instance_stat_t stat;
+ void *param;
+ struct _nsfw_module_instance *next;
+ struct _nsfw_module_instance *child;
+ struct _nsfw_module_instance *father;
+} nsfw_module_instance_t;
+
+static nsfw_module_instance_t *nsfwLocalInitInst __attribute__ ((unused)) =
+ NULL;
+
+extern nsfw_module_instance_t *nsfw_module_create_instance();
+extern nsfw_module_instance_t *nsfw_module_get_module_by_name(char *);
+extern void nsfw_module_add_instance(nsfw_module_instance_t * inst);
+extern void nsfw_module_del_instance(nsfw_module_instance_t * inst);
+extern void nsfw_module_set_instance_name(nsfw_module_instance_t * inst,
+ char *name);
+extern void nsfw_module_set_instance_father(nsfw_module_instance_t * inst,
+ char *father);
+extern void nsfw_module_set_instance_priority(nsfw_module_instance_t * inst,
+ int priority);
+extern void nsfw_module_set_instance_initfn(nsfw_module_instance_t * inst,
+ nsfw_module_init_fn fn);
+extern void nsfw_module_set_instance_depends(nsfw_module_instance_t * inst,
+ char *name);
+
#define NSFW_SET_INSTANCE_VALUE(_attr, _inst, _value) \
nsfw_module_set_instance_##_attr(_inst, _value)
-#define NSFW_INIT_CREATE_LOCAL_INSTANCE() \
+#define NSFW_INIT_CRAETE_LOCAL_INSTANCE() \
if (!nsfwLocalInitInst) {\
nsfwLocalInitInst = nsfw_module_create_instance(); \
- nsfw_module_add_instance(nsfwLocalInitInst);\
+ if (nsfwLocalInitInst) \
+ { \
+ nsfw_module_add_instance(nsfwLocalInitInst);\
+ } \
}
#define _NSFW_MODULE_ATTRIBUTE_DEFINE_SURFIX(_attr, _value, _priority, _surfix) \
+ \
+ \
static __attribute__((__constructor__(_priority))) void nsfw_module_attribute_##_attr##_surfix(void){\
- NSFW_INIT_CREATE_LOCAL_INSTANCE(); \
+ NSFW_INIT_CRAETE_LOCAL_INSTANCE(); \
NSFW_SET_INSTANCE_VALUE(_attr, nsfwLocalInitInst, _value);\
} \
+ \
#define NSFW_MODULE_ATTRIBUTE_DEFINE_SURFIX(_attr, _value, _priority, _surfix) \
_NSFW_MODULE_ATTRIBUTE_DEFINE_SURFIX(_attr, _value, _priority, _surfix)
@@ -69,75 +129,26 @@ extern "C"{
#define NSFW_MODULE_INIT(_initfn) \
NSFW_MODULE_ATTRIBUTE_DEFINE(initfn, _initfn, NSFW_INIT_PRIORITY_INITFN)
-#define NSFW_MAX_STRING_LENGTH 128
-
-#define NSFW_DEPENDS_SIZE 8
-typedef struct _nsfw_module_depends
-{
- char name[NSFW_MAX_STRING_LENGTH];
- int isReady;
- struct _nsfw_module_depends *next; /* It is a list, not just only one */
-} nsfw_module_depends_t;
-
-typedef enum
-{
- NSFW_INST_STAT_CHECKING, /* Not check yet */
- NSFW_INST_STAT_DEPENDING, /* Blocked, waiting for other module instances */
- NSFW_INST_STAT_DONE, /* Check done */
- NSFW_INST_STAT_FAIL /* Check Fail */
-} nsfw_module_instance_stat_t;
-
-typedef int (*nsfw_module_init_fn) (void *);
-
-typedef struct _nsfw_module_instance
-{
- nsfw_module_init_fn fnInit;
- char name[NSFW_MAX_STRING_LENGTH];
- char fatherName[NSFW_MAX_STRING_LENGTH];
- int priority;
- nsfw_module_depends_t *depends;
- nsfw_module_instance_stat_t stat;
- void *param;
- struct _nsfw_module_instance *next;
- struct _nsfw_module_instance *child;
- struct _nsfw_module_instance *father;
-} nsfw_module_instance_t;
-
-static nsfw_module_instance_t *nsfwLocalInitInst __attribute__ ((unused)) =
- (void *) 0;
-
-extern nsfw_module_instance_t *nsfw_module_create_instance ();
-extern nsfw_module_instance_t *nsfw_module_getModuleByName (char *);
-extern void nsfw_module_add_instance (nsfw_module_instance_t * inst);
-extern void nsfw_module_del_instance (nsfw_module_instance_t * inst);
-extern void nsfw_module_set_instance_name (nsfw_module_instance_t * inst,
- char *name);
-extern void nsfw_module_set_instance_father (nsfw_module_instance_t * inst,
- char *father);
-extern void nsfw_module_set_instance_priority (nsfw_module_instance_t *
- inst, int priority);
-extern void nsfw_module_set_instance_initfn (nsfw_module_instance_t * inst,
- nsfw_module_init_fn fn);
-extern void nsfw_module_set_instance_depends (nsfw_module_instance_t * inst,
- char *name);
-
/**
* @Function nstack_framework_init
- * @Description This function will do framework initial work, it will invoke all initial functions
- * registered using macro NSFW_MODULE_INIT before
+ * @Description This function will do framework initial work, it will involk all initial functions
+ * registed using macro NSFW_MODULE_INIT before
* @param none
* @return 0 on success, -1 on error
*/
-extern int nstack_framework_init (void);
+extern int nstack_framework_init(void);
/**
- * @Function nstack_framework_setModuleParam
+ * @Function nstack_framework_set_module_param
* @Description This function set parameter of module initial function parameter
* @param module - name of module
* @param param - parameter to set
* @return 0 on success, -1 on error
*/
-extern int nstack_framework_setModuleParam (char *module, void *param);
+extern int nstack_framework_set_module_param(char *module, void *param);
+
+extern int get_fw_init_err();
+extern void set_fw_init_err(int);
#ifdef __cplusplus
/* *INDENT-OFF* */
diff --git a/src/framework/include/nsfw_maintain_api.h b/src/framework/include/nsfw_maintain_api.h
index bf0d45e..a05719f 100644
--- a/src/framework/include/nsfw_maintain_api.h
+++ b/src/framework/include/nsfw_maintain_api.h
@@ -20,6 +20,7 @@
#include "types.h"
#include "nsfw_mgr_com_api.h"
#include "compiling_check.h"
+#include <time.h>
#ifdef __cplusplus
/* *INDENT-OFF* */
@@ -36,83 +37,156 @@ extern "C"{
#define MEM_STAT(module, mem_name, mem_type, mem_size)\
nsfw_mem_stat(module, mem_name, mem_type, mem_size)
-extern void nsfw_mem_stat (char *module, char *mem_name, u8 mem_type,
- u32 mem_size);
-extern void nsfw_mem_stat_print ();
+extern void nsfw_mem_stat(char *module, char *mem_name, u8 mem_type,
+ u64 mem_size);
+extern void nsfw_mem_stat_print();
/*##############################################*/
/*################SRV_CTRL######################*/
typedef enum _nsfw_srv_ctrl_state
{
- NSFW_SRV_CTRL_RESUME = 1,
- NSFW_SRV_CTRL_SUSPEND = 2
+ NSFW_SRV_CTRL_RESUME = 1,
+ NSFW_SRV_CTRL_SUSPEND = 2
} nsfw_srv_ctrl_state;
typedef struct _nsfw_srv_ctrl_msg
{
- nsfw_srv_ctrl_state srv_state;
- u16 rsp_code;
+ nsfw_srv_ctrl_state srv_state;
+ u16 rsp_code;
} nsfw_srv_ctrl_msg;
-extern u8 nsfw_srv_ctrl_send (nsfw_srv_ctrl_state state, u8 rsp_flag);
+extern u8 nsfw_srv_ctrl_send(nsfw_srv_ctrl_state state, u8 rsp_flag);
/*#############################################*/
/*#################RES_MGR######################*/
-#define NSFW_RES_MGR_MODULE "nsfw_res_mgr"
+#define SPL_RES_MGR_MODULE "spl_res_mgr"
typedef enum _nsfw_res_scan_type
{
- NSFW_RES_SCAN_ARRAY = 0,
- NSFW_RES_SCAN_SPOOL,
- NSFW_RES_SCAN_MBUF,
- NSFW_RES_SCAN_MAX
+ NSFW_RES_SCAN_ARRAY = 0,
+ NSFW_RES_SCAN_SPOOL,
+ NSFW_RES_SCAN_MBUF,
+ NSFW_RES_SCAN_MAX
} nsfw_res_scan_type;
typedef int (*nsfw_res_free_fun) (void *pdata);
typedef struct _nsfw_res_scn_cfg
{
- u8 type; /*nsfw_res_scan_type */
- u8 force_free_percent; /*if the resource free percent below this value, begin to force free the element */
- u16 force_free_chk_num; /*if the check count beyone this value, call free fun release this element */
- u16 alloc_speed_factor; /*alloc fast with higher value */
+ u8 type; /*nsfw_res_scan_type */
+ u8 force_free_percent; /*if the resource free percent below this vlaue, begin to force free the element */
+ u16 force_free_chk_num; /*if the check count beyone this vlaue, call free fun release this element */
+ u16 alloc_speed_factor; /*alloc fast with higher value */
- u32 num_per_cyc; /*define the element number in one scan cycle process and increase chk_count of every element */
- u32 total_num; /*total number of elements */
- u32 elm_size; /*element size */
- u32 res_mem_offset; /*the nsfw_res offset from the element start */
+ u32 num_per_cyc; /*define the element number in one scan cycle process and increase chk_count of every element */
+ u32 total_num; /*total number of elements */
+ u32 elm_size; /*element size */
+ u32 res_mem_offset; /*the nsfw_res offset from the element start */
- void *data; /*the array addr or spool addr */
- void *mgr_ring;
+ void *data; /*the array addr or spool addr */
+ void *mgr_ring;
- nsfw_res_free_fun free_fun;
+ nsfw_res_free_fun free_fun;
} nsfw_res_scn_cfg;
typedef struct _nsfw_res_mgr_item_cfg
{
- nsfw_res_scn_cfg scn_cfg;
- u32 cons_head;
- u32 prod_head;
- u32 free_percent;
- u32 last_scn_idx;
- u64 force_count;
+ nsfw_res_scn_cfg scn_cfg;
+ u32 cons_head;
+ u32 prod_head;
+ u32 free_percent;
+ u32 last_scn_idx;
+ u64 force_count;
} nsfw_res_mgr_item_cfg;
#define NSFW_MAX_RES_SCAN_COUNT 256
-extern u8 nsfw_res_mgr_reg (nsfw_res_scn_cfg * cfg);
-extern i32 nsfw_proc_start_with_lock (u8 proc_type);
+extern u8 nsfw_res_mgr_reg(nsfw_res_scn_cfg * cfg);
+extern i32 nsfw_proc_start_with_lock(u8 proc_type);
+extern i32 nstack_record_pid_check_memory(u8 proc_type);
+
/*#############################################*/
+/*#################VER_MGR######################*/
+#define NSFW_VER_MGR_MODULE "nsfw_ver_mgr"
+
+typedef enum _nsfw_ver_mgr_state
+{
+ NSFW_VER_NULL = 0,
+ NSFW_VER_UPG = 1,
+ NSFW_VER_RBK = 2,
+ NSFW_VER_QRY = 3,
+ NSFW_VER_READY_TO_RESTART = 4
+} nsfw_ver_mgr_state;
+
+typedef enum _nsfw_ver_mgr_err
+{
+ NSFW_OK = 0,
+ NSFW_STATE_IN_UPG = 100,
+ NSFW_INTER_FALIED = 120,
+ NSFW_POOL_NULL = 121,
+
+} nsfw_ver_mgr_err;
+
+#define NSTACK_MAX_VERSION_LEN 40
+#define NSTACK_MAX_MODULE_LEN 20
+#define NSTACK_MAX_BUILDTIME_LEN 32
+
+typedef struct _nsfw_ver_mgr_msg
+{
+ nsfw_ver_mgr_state ver_state;
+ u16 rsp_code;
+ char src_ver[NSTACK_MAX_VERSION_LEN];
+ char dst_ver[NSTACK_MAX_VERSION_LEN];
+ char module_name[NSTACK_MAX_MODULE_LEN];
+ char build_time[NSTACK_MAX_BUILDTIME_LEN];
+} nsfw_ver_mgr_msg;
+extern u8 nsfw_ver_mgr_rsq(u16 rsp_code, u32 src_pid);
+
+typedef struct _nsfw_ver_info
+{
+ char version[NSTACK_MAX_VERSION_LEN];
+ char module_name[NSTACK_MAX_MODULE_LEN];
+ char build_time[NSTACK_MAX_BUILDTIME_LEN];
+} nsfw_ver_info;
+
+typedef enum _nsfw_run_type
+{
+ NSFW_RUN_NULL = 0,
+ NSFW_RUN_FIRST = 1,
+ NSFW_RUN_NORMAL_RESTART,
+ NSFW_RUN_RESTART,
+ NSFW_RUN_STOP,
+ NSFW_RUN_FREQUENTLY
+} nsfw_run_type;
+
+typedef enum _nsfw_init_state
+{
+ NSFW_INIT_SUCESS = 1,
+ NSFW_INIT_MEMADDR_ERR = 2
+} nsfw_init_state;
+
+typedef struct _nsfw_init_nty_msg
+{
+ nsfw_init_state init_state;
+ u16 rsp_code;
+} nsfw_init_nty_msg;
+
+u8 nsfw_init_result_send(u8 local_proc, nsfw_init_state state, u8 rsp_flag);
+
+extern int g_cur_upg_state;
+extern int g_start_type;
+
typedef enum _nsfw_exit_code
{
- NSFW_EXIT_SUCCESS = 0,
- NSFW_EXIT_FAILED = 1,
- NSFW_EXIT_DST_ERROR = 2,
- NSFW_EXIT_TIME_OUT = 3,
+ NSFW_EXIT_SUCCESS = 0,
+ NSFW_EXIT_FAILED = 1,
+ NSFW_EXIT_DST_ERROR = 2,
+ NSFW_EXIT_TIME_OUT = 3,
- NSFW_EXIT_MAX_COM_ERR = 31,
+ NSFW_EXIT_MAX_COM_ERR = 31,
} nsfw_exit_code;
+extern int nsfw_vermgr_module_init(void *param);
/*#############################################*/
/*#################SOFT_PARAM##################*/
@@ -120,37 +194,69 @@ typedef enum _nsfw_exit_code
typedef struct _nsfw_soft_param_msg
{
- u32 param_name;
- u32 rsp_code;
- u8 param_value[NSFW_MGR_MSG_BODY_LEN - sizeof (u32) - sizeof (u32)];
+ u32 param_name;
+ u32 rsp_code;
+ u8 param_value[NSFW_MGR_MSG_BODY_LEN - sizeof(u32) - sizeof(u32)];
}
nsfw_soft_param_msg;
typedef enum _nsfw_soft_param
{
- NSFW_DBG_MODE_PARAM = 1,
- NSFW_HBT_TIMER = 2,
- NSFW_HBT_COUNT_PARAM = 3,
- NSFW_APP_EXIT_TIMER = 4,
- NSFW_SRV_RESTORE_TIMER = 5,
- NSFW_APP_RESEND_TIMER = 6,
- NSFW_APP_SEND_PER_TIME = 7,
-
- NSFW_MAX_SOFT_PARAM = 1024
+ NSFW_DBG_MODE_PARAM = 1,
+ NSFW_HBT_TIMER = 2,
+ NSFW_HBT_COUNT_PARAM = 3,
+ NSFW_APP_EXIT_TIMER = 4,
+ NSFW_SRV_RESTORE_TIMER = 5,
+ NSFW_APP_RESEND_TIMER = 6,
+ NSFW_APP_SEND_PER_TIME = 7,
+ NSFW_TCP_OOSLE_PARAM = 8,
+
+ NSFW_MAX_SOFT_PARAM = 1024
} nsfw_soft_param;
typedef int (*nsfw_set_soft_fun) (u32 param, char *buf, u32 buf_len);
-extern u8 nsfw_soft_param_reg_fun (u32 param_name, nsfw_set_soft_fun fun);
-extern u8 nsfw_soft_param_reg_int (u32 param_name, u32 size, u32 min,
- u32 max, u64 * data);
+extern u8 nsfw_soft_param_reg_fun(u32 param_name, nsfw_set_soft_fun fun);
+extern u8 nsfw_soft_param_reg_int(u32 param_name, u32 size, u32 min, u32 max,
+ u64 * data);
-extern void nsfw_set_soft_para (fw_poc_type proc_type, u32 para_name,
- void *value, u32 size);
+extern void nsfw_set_soft_para(fw_poc_type proc_type, u32 para_name,
+ void *value, u32 size);
-extern int nsfw_isdigitstr (const char *str);
+extern int nsfw_isdigitstr(const char *str);
#define NSFW_REG_SOFT_INT(_param,_data,_min, _max) nsfw_soft_param_reg_int(_param,sizeof(_data),_min,_max,(u64*)&_data)
/*#############################################*/
+/*################# SPLNET ######################*/
+#define NSFW_FAU_INJ_MODULE "nsfw_splnet"
+
+typedef enum
+{
+ SPLNET_ACTION_NULL = 0,
+ SPLNET_ACTION_SETDROP,
+ SPLNET_ACTION_GETDROP,
+ SPLNET_ACTION_BONDSWITCH,
+ SPLNET_ACTION_GETBONDPRI,
+ SPLNET_ACTION_MAX
+} splnet_action;
+
+#define MAX_NETIF_NAME_LEN 256
+#define MAX_NETIF_NUM 32
+
+typedef struct _nsfw_splnet_msg
+{
+ struct timeval start_time;
+ splnet_action action;
+ char name[MAX_NETIF_NAME_LEN]; //means eth list when fault_inject, or network name when bondswitch
+ int drop_numer;
+ int drop_denom;
+ int exp_time;
+} nsfw_splnet_msg;
+
+extern struct netif_fault_ctl *alloc_netif_fault_ctl_entry();
+extern bool do_drop_packet(struct netif_fault_ctl *fault_ctl);
+
+/*#############################################*/
+
/*#################LOG_CONFIG##################*/
#define NSFW_LOG_CFG_MODULE "nsfw_log_cfg"
@@ -160,9 +266,9 @@ extern int nsfw_isdigitstr (const char *str);
typedef struct _nsfw_set_log_msg
{
- u16 rsp_code;
- char module[NSFW_MODULE_NAME_LEN];
- char log_level[NSFW_LOG_VALUE_LEN];
+ u16 rsp_code;
+ char module[NSFW_MODULE_NAME_LEN];
+ char log_level[NSFW_LOG_VALUE_LEN];
} nsfw_set_log_msg;
/*#############################################*/
@@ -174,38 +280,55 @@ typedef struct _nsfw_set_log_msg
#define SPL_DFX_RES_CONN "conn"
#define SPL_DFX_RES_L2TO4 "l2to4"
#define SPL_DFX_RES_UNMATCH "version"
-#define SPL_DFX_RES_SOCKET_CB "socketcb"
-#define SPL_DFX_RES_COMM_MEMPOOL "mbufpool"
+#define SPL_DFX_RES_SOCKT_CB "socketcb"
+#define SPL_DFX_RES_RTP_MEMPOOL "mbufpool"
#define SPL_DFX_RES_PCBLIST "pcblist"
#define SPL_DFX_RES_ARPLIST "arplist"
typedef enum
{
- DFX_ACTION_SNAPSHOT,
- DFX_ACTION_RST_STATS,
- DFX_ACTION_SWITCH,
- DFX_ACTION_MAX
+ DFX_ACTION_SNAPSHOT,
+ DFX_ACTION_RST_STATS,
+ DFX_ACTION_SWITCH,
+ DFX_ACTION_GET_CONTAINER_STAT,
+ DFX_ACTION_GET_CONTAINER_L4_STAT,
+ DFX_ACTION_MAX
} dfx_module_action;
typedef struct _nsfw_dfx_qry_msg
{
- dfx_module_action action;
- char resource[MAX_DFX_QRY_RES_LEN];
- char flag; //for snapshot print "all"
+ dfx_module_action action;
+ char resource[MAX_DFX_QRY_RES_LEN];
+ char flag; //for snapshot print "all"
} nsfw_dfx_qry_msg;
+typedef struct _nsfw_dfx_qry_container_stat_msg
+{
+ dfx_module_action action;
+ char container_id[256]; //TODO
+} nsfw_dfx_qry_container_stat_msg;
+
typedef enum
{
- QUERY_ACTION_GET,
- QUERY_ACTION_MAX
+ QUERY_ACTION_GET,
+ QUERY_ACTION_MAX
} query_action;
typedef struct _nsfw_qry_msg
{
- query_action action;
- char resource[MAX_DFX_QRY_RES_LEN];
+ query_action action;
+ char resource[MAX_DFX_QRY_RES_LEN];
} nsfw_get_qry_msg;
+typedef enum _qry_errcode
+{
+ QUERY_OK = 0,
+ QUERY_INTERNAL_ERR = 1,
+ QUERY_CONTAINER_STAT_NOT_SURPPORTED = 32,
+ QUERY_NO_SUCH_CONTAINER = 33,
+ QUERY_ERR_MAX = 127
+} qry_errcode;
+
/*##################DFX#########################*/
/*#################for tcpdump#####################*/
@@ -219,10 +342,20 @@ typedef struct _nsfw_qry_msg
#define TCPDUMP_MODULE "tcpdump_tool"
-#define DUMP_MSG_NUM (64 * 1024)
-COMPAT_PROTECT (DUMP_MSG_NUM, 64 * 1024);
+#define MIN_DUMP_MSG_NUM (4 * 1024)
+#define MAX_DUMP_MSG_NUM (64 * 1024)
+
+#define DUMP_NO_LIMIT 0 //must be set to 0 dumping only packets header for release
+
+/* *INDENT-OFF* */
+#if DUMP_NO_LIMIT
+#define DUMP_MSG_SIZE 1515 // can not be less than 14
+COMPAT_PROTECT_RETURN (DUMP_MSG_SIZE, 1515)
+#else
#define DUMP_MSG_SIZE 128 // can not be less than 14
-COMPAT_PROTECT (DUMP_MSG_SIZE, 128);
+COMPAT_PROTECT_RETURN (DUMP_MSG_SIZE, 128)
+#endif
+/* *INDENT-ON* */
#define DEFAULT_DUMP_TIME 600
#define MAX_DUMP_TIME 86400
@@ -233,84 +366,492 @@ COMPAT_PROTECT (DUMP_MSG_SIZE, 128);
#define DUMP_HBT_CHK_INTERVAL 4
#define DUMP_TASK_HBT_TIME_OUT 30
-#define DUMP_SHMEM_RIGN_NAME "tcpdump_ring"
+#define DUMP_SHMEM_RING_NAME "tcpdump_ring"
#define DUMP_SHMEM_POOL_NAME "tcpdump_pool"
+/* for multi-dump */
+#define DUMP_SHMEM_INFO_NAME_MST "tcpdump_infozone_mst"
+#define DUMP_SHMEM_INFO_NAME_SLV "tcpdump_infozone_slv"
+
+#define DUMP_SHMEM_RING_NAME_MST "tcpdump_ring_mst"
+#define DUMP_SHMEM_POOL_NAME_MST "tcpdump_pool_mst"
+
+#define DUMP_SHMEM_RING_NAME_SLV_0 "tcpdump_ring_slv_0"
+#define DUMP_SHMEM_POOL_NAME_SLV_0 "tcpdump_pool_slv_0"
+#define DUMP_SHMEM_RING_NAME_SLV_1 "tcpdump_ring_slv_1"
+#define DUMP_SHMEM_POOL_NAME_SLV_1 "tcpdump_pool_slv_1"
+#define DUMP_SHMEM_RING_NAME_SLV_2 "tcpdump_ring_slv_2"
+#define DUMP_SHMEM_POOL_NAME_SLV_2 "tcpdump_pool_slv_2"
+#define DUMP_SHMEM_RING_NAME_SLV_3 "tcpdump_ring_slv_3"
+#define DUMP_SHMEM_POOL_NAME_SLV_3 "tcpdump_pool_slv_3"
+
enum L2_PROTOCOL
{
- PROTOCOL_IP = 0x0800,
- PROTOCOL_ARP = 0x0806,
- PROTOCOL_RARP = 0x8035,
- PROTOCOL_OAM_LACP = 0x8809,
- INVALID_L2_PROTOCOL = 0xFFFF
+ PROTOCOL_IP = 0x0800,
+ PROTOCOL_ARP = 0x0806,
+ PROTOCOL_RARP = 0x8035,
+ PROTOCOL_IPV6 = 0x86DD,
+ PROTOCOL_OAM_LACP = 0x8809,
+ INVALID_L2_PROTOCOL = 0xFFFF
};
enum L3_PROTOCOL
{
- PROTOCOL_ICMP = 1,
- PROTOCOL_TCP = 6,
- PROTOCOL_UDP = 17,
- INVALID_L3_PROTOCOL = 0xFF
+ PROTOCOL_ICMP = 1,
+ PROTOCOL_TCP = 6,
+ PROTOCOL_UDP = 17,
+ INVALID_L3_PROTOCOL = 0xFF
};
enum DUMP_MSG_DIRECTION
{
- DUMP_SEND = 1,
- DUMP_RECV = 2,
- DUMP_SEND_RECV = 3
+ DUMP_SEND = 1,
+ DUMP_RECV = 2,
+ DUMP_SEND_RECV = 3
};
enum DUMP_MSG_TYPE
{
- START_DUMP_REQ,
- STOP_DUMP_REQ,
- TOOL_COM_HBT_REQ,
+ START_DUMP_REQ,
+ STOP_DUMP_REQ,
+ TOOL_COM_HBT_REQ,
+ START_DUMP_MASTER_REQ,
- DUMP_MSG_TYPE_RSP = 0x00010000,
+ DUMP_MSG_TYPE_RSP = 0x00010000, //65536
- START_DUMP_RSP = START_DUMP_REQ + DUMP_MSG_TYPE_RSP,
- STOP_DUMP_RSP = STOP_DUMP_REQ + DUMP_MSG_TYPE_RSP,
+ START_DUMP_RSP = START_DUMP_REQ + DUMP_MSG_TYPE_RSP,
+ STOP_DUMP_RSP = STOP_DUMP_REQ + DUMP_MSG_TYPE_RSP,
+ TOOL_COM_HBT_RSP = TOOL_COM_HBT_REQ + DUMP_MSG_TYPE_RSP,
+ START_DUMP_MASTER_RSP = START_DUMP_MASTER_REQ + DUMP_MSG_TYPE_RSP,
- DUMP_MSG_TYPE_INVALID
+ DUMP_MSG_TYPE_INVALID
};
typedef struct _nsfw_tool_hbt
{
- u32 seq;
- i16 task_id;
+ u32 seq;
+ i16 task_id;
} nsfw_tool_hbt;
typedef struct _nsfw_tool_dump_msg
{
- u16 op_type;
- i16 task_id;
- u32 task_keep_time;
+ u16 op_type;
+ i16 task_id;
+ u32 task_keep_time;
} nsfw_tool_dump_msg;
typedef struct _dump_msg_info
{
- u32 len;
- u16 direction; // 1:SEND, 2:RECV
- u32 dump_sec;
- u32 dump_usec;
- nsfw_res res_chk;
- char buf[1];
+ u32 org_len;
+ u16 direction; // 1:SEND, 2:RECV
+ u32 dump_sec;
+ u32 dump_usec;
+ u32 len;
+ nsfw_res res_chk;
+ char buf[1];
} dump_msg_info;
typedef struct _dump_timer_info
{
- u32 seq;
- i16 task_id;
- void *interval;
- void *ptimer;
+ u32 seq;
+ i16 task_id;
+ void *interval;
+ void *ptimer;
} dump_timer_info;
-extern void ntcpdump_loop (void *buf, u32 buf_len, u16 direction,
- void *eth_addr);
-extern void ntcpdump (void *buf, u32 buf_len, u16 direction);
+extern void ntcpdump_loop(void *buf, u32 buf_len, u16 direction,
+ void *eth_addr);
+extern void ntcpdump(void *buf, u32 buf_len, u16 direction);
+extern int get_dump_status(char *jbuf, int pid);
/*##############for tcpdump######################*/
+/*################# HOTFIX Begin ##################*/
+#define NSFW_HOTFIX_MODULE "nsfw_hotfix"
+#define ALARM_HOTFIX_NAME "hotfix"
+
+#define MAX_PATCH_PATH_LEN 256
+#define MAX_PATCH_VER_LEN 64
+
+#define HOTFIX_STR_ACTV "activate"
+#define HOTFIX_STR_ROLLBACK "rollback"
+#define HOTFIX_STR_QUERY "query"
+
+#define HOTFIX_STR_SUCCESS "success"
+#define HOTFIX_STR_FAIL "fail"
+
+#define HOTFIX_SUCCESS 0
+#define HOTFIX_FAIL 1
+
+/* hotfix operation type */
+typedef enum
+{
+ HOTFIX_IDLE, //invalid value, not use
+ HOTFIX_ACTV, //activate: load & activate & run a patch
+ HOTFIX_ROLLBACK, //rollback: remove a patch
+ HOTFIX_QUERY, //query: query product version
+ HOTFIX_MAX
+} hotfix_optype;
+
+typedef struct _nsfw_hotfix_msg
+{
+ u16 rsp_code;
+ hotfix_optype optype;
+ char patch_path[MAX_PATCH_PATH_LEN];
+ char patch_version[MAX_PATCH_VER_LEN]; //product's patch version
+} nsfw_hotfix_msg;
+
+typedef struct _hotfix_res
+{
+ fw_poc_type proc_type; //process type
+ hotfix_optype action;
+ int result;
+ char patch_version[MAX_PATCH_VER_LEN]; //product's patch version
+} hotfix_res;
+
+extern int nsfw_hotfix_module_init(void *param);
+/*################# HOTFIX End##################*/
+#define NSFW_CONFIG_MODULE "nsfw_config"
+#define NSTACK_SHARE_CONFIG "nstack_share_config"
+
+#define CFG_PATH "NSTACK_CONFIG_PATH"
+#define CFG_FILE_NAME "nStackConfig.json"
+#define MAX_FILE_NAME_LEN 512
+#define CFG_BUFFER_LEN 2048
+#define MAX_CFG_ITEM 128
+#define CFG_ITEM_LENGTH 64
+
+enum NSTACK_BASE_CFG
+{
+ CFG_BASE_THREAD_NUM = 0,
+ CFG_BASE_SOCKET_NUM,
+ CFG_BASE_RING_SIZE,
+ CFG_BASE_HAL_PORT_NUM,
+ CFG_BASE_ARP_STALE_TIME,
+ CFG_BASE_ARP_BC_RETRANS_NUM,
+ MAX_BASE_CFG
+};
+/* *INDENT-OFF* */
+COMPAT_PROTECT_RETURN (MAX_BASE_CFG, 6)
+/* *INDENT-ON* */
+
+enum NSTACK_CUSTOM_CFG
+{
+ /* mBuf config */
+ CFG_MBUF_DATA_SIZE,
+ CFG_TX_MBUF_NUM,
+ CFG_RX_MBUF_NUM,
+
+ /* memory pool config */
+ CFG_MP_TCPSEG_NUM,
+ CFG_MP_MSG_NUM,
+
+ /* RING config */
+ CFG_HAL_TX_RING_SIZE,
+ CFG_HAL_RX_RING_SIZE,
+ CFG_MBOX_RING_SIZE,
+ CFG_SPL_MAX_ACCEPT_RING_SIZE,
+
+ /* PCB config */
+ CFG_TCP_PCB_NUM,
+ CFG_UDP_PCB_NUM,
+ CFG_RAW_PCB_NUM,
+
+ CFG_ARP_QUEUE_NUM,
+
+ MAX_CUSTOM_CFG
+};
+
+enum EN_CFG_SEG
+{
+ CFG_SEG_BASE = 0,
+ CFG_SEG_LOG,
+ CFG_SEG_PATH,
+ CFG_SEG_PRI,
+ CFG_SEG_FOR_MACRO,
+ CFG_SEG_PARAM,
+ EN_CFG_SEG,
+ CFG_SEG_TCP,
+ CFG_SEG_SYNC,
+ CFG_SEG_RET,
+ CFG_SEG_MAX
+};
+
+enum EN_CFG_ITEM_TYPE
+{
+ CFG_ITEM_TYPE_INT = 0,
+ CFG_ITEM_TYPE_STRING
+};
+
+enum EN_SEG_BASE_ITEM
+{
+ CFG_ITEM_BASE_SOCKET_NUM = 0,
+ CFG_ITEM_BASE_ARP_STALE_TIME,
+ CFG_ITEM_BASE_ARP_BC_RETRANS_NUM,
+ CFG_ITEM_BASE_APP_SOCKET_NUM,
+ CFG_ITEM_BASE_RING_BASE_SIZE,
+ CFG_ITEM_BASE_TCP_PCB_NUM,
+ CFG_ITEM_BASE_UDP_PCB_NUM,
+ CFG_ITEM_BASE_RAW_PCB_NUM,
+ CFG_ITEM_BASE_SPL_MAX_RING_SIZE,
+ CFG_ITEM_BASE_ARP_QUEUE_NUM,
+ CFG_ITEM_BASE_DUMP_MSG_NUM,
+ CFG_ITEM_BASE_TX_MBUF_POOL_SIZE,
+ CFG_ITEM_BASE_PKT_BURT_NUM,
+ CFG_ITEM_BASE_MAX
+};
+
+enum EN_SEG_TCP_ITEM
+{
+ CFG_ITEM_TCP_SYN_REXMIT_INTERVAL_MS = 0,
+ CFG_ITEM_TCP_SYN_REXMIT_TIMES,
+ CFG_ITEM_TCP_ESTABLISHED_REXMIT_TIMES,
+ CFG_ITEM_TCP_MAX
+};
+
+enum EN_SEG_THREAD_PRI_ITEM
+{
+ CFG_ITEM_THREAD_PRI_POLICY = 0,
+ CFG_ITEM_THREAD_PRI_PRI,
+ CFG_ITEM_THREAD_PRI_MAX
+};
+
+enum EN_SEG_FOR_MACRO_ITEM
+{
+ CFG_ITEM_C10M_SUPPORT = 0,
+ CFG_ITEM_FOR_MACRO_MAX
+};
+
+enum EN_SEG_MACRO_CUSTOM
+{
+ CFG_SBR_FD_NETCONN_SIZE = 0,
+ CFG_SS_NETCONN_SIZE,
+ CFG_DEF_APP_SOCKET_NUM,
+ CFG_SOCKET_NUM_PER_THREAD,
+ CFG_MAX_SOCKET_NUM, // same as socket num
+ CFG_APP_POOL_NUM,
+ CFG_MAX_TCP_HASH_SIZE,
+ CFG_DEF_RX_MBUF_POOL_SIZE, // from POOL_RING_BASE_SIZE
+ CFG_DEF_TX_MBUF_POOL_SIZE,
+ CFG_MAX_LISTEN_SOCKET_NUM,
+ CFG_DEF_SPL_MAX_ACCEPT_RING_SIZE,
+ CFG_DEF_TCP_PCB_NUM,
+ CFG_DEF_UDP_PCB_NUM,
+ CFG_DEF_RAW_PCB_NUM,
+ CFG_MAX_EPOLL_NUM,
+ CFG_MAX_EPITEM_NUM,
+ CFG_MAX_SOCK_FOR_KERNEL,
+ CFG_MAX_SOCK_FOR_STACK,
+ CFG_DEF_SPL_MAX_RING_SIZE,
+ CFG_DEF_HAL_RX_RING_SIZE,
+ CFG_DEF_TX_MSG_POOL_SIZE,
+ CFG_DEF_MBOX_RING_SIZE,
+ CFG_DEF_MPTCP_VERSION,
+ CFG_ITEM_MACRO_CUSTOM_MAX
+};
+
+typedef void (*custom_check_fn) (void *pitem);
+
+// pack size?
+struct cfg_item_info
+{
+ char *name;
+ int type;
+ int min_value;
+ int max_value;
+ int default_value;
+ char *default_str;
+ custom_check_fn custom_check;
+ union
+ {
+ int value;
+ char *pvalue;
+ };
+};
+
+typedef struct _cfg_module_param
+{
+ u32 proc_type;
+ i32 argc;
+ u8 **argv;
+} cfg_module_param;
+
+extern u32 g_custom_cfg_items[MAX_CUSTOM_CFG];
+extern u32 g_base_cfg_items[MAX_BASE_CFG];
+extern u32 g_macro_custom_cfg_items[CFG_ITEM_MACRO_CUSTOM_MAX];
+extern struct cfg_item_info g_cfg_item_info[CFG_SEG_MAX][MAX_CFG_ITEM];
+
+#define get_base_cfg(tag) g_base_cfg_items[(tag)]
+#define get_custom_cfg(tag) g_custom_cfg_items[(tag)]
+#define set_custom_cfg_item(tag, value) g_custom_cfg_items[(tag)] = (value)
+
+/* stackpool config data definition */
+#ifndef C10M_SUPPORT
+#define C10M_SUPPORT get_cfg_info(CFG_SEG_FOR_MACRO, CFG_ITEM_C10M_SUPPORT)
+#endif
+
+#define CFG(item) g_macro_custom_cfg_items[item]
+/*
+ MAX_SOCKET_NUM: max socket fd number one app can use, it should equal the max socket
+ number nstack support(CUR_CFG_SOCKET_NUM)
+*/
+
+/* *INDENT-OFF* */
+#define DEF_SOCKET_NUM 1024 /* default socket number */
+COMPAT_PROTECT_RETURN (DEF_SOCKET_NUM, 1024)
+#define MIN_SOCKET_NUM 1024 /* min socket number */
+/* *INDENT-ON* */
+
+#define MAX_SOCKET_NUM 8192 /* default: 8K sockets */
+#define CUR_CFG_SOCKET_NUM get_base_cfg(CFG_BASE_SOCKET_NUM) /* max socket number nstack support */
+
+/* socket num per instance, CUR_CFG_THREAD_NUM should be 2^n */
+#define INSTANCE_SOCKET_NUM (CUR_CFG_SOCKET_NUM/CUR_CFG_THREAD_NUM)
+
+#define DEF_ARP_STACLE_TIME 300 /* default arp stale time: second */
+#define MIN_ARP_STACLE_TIME 30 /* min arp stale time: second */
+#define MAX_ARP_STACLE_TIME 1200 /* max arp stale time: second */
+#define ARP_STALE_TIME get_base_cfg(CFG_BASE_ARP_STALE_TIME)
+
+#define DEF_ARP_BC_RETRANS_NUM 5 /* default arp broadcast retransmission times */
+#define MIN_ARP_BC_RETRANS_NUM 1 /* min arp broadcast retransmission times */
+#define MAX_ARP_BC_RETRANS_NUM 20 /* max arp broadcast retransmission times */
+#define ARP_BC_RETRANS_NUM get_base_cfg(CFG_BASE_ARP_BC_RETRANS_NUM)
+
+/* thread number config */
+#define DEF_THREAD_NUM 1 /* default stackpool thread number */
+#define MIN_THREAD_NUM 1 /* min thread number */
+#define MAX_THREAD_NUM 8
+#define CUR_CFG_THREAD_NUM get_base_cfg(CFG_BASE_THREAD_NUM)
+
+/* use GLOBAL_THREAD_INDEX to create socket in apps */
+#define GLOBAL_THREAD_INDEX 0
+
+/* hal port number config */
+#define DEF_HAL_PORT_NUM 20 /* port number */
+/* *INDENT-OFF* */
+COMPAT_PROTECT_RETURN (DEF_HAL_PORT_NUM, 20)
+/* *INDENT-ON* */
+#define MIN_HAL_PORT_NUM 1
+#define MAX_HAL_PORT_NUM 255
+#define CUR_CFG_HAL_PORT_NUM get_base_cfg(CFG_BASE_HAL_PORT_NUM)
+
+/* vm number config */
+#define MAX_VF_NUM 4 /* max vf number */
+/* *INDENT-OFF* */
+COMPAT_PROTECT_RETURN (MAX_VF_NUM, 4)
+/* *INDENT-ON* */
+
+/* base ring size config */
+#define DEF_RING_BASE_SIZE 2048 /* base ring size */
+/* *INDENT-OFF* */
+COMPAT_PROTECT_RETURN (DEF_RING_BASE_SIZE, 2048)
+/* *INDENT-ON* */
+#define MIN_RING_BASE_SIZE 1024
+#define MAX_RING_BASE_SIZE 4096
+#define POOL_RING_BASE_SIZE get_base_cfg(CFG_BASE_RING_SIZE)
+
+#define RX_MBUF_MID_THRESHOLD RX_MBUF_POOL_SIZE/4
+#define RX_MBUF_MIN_THRESHOLD RX_MBUF_POOL_SIZE/16
+
+/* mbuf data size config */
+#define DEF_MBUF_DATA_SIZE 2048 /* mbuf data size */
+/* *INDENT-OFF* */
+COMPAT_PROTECT_RETURN (DEF_MBUF_DATA_SIZE, 2048)
+/* *INDENT-ON* */
+#define TX_MBUF_MAX_LEN get_custom_cfg(CFG_MBUF_DATA_SIZE)
+/* ptk/task burst config */
+#define MAX_PKT_BURST 512
+#define MIN_PKT_BURST 1
+#define DEF_PKT_BURST 32
+/* *INDENT-OFF* */
+COMPAT_PROTECT_RETURN (DEF_PKT_BURST, 32)
+/* *INDENT-ON* */
+
+/*tcp related param*/
+#define SPL_TCP_SYN_RTX_INTVAL ((u32)get_cfg_info(CFG_SEG_TCP, CFG_ITEM_TCP_SYN_REXMIT_INTERVAL_MS))
+#define SPL_TCP_SYNMAXRTX ((u32)get_cfg_info(CFG_SEG_TCP, CFG_ITEM_TCP_SYN_REXMIT_TIMES))
+#define SPL_TCP_MAXRTX ((u32)get_cfg_info(CFG_SEG_TCP, CFG_ITEM_TCP_ESTABLISHED_REXMIT_TIMES))
+
+/* tx mbuf pool size config */
+#define TX_MBUF_POOL_SIZE get_custom_cfg(CFG_TX_MBUF_NUM)
+#define RX_MBUF_POOL_SIZE get_custom_cfg(CFG_RX_MBUF_NUM)
+
+#define DEF_HAL_TX_RING_SIZE 2048 /* hal tx ring size */
+#define HAL_RX_RING_SIZE get_custom_cfg(CFG_HAL_RX_RING_SIZE)
+#define HAL_TX_RING_SIZE get_custom_cfg(CFG_HAL_TX_RING_SIZE)
+
+/* stackpool recv ring size config */
+
+#define SPL_MAX_RING_SIZE (u32)get_cfg_info(CFG_SEG_BASE, CFG_ITEM_BASE_SPL_MAX_RING_SIZE) /* ring size config, used in recv ring(per socket) */
+
+#define MIN_ARP_QUEUE_NUM 300
+#define LARGE_ARP_QUEUE_NUM (512*1024)
+#define CUR_ARP_QUEUE_NUM (u32)get_cfg_info(CFG_SEG_BASE, CFG_ITEM_BASE_ARP_QUEUE_NUM)
+
+#define CUR_CFG_DEF_TCP_PCB_NUM (u32)get_cfg_info(CFG_SEG_BASE, CFG_ITEM_BASE_TCP_PCB_NUM)
+#define CUR_CFG_DEF_UDP_PCB_NUM (u32)get_cfg_info(CFG_SEG_BASE, CFG_ITEM_BASE_UDP_PCB_NUM)
+#define CUR_CFG_DEF_RAW_PCB_NUM (u32)get_cfg_info(CFG_SEG_BASE, CFG_ITEM_BASE_RAW_PCB_NUM)
+
+/* tcp seg number config */
+ /* seg num = txbuf num + rxbuf num, and mptcp may double, so set it to txbuf num * 4 */
+#define DEF_MEMP_NUM_TCP_SEG (4 * CFG(CFG_APP_POOL_NUM) * CFG(CFG_DEF_TX_MBUF_POOL_SIZE))
+
+#define TX_MSG_POOL_SIZE get_custom_cfg(CFG_MP_MSG_NUM) /* msg number, used by stackpool internal, per thread */
+
+#define MBOX_RING_SIZE get_custom_cfg(CFG_MBOX_RING_SIZE) /* mbox ring size config, per thread */
+
+#define MIN_DUMP_MSG_NUM (4 * 1024)
+#define MAX_DUMP_MSG_NUM (64 * 1024)
+
+/*some problem if CUSOTM_RECV_RING_SIZE more than 4096*/
+#define CUSOTM_RECV_RING_SIZE 4096
+/* *INDENT-OFF* */
+COMPAT_PROTECT_RETURN (CUSOTM_RECV_RING_SIZE, 4096)
+/* *INDENT-ON* */
+
+u32 get_cfg_info(int tag, int item);
+u32 get_cfg_share_mem_size();
+
+int get_share_cfg_from_mem(void *mem);
+
+void get_default_base_cfg(u32 thread_num);
+
+int set_share_cfg_to_mem(void *mem);
+
+void config_module_init(cfg_module_param * param);
+
+/*##############for netstat######################*/
+typedef enum _netstat_protocol_type
+{
+ NETSTAT_TCP_UDP_CONN,
+ NETSTAT_TCP_CONN,
+ NETSTAT_UDP_CONN
+} netstat_protocol_type;
+
+typedef struct _netstat_send_para
+{
+ netstat_protocol_type protocol_type; /*0:all; 1:TCP; 2:UDP */
+ unsigned int instance_flag; /*0: all instance; 1:specific instance */
+ int instance_id;
+} netstat_send_para;
+
+typedef struct _netstat_data_info
+{
+ unsigned int local_addr;
+ unsigned int remote_addr;
+ unsigned short local_port;
+ unsigned short remote_port;
+ unsigned short state;
+ unsigned short resv;
+} netstat_data_info;
+
+typedef struct _netstat_info
+{
+ unsigned int pcb_num;
+ netstat_data_info data[10240];
+} netstat_info;
+
#ifdef __cplusplus
/* *INDENT-OFF* */
}
diff --git a/src/framework/include/nsfw_mem_api.h b/src/framework/include/nsfw_mem_api.h
index db7f5e7..f22fd32 100644
--- a/src/framework/include/nsfw_mem_api.h
+++ b/src/framework/include/nsfw_mem_api.h
@@ -22,18 +22,35 @@
#include "types.h"
#include "nsfw_mgr_com_api.h"
#include "nstack_log.h"
+#include <unistd.h>
+#include <string.h>
#define NSFW_MEM_MGR_MODULE "nsfw_mem_mgr"
/*
*the max len of memory name is 32bytes, but app just can use max 22bytes, left 10bytes to memory manager module
*/
-#define NSFW_MEM_NAME_LENGTH (32)
-#define NSFW_MEM_APPNAME_LENGTH (22)
+#define NSFW_MEM_NAME_LENTH (32)
+#define NSFW_MEM_APPNAME_LENTH (22)
#define NSFW_SOCKET_ANY (-1)
-#define NSFW_MEM_OK (0)
-#define NSFW_MEM_ERR (-1)
+
+#define NSFW_MEM_NOT_INIT (0)
+#define NSFW_MEM_INIT_ERR (1)
+#define NSFW_MEM_INIT_OK (2)
+
+/*
+ * type of init error
+ */
+typedef enum
+{
+ NSFW_MEM_ERR_MISALIGN = -2,
+ NSFW_MEM_ERR = -1,
+ NSFW_MEM_OK = 0,
+ NSFW_MEM_RTP_FAIL = 1, /* init rtp fail */
+ NSFW_MEM_MALLOC_FAIL = 2, /* mem alloc fail */
+ NSFW_MEM_MEMSET_FAIL = 3,
+} nsfw_init_errno;
/*
*type of memory:
@@ -42,20 +59,20 @@
*/
typedef enum
{
- NSFW_SHMEM,
- NSFW_NSHMEM,
- NSFW_MEM_TYPEMAX,
+ NSFW_SHMEM,
+ NSFW_NSHMEM,
+ NSFW_MEM_TYPEMAX,
} nsfw_mem_type;
/*type of ring operation*/
typedef enum
{
- NSFW_MRING_SPSC, /*single producer single consumer ring */
- NSFW_MRING_MPSC, /*multi producer single consumer ring */
- NSFW_MRING_SPMC, /*single producer multi consumer ring */
- NSFW_MRING_MPMC, /*multi producer multi consumer ring */
- NSFW_MRING_SPSC_ST, /*single producer single consumer and belong to one thread ring */
- NSFW_MPOOL_TYPEMAX,
+ NSFW_MRING_SPSC, /*sigle producer sigle consumer ring */
+ NSFW_MRING_MPSC, /*multi producer sigle consumer ring */
+ NSFW_MRING_SPMC, /*sigle producer multi consumer ring */
+ NSFW_MRING_MPMC, /*multi producer multi consumer ring */
+ NSFW_MRING_SPSC_ST, /*single producer single consumer and belong to one thread ring */
+ NSFW_MPOOL_TYPEMAX,
} nsfw_mpool_type;
typedef void *mpool_handle;
@@ -66,169 +83,190 @@ typedef void *mring_handle;
/*initial of param*/
typedef struct
{
- i32 iargsnum;
- i8 **pargs;
- fw_poc_type enflag; /*app, nStackMain, Master */
+ i32 iargsnum;
+ i8 **pargs;
+ fw_poc_type enflag; /*app, daemon-stack, Master */
} nsfw_mem_para;
typedef struct
{
- nsfw_mem_type entype;
- fw_poc_type enowner; /*notes: 1. when calling any shared memory create inferface, the name of memory end with _0 created by nStackMain,
+ nsfw_mem_type entype;
+ fw_poc_type enowner; /*notes: 1. when calling any shared memory create inferface, the name of memory end with _0 created by daemon-stack,
* end with null created by nStackMaster, and end with _<pid> created by other.
* 2. pname->enowner is available only when call look up shared memory.
* 3. if the roles of process is NSFW_PROC_MASTER but the memory was created by others, or pname->enowner is NSFW_PROC_NULL,
* the name must be full name.
- * for examles if the memory was created by nStackMain and pname->enowner is NSFW_PROC_NULL,
+ * for examles if the memory was created by daemon-stack and pname->enowner is NSFW_PROC_NULL,
* must add '_0' at the end of name, if the memory was created by app and the role of process is NSFW_PROC_MASTER, must add
* _(pid) at the end of name, nstack_123.
*/
- i8 aname[NSFW_MEM_NAME_LENGTH]; /*the length of name must be less than NSFW_MEM_APPNAME_LENGTH. */
+ i8 aname[NSFW_MEM_NAME_LENTH]; /*the lenth of name must be less than NSFW_MEM_APPNAME_LENTH. */
} nsfw_mem_name;
typedef struct
{
- nsfw_mem_name stname;
- size_t length;
- i32 isocket_id;
- i32 ireserv;
+ nsfw_mem_name stname;
+ size_t lenth;
+ i32 isocket_id;
+ i32 ireserv;
} nsfw_mem_zone;
typedef struct
{
- nsfw_mem_name stname;
- unsigned usnum; /*the really created mbfpool num is (num+1) power of 2 */
- unsigned uscash_size;
- unsigned uspriv_size;
- unsigned usdata_room;
- i32 isocket_id;
- nsfw_mpool_type enmptype;
+ nsfw_mem_name stname;
+ unsigned usnum; /*the really created mbfpool num is (num+1) power of 2 */
+ unsigned uscash_size;
+ unsigned uspriv_size;
+ unsigned usdata_room;
+ i32 isocket_id;
+ nsfw_mpool_type enmptype;
} nsfw_mem_mbfpool;
typedef struct
{
- nsfw_mem_name stname;
- u32 usnum; /*the really created sppool num is (num+1) power of 2 */
- u32 useltsize;
- i32 isocket_id;
- nsfw_mpool_type enmptype;
+ nsfw_mem_name stname;
+ u32 usnum; /*the really created sppool num is (num+1) power of 2 */
+ u32 useltsize;
+ i32 isocket_id;
+ nsfw_mpool_type enmptype;
} nsfw_mem_sppool;
typedef struct
{
- nsfw_mem_name stname;
- u32 usnum; /*the really created ring num is (num+1) power of 2 */
- i32 isocket_id;
- nsfw_mpool_type enmptype;
+ nsfw_mem_name stname;
+ u32 usnum; /*the really created ring num is (num+1) power of 2 */
+ i32 isocket_id;
+ nsfw_mpool_type enmptype;
} nsfw_mem_mring;
typedef enum
{
- NSFW_MEM_ALLOC_SUCC = 1,
- NSFW_MEM_ALLOC_FAIL = 2,
+ NSFW_MEM_ALLOC_SUCC = 1,
+ NSFW_MEM_ALLOC_FAIL = 2,
} nsfw_mem_alloc_state;
typedef enum
{
- NSFW_MEM_MZONE,
- NSFW_MEM_MBUF,
- NSFW_MEM_SPOOL,
- NSFW_MEM_RING
+ NSFW_MEM_MZONE,
+ NSFW_MEM_MBUF,
+ NSFW_MEM_SPOOL,
+ NSFW_MEM_RING
} nsfw_mem_struct_type;
typedef enum
{
- NSFW_RESERV_REQ_MSG,
- NSFW_RESERV_ACK_MSG,
- NSFW_MBUF_REQ_MSG,
- NSFW_MBUF_ACK_MSG,
- NSFW_SPPOOL_REQ_MSG,
- NSFW_SPPOOL_ACK_MSG,
- NSFW_RING_REQ_MSG,
- NSFW_RING_ACK_MSG,
- NSFW_RELEASE_REQ_MSG,
- NSFW_RELEASE_ACK_MSG,
- NSFW_MEM_LOOKUP_REQ_MSG,
- NSFW_MEM_LOOKUP_ACK_MSG,
- NSFW_MEM_MAX_MSG
+ NSFW_RESERV_REQ_MSG,
+ NSFW_RESERV_ACK_MSG,
+ NSFW_MBUF_REQ_MSG,
+ NSFW_MBUF_ACK_MSG,
+ NSFW_SPPOOL_REQ_MSG,
+ NSFW_SPPOOL_ACK_MSG,
+ NSFW_RING_REQ_MSG,
+ NSFW_RING_ACK_MSG,
+ NSFW_RELEASE_REQ_MSG,
+ NSFW_RELEASE_ACK_MSG,
+ NSFW_MEM_LOOKUP_REQ_MSG,
+ NSFW_MEM_LOOKUP_ACK_MSG,
+ NSFW_MEM_MAX_MSG
} nsfw_remote_msg;
typedef struct __nsfw_shmem_msg_head
{
- unsigned usmsg_type;
- unsigned uslength;
- i32 aidata[0];
+ unsigned usmsg_type;
+ unsigned uslenth;
+
+ i32 aidata[0];
+
} nsfw_shmem_msg_head;
typedef struct __nsfw_shmem_ack
{
- void *pbase_addr;
- u16 usseq;
- i8 cstate;
- i8 creserv;
- i32 ireserv;
+ void *pbase_addr;
+ u16 usseq;
+ i8 cstate;
+ i8 creserv;
+ i32 ireserv;
} nsfw_shmem_ack;
typedef struct __nsfw_shmem_reserv_req
{
- i8 aname[NSFW_MEM_NAME_LENGTH];
- u16 usseq;
- u16 usreserv;
- i32 isocket_id;
- size_t length;
- i32 ireserv;
+ i8 aname[NSFW_MEM_NAME_LENTH];
+ u16 usseq;
+ u16 usreserv;
+ i32 isocket_id;
+ size_t lenth;
+ i32 ireserv;
} nsfw_shmem_reserv_req;
typedef struct __nsfw_shmem_mbuf_req
{
- i8 aname[NSFW_MEM_NAME_LENGTH];
- u16 usseq;
- u16 enmptype;
- unsigned usnum;
- unsigned uscash_size;
- unsigned uspriv_size;
- unsigned usdata_room;
- i32 isocket_id;
- i32 ireserv;
+ i8 aname[NSFW_MEM_NAME_LENTH];
+ u16 usseq;
+ u16 enmptype;
+ unsigned usnum;
+ unsigned uscash_size;
+ unsigned uspriv_size;
+ unsigned usdata_room;
+ i32 isocket_id;
+ i32 ireserv;
} nsfw_shmem_mbuf_req;
typedef struct __nsfw_shmem_sppool_req
{
- i8 aname[NSFW_MEM_NAME_LENGTH];
- u16 usseq;
- u16 enmptype;
- u32 usnum;
- u32 useltsize;
- i32 isocket_id;
- i32 ireserv;
+ i8 aname[NSFW_MEM_NAME_LENTH];
+ u16 usseq;
+ u16 enmptype;
+ u32 usnum;
+ u32 useltsize;
+ i32 isocket_id;
+ i32 ireserv;
} nsfw_shmem_sppool_req;
typedef struct __nsfw_shmem_ring_req
{
- i8 aname[NSFW_MEM_NAME_LENGTH];
- u16 usseq;
- u16 enmptype;
- u32 usnum;
- i32 isocket_id;
- i32 ireserv;
+ i8 aname[NSFW_MEM_NAME_LENTH];
+ u16 usseq;
+ u16 enmptype;
+ u32 usnum;
+ i32 isocket_id;
+ i32 ireserv;
} nsfw_shmem_ring_req;
typedef struct __nsfw_shmem_free_req
{
- i8 aname[NSFW_MEM_NAME_LENGTH];
- u16 usseq;
- u16 ustype; /*structure of memory(memzone,mbuf,mpool,ring) */
- i32 ireserv;
+ i8 aname[NSFW_MEM_NAME_LENTH];
+ u16 usseq;
+ u16 ustype; /*structure of memory(memzone,mbuf,mpool,ring) */
+ i32 ireserv;
} nsfw_shmem_free_req;
typedef struct __nsfw_shmem_lookup_req
{
- i8 aname[NSFW_MEM_NAME_LENGTH];
- u16 usseq;
- u16 ustype; /*structure of memory(memzone,mbuf,mpool,ring) */
- i32 ireserv;
+ i8 aname[NSFW_MEM_NAME_LENTH];
+ u16 usseq;
+ u16 ustype; /*structure of memory(memzone,mbuf,mpool,ring) */
+ i32 ireserv;
} nsfw_shmem_lookup_req;
+typedef struct __nsfw_mem_ring_health_info
+{
+ struct
+ {
+ u32 head; //Head of the Ring, used to indicate pos where to pull a val
+ u32 tail; //for nshmem, shmem not used.
+ } prod;
+ struct
+ {
+ u32 head; //for nshmem, shmem not used.
+ u32 tail; //Tail of the Ring, used to indicate pos where to push a val
+ } cons;
+ struct timeval overflow_time;
+ u32 size;
+ u32 mask;
+ u16 overflow_count;
+
+} nsfw_mem_ring_health_info;
+
typedef int (*nsfw_mem_ring_enqueue_fun) (mring_handle ring, void *box);
typedef int (*nsfw_mem_ring_dequeue_fun) (mring_handle ring, void **box);
typedef int (*nsfw_mem_ring_dequeuev_fun) (mring_handle ring, void **box,
@@ -236,200 +274,190 @@ typedef int (*nsfw_mem_ring_dequeuev_fun) (mring_handle ring, void **box,
typedef struct
{
- nsfw_mem_ring_enqueue_fun ring_ops_enqueue;
- nsfw_mem_ring_dequeue_fun ring_ops_dequeue;
- nsfw_mem_ring_dequeuev_fun ring_ops_dequeuev;
+ nsfw_mem_ring_enqueue_fun ring_ops_enqueue;
+ nsfw_mem_ring_dequeue_fun ring_ops_dequeue;
+ nsfw_mem_ring_dequeuev_fun ring_ops_dequeuev;
} nsfw_ring_ops;
/*
* memory module init
- * para:point to nstack_fwmem_para
+ * para:point to nstak_fwmem_para
*/
-i32 nsfw_mem_init (void *para);
+i32 nsfw_mem_init(void *para);
/*
* create a block memory with name
* nsfw_mem_zone::stname
* nsfw_mem_zone::isize
- * note: 1. the length of name must be less than NSFW_MEM_APPNAME_LENGTH.
+ * note: 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
*/
-mzone_handle nsfw_mem_zone_create (nsfw_mem_zone * pinfo);
+mzone_handle nsfw_mem_zone_create(nsfw_mem_zone * pinfo);
/*
*create some memory blocks
- * note: 1. the length of name must be less than NSFW_MEM_APPNAME_LENGTH.
+ * note: 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
*/
-i32 nsfw_mem_zone_createv (nsfw_mem_zone * pmeminfo, i32 inum,
- mzone_handle * paddr_array, i32 iarray_num);
+i32 nsfw_mem_zone_createv(nsfw_mem_zone * pmeminfo, i32 inum,
+ mzone_handle * paddr_array, i32 iarray_num);
/*
*look up a memory
- * note: 1. the length of name must be less than NSFW_MEM_APPNAME_LENGTH.
+ * note: 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
* 2. if the memory is shared, pname->enowner indicate that who create this memory,
* note:
- * 1. when calling any shared memory create inferface, the name of memory end with _0 created by nStackMain,
+ * 1. when calling any shared memory create inferface, the name of memory end with _0 created by daemon-stack,
* end with none created by nStackMaster, and end with _<pid> created by other.
* 2. pname->enowner is available only when call look up shared memory.
* 3. if the roles of process is NSFW_PROC_MASTER but the memory was created by others, or pname->enowner is NSFW_PROC_NULL,
* the name must be full name.
- * for examles if the memory was created by nStackMain and pname->enowner is NSFW_PROC_NULL,
+ * for examles if the memory was created by daemon-stack and pname->enowner is NSFW_PROC_NULL,
* must add '_0' at the end of name, if the memory was created by app and the role of process is NSFW_PROC_MASTER, must add
* _(pid) at the end of name, nstack_123.
*/
-mzone_handle nsfw_mem_zone_lookup (nsfw_mem_name * pname);
+mzone_handle nsfw_mem_zone_lookup(nsfw_mem_name * pname);
/*release a memory*/
-i32 nsfw_mem_zone_release (nsfw_mem_name * pname);
+i32 nsfw_mem_zone_release(nsfw_mem_name * pname);
/*
*create a mbuf pool
*/
-mpool_handle nsfw_mem_mbfmp_create (nsfw_mem_mbfpool * pbufinfo);
+mpool_handle nsfw_mem_mbfmp_create(nsfw_mem_mbfpool * pbufinfo);
/*
*create some mbuf pools
- * note: 1. the name of length must be less than NSFW_MEM_APPNAME_LENGTH.
- */
-i32 nsfw_mem_mbfmp_createv (nsfw_mem_mbfpool * pmbfname, i32 inum,
- mpool_handle * phandle_array, i32 iarray_num);
-
-/*
- *alloc a mbuf from mbuf pool
+ * note: 1. the name of lenth must be less than NSFW_MEM_APPNAME_LENTH.
*/
-mbuf_handle nsfw_mem_mbf_alloc (mpool_handle mhandle, nsfw_mem_type entype);
-
-/*
- *put a mbuf backintp mbuf pool
- */
-i32 nsfw_mem_mbf_free (mbuf_handle mhandle, nsfw_mem_type entype);
+i32 nsfw_mem_mbfmp_createv(nsfw_mem_mbfpool * pmbfname, i32 inum,
+ mpool_handle * phandle_array, i32 iarray_num);
/*
*look up mbuf mpool
- * note: 1. the length of name must be less than NSFW_MEM_APPNAME_LENGTH.
+ * note: 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
* 2. if the memory is shared, pname->enowner indicate that who create this memory.
* note:
- * 1. when calling any shared memory create inferface, the name of memory end with _0 created by nStackMain,
+ * 1. when calling any shared memory create inferface, the name of memory end with _0 created by daemon-stack,
* end with none created by nStackMaster, and end with _<pid> created by other.
* 2. pname->enowner is available only when call look up shared memory.
* 3. if the roles of process is NSFW_PROC_MASTER but the memory was created by others, or pname->enowner is NSFW_PROC_NULL,
* the name must be full name.
- * for examles if the memory was created by nStackMain and pname->enowner is NSFW_PROC_NULL,
+ * for examles if the memory was created by daemon-stack and pname->enowner is NSFW_PROC_NULL,
* must add '_0' at the end of name, if the memory was created by app and the role of process is NSFW_PROC_MASTER, must add
* _(pid) at the end of name, nstack_123.
*/
-mpool_handle nsfw_mem_mbfmp_lookup (nsfw_mem_name * pmbfname);
+mpool_handle nsfw_mem_mbfmp_lookup(nsfw_mem_name * pmbfname);
/*
*release mbuf pool
- * note: 1. the length of name must be less than NSFW_MEM_APPNAME_LENGTH.
+ * note: 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
*/
-i32 nsfw_mem_mbfmp_release (nsfw_mem_name * pname);
+i32 nsfw_mem_mbfmp_release(nsfw_mem_name * pname);
/*
*create a simple pool
- *note: 1. the length of name must be less than NSFW_MEM_APPNAME_LENGTH.
+ *note: 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
*/
-mring_handle nsfw_mem_sp_create (nsfw_mem_sppool * pmpinfo);
+mring_handle nsfw_mem_sp_create(nsfw_mem_sppool * pmpinfo);
/*
*create some simple pools one time
- *note: 1. the length of name must be less than NSFW_MEM_APPNAME_LENGTH.
+ *note: 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
*/
-i32 nsfw_mem_sp_createv (nsfw_mem_sppool * pmpinfo, i32 inum,
- mring_handle * pringhandle_array, i32 iarray_num);
+i32 nsfw_mem_sp_createv(nsfw_mem_sppool * pmpinfo, i32 inum,
+ mring_handle * pringhandle_array, i32 iarray_num);
/*
*create a simple pool with many rings
- *note: 1. the length of name must be less than NSFW_MEM_APPNAME_LENGTH.
+ *note: 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
*/
-i32 nsfw_mem_sp_ring_create (nsfw_mem_mring * prpoolinfo,
- mring_handle * pringhandle_array, i32 iringnum);
+i32 nsfw_mem_sp_ring_create(nsfw_mem_mring * prpoolinfo,
+ mring_handle * pringhandle_array, i32 iringnum);
/*
*release a simple mempool
- *note: 1. the length of name must be less than NSFW_MEM_APPNAME_LENGTH.
+ *note: 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
*/
-i32 nsfw_mem_sp_release (nsfw_mem_name * pname);
+i32 nsfw_mem_sp_release(nsfw_mem_name * pname);
/*
*look up a simpile ring
- * note: 1. the length of name must be less than NSFW_MEM_APPNAME_LENGTH.
+ * note: 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
* 2. if the memory is shared, pname->enowner indicate that who create this memory,
* note:
- * 1. when calling any shared memory create inferface, the name of memory end with _0 created by nStackMain,
+ * 1. when calling any shared memory create inferface, the name of memory end with _0 created by daemon-stack,
* end with none created by nStackMaster, and end with _<pid> created by other.
* 2. pname->enowner is available only when call look up shared memory.
* 3. if the roles of process is NSFW_PROC_MASTER but the memory was created by others, or pname->enowner is NSFW_PROC_NULL,
* the name must be full name.
- * for examles if the memory was created by nStackMain and pname->enowner is NSFW_PROC_NULL,
+ * for examles if the memory was created by daemon-stack and pname->enowner is NSFW_PROC_NULL,
* must add '_0' at the end of name, if the memory was created by app and the role of process is NSFW_PROC_MASTER, must add
* _(pid) at the end of name, nstack_123.
*/
-mring_handle nsfw_mem_sp_lookup (nsfw_mem_name * pname);
+mring_handle nsfw_mem_sp_lookup(nsfw_mem_name * pname);
/*
*create a ring
- *note: 1. the length of name must be less than NSFW_MEM_APPNAME_LENGTH.
- * 2. shared memory ring (NSFW_SHMEM) just can put a pointer into the queue, the queue also point to a shared block memory.
+ *note: 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
+ * 2. shared memory ring (NSFW_SHMEM) just can put a pointor into the queue, the queue also point to a shared block memory.
* no shared memory ring(NSFW_NSHMEM) is other wise.
*/
-mring_handle nsfw_mem_ring_create (nsfw_mem_mring * pringinfo);
+mring_handle nsfw_mem_ring_create(nsfw_mem_mring * pringinfo);
/*
*look up a ring by name
- * note:1. the length of name must be less than NSFW_MEM_APPNAME_LENGTH.
+ * note:1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
* 2. if the memory is shared, pname->enowner indicate that who create this memory,
* note:
- * 1. when calling any shared memory create inferface, the name of memory end with _0 created by nStackMain,
+ * 1. when calling any shared memory create inferface, the name of memory end with _0 created by daemon-stack,
* end with none created by nStackMaster, and end with _<pid> created by other.
* 2. pname->enowner is available only when call look up shared memory.
* 3. if the roles of process is NSFW_PROC_MASTER but the memory was created by others, or pname->enowner is NSFW_PROC_NULL,
* the name must be full name.
- * for examles if the memory was created by nStackMain and pname->enowner is NSFW_PROC_NULL,
+ * for examles if the memory was created by daemon-stack and pname->enowner is NSFW_PROC_NULL,
* must add '_0' at the end of name, if the memory was created by app and the role of process is NSFW_PROC_MASTER, must add
* _(pid) at the end of name, nstack_123.
*/
-mring_handle nsfw_mem_ring_lookup (nsfw_mem_name * pname);
+mring_handle nsfw_mem_ring_lookup(nsfw_mem_name * pname);
/*
* reset the number of producer and consumer, also, the state of ring reset to empty
* notes: must be called before doing any operations base on the ring
*/
-void nsfw_mem_ring_reset (mring_handle mhandle, nsfw_mpool_type entype);
+void nsfw_mem_ring_reset(mring_handle mhandle, nsfw_mpool_type entype);
extern nsfw_ring_ops g_ring_ops_arry[NSFW_MEM_TYPEMAX][NSFW_MPOOL_TYPEMAX];
/*****************************************************************************
* Prototype : nsfw_mem_ring_dequeue
* Description : get a member from a ring
-* note : if NSFW_SHMEM ring, pdata returned already a local address
+* note : if NSFW_SHMEM ring, pdata returned alread a local address
* Input : mring_handle mhandle
* void** pdata
* Output : None
* Return Value : the num of elment get from the queue, =0: get null, <0: err happen, >0: return num.
* Calls :
* Called By :
-*
*****************************************************************************/
-static inline i32
-nsfw_mem_ring_dequeue (mring_handle mhandle, void **pdata)
+static inline i32 nsfw_mem_ring_dequeue(mring_handle mhandle, void **pdata)
{
- if (NULL == mhandle || *((u8 *) mhandle) >= NSFW_MEM_TYPEMAX
- || *((u8 *) mhandle + 1) >= NSFW_MPOOL_TYPEMAX)
+ if (NULL == mhandle || *((u8 *) mhandle) >= NSFW_MEM_TYPEMAX
+ || *((u8 *) mhandle + 1) >= NSFW_MPOOL_TYPEMAX)
{
- NSCOMM_LOGERR ("input para error] mhandle=%p", mhandle);
- return -1;
+ NSRTP_LOGERR("input para error] mhandle=%p", mhandle);
+ return -1;
}
- return
- g_ring_ops_arry[*((u8 *) mhandle)][*((u8 *) mhandle + 1)].ring_ops_dequeue
- (mhandle, pdata);
+ return
+ g_ring_ops_arry[*((u8 *) mhandle)][*
+ ((u8 *) mhandle +
+ 1)].ring_ops_dequeue(mhandle,
+ pdata);
}
/*****************************************************************************
* Prototype : nsfw_mem_ring_dequeuev
* Description : get some members from a ring
-* note : if NSFW_SHMEM ring, pdata returned already a local address
+* note : if NSFW_SHMEM ring, pdata returned alread a local address
* Input : mring_handle mhandle
* void** pdata
* unsigned inum
@@ -437,23 +465,23 @@ nsfw_mem_ring_dequeue (mring_handle mhandle, void **pdata)
* Return Value : the num of elment get from the queue, =0: get null, <0: err happen, >0: return num.
* Calls :
* Called By :
-*
*****************************************************************************/
-static inline i32
-nsfw_mem_ring_dequeuev (mring_handle mhandle, void **pdata, unsigned int inum)
+static inline i32 nsfw_mem_ring_dequeuev(mring_handle mhandle, void **pdata,
+ unsigned int inum)
{
- if (NULL == mhandle || *((u8 *) mhandle) >= NSFW_MEM_TYPEMAX
- || *((u8 *) mhandle + 1) >= NSFW_MPOOL_TYPEMAX)
+ if (NULL == mhandle || *((u8 *) mhandle) >= NSFW_MEM_TYPEMAX
+ || *((u8 *) mhandle + 1) >= NSFW_MPOOL_TYPEMAX)
{
- NSCOMM_LOGERR ("input para error] mhandle=%p", mhandle);
- return -1;
+ NSRTP_LOGERR("input para error] mhandle=%p", mhandle);
+ return -1;
}
- return
- g_ring_ops_arry[*((u8 *) mhandle)][*
- ((u8 *) mhandle +
- 1)].ring_ops_dequeuev (mhandle, pdata,
- inum);
+ return
+ g_ring_ops_arry[*((u8 *) mhandle)][*
+ ((u8 *) mhandle +
+ 1)].ring_ops_dequeuev(mhandle,
+ pdata,
+ inum);
}
/*****************************************************************************
@@ -467,80 +495,118 @@ nsfw_mem_ring_dequeuev (mring_handle mhandle, void **pdata, unsigned int inum)
* Return Value : the num of elment put into the queue, =0: put null, <0: err happen, >0: return num.
* Calls :
* Called By :
-*
*****************************************************************************/
-static inline i32
-nsfw_mem_ring_enqueue (mring_handle mhandle, void *pdata)
+static inline i32 nsfw_mem_ring_enqueue(mring_handle mhandle, void *pdata)
{
- if (NULL == mhandle || *((u8 *) mhandle) >= NSFW_MEM_TYPEMAX
- || *((u8 *) mhandle + 1) >= NSFW_MPOOL_TYPEMAX)
+ if (NULL == mhandle || *((u8 *) mhandle) >= NSFW_MEM_TYPEMAX
+ || *((u8 *) mhandle + 1) >= NSFW_MPOOL_TYPEMAX)
{
- NSCOMM_LOGERR ("input para error] mhandle=%p", mhandle);
- return -1;
+ NSRTP_LOGERR("input para error] mhandle=%p", mhandle);
+ return -1;
}
- return
- g_ring_ops_arry[*((u8 *) mhandle)][*((u8 *) mhandle + 1)].ring_ops_enqueue
- (mhandle, pdata);
+ return
+ g_ring_ops_arry[*((u8 *) mhandle)][*
+ ((u8 *) mhandle +
+ 1)].ring_ops_enqueue(mhandle,
+ pdata);
}
/*
*get the free number of ring
*/
-u32 nsfw_mem_ring_free_count (mring_handle mhandle);
+u32 nsfw_mem_ring_free_count(mring_handle mhandle);
/*
*get the in using number of ring
*/
-u32 nsfw_mem_ring_using_count (mring_handle mhandle);
+u32 nsfw_mem_ring_using_count(mring_handle mhandle);
/*
*get size of ring
*/
-u32 nsfw_mem_ring_size (mring_handle mhandle);
+u32 nsfw_mem_ring_size(mring_handle mhandle);
/*
*release a ring memory
- *note: the length of name must be less than NSFW_MEM_APPNAME_LENGTH.
+ *note: the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
*/
-i32 nsfw_mem_ring_release (nsfw_mem_name * pname);
+i32 nsfw_mem_ring_release(nsfw_mem_name * pname);
/*
*statics mbufpool, sppool, ring mem size
*return: <=0, err happen, >0 mem size
- * NSFW_MEM_MZONE: not surport because you already know the length when create
- */
-ssize_t nsfw_mem_get_len (void *handle, nsfw_mem_struct_type type);
-
-/*
- *recycle mbuf
- *
+ * NSFW_MEM_MZONE: not surport because you already know the lenth when create
*/
-i32 nsfw_mem_mbuf_pool_recycle (mpool_handle handle);
+ssize_t nsfw_mem_get_len(void *handle, nsfw_mem_struct_type type);
typedef int (*nsfw_mem_item_fun) (void *data, void *argv);
-i32 nsfw_mem_sp_iterator (mpool_handle handle, u32 start, u32 end,
- nsfw_mem_item_fun fun, void *argv);
-i32 nsfw_mem_mbuf_iterator (mpool_handle handle, u32 start, u32 end,
- nsfw_mem_item_fun fun, void *argv);
+i32 nsfw_mem_sp_iterator(mpool_handle handle, u32 start, u32 end,
+ nsfw_mem_item_fun fun, void *argv);
+i32 nsfw_mem_mbuf_iterator(mpool_handle handle, u32 start, u32 end,
+ nsfw_mem_item_fun fun, void *argv);
+i32 nsfw_mem_ring_iterator(mpool_handle handle, nsfw_mem_item_fun fun,
+ void *argv);
-/*****************************************************************************
-* Prototype : nsfw_mem_dfx_ring_print
-* Description : print ring info
-* Input : mring_handle mhandle
-* char *pbuf
-* int length
-* Output : None
-* Return Value : i32
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-i32 nsfw_mem_dfx_ring_print (mring_handle mhandle, char *pbuf, int length);
+nsfw_mem_ring_health_info nsfw_mem_get_health_info(mring_handle mhandle);
-#ifdef SYS_MEM_RES_STAT
-u32 nsfw_mem_mbfpool_free_count (mpool_handle mhandle);
-#endif
+typedef struct
+{
+ fw_poc_type enflag; /*app, daemon-stack, Master */
+} nsfw_mem_localdata;
+
+/*memory access inferface define*/
+typedef struct
+{
+ i32(*mem_ops_init) (nsfw_mem_para * para);
+ void (*mem_ops_destroy) (void);
+ mzone_handle(*mem_ops_zone_creae) (nsfw_mem_zone * pinfo);
+ i32(*mem_ops_zone_createv) (nsfw_mem_zone * pmeminfo, i32 inum,
+ mzone_handle * paddr_array, i32 iarray_num);
+ mzone_handle(*mem_ops_zone_lookup) (nsfw_mem_name * pname);
+ i32(*mem_ops_mzone_release) (nsfw_mem_name * pname);
+ mpool_handle(*mem_ops_mbfmp_create) (nsfw_mem_mbfpool * pbufinfo);
+ i32(*mem_ops_mbfmp_createv) (nsfw_mem_mbfpool * pmbfname, i32 inum,
+ mpool_handle * phandle_array,
+ i32 iarray_num);
+ mpool_handle(*mem_ops_mbfmp_lookup) (nsfw_mem_name * pmbfname);
+ i32(*mem_ops_mbfmp_release) (nsfw_mem_name * pname);
+ mring_handle(*mem_ops_sp_create) (nsfw_mem_sppool * pmpinfo);
+ i32(*mem_ops_sp_createv) (nsfw_mem_sppool * pmpinfo, i32 inum,
+ mring_handle * pringhandle_array,
+ i32 iarray_num);
+ i32(*mem_ops_spring_create) (nsfw_mem_mring * prpoolinfo,
+ mring_handle * pringhandle_array,
+ i32 iringnum);
+ i32(*mem_ops_sp_release) (nsfw_mem_name * pname);
+ mring_handle(*mem_ops_sp_lookup) (nsfw_mem_name * pname);
+ mring_handle(*mem_ops_ring_create) (nsfw_mem_mring * pringinfo);
+ mring_handle(*mem_ops_ring_lookup) (nsfw_mem_name * pname);
+ i32(*mem_ops_ring_release) (nsfw_mem_name * pname);
+ ssize_t(*mem_ops_mem_statics) (void *handle, nsfw_mem_struct_type type);
+ i32(*mem_ops_sp_iterator) (mpool_handle handle, u32 start, u32 end,
+ nsfw_mem_item_fun fun, void *argv);
+ i32(*mem_ops_mbuf_iterator) (mpool_handle handle, u32 start, u32 end,
+ nsfw_mem_item_fun fun, void *argv);
+ i32(*mem_ops_ring_iterator) (mpool_handle handle,
+ nsfw_mem_item_fun fun, void *argv);
+ void *(*mem_ops_shddr_to_laddr) (void *addr);
+ uint64_t(*mem_ops_laddr_to_shddr) (void *addr);
+ int (*mem_ops_attach_core_id) (nsfw_mem_name * name);
+} nsfw_mem_ops;
+
+ /**/ typedef struct
+{
+ nsfw_mem_type entype;
+ nsfw_mem_ops *stmemop;
+} nsfw_mem_attr;
+
+extern nsfw_mem_attr g_nsfw_mem_ops[];
+extern i32 g_mem_type_num;
+#define SHMEM_ADDR_SHTOL(addr) (g_nsfw_mem_ops[NSFW_SHMEM].stmemop->mem_ops_shddr_to_laddr(addr))
+#define SHMEM_ADDR_LTOSH(addr) (g_nsfw_mem_ops[NSFW_SHMEM].stmemop->mem_ops_laddr_to_shddr(addr))
+#define SHMEM_PTR_SHTOL(type, addr) ((type)SHMEM_ADDR_SHTOL(addr))
+#define SHMEM_ADDR_LTOSH_EXT(addr) (SHMEM_ADDR_LTOSH(addr))
#endif
diff --git a/src/framework/include/nsfw_mgr_com_api.h b/src/framework/include/nsfw_mgr_com_api.h
index 9bbcaca..52d34bf 100644
--- a/src/framework/include/nsfw_mgr_com_api.h
+++ b/src/framework/include/nsfw_mgr_com_api.h
@@ -20,6 +20,8 @@
#ifndef _NSFW_MGRCOM_API_H
#define _NSFW_MGRCOM_API_H
+#include "types.h"
+
#ifdef __cplusplus
/* *INDENT-OFF* */
extern "C"{
@@ -32,96 +34,102 @@ extern "C"{
typedef enum _mgr_msg_type
{
- MGR_MSG_NULL = 0,
- /*#############common msg type################# */
- MGR_MSG_CHK_INIT_REQ = 1,
- MGR_MSG_INIT_NTY_REQ,
- MGR_MSG_CHK_HBT_REQ,
- MGR_MSG_APP_EXIT_REQ,
- MGR_MSG_SRV_CTL_REQ,
- MGR_MSG_VER_MGR_REQ,
- MGR_MSG_SOF_PAR_REQ,
-
- /*############################################# */
- MGR_MSG_MEM_ALLOC_REQ = 64, /* memory msg type */
-
- /*############################################# */
- MGR_MSG_DFX_QRY_REQ = 96, /* nStackCtrl maintain msg */
- MGR_MSG_SET_LOG_REQ,
-
- /*############################################# */
- MGR_MSG_RCC_END_REQ = 128, /* service msg type */
-
- /*############################################# */
- MGR_MSG_TOOL_TCPDUMP_REQ = 256, /* for tools */
- MGR_MSG_TOOL_HEART_BEAT,
-
- /*###query message with large rsp message begin## */
- MGR_MSG_LARGE_QRY_REQ_BEGIN = 384,
- MGR_MSG_LARGE_STA_QRY_REQ = MGR_MSG_LARGE_QRY_REQ_BEGIN,
- MGR_MSG_LARGE_MT_QRY_REQ, /* nStackCtrl maintain msg */
-
- /*############################################# */
- MGR_MSG_LARGE_ALARM_REQ = 500, /* alarm msg type */
-
- MGR_MSG_RSP_BASE = 512,
- /*#############common msg type################# */
- MGR_MSG_CHK_INIT_RSP = MRG_RSP (MGR_MSG_CHK_INIT_REQ),
- MGR_MSG_INIT_NTY_RSP = MRG_RSP (MGR_MSG_INIT_NTY_REQ),
- MGR_MSG_CHK_HBT_RSP = MRG_RSP (MGR_MSG_CHK_HBT_REQ),
- MGR_MSG_APP_EXIT_RSP = MRG_RSP (MGR_MSG_APP_EXIT_REQ),
- MGR_MSG_SRV_CTL_RSP = MRG_RSP (MGR_MSG_SRV_CTL_REQ),
- MGR_MSG_VER_MGR_RSP = MRG_RSP (MGR_MSG_VER_MGR_REQ),
- MGR_MSG_SOF_PAR_RSP = MRG_RSP (MGR_MSG_SOF_PAR_REQ),
- /*############################################# */
-
- MGR_MSG_MEM_ALLOC_RSP = MRG_RSP (MGR_MSG_MEM_ALLOC_REQ),
-
- MGR_MSG_DFX_QRY_RSP = MRG_RSP (MGR_MSG_DFX_QRY_REQ),
-
- MGR_MSG_SET_LOG_RSP = MRG_RSP (MGR_MSG_SET_LOG_REQ),
-
- MGR_MSG_RCC_END_RSP = MRG_RSP (MGR_MSG_RCC_END_REQ),
-
- /*############################################# */
- MGR_MSG_TOOL_TCPDUMP_RSP = MRG_RSP (MGR_MSG_TOOL_TCPDUMP_REQ),
- MGR_MSG_TOOL_HEART_BEAT_RSP = MRG_RSP (MGR_MSG_TOOL_HEART_BEAT),
-
- /*##############LARGE RSP MESSAGE################## */
- MGR_MSG_LAG_QRY_RSP_BEGIN = MRG_RSP (MGR_MSG_LARGE_QRY_REQ_BEGIN),
- MGR_MSG_LAG_STA_QRY_RSP = MRG_RSP (MGR_MSG_LARGE_STA_QRY_REQ),
- MGR_MSG_LAG_MT_QRY_RSP = MRG_RSP (MGR_MSG_LARGE_MT_QRY_REQ),
- MGR_MSG_LARGE_ALARM_RSP = MRG_RSP (MGR_MSG_LARGE_ALARM_REQ),
- MGR_MSG_MAX = 1024
+ MGR_MSG_NULL = 0,
+ /*#############common msg type################# */
+ MGR_MSG_CHK_INIT_REQ = 1,
+ MGR_MSG_INIT_NTY_REQ,
+ MGR_MSG_CHK_HBT_REQ,
+ MGR_MSG_APP_EXIT_REQ,
+ MGR_MSG_SRV_CTL_REQ,
+ MGR_MSG_VER_MGR_REQ,
+ MGR_MSG_SOF_PAR_REQ,
+ MGR_MSG_HOTFIX_REQ,
+
+ /*############################################# */
+ MGR_MSG_MEM_ALLOC_REQ = 64, /* memory msg type */
+
+ /*############################################# */
+ MGR_MSG_DFX_QRY_REQ = 96, /* nStackCtrl maitain msg */
+ MGR_MSG_SET_LOG_REQ,
+
+ /*############################################# */
+ MGR_MSG_RCC_END_REQ = 128, /* service msg type */
+
+ /*############################################# */
+ MGR_MSG_TOOL_TCPDUMP_REQ = 256, /* for tools */
+ MGR_MSG_TOOL_HEART_BEAT,
+
+ /*###query message with large rsp message begin## */
+ MGR_MSG_LARGE_QRY_REQ_BEGIN = 384,
+ MGR_MSG_LARGE_STA_QRY_REQ = MGR_MSG_LARGE_QRY_REQ_BEGIN,
+ MGR_MSG_LARGE_MT_QRY_REQ, /* nStackCtrl maitain msg */
+ MGR_MSG_SPLNET_REQ,
+
+ /*############################################# */
+ MGR_MSG_LARGE_ALARM_REQ = 500, /* alarm msg type */
+ MGR_MSG_LARGE_MT_NETSTAT, /* netstat tool */
+
+ MGR_MSG_RSP_BASE = 512,
+ /*#############common msg type################# */
+ MGR_MSG_CHK_INIT_RSP = MRG_RSP(MGR_MSG_CHK_INIT_REQ),
+ MGR_MSG_INIT_NTY_RSP = MRG_RSP(MGR_MSG_INIT_NTY_REQ),
+ MGR_MSG_CHK_HBT_RSP = MRG_RSP(MGR_MSG_CHK_HBT_REQ),
+ MGR_MSG_APP_EXIT_RSP = MRG_RSP(MGR_MSG_APP_EXIT_REQ),
+ MGR_MSG_SRV_CTL_RSP = MRG_RSP(MGR_MSG_SRV_CTL_REQ),
+ MGR_MSG_VER_MGR_RSP = MRG_RSP(MGR_MSG_VER_MGR_REQ),
+ MGR_MSG_SOF_PAR_RSP = MRG_RSP(MGR_MSG_SOF_PAR_REQ),
+ MGR_MSG_HOTFIX_RSP = MRG_RSP(MGR_MSG_HOTFIX_REQ),
+ /*############################################# */
+
+ MGR_MSG_MEM_ALLOC_RSP = MRG_RSP(MGR_MSG_MEM_ALLOC_REQ),
+
+ MGR_MSG_DFX_QRY_RSP = MRG_RSP(MGR_MSG_DFX_QRY_REQ),
+
+ MGR_MSG_SET_LOG_RSP = MRG_RSP(MGR_MSG_SET_LOG_REQ),
+
+ MGR_MSG_RCC_END_RSP = MRG_RSP(MGR_MSG_RCC_END_REQ),
+
+ /*############################################# */
+ MGR_MSG_TOOL_TCPDUMP_RSP = MRG_RSP(MGR_MSG_TOOL_TCPDUMP_REQ),
+ MGR_MSG_TOOL_HEART_BEAT_RSP = MRG_RSP(MGR_MSG_TOOL_HEART_BEAT),
+
+ /*##############LARGE RSP MESSAGE################## */
+ MGR_MSG_LAG_QRY_RSP_BEGIN = MRG_RSP(MGR_MSG_LARGE_QRY_REQ_BEGIN),
+ MGR_MSG_LAG_STA_QRY_RSP = MRG_RSP(MGR_MSG_LARGE_STA_QRY_REQ),
+ MGR_MSG_LAG_MT_QRY_RSP = MRG_RSP(MGR_MSG_LARGE_MT_QRY_REQ),
+ MGR_MSG_SPLNET_RSP = MRG_RSP(MGR_MSG_SPLNET_REQ),
+ MGR_MSG_LARGE_ALARM_RSP = MRG_RSP(MGR_MSG_LARGE_ALARM_REQ),
+ MGR_MSG_LARGE_MT_NETSTAT_RSP = MRG_RSP(MGR_MSG_LARGE_MT_NETSTAT),
+ MGR_MSG_MAX = 1024
} mgr_msg_type;
typedef enum _fw_poc_type
{
- NSFW_PROC_NULL = 0,
- NSFW_PROC_MAIN,
- NSFW_PROC_MASTER,
- NSFW_PROC_APP,
- NSFW_PROC_CTRL,
- NSFW_PROC_TOOLS,
- NSFW_PROC_ALARM,
- NSFW_PROC_MAX = 16
+ NSFW_PROC_NULL = 0,
+ NSFW_PROC_MAIN,
+ NSFW_PROC_MASTER,
+ NSFW_PROC_APP,
+ NSFW_PROC_CTRL,
+ NSFW_PROC_TOOLS,
+ NSFW_PROC_ALARM,
+ NSFW_PROC_MAX = 16
} fw_poc_type;
-#define NSFW_DOMAIN_DIR "/var/log/nStack/ip_module/"
+#define NSFW_DOMAIN_DIR "/var/run"
#define NSTACK_MAX_PROC_NAME_LEN 20
typedef enum _nsfw_mgr_msg_rsp_code
{
- NSFW_MGR_SUCCESS,
- NSFW_MGR_MSG_TYPE_ERROR,
+ NSFW_MGR_SUCESS,
+ NSFW_MGR_MSG_TYPE_ERROR,
} mgr_msg_rsp_code;
-extern char *nsfw_get_proc_name (u8 proc_type);
+extern char *nsfw_get_proc_name(u8 proc_type);
#define GET_USER_MSG(_stu, _msg) ((_stu *)(&(_msg)->msg_body[0]))
/*for log print*/
-#define MSGINFO "msg=%p,len=%d,t=%d,sq=%d,st=%d,sp=%d,dt=%d,dp=%d"
+#define MSGINFO "msg=%p,len=%u,t=%u,sq=%d,st=%u,sp=%u,dt=%u,dp=%u"
#define PRTMSG(msg) (msg), (msg)->msg_len,(msg)->msg_type,(msg)->seq, (msg)->src_proc_type,(msg)->src_pid,(msg)->dst_proc_type,(msg)->dst_pid
#define NSFW_MGR_MSG_LEN 512
@@ -131,62 +139,66 @@ extern char *nsfw_get_proc_name (u8 proc_type);
#define NSFW_MGR_LARGE_MSG_LEN (256*1024)
#define NSFW_MGR_LARGE_MSG_BODY_LEN (NSFW_MGR_LARGE_MSG_LEN - NSFW_MGR_MSG_HDR_LEN)
+/* When copy data to msg->body[], use this MACRO instead of using NSFW_MGR_MSG_BODY_LEN/NSFW_MGR_LARGE_MSG_BODY_LEN directly.
+ * Because msg's body length is various, use this MACRO will help you select the real body len*/
+#define MSG_BODY_LEN(msg) (msg->msg_len - NSFW_MGR_MSG_HDR_LEN)
+
typedef struct _nsfw_mgr_msg
{
- u16 msg_type; /* mgr_msg_type */
- u16 u16Reserve;
- u32 msg_len;
-
- u8 alloc_flag:1;
- u8 fw_flag:1;
- u8 from_mem:1;
- u8 more_msg_flag:1;
- u8 reserve_flag:4;
- u8 resp_code;
- u8 src_proc_type; /* fw_poc_type */
- u8 dst_proc_type;
- i32 seq;
-
- u32 src_pid;
- u32 dst_pid;
-
- u8 msg_body[NSFW_MGR_MSG_BODY_LEN];
+ u16 msg_type; /* mgr_msg_type */
+ u16 u16Reserve;
+ u32 msg_len;
+
+ u8 alloc_flag:1;
+ u8 fw_flag:1;
+ u8 from_mem:1;
+ u8 more_msg_flag:1;
+ u8 reserve_flag:4;
+ u8 resp_code;
+ u8 src_proc_type; /* fw_poc_type */
+ u8 dst_proc_type;
+ i32 seq;
+ u32 src_pid;
+ u32 dst_pid;
+ u64 padding;
+ u8 msg_body[NSFW_MGR_MSG_BODY_LEN];
} nsfw_mgr_msg;
-extern nsfw_mgr_msg *nsfw_mgr_msg_alloc (u16 msg_type, u8 dst_proc_type);
-extern void nsfw_mgr_msg_free (nsfw_mgr_msg * msg);
+extern nsfw_mgr_msg *nsfw_mgr_msg_alloc(u16 msg_type, u8 dst_proc_type);
+extern void nsfw_mgr_msg_free(nsfw_mgr_msg * msg);
+
+extern const char *get_home_path();
/* for rsp msg alloc*/
-extern nsfw_mgr_msg *nsfw_mgr_null_rspmsg_alloc ();
-extern nsfw_mgr_msg *nsfw_mgr_rsp_msg_alloc (nsfw_mgr_msg * req_msg);
+extern nsfw_mgr_msg *nsfw_mgr_null_rspmsg_alloc();
+extern nsfw_mgr_msg *nsfw_mgr_rsp_msg_alloc(nsfw_mgr_msg * req_msg);
/* for msg proc fun reg*/
typedef int (*nsfw_mgr_msg_fun) (nsfw_mgr_msg * msg);
-extern u8 nsfw_mgr_reg_msg_fun (u16 msg_type, nsfw_mgr_msg_fun fun);
+extern u8 nsfw_mgr_reg_msg_fun(u16 msg_type, nsfw_mgr_msg_fun fun);
-extern u8 nsfw_mgr_send_msg (nsfw_mgr_msg * msg);
-extern u8 nsfw_mgr_send_req_wait_rsp (nsfw_mgr_msg * req_msg,
- nsfw_mgr_msg * rsp_msg);
+extern u8 nsfw_mgr_send_msg(nsfw_mgr_msg * msg);
+extern u8 nsfw_mgr_send_req_wait_rsp(nsfw_mgr_msg * req_msg,
+ nsfw_mgr_msg * rsp_msg);
/* for fork clear parent resource*/
-extern void nsfw_mgr_close_dst_proc (u8 proc_type, u32 dst_pid);
-extern u8 nsfw_mgr_clr_fd_lock ();
+extern void nsfw_mgr_close_dst_proc(u8 proc_type, u32 dst_pid);
+extern u8 nsfw_mgr_clr_fd_lock();
/* for epoll thread reg other sock proc fun*/
typedef int (*nsfw_mgr_sock_fun) (i32 epfd, i32 socket, u32 events);
-extern u8 nsfw_mgr_reg_sock_fun (i32 socket, nsfw_mgr_sock_fun fun);
-extern void nsfw_mgr_unreg_sock_fun (i32 socket);
-extern int nsfw_mgr_com_socket_error (i32 fd, nsfw_mgr_sock_fun fun,
- i32 timer);
-extern u8 nsfw_mgr_ep_start ();
-extern int nsfw_mgr_com_module_init (void *param);
-extern int nsfw_mgr_run_script (const char *cmd, char *result,
- int result_buf_len);
-
-extern int nsfw_mgr_com_chk_hbt (int v_add);
-extern i32 nsfw_set_close_on_exec (i32 sock);
-extern int nsfw_mgr_comm_fd_init (u32 proc_type);
-extern void nsfw_mgr_com_mkdir_domainpath (char *pathname);
+extern u8 nsfw_mgr_reg_sock_fun(i32 socket, nsfw_mgr_sock_fun fun);
+extern void nsfw_mgr_unreg_sock_fun(i32 socket);
+extern int nsfw_mgr_com_socket_error(i32 fd, nsfw_mgr_sock_fun fun,
+ i32 timer);
+extern int nsfw_mgr_com_module_init(void *param);
+extern int nsfw_mgr_run_script(const char *cmd, char *result,
+ int result_buf_len);
+
+extern int nsfw_mgr_com_chk_hbt(int v_add);
+/* close on exec */
+extern i32 nsfw_set_close_on_exec(i32 sock);
+extern int nsfw_mgr_comm_fd_init(u32 proc_type);
#ifdef __cplusplus
/* *INDENT-OFF* */
diff --git a/src/framework/include/nsfw_ps_api.h b/src/framework/include/nsfw_ps_api.h
index 69fa992..36a64ee 100644
--- a/src/framework/include/nsfw_ps_api.h
+++ b/src/framework/include/nsfw_ps_api.h
@@ -18,6 +18,7 @@
#define _NSFW_PS_API_H
#include "list.h"
+#include "compiling_check.h"
#ifdef __cplusplus
/* *INDENT-OFF* */
extern "C"{
@@ -29,101 +30,109 @@ extern "C"{
#define NSFW_PS_MAX_CALLBACK 16
#define NSFW_MAX_HBT_CHK_COUNT_DEF 60
+#define NSFW_MAX_PID 65535
+COMPAT_PROTECT_RETURN(NSFW_MAX_PID, 65535);
typedef enum _nsfw_ps_state
{
- NSFW_PS_NULL = 0,
- NSFW_PS_START,
- NSFW_PS_RUNNING,
- NSFW_PS_PARENT_FORK,
- NSFW_PS_CHILD_FORK,
- NSFW_PS_HBT_FAILED,
- NSFW_PS_EXITING,
- NSFW_PS_EXIT,
- NSFW_PS_MAX
+ NSFW_PS_NULL = 0,
+ NSFW_PS_START,
+ NSFW_PS_RUNNING,
+ NSFW_PS_PARENT_FORK,
+ NSFW_PS_CHILD_FORK,
+ NSFW_PS_HBT_FAILED,
+ NSFW_PS_EXITING,
+ NSFW_PS_EXIT,
+ NSFW_PS_MAX
} nsfw_ps_state;
/* for state change call back proc*/
typedef int (*nsfw_ps_proc_fun) (void *pps_info, void *argv);
typedef struct _nsfw_ps_callback
{
- u8 state;
- nsfw_ps_proc_fun fun;
- void *argv;
+ u8 state;
+ nsfw_ps_proc_fun fun;
+ void *argv;
} nsfw_ps_callback;
/* for value in ps_info get/set*/
typedef enum _nsfw_ps_user_value
{
- NSFW_REC_IDX = 1,
- NSFW_REC_TIMER = 2,
- NSFW_PS_UV_MAX = 16
+ NSFW_REC_IDX = 1,
+ NSFW_REC_TIMER = 2,
+ NSFW_PS_UV_MAX = 16
} nsfw_ps_user_value;
#define nsfw_ps_set_uv(_pps_info, _type, _value) (_pps_info)->value[(_type)] = (_value)
#define nsfw_ps_get_uv(_pps_info, _type) ((_pps_info)->value[(_type)])
typedef struct _nsfw_ps_info
{
- struct list_head node;
- u8 alloc_flag;
- u8 state; /*nsfw_ps_state */
- u8 proc_type; /*fw_poc_type */
- u8 rechk_flg;
- u32 host_pid;
- u32 parent_pid; /* only use for fork */
- u32 cur_child_pid; /* only use for fork */
- void *exit_timer_ptr;
- void *resend_timer_ptr;
- void *hbt_timer_ptr;
- u32 hbt_failed_count;
- nsfw_ps_callback callback[NSFW_PS_MAX_CALLBACK];
- void *value[NSFW_PS_UV_MAX];
+ struct list_head node;
+ u8 alloc_flag;
+ u8 state; /*nsfw_ps_state */
+ u8 proc_type; /*fw_poc_type */
+ u8 rechk_flg;
+ u32 host_pid;
+ u32 parent_pid; /* only use for fork */
+ u32 cur_child_pid; /* only use for fork */
+ void *exit_timer_ptr;
+ void *resend_timer_ptr;
+ void *hbt_timer_ptr;
+ u32 hbt_failed_count;
+ nsfw_ps_callback callback[NSFW_PS_MAX_CALLBACK];
+ void *value[NSFW_PS_UV_MAX];
} nsfw_ps_info;
typedef struct _nsfw_thread_dogs
{
- u8 alloc_flag;
- i32 count;
- u32 thread_id;
+ u8 alloc_flag;
+ i32 count;
+ u32 thread_id;
} nsfw_thread_dogs;
-extern nsfw_ps_info *nsfw_ps_info_alloc (u32 pid, u8 proc_type);
-extern nsfw_ps_info *nsfw_ps_info_get (u32 pid);
-extern void nsfw_ps_info_free (nsfw_ps_info * ps_info);
+extern nsfw_ps_info *nsfw_ps_info_alloc(u32 pid, u8 proc_type,
+ u8 realloc_flg);
+extern nsfw_ps_info *nsfw_ps_info_get(u32 pid);
+extern void nsfw_ps_info_free(nsfw_ps_info * ps_info);
-extern u8 nsfw_ps_reg_fun (nsfw_ps_info * pps_info, u8 ps_state,
- nsfw_ps_proc_fun fun, void *argv);
+extern u8 nsfw_ps_reg_fun(nsfw_ps_info * pps_info, u8 ps_state,
+ nsfw_ps_proc_fun fun, void *argv);
/* will auto reg after ps_info alloc*/
-extern u8 nsfw_ps_reg_global_fun (u8 proc_type, u8 ps_state,
- nsfw_ps_proc_fun fun, void *argv);
+extern u8 nsfw_ps_reg_global_fun(u8 proc_type, u8 ps_state,
+ nsfw_ps_proc_fun fun, void *argv);
typedef struct _nsfw_ps_info_msg
{
- u32 host_pid;
- u32 parent_pid;
- u64 reserve;
+ u32 host_pid;
+ u32 parent_pid;
+ u64 reserve;
} nsfw_ps_info_msg;
-extern u8 nsfw_ps_exit_end_notify (u32 pid);
+extern u8 nsfw_ps_exit_end_notify(u32 pid);
/*for heartbeat check*/
-extern u8 nsfw_ps_check_dst_init (u8 dst_proc_type);
-extern u8 nsfw_thread_chk ();
-extern nsfw_thread_dogs *nsfw_thread_getDog ();
-extern u8 nsfw_thread_chk_unreg ();
-extern u8 nsfw_ps_hbt_start (nsfw_ps_info * ps_info);
-extern u8 nsfw_ps_hbt_stop (nsfw_ps_info * ps_info);
+extern u8 nsfw_ps_check_dst_init(u8 dst_proc_type);
+extern u8 nsfw_thread_chk();
+extern nsfw_thread_dogs *nsfw_thread_get_dog();
+extern u8 nsfw_thread_chk_unreg();
+extern u8 nsfw_ps_hbt_start(nsfw_ps_info * ps_info);
+extern u8 nsfw_ps_hbt_stop(nsfw_ps_info * ps_info);
-extern u32 nsfw_ps_iterator (nsfw_ps_proc_fun fun, void *argv);
+extern u32 nsfw_ps_iterator(nsfw_ps_proc_fun fun, void *argv);
+/* print bt */
#define MAX_THREAD 16
extern pthread_t g_all_thread[];
-extern u8 nsfw_reg_trace_thread (pthread_t tid);
+extern u8 nsfw_reg_trace_thread(pthread_t tid);
typedef int (*nsfw_ps_pid_fun) (u32 pid, u8 proc_type, void *argv);
-extern int nsfw_ps_rechk_pid_exit (nsfw_ps_pid_fun fun, void *argv);
-extern nsfw_ps_info *nsfw_share_ps_info_get (u32 pid);
-extern void nsfw_ps_cfg_set_chk_count (u16 count);
+extern int nsfw_ps_rechk_pid_exit(nsfw_ps_pid_fun fun, void *argv);
+extern nsfw_ps_info *nsfw_share_ps_info_get(u32 pid);
+extern void nsfw_ps_cfg_set_chk_count(u16 count);
+
+extern int nsfw_ps_check_pid_nstack_status(int pid);
+extern u64 nsfw_ps_get_starttime_from_file(u32 pid);
+extern u64 nsfw_ps_get_starttime_from_info(u32 pid);
#ifdef __cplusplus
/* *INDENT-OFF* */
diff --git a/src/framework/include/nsfw_recycle_api.h b/src/framework/include/nsfw_recycle_api.h
index 9d7f3bb..35ba388 100644
--- a/src/framework/include/nsfw_recycle_api.h
+++ b/src/framework/include/nsfw_recycle_api.h
@@ -17,6 +17,8 @@
#ifndef _NSFW_RECYCLE_API_H
#define _NSFW_RECYCLE_API_H
+#include "types.h"
+
#ifdef __cplusplus
/* *INDENT-OFF* */
extern "C"{
@@ -27,40 +29,40 @@ extern "C"{
typedef enum _nsfw_recycle_item_type
{
- NSFW_REC_TYPE_NULL = 0,
- NSFW_REC_SBR_START = 1,
- NSFW_REC_SBR_SOCKET,
- NSFW_REC_SBR_END = NSFW_REC_SBR_START + 63,
- NSFW_REC_NSOCKET_START,
- NSFW_REC_NSOCKET_EPOLL,
- NSFW_REC_NSOCKET_END = NSFW_REC_NSOCKET_START + 63,
- NSFW_REC_TYPE_MAX = 512
+ NSFW_REC_TYPE_NULL = 0,
+ NSFW_REC_SBR_START = 1,
+ NSFW_REC_SBR_SOCKET,
+ NSFW_REC_SBR_END = NSFW_REC_SBR_START + 63,
+ NSFW_REC_NSOCKET_START,
+ NSFW_REC_NSOCKET_EPOLL,
+ NSFW_REC_NSOCKET_END = NSFW_REC_NSOCKET_START + 63,
+ NSFW_REC_TYPE_MAX = 512
} nsfw_recycle_item_type;
typedef enum _nsfw_recycle_priority
{
- NSFW_REC_PRO_HIGHTEST = 0,
- NSFW_REC_PRO_NORMAL = 1,
- NSFW_REC_PRO_DEFAULT = 2,
- NSFW_REC_PRO_LOWEST = 3,
- NSFW_REC_PRO_MAX = 4
+ NSFW_REC_PRO_HIGHTEST = 0,
+ NSFW_REC_PRO_NORMAL = 1,
+ NSFW_REC_PRO_DEFALUT = 2,
+ NSFW_REC_PRO_LOWEST = 3,
+ NSFW_REC_PRO_MAX = 4
} nsfw_recycle_priority;
typedef enum _nsfw_rcc_stat
{
- NSFW_RCC_CONTINUE = 0,
- NSFW_RCC_SUSPEND = 1,
- NSFW_RCC_FAILED = 2,
+ NSFW_RCC_CONTINUE = 0,
+ NSFW_RCC_SUSPEND = 1,
+ NSFW_RCC_FAILED = 2,
} nsfw_rcc_stat;
-/*work on nStackMain*/
-typedef nsfw_rcc_stat (*nsfw_recycle_fun) (u32 exit_pid, void *pdata,
- u16 rec_type);
-extern u8 nsfw_recycle_reg_fun (u16 obj_type, nsfw_recycle_fun fun);
-extern u8 nsfw_recycle_obj_end (u32 pid);
-extern u8 nsfw_recycle_lock_rel_fun (nsfw_recycle_fun fun, void *data,
- u8 proc_type);
-extern int nsfw_recycle_exit_pid_lock (u32 pid, u8 proc_type, void *argv);
+/*work on daemon-stack*/
+typedef nsfw_rcc_stat(*nsfw_recycle_fun) (u32 exit_pid, void *pdata,
+ u16 rec_type);
+extern u8 nsfw_recycle_reg_fun(u16 obj_type, nsfw_recycle_fun fun);
+extern u8 nsfw_recycle_obj_end(u32 pid);
+extern u8 nsfw_recycle_lock_rel_fun(nsfw_recycle_fun fun, void *data,
+ u8 proc_type);
+extern int nsfw_recycle_exit_pid_lock(u32 pid, u8 proc_type, void *argv);
#define REGIST_RECYCLE_OBJ_FUN(_obj_type, _fun) \
NSTACK_STATIC void regist_ ## _obj_type ## _fun (void) \
@@ -79,9 +81,9 @@ extern int nsfw_recycle_exit_pid_lock (u32 pid, u8 proc_type, void *argv);
}
/*work on nStackApp*/
-extern void *nsfw_recycle_reg_obj (u8 priority, u16 rec_type, void *data);
-extern u8 nsfw_recycle_fork_init ();
-extern int nsfw_recycle_rechk_lock ();
+extern void *nsfw_recycle_reg_obj(u8 priority, u16 rec_type, void *data);
+extern u8 nsfw_recycle_fork_init();
+extern int nsfw_recycle_rechk_lock();
#ifdef __cplusplus
/* *INDENT-OFF* */
diff --git a/src/framework/include/nsfw_ring_data.h b/src/framework/include/nsfw_ring_data.h
new file mode 100644
index 0000000..cafffe0
--- /dev/null
+++ b/src/framework/include/nsfw_ring_data.h
@@ -0,0 +1,99 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#ifndef _NSFW_RING_DATA_H_
+#define _NSFW_RING_DATA_H_
+
+#include <stdint.h>
+#include "types.h"
+
+#define VALUE_LEN 40
+
+/*
+Ring Data has two part; Ver&Data
+val is a pointer offset base on rtp_perf_ring::Addrbase, this struct support 1TB, it's enough now;
+future __int128 maybe used, this type can perfectly solve the version & address rang problem.
+*/
+union RingData_U
+{
+ struct RingData_S
+ {
+ /*
+ value of data, indeed it's a pointer offset base on rtp_perf_ring::Addrbase;40bit is enough for user space addr
+ ver must using 24bit, so val using 40bit; a CAS now just support 64bit; in future, we may using __int128,now __int128 not support well.
+ */
+ volatile unsigned long long val:VALUE_LEN;
+ /*
+ version of data, using 16b store version flg is more suitable for Address save, but using 16b version is too short, it's value range is [0-65535];
+ between two cpu schedule time (TM-SPACE) of one process/thread, other processes/threads do N times queue oper. if N > 65535, still have a chance of ABA.
+ if using a 24bit save version flg, if ABA happened, 16777216 times queue oper need done in one TM-SPACE, it's impossible for today cpu.
+ */
+ volatile unsigned long long ver:(64 - VALUE_LEN);
+ } data_s;
+ u64 data_l;
+};
+
+/*
+ this high perf Ring rely on the init value of Ring Slot;
+ Ring Must init using PerfRingInit, Pool Must init using PerfPoolInit
+
+ the addrbase is base addr for all element; now we support 1024G offset;
+ for nstack the Ring element is from hugepage, and the addr is in stack space.
+
+ 1. not support a ring who's element space range bigger than 1024GB
+ [if one element from heep, one from stack, range will bigger than 1024GB, we not support]
+ 2. one more thing addr from mmap is in stack
+ 3. rtp_perf_ring must create by rtp_perf_ring_create/rtp_perf_pool_create
+*/
+struct nsfw_mem_ring
+{
+ u8 memtype; //shared, no shared
+ u8 ringflag; //scmp, scsp, mcsp,mcmp
+ u16 overflow_count; //reserv data
+ u32 size; //size of the Ring, must 2^n
+ u32 eltsize; //for sppool, it is the size of per buf, if is ring, eltsize is zero.
+ u32 mask; //mask of the Ring, used mask mod Head/Tail to get real pos, must 2^n-1
+ void *Addrbase; /*Cause the Addr we support just 40b(1024G), we using a basAddr+offset to get the real addr; ring[x].data_s.val just store offset;
+ * not used when no shared mode
+ */
+ volatile u32_t prodhflag; //for nshmem fork recover
+ volatile u32_t prodtflag; //for nshmem fork recover
+ volatile u32_t conshflag; //for nshmem fork recover
+ volatile u32_t constflag; //for nshmem fork recover
+ nsfw_res res_chk;
+
+ struct
+ {
+ volatile u32 head; //Head of the Ring, used to indicat pos where to pull a val
+ volatile u32 tail; //for nshmem, shmem not used.
+ } prod;
+ struct
+ {
+ volatile u32 head; //for nshmem, shmem not used.
+ volatile u32 tail; //Tail of the Ring, used to indicat pos where to push a val
+ } cons;
+ struct timeval overflow_time;
+
+ union RingData_U ring[0]; //Value of Ring
+
+};
+
+#define PERFRING_ADDR_RANGE (0xFFFFFFFFFFL)
+#define PERFRING_HEAD_INCRASE_MASK (0x03)
+
+#define PERFRING_HEAD_INCRASE_VALUE (PERFRING_HEAD_INCRASE_MASK+1)
+
+#endif /*_NSFW_RING_DATA_H_*/
diff --git a/src/framework/include/nsfw_ring_fun.h b/src/framework/include/nsfw_ring_fun.h
new file mode 100644
index 0000000..f93a59d
--- /dev/null
+++ b/src/framework/include/nsfw_ring_fun.h
@@ -0,0 +1,114 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#ifndef _NSFW_RING_FUN_H_
+#define _NSFW_RING_FUN_H_
+
+#include <stdint.h>
+#include "nsfw_mem_api.h"
+#include "nsfw_ring_data.h"
+#include "nsfw_branch_prediction.h"
+#include "pid_common.h"
+
+/*
+ for nstack I advise addrbase set to lowest of mmaped hugepage Addr.
+ to simple:
+ 1. ring element is from mmaped mem, set Addrbase to 0x7fffffffffff - 0xffffffffff is OK;
+ 1. ring element is from heap, set Addrbase to NULL is ok;
+*/
+static inline void nsfw_mem_ring_init(struct nsfw_mem_ring *ring,
+ unsigned int size, void *addrbase,
+ unsigned char memtype,
+ unsigned char flag)
+{
+ unsigned int loop = 0;
+
+ if (!ring)
+ {
+ return;
+ }
+
+ ring->prod.head = 0;
+ ring->prod.tail = 0;
+ ring->cons.head = 0;
+ ring->cons.tail = 0;
+ ring->size = size;
+ ring->eltsize = 0;
+ ring->mask = size - 1;
+ ring->memtype = memtype;
+ ring->ringflag = flag;
+ ring->prodtflag = ring->prodhflag = get_sys_pid();
+ ring->conshflag = ring->constflag = get_sys_pid();
+ /*if shmem, addrbase already changed to primary memory address */
+ ring->Addrbase = addrbase;
+
+ ring->overflow_count = 0;
+ ring->overflow_time.tv_sec = 0;
+ ring->overflow_time.tv_usec = 0;
+
+ /*init Ring */
+ for (loop = 0; loop < size; loop++)
+ {
+ /*
+ for a empty ring, version is the mapping head val - size
+ so the empty ring's ver is loop-size;
+ */
+ ring->ring[loop].data_s.ver = (loop - size);
+ ring->ring[loop].data_s.val = 0;
+ }
+}
+
+/*
+another way to init Pool while no continuous space
+1. init a empt rtp_perf_ring
+2. add element to PerRing.
+*/
+static inline void nsfw_mem_pool_head_init(struct nsfw_mem_ring *ring,
+ unsigned int size,
+ unsigned int eltsize,
+ void *addrbase,
+ nsfw_mem_type memtype,
+ nsfw_mpool_type flag)
+{
+ ring->prod.head = size;
+ ring->prod.tail = size;
+ ring->cons.head = 0;
+ ring->cons.tail = 0;
+ ring->size = size;
+ ring->eltsize = eltsize;
+ ring->mask = size - 1;
+ ring->memtype = memtype;
+ ring->ringflag = flag;
+ ring->prodtflag = ring->prodhflag = get_sys_pid();
+ ring->conshflag = ring->constflag = get_sys_pid();
+ /*if shmem, addrbase already changed to primary memory address */
+ ring->Addrbase = addrbase;
+ ring->overflow_count = 0;
+ ring->overflow_time.tv_sec = 0;
+ ring->overflow_time.tv_usec = 0;
+
+ return;
+}
+
+#define NSFW_RING_FLAG_CHECK_RET(handle, desc) {\
+ if (((struct nsfw_mem_ring*)mhandle)->ringflag >= NSFW_MPOOL_TYPEMAX) \
+ { \
+ NSRTP_LOGERR("invalid ring]desc=%s,ringflag=%d", desc, ((struct nsfw_mem_ring*)mhandle)->ringflag); \
+ return 0; \
+ } \
+ }
+
+#endif /*_NSFW_RING_FUN_H_*/
diff --git a/src/framework/include/nsfw_snapshot.h b/src/framework/include/nsfw_snapshot_api.h
index 5ce64aa..46df683 100644
--- a/src/framework/include/nsfw_snapshot.h
+++ b/src/framework/include/nsfw_snapshot_api.h
@@ -14,12 +14,11 @@
* limitations under the License.
*/
-#ifndef _FW_SNAPSHOT_H
-#define _FW_SNAPSHOT_H
+#ifndef _NSFW_SNAPSHOT_API_H
+#define _NSFW_SNAPSHOT_API_H
#include <stdlib.h>
#include "types.h"
-#include "../snapshot/fw_ss_tlv.h"
#ifdef __cplusplus
/* *INDENT-OFF* */
@@ -51,76 +50,86 @@ extern "C"{
/*
* This structure tells how to describe one object and its members
*/
-typedef struct _nsfw_ss_objMemDesc
+typedef struct _nsfw_ss_obj_mem_desc
{
- u16 type; // object type(7 bits) | member type (7 bits) | is object(1 bit) | is array(1 bit)
- u32 length;
- u8 offset;
-} nsfw_ss_objMemDesc_t;
+ u16 type; // object type(7 bits) | member type (7 bits) | is object(1 bit) | is array(1 bit)
+ u32 length;
+ u8 offset;
+} nsfw_ss_obj_mem_desc_t;
-typedef struct _nsfw_ss_objDesc
+typedef struct _nsfw_ss_obj_desc
{
- u16 objType; /* Type number of object */
- u8 memNum; /* Nubmer of object members */
- u32 objSize;
- nsfw_ss_objMemDesc_t *memDesc; /* Member descript */
-} nsfw_ss_objDesc_t;
+ u16 objType; /* Type number of object */
+ u8 memNum; /* Nubmer of object members */
+ u32 objSize;
+ nsfw_ss_obj_mem_desc_t *memDesc; /* Member descripe */
+} nsfw_ss_obj_desc_t;
#define NSFW_SS_MAX_OBJDESC_NUM 256
/* Traversal, you can save the current value to start the search, do not need to start from the beginning of the search, because the value is generally a sequential */
-typedef struct _nsfw_ss_objDescManager
+typedef struct _nsfw_ss_obj_desc_manager
{
- nsfw_ss_objDesc_t *g_nsfw_ss_objDescs[NSFW_SS_MAX_OBJDESC_NUM];
- int g_nsfw_ss_objDesNum;
-} nsfw_ss_objDescManager_t;
+ nsfw_ss_obj_desc_t *g_nsfw_ss_obj_descs[NSFW_SS_MAX_OBJDESC_NUM];
+ int g_nsfw_ss_obj_des_num;
+} nsfw_ss_obj_desc_manager_t;
-extern nsfw_ss_objDescManager_t g_nsfw_ss_objDescManager;
+/* package the parameters to a struct */
+typedef struct _nsfw_ss_obj_restore
+{
+ void *objMem; /*memory of object */
+ void *mem; /*memory of storage */
+ u32 storeMemLen; /*maximal length of storage memory */
+ u32 reserved;
+} nsfw_ss_obj_restore_t;
+
+extern nsfw_ss_obj_desc_manager_t g_nsfw_ss_obj_desc_manager;
-#define nsfw_ss_getObjDescManagerInst() (&g_nsfw_ss_objDescManager)
+#define nsfw_ss_get_obj_desc_manager_inst() (&g_nsfw_ss_obj_desc_manager)
/**
- * @Function nsfw_ss_register_ObjDesc
- * @Description Register object description to snapshot
+ * @Function nsfw_ss_registe_ObjDesc
+ * @Description Registe object description to snapshot
* @param objDesc - description of object
* @return void
*/
-extern void nsfw_ss_register_ObjDesc (nsfw_ss_objDesc_t * objDesc);
+extern void nsfw_ss_register_obj_desc(nsfw_ss_obj_desc_t * objDesc);
/**
* @Function nsfw_ss_store
* @Description store object to memory
* @param (in) objType - type of object
- * @param (in) obj - address of object memory
+ * @param (in) obj - adderss of object memory
* @param (in) storeMem - address of memory to store object data
* @param (in) storeMemLen - maximal length of storage memory
* @return positive integer means length of memory cost on success. return -1 if error
*/
-extern int nsfw_ss_store (u16 objType, void *obj, void *storeMem,
- u32 storeMemLen);
+extern int nsfw_ss_store(u16 objType, void *obj, void *storeMem,
+ u32 storeMemLen);
/**
* @Function nsfw_ss_restore
* @Description restore object from memory
- * @param (in) objMem - memory of object
- * @param (in) mem - memory of storage
- * @param (in) storeMemLen - maximal length of storage memory
+ * @param (in) obj_res - memory of object/storage memory info
+ * @param (in) count - recursion max num
* @return positive integer stands on object type, -1 on error
*/
-extern int nsfw_ss_restore (void *objMem, void *mem, u32 storeMemLen);
+extern int nsfw_ss_restore(nsfw_ss_obj_restore_t * obj_res);
/**
- * @Function nsfw_ss_getObjStoreMemLen
+ * @Function nsfw_ss_get_obj_store_mem_len
* @Description Get the maximal memory it needs
* @param (in) objType - type of object
* @return length of memory needs, -1 if error
*/
-extern int nsfw_ss_getObjStoreMemLen (int objType);
+extern int nsfw_ss_get_obj_store_mem_len(int objType);
#define _NSFW_SNAPSHOT_OBJDESC_REGISTER_SURFIX(_value, _surfix) \
+ \
static __attribute__((__constructor__(121))) void nsfw_snapshot_objdesc_register_constructor##_surfix(void){\
- nsfw_ss_register_ObjDesc((_value));\
+ nsfw_ss_register_obj_desc((_value));\
+ \
}
#define NSFW_SNAPSHOT_OBJDESC_REGISTER_SURFIX(_value, _surfix) \
@@ -130,7 +139,7 @@ extern int nsfw_ss_getObjStoreMemLen (int objType);
NSFW_SNAPSHOT_OBJDESC_REGISTER_SURFIX(_value, __LINE__)
/**
- * Using this macro to register object description
+ * Using this marcro to register object description
*/
#define NSFW_SS_REGSITER_OBJDESC(_value) \
NSFW_SNAPSHOT_OBJDESC_REGISTER_UNIQUE(_value)
diff --git a/src/framework/include/nsfw_upgrade.h b/src/framework/include/nsfw_upgrade.h
index d5cb5aa..a4e809c 100644
--- a/src/framework/include/nsfw_upgrade.h
+++ b/src/framework/include/nsfw_upgrade.h
@@ -32,9 +32,9 @@ extern "C" {
#define USE_MEM_BIT(mem_bit, struct, mem) (mem_bit |= ((i64)1 << struct ## _ ## mem))
-#define UPGRADE_MEM_VAL(mem_bit, struct, mem, obj, default) { \
+#define UPGRADE_MEM_VAL(mem_bit, struct, mem, obj, defalut) { \
if (!GET_MEM_BIT(mem_bit, struct, mem)){ \
- obj->mem = default; \
+ obj->mem = defalut; \
} \
}
diff --git a/src/framework/include/nstack_log.h b/src/framework/include/nstack_log.h
deleted file mode 100644
index 9473aa4..0000000
--- a/src/framework/include/nstack_log.h
+++ /dev/null
@@ -1,474 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _NSTACK_LOG_H_
-#define _NSTACK_LOG_H_
-/*==============================================*
- * include header files *
- *----------------------------------------------*/
-#pragma GCC diagnostic ignored "-Wcpp"
-#include <stdio.h>
-#include <string.h>
-#include <stdint.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include <unistd.h>
-#include <sys/syscall.h>
-#include <sys/types.h>
-#include <signal.h>
-#include "types.h"
-
-#include "glog/nstack_glog.ph"
-#include "glog/nstack_glog_in.h"
-
-#define NSTACK_GETVER_MODULE "nStack"
-
-#ifndef NSTACK_GETVER_VERSION
-#error "need define version first"
-#endif
-
-#define NSTACK_GETVER_BUILDTIME "[" __DATE__ "]" "[" __TIME__ "]"
-#define NSTACK_VERSION NSTACK_GETVER_VERSION " (" NSTACK_GETVER_MODULE ") " NSTACK_GETVER_BUILDTIME
-
-#define LOG_TIME_STAMP_LEN 17 // "YYYYMMDDHHMMSS";
-
-/*==============================================*
- * constants or macros define *
- *----------------------------------------------*/
-typedef enum _LOG_MODULE
-{
- NSOCKET = 1,
- STACKX,
- OPERATION,
- MASTER,
- LOGTCP,
- LOGUDP,
- LOGIP,
- LOGCMP,
- LOGARP,
- LOGRTE,
- LOGHAL,
- LOGDFX,
- LOGFW,
- LOGSBR,
- MAX_LOG_MODULE
-} LOG_MODULE;
-
-enum _LOG_TYPE
-{
- LOG_TYPE_NSTACK = 0,
- LOG_TYPE_OPERATION,
- LOG_TYPE_MASTER,
- LOG_TYPE_APP,
- MAX_LOG_TYPE
-};
-
-enum _LOG_PROCESS
-{
- LOG_PRO_NSTACK = 0,
- LOG_PRO_MASTER,
- LOG_PRO_APP,
- LOG_PRO_OMC_CTRL,
- LOG_PRO_INVALID
-};
-
-#define LOG_INVALID_VALUE 0xFFFF
-
-#define NSLOG_DBG 0x10
-#define NSLOG_INF 0x08
-#define NSLOG_WAR 0x04
-#define NSLOG_ERR 0x02
-#define NSLOG_EMG 0x01
-#define NSLOG_OFF 0x00
-
-#define LOG_LEVEL_EMG "emg"
-#define LOG_LEVEL_ERR "err"
-#define LOG_LEVEL_WAR "war"
-#define LOG_LEVEL_DBG "dbg"
-#define LOG_LEVEL_INF "inf"
-
-#define GET_FILE_NAME(name_have_path) strrchr(name_have_path,'/')?strrchr(name_have_path,'/')+1:name_have_path
-
-#define NSTACK_LOG_NAME "/var/log/nStack/"
-
-#define STACKX_LOG_NAME "running.log"
-
-#define OPERATION_LOG_NAME "operation.log"
-
-#define MASTER_LOG_NAME "master.log"
-
-#define OMC_CTRL_LOG_NAME "omc_ctrl.log"
-
-#define FAILURE_LOG_NAME "fail_dump.log"
-
-#define FLUSH_TIME 10
-
-#define APP_LOG_SIZE 30
-#define APP_LOG_COUNT 10
-#define APP_LOG_PATH "/var/log"
-#define APP_LOG_NAME "nStack_nSocket.log"
-
-#define NS_LOG_STACKX_ON 0x80U
-#define NS_LOG_STACKX_TRACE 0x40U
-#define NS_LOG_STACKX_STATE 0x20U
-#define NS_LOG_STACKX_FRESH 0x10U
-#define NS_LOG_STACKX_HALT 0x08U
-#define NS_LOG_STACKX_OFF 0x00U
-
-#define NULL_STRING ""
-#define MODULE_INIT_FORMAT_STRING "module %s]name=[%s]%s"
-#define MODULE_INIT_START "init"
-#define MODULE_INIT_FAIL "start failed"
-#define MODULE_INIT_SUCCESS "start success"
-
-#define PRE_INIT_LOG_LENGTH 128
-
-struct nstack_logs
-{
- uint32_t level; /**< Log level. */
- int pad64;
- int inited;
- int file_type;
-};
-
-struct log_init_para
-{
- uint32_t run_log_size;
- uint32_t run_log_count;
- char *run_log_path;
- uint32_t mon_log_size; //master and ctrl both use the parameter to reduce the redundancy
- uint32_t mon_log_count; //master and ctrl both use the parameter to reduce the redundancy
- char *mon_log_path; //master and ctrl both use the parameter to reduce the redundancy
-};
-
-enum LOG_CTRL_ID
-{
- // for socket api
- LOG_CTRL_SEND = 0,
- LOG_CTRL_RECV,
- LOG_CTRL_SENDMSG,
- LOG_CTRL_RECVMSG,
- LOG_CTRL_READ,
- LOG_CTRL_WRITE,
- LOG_CTRL_READV,
- LOG_CTRL_WRITEV,
- LOG_CTRL_GETSOCKNAME,
- LOG_CTRL_GETPEERNAME,
- LOG_CTRL_GETSOCKOPT,
-
- // for nstack service
- LOG_CTRL_RECV_QUEUE_FULL,
- LOG_CTRL_L4_RECV_QUEUE_FULL,
- LOG_CTRL_HUGEPAGE_ALLOC_FAIL,
- LOG_CTRL_TCP_MEM_NOT_ENOUGH,
- LOG_CTRL_IPREASS_OVERFLOW,
- LOG_CTRL_ID_MAX
-};
-
-struct log_ctrl_info
-{
- u32 expire_time;
- u32 unprint_count;
- struct timespec last_log_time;
-};
-
-struct pre_init_info
-{
- uint32_t level; /**< Log level. */
- char log_buffer[PRE_INIT_LOG_LENGTH];
-};
-
-#define NS_LOG_STACKX(dbug,_module,_prestr,_level,fmt, ...) \
-{\
- if ((dbug) & NS_LOG_STACKX_ON)\
- {\
- NS_LOGPID(_module,_prestr,_level,fmt,##__VA_ARGS__);\
- }\
-}\
-
-
-/*****************************************************************************
-* Prototype : nstack_get_log_level
-* Description : get log level
-* Input : int module
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*****************************************************************************/
-extern struct nstack_logs g_nstack_logs[MAX_LOG_MODULE];
-static inline int
-nstack_get_log_level (int module)
-{
- /* validity check for path */
- if ((MAX_LOG_MODULE <= module) || (module < 0))
- {
- return -1;
- }
-
- return g_nstack_logs[module].level;
-}
-
-/*****************************************************************************
-* Prototype : level_stoa
-* Description : convert stack log level to app log level
-* Input : unsigned int nstack_level
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*****************************************************************************/
-static inline unsigned int
-level_stoa (unsigned int level)
-{
- unsigned int golg_level;
- switch (level)
- {
- case NSLOG_DBG:
- golg_level = GLOG_LEVEL_DEBUG;
- break;
- case NSLOG_INF:
- golg_level = GLOG_LEVEL_INFO;
- break;
- case NSLOG_WAR:
- golg_level = GLOG_LEVEL_WARNING;
- break;
- case NSLOG_ERR:
- golg_level = GLOG_LEVEL_ERROR;
- break;
- case NSLOG_EMG:
- golg_level = GLOG_LEVEL_FATAL;
- break;
- default:
- golg_level = GLOG_LEVEL_BUTT;
- break;
- }
- return golg_level;
-}
-
-/* use the glog function to replace old nstack log module */
-
-/* segregate the dump info */
-#define LOG_TYPE(_module, _level) \
- (((STACKX == _module) && (NSLOG_EMG == _level)) ? GLOG_LEVEL_ERROR : ((OPERATION == _module) ? GLOG_LEVEL_WARNING : GLOG_LEVEL_INFO))
-
-#define log_shooting(_module,_level) \
- ((NULL == g_log_hook_tag.log_hook) ? (nstack_get_log_level(_module) >= _level) : (level_stoa(_level) >= g_log_hook_tag.level))
-
-/* add the non reentry protection */
-extern __thread unsigned int nstack_log_nonreentry;
-
-/* hanging up version check log need restrain */
-extern int ctrl_log_switch;
-
-#define NS_LOGPID(_module,_prestr,_level,fmt, ...) \
-{\
- if (log_shooting(_module, _level) && (0 == nstack_log_nonreentry) && (0 == ctrl_log_switch))\
- {\
- nstack_log_nonreentry = 1;\
- if(nstack_log_info_check(_module, _level))\
- glog_print(LOG_TYPE(_module,_level),_prestr,level_stoa(_level),-1,GET_FILE_NAME(__FILE__),\
- __LINE__,__func__,fmt, ##__VA_ARGS__);\
- nstack_log_nonreentry = 0;\
- }\
-}
-
-#define NS_LOG_CTRL(_id, _module, _prestr, _level, fmt, ...) \
-{\
- if (log_shooting(_module, _level) && (0 == nstack_log_nonreentry) && check_log_prt_time(_id))\
- {\
- nstack_log_nonreentry = 1;\
- if(nstack_log_info_check(_module, _level))\
- glog_print(LOG_TYPE(_module,_level),_prestr,level_stoa(_level),get_unprt_log_count(_id),\
- GET_FILE_NAME(__FILE__),__LINE__,__func__,fmt, ##__VA_ARGS__);\
- clr_unprt_log_count(_id);\
- nstack_log_nonreentry = 0;\
- }\
-}
-
-#define NS_LOG_CTRL_STACKX(_id, dbug,_module,_prestr,_level,fmt, ...) \
-{\
- if ((dbug) & NS_LOG_STACKX_ON)\
- {\
- NS_LOG_CTRL(_id, _module,_prestr,_level,fmt,##__VA_ARGS__);\
- }\
-}\
-
-
-/*for every log modules should def marcos below use a sort module name, just like MON means Monitor*/
-#define NSMON_LOGINF(fmt, ...) NS_LOGPID(MASTER,"NSMON",NSLOG_INF,fmt,##__VA_ARGS__)
-#define NSMON_LOGDBG(fmt, ...) NS_LOGPID(MASTER,"NSMON",NSLOG_DBG,fmt,##__VA_ARGS__)
-#define NSMON_LOGWAR(fmt, ...) NS_LOGPID(MASTER,"NSMON",NSLOG_WAR,fmt,##__VA_ARGS__)
-#define NSMON_LOGERR(fmt, ...) NS_LOGPID(MASTER,"NSMON",NSLOG_ERR,fmt,##__VA_ARGS__)
-
-#define NSPOL_LOGINF(debug,fmt, ...)NS_LOG_STACKX(debug,STACKX,"NSLWIP",NSLOG_INF,fmt,##__VA_ARGS__)
-#define NSPOL_LOGDBG(debug,fmt, ...) NS_LOG_STACKX(debug,STACKX,"NSLWIP",NSLOG_DBG,fmt,##__VA_ARGS__)
-#define NSPOL_LOGWAR(debug,fmt, ...) NS_LOG_STACKX(debug,STACKX,"NSLWIP",NSLOG_WAR,fmt,##__VA_ARGS__)
-#define NSPOL_LOGERR(fmt, ...) NS_LOGPID(STACKX,"NSLWIP",NSLOG_ERR,fmt,##__VA_ARGS__)
-#define NSPOL_LOGEMG(fmt, ...) NS_LOGPID(STACKX,"NSLWIP",NSLOG_EMG,fmt,##__VA_ARGS__)
-
-#define NSOPR_LOGINF(fmt, ...) NS_LOGPID(OPERATION,"NSOPR",NSLOG_INF,fmt,##__VA_ARGS__)
-#define NSOPR_LOGDBG(fmt, ...) NS_LOGPID(OPERATION,"NSOPR",NSLOG_DBG,fmt,##__VA_ARGS__)
-#define NSOPR_LOGWAR(fmt, ...) NS_LOGPID(OPERATION,"NSOPR",NSLOG_WAR,fmt,##__VA_ARGS__)
-#define NSOPR_LOGERR(fmt, ...) NS_LOGPID(OPERATION,"orchestration",NSLOG_ERR,fmt,##__VA_ARGS__)
-
-#define NSSOC_LOGINF(fmt, ...) NS_LOGPID(NSOCKET,"NSSOC",NSLOG_INF,fmt,##__VA_ARGS__)
-#define NSSOC_LOGDBG(fmt, ...) NS_LOGPID(NSOCKET,"NSSOC",NSLOG_DBG,fmt,##__VA_ARGS__)
-#define NSSOC_LOGWAR(fmt, ...) NS_LOGPID(NSOCKET,"NSSOC",NSLOG_WAR,fmt,##__VA_ARGS__)
-#define NSSOC_LOGERR(fmt, ...) NS_LOGPID(NSOCKET,"NSSOC",NSLOG_ERR,fmt,##__VA_ARGS__)
-
-#define NSSBR_LOGINF(fmt, ...) NS_LOGPID(LOGSBR,"NSSBR",NSLOG_INF,fmt,##__VA_ARGS__)
-#define NSSBR_LOGDBG(fmt, ...) NS_LOGPID(LOGSBR,"NSSBR",NSLOG_DBG,fmt,##__VA_ARGS__)
-#define NSSBR_LOGWAR(fmt, ...) NS_LOGPID(LOGSBR,"NSSBR",NSLOG_WAR,fmt,##__VA_ARGS__)
-#define NSSBR_LOGERR(fmt, ...) NS_LOGPID(LOGSBR,"NSSBR",NSLOG_ERR,fmt,##__VA_ARGS__)
-
-#define NSCOMM_LOGINF(fmt, ...) NS_LOGPID(LOGRTE, "NSRTE",NSLOG_INF,fmt,##__VA_ARGS__)
-#define NSCOMM_LOGDBG(fmt, ...) NS_LOGPID(LOGRTE, "NSRTE",NSLOG_DBG,fmt,##__VA_ARGS__)
-#define NSCOMM_LOGWAR(fmt, ...) NS_LOGPID(LOGRTE, "NSRTE",NSLOG_WAR,fmt,##__VA_ARGS__)
-#define NSCOMM_LOGERR(fmt, ...) NS_LOGPID(LOGRTE, "NSRTE",NSLOG_ERR,fmt,##__VA_ARGS__)
-
-#define NSTCP_LOGINF(fmt, ...) NS_LOGPID(LOGTCP,"NSTCP",NSLOG_INF,fmt,##__VA_ARGS__)
-#define NSTCP_LOGDBG(fmt, ...) NS_LOGPID(LOGTCP,"NSTCP",NSLOG_DBG,fmt,##__VA_ARGS__)
-#define NSTCP_LOGWAR(fmt, ...) NS_LOGPID(LOGTCP,"NSTCP",NSLOG_WAR,fmt,##__VA_ARGS__)
-#define NSTCP_LOGERR(fmt, ...) NS_LOGPID(LOGTCP,"NSTCP",NSLOG_ERR,fmt,##__VA_ARGS__)
-
-#define NSIP_LOGINF(fmt, ...) NS_LOGPID(LOGIP,"NSIP",NSLOG_INF,fmt,##__VA_ARGS__)
-#define NSIP_LOGDBG(fmt, ...) NS_LOGPID(LOGIP,"NSIP",NSLOG_DBG,fmt,##__VA_ARGS__)
-#define NSIP_LOGWAR(fmt, ...) NS_LOGPID(LOGIP,"NSIP",NSLOG_WAR,fmt,##__VA_ARGS__)
-#define NSIP_LOGERR(fmt, ...) NS_LOGPID(LOGIP,"NSIP",NSLOG_ERR,fmt,##__VA_ARGS__)
-
-#define NSUDP_LOGINF(fmt, ...) NS_LOGPID(LOGUDP,"NSUDP",NSLOG_INF,fmt,##__VA_ARGS__)
-#define NSUDP_LOGDBG(fmt, ...) NS_LOGPID(LOGUDP,"NSUDP",NSLOG_DBG,fmt,##__VA_ARGS__)
-#define NSUDP_LOGWAR(fmt, ...) NS_LOGPID(LOGUDP,"NSUDP",NSLOG_WAR,fmt,##__VA_ARGS__)
-#define NSUDP_LOGERR(fmt, ...) NS_LOGPID(LOGUDP,"NSUDP",NSLOG_ERR,fmt,##__VA_ARGS__)
-
-#define NSHAL_LOGINF(fmt, ...) NS_LOGPID(LOGHAL,"NSHAL",NSLOG_INF,fmt,##__VA_ARGS__)
-#define NSHAL_LOGDBG(fmt, ...) NS_LOGPID(LOGHAL,"NSHAL",NSLOG_DBG,fmt,##__VA_ARGS__)
-#define NSHAL_LOGWAR(fmt, ...) NS_LOGPID(LOGHAL,"NSHAL",NSLOG_WAR,fmt,##__VA_ARGS__)
-#define NSHAL_LOGERR(fmt, ...) NS_LOGPID(LOGHAL,"NSHAL",NSLOG_ERR,fmt,##__VA_ARGS__)
-
-#define NSARP_LOGINF(fmt, ...) NS_LOGPID(LOGARP,"NSARP",NSLOG_INF,fmt,##__VA_ARGS__)
-#define NSARP_LOGDBG(fmt, ...) NS_LOGPID(LOGARP,"NSARP",NSLOG_DBG,fmt,##__VA_ARGS__)
-#define NSARP_LOGWAR(fmt, ...) NS_LOGPID(LOGARP,"NSARP",NSLOG_WAR,fmt,##__VA_ARGS__)
-#define NSARP_LOGERR(fmt, ...) NS_LOGPID(LOGARP,"NSARP",NSLOG_ERR,fmt,##__VA_ARGS__)
-
-#define NSDFX_LOGINF(fmt, ...) NS_LOGPID(LOGDFX,"NSDFX",NSLOG_INF,fmt,##__VA_ARGS__)
-#define NSDFX_LOGDBG(fmt, ...) NS_LOGPID(LOGDFX,"NSDFX",NSLOG_DBG,fmt,##__VA_ARGS__)
-#define NSDFX_LOGWAR(fmt, ...) NS_LOGPID(LOGDFX,"NSDFX",NSLOG_WAR,fmt,##__VA_ARGS__)
-#define NSDFX_LOGERR(fmt, ...) NS_LOGPID(LOGDFX,"NSDFX",NSLOG_ERR,fmt,##__VA_ARGS__)
-
-#define NSFW_LOGINF(fmt, ...) NS_LOGPID(LOGFW,"NSFW",NSLOG_INF,fmt,##__VA_ARGS__)
-#define NSFW_LOGDBG(fmt, ...) NS_LOGPID(LOGFW,"NSFW",NSLOG_DBG,fmt,##__VA_ARGS__)
-#define NSFW_LOGERR(fmt, ...) NS_LOGPID(LOGFW,"NSFW",NSLOG_ERR,fmt,##__VA_ARGS__)
-#define NSFW_LOGWAR(fmt, ...) NS_LOGPID(LOGFW,"NSFW",NSLOG_WAR,fmt,##__VA_ARGS__)
-
-#define NSAM_LOGINF(fmt, ...) NS_LOGPID(LOGFW,"NSAM",NSLOG_INF,fmt,##__VA_ARGS__)
-#define NSAM_LOGDBG(fmt, ...) NS_LOGPID(LOGFW,"NSAM",NSLOG_DBG,fmt,##__VA_ARGS__)
-#define NSAM_LOGERR(fmt, ...) NS_LOGPID(LOGFW,"NSAM",NSLOG_ERR,fmt,##__VA_ARGS__)
-#define NSAM_LOGWAR(fmt, ...) NS_LOGPID(LOGFW,"NSAM",NSLOG_WAR,fmt,##__VA_ARGS__)
-
-#define INIT_LOG_ASSEM(log_module,_prestr,_level, init_module , function, errString, errValue, status) \
- if ((LOG_INVALID_VALUE <= errValue) && (1 == sizeof(errString))) \
- { \
- NS_LOGPID(log_module,_prestr, _level,MODULE_INIT_FORMAT_STRING, (char*)status, init_module, function ); \
- } \
- else if (LOG_INVALID_VALUE <= errValue)\
- { \
- NS_LOGPID(log_module,_prestr, _level,MODULE_INIT_FORMAT_STRING",err_string=%s", (char*)status, init_module, function, errString ); \
- } \
- else if (1 == sizeof(errString))\
- { \
- NS_LOGPID(log_module,_prestr, _level,MODULE_INIT_FORMAT_STRING",err_value=%d", (char*)status, init_module, function, errValue ); \
- } \
- else \
- { \
- NS_LOGPID(log_module,_prestr, _level,MODULE_INIT_FORMAT_STRING",err_string=%s,err_value=%d", (char*)status, init_module, function, errString, errValue ); \
- } \
-
-#define INITPOL_LOGINF(init_module_name, function, err_string, err_value, status) \
- INIT_LOG_ASSEM(STACKX,"NSLWIP",NSLOG_INF,init_module_name , function, err_string, err_value, status)\
-
-#define INITPOL_LOGERR(init_module_name, function, err_string, err_value, status) \
- INIT_LOG_ASSEM(STACKX,"NSLWIP",NSLOG_ERR,init_module_name , function, err_string, err_value, status)\
-
-#define INITTCP_LOGINF(init_module_name , function, err_string, err_value, status) \
- INIT_LOG_ASSEM(LOGTCP,"NSTCP",NSLOG_INF,init_module_name , function, err_string, err_value, status)\
-
-#define INITTCP_LOGERR(init_module_name , function, err_string, err_value, status) \
- INIT_LOG_ASSEM(LOGTCP,"NSTCP",NSLOG_ERR,init_module_name , function, err_string, err_value, status)\
-
-#define INITMON_LOGERR(init_module_name , function, err_string, err_value, status) \
- INIT_LOG_ASSEM(MASTER,"NSMON",NSLOG_ERR,init_module_name , function, err_string, err_value, status)\
-
-#define INITSOC_LOGERR(init_module_name , function, err_string, err_value, status) \
- INIT_LOG_ASSEM(NSOCKET,"NSSOC",NSLOG_ERR,init_module_name , function, err_string, err_value, status)
-
-#define NSPOL_DUMP_LOGINF(fmt, ...) NSPOL_LOGINF(0x80, fmt, ##__VA_ARGS__)
-#define NSPOL_DUMP_LOGDBG(fmt, ...) NSPOL_LOGDBG(0x80, fmt, ##__VA_ARGS__)
-#define NSPOL_DUMP_LOGERR(fmt, ...) NSPOL_LOGERR(fmt, ##__VA_ARGS__)
-#define NSPOL_DUMP_LOGWAR(fmt, ...) NSPOL_LOGWAR(0x80, fmt, ##__VA_ARGS__)
-
-/*==============================================*
- * routines' or functions' implementations *
- *----------------------------------------------*/
-
-void save_pre_init_log (uint32_t level, char *fmt, ...);
-void write_pre_init_log ();
-
-void set_log_init_para (struct log_init_para *para);
-
-void nstack_setlog_level (int module, uint32_t level);
-bool nstack_log_info_check (uint32_t module, uint32_t level);
-int nstack_log_init ();
-void nstack_log_init_app ();
-int get_app_env_log_path (char *app_file_path, unsigned int app_file_size);
-void set_log_proc_type (int log_proc_type);
-
-int setlog_level_value (const char *param, const char *value);
-int get_str_value (const char *arg);
-int check_log_dir_valid (const char *path);
-void nstack_segment_error (int s);
-void init_log_ctrl_info ();
-void set_log_ctrl_time (int id, int ctrl_time);
-
-int cmp_log_path (const char *path);
-
-#ifndef sys_sleep_ns
-#define sys_sleep_ns(_s, _ns)\
- {\
- if ((_s) >= 0 && (_ns) >= 0){\
- struct timespec delay, remain;\
- delay.tv_sec=(_s);\
- delay.tv_nsec=(_ns);\
- while (nanosleep (&delay, &remain) < 0)\
- {\
- delay = remain;\
- }\
- }\
- }
-#endif /* sys_sleep_ns */
-
-int check_log_prt_time (int id);
-int get_unprt_log_count (int id);
-void clr_unprt_log_count (int id);
-
-void get_current_time (char *buf, const int len);
-
-#endif
diff --git a/src/framework/include/nstack_rd_data.h b/src/framework/include/nstack_rd_data.h
index 3924680..4d6ed15 100644
--- a/src/framework/include/nstack_rd_data.h
+++ b/src/framework/include/nstack_rd_data.h
@@ -17,64 +17,62 @@
#ifndef __NSTACK_RD_DATA_H
#define __NSTACK_RD_DATA_H
+#include "dmm_spinlock.h"
+#include "nstack_rd_api.h"
+
/*choose router base on ip seg*/
-#define STACK_NAME_MAX 32
+#define STACK_NAME_MAX (32)
#define RD_PLANE_NAMELEN (32)
-#define NSTACK_IP_BIT_MAX (32)
#define NSTACK_RD_DATA_MAX (2048)
-#define RD_IP_STR_MAX_LEN (32)
+/* correspond to the parameters called by *socket* */
typedef enum __rd_data_type
{
- RD_DATA_TYPE_IP,
- RD_DATA_TYPE_PROTO,
- RD_DATA_TYPE_MAX,
+ RD_DATA_TYPE_IP, /* domain */
+ RD_DATA_TYPE_IP6,
+ RD_DATA_TYPE_TYPE, /* type */
+ RD_DATA_TYPE_PROTO, /* protocol */
+ RD_DATA_TYPE_MAX,
} rd_data_type;
typedef enum __rd_node_state
{
- RD_NODE_USELESS,
- RD_NODE_USING,
- RD_NODE_DELETING,
- RD_NODE_MAX,
+ RD_NODE_USELESS,
+ RD_NODE_USING,
+ RD_NODE_DELETING,
+ RD_NODE_MAX,
} rd_node_state;
-/*route info base on ip*/
-typedef struct __rd_route_ip_data
-{
- unsigned int addr;
- unsigned int masklen;
- unsigned int resev[2];
-} rd_ip_data;
-
-/*route data*/
+/* route data */
typedef struct __rd_route_data
{
- /*route info type , for example base on ip */
- rd_data_type type;
- char stack_name[RD_PLANE_NAMELEN];
- union
- {
- rd_ip_data ipdata;
- unsigned int proto_type;
- /*:::other type to be add */
- };
+ /*route info type , for example base on ip */
+ rd_data_type type;
+ char stack_name[RD_PLANE_NAMELEN];
+ union
+ {
+ rd_ip_data ipdata;
+ rd_type_data type_data;
+ rd_proto_data proto_data;
+ rd_ip6_data ip6data;
+ /*:::other type to be add */
+ };
} rd_route_data;
typedef struct __rd_route_node
{
- rd_node_state flag;
- int agetime;
- rd_route_data data;
+ rd_node_state flag;
+ int agetime;
+ rd_route_data data;
} rd_route_node;
typedef struct __rd_route_table
{
- int size;
- int icnt;
- rd_route_node node[NSTACK_RD_DATA_MAX];
+ volatile int rdtbl_ver;
+ dmm_spinlock_t rd_lock;
+ int size;
+ int icnt;
+ rd_route_node node[NSTACK_RD_DATA_MAX];
} rd_route_table;
-#define MASK_V(ipaddr, masklen) ((ipaddr) & (~0 << (NSTACK_IP_BIT_MAX - (masklen))))
-
#endif
diff --git a/src/framework/include/nstack_securec.h b/src/framework/include/nstack_securec.h
deleted file mode 100644
index c9efb4f..0000000
--- a/src/framework/include/nstack_securec.h
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef __NSTACK_SECUREC_H__
-#define __NSTACK_SECUREC_H__
-
-/*if you need export the function of this library in Win32 dll, use __declspec(dllexport) */
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-
-#endif /* */
-#ifndef SECUREC_LIB
-#include <stdio.h>
-#include <stdarg.h>
-#include <wchar.h>
-#include <string.h>
-
-#ifndef NULL
-#define NULL ((void *)0)
-#endif /*
- */
-
-/*define error code*/
-#ifndef errno_t
-typedef int errno_t;
-
-#endif /*
- */
-
-/* success */
-#define EOK (0)
-
-/* invalid parameter */
-#ifndef EINVAL
-#define EINVAL (22)
-#endif /*
- */
-
-#define EINVAL_AND_RESET (22 | 0X80)
-#define ERANGE_AND_RESET (34 | 0X80)
-
-#define SCANF_S scanf
-#define WSCANF_S wscanf
-#define VSCANF_S vscanf
-#define VWSCANF_S vwscanf
-#define FSCANF_S fscanf
-#define FWSCANF_S fwscanf
-#define VFSCANF_S vfscanf
-#define VFWSCANF_S vfwscanf
-#define SSCANF_S sscanf
-#define SWSCANF_S swscanf
-#define VSSCANF_S vsscanf
-#define VSWSCANF_S vswscanf
-
-#define SPRINTF_S(a, b, ...) sprintf(a, ##__VA_ARGS__)
-#define SWPRINTF_S(a, b, c, ...) swprintf(a, b, c, ##__VA_ARGS__)
-#define VSPRINTF_S(a, b, c, d) vsprintf(a, c, d)
-#define VSWPRINTF_S(a, b, c, d) vswprintf(a, b, c, d)
-#define VSNPRINTF_S(a, b, c, d, e) vsnprintf(a, c, d, e)
-#define SNPRINTF_S(a, b, c, d, ...) snprintf(a, c, d, ##__VA_ARGS__)
-
-#define WMEMCPY_S(a, b, c, d) ((NULL == wmemcpy(a, c, d)) ? EINVAL : EOK)
-#define MEMMOVE_S(a, b, c, d) ((NULL == memmove(a, c, d)) ? EINVAL : EOK)
-#define WMEMMOVE_S(a, b, c, d) ((NULL == wmemmove(a, c, d)) ? EINVAL : EOK)
-#define WCSCPY_S(a, b, c) ((NULL == wcscpy(a, c)) ? EINVAL : EOK)
-#define WCSNCPY_S(a, b, c, d) ((NULL == wcsncpy(a, c, d)) ? EINVAL : EOK)
-#define WCSCAT_S(a, b, c) ((NULL == wcscat(a, c)) ? EINVAL : EOK)
-#define WCSNCAT_S(a, b, c, d) ((NULL == wcsncat(a, c, d)) ? EINVAL : EOK)
-
-#define MEMSET_S(a, b, c, d) ((NULL == memset(a, c, d)) ? EINVAL : EOK)
-#define MEMCPY_S(a, b, c, d) ((NULL == memcpy(a, c, d)) ? EINVAL : EOK)
-#define STRCPY_S(a, b, c) ((NULL == strcpy(a, c )) ? EINVAL : EOK)
-#define STRNCPY_S(a, b, c, d) ((NULL == strncpy(a, c, d)) ? EINVAL : EOK)
-#define STRCAT_S(a, b, c) ((NULL == strcat(a, c)) ? EINVAL : EOK)
-#define STRNCAT_S(a, b, c, d) ((NULL == strncat(a, c, d)) ? EINVAL : EOK)
-
-#define STRTOK_S(a, b, c) strtok(a, b)
-#define WCSTOK_S(a, b, c) wcstok(a, b)
-#define GETS_S(a, b) gets(a)
-
-#else /* */
-#include "securec.h"
-
-#define SCANF_S scanf_s
-#define WSCANF_S wscanf_s
-#define VSCANF_S vscanf_s
-#define VWSCANF_S vwscanf_s
-#define FSCANF_S fscanf_s
-#define FWSCANF_S fwscanf_s
-#define VFSCANF_S vfscanf_s
-#define VFWSCANF_S vfwscanf_s
-#define SSCANF_S sscanf_s
-#define SWSCANF_S swscanf_s
-#define VSSCANF_S vsscanf_s
-#define VSWSCANF_S vswscanf_s
-
-#define SPRINTF_S(a, b, ...) sprintf_s (a, b, ##__VA_ARGS__)
-#define SWPRINTF_S(a, b, c, ...) swprintf_s(a, b, c, ##__VA_ARGS__)
-#define VSPRINTF_S(a, b, c, d) vsprintf_s(a, b, c, d)
-#define VSWPRINTF_S(a, b, c, d) vswprintf_s(a, b, c, d)
-#define VSNPRINTF_S(a, b, c, d, e) vsnprintf_s(a, b, c, d, e)
-#define SNPRINTF_S(a, b, c, d, ...) snprintf_s(a, b, c, d, ##__VA_ARGS__)
-
-#define WMEMCPY_S(a, b, c, d) wmemcpy_s(a, b, c, d)
-#define MEMMOVE_S(a, b, c, d) memmove_s(a, b, c, d)
-#define WMEMMOVE_S(a, b, c, d) wmemmove_s(a, b, c, d)
-#define WCSCPY_S(a, b, c) wcscpy_s(a, b, c)
-#define WCSNCPY_S(a, b, c, d) wcsncpy_s(a, b, c, d)
-#define WCSCAT_S(a, b, c) wcscat_s(a, b, c)
-#define WCSNCAT_S(a, b, c, d) wcsncat_s(a, b, c, d)
-
-#define MEMSET_S(a, b, c, d) memset_s(a, b, c, d)
-#define MEMCPY_S(a, b, c, d) memcpy_s(a, b, c, d)
-#define STRCPY_S(a, b, c) strcpy_s(a, b, c)
-#define STRNCPY_S(a, b, c, d) strncpy_s(a, b, c, d)
-#define STRCAT_S(a, b, c) strcat_s(a, b, c)
-#define STRNCAT_S(a, b, c, d) strncat_s(a, b, c, d)
-
-#define STRTOK_S(a, b, c) strtok_s(a, b, c)
-#define WCSTOK_S(a, b, c) wcstok_s(a, b, c)
-#define GETS_S(a, b) gets_s(a, b)
-#endif /* */
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif /* __cplusplus */
-
-#endif /* __NSTACK_SECUREC_H__ */
diff --git a/src/framework/include/nstack_share_res.h b/src/framework/include/nstack_share_res.h
new file mode 100644
index 0000000..930456d
--- /dev/null
+++ b/src/framework/include/nstack_share_res.h
@@ -0,0 +1,91 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#ifndef NSTACK_SHARE_RES_H
+#define NSTACK_SHARE_RES_H
+
+#include "nstack_log.h"
+#include "compiling_check.h"
+#include "nsfw_recycle_api.h"
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
+#define NSTACK_VERSION_SHM "nstack_version"
+#define MAX_U16_INT 0xFFFF
+#define NSTACK_VERSION_LEN 128
+
+COMPAT_PROTECT_RETURN(NSTACK_VERSION_LEN, 128);
+#define MAX_UNMATCH_VER_CNT 32
+COMPAT_PROTECT_RETURN(MAX_UNMATCH_VER_CNT, 32);
+
+/* Add dfx timer tick */
+#define NSTACK_GLOBAL_TICK_SHM "nstack_global_tick"
+
+typedef struct unmatch_ver_info
+{
+ int unmatch_count;
+ char lib_version[NSTACK_VERSION_LEN];
+ char first_time_stamp[LOG_TIME_STAMP_LEN];
+} unmatch_ver_info_t;
+
+/* Add dfx timer tick Begin */
+#define DFX_TMR_INTERVAL 60000 /*60 seconds */
+typedef struct nstack_tick_info
+{
+ u64 *tick_ptr; // tick from shared memory
+ u64 interval; // tick interval, only used in stack process
+ /* tick refference, updated periodically and read in tcpip_thread only */
+ struct timeval ref_time; // ref tick time
+ u64 ref_tick; // ref tick
+} nstack_tick_info_t;
+/* Add dfx timer tick End */
+
+int nstack_init_share_res();
+int nstack_attach_share_res();
+
+void fork_parent_start(i32 ppid);
+void fork_wait_child_done(u32 ppid);
+void fork_parent_failed(u32 ppid);
+void fork_child_start(u32 ppid);
+void fork_child_done(u32 ppid);
+int fork_recycle_check(u32 pid);
+void fork_delay_recycle(u8 sec, nsfw_recycle_fun fun);
+
+static inline u16 calculate_elapse(u64 a, u64 b)
+{
+ u64 ret = 0;
+ if (a > b)
+ {
+ ret = a - b;
+ return ret < MAX_U16_INT ? (u16) ret : (u16) MAX_U16_INT;
+ }
+ else
+ {
+ return 0;
+ }
+}
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif
+
+#endif
diff --git a/src/framework/init/CMakeLists.txt b/src/framework/init/CMakeLists.txt
deleted file mode 100644
index ff8d4d2..0000000
--- a/src/framework/init/CMakeLists.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-#########################################################################
-#
-# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-# 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.
-#########################################################################
-
-SET(LIBSBR_SRC fw_init.c fw_module.c)
-
-SET(COMM_CONFIG ${PROJECT_SOURCE_DIR}/src/framework/common/base/include/common_sys_config.h)
-ADD_DEFINITIONS(-fPIC -mssse3)
-ADD_DEFINITIONS(-include ${COMM_CONFIG})
-
-ADD_LIBRARY(nStackfwinit static ${LIBSBR_SRC})
-
diff --git a/src/framework/init/fw_init.c b/src/framework/init/fw_init.c
index 2764479..636fe20 100644
--- a/src/framework/init/fw_init.c
+++ b/src/framework/init/fw_init.c
@@ -18,6 +18,7 @@
#include <stdlib.h>
#include <string.h>
#include "nstack_securec.h"
+#include "nsfw_init_api.h"
#include "fw_module.h"
#include "nstack_log.h"
@@ -27,290 +28,302 @@ extern "C"{
/* *INDENT-ON* */
#endif /* __cplusplus */
-NSTACK_STATIC int
-nsfw_module_instance_isIndepend (nsfw_module_instance_t * inst)
+int g_fw_init_err = 0;
+int get_fw_init_err()
{
- nsfw_module_depends_t *dep = inst->depends;
- while (dep)
+ return g_fw_init_err;
+}
+
+void set_fw_init_err(int x)
+{
+ g_fw_init_err = x;
+}
+
+NSTACK_STATIC int nsfw_module_instance_is_independ(nsfw_module_instance_t *
+ inst)
+{
+ nsfw_module_depends_t *dep = inst->depends;
+ while (dep)
{
- if (!dep->isReady)
- return 1;
- dep = dep->next;
+ if (!dep->isReady)
+ return 1;
+ dep = dep->next;
}
- return 0;
+ return 0;
}
-NSTACK_STATIC void
-nsfw_module_instance_depend_check (nsfw_module_instance_t * inst)
+NSTACK_STATIC void nsfw_module_instance_depend_check(nsfw_module_instance_t *
+ inst)
{
- nsfw_module_instance_t *curInst = nsfw_module_getManager ()->inst;
- while (curInst)
+ nsfw_module_instance_t *curInst = nsfw_module_get_manager()->inst;
+ while (curInst)
{
- if (curInst == inst)
- goto nextLoop;
- if (NSFW_INST_STAT_CHECKING == curInst->stat
- || NSFW_INST_STAT_DEPENDING == curInst->stat)
+ if (curInst == inst)
+ goto nextLoop;
+ if (NSFW_INST_STAT_CHECKING == curInst->stat
+ || NSFW_INST_STAT_DEPENDING == curInst->stat)
{
- nsfw_module_depends_t *dep = curInst->depends;
- while (dep)
+ nsfw_module_depends_t *dep = curInst->depends;
+ while (dep)
{
- if (0 == dep->isReady && 0 == strcmp (dep->name, inst->name))
+ if (0 == dep->isReady && 0 == strcmp(dep->name, inst->name))
{
- dep->isReady = 1; /* Don't break for case that duplicate name exist, though I think it should
+ dep->isReady = 1; /* Don't break for case that duplicate name exist, though I think it should
not happen */
}
- dep = dep->next;
+ dep = dep->next;
}
}
- nextLoop:
- curInst = curInst->next;
+ nextLoop: /*this type usually use like this and no "space" */
+ curInst = curInst->next;
}
}
-/**
- * @Function nstack_framework_init
- * @Description Init child modules
- * @param father instance , NULL means root
- * @return 0 on success, -1 on error
- */
-NSTACK_STATIC int
-nstack_framework_initChild_unsafe (nsfw_module_instance_t * father)
+NSTACK_STATIC int nstack_framework_init_child_unsafe(nsfw_module_instance_t *
+ father)
{
- NSFW_LOGDBG ("init framework module] name=%s",
- father ? father->name : "NULL");
-
- nsfw_module_instance_t *inst = nsfw_module_getManager ()->inst;
+ NSFW_LOGDBG("init framework module] name=%s",
+ father ? father->name : "NULL");
- while (inst)
+ nsfw_module_instance_t *inst = nsfw_module_get_manager()->inst;
+ int initRet = 0;
+ while (inst)
{
- NSFW_LOGDBG
- ("init child] inst=%s, inst->father=%s, inst->depends=%s, inst->state=%d",
- inst->name, inst->father ? inst->father->name : "NULL",
- inst->depends ? inst->depends->name : "NULL", inst->stat);
+ NSFW_LOGDBG
+ ("init child] inst=%s, inst->father=%s, inst->depends=%s, inst->state=%d",
+ inst->name, inst->father ? inst->father->name : "NULL",
+ inst->depends ? inst->depends->name : "NULL", inst->stat);
- if (father != inst->father)
+ if (father != inst->father)
{
- NSFW_LOGDBG ("inst->father not match] inst=%s, ", inst->name);
+ NSFW_LOGDBG("inst->father not match] inst=%s, ", inst->name);
- inst = inst->next;
- continue;
+ inst = inst->next;
+ continue;
}
- switch (inst->stat)
+ switch (inst->stat)
{
- case NSFW_INST_STAT_CHECKING:
- /* First, check if any depends, then check if other instance depends on it */
- if (nsfw_module_instance_isIndepend (inst))
- {
- inst->stat = NSFW_INST_STAT_DEPENDING;
- NSFW_LOGDBG ("inst is still depending] name=%s", inst->name);
- inst = inst->next;
- break;
- }
+ case NSFW_INST_STAT_CHECKING:
+ /* First, check if any depends, then check if other instance depends on it */
+ if (nsfw_module_instance_is_independ(inst))
+ {
+ inst->stat = NSFW_INST_STAT_DEPENDING;
+ NSFW_LOGDBG("inst is still depending] name=%s",
+ inst->name);
+ inst = inst->next;
+ break;
+ }
- NSFW_LOGINF ("Going to init module] name=%s, init fun=%p",
- inst->name, inst->fnInit);
- if (NULL != inst->fnInit && 0 != inst->fnInit (inst->param))
- {
- NSFW_LOGERR ("initial fail!!!] inst=%s", inst->name);
- inst->stat = NSFW_INST_STAT_FAIL;
- return -1;
- }
+ NSFW_LOGINF("Going to init module]name=%s,init fun=%p",
+ inst->name, inst->fnInit);
+ if (NULL != inst->fnInit
+ && 0 != (initRet = inst->fnInit(inst->param)))
+ {
+ NSFW_LOGERR("initial fail]inst=%s,initRet=%d",
+ inst->name, initRet);
+ inst->stat = NSFW_INST_STAT_FAIL;
+ if (get_fw_init_err() == 0) /* record first init err */
+ {
+ NSFW_LOGERR("update g_fw_init_err to %d", initRet);
+ /* TODO: now g_fw_init_err conveys errcode and be processed in master_main,
+ * better way is to regsiter an error-handler for each inst */
+ set_fw_init_err(initRet);
+ }
+ return -1;
+ }
- inst->stat = NSFW_INST_STAT_DONE;
- nsfw_module_instance_depend_check (inst);
+ inst->stat = NSFW_INST_STAT_DONE;
+ nsfw_module_instance_depend_check(inst);
- if (-1 == nsfw_module_addDoneNode (inst))
- {
- NSFW_LOGERR ("add done node fail");
- }
+ if (-1 == nsfw_module_add_done_node(inst))
+ {
+ NSFW_LOGERR("add done node fail");
+ }
- inst = nsfw_module_getManager ()->inst; /* check from begining */
- break;
- case NSFW_INST_STAT_DEPENDING:
- /* check if depending stat is still there */
- if (!nsfw_module_instance_isIndepend (inst))
- {
- inst->stat = NSFW_INST_STAT_CHECKING;
- break;
- }
- case NSFW_INST_STAT_FAIL:
- case NSFW_INST_STAT_DONE:
- default:
- inst = inst->next;
- break;
+ inst = nsfw_module_get_manager()->inst; /* check from begining */
+ break;
+ case NSFW_INST_STAT_DEPENDING:
+ /* check if depending stat is still there */
+ if (!nsfw_module_instance_is_independ(inst))
+ {
+ inst->stat = NSFW_INST_STAT_CHECKING;
+ break;
+ }
+ case NSFW_INST_STAT_FAIL:
+ case NSFW_INST_STAT_DONE:
+ default:
+ inst = inst->next;
+ break;
}
}
- return 0;
+ return 0;
}
-NSTACK_STATIC void
-nstack_framework_printInstanceInfo (nsfw_module_instance_t * inst)
+NSTACK_STATIC
+ void nstack_framework_print_instance_info(nsfw_module_instance_t * inst)
{
- if (NULL == inst)
+ if (NULL == inst)
{
- NSFW_LOGERR ("param error,inst==NULL");
- return;
+ NSFW_LOGERR("param err]inst=NULL");
+ return;
}
- char info[1024] = "";
- int plen = 0;
+ char info[1000] = "";
+ int plen = 0;
- int ret = SPRINTF_S (info, sizeof (info), "Inst:%s,father:%s,depends:",
- inst->name,
- inst->father ? inst->father->name : "NULL");
+ int ret = sprintf_s(info, sizeof(info), "Inst:%s,father:%s,depends:",
+ inst->name,
+ inst->father ? inst->father->name : "NULL");
- if (ret <= 0)
+ if (ret <= 0)
{
- NSFW_LOGERR ("Sprintf Error] module=%s,state=%d, ret=%d", inst->name,
- inst->stat, ret);
- return;
+ NSFW_LOGERR("Sprintf err]module=%s,state=%d,ret=%d", inst->name,
+ inst->stat, ret);
+ return;
}
- else
+ else
{
- plen += ret;
+ plen += ret;
}
- if (NULL == inst->depends)
+ if (NULL == inst->depends)
{
- ret = SPRINTF_S (info + plen, sizeof (info) - plen, "NULL");
- if (ret <= 0)
+ ret = sprintf_s(info + plen, sizeof(info) - plen, "NULL");
+ if (ret <= 0)
{
- NSFW_LOGERR ("Sprintf Error] module=%s,state=%d, ret=%d",
- inst->name, inst->stat, ret);
- return;
+ NSFW_LOGERR("Sprintf Err]module=%s,state=%d,ret=%d", inst->name,
+ inst->stat, ret);
+ return;
}
- NSFW_LOGINF ("] inst info=%s", info);
- return;
+ NSFW_LOGINF("]inst info=%s", info);
+ return;
}
- nsfw_module_depends_t *dep = inst->depends;
- while (dep)
+ nsfw_module_depends_t *dep = inst->depends;
+ while (dep && (plen < (int) sizeof(info)))
{
- ret = SPRINTF_S (info + plen, sizeof (info) - plen, "%s ", dep->name);
- if (ret <= 0)
+ ret = sprintf_s(info + plen, sizeof(info) - plen, "%s ", dep->name);
+ if (ret <= 0)
{
- NSFW_LOGERR ("Sprintf Error] module=%s,state=%d, ret=%d",
- inst->name, inst->stat, ret);
- return;
+ NSFW_LOGERR("Sprintf Err]module=%s,state=%d,ret=%d", inst->name,
+ inst->stat, ret);
+ return;
}
- plen += ret;
- dep = dep->next;
+ plen += ret;
+ dep = dep->next;
}
- NSFW_LOGINF ("] inst info=%s", info);
+ NSFW_LOGINF("]inst info=%s", info);
}
-NSTACK_STATIC void
-nstack_framework_printInitialResult ()
+NSTACK_STATIC void nstack_framework_print_initial_result()
{
- nsfw_module_manager_t *manager = nsfw_module_getManager ();
+ nsfw_module_manager_t *manager = nsfw_module_get_manager();
- if (manager->doneHead)
+ if (manager->doneHead)
{
- NSFW_LOGINF ("Here is the initial done modules: ");
+ NSFW_LOGINF("Here is the initial done modules: ");
- nsfw_module_doneNode_t *curNode = manager->doneHead;
- while (curNode)
+ nsfw_module_done_node_t *curNode = manager->doneHead;
+ while (curNode)
{
- nstack_framework_printInstanceInfo (curNode->inst);
- curNode = curNode->next;
+ nstack_framework_print_instance_info(curNode->inst);
+ curNode = curNode->next;
}
}
- else
+ else
{
- NSFW_LOGERR ("No initial done modules");
+ NSFW_LOGERR("No initial done modules");
}
- nsfw_module_instance_t *curInst = manager->inst;
- int unDoneNum = 0;
- while (curInst)
+ nsfw_module_instance_t *curInst = manager->inst;
+ int unDoneNum = 0;
+ while (curInst)
{
- if (curInst->stat != NSFW_INST_STAT_DONE)
+ if (curInst->stat != NSFW_INST_STAT_DONE)
{
- if (0 == unDoneNum)
+ if (0 == unDoneNum)
{
- NSFW_LOGINF ("Here is the unInited modules:");
+ NSFW_LOGINF("Here is the unInited modules:");
}
- unDoneNum++;
- nstack_framework_printInstanceInfo (curInst);
+ unDoneNum++;
+ nstack_framework_print_instance_info(curInst);
}
- curInst = curInst->next;
+ curInst = curInst->next;
}
- if (0 == unDoneNum)
- NSFW_LOGINF ("All modules are inited");
+ if (0 == unDoneNum)
+ NSFW_LOGINF("All modules are inited");
}
/**
* @Function nstack_framework_init
- * @Description This function will do framework initial work, it will invoke all initial functions
- * registered using macro NSFW_MODULE_INIT before
+ * @Description This function will do framework initial work, it will involk all initial functions
+ * registed using macro NSFW_MODULE_INIT before
* @param none
* @return 0 on success, -1 on error
*/
-int
-nstack_framework_init (void)
+int nstack_framework_init(void)
{
- int ret = -1;
- if (nsfw_module_getManager ()->done)
+ int ret = -1;
+ if (nsfw_module_get_manager()->done)
{
- goto init_finished;
+ goto init_finished;
}
- if (pthread_mutex_lock (&nsfw_module_getManager ()->initMutex))
+ if (pthread_mutex_lock(&nsfw_module_get_manager()->initMutex))
{
- return -1;
+ return -1;
}
- if (nsfw_module_getManager ()->done)
+ if (nsfw_module_get_manager()->done)
{
- goto done;
+ goto done;
}
- ret = nstack_framework_initChild_unsafe (NULL);
+ ret = nstack_framework_init_child_unsafe(NULL);
- if (0 == ret)
+ if (0 == ret)
{
- nsfw_module_getManager ()->done = 1;
+ nsfw_module_get_manager()->done = 1;
}
- else
+ else
{
- nsfw_module_getManager ()->done = -1;
+ nsfw_module_get_manager()->done = -1;
}
- // Going to print done modules and undone modules
- nstack_framework_printInitialResult ();
+ // Going to print done modules and undone modules
+ nstack_framework_print_initial_result();
-done:
- if (pthread_mutex_unlock (&nsfw_module_getManager ()->initMutex))
+ done:
+ if (pthread_mutex_unlock(&nsfw_module_get_manager()->initMutex))
{
- return -1;
+ return -1;
}
-init_finished:
- ret = nsfw_module_getManager ()->done == 1 ? 0 : -1;
- return ret;
+ init_finished:
+ ret = nsfw_module_get_manager()->done == 1 ? 0 : -1;
+ return ret;
}
/**
- * @Function nstack_framework_setModuleParam
+ * @Function nstack_framework_set_module_param
* @Description This function set parameter of module initial function parameter
* @param module - name of module
* @param param - parameter to set
* @return 0 on success, -1 on error
*/
-int
-nstack_framework_setModuleParam (char *module, void *param)
+int nstack_framework_set_module_param(char *module, void *param)
{
- nsfw_module_instance_t *inst = nsfw_module_getModuleByName (module);
- if (!inst)
- return -1;
+ nsfw_module_instance_t *inst = nsfw_module_get_module_by_name(module);
+ if (!inst)
+ return -1;
- inst->param = param;
- return 0;
+ inst->param = param;
+ return 0;
}
#ifdef __cplusplus
diff --git a/src/framework/init/fw_module.c b/src/framework/init/fw_module.c
index 1f22ecb..66c06ee 100644
--- a/src/framework/init/fw_module.c
+++ b/src/framework/init/fw_module.c
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include "nstack_securec.h"
#include "fw_module.h"
+#include "nsfw_init_api.h"
#ifdef __cplusplus
/* *INDENT-OFF* */
@@ -27,8 +28,8 @@ extern "C"{
/* *INDENT-ON* */
#endif /* __cplusplus */
-COMPAT_PROTECT (NSFW_MODULE_INSTANCE_POOL_SIZE, 64);
-COMPAT_PROTECT (NSFW_MODULE_DEPENDS_POOL_SIZE, 128);
+COMPAT_PROTECT_RETURN(NSFW_MODULE_INSTANCE_POOL_SIZE, 64);
+COMPAT_PROTECT_RETURN(NSFW_MODULE_DEPENDS_POOL_SIZE, 128);
nsfw_module_instance_pool_t g_nsfw_module_inst_pool;
nsfw_module_depends_pool_t g_nsfw_module_deps_pool;
@@ -37,291 +38,280 @@ nsfw_module_depends_pool_t g_nsfw_module_deps_pool;
* WARNING!!!:
* This function is only used in constructor progress. Multi-thread concurrent is not supported!
*/
-NSTACK_STATIC nsfw_module_instance_t *
-nsfw_module_malloc_instance ()
+NSTACK_STATIC nsfw_module_instance_t *nsfw_module_malloc_instance()
{
- if (g_nsfw_module_inst_pool.last_idx >= NSFW_MODULE_INSTANCE_POOL_SIZE)
+ if (g_nsfw_module_inst_pool.last_idx >= NSFW_MODULE_INSTANCE_POOL_SIZE)
{
- return NULL;
+ return NULL;
}
- return
- &g_nsfw_module_inst_pool.module_instance_pool[g_nsfw_module_inst_pool.
- last_idx++];
+ return
+ &g_nsfw_module_inst_pool.module_instance_pool[g_nsfw_module_inst_pool.
+ last_idx++];
}
/*
* WARNING!!!:
* This function is only used in constructor progress. Multi-thread concurrent is not supported!
*/
-NSTACK_STATIC nsfw_module_depends_t *
-nsfw_module_malloc_depends ()
+NSTACK_STATIC nsfw_module_depends_t *nsfw_module_malloc_depends()
{
- if (g_nsfw_module_deps_pool.last_idx >= NSFW_MODULE_DEPENDS_POOL_SIZE)
+ if (g_nsfw_module_deps_pool.last_idx >= NSFW_MODULE_DEPENDS_POOL_SIZE)
{
- return NULL;
+ return NULL;
}
- return
- &g_nsfw_module_deps_pool.module_depends_pool[g_nsfw_module_deps_pool.
- last_idx++];
+ return
+ &g_nsfw_module_deps_pool.module_depends_pool[g_nsfw_module_deps_pool.
+ last_idx++];
}
-NSTACK_STATIC void
-nsfw_module_setChildInstance (nsfw_module_instance_t *
- father, nsfw_module_instance_t * child)
+/*Change module malloc to pool array End*/
+
+NSTACK_STATIC void nsfw_module_set_child_instance(nsfw_module_instance_t *
+ father,
+ nsfw_module_instance_t *
+ child)
{
- if (NULL == father || NULL == child)
- return;
- child->father = father;
+ if (NULL == father || NULL == child)
+ return;
+ child->father = father;
}
-nsfw_module_depends_t *
-nsfw_module_create_depends (char *name)
+nsfw_module_depends_t *nsfw_module_create_depends(char *name)
{
- if (NULL == name)
- return NULL;
-
- /*Change module malloc to pool array */
- nsfw_module_depends_t *dep = nsfw_module_malloc_depends ();
-
- if (NULL == dep)
- return NULL;
-
- if (EOK !=
- MEMSET_S (dep, sizeof (nsfw_module_depends_t), 0,
- sizeof (nsfw_module_depends_t)))
+ if (NULL == name)
+ return NULL;
+ /*Change module malloc to pool array */
+ nsfw_module_depends_t *dep = nsfw_module_malloc_depends();
+ if (NULL == dep)
+ return NULL;
+
+ if (EOK !=
+ memset_s(dep, sizeof(nsfw_module_depends_t), 0,
+ sizeof(nsfw_module_depends_t)))
{
- goto fail;
+ goto fail;
}
- /*change destMax from nameSize - 1 to sizeof(dep->name) */
- if (EOK != STRCPY_S (dep->name, sizeof (dep->name), name))
+ /*change destMax from nameSize - 1 to sizeof(dep->name) */
+ if (EOK != strcpy_s(dep->name, sizeof(dep->name), name))
{
- goto fail;
+ goto fail;
}
- dep->isReady = 0;
+ dep->isReady = 0;
- return dep;
+ return dep;
-fail:
- // NOTE: if dep is not null, we do not free it and just leave it there.
- return NULL;
+ fail:
+ // NOTE: if dep is not null, we do not free it and just leave it there.
+ return NULL;
}
-nsfw_module_instance_t *
-nsfw_module_create_instance (void)
+nsfw_module_instance_t *nsfw_module_create_instance(void)
{
- /*Change module malloc to pool array */
- nsfw_module_instance_t *inst = nsfw_module_malloc_instance ();
- if (NULL == inst)
- return NULL;
-
- if (EOK !=
- MEMSET_S (inst, sizeof (nsfw_module_instance_t), 0,
- sizeof (nsfw_module_instance_t)))
+ /*Change module malloc to pool array */
+ nsfw_module_instance_t *inst = nsfw_module_malloc_instance();
+ if (NULL == inst)
+ return NULL;
+
+ if (EOK !=
+ memset_s(inst, sizeof(nsfw_module_instance_t), 0,
+ sizeof(nsfw_module_instance_t)))
{
- // NOTE: if inst is not null, we do not free it and just leave it there.
- return NULL;
+ // NOTE: if inst is not null, we do not free it and just leave it there.
+ return NULL;
}
- inst->stat = NSFW_INST_STAT_CHECKING;
- return inst;
+ inst->stat = NSFW_INST_STAT_CHECKING;
+ return inst;
}
-void
-nsfw_module_set_instance_name (nsfw_module_instance_t * inst, char *name)
+void nsfw_module_set_instance_name(nsfw_module_instance_t * inst, char *name)
{
- if (NULL == inst || NULL == name || inst->name[0] != '\0')
+ if (NULL == inst || NULL == name || inst->name[0] != '\0')
{
- return;
+ return;
}
- /*change destMax from nameSize - 1 to sizeof(inst->name) */
- if (EOK != STRCPY_S (inst->name, sizeof (inst->name), name))
+ /*change destMax from nameSize - 1 to sizeof(inst->name) */
+ if (EOK != strcpy_s(inst->name, sizeof(inst->name), name))
{
- return;
+ return;
}
- // Now we need to search if it's any instance's father
- nsfw_module_instance_t *curInst = nsfw_module_getManager ()->inst;
- while (curInst)
+ // Now we need to search if it's any instance's father
+ nsfw_module_instance_t *curInst = nsfw_module_get_manager()->inst;
+ while (curInst)
{
- if (curInst == inst)
- goto next_loop;
+ if (curInst == inst)
+ goto next_loop;
- if (0 == strcmp (curInst->fatherName, inst->name)
- && NULL == curInst->father)
+ if (0 == strcmp(curInst->fatherName, inst->name)
+ && NULL == curInst->father)
{
- nsfw_module_setChildInstance (inst, curInst);
+ nsfw_module_set_child_instance(inst, curInst);
}
- next_loop:
- curInst = curInst->next;
+ next_loop: /*usually use like this and no "space" */
+ curInst = curInst->next;
}
- return;
+ return;
}
-void
-nsfw_module_set_instance_father (nsfw_module_instance_t * inst,
- char *fatherName)
+void nsfw_module_set_instance_father(nsfw_module_instance_t * inst,
+ char *fatherName)
{
- if (NULL == inst || NULL == fatherName)
+ if (NULL == inst || NULL == fatherName)
{
- return;
+ return;
}
- if (EOK !=
- STRCPY_S (inst->fatherName, sizeof (inst->fatherName), fatherName))
+ if (EOK !=
+ strcpy_s(inst->fatherName, sizeof(inst->fatherName), fatherName))
{
- return;
+ return;
}
- nsfw_module_instance_t *fatherInst =
- nsfw_module_getModuleByName (fatherName);
- if (fatherInst)
+ nsfw_module_instance_t *fatherInst =
+ nsfw_module_get_module_by_name(fatherName);
+ if (fatherInst)
{
- nsfw_module_setChildInstance (fatherInst, inst);
+ nsfw_module_set_child_instance(fatherInst, inst);
}
- return;
+ return;
}
-void
-nsfw_module_set_instance_priority (nsfw_module_instance_t * inst,
- int priority)
+void nsfw_module_set_instance_priority(nsfw_module_instance_t * inst,
+ int priority)
{
- if (NULL == inst)
- return;
- inst->priority = priority;
+ if (NULL == inst)
+ return;
+ inst->priority = priority;
- nsfw_module_del_instance (inst);
- nsfw_module_add_instance (inst);
- return;
+ nsfw_module_del_instance(inst);
+ nsfw_module_add_instance(inst);
+ return;
}
-void
-nsfw_module_set_instance_initfn (nsfw_module_instance_t * inst,
- nsfw_module_init_fn fn)
+void nsfw_module_set_instance_initfn(nsfw_module_instance_t * inst,
+ nsfw_module_init_fn fn)
{
- if (NULL == inst)
+ if (NULL == inst)
+ return;
+ inst->fnInit = fn;
return;
- inst->fnInit = fn;
- return;
}
-void
-nsfw_module_set_instance_depends (nsfw_module_instance_t * inst, char *name)
+void nsfw_module_set_instance_depends(nsfw_module_instance_t * inst,
+ char *name)
{
- if (NULL == inst || name == NULL)
- return;
+ if (NULL == inst || name == NULL)
+ return;
- // Check if depends already set
- nsfw_module_depends_t *dep = inst->depends;
- while (dep)
+ // Check if depends already set
+ nsfw_module_depends_t *dep = inst->depends;
+ while (dep)
{
- if (0 == strcmp (dep->name, name))
- return;
- dep = dep->next;
+ if (0 == strcmp(dep->name, name))
+ return;
+ dep = dep->next;
}
- dep = nsfw_module_create_depends (name);
- if (NULL == dep)
- return;
+ dep = nsfw_module_create_depends(name);
+ if (NULL == dep)
+ return;
- if (NULL == inst->depends)
- inst->depends = dep;
- else
- inst->depends->next = dep;
+ if (NULL == inst->depends)
+ inst->depends = dep;
+ else
+ inst->depends->next = dep;
}
-/* *INDENT-OFF* */
-nsfw_module_manager_t g_nsfw_module_manager = {.inst = NULL, .initMutex =
- PTHREAD_MUTEX_INITIALIZER, .done = 0};
-/* *INDENT-ON* */
+nsfw_module_manager_t g_nsfw_module_manager = {.inst = NULL,.initMutex =
+ PTHREAD_MUTEX_INITIALIZER,.done = 0
+};
-void
-nsfw_module_add_instance (nsfw_module_instance_t * inst)
+void nsfw_module_add_instance(nsfw_module_instance_t * inst)
{
- nsfw_module_instance_t *curInst = nsfw_module_getManager ()->inst;
+ nsfw_module_instance_t *curInst = nsfw_module_get_manager()->inst;
- if (NULL == curInst || curInst->priority > inst->priority)
+ if (NULL == curInst || curInst->priority > inst->priority)
{
- inst->next = curInst;
- nsfw_module_getManager ()->inst = inst;
+ inst->next = curInst;
+ nsfw_module_get_manager()->inst = inst;
}
- else
+ else
{
- while (curInst->next && curInst->next->priority <= inst->priority)
+ while (curInst->next && curInst->next->priority <= inst->priority)
{
- curInst = curInst->next;
+ curInst = curInst->next;
}
- inst->next = curInst->next;
- curInst->next = inst;
+ inst->next = curInst->next;
+ curInst->next = inst;
}
}
-void
-nsfw_module_del_instance (nsfw_module_instance_t * inst)
+void nsfw_module_del_instance(nsfw_module_instance_t * inst)
{
- if (nsfw_module_getManager ()->inst == inst)
+ if (nsfw_module_get_manager()->inst == inst)
{
- nsfw_module_getManager ()->inst = inst->next;
- return;
+ nsfw_module_get_manager()->inst = inst->next;
+ return;
}
- nsfw_module_instance_t *curInst = nsfw_module_getManager ()->inst;
+ nsfw_module_instance_t *curInst = nsfw_module_get_manager()->inst;
- while (curInst->next && curInst->next != inst)
- curInst = curInst->next;
+ while (curInst->next && curInst->next != inst)
+ curInst = curInst->next;
- if (!curInst->next)
- return;
- curInst->next = inst->next;
+ if (!curInst->next)
+ return;
+ curInst->next = inst->next;
}
-nsfw_module_instance_t *
-nsfw_module_getModuleByName (char *name)
+nsfw_module_instance_t *nsfw_module_get_module_by_name(char *name)
{
- if (NULL == name)
- return NULL;
+ if (NULL == name)
+ return NULL;
- nsfw_module_instance_t *curInst = nsfw_module_getManager ()->inst;
- while (curInst)
+ nsfw_module_instance_t *curInst = nsfw_module_get_manager()->inst;
+ while (curInst)
{
- if (0 == strcmp (curInst->name, name))
+ if (0 == strcmp(curInst->name, name))
{
- return curInst;
+ return curInst;
}
- curInst = curInst->next;
+ curInst = curInst->next;
}
- return NULL;
+ return NULL;
}
-int
-nsfw_module_addDoneNode (nsfw_module_instance_t * inst)
+int nsfw_module_add_done_node(nsfw_module_instance_t * inst)
{
- nsfw_module_doneNode_t *node =
- (nsfw_module_doneNode_t *) malloc (sizeof (nsfw_module_doneNode_t));
- if (NULL == node)
- return -1;
- node->inst = inst;
- node->next = NULL;
-
- nsfw_module_manager_t *manager = nsfw_module_getManager ();
- if (NULL == manager->doneHead)
+ nsfw_module_done_node_t *node = (nsfw_module_done_node_t *) malloc(sizeof(nsfw_module_done_node_t)); /*malloc can use */
+ if (NULL == node)
+ {
+ return -1;
+ }
+ node->inst = inst;
+ node->next = NULL;
+
+ nsfw_module_manager_t *manager = nsfw_module_get_manager();
+ if (NULL == manager->doneHead)
{
- manager->doneHead = node;
+ manager->doneHead = node;
}
- else
+ else
{
- nsfw_module_doneNode_t *tail = manager->doneHead;
- while (tail->next)
+ nsfw_module_done_node_t *tail = manager->doneHead;
+ while (tail->next)
{
- tail = tail->next;
+ tail = tail->next;
}
- tail->next = node;
+ tail->next = node;
}
- return 0;
+ return 0;
}
#ifdef __cplusplus
diff --git a/src/framework/init/fw_module.h b/src/framework/init/fw_module.h
index 0818aed..a3da4f4 100644
--- a/src/framework/init/fw_module.h
+++ b/src/framework/init/fw_module.h
@@ -17,15 +17,13 @@
#ifndef _FW_MODULE
#define _FW_MODULE
#include <pthread.h>
-
+#include "nsfw_init_api.h"
#ifdef __cplusplus
/* *INDENT-OFF* */
extern "C"{
/* *INDENT-ON* */
#endif /* _cplusplus */
-#include "nsfw_init.h"
-
/* Unique name declare */
#define NSFW__STRINGIFY(x) #x
#define NSFW_STRINGIFY(x) NSFW__STRINGIFY(x)
@@ -37,43 +35,45 @@ extern "C"{
#define NSFW_MODULE_INITFN(_fn) \
static int _fn(void* param)
-extern nsfw_module_depends_t *nsfw_module_create_depends (char *name);
+
+#define NSFW_DEPENDS_SIZE 8
#define NSFW_MODULE_SET_STATE(inst, state) ((inst)->stat = (state))
-typedef struct _nsfw_module_doneNode
+/*Change module malloc to pool array*/
+#define NSFW_MODULE_INSTANCE_POOL_SIZE 64
+#define NSFW_MODULE_DEPENDS_POOL_SIZE 128
+
+typedef struct _nsfw_module_done_node
{
- nsfw_module_instance_t *inst;
- struct _nsfw_module_doneNode *next;
-} nsfw_module_doneNode_t;
+ nsfw_module_instance_t *inst;
+ struct _nsfw_module_done_node *next;
+} nsfw_module_done_node_t;
typedef struct _nsfw_module_manager
{
- pthread_mutex_t initMutex;
- int done; // 0 - not finished, 1 - finished, -1 - error
- nsfw_module_instance_t *inst;
- nsfw_module_doneNode_t *doneHead;
+ pthread_mutex_t initMutex;
+ int done; // 0 - not finished, 1 - finished, -1 - error
+ nsfw_module_instance_t *inst;
+ nsfw_module_done_node_t *doneHead;
} nsfw_module_manager_t;
-extern int nsfw_module_addDoneNode (nsfw_module_instance_t * inst);
+extern int nsfw_module_add_done_node(nsfw_module_instance_t * inst);
extern nsfw_module_manager_t g_nsfw_module_manager;
-#define nsfw_module_getManager() (&g_nsfw_module_manager)
-
-#define NSFW_MODULE_INSTANCE_POOL_SIZE 64
-#define NSFW_MODULE_DEPENDS_POOL_SIZE 128
+#define nsfw_module_get_manager() (&g_nsfw_module_manager)
typedef struct _nsfw_module_instance_pool
{
- int last_idx;
- nsfw_module_instance_t
- module_instance_pool[NSFW_MODULE_INSTANCE_POOL_SIZE];
+ int last_idx;
+ nsfw_module_instance_t
+ module_instance_pool[NSFW_MODULE_INSTANCE_POOL_SIZE];
} nsfw_module_instance_pool_t;
typedef struct _nsfw_module_depends_pool
{
- int last_idx;
- nsfw_module_depends_t module_depends_pool[NSFW_MODULE_DEPENDS_POOL_SIZE];
+ int last_idx;
+ nsfw_module_depends_t module_depends_pool[NSFW_MODULE_DEPENDS_POOL_SIZE];
} nsfw_module_depends_pool_t;
#ifdef __cplusplus
diff --git a/src/framework/ipc/mgr_com/mgr_com.c b/src/framework/ipc/mgr_com/mgr_com.c
index a2998fa..d09f1d5 100644
--- a/src/framework/ipc/mgr_com/mgr_com.c
+++ b/src/framework/ipc/mgr_com/mgr_com.c
@@ -20,8 +20,7 @@
#include "types.h"
#include "nstack_securec.h"
-#include "nsfw_init.h"
-#include "common_mem_api.h"
+#include "nsfw_init_api.h"
#include "nsfw_mgr_com_api.h"
#include "mgr_com.h"
@@ -32,13 +31,12 @@
#include <stddef.h>
#include <sys/epoll.h>
#include <fcntl.h>
-#include <sys/stat.h>
#include "nsfw_maintain_api.h"
#include "nsfw_ps_api.h"
#include "nsfw_fd_timer_api.h"
-#include "common_func.h"
+#include "nsfw_maintain_api.h"
#ifdef __cplusplus
/* *INDENT-OFF* */
@@ -46,49 +44,50 @@ extern "C"{
/* *INDENT-ON* */
#endif /* __cplusplus */
+nsfw_mgr_msg_fun g_mgr_fun[MGR_MSG_MAX][NSFW_MGRCOM_MAX_PROC_FUN];
/* *INDENT-OFF* */
+/* nstackMaster can't start daemon-stack successfully,
+ because daemon-stack can't successfully recv MGR_MSG_INIT_NTY_RSP */
+nsfw_mgr_init_cfg g_mgr_com_cfg =
+{
+ .msg_size = MGR_COM_MSG_COUNT_DEF,
+ .max_recv_timeout = MGR_COM_RECV_TIMEOUT_DEF,
+ .max_recv_drop_msg = MGR_COM_MAX_DROP_MSG_DEF,
+};
-/* *INDENT-OFF* */
-nsfw_mgr_msg_fun g_mgr_fun[MGR_MSG_MAX][NSFW_MGRCOM_MAX_PROC_FUN];
-nsfw_mgr_init_cfg g_mgr_com_cfg;
-nsfw_mgr_sock_map g_mgr_socket_map = {{0}, NULL};
+nsfw_mgr_sock_map g_mgr_sockt_map = {{0}, NULL};
nsfw_mgrcom_stat g_mgr_stat;
-nsfw_mgrcom_proc g_ep_proc = { 0 };
-/* *INDENT-ON* */
-
+nsfw_mgrcom_proc g_ep_proc = {0};
u32 g_mgr_sockfdmax = NSFW_MGRCOM_MAX_SOCKET;
+
char g_proc_info[NSFW_PROC_MAX][NSTACK_MAX_PROC_NAME_LEN] = {
- "", "nStackMain", "nStackMaster", "nStackLib", "nStackTools", "nStackCtrl",
- "", "", "", "", "", "", "", "", "", ""
+ ""
+ ,"nStackMain"
+ ,"nStackMaster"
+ ,"nStackLib"
+ ,"nStackCtrl"
+ ,"nStackTools"
+ ,"","","","",""
+ ,"","","","",""
};
-
/* *INDENT-ON* */
-int g_thread_policy = 0;
-int g_thread_pri = 0;
+char *g_home_direct = NULL;
-void
-nsfw_com_attr_set (int policy, int pri)
+char *nsfw_get_proc_name(u8 proc_type)
{
- g_thread_policy = policy;
- g_thread_pri = pri;
-}
-
-char *
-nsfw_get_proc_name (u8 proc_type)
-{
- if (proc_type >= NSFW_PROC_MAX || NSFW_PROC_NULL == proc_type)
+ if (proc_type >= NSFW_PROC_MAX || NSFW_PROC_NULL == proc_type)
{
- return NULL;
+ return NULL;
}
- return g_proc_info[proc_type];
+ return g_proc_info[proc_type];
}
/*****************************************************************************
* Prototype : nsfw_mgr_reg_msg_fun
-* Description : reg the callback function when receive new message
+* Description : reg the callback funciton when receive new message
* Input : u16 msg_type
* nsfw_mgr_msg_fun fun
* Output : None
@@ -96,29 +95,29 @@ nsfw_get_proc_name (u8 proc_type)
* Calls :
* Called By :
*****************************************************************************/
-u8
-nsfw_mgr_reg_msg_fun (u16 msg_type, nsfw_mgr_msg_fun fun)
+u8 nsfw_mgr_reg_msg_fun(u16 msg_type, nsfw_mgr_msg_fun fun)
{
- u32 i;
- if (MGR_MSG_MAX <= msg_type)
+ u32 i;
+ if (MGR_MSG_MAX <= msg_type)
{
- NSFW_LOGERR ("reg mgr_msg]msg_type=%u,fun=%p", msg_type, fun);
- return FALSE;
+ NSFW_LOGERR("reg mgr_msg]msg_type=%u,fun=%p", msg_type, fun);
+ return FALSE;
}
- for (i = 0; i < NSFW_MGRCOM_MAX_PROC_FUN; i++)
+ for (i = 0; i < NSFW_MGRCOM_MAX_PROC_FUN; i++)
{
- if (NULL == g_mgr_fun[msg_type][i])
+ if (NULL == g_mgr_fun[msg_type][i])
{
- g_mgr_fun[msg_type][i] = fun;
- NSFW_LOGINF ("reg mgr_msg fun suc]msg_type=%u,fun=%p", msg_type,
- fun);
- return TRUE;
+ /*TODO should use cas */
+ g_mgr_fun[msg_type][i] = fun;
+ NSFW_LOGINF("reg mgr_msg fun suc]msg_type=%u,fun=%p", msg_type,
+ fun);
+ return TRUE;
}
}
- NSFW_LOGERR ("reg mgr_msg type full]msg_type=%u,fun=%p", msg_type, fun);
- return FALSE;
+ NSFW_LOGERR("reg mgr_msg type full]msg_type=%u,fun=%p", msg_type, fun);
+ return FALSE;
}
/*****************************************************************************
@@ -130,10 +129,9 @@ nsfw_mgr_reg_msg_fun (u16 msg_type, nsfw_mgr_msg_fun fun)
* Calls :
* Called By :
*****************************************************************************/
-nsfw_mgr_msg *
-nsfw_mgr_null_rspmsg_alloc ()
+nsfw_mgr_msg *nsfw_mgr_null_rspmsg_alloc()
{
- return nsfw_mgr_msg_alloc (MGR_MSG_NULL, NSFW_PROC_NULL);
+ return nsfw_mgr_msg_alloc(MGR_MSG_NULL, NSFW_PROC_NULL);
}
/*****************************************************************************
@@ -146,86 +144,75 @@ nsfw_mgr_null_rspmsg_alloc ()
* Calls :
* Called By :
*****************************************************************************/
-nsfw_mgr_msg *
-nsfw_mgr_msg_alloc (u16 msg_type, u8 dst_proc_type)
+nsfw_mgr_msg *nsfw_mgr_msg_alloc(u16 msg_type, u8 dst_proc_type)
{
- nsfw_mgr_msg *p_msg = NULL;
- u8 from_mem_flag = FALSE;
- u32 alloc_len = sizeof (nsfw_mgr_msg);
+ nsfw_mgr_msg *p_msg = NULL;
+ u8 from_mem_flag = FALSE;
+ u32 alloc_len = sizeof(nsfw_mgr_msg);
- if (MGR_MSG_LAG_QRY_RSP_BEGIN <= msg_type)
+ if (MGR_MSG_LAG_QRY_RSP_BEGIN <= msg_type
+ || MGR_MSG_SPLNET_REQ == msg_type)
{
- from_mem_flag = TRUE;
- alloc_len = NSFW_MGR_LARGE_MSG_LEN;
+ from_mem_flag = TRUE;
+ alloc_len = NSFW_MGR_LARGE_MSG_LEN;
}
- if ((NULL == g_mgr_com_cfg.msg_pool)
- && (MGR_MSG_INIT_NTY_REQ == msg_type
- || MGR_MSG_INIT_NTY_RSP == msg_type))
+ if ((NULL == g_mgr_com_cfg.msg_pool)
+ && (MGR_MSG_INIT_NTY_REQ == msg_type
+ || MGR_MSG_INIT_NTY_RSP == msg_type))
{
- from_mem_flag = TRUE;
+ from_mem_flag = TRUE;
}
- if (FALSE == from_mem_flag)
+ if (FALSE == from_mem_flag)
{
- if (0 ==
- nsfw_mem_ring_dequeue (g_mgr_com_cfg.msg_pool, (void *) &p_msg))
+ if (0 ==
+ nsfw_mem_ring_dequeue(g_mgr_com_cfg.msg_pool, (void *) &p_msg))
{
- NSFW_LOGERR ("alloc msg full]type=%u,dst=%u", msg_type,
- dst_proc_type);
- return NULL;
+ NSFW_LOGERR("alloc msg full]type=%u,dst=%u", msg_type,
+ dst_proc_type);
+ return NULL;
}
- alloc_len = sizeof (nsfw_mgr_msg);
+ alloc_len = sizeof(nsfw_mgr_msg);
}
- else
+ else
{
- p_msg = (nsfw_mgr_msg *) malloc (alloc_len);
+ p_msg = (nsfw_mgr_msg *) malloc(alloc_len); /*malloc() can be used */
}
- if (NULL == p_msg)
+ if (NULL == p_msg)
{
- NSFW_LOGERR ("alloc msg nul]type=%u,dst=%u", msg_type, dst_proc_type);
- return NULL;
+ NSFW_LOGERR("alloc msg nul]type=%u,dst=%u", msg_type, dst_proc_type);
+ return NULL;
}
- if (EOK != MEMSET_S (p_msg, alloc_len, 0, alloc_len))
+ if (EOK != memset_s(p_msg, alloc_len, 0, alloc_len))
{
- p_msg->from_mem = from_mem_flag;
- nsfw_mgr_msg_free (p_msg);
- NSFW_LOGERR ("alloc msg MEMSET_S failed]type=%u,dst=%u", msg_type,
- dst_proc_type);
- return NULL;
+ p_msg->from_mem = from_mem_flag;
+
+ nsfw_mgr_msg_free(p_msg);
+ NSFW_LOGERR("alloc msg memset_s failed]type=%u,dst=%u", msg_type,
+ dst_proc_type);
+ return NULL;
}
- p_msg->from_mem = from_mem_flag;
+ p_msg->from_mem = from_mem_flag;
- if (msg_type < MGR_MSG_RSP_BASE && msg_type > 0)
+ if (msg_type < MGR_MSG_RSP_BASE && msg_type > 0)
{
- p_msg->seq = common_mem_atomic32_add_return (&g_mgr_com_cfg.cur_idx, 1);
+ p_msg->seq = dmm_atomic_add_return(&g_mgr_com_cfg.cur_idx, 1);
}
- p_msg->from_mem = from_mem_flag;
- p_msg->msg_type = msg_type;
- p_msg->src_pid = get_sys_pid ();
- p_msg->src_proc_type = g_mgr_com_cfg.proc_type;
- p_msg->msg_len = alloc_len;
- p_msg->dst_proc_type = dst_proc_type;
- p_msg->alloc_flag = TRUE;
- p_msg->more_msg_flag = 0;
+ p_msg->from_mem = from_mem_flag;
+ p_msg->msg_type = msg_type;
+ p_msg->src_pid = get_sys_pid();
+ p_msg->src_proc_type = g_mgr_com_cfg.proc_type;
+ p_msg->msg_len = alloc_len;
+ p_msg->dst_proc_type = dst_proc_type;
+ p_msg->alloc_flag = TRUE;
+ p_msg->more_msg_flag = 0;
- g_mgr_stat.msg_alloc++;
- return p_msg;
-}
-
-static inline void
-lint_lock_1 ()
-{
- return;
-}
-
-static inline void
-lint_unlock_1 ()
-{
- return;
+ g_mgr_stat.msg_alloc++;
+ return p_msg;
}
/*****************************************************************************
@@ -237,27 +224,26 @@ lint_unlock_1 ()
* Calls :
* Called By :
*****************************************************************************/
-nsfw_mgr_msg *
-nsfw_mgr_rsp_msg_alloc (nsfw_mgr_msg * req_msg)
+nsfw_mgr_msg *nsfw_mgr_rsp_msg_alloc(nsfw_mgr_msg * req_msg)
{
- nsfw_mgr_msg *p_msg = NULL;
- if (NULL == req_msg)
+ nsfw_mgr_msg *p_msg = NULL;
+ if (NULL == req_msg)
{
- NSFW_LOGERR ("req msg nul!");
- return NULL;
+ NSFW_LOGERR("req msg nul!");
+ return NULL;
}
- p_msg =
- nsfw_mgr_msg_alloc (req_msg->msg_type + MGR_MSG_RSP_BASE,
- req_msg->src_proc_type);
- if (NULL == p_msg)
+ p_msg =
+ nsfw_mgr_msg_alloc(req_msg->msg_type + MGR_MSG_RSP_BASE,
+ req_msg->src_proc_type);
+ if (NULL == p_msg)
{
- return NULL;
+ return NULL;
}
- p_msg->dst_pid = req_msg->src_pid;
- p_msg->seq = req_msg->seq;
- return p_msg;
+ p_msg->dst_pid = req_msg->src_pid;
+ p_msg->seq = req_msg->seq;
+ return p_msg;
}
/*****************************************************************************
@@ -269,44 +255,87 @@ nsfw_mgr_rsp_msg_alloc (nsfw_mgr_msg * req_msg)
* Calls :
* Called By :
*****************************************************************************/
-void
-nsfw_mgr_msg_free (nsfw_mgr_msg * msg)
+void nsfw_mgr_msg_free(nsfw_mgr_msg * msg)
{
- if (NULL == msg)
+
+ if (NULL == msg)
{
- return;
+ return;
}
- if (FALSE == msg->alloc_flag)
+ if (FALSE == msg->alloc_flag)
+ {
+ NSFW_LOGERR("msg refree]msg=%p, type=%u", msg, msg->msg_type);
+ return;
+ }
+
+ msg->alloc_flag = FALSE;
+
+ if (TRUE == msg->from_mem)
+ {
+ /*remove msg->msg_type judgement */
+ free(msg); /*free() can be used */
+ g_mgr_stat.msg_free++;
+ return;
+ }
+ else
{
- NSFW_LOGERR ("msg refree]msg=%p, type=%u", msg, msg->msg_type);
- return;
+ if (0 == nsfw_mem_ring_enqueue(g_mgr_com_cfg.msg_pool, msg))
+ {
+ NSFW_LOGERR("msg free failed pool full]msg=%p, type=%u", msg,
+ msg->msg_type);
+ return;
+ }
+ g_mgr_stat.msg_free++;
}
- msg->alloc_flag = FALSE;
+ return;
+}
- if (TRUE == msg->from_mem)
+/*****************************************************************************
+* Prototype : get_home_path
+* Description : get the env "HOME" path info
+* Input :
+* Output : None
+* Return Value : int
+* Calls :
+* Called By :
+*****************************************************************************/
+const char *get_home_path()
+{
+ //a extern global var, if not null ,just return it.
+ if (g_home_direct)
{
- if ((MGR_MSG_INIT_NTY_REQ == msg->msg_type
- || MGR_MSG_INIT_NTY_RSP == msg->msg_type)
- || (MGR_MSG_LAG_QRY_RSP_BEGIN <= msg->msg_type))
+ return g_home_direct;
+ }
+
+ //just need do one time.
+ const char *home_dir = getenv("HOME"); /*getenv() can be used */
+ if (getuid() != 0 && home_dir != NULL)
+ {
+ g_home_direct = realpath(home_dir, NULL);
+ if (!g_home_direct)
{
- free (msg);
- g_mgr_stat.msg_free++;
- return;
+ NSFW_LOGWAR("realpath fail]home_dir=%s,errno=%d", home_dir,
+ errno);
+ return NULL;
}
- NSFW_LOGERR ("msg err free]type=%u", msg->msg_type);
}
- if (0 == nsfw_mem_ring_enqueue (g_mgr_com_cfg.msg_pool, msg))
+ //check if the path is valid
+ if (check_log_dir_valid(g_home_direct) < 0)
{
- NSFW_LOGERR ("msg free failed pool full]msg=%p, type=%u", msg,
- msg->msg_type);
- return;
+ NSFW_LOGWAR("path check valid fail, free it]home_direct=%s",
+ g_home_direct);
+ if (g_home_direct)
+ {
+ free(g_home_direct);
+ g_home_direct = NULL;
+ }
+ return NULL;
}
- g_mgr_stat.msg_free++;
- return;
+ return g_home_direct;
}
/*****************************************************************************
@@ -318,82 +347,99 @@ nsfw_mgr_msg_free (nsfw_mgr_msg * msg)
* Calls :
* Called By :
*****************************************************************************/
-i32
-nsfw_mgr_get_listen_socket ()
+i32 nsfw_mgr_get_listen_socket()
{
- i32 fd, len, retVal;
- struct sockaddr_un un;
- char name[NSFW_MGRCOM_PATH_LEN] = { 0 };
+ i32 fd, len;
+ struct sockaddr_un un;
- if ((fd = nsfw_base_socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
+ if ((fd = nsfw_base_socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
{
- NSFW_LOGERR ("create sock failed!");
- return -1;
+ NSFW_LOGERR("create sock failed!");
+ return -1;
}
- retVal = STRCPY_S ((char *) name, sizeof (name),
- (char *) g_mgr_com_cfg.domain_path);
- if (EOK != retVal)
+ if (-1 == unlink((char *) g_mgr_com_cfg.domain_path))
{
- (void) nsfw_base_close (fd);
- NSFW_LOGERR ("module mgr get listen STRCPY_S failed! ret=%d", retVal);
- return -1;
+ NSFW_LOGWAR("unlink failed]error=%d", errno);
}
- if (EOK != STRCAT_S (name, NSFW_MGRCOM_PATH_LEN, NSFW_MAIN_FILE))
+ if (EOK != memset_s(&un, sizeof(un), 0, sizeof(un)))
{
- (void) nsfw_base_close (fd);
- NSFW_LOGERR ("module mgr get listen STRCAT_S failed!");
- return -1;
+ (void) nsfw_base_close(fd);
+ NSFW_LOGERR("create sock memset_s failed!] error=%d", errno);
+ return -1;
}
- if (-1 == unlink ((char *) name))
+ un.sun_family = AF_UNIX;
+ int retVal = strcpy_s((char *) un.sun_path, sizeof(un.sun_path),
+ (char *) g_mgr_com_cfg.domain_path);
+ if (EOK != retVal)
{
- NSFW_LOGWAR ("unlink failed]error=%d", errno);
+ (void) nsfw_base_close(fd);
+ NSFW_LOGERR("create sock strcpy_s failed!] error=%d", errno);
+ return -1;
}
- if (EOK != MEMSET_S (&un, sizeof (un), 0, sizeof (un)))
+
+ /* close on exec */
+ int rc = nsfw_set_close_on_exec(fd);
+ if (rc == -1)
{
- (void) nsfw_base_close (fd);
- NSFW_LOGERR ("create sock MEMSET_S failed!] error=%d", errno);
- return -1;
+ (void) nsfw_base_close(fd);
+ NSFW_LOGERR("set exec err]fd=%d, errno=%d", fd, errno);
+ return -1;
}
- un.sun_family = AF_UNIX;
- retVal = STRCPY_S ((char *) un.sun_path, sizeof (un.sun_path),
- (char *) name);
- if (EOK != retVal)
+ len = offsetof(struct sockaddr_un, sun_path) +strlen((char *) g_mgr_com_cfg.domain_path); /*strlen() can be used */
+
+ if (nsfw_base_bind(fd, (struct sockaddr *) &un, len) < 0)
{
- (void) nsfw_base_close (fd);
- NSFW_LOGERR ("create sock STRCPY_S failed!] error=%d", errno);
- return -1;
+ (void) nsfw_base_close(fd);
+ NSFW_LOGERR("bind failed!]mgr_fd=%d,error=%d", fd, errno);
+ return -1;
}
- int rc = nsfw_set_close_on_exec (fd);
- if (rc == -1)
+ if (nsfw_base_listen(fd, 10) < 0)
{
- (void) nsfw_base_close (fd);
- NSFW_LOGERR ("set exec err]fd=%d, errno=%d", fd, errno);
- return -1;
+ (void) nsfw_base_close(fd);
+ NSFW_LOGERR("listen failed!]mgr_fd=%d,error=%d", fd, errno);
+ return -1;
}
- len = offsetof (struct sockaddr_un, sun_path) +strlen ((char *) name);
+ NSFW_LOGINF("mgr com start with]mgr_fd=%d", fd);
+ return fd;
+}
- if (nsfw_base_bind (fd, (struct sockaddr *) &un, len) < 0)
+/*****************************************************************************
+* Prototype : nsfw_mgr_connect_with_retry
+* Description : connect dst_socket, retry some times every 100ms
+* Input : nsfw_mgr_msg* req_msg
+* nsfw_mgr_msg* rsp_msg
+* Output : None
+* Return Value : u8
+* Calls :
+* Called By :
+*****************************************************************************/
+i32 nsfw_mgr_connect_with_retry(i32 fd, struct sockaddr * un, i32 len,
+ i32 interval_ms, i32 retry_times)
+{
+ if (nsfw_base_connect(fd, un, len) == 0)
{
- (void) nsfw_base_close (fd);
- NSFW_LOGERR ("bind failed!]mgr_fd=%d,error=%d", fd, errno);
- return -1;
+ return 0;
}
-
- if (nsfw_base_listen (fd, 10) < 0)
+ while (retry_times > 0)
{
- (void) nsfw_base_close (fd);
- NSFW_LOGERR ("listen failed!]mgr_fd=%d,error=%d", fd, errno);
- return -1;
+ sys_sleep_ns(0, interval_ms * 1000 * 1000);
+ --retry_times;
+ if (nsfw_base_connect(fd, un, len) == 0)
+ {
+ return 0;
+ }
+ else if (errno != ECONNRESET && errno != ECONNREFUSED) /* Retry is for Master upgrade only */
+ {
+ return -1;
+ }
}
-
- NSFW_LOGINF ("mgr com start with]mgr_fd=%d", fd);
- return fd;
+ return -1;
}
/*****************************************************************************
@@ -406,115 +452,138 @@ nsfw_mgr_get_listen_socket ()
* Calls :
* Called By :
*****************************************************************************/
-i32
-nsfw_mgr_get_connect_socket (u8 proc_type, u32 host_pid)
+i32 nsfw_mgr_get_connect_socket(u8 proc_type, u32 host_pid)
{
- i32 fd, len;
- char *name;
- struct sockaddr_un un;
- const char *directory = NSFW_DOMAIN_DIR;
- const char *home_dir = getenv ("HOME");
+ i32 fd = -1;
+ i32 len = 0;
+ char *name;
+ struct sockaddr_un un;
+ i32 retry_times = 0;
+ i32 interval_ms = 50;
+ const char *directory = NSFW_DOMAIN_DIR;
+ const char *home_dir = get_home_path();
+ if (home_dir)
+ {
+ directory = home_dir;
+ }
- if (getuid () != 0 && home_dir != NULL)
- directory = home_dir;
+ switch (proc_type)
+ {
+ case NSFW_PROC_MAIN:
+ name = NSFW_MAIN_FILE;
+ break;
+ case NSFW_PROC_MASTER:
+ name = NSFW_MASTER_FILE;
+ retry_times = 10;
+ break;
+ case NSFW_PROC_ALARM: /* alarm */
+ directory = "/tmp";
+ name = NSFW_ALARM_FILE;
+ break;
+ default:
+ NSFW_LOGERR("get dst socket err]type=%u,pid=%u", proc_type,
+ host_pid);
+ return -1;
+ }
- switch (proc_type)
+ if ((fd = nsfw_base_socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
{
- case NSFW_PROC_MAIN:
- name = NSFW_MAIN_FILE;
- break;
- case NSFW_PROC_ALARM:
- directory = "/tmp";
- name = NSFW_ALARM_FILE;
- break;
- default:
- NSFW_LOGERR ("get dst socket err]type=%u,pid=%u", proc_type, host_pid);
- return -1;
+ NSFW_LOGERR("create socket err]type=%u,pid=%u,errno=%d", proc_type,
+ host_pid, errno);
+ return -1;
}
- if ((fd = nsfw_base_socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
+ if (EOK != memset_s(&un, sizeof(un), 0, sizeof(un)))
{
- NSFW_LOGERR ("create socket err]type=%u,pid=%u,errno=%d", proc_type,
- host_pid, errno);
- return -1;
+ (void) nsfw_base_close(fd);
+ NSFW_LOGERR("get dst socket err]mgr_fd=%d,type=%u,pid=%u", fd,
+ proc_type, host_pid);
+ return -1;
}
- if (EOK != MEMSET_S (&un, sizeof (un), 0, sizeof (un)))
+ struct timeval tv;
+ tv.tv_sec = MGR_COM_RECV_TIMEOUT;
+ tv.tv_usec = 0;
+ if (nsfw_base_setsockopt
+ (fd, SOL_SOCKET, SO_RCVTIMEO, (char *) &tv, sizeof tv))
{
- (void) nsfw_base_close (fd);
- NSFW_LOGERR ("get dst socket err]mgr_fd=%d,type=%u,pid=%u", fd,
- proc_type, host_pid);
- return -1;
+ NSFW_LOGERR
+ ("setsockopt socket err]mgr_fd=%d,type=%u,pid=%u,errno=%d", fd,
+ proc_type, host_pid, errno);
+ (void) nsfw_base_close(fd);
+ return -1;
}
- struct timeval tv;
- tv.tv_sec = MGR_COM_RECV_TIMEOUT;
- tv.tv_usec = 0;
- if (nsfw_base_setsockopt
- (fd, SOL_SOCKET, SO_RCVTIMEO, (char *) &tv, sizeof tv))
+ tv.tv_sec = MGR_COM_SEND_TIMEOUT_DEF;
+ tv.tv_usec = 0;
+ if (nsfw_base_setsockopt
+ (fd, SOL_SOCKET, SO_SNDTIMEO, (char *) &tv, sizeof tv))
{
- (void) nsfw_base_close (fd);
- NSFW_LOGERR ("setsockopt socket err]mgr_fd=%d,type=%u,pid=%u", fd,
- proc_type, host_pid);
- return -1;
+ NSFW_LOGERR
+ ("setsockopt socket err]mgr_fd=%d,type=%u,pid=%u,errno=%d", fd,
+ proc_type, host_pid, errno);
+ (void) nsfw_base_close(fd);
+ return -1;
}
- int rc = nsfw_set_close_on_exec (fd);
- if (rc == -1)
+ /* close on exec Add Begin */
+ int rc = nsfw_set_close_on_exec(fd);
+ if (rc == -1)
{
- (void) nsfw_base_close (fd);
- NSFW_LOGERR ("set exec err]fd=%d, errno=%d", fd, errno);
- return -1;
+ (void) nsfw_base_close(fd);
+ NSFW_LOGERR("set exec err]fd=%d, errno=%d", fd, errno);
+ return -1;
}
- int size, size_len;
- size = MAX_RECV_BUF_DEF;
- size_len = sizeof (size);
- if (0 >
- nsfw_base_setsockopt (fd, SOL_SOCKET, SO_RCVBUF, (void *) &size,
- (socklen_t) size_len))
+ int size, size_len;
+ size = MAX_RECV_BUF_DEF;
+ size_len = sizeof(size);
+ if (0 >
+ nsfw_base_setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (void *) &size,
+ (socklen_t) size_len))
{
- NSFW_LOGERR ("set socket opt err!]error=%d", errno);
+ NSFW_LOGERR("set socket opt err]error=%d", errno);
}
- if (0 >
- nsfw_base_setsockopt (fd, SOL_SOCKET, SO_SNDBUF, (void *) &size,
- (socklen_t) size_len))
+ if (0 >
+ nsfw_base_setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (void *) &size,
+ (socklen_t) size_len))
{
- NSFW_LOGERR ("set socket opt err!]error=%d", errno);
+ NSFW_LOGERR("set socket opt err]error=%d", errno);
}
- un.sun_family = AF_UNIX;;
- int retVal = STRCPY_S ((char *) un.sun_path, sizeof (un.sun_path),
- (char *) directory);
- if (EOK != retVal)
+ un.sun_family = AF_UNIX;;
+ int retVal = strcpy_s((char *) un.sun_path, sizeof(un.sun_path),
+ (char *) directory);
+ if (EOK != retVal)
{
- (void) nsfw_base_close (fd);
- NSFW_LOGERR ("create sock STRCPY_S failed!] error=%d", errno);
- return -1;
+ (void) nsfw_base_close(fd);
+ NSFW_LOGERR("create sock strcpy_s fail]error=%d", errno);
+ return -1;
}
- retVal = STRCAT_S (un.sun_path, sizeof (un.sun_path), name);
- if (EOK != retVal)
+ retVal = strcat_s(un.sun_path, sizeof(un.sun_path), name);
+ if (EOK != retVal)
{
- (void) nsfw_base_close (fd);
- NSFW_LOGERR ("create sock STRCAT_S failed!] error=%d", errno);
- return -1;
+ (void) nsfw_base_close(fd);
+ NSFW_LOGERR("create sock strcat_s fail]error=%d", errno);
+ return -1;
}
- len = offsetof (struct sockaddr_un, sun_path) +strlen (un.sun_path);
- if (nsfw_base_connect (fd, (struct sockaddr *) &un, len) < 0)
+ len = offsetof(struct sockaddr_un, sun_path) +strlen(un.sun_path); /*strlen() can be used */
+ if (nsfw_mgr_connect_with_retry
+ (fd, (struct sockaddr *) &un, len, interval_ms, retry_times) < 0)
{
- (void) nsfw_base_close (fd);
- NSFW_LOGERR
- ("create socket err]mgr_fd=%d,type=%u,pid=%u,errno=%d,path=%s", fd,
- proc_type, host_pid, errno, un.sun_path);
- return -1;
+ (void) nsfw_base_close(fd);
+ NSFW_LOGERR
+ ("connect socket failed]mgr_fd=%d,type=%u,pid=%u,errno=%d,path=%s",
+ fd, proc_type, host_pid, errno, un.sun_path);
+ return -1;
}
- NSFW_LOGINF ("get dst socket]mgr_fd=%d,type=%u,pid=%u", fd, proc_type,
- host_pid);
- return (fd);
+ NSFW_LOGINF("get dst socket]mgr_fd=%d,type=%u,pid=%u", fd, proc_type,
+ host_pid);
+ return fd;
}
/*****************************************************************************
@@ -528,33 +597,42 @@ nsfw_mgr_get_connect_socket (u8 proc_type, u32 host_pid)
* Calls :
* Called By :
*****************************************************************************/
-NSTACK_STATIC inline u8
-nsfw_mgr_new_socket (i32 fd, u8 proc_type, u32 host_pid)
+NSTACK_STATIC inline u8 nsfw_mgr_new_socket(i32 fd, u8 proc_type,
+ u32 host_pid)
{
- nsfw_mgr_sock_info *sock_info = NULL;
- if (((i32) NSFW_MGR_FD_MAX <= fd) || (fd < 0) || (!g_mgr_socket_map.sock))
+ nsfw_mgr_sock_info *sock_info = NULL;
+ if (((i32) NSFW_MGR_FD_MAX <= fd) || (fd < 0) || (!g_mgr_sockt_map.sock))
{
- NSFW_LOGERR ("fd err]mgr_fd=%d, sock=%p", fd, g_mgr_socket_map.sock);
- return FALSE;
+ NSFW_LOGERR("fd err]mgr_fd=%d, sock=%p", fd, g_mgr_sockt_map.sock);
+ return FALSE;
}
- sock_info = &g_mgr_socket_map.sock[fd];
- if (host_pid != sock_info->host_pid)
+ sock_info = &g_mgr_sockt_map.sock[fd];
+ if (host_pid != sock_info->host_pid)
{
- NSFW_LOGDBG
- ("update sock info]mgr_fd=%d,old_pid=%u,new_pid=%u,type=%u", fd,
- sock_info->host_pid, host_pid, proc_type);
+ /* Fix mgr fd leak */
+ if (g_mgr_com_cfg.proc_type == NSFW_PROC_MAIN
+ && (proc_type == NSFW_PROC_MAIN || proc_type == NSFW_PROC_MASTER))
+ {
+ NSFW_LOGINF("update sock]fd=%d,opid=%u,npid=%u,type=%u", fd,
+ sock_info->host_pid, host_pid, proc_type);
+ }
+ else
+ {
+ NSFW_LOGDBG("update sock]fd=%d,opid=%u,npid=%u,type=%u", fd,
+ sock_info->host_pid, host_pid, proc_type);
+ }
}
- sock_info->host_pid = host_pid;
- sock_info->proc_type = proc_type;
+ sock_info->host_pid = host_pid;
+ sock_info->proc_type = proc_type;
- if (proc_type < NSFW_PROC_MAX)
+ if (proc_type < NSFW_PROC_MAX)
{
- g_mgr_socket_map.proc_cache[proc_type] = fd;
+ g_mgr_sockt_map.proc_cache[proc_type] = fd;
}
- return TRUE;
+ return TRUE;
}
/*****************************************************************************
@@ -566,29 +644,28 @@ nsfw_mgr_new_socket (i32 fd, u8 proc_type, u32 host_pid)
* Calls :
* Called By :
*****************************************************************************/
-NSTACK_STATIC inline u8
-nsfw_mgr_del_socket (u32 fd)
+NSTACK_STATIC inline u8 nsfw_mgr_del_socket(u32 fd)
{
- nsfw_mgr_sock_info *sock_info = NULL;
- if ((NSFW_MGR_FD_MAX <= fd) || (!g_mgr_socket_map.sock))
+ nsfw_mgr_sock_info *sock_info = NULL;
+ if ((NSFW_MGR_FD_MAX <= fd) || (!g_mgr_sockt_map.sock))
{
- NSFW_LOGERR ("fd err]mgr_fd=%u, sock=%p", fd, g_mgr_socket_map.sock);
- return FALSE;
+ NSFW_LOGERR("fd err]mgr_fd=%u,sock=%p", fd, g_mgr_sockt_map.sock);
+ return FALSE;
}
- sock_info = &g_mgr_socket_map.sock[fd];
+ sock_info = &g_mgr_sockt_map.sock[fd];
- if (sock_info->proc_type < NSFW_PROC_MAX
- && fd == g_mgr_socket_map.proc_cache[sock_info->proc_type])
+ if (sock_info->proc_type < NSFW_PROC_MAX
+ && fd == g_mgr_sockt_map.proc_cache[sock_info->proc_type])
{
- g_mgr_socket_map.proc_cache[sock_info->proc_type] = 0;
+ g_mgr_sockt_map.proc_cache[sock_info->proc_type] = 0;
}
- NSFW_LOGDBG ("del sock]mgr_fd=%u,type=%u,pid=%u", fd,
- sock_info->proc_type, sock_info->host_pid);
- sock_info->host_pid = 0;
- sock_info->proc_type = 0;
- return TRUE;
+ NSFW_LOGDBG("del sock]mgr_fd=%u,type=%u,pid=%u", fd,
+ sock_info->proc_type, sock_info->host_pid);
+ sock_info->host_pid = 0;
+ sock_info->proc_type = 0;
+ return TRUE;
}
/*****************************************************************************
@@ -601,53 +678,52 @@ nsfw_mgr_del_socket (u32 fd)
* Calls :
* Called By :
*****************************************************************************/
-NSTACK_STATIC inline i32
-nsfw_mgr_get_dst_socket (u8 proc_type, u32 dst_pid)
+NSTACK_STATIC inline i32 nsfw_mgr_get_dst_socket(u8 proc_type, u32 dst_pid)
{
- i32 fd = -1;
+ i32 fd = -1;
- nsfw_mgr_sock_info *sock_info = NULL;
+ nsfw_mgr_sock_info *sock_info = NULL;
- if (proc_type < NSFW_PROC_MAX)
+ if (proc_type < NSFW_PROC_MAX)
{
- fd = g_mgr_socket_map.proc_cache[proc_type];
+ fd = g_mgr_sockt_map.proc_cache[proc_type];
}
- if (!g_mgr_socket_map.sock)
+ if (!g_mgr_sockt_map.sock)
{
- return -1;
+ return -1;
}
- if (fd > 0 && fd < (i32) NSFW_MGR_FD_MAX)
+ if (fd > 0 && fd < (i32) NSFW_MGR_FD_MAX)
{
- sock_info = &g_mgr_socket_map.sock[fd];
- if (sock_info->host_pid != 0)
+ sock_info = &g_mgr_sockt_map.sock[fd];
+ if (sock_info->host_pid != 0)
{
- if (0 == dst_pid || dst_pid == sock_info->host_pid)
+ if (0 == dst_pid || dst_pid == sock_info->host_pid)
{
- return fd;
+ return fd;
}
}
- else if (proc_type == sock_info->proc_type)
+ else if (proc_type == sock_info->proc_type)
{
- return fd;
+ return fd;
}
}
- i32 i;
- for (i = 0; i < (i32) NSFW_MGR_FD_MAX; i++)
+ i32 i;
+ for (i = 0; i < (i32) NSFW_MGR_FD_MAX; i++)
{
- sock_info = &g_mgr_socket_map.sock[i];
- if (sock_info->host_pid != 0 && proc_type == sock_info->proc_type)
+ sock_info = &g_mgr_sockt_map.sock[i];
+ if (sock_info->host_pid != 0 && proc_type == sock_info->proc_type)
{
- if (0 == dst_pid || dst_pid == sock_info->host_pid)
+ if (0 == dst_pid || dst_pid == sock_info->host_pid)
{
- return i;
+ return i;
}
}
}
- return -1;
+ return -1;
}
/*****************************************************************************
@@ -660,17 +736,16 @@ nsfw_mgr_get_dst_socket (u8 proc_type, u32 dst_pid)
* Calls :
* Called By :
*****************************************************************************/
-i32
-nsfw_mgr_get_new_socket (u8 proc_type, u32 dst_pid)
+i32 nsfw_mgr_get_new_socket(u8 proc_type, u32 dst_pid)
{
- i32 fd = 0;
- fd = nsfw_mgr_get_connect_socket (proc_type, dst_pid);
- if (fd > 0)
+ i32 fd = 0;
+ fd = nsfw_mgr_get_connect_socket(proc_type, dst_pid);
+ if (fd > 0)
{
- (void) nsfw_mgr_new_socket (fd, proc_type, dst_pid);
- (void) nsfw_mgr_reg_sock_fun (fd, nsfw_mgr_new_msg);
+ (void) nsfw_mgr_new_socket(fd, proc_type, dst_pid);
+ (void) nsfw_mgr_reg_sock_fun(fd, nsfw_mgr_new_msg);
}
- return fd;
+ return fd;
}
/*****************************************************************************
@@ -682,20 +757,19 @@ nsfw_mgr_get_new_socket (u8 proc_type, u32 dst_pid)
* Calls :
* Called By :
*****************************************************************************/
-u8
-nsfw_mgr_clr_fd_lock ()
+u8 nsfw_mgr_clr_fd_lock()
{
- i32 i;
- if (!g_mgr_socket_map.sock)
+ i32 i;
+ if (!g_mgr_sockt_map.sock)
{
- NSFW_LOGERR ("clr fd lock fail, sock is null");
- return FALSE;
+ NSFW_LOGERR("clr fd lock fail, sock is null");
+ return FALSE;
}
- for (i = 0; i < (i32) NSFW_MGR_FD_MAX; i++)
+ for (i = 0; i < (i32) NSFW_MGR_FD_MAX; i++)
{
- common_mem_spinlock_init (&(g_mgr_socket_map.sock[i].opr_lock));
+ dmm_spin_init(&(g_mgr_sockt_map.sock[i].opr_lock));
}
- return TRUE;
+ return TRUE;
}
/*****************************************************************************
@@ -708,15 +782,14 @@ nsfw_mgr_clr_fd_lock ()
* Calls :
* Called By :
*****************************************************************************/
-void
-nsfw_mgr_close_dst_proc (u8 proc_type, u32 dst_pid)
+void nsfw_mgr_close_dst_proc(u8 proc_type, u32 dst_pid)
{
- i32 fd = nsfw_mgr_get_dst_socket (proc_type, dst_pid);
- if (fd > 0)
+ i32 fd = nsfw_mgr_get_dst_socket(proc_type, dst_pid);
+ if (fd > 0)
{
- (void) nsfw_mgr_del_socket (fd);
- (void) nsfw_mgr_unreg_sock_fun (fd);
- (void) nsfw_base_close (fd);
+ (void) nsfw_mgr_del_socket(fd);
+ (void) nsfw_mgr_unreg_sock_fun(fd);
+ (void) nsfw_base_close(fd);
}
}
@@ -730,49 +803,49 @@ nsfw_mgr_close_dst_proc (u8 proc_type, u32 dst_pid)
* Calls :
* Called By :
*****************************************************************************/
-u8
-nsfw_mgr_send_msg_socket (u32 fd, nsfw_mgr_msg * msg)
+u8 nsfw_mgr_send_msg_socket(u32 fd, nsfw_mgr_msg * msg)
{
- i32 send_len = 0;
- i32 off_set = 0;
+ i32 send_len = 0;
+ i32 off_set = 0;
- if (NULL == msg)
+ if (NULL == msg)
{
- NSFW_LOGERR ("msg nul]mgr_fd=%u", fd);
- return FALSE;
+ NSFW_LOGERR("msg nul]mgr_fd=%u", fd);
+ return FALSE;
}
- if (msg->msg_len < sizeof (nsfw_mgr_msg))
+ if (msg->msg_len < sizeof(nsfw_mgr_msg))
{
- msg->msg_len = sizeof (nsfw_mgr_msg);
+ msg->msg_len = sizeof(nsfw_mgr_msg);
}
- if (msg->msg_type == MGR_MSG_LARGE_ALARM_RSP)
+ /* only need send msg->msg_body */
+ if (msg->msg_type == MGR_MSG_LARGE_ALARM_RSP)
{
- off_set = NSFW_MGR_MSG_HDR_LEN;
+ off_set = NSFW_MGR_MSG_HDR_LEN;
}
- do
+ /*TODO if closed by peer, may send failed, should close this fd */
+ do
{
- off_set += send_len;
- send_len =
- nsfw_base_send (fd, (char *) msg + off_set, msg->msg_len - off_set,
- MSG_NOSIGNAL);
- if (send_len <= 0)
+ off_set += send_len;
+ send_len =
+ nsfw_base_send(fd, (char *) msg + off_set,
+ msg->msg_len - off_set, MSG_NOSIGNAL);
+ if (send_len <= 0)
{
- NSFW_LOGERR
- ("send error]mgr_fd=%u,send_len=%d,off_set=%d,errno=%d" MSGINFO,
- fd, send_len, off_set, errno, PRTMSG (msg));
- return FALSE;
+ NSFW_LOGERR("send err]mgr_fd=%u,send_len=%d,off_set=%d,errno=%d"
+ MSGINFO, fd, send_len, off_set, errno, PRTMSG(msg));
+ return FALSE;
}
}
- while ((send_len + off_set) < (i32) msg->msg_len);
- NSFW_LOGDBG ("send mgr_msg suc]mgr_fd=%u," MSGINFO, fd, PRTMSG (msg));
- g_mgr_stat.msg_send[msg->msg_type]++;
- return TRUE;
+ while ((send_len + off_set) < (i32) msg->msg_len);
+ NSFW_LOGDBG("send mgr_msg suc]mgr_fd=%u," MSGINFO, fd, PRTMSG(msg));
+ g_mgr_stat.msg_send[msg->msg_type]++;
+ return TRUE;
}
-#define MAX_RECV_COUNT 100
+#define MAX_RECV_COUNT 2
/*****************************************************************************
* Prototype : nsfw_mgr_recv_msg_socket
@@ -784,212 +857,289 @@ nsfw_mgr_send_msg_socket (u32 fd, nsfw_mgr_msg * msg)
* Calls :
* Called By :
*****************************************************************************/
-u8
-nsfw_mgr_recv_msg_socket (u32 fd, nsfw_mgr_msg * msg,
- nsfw_mgr_msg ** large_msg)
+u8 nsfw_mgr_recv_msg_socket(u32 fd, nsfw_mgr_msg * msg,
+ nsfw_mgr_msg ** large_msg)
{
- i32 recv_len = 0;
- i32 off_set = 0;
- u32 msg_len = 0;
- i32 max_count = 0;
- if (NULL == msg)
+ i32 recv_len = 0;
+ i32 off_set = 0;
+ u32 msg_len = 0;
+ i32 max_count = 0;
+ if (NULL == msg)
{
- return FALSE;
+ return FALSE;
}
- u8 from_flag = msg->from_mem;
- msg_len = msg->msg_len;
- do
+ u8 from_flag = msg->from_mem;
+ msg_len = msg->msg_len;
+ do
{
- off_set += recv_len;
- recv_len =
- nsfw_base_recv (fd, (char *) msg + off_set, msg_len - off_set, 0);
- if (recv_len <= 0)
+ off_set += recv_len;
+ recv_len =
+ nsfw_base_recv(fd, (char *) msg + off_set, msg_len - off_set, 0);
+ if (recv_len <= 0)
{
- if ((EINTR == errno || EAGAIN == errno)
- && (max_count < MAX_RECV_COUNT))
+ if ((EINTR == errno || EAGAIN == errno)
+ && (max_count < MAX_RECV_COUNT))
{
- recv_len = 0;
- max_count++;
- continue;
+ recv_len = 0;
+ max_count++;
+ continue;
}
- NSFW_LOGERR
- ("recv error]mgr_fd=%u,recv_len=%d,off_set=%d,errno=%d,"
- MSGINFO, fd, recv_len, off_set, errno, PRTMSG (msg));
- msg->from_mem = from_flag;
- return FALSE;
+ NSFW_LOGERR("recv err]mgr_fd=%u,recv_len=%d,off_set=%d,errno=%d,"
+ MSGINFO, fd, recv_len, off_set, errno, PRTMSG(msg));
+ msg->from_mem = from_flag;
+ return FALSE;
}
}
- while (recv_len + off_set < (i32) msg_len);
+ while (recv_len + off_set < (i32) msg_len);
- msg->from_mem = from_flag;
+ msg->from_mem = from_flag;
- g_mgr_stat.msg_recv[msg->msg_type]++;
+ g_mgr_stat.msg_recv[msg->msg_type]++;
- if (msg->msg_len <= msg_len)
+ if (msg->msg_len <= msg_len)
{
- NSFW_LOGDBG ("recv mgr_msg suc]mgr_fd=%u," MSGINFO, fd, PRTMSG (msg));
- return TRUE;
+ NSFW_LOGDBG("recv mgr_msg suc]mgr_fd=%u," MSGINFO, fd, PRTMSG(msg));
+ return TRUE;
}
- if (large_msg == NULL)
+ if (large_msg == NULL)
{
- return TRUE;
+ return TRUE;
}
- nsfw_mgr_msg *l_msg =
- nsfw_mgr_msg_alloc (msg->msg_type, msg->dst_proc_type);
- if (NULL == l_msg)
+ nsfw_mgr_msg *l_msg =
+ nsfw_mgr_msg_alloc(msg->msg_type, msg->dst_proc_type);
+ if (NULL == l_msg)
{
- return TRUE;
+ return TRUE;
}
- if (l_msg->msg_len <= msg_len)
+ if (l_msg->msg_len <= msg_len)
{
- NSFW_LOGWAR ("alloc new msg error!]len=%u,org_len=%u,type=%u",
- l_msg->msg_len, msg->msg_len, msg->msg_type);
- nsfw_mgr_msg_free (l_msg);
- return TRUE;
+ NSFW_LOGWAR("alloc new msg err]len=%u,org_len=%u,type=%u",
+ l_msg->msg_len, msg->msg_len, msg->msg_type);
+ nsfw_mgr_msg_free(l_msg);
+ return TRUE;
}
- max_count = 0;
- (void) nsfw_set_sock_block (fd, FALSE);
- from_flag = l_msg->from_mem;
- u32 l_msg_len = l_msg->msg_len;
- do
+ max_count = 0;
+ (void) nsfw_set_sock_block(fd, FALSE);
+ from_flag = l_msg->from_mem;
+ u32 l_msg_len = l_msg->msg_len;
+ do
{
- off_set += recv_len;
- recv_len =
- nsfw_base_recv (fd, (char *) l_msg + off_set, l_msg_len - off_set, 0);
- if (recv_len <= 0)
+ off_set += recv_len;
+ recv_len =
+ nsfw_base_recv(fd, (char *) l_msg + off_set, l_msg_len - off_set,
+ 0);
+ if (recv_len <= 0)
{
- if ((EINTR == errno || EAGAIN == errno)
- && (max_count < MAX_RECV_COUNT))
+ if ((EINTR == errno || EAGAIN == errno)
+ && (max_count < MAX_RECV_COUNT))
{
- recv_len = 0;
- max_count++;
- continue;
+ recv_len = 0;
+ max_count++;
+ continue;
}
- NSFW_LOGERR
- ("recv error]mgr_fd=%u,recv_len=%d,off_set=%d,errno=%d,"
- MSGINFO, fd, recv_len, off_set, errno, PRTMSG (msg));
- l_msg->from_mem = from_flag;
- nsfw_mgr_msg_free (l_msg);
- return FALSE;
+ NSFW_LOGERR("recv err]mgr_fd=%u,recv_len=%d,off_set=%d,errno=%d,"
+ MSGINFO, fd, recv_len, off_set, errno, PRTMSG(msg));
+ l_msg->from_mem = from_flag;
+ nsfw_mgr_msg_free(l_msg);
+ return FALSE;
}
}
- while (recv_len + off_set < (i32) l_msg_len);
- (void) nsfw_set_sock_block (fd, TRUE);
- int retVal = MEMCPY_S (l_msg, msg_len, msg, msg_len);
- if (EOK != retVal)
+ while (recv_len + off_set < (i32) l_msg_len);
+ (void) nsfw_set_sock_block(fd, TRUE);
+ int retVal = memcpy_s(l_msg, msg_len, msg, msg_len);
+ if (EOK != retVal)
{
- NSFW_LOGERR ("MEMCPY_S failed] ret=%d", retVal);
- l_msg->from_mem = from_flag;
- nsfw_mgr_msg_free (l_msg);
- return TRUE;
+ NSFW_LOGERR("memcpy_s fail]ret=%d", retVal);
+ l_msg->from_mem = from_flag;
+ nsfw_mgr_msg_free(l_msg);
+ return TRUE;
}
- l_msg->from_mem = from_flag;
- l_msg->msg_len = l_msg_len;
+ l_msg->from_mem = from_flag;
+ l_msg->msg_len = l_msg_len;
- *large_msg = l_msg;
- NSFW_LOGDBG ("recv large mgr_msg suc]mgr_fd=%u," MSGINFO, fd,
- PRTMSG (l_msg));
- return TRUE;
+ *large_msg = l_msg;
+ NSFW_LOGDBG("recv large mgr_msg suc]mgr_fd=%u," MSGINFO, fd,
+ PRTMSG(l_msg));
+ return TRUE;
}
/*****************************************************************************
-* Prototype : nsfw_mgr_send_req_wait_rsp
-* Description : send request message and block waiting for it's response
- within MGR_COM_RECV_TIMEOUT
+* Prototype : nsfw_mgr_get_socket
+* Description : try best to return an available dst_socket
* Input : nsfw_mgr_msg* req_msg
* nsfw_mgr_msg* rsp_msg
+ i32 dst_socket (origin fd, <=0 to lookup or create, >0 to renew)
* Output : None
-* Return Value : u8
+* Return Value : i32
* Calls :
* Called By :
*****************************************************************************/
-u8
-nsfw_mgr_send_req_wait_rsp (nsfw_mgr_msg * req_msg, nsfw_mgr_msg * rsp_msg)
+i32 nsfw_mgr_get_socket(nsfw_mgr_msg * req_msg, nsfw_mgr_msg * rsp_msg,
+ i32 dst_socket)
{
- if (NULL == req_msg)
+ if (dst_socket <= 0) /* origin fd <= 0, first lookup the eastablished, if none, create a new one */
{
- NSFW_LOGERR ("req msg nul!");
- return FALSE;
+ dst_socket =
+ nsfw_mgr_get_dst_socket(req_msg->dst_proc_type, req_msg->dst_pid);
+ if (dst_socket <= 0)
+ {
+ dst_socket =
+ nsfw_mgr_get_new_socket(req_msg->dst_proc_type,
+ req_msg->dst_pid);
+ if (dst_socket <= 0)
+ {
+ NSFW_LOGERR("send msg get dst_socket_err]" MSGINFO,
+ PRTMSG(req_msg));
+ return -1;
+ }
+ }
}
-
- i32 dst_socket =
- nsfw_mgr_get_dst_socket (req_msg->dst_proc_type, req_msg->dst_pid);
- if (dst_socket <= 0)
+ else /* origin fd is broken probably because the other end just upgraded, delete the old one and re-create */
{
- dst_socket =
- nsfw_mgr_get_new_socket (req_msg->dst_proc_type, req_msg->dst_pid);
- if (dst_socket <= 0)
+ (void) nsfw_mgr_del_socket(dst_socket);
+ (void) nsfw_mgr_unreg_sock_fun(dst_socket);
+ (void) nsfw_base_close(dst_socket);
+ UNLOCK_MGR_FD(dst_socket)
+ dst_socket =
+ nsfw_mgr_get_new_socket(req_msg->dst_proc_type, req_msg->dst_pid);
+ if (dst_socket <= 0)
{
- NSFW_LOGERR ("send msg get dst_socket_error]" MSGINFO,
- PRTMSG (req_msg));
- return FALSE;
+ NSFW_LOGERR("send msg get dst_socket_err]" MSGINFO,
+ PRTMSG(req_msg));
+ return -1;
}
}
+ return dst_socket;
+}
- if ((NULL == rsp_msg) && (req_msg->msg_len == sizeof (nsfw_mgr_msg)))
+/*****************************************************************************
+* Prototype : nsfw_mgr_do_send_and_recv
+* Description : do send and recv work
+* Input : nsfw_mgr_msg* req_msg
+* nsfw_mgr_msg* rsp_msg
+* Output : None
+* Return Value : u8
+* Calls :
+* Called By :
+*****************************************************************************/
+u8 nsfw_mgr_do_send_and_recv(nsfw_mgr_msg * req_msg, nsfw_mgr_msg * rsp_msg,
+ i32 dst_socket, i32 retry_times_left)
+{
+ LOCK_MGR_FD(dst_socket)
+ if ((NULL == rsp_msg) && (req_msg->msg_len == sizeof(nsfw_mgr_msg)))
{
- LOCK_MGR_FD (dst_socket)
- if (FALSE == nsfw_mgr_send_msg_socket (dst_socket, req_msg))
+ if (FALSE == nsfw_mgr_send_msg_socket(dst_socket, req_msg))
{
- NSFW_LOGERR ("send msg error]" MSGINFO, PRTMSG (req_msg));
- g_mgr_stat.msg_send_failed++;
- UNLOCK_MGR_FD (dst_socket) return FALSE;
+ g_mgr_stat.msg_send_failed++;
+ goto ERROR_RETURN;
}
- UNLOCK_MGR_FD (dst_socket) return TRUE;
+ UNLOCK_MGR_FD(dst_socket) return TRUE;
}
- LOCK_MGR_FD (dst_socket);
- (void) nsfw_mgr_unreg_sock_fun (dst_socket);
- if (FALSE == nsfw_mgr_send_msg_socket (dst_socket, req_msg))
+ (void) nsfw_mgr_unreg_sock_fun(dst_socket);
+ if (FALSE == nsfw_mgr_send_msg_socket(dst_socket, req_msg))
{
- NSFW_LOGERR ("send msg error]" MSGINFO, PRTMSG (req_msg));
- g_mgr_stat.msg_send_failed++;
- (void) nsfw_mgr_reg_sock_fun (dst_socket, nsfw_mgr_new_msg);
- UNLOCK_MGR_FD (dst_socket);
- return FALSE;
+ g_mgr_stat.msg_send_failed++;
+ goto ERROR_RETURN;
}
- if (NULL == rsp_msg)
+ if (NULL == rsp_msg)
{
- (void) nsfw_mgr_reg_sock_fun (dst_socket, nsfw_mgr_new_msg);
- UNLOCK_MGR_FD (dst_socket) return TRUE;
+ (void) nsfw_mgr_reg_sock_fun(dst_socket, nsfw_mgr_new_msg);
+ UNLOCK_MGR_FD(dst_socket) return TRUE;
}
- u16 i;
- for (i = 0; i < MGR_COM_MAX_DROP_MSG; i++)
+ u16 i;
+ for (i = 0; i < MGR_COM_MAX_DROP_MSG; i++)
{
- if (FALSE == nsfw_mgr_recv_msg_socket (dst_socket, rsp_msg, NULL))
+ if (FALSE == nsfw_mgr_recv_msg_socket(dst_socket, rsp_msg, NULL))
{
- NSFW_LOGERR ("recv msg error]" MSGINFO, PRTMSG (req_msg));
- (void) nsfw_mgr_reg_sock_fun (dst_socket, nsfw_mgr_new_msg);
- UNLOCK_MGR_FD (dst_socket) return FALSE;
+ goto ERROR_RETURN;
}
- if ((rsp_msg->seq == req_msg->seq)
- && (rsp_msg->msg_type == req_msg->msg_type + MGR_MSG_RSP_BASE))
+ if ((rsp_msg->seq == req_msg->seq)
+ && (rsp_msg->msg_type == req_msg->msg_type + MGR_MSG_RSP_BASE))
{
- break;
+ break;
}
- NSFW_LOGINF ("recv msg forward]" MSGINFO, PRTMSG (rsp_msg));
- rsp_msg->fw_flag = TRUE;
- (void) nsfw_mgr_send_msg (rsp_msg);
+ NSFW_LOGDBG("recv msg forward]" MSGINFO, PRTMSG(rsp_msg));
+ rsp_msg->fw_flag = TRUE;
+ (void) nsfw_mgr_send_msg(rsp_msg);
+ }
+
+ (void) nsfw_mgr_reg_sock_fun(dst_socket, nsfw_mgr_new_msg);
+ if (0 == req_msg->dst_pid)
+ {
+ (void) nsfw_mgr_new_socket(dst_socket, rsp_msg->src_proc_type,
+ rsp_msg->src_pid);
+ }
+ UNLOCK_MGR_FD(dst_socket) return TRUE;
+
+ ERROR_RETURN:
+ if (0 >= retry_times_left)
+ {
+ NSFW_LOGERR("send msg err]" MSGINFO, PRTMSG(req_msg));
+ (void) nsfw_mgr_reg_sock_fun(dst_socket, nsfw_mgr_new_msg);
+ UNLOCK_MGR_FD(dst_socket);
+ }
+ else
+ {
+ NSFW_LOGWAR
+ ("origin mgr socket=%d is broken, try re-create, %d times left",
+ dst_socket, retry_times_left);
+ /* NOTE: no need to re-register sock_fun, will UNLOCK in next call of nsfw_mgr_get_socket */
+ }
+ return FALSE;
+
+}
+
+/*****************************************************************************
+* Prototype : nsfw_mgr_send_req_wait_rsp
+* Description : send request message and block waiting for it's response
+ within MGR_COM_RECV_TIMEOUT
+* Input : nsfw_mgr_msg* req_msg
+* nsfw_mgr_msg* rsp_msg
+* Output : None
+* Return Value : u8
+* Calls :
+* Called By :
+*****************************************************************************/
+u8 nsfw_mgr_send_req_wait_rsp(nsfw_mgr_msg * req_msg, nsfw_mgr_msg * rsp_msg)
+{
+ if (NULL == req_msg)
+ {
+ NSFW_LOGERR("req msg nul");
+ return FALSE;
}
- (void) nsfw_mgr_reg_sock_fun (dst_socket, nsfw_mgr_new_msg);
- if (0 == req_msg->dst_pid)
+ i32 dst_socket = 0;
+ i32 retry_times_left = 1;
+ while (retry_times_left >= 0)
{
- (void) nsfw_mgr_new_socket (dst_socket, rsp_msg->src_proc_type,
- rsp_msg->src_pid);
+ dst_socket = nsfw_mgr_get_socket(req_msg, rsp_msg, dst_socket);
+ if (dst_socket <= 0)
+ {
+ NSFW_LOGERR("send msg get dst_socket_err]" MSGINFO,
+ PRTMSG(req_msg));
+ return FALSE;
+ }
+ u8 ret = nsfw_mgr_do_send_and_recv(req_msg, rsp_msg, dst_socket,
+ retry_times_left);
+ if (ret == TRUE)
+ {
+ return TRUE;
+ }
+ --retry_times_left;
}
- UNLOCK_MGR_FD (dst_socket) return TRUE;
+ return FALSE;
}
/*****************************************************************************
@@ -1001,10 +1151,9 @@ nsfw_mgr_send_req_wait_rsp (nsfw_mgr_msg * req_msg, nsfw_mgr_msg * rsp_msg)
* Calls :
* Called By :
*****************************************************************************/
-u8
-nsfw_mgr_send_msg (nsfw_mgr_msg * msg)
+u8 nsfw_mgr_send_msg(nsfw_mgr_msg * msg)
{
- return nsfw_mgr_send_req_wait_rsp (msg, NULL);
+ return nsfw_mgr_send_req_wait_rsp(msg, NULL);
}
/*****************************************************************************
@@ -1016,79 +1165,77 @@ nsfw_mgr_send_msg (nsfw_mgr_msg * msg)
* Calls :
* Called By :
*****************************************************************************/
-u8
-nsfw_mgr_msg_in (i32 fd)
+u8 nsfw_mgr_msg_in(i32 fd)
{
- u32 i = 0;
- u8 ret = FALSE;
- u8 msg_match = FALSE;
- nsfw_mgr_msg *msg = nsfw_mgr_null_rspmsg_alloc ();
- nsfw_mgr_msg *large_msg = NULL;
+ u32 i = 0;
+ u8 ret = FALSE;
+ u8 msg_match = FALSE;
+ nsfw_mgr_msg *msg = nsfw_mgr_null_rspmsg_alloc();
+ nsfw_mgr_msg *large_msg = NULL;
- LOCK_MGR_FD (fd) ret = nsfw_mgr_recv_msg_socket (fd, msg, &large_msg);
- UNLOCK_MGR_FD (fd) if (large_msg != NULL)
+ LOCK_MGR_FD(fd) ret = nsfw_mgr_recv_msg_socket(fd, msg, &large_msg);
+ UNLOCK_MGR_FD(fd) if (large_msg != NULL)
{
- nsfw_mgr_msg_free (msg);
- msg = large_msg;
+ nsfw_mgr_msg_free(msg);
+ msg = large_msg;
}
- if (FALSE == ret)
+ if (FALSE == ret)
{
- nsfw_mgr_msg_free (msg);
- return FALSE;
+ nsfw_mgr_msg_free(msg);
+ return FALSE;
}
-
- if (msg->fw_flag != TRUE)
+ if (msg->fw_flag != TRUE)
{
- (void) nsfw_mgr_new_socket (fd, msg->src_proc_type, msg->src_pid);
+ (void) nsfw_mgr_new_socket(fd, msg->src_proc_type, msg->src_pid);
}
- if (msg->msg_type < MGR_MSG_MAX)
+ if (msg->msg_type < MGR_MSG_MAX)
{
- for (i = 0; i < NSFW_MGRCOM_MAX_PROC_FUN; i++)
+ for (i = 0; i < NSFW_MGRCOM_MAX_PROC_FUN; i++)
{
- if (NULL == g_mgr_fun[msg->msg_type][i])
+ if (NULL == g_mgr_fun[msg->msg_type][i])
{
- break;
+ break;
}
- (void) g_mgr_fun[msg->msg_type][i] (msg);
- msg_match = TRUE;
+ (void) g_mgr_fun[msg->msg_type][i] (msg);
+ msg_match = TRUE;
}
}
- if (FALSE != msg_match)
+ if (FALSE != msg_match)
{
- nsfw_mgr_msg_free (msg);
- return TRUE;
+ nsfw_mgr_msg_free(msg);
+ return TRUE;
}
- if (msg->msg_type < MGR_MSG_RSP_BASE)
+ if (msg->msg_type < MGR_MSG_RSP_BASE)
{
- NSFW_LOGERR ("msg match failed! auto rsp]" MSGINFO, PRTMSG (msg));
- nsfw_mgr_msg *rsp_msg = nsfw_mgr_rsp_msg_alloc (msg);
- if (NULL != rsp_msg)
+ NSFW_LOGERR("msg match failed! auto rsp]" MSGINFO, PRTMSG(msg));
+ nsfw_mgr_msg *rsp_msg = nsfw_mgr_rsp_msg_alloc(msg);
+ if (NULL != rsp_msg)
{
- rsp_msg->resp_code = NSFW_MGR_MSG_TYPE_ERROR;
- (void) nsfw_mgr_send_msg (rsp_msg);
- nsfw_mgr_msg_free (rsp_msg);
+ rsp_msg->resp_code = NSFW_MGR_MSG_TYPE_ERROR;
+ (void) nsfw_mgr_send_msg(rsp_msg);
+ nsfw_mgr_msg_free(rsp_msg);
}
}
- NSFW_LOGERR ("drop msg]" MSGINFO, PRTMSG (msg));
- /* fix "Out-of-bounds write" type codex issue */
- if (msg->msg_type < MGR_MSG_MAX)
+ NSFW_LOGERR("drop msg]" MSGINFO, PRTMSG(msg));
+ /* fix "Out-of-bounds write" */
+ if (msg->msg_type < MGR_MSG_MAX)
{
- g_mgr_stat.recv_drop[msg->msg_type]++;
+ g_mgr_stat.recv_drop[msg->msg_type]++;
}
- nsfw_mgr_msg_free (msg);
- return FALSE;
+ nsfw_mgr_msg_free(msg);
+ return FALSE;
}
/*****************************************************************************
* Prototype : nsfw_mgr_new_msg
-* Description : when new mgr message receive from socket, this function
+* Description : when new mgr message recive from socket, this funciton
will call back
* Input : i32 epfd
* i32 fd
@@ -1098,22 +1245,19 @@ nsfw_mgr_msg_in (i32 fd)
* Calls :
* Called By :
*****************************************************************************/
-int
-nsfw_mgr_new_msg (i32 epfd, i32 fd, u32 events)
+/*try to get event form all modules */
+int nsfw_mgr_new_msg(i32 epfd, i32 fd, u32 events)
{
- lint_lock_1 ();
- if ((events & EPOLLERR) || (events & EPOLLHUP) || (!(events & EPOLLIN)))
+ if ((events & EPOLLERR) || (events & EPOLLHUP) || (!(events & EPOLLIN)))
{
- (void) nsfw_mgr_del_socket (fd);
- (void) nsfw_mgr_unreg_sock_fun (fd);
- (void) nsfw_base_close (fd);
- lint_unlock_1 ();
- return TRUE;
+ (void) nsfw_mgr_del_socket(fd);
+ (void) nsfw_mgr_unreg_sock_fun(fd);
+ (void) nsfw_base_close(fd);
+ return TRUE;
}
- (void) nsfw_mgr_msg_in (fd);
- lint_unlock_1 ();
- return TRUE;
+ (void) nsfw_mgr_msg_in(fd);
+ return TRUE;
}
/*****************************************************************************
@@ -1126,11 +1270,11 @@ nsfw_mgr_new_msg (i32 epfd, i32 fd, u32 events)
* Calls :
* Called By :
*****************************************************************************/
-int
-nsfw_mgr_com_rereg_fun (u32 timer_type, void *data)
+int nsfw_mgr_com_rereg_fun(u32 timer_type, void *data)
{
- (void) nsfw_mgr_reg_sock_fun (timer_type, (nsfw_mgr_sock_fun) data);
- return TRUE;
+
+ (void) nsfw_mgr_reg_sock_fun(timer_type, (nsfw_mgr_sock_fun) data);
+ return TRUE;
}
/*****************************************************************************
@@ -1144,18 +1288,18 @@ nsfw_mgr_com_rereg_fun (u32 timer_type, void *data)
* Calls :
* Called By :
*****************************************************************************/
-int
-nsfw_mgr_com_socket_error (i32 fd, nsfw_mgr_sock_fun fun, i32 timer)
+int nsfw_mgr_com_socket_error(i32 fd, nsfw_mgr_sock_fun fun, i32 timer)
{
- struct timespec time_left = { timer, 0 };
- nsfw_mgr_unreg_sock_fun (fd);
- nsfw_timer_reg_timer (fd, (void *) fun, nsfw_mgr_com_rereg_fun, time_left);
- return TRUE;
+
+ struct timespec time_left = { timer, 0 };
+ nsfw_mgr_unreg_sock_fun(fd);
+ nsfw_timer_reg_timer(fd, (void *) fun, nsfw_mgr_com_rereg_fun, time_left);
+ return TRUE;
}
/*****************************************************************************
* Prototype : nsfw_mgr_new_connection
-* Description : when new mgr connection in, this function will call back
+* Description : when new mgr connection in, this funciton will call back
* Input : i32 epfd
* i32 fd
* u32 events
@@ -1164,81 +1308,79 @@ nsfw_mgr_com_socket_error (i32 fd, nsfw_mgr_sock_fun fun, i32 timer)
* Calls :
* Called By :
*****************************************************************************/
-int
-nsfw_mgr_new_connection (i32 epfd, i32 fd, u32 events)
+int nsfw_mgr_new_connection(i32 epfd, i32 fd, u32 events)
{
- if ((events & EPOLLERR) || (events & EPOLLHUP) || (!(events & EPOLLIN)))
- {
- (void) nsfw_base_close (fd);
- NSFW_LOGWAR ("listen disconnect!]epfd=%d,listen=%d,event=0x%x", epfd,
- fd, events);
- (void) nsfw_mgr_unreg_sock_fun (fd);
- i32 listen_fd = nsfw_mgr_get_listen_socket ();
- if (listen_fd < 0)
+ if ((events & EPOLLERR) || (events & EPOLLHUP) || (!(events & EPOLLIN)))
+ {
+ (void) nsfw_base_close(fd);
+ NSFW_LOGWAR("listen disconnect]epfd=%d,listen=%d,event=0x%x", epfd,
+ fd, events);
+ (void) nsfw_mgr_unreg_sock_fun(fd);
+ i32 listen_fd = nsfw_mgr_get_listen_socket();
+ if (listen_fd < 0)
{
- NSFW_LOGERR
- ("get listen_fd failed!]epfd=%d,listen_fd=%d,event=0x%x", epfd,
- fd, events);
- return FALSE;
+ NSFW_LOGERR("get listen_fd fail]epfd=%d,listen_fd=%d,event=0x%x",
+ epfd, fd, events);
+ return FALSE;
}
- (void) nsfw_mgr_reg_sock_fun (listen_fd, nsfw_mgr_new_connection);
- return TRUE;
+ (void) nsfw_mgr_reg_sock_fun(listen_fd, nsfw_mgr_new_connection);
+ return TRUE;
}
- struct sockaddr in_addr;
- socklen_t in_len;
- int infd;
- in_len = sizeof in_addr;
+ int infd;
+ struct sockaddr addr;
+ socklen_t len = sizeof(addr);
+ int size, size_len;
+ u8 accept_flag = FALSE;
- int size, size_len;
- u8 accept_flag = FALSE;
- while (1)
+ while (1)
{
- infd = nsfw_base_accept (fd, &in_addr, &in_len);
- if (infd == -1)
+ infd = nsfw_base_accept(fd, &addr, &len);
+ if (infd == -1)
{
- if (FALSE == accept_flag)
+ if (FALSE == accept_flag)
{
- nsfw_mgr_com_socket_error (fd, nsfw_mgr_new_connection, 1);
+ nsfw_mgr_com_socket_error(fd, nsfw_mgr_new_connection, 1);
}
- break;
+ break;
}
- if (-1 == nsfw_set_close_on_exec (infd))
+ /* close on exec */
+ if (-1 == nsfw_set_close_on_exec(infd))
{
- (void) nsfw_base_close (infd);
- NSFW_LOGERR ("set exec err]fd=%d, errno=%d", infd, errno);
- break;
+ (void) nsfw_base_close(infd);
+ NSFW_LOGERR("set exec err]fd=%d, errno=%d", infd, errno);
+ break;
}
- size = MAX_RECV_BUF_DEF;
- size_len = sizeof (size);
- if (0 >
- nsfw_base_setsockopt (infd, SOL_SOCKET, SO_RCVBUF, (void *) &size,
- (socklen_t) size_len))
+ size = MAX_RECV_BUF_DEF;
+ size_len = sizeof(size);
+ if (0 >
+ nsfw_base_setsockopt(infd, SOL_SOCKET, SO_RCVBUF, (void *) &size,
+ (socklen_t) size_len))
{
- NSFW_LOGERR ("set socket opt err!]error=%d", errno);
+ NSFW_LOGERR("set socket opt err]error=%d", errno);
}
- if (0 >
- nsfw_base_setsockopt (infd, SOL_SOCKET, SO_SNDBUF, (void *) &size,
- (socklen_t) size_len))
+ if (0 >
+ nsfw_base_setsockopt(infd, SOL_SOCKET, SO_SNDBUF, (void *) &size,
+ (socklen_t) size_len))
{
- NSFW_LOGERR ("set socket opt err!]error=%d", errno);
+ NSFW_LOGERR("set socket opt err]error=%d", errno);
}
- (void) nsfw_mgr_reg_sock_fun (infd, nsfw_mgr_new_msg);
- NSFW_LOGDBG ("accept_flag new fd]new_mgr_fd=%d", infd);
- accept_flag = TRUE;
+ (void) nsfw_mgr_reg_sock_fun(infd, nsfw_mgr_new_msg);
+ NSFW_LOGDBG("accept_flag new fd]new_mgr_fd=%d", infd);
+ accept_flag = TRUE;
}
- return TRUE;
+ return TRUE;
}
/*****************************************************************************
* Prototype : nsfw_set_sock_block
-* Description : set fd block or not for epoll thread
+* Description : set fd blok or not for epoll thread
* Input : i32 sock
* u8 flag
* Output : None
@@ -1246,45 +1388,45 @@ nsfw_mgr_new_connection (i32 epfd, i32 fd, u32 events)
* Calls :
* Called By :
*****************************************************************************/
-i32
-nsfw_set_sock_block (i32 sock, u8 flag)
+i32 nsfw_set_sock_block(i32 sock, u8 flag)
{
- i32 flags;
- flags = nsfw_base_fcntl (sock, F_GETFL, 0);
- if (flags < 0)
+ i32 flags;
+ flags = nsfw_base_fcntl(sock, F_GETFL, 0);
+ if (flags < 0)
{
- NSFW_LOGERR ("fcntl err]new_mgr_fd=%d,errno=%d", sock, errno);
- return -1;
+ NSFW_LOGERR("fcntl err]new_mgr_fd=%d,errno=%d", sock, errno);
+ return -1;
}
- if (TRUE == flag)
+ if (TRUE == flag)
{
- flags = flags | O_NONBLOCK;
+ flags = flags | O_NONBLOCK;
}
- else
+ else
{
- flags = flags & (~O_NONBLOCK);
- struct timeval tv;
- tv.tv_sec = MGR_COM_RECV_TIMEOUT;
- tv.tv_usec = 0;
- if (nsfw_base_setsockopt
- (sock, SOL_SOCKET, SO_RCVTIMEO, (char *) &tv, sizeof tv))
+ flags = flags & (~O_NONBLOCK);
+ struct timeval tv;
+ tv.tv_sec = MGR_COM_RECV_TIMEOUT;
+ tv.tv_usec = 0;
+ if (nsfw_base_setsockopt
+ (sock, SOL_SOCKET, SO_RCVTIMEO, (char *) &tv, sizeof tv))
{
- NSFW_LOGERR ("setsockopt socket err]mgr_fd=%d", sock);
- return -1;
+ NSFW_LOGERR("setsockopt socket err]mgr_fd=%d", sock);
+ return -1;
}
}
- if (nsfw_base_fcntl (sock, F_SETFL, flags) < 0)
+ if (nsfw_base_fcntl(sock, F_SETFL, flags) < 0)
{
- NSFW_LOGERR ("fcntl err]new_mgr_fd=%d,errno=%d,flags=%d", sock, errno,
- flags);
- return -1;
+ NSFW_LOGERR("fcntl err]new_mgr_fd=%d,errno=%d,flags=%d", sock, errno,
+ flags);
+ return -1;
}
- return 0;
+ return 0;
}
+/* close on exec */
/*****************************************************************************
* Prototype : nsfw_set_close_on_exec
* Description : close on exec set
@@ -1294,26 +1436,25 @@ nsfw_set_sock_block (i32 sock, u8 flag)
* Calls :
* Called By :
*****************************************************************************/
-i32
-nsfw_set_close_on_exec (i32 sock)
+i32 nsfw_set_close_on_exec(i32 sock)
{
- i32 flags;
- flags = nsfw_base_fcntl (sock, F_GETFD, 0);
- if (flags < 0)
+ i32 flags;
+ flags = nsfw_base_fcntl(sock, F_GETFD, 0);
+ if (flags < 0)
{
- NSFW_LOGERR ("fcntl err]fd=%d,errno=%d", sock, errno);
- return -1;
+ NSFW_LOGERR("fcntl err]fd=%d,errno=%d", sock, errno);
+ return -1;
}
- flags |= FD_CLOEXEC;
+ flags |= FD_CLOEXEC;
- if (nsfw_base_fcntl (sock, F_SETFD, flags) < 0)
+ if (nsfw_base_fcntl(sock, F_SETFD, flags) < 0)
{
- NSFW_LOGERR ("fcntl err]fd=%d,errno=%d,flags=%d", sock, errno, flags);
- return -1;
+ NSFW_LOGERR("fcntl err]fd=%d,errno=%d,flags=%d", sock, errno, flags);
+ return -1;
}
- return 0;
+ return 0;
}
/*****************************************************************************
@@ -1325,29 +1466,35 @@ nsfw_set_close_on_exec (i32 sock)
* Calls :
* Called By :
*****************************************************************************/
-u8
-nsfw_add_sock_to_ep (i32 fd)
+u8 nsfw_add_sock_to_ep(i32 fd)
{
- struct epoll_event event;
- event.data.fd = fd;
- event.events = EPOLLIN;
- if (g_ep_proc.epfd == 0)
+ struct epoll_event event;
+ event.data.fd = fd;
+ event.events = EPOLLIN;
+ if (g_ep_proc.epfd == 0)
{
- return TRUE;
+ return TRUE;
}
- (void) nsfw_set_sock_block (fd, TRUE);
+ (void) nsfw_set_sock_block(fd, TRUE);
- if (0 > nsfw_base_epoll_ctl (g_ep_proc.epfd, EPOLL_CTL_ADD, fd, &event))
+ if (0 > nsfw_base_epoll_ctl(g_ep_proc.epfd, EPOLL_CTL_ADD, fd, &event))
{
- NSFW_LOGINF
- ("add sock to ep thread failed]mgr_fd=%d,errno=%d,epfd=%d", fd,
- errno, g_ep_proc.epfd);
- return FALSE;
+ /*It is possible that multi-threads operate EPOLL_ADD at the same time,
+ *we allow this case, and return TRUE for it when errno==EEXIST*/
+ if (EEXIST == errno)
+ {
+ NSFW_LOGDBG
+ ("add sock to ep thread but exist already, return TRUE directly]mgr_fd=%d,epfd=%d",
+ fd, g_ep_proc.epfd) return TRUE;
+ }
+ NSFW_LOGINF("add sock to ep thread fail]mgr_fd=%d,errno=%d,epfd=%d",
+ fd, errno, g_ep_proc.epfd);
+ return FALSE;
}
- NSFW_LOGDBG ("add sock to ep thread]mgr_fd=%d,epfd=%d", fd,
- g_ep_proc.epfd) return TRUE;
+ NSFW_LOGDBG("add sock to ep thread]mgr_fd=%d,epfd=%d", fd,
+ g_ep_proc.epfd) return TRUE;
}
/*****************************************************************************
@@ -1359,29 +1506,28 @@ nsfw_add_sock_to_ep (i32 fd)
* Calls :
* Called By :
*****************************************************************************/
-u8
-nsfw_rmv_sock_from_ep (i32 fd)
+u8 nsfw_rmv_sock_from_ep(i32 fd)
{
- struct epoll_event event;
- event.data.fd = fd;
- event.events = EPOLLIN;
- if (g_ep_proc.epfd == 0)
+ struct epoll_event event;
+ event.data.fd = fd;
+ event.events = EPOLLIN;
+ if (g_ep_proc.epfd == 0)
{
- return TRUE;
+ //NSFW_LOGINF("rmv sock to ep thread before start]mgr_fd=%d",fd);
+ return TRUE;
}
- (void) nsfw_set_sock_block (fd, FALSE);
+ (void) nsfw_set_sock_block(fd, FALSE);
- if (0 > nsfw_base_epoll_ctl (g_ep_proc.epfd, EPOLL_CTL_DEL, fd, &event))
+ if (0 > nsfw_base_epoll_ctl(g_ep_proc.epfd, EPOLL_CTL_DEL, fd, &event))
{
- NSFW_LOGINF
- ("rmv sock to ep thread failed] mgr_fd=%d,errno=%d,epfd=%d", fd,
- errno, g_ep_proc.epfd);
- return FALSE;
+ NSFW_LOGINF("rmv sock to ep thread fail]mgr_fd=%d,errno=%d,epfd=%d",
+ fd, errno, g_ep_proc.epfd);
+ return FALSE;
}
- NSFW_LOGDBG ("rmv sock to ep thread] mgr_fd=%d,epfd=%d", fd,
- g_ep_proc.epfd) return TRUE;
+ NSFW_LOGDBG("rmv sock to ep thread]mgr_fd=%d,epfd=%d", fd,
+ g_ep_proc.epfd) return TRUE;
}
/*****************************************************************************
@@ -1395,33 +1541,28 @@ nsfw_rmv_sock_from_ep (i32 fd)
* Calls :
* Called By :
*****************************************************************************/
-u8
-nsfw_mgr_reg_sock_fun (i32 fd, nsfw_mgr_sock_fun fun)
+/*try to get event form all modules */
+u8 nsfw_mgr_reg_sock_fun(i32 fd, nsfw_mgr_sock_fun fun)
{
- lint_lock_1 ();
- if ((fd >= (i32) NSFW_MGR_FD_MAX) || (fd < 0) || NULL == fun)
+ if ((fd >= (i32) NSFW_MGR_FD_MAX) || (fd < 0) || NULL == fun)
{
- NSFW_LOGINF ("reg sock fun error!] mgr_fd=%d,fun=%p", fd, fun);
- lint_unlock_1 ();
- return FALSE;
+ NSFW_LOGINF("reg sock fun error]mgr_fd=%d,fun=%p", fd, fun);
+ return FALSE;
}
- if ((g_ep_proc.ep_fun) && (NULL == g_ep_proc.ep_fun[fd]))
+ if ((g_ep_proc.ep_fun) && (NULL == g_ep_proc.ep_fun[fd]))
{
- g_ep_proc.ep_fun[fd] = fun;
- if (FALSE == nsfw_add_sock_to_ep (fd))
+ g_ep_proc.ep_fun[fd] = fun;
+ if (FALSE == nsfw_add_sock_to_ep(fd))
{
- g_ep_proc.ep_fun[fd] = NULL;
- lint_unlock_1 ();
- return FALSE;
+ g_ep_proc.ep_fun[fd] = NULL;
+ return FALSE;
}
- NSFW_LOGDBG ("reg sock fun] mgr_fd=%d,fun=%p", fd, fun);
- lint_unlock_1 ();
- return TRUE;
+ NSFW_LOGDBG("reg sock fun]mgr_fd=%d,fun=%p", fd, fun);
+ return TRUE;
}
- lint_unlock_1 ();
- return FALSE;
+ return FALSE;
}
/*****************************************************************************
@@ -1433,28 +1574,24 @@ nsfw_mgr_reg_sock_fun (i32 fd, nsfw_mgr_sock_fun fun)
* Calls :
* Called By :
*****************************************************************************/
-void
-nsfw_mgr_unreg_sock_fun (i32 fd)
+/*try to get event form all modules */
+void nsfw_mgr_unreg_sock_fun(i32 fd)
{
- lint_lock_1 ();
- if (fd >= (i32) NSFW_MGR_FD_MAX)
+ if (fd >= (i32) NSFW_MGR_FD_MAX)
{
- NSFW_LOGINF ("unreg sock fun failed!] mgr_fd=%d", fd);
- lint_unlock_1 ();
- return;
+ NSFW_LOGINF("unreg sock fun fail]mgr_fd=%d", fd);
+ return;
}
- if ((g_ep_proc.ep_fun) && (NULL != g_ep_proc.ep_fun[fd]))
+ if ((g_ep_proc.ep_fun) && (NULL != g_ep_proc.ep_fun[fd]))
{
- g_ep_proc.ep_fun[fd] = NULL;
- (void) nsfw_rmv_sock_from_ep (fd);
- NSFW_LOGDBG ("unreg sock fun] mgr_fd=%d", fd);
- lint_unlock_1 ();
- return;
+ g_ep_proc.ep_fun[fd] = NULL;
+ (void) nsfw_rmv_sock_from_ep(fd);
+ NSFW_LOGDBG("unreg sock fun]mgr_fd=%d", fd);
+ return;
}
- lint_unlock_1 ();
- return;
+ return;
}
/*****************************************************************************
@@ -1468,22 +1605,21 @@ nsfw_mgr_unreg_sock_fun (i32 fd)
* Calls :
* Called By :
*****************************************************************************/
-NSTACK_STATIC inline u8
-nsfw_sock_fun_callback (i32 epfd, i32 fd, u32 events)
+NSTACK_STATIC inline u8 nsfw_sock_fun_callback(i32 epfd, i32 fd, u32 events)
{
- if ((fd < (i32) NSFW_MGR_FD_MAX)
- && (g_ep_proc.ep_fun) && (NULL != g_ep_proc.ep_fun[fd]))
+ if ((fd < (i32) NSFW_MGR_FD_MAX)
+ && (g_ep_proc.ep_fun) && (NULL != g_ep_proc.ep_fun[fd]))
{
- (void) g_ep_proc.ep_fun[fd] (epfd, fd, events);
- return TRUE;
+ (void) g_ep_proc.ep_fun[fd] (epfd, fd, events);
+ return TRUE;
}
- return FALSE;
+ return FALSE;
}
/*****************************************************************************
-* Prototype : nsfw_sock_add_to_ep
-* Description : add all event process function has ben reg to the epoll
+* Prototype : nsfw_add_prestored_sock_to_ep
+* Description : add all the socks (whose process function has ben reg) to the epoll
thread when thread start
* Input : i32 epfd
* Output : None
@@ -1491,21 +1627,37 @@ nsfw_sock_fun_callback (i32 epfd, i32 fd, u32 events)
* Calls :
* Called By :
*****************************************************************************/
-u8
-nsfw_sock_add_to_ep (i32 epfd)
+u8 nsfw_add_prestored_sock_to_ep()
{
- u32 i;
+ u32 i;
+ u8 ret;
+
+ if (NULL == g_ep_proc.ep_fun)
+ {
+ NSFW_LOGERR("g_ep_proc.ep_fun should not be NULL at this time");
+ return FALSE;
+ }
- for (i = 0; i < NSFW_MGR_FD_MAX; i++)
+ for (i = 0; i < NSFW_MGR_FD_MAX; i++)
{
- if ((g_ep_proc.ep_fun) && (NULL == g_ep_proc.ep_fun[i]))
+ if (NULL == g_ep_proc.ep_fun[i])
{
- continue;
+ continue;
+ }
+
+ /*add return value check */
+ ret = nsfw_add_sock_to_ep(i);
+ if (FALSE == ret)
+ {
+ /*here, we add some fd(which belongs to other module and prestore to g_ep_proc) to ep .
+ must add success. if add fail, stack init should end up */
+ NSFW_LOGERR("nsfw_add_sock_to_ep fail]epfd=%d,i=%u",
+ g_ep_proc.epfd, i);
+ return FALSE;
}
- (void) nsfw_add_sock_to_ep (i);
}
- return TRUE;
+ return TRUE;
}
/*****************************************************************************
@@ -1517,19 +1669,18 @@ nsfw_sock_add_to_ep (i32 epfd)
* Calls :
* Called By :
*****************************************************************************/
-u8
-nsfw_mgr_com_start ()
+u8 nsfw_mgr_com_start()
{
- i32 listen_fd = nsfw_mgr_get_listen_socket ();
- if (listen_fd < 0)
+ i32 listern_fd = nsfw_mgr_get_listen_socket();
+ if (listern_fd < 0)
{
- NSFW_LOGERR ("get listen_fd failed!");
- return FALSE;
+ NSFW_LOGERR("get listern_fd fail");
+ return FALSE;
}
- NSFW_LOGINF ("start mgr_com module!] listen_fd=%d", listen_fd);
- (void) nsfw_mgr_reg_sock_fun (listen_fd, nsfw_mgr_new_connection);
- return TRUE;
+ NSFW_LOGINF("start mgr_com module]listern_fd=%d", listern_fd);
+ (void) nsfw_mgr_reg_sock_fun(listern_fd, nsfw_mgr_new_connection);
+ return TRUE;
}
/*****************************************************************************
@@ -1541,24 +1692,28 @@ nsfw_mgr_com_start ()
* Calls :
* Called By :
*****************************************************************************/
-u8
-nsfw_mgr_com_start_local (u8 proc_type)
+u8 nsfw_mgr_com_start_local(u8 proc_type)
{
- int fd[2];
- if ((socketpair (AF_UNIX, SOCK_STREAM, 0, fd)) < 0)
+ int fd[2];
+ if ((socketpair(AF_UNIX, SOCK_STREAM, 0, fd)) < 0)
{
- NSFW_LOGERR ("create socket err] type=%u,errno=%d", proc_type, errno);
- return FALSE;
+ NSFW_LOGERR("create socket err]type=%u,errno=%d", proc_type, errno);
+ return FALSE;
}
- (void) nsfw_mgr_new_socket (fd[0], proc_type, get_sys_pid ());
- (void) nsfw_mgr_new_socket (fd[1], proc_type, get_sys_pid ());
- (void) nsfw_mgr_reg_sock_fun (fd[0], nsfw_mgr_new_msg);
- (void) nsfw_mgr_reg_sock_fun (fd[1], nsfw_mgr_new_msg);
- NSFW_LOGINF ("create local socket] fd0=%d,fd1=%d", fd[0], fd[1]);
- return TRUE;
+ (void) nsfw_mgr_new_socket(fd[0], proc_type, get_sys_pid());
+ (void) nsfw_mgr_new_socket(fd[1], proc_type, get_sys_pid());
+ (void) nsfw_mgr_reg_sock_fun(fd[0], nsfw_mgr_new_msg);
+ (void) nsfw_mgr_reg_sock_fun(fd[1], nsfw_mgr_new_msg);
+ if (proc_type != NSFW_PROC_CTRL)
+ {
+ NSFW_LOGINF("create local socket]fd0=%d,fd1=%d", fd[0], fd[1]);
+ }
+ return TRUE;
}
+/*try to get event form all modules */
+
/*****************************************************************************
* Prototype : nsfw_mgr_listen_thread
* Description : epoll thread function
@@ -1568,115 +1723,40 @@ nsfw_mgr_com_start_local (u8 proc_type)
* Calls :
* Called By :
*****************************************************************************/
-void *
-nsfw_mgr_listen_thread (void *arg)
+void *nsfw_mgr_listen_thread(void *arg)
{
- i32 epfd = 0;
- //i32 listen_socket = 0;
-
- lint_lock_1 ();
#define MAXEVENTS 10
- epfd = nsfw_base_epoll_create (10);
+ struct epoll_event events[MAXEVENTS];
+
+ i32 epfd = g_ep_proc.epfd;
- struct epoll_event events[MAXEVENTS];
- if (EOK != MEMSET_S (events, sizeof (events), 0, sizeof (events)))
+ /* Init log suppression for this thread */
+ if (NULL == init_sup_table(LOG_SUP_TABLE_SIZE_FOR_MGR_COM_THREAD))
{
- NSFW_LOGERR ("MEMSET_S failed!]epfd=%d", epfd);
- lint_unlock_1 ();
- return NULL;
+ NSFW_LOGWAR("log suppression init failed in thread: %s",
+ NSFW_MGRCOM_THREAD);
}
- g_ep_proc.epfd = epfd;
- g_ep_proc.hbt_count = 0;
- (void) nsfw_sock_add_to_ep (epfd);
- lint_unlock_1 ();
- while (1)
+ while (1)
{
- lint_lock_1 ();
- int n, i;
- n = nsfw_base_epoll_wait (epfd, events, MAXEVENTS, -1);
- for (i = 0; i < n; i++)
+ int n, i;
+ n = nsfw_base_epoll_wait(epfd, events, MAXEVENTS, -1);
+ for (i = 0; i < n; i++)
{
- if (TRUE ==
- nsfw_sock_fun_callback (epfd, events[i].data.fd,
- events[i].events))
+ if (TRUE ==
+ nsfw_sock_fun_callback(epfd, events[i].data.fd,
+ events[i].events))
{
- g_ep_proc.hbt_count = 0;
- continue;
+ g_ep_proc.hbt_count = 0; /*, we know here has multi-thread case, but we allow it */
+ continue;
}
- NSFW_LOGERR ("error event recv] fd=%d,event=%d",
- events[i].data.fd, events[i].events);
+ NSFW_LOGERR("error event recv]fd=%d,event=%u", events[i].data.fd,
+ events[i].events);
}
- lint_unlock_1 ();
- }
-
-}
-
-NSTACK_STATIC inline void
-get_thread_policy (pthread_attr_t * attr)
-{
- int policy;
- int rs = pthread_attr_getschedpolicy (attr, &policy);
- if (rs != 0)
- {
- NSFW_LOGERR ("pthread_attr_getschedpolicy failed");
- return;
- }
- switch (policy)
- {
- case SCHED_FIFO:
- NSFW_LOGINF ("policy= SCHED_FIFO");
- break;
- case SCHED_RR:
- NSFW_LOGINF ("policy= SCHED_RR");
- break;
- case SCHED_OTHER:
- NSFW_LOGINF ("policy=SCHED_OTHER");
- break;
- default:
- NSFW_LOGINF ("policy=UNKNOWN");
- break;
- }
-
- return;
-}
-NSTACK_STATIC inline void
-get_thread_priority (pthread_attr_t * attr)
-{
- struct sched_param param;
- int rs = pthread_attr_getschedparam (attr, &param);
- if (rs != 0)
- {
- NSFW_LOGERR ("pthread_attr_getschedparam failed");
- return;
}
- NSFW_LOGINF ("get thread priority] pri=%d", param.sched_priority);
-}
-
-/* support thread priority configuration */
-void
-set_thread_attr (pthread_attr_t * pattr, int stacksize, int pri, int policy)
-{
- struct sched_param param;
- (void) pthread_attr_init (pattr);
-
- if (stacksize > 0)
- {
- (void) pthread_attr_setstacksize (pattr, stacksize);
- }
-
- param.sched_priority = pri;
- if (SCHED_OTHER != policy)
- {
- (void) pthread_attr_setschedpolicy (pattr, policy);
- (void) pthread_attr_setschedparam (pattr, &param);
- (void) pthread_attr_setinheritsched (pattr, PTHREAD_EXPLICIT_SCHED);
- }
- get_thread_policy (pattr);
- get_thread_priority (pattr);
}
/*****************************************************************************
@@ -1688,66 +1768,71 @@ set_thread_attr (pthread_attr_t * pattr, int stacksize, int pri, int policy)
* Calls :
* Called By :
*****************************************************************************/
-u8
-nsfw_mgr_ep_start ()
+u8 nsfw_mgr_ep_start()
{
- /* heart beat thread should have the same priority with the tcpip thread */
- pthread_attr_t attr;
- pthread_attr_t *pattr = NULL;
+ pthread_attr_t *pattr = NULL;
- if (g_thread_policy != SCHED_OTHER)
+ /* move this code snippet from nsfw_mgr_listen_thread to here,
+ * to avoid multi-thread problem when calling nsfw_add_prestored_sock_to_ep in nsfw_mgr_listen_thread*/
+ g_ep_proc.epfd = nsfw_base_epoll_create(10);
+ if (g_ep_proc.epfd <= 0)
{
- set_thread_attr (&attr, 0, g_thread_pri, g_thread_policy);
- pattr = &attr;
+ NSFW_LOGERR("epoll_create fail]epfd=%d,errno=%d", g_ep_proc.epfd,
+ errno);
+ return FALSE;
}
+ g_ep_proc.hbt_count = 0;
- if (pthread_create
- (&g_ep_proc.ep_thread, pattr, nsfw_mgr_listen_thread, NULL))
+ if (FALSE == nsfw_add_prestored_sock_to_ep())
{
- return FALSE;
+ return FALSE;
}
- NSFW_LOGINF ("start thread] id=%d", g_ep_proc.ep_thread);
+ if (pthread_create
+ (&g_ep_proc.ep_thread, pattr, nsfw_mgr_listen_thread, NULL))
+ {
+ return FALSE;
+ }
- if (pthread_setname_np (g_ep_proc.ep_thread, NSFW_MGRCOM_THREAD))
+ NSFW_LOGINF("start thread]id=%d", g_ep_proc.ep_thread);
+
+ if (pthread_setname_np(g_ep_proc.ep_thread, NSFW_MGRCOM_THREAD))
{
- return TRUE;
+ return TRUE;
}
- (void) nsfw_reg_trace_thread (g_ep_proc.ep_thread);
- return TRUE;
+ (void) nsfw_reg_trace_thread(g_ep_proc.ep_thread);
+ return TRUE;
}
-int
-nsfw_mgr_com_chk_hbt (int v_add)
+int nsfw_mgr_com_chk_hbt(int v_add)
{
- int ret = g_ep_proc.hbt_count;
- g_ep_proc.hbt_count += v_add;
- return ret;
+ int ret = g_ep_proc.hbt_count;
+ g_ep_proc.hbt_count += v_add;
+ return ret;
}
/*****************************************************************************
* Prototype : nsfw_mgr_comm_fd_destroy
-* Description : free the memory
+* Description : free the memeory
* Input :
* Output : None
* Return Value : int
* Calls :
* Called By :
*****************************************************************************/
-void
-nsfw_mgr_comm_fd_destroy ()
+void nsfw_mgr_comm_fd_destroy()
{
- if (g_ep_proc.ep_fun)
+ if (g_ep_proc.ep_fun)
{
- free (g_ep_proc.ep_fun);
- g_ep_proc.ep_fun = NULL;
+ free(g_ep_proc.ep_fun);
+ g_ep_proc.ep_fun = NULL;
}
- if (g_mgr_socket_map.sock)
+ if (g_mgr_sockt_map.sock)
{
- free (g_mgr_socket_map.sock);
- g_mgr_socket_map.sock = NULL;
+ free(g_mgr_sockt_map.sock);
+ g_mgr_sockt_map.sock = NULL;
}
- return;
+ return;
}
/*****************************************************************************
@@ -1759,115 +1844,91 @@ nsfw_mgr_comm_fd_destroy ()
* Calls :
* Called By :
*****************************************************************************/
-int
-nsfw_mgr_comm_fd_init (u32 proc_type)
+int nsfw_mgr_comm_fd_init(u32 proc_type)
{
- /*only app need to do this */
- if ((g_mgr_socket_map.sock) && (g_ep_proc.ep_fun))
+ /*distributed log collect, RANCU multi-nodes senario, nstack fd is limited to 1024,
+ this leads to DLOG SERVER container can't accept new connection, log can't be record normally.
+ maxfd limit to 60k begin */
+ /*only app need to do this */
+ errno_t err_ret = -1;
+
+ if ((g_mgr_sockt_map.sock) && (g_ep_proc.ep_fun))
{
- return 0;
+ return 0;
}
- if (NSFW_PROC_APP == proc_type)
+ if (NSFW_PROC_APP == proc_type)
{
- long sysfdmax = 0;
- sysfdmax = sysconf (_SC_OPEN_MAX);
- NSFW_LOGINF ("] sys max open files=%d", sysfdmax);
- if (sysfdmax > 0)
+ long sysfdmax = 0;
+ sysfdmax = sysconf(_SC_OPEN_MAX);
+ NSFW_LOGINF("sys max open files]fds=%ld", sysfdmax);
+ if (sysfdmax > 0)
{
- NSFW_MGR_FD_MAX =
- (int) ((sysfdmax <=
- NSFW_MGRCOM_MAX_SOCKET *
- 60) ? sysfdmax : NSFW_MGRCOM_MAX_SOCKET * 60);
+ NSFW_MGR_FD_MAX =
+ (int) ((sysfdmax <=
+ NSFW_MGRCOM_MAX_SOCKET *
+ 60) ? sysfdmax : NSFW_MGRCOM_MAX_SOCKET * 60);
}
- else
+ else
{
- NSFW_LOGERR ("get sys max open file fail");
- NSFW_MGR_FD_MAX = NSFW_MGRCOM_MAX_SOCKET;
+ NSFW_LOGERR("get sys max open file fail");
+ NSFW_MGR_FD_MAX = NSFW_MGRCOM_MAX_SOCKET;
}
}
- NSFW_LOGINF ("] final max fd=%d", NSFW_MGR_FD_MAX);
- if (!g_mgr_socket_map.sock)
+ /* distributed log collect, RANCU multi-nodes senario, nstack fd is limited to 1024,
+ this leads to DLOG SERVER container can't accept new connection, log can't be record normally.
+ maxfd limit to 60k end */
+ if (proc_type != NSFW_PROC_CTRL)
{
- g_mgr_socket_map.sock =
- (nsfw_mgr_sock_info *) malloc (sizeof (nsfw_mgr_sock_info) *
- NSFW_MGR_FD_MAX);
- if (NULL == g_mgr_socket_map.sock)
- {
- NSFW_LOGERR ("malloc fail] length=%d",
- sizeof (nsfw_mgr_sock_info) * NSFW_MGR_FD_MAX);
- return -1;
- }
- (void) MEMSET_S (g_mgr_socket_map.sock,
- sizeof (nsfw_mgr_sock_info) * NSFW_MGR_FD_MAX, 0,
- sizeof (nsfw_mgr_sock_info) * NSFW_MGR_FD_MAX);
+ NSFW_LOGINF("final]max fd=%d", NSFW_MGR_FD_MAX);
}
- if (!g_ep_proc.ep_fun)
+
+ if (!g_mgr_sockt_map.sock)
{
- g_ep_proc.ep_fun =
- (nsfw_mgr_sock_fun *) malloc (sizeof (nsfw_mgr_sock_fun) *
- NSFW_MGR_FD_MAX);
- if (NULL == g_ep_proc.ep_fun)
+ g_mgr_sockt_map.sock =
+ (nsfw_mgr_sock_info *) malloc(sizeof(nsfw_mgr_sock_info) *
+ NSFW_MGR_FD_MAX);
+ if (NULL == g_mgr_sockt_map.sock)
{
- NSFW_LOGERR ("malloc fail] length=%d ",
- sizeof (nsfw_mgr_sock_fun) * NSFW_MGR_FD_MAX);
- return -1;
+ NSFW_LOGERR("malloc fail]length=%d",
+ sizeof(nsfw_mgr_sock_info) * NSFW_MGR_FD_MAX);
+ return -1;
+ }
+ err_ret =
+ memset_s(g_mgr_sockt_map.sock,
+ sizeof(nsfw_mgr_sock_info) * NSFW_MGR_FD_MAX, 0,
+ sizeof(nsfw_mgr_sock_info) * NSFW_MGR_FD_MAX);
+ if (EOK != err_ret)
+ {
+ NSFW_LOGERR("memset_s fail]err_ret=%d", err_ret);
+ goto error;
}
- (void) MEMSET_S (g_ep_proc.ep_fun,
- sizeof (nsfw_mgr_sock_fun) * NSFW_MGR_FD_MAX, 0,
- sizeof (nsfw_mgr_sock_fun) * NSFW_MGR_FD_MAX);
}
- return 0;
-}
-
-/*****************************************************************************
-* Prototype : nsfw_mgr_com_mkdir_domainpath
-* Description : check whether the domain path exist.if not exist, create it.
-* Input : char *pathname
-* Output : None
-* Return Value : void
-* Calls :
-* Called By :
-*****************************************************************************/
-void
-nsfw_mgr_com_mkdir_domainpath (char *pathname)
-{
- char dirname[NSFW_MGRCOM_PATH_LEN] = { 0 };
- int i, len;
- if (NULL == pathname)
+ if (!g_ep_proc.ep_fun)
{
- NSFW_LOGERR ("the pathname is null.");
- return;
- }
-
- strncpy (dirname, pathname, NSFW_MGRCOM_PATH_LEN - 1);
- len = strlen (dirname);
- if (dirname[len - 1] != '/')
- strncat (dirname, "/", 2);
-
- if (access (dirname, F_OK) == 0)
- return;
-
- len = strlen (dirname);
-
- for (i = 1; i < len; i++)
- {
- if (dirname[i] == '/')
+ g_ep_proc.ep_fun =
+ (nsfw_mgr_sock_fun *) malloc(sizeof(nsfw_mgr_sock_fun) *
+ NSFW_MGR_FD_MAX);
+ if (NULL == g_ep_proc.ep_fun)
{
- dirname[i] = 0;
- if (access (dirname, F_OK) != 0)
- {
- if (mkdir (dirname, 0755) == -1)
- {
- NSFW_LOGERR ("mkdir:%s error", dirname);
- return;
- }
- }
- dirname[i] = '/';
+ NSFW_LOGERR("malloc fail] length=%d ",
+ sizeof(nsfw_mgr_sock_fun) * NSFW_MGR_FD_MAX);
+ goto error;
+ }
+ err_ret =
+ memset_s(g_ep_proc.ep_fun,
+ sizeof(nsfw_mgr_sock_fun) * NSFW_MGR_FD_MAX, 0,
+ sizeof(nsfw_mgr_sock_fun) * NSFW_MGR_FD_MAX);
+ if (EOK != err_ret)
+ {
+ NSFW_LOGERR("memset_s fail]err_ret=%d", err_ret);
+ goto error;
}
}
-
- return;
+ return 0;
+ error:
+ nsfw_mgr_comm_fd_destroy();
+ return -1;
}
/*****************************************************************************
@@ -1879,129 +1940,155 @@ nsfw_mgr_com_mkdir_domainpath (char *pathname)
* Calls :
* Called By :
*****************************************************************************/
-int nsfw_mgr_com_module_init (void *param);
-int
-nsfw_mgr_com_module_init (void *param)
+/*try to get event form all modules */
+int nsfw_mgr_com_module_init(void *param);
+int nsfw_mgr_com_module_init(void *param)
{
- lint_lock_1 ();
- u32 proc_type = (u32) ((long long) param);
- nsfw_mgr_init_cfg *mgr_cfg = &g_mgr_com_cfg;
- const char *directory = NSFW_DOMAIN_DIR;
- const char *home_dir = getenv ("HOME");
+ u32 proc_type = (u32) ((long long) param);
+ nsfw_mgr_init_cfg *mgr_cfg = &g_mgr_com_cfg;
+ const char *directory = NSFW_DOMAIN_DIR;
+ const char *home_dir = get_home_path();
- NSFW_LOGINF ("module mgr init] type=%u", proc_type);
+ NSFW_LOGINF("module mgr init]type=%u", proc_type);
- if (getuid () != 0 && home_dir != NULL)
- directory = home_dir;
+ if (home_dir)
+ {
+ directory = home_dir;
+ }
- if (0 != nsfw_mgr_comm_fd_init (proc_type))
+ if (0 != nsfw_mgr_comm_fd_init(proc_type))
{
- NSFW_LOGERR ("fd init fail] proc_type=%u", proc_type);
- lint_unlock_1 ();
- return -1;
+ NSFW_LOGERR("fd init fail]proc_type=%u", proc_type);
+ return -1;
}
- switch (proc_type)
+ switch (proc_type)
{
- case NSFW_PROC_MAIN:
- /* modify destMax, remove "-1" */
- if (EOK !=
- STRCPY_S (mgr_cfg->domain_path, NSFW_MGRCOM_PATH_LEN, directory))
- {
- NSFW_LOGERR ("module mgr init STRCPY_S failed!");
- lint_unlock_1 ();
- return -1;
- }
+ case NSFW_PROC_MAIN:
+ /*modify destMax, remove "-1" */
+ if (EOK !=
+ strcpy_s(mgr_cfg->domain_path, NSFW_MGRCOM_PATH_LEN,
+ directory))
+ {
+ NSFW_LOGERR("module mgr init strcpy_s fail");
+ return -1;
+ }
- nsfw_mgr_com_mkdir_domainpath (mgr_cfg->domain_path);
+ /*modify destMax, remove "-1" */
+ if (EOK !=
+ strcat_s(mgr_cfg->domain_path, NSFW_MGRCOM_PATH_LEN,
+ NSFW_MAIN_FILE))
+ {
+ NSFW_LOGERR("module mgr init strcat_s fail");
+ return -1;
+ }
- NSFW_LOGINF ("module mgr init]NSFW_PROC_MAIN domain_path=%s",
- mgr_cfg->domain_path);
+ NSFW_LOGINF("module mgr init]NSFW_PROC_MAIN domain_path=%s",
+ mgr_cfg->domain_path);
- if (TRUE != nsfw_mgr_com_start ())
- {
- NSFW_LOGERR ("module mgr nsfw_mgr_com_start failed!");
- lint_unlock_1 ();
- return -1;
- }
+ if (TRUE != nsfw_mgr_com_start())
+ {
+ NSFW_LOGERR("module mgr nsfw_mgr_com_start fail");
+ return -1;
+ }
- break;
+ break;
+ case NSFW_PROC_MASTER:
+ /* modify destMax, remove "-1" */
+ if (EOK !=
+ strcpy_s(mgr_cfg->domain_path, NSFW_MGRCOM_PATH_LEN,
+ directory))
+ {
+ NSFW_LOGERR("module mgr init strcpy_s fail");
+ return -1;
+ }
- case NSFW_PROC_TOOLS:
- break;
- case NSFW_PROC_CTRL:
- if (TRUE != nsfw_mgr_com_start_local (proc_type))
- {
- NSFW_LOGERR ("module mgr nsfw_mgr_com_start_local failed!");
- lint_unlock_1 ();
- return -1;
- }
- break;
- default:
- if (proc_type < NSFW_PROC_MAX)
- {
- break;
- }
- lint_unlock_1 ();
- return -1;
+ /* modify destMax, remove "-1" */
+ if (EOK !=
+ strcat_s(mgr_cfg->domain_path, NSFW_MGRCOM_PATH_LEN,
+ NSFW_MASTER_FILE))
+ {
+ NSFW_LOGERR("module mgr init strcat_s fail");
+ return -1;
+ }
+
+ NSFW_LOGINF("module mgr init]NSFW_PROC_MASTER domain_path=%s",
+ mgr_cfg->domain_path);
+
+ if (TRUE != nsfw_mgr_com_start())
+ {
+ NSFW_LOGERR("module mgr nsfw_mgr_com_start fail");
+ return -1;
+ }
+
+ break;
+ case NSFW_PROC_TOOLS:
+ case NSFW_PROC_CTRL:
+ if (TRUE != nsfw_mgr_com_start_local(proc_type))
+ {
+ NSFW_LOGERR("module mgr nsfw_mgr_com_start_local fail");
+ return -1;
+ }
+ break;
+ default:
+ if (proc_type < NSFW_PROC_MAX)
+ {
+ break;
+ }
+ return -1;
}
- mgr_cfg->msg_size = MGR_COM_MSG_COUNT_DEF;
- mgr_cfg->max_recv_timeout = MGR_COM_RECV_TIMEOUT_DEF;
- mgr_cfg->max_recv_drop_msg = MGR_COM_MAX_DROP_MSG_DEF;
+ mgr_cfg->msg_size = MGR_COM_MSG_COUNT_DEF;
+ mgr_cfg->max_recv_timeout = MGR_COM_RECV_TIMEOUT_DEF;
+ mgr_cfg->max_recv_drop_msg = MGR_COM_MAX_DROP_MSG_DEF;
- mgr_cfg->proc_type = proc_type;
+ mgr_cfg->proc_type = proc_type;
- nsfw_mem_sppool pmpinfo;
- if (EOK != MEMSET_S (&pmpinfo, sizeof (pmpinfo), 0, sizeof (pmpinfo)))
+ nsfw_mem_sppool pmpinfo;
+ if (EOK != memset_s(&pmpinfo, sizeof(pmpinfo), 0, sizeof(pmpinfo)))
{
- NSFW_LOGERR ("Error to memset!!!");
- nsfw_mgr_comm_fd_destroy ();
- lint_unlock_1 ();
- return -1;
+ NSFW_LOGERR("memset fail");
+ nsfw_mgr_comm_fd_destroy();
+ return -1;
}
- pmpinfo.enmptype = NSFW_MRING_MPMC;
- pmpinfo.usnum = mgr_cfg->msg_size;
- pmpinfo.useltsize = sizeof (nsfw_mgr_msg);
- pmpinfo.isocket_id = NSFW_SOCKET_ANY;
- pmpinfo.stname.entype = NSFW_NSHMEM;
- if (-1 ==
- SPRINTF_S (pmpinfo.stname.aname, sizeof (pmpinfo.stname.aname), "%s",
- "MS_MGR_MSGPOOL"))
+ pmpinfo.enmptype = NSFW_MRING_MPMC;
+ pmpinfo.usnum = mgr_cfg->msg_size;
+ pmpinfo.useltsize = sizeof(nsfw_mgr_msg);
+ pmpinfo.isocket_id = NSFW_SOCKET_ANY;
+ pmpinfo.stname.entype = NSFW_NSHMEM;
+ if (-1 ==
+ sprintf_s(pmpinfo.stname.aname, sizeof(pmpinfo.stname.aname), "%s",
+ "MS_MGR_MSGPOOL"))
{
- NSFW_LOGERR ("Error to SPRINTF_S!!!");
- nsfw_mgr_comm_fd_destroy ();
- lint_unlock_1 ();
- return -1;
+ NSFW_LOGERR("sprintf_s fail");
+ nsfw_mgr_comm_fd_destroy();
+ return -1;
}
- mgr_cfg->msg_pool = nsfw_mem_sp_create (&pmpinfo);
+ mgr_cfg->msg_pool = nsfw_mem_sp_create(&pmpinfo);
- if (!mgr_cfg->msg_pool)
+ if (!mgr_cfg->msg_pool)
{
- NSFW_LOGERR ("module mgr init msg_pool alloc failed!");
- nsfw_mgr_comm_fd_destroy ();
- lint_unlock_1 ();
- return -1;
+ NSFW_LOGERR("module mgr init msg_pool alloc fail");
+ nsfw_mgr_comm_fd_destroy();
+ return -1;
}
- (void) MEM_STAT (NSFW_MGR_COM_MODULE, pmpinfo.stname.aname, NSFW_NSHMEM,
- nsfw_mem_get_len (mgr_cfg->msg_pool, NSFW_MEM_SPOOL));
+ (void) MEM_STAT(NSFW_MGR_COM_MODULE, pmpinfo.stname.aname, NSFW_NSHMEM,
+ nsfw_mem_get_len(mgr_cfg->msg_pool, NSFW_MEM_SPOOL));
- if ((NSFW_PROC_TOOLS == proc_type)
- || (NSFW_PROC_CTRL == proc_type) || (NSFW_PROC_MAIN == proc_type))
+ if ((NSFW_PROC_TOOLS == proc_type)
+ || (NSFW_PROC_CTRL == proc_type) || (NSFW_PROC_MAIN == proc_type))
{
- if (TRUE != nsfw_mgr_ep_start ())
+ if (TRUE != nsfw_mgr_ep_start())
{
- NSFW_LOGERR ("module mgr nsfw_mgr_ep_start failed!");
- nsfw_mgr_comm_fd_destroy ();
- lint_unlock_1 ();
- return -1;
+ NSFW_LOGERR("module mgr nsfw_mgr_ep_start fail");
+ nsfw_mgr_comm_fd_destroy();
+ return -1;
}
}
- lint_unlock_1 ();
- return 0;
+ return 0;
}
/*****************************************************************************
@@ -2012,37 +2099,36 @@ nsfw_mgr_com_module_init (void *param)
* Return Value : int
* Calls :
* Called By :
- *****************************************************************************/
-int
-nsfw_mgr_run_script (const char *cmd, char *result, int result_buf_len)
+*****************************************************************************/
+int nsfw_mgr_run_script(const char *cmd, char *result, int result_buf_len)
{
- if (!cmd || !result || result_buf_len <= 1)
+ if (!cmd || !result || result_buf_len <= 1)
{
- return -1;
+ return -1;
}
- FILE *fp = popen (cmd, "r");
- if (fp != NULL)
+ FILE *fp = popen(cmd, "r");
+ if (fp != NULL)
{
- size_t n = fread (result, sizeof (char), result_buf_len - 1, fp);
- if (n == 0)
+ size_t n = fread(result, sizeof(char), result_buf_len - 1, fp);
+ if (n == 0)
{
- result[0] = '\0';
+ result[0] = '\0';
}
- else if ('\n' == result[n - 1])
+ else if ('\n' == result[n - 1])
{
- result[n - 1] = '\0';
+ result[n - 1] = '\0';
}
- else
+ else
{
- result[n] = '\0';
+ result[n] = '\0';
}
- pclose (fp);
- return n;
+ pclose(fp);
+ return n;
}
- return -1;
+ return -1;
}
/* *INDENT-OFF* */
diff --git a/src/framework/ipc/mgr_com/mgr_com.h b/src/framework/ipc/mgr_com/mgr_com.h
index 03f58c8..0011716 100644
--- a/src/framework/ipc/mgr_com/mgr_com.h
+++ b/src/framework/ipc/mgr_com/mgr_com.h
@@ -14,23 +14,13 @@
* limitations under the License.
*/
-/*****************************************************************************
-* Prototype : ifndef _NSFW_MGRCOM_MODULE_H
-* Description : mgr com module definition
-* Input : None
-* Output : None
-* Return Value : #
-* Calls :
-* Called By :
- *****************************************************************************/
#ifndef _NSFW_MGRCOM_MODULE_H
#define _NSFW_MGRCOM_MODULE_H
#include "pthread.h"
#include "nsfw_mem_api.h"
-#include "common_mem_api.h"
-#include "common_mem_memzone.h"
-#include "common_func.h"
+#include "dmm_spinlock.h"
+#include "dmm_atomic.h"
#ifdef __cplusplus
/* *INDENT-OFF* */
@@ -47,100 +37,96 @@ extern "C"{
#define MGR_COM_MSG_COUNT_DEF 1023 /*g_mgr_com_cfg */
#define MGR_COM_RECV_TIMEOUT_DEF 5
#define MGR_COM_MAX_DROP_MSG_DEF 1024
+#define MGR_COM_SEND_TIMEOUT_DEF 5
#define MGR_COM_MSG_COUNT (g_mgr_com_cfg.msg_size)
#define MGR_COM_RECV_TIMEOUT (g_mgr_com_cfg.max_recv_timeout)
#define MGR_COM_MAX_DROP_MSG (g_mgr_com_cfg.max_recv_drop_msg)
-#define NSFW_MAIN_FILE "nStackMainMgr"
-#define NSFW_MASTER_FILE "nStackMasterMgr"
+#define NSFW_MAIN_FILE "/ip_module/nStackMainMgr"
+#define NSFW_MASTER_FILE "/ip_module/nStackMasterMgr"
#define NSFW_ALARM_FILE "/HuskyAlarm.domain"
-#define NSFW_MGRCOM_THREAD "nStackMgrCom"
+#define NSFW_MGRCOM_THREAD "nstk_mgr_com"
typedef struct _nsfw_mgr_init_cfg
{
- u8 proc_type; /*fw_poc_type */
- u8 max_recv_timeout;
- u16 max_recv_drop_msg;
- u32 msg_size;
- common_mem_atomic32_t cur_idx;
- u64 u64reserve;
- mring_handle msg_pool;
- char domain_path[NSFW_MGRCOM_PATH_LEN];
+ u8 proc_type; /*fw_poc_type */
+ u8 max_recv_timeout;
+ u16 max_recv_drop_msg;
+ u32 msg_size;
+ dmm_atomic_t cur_idx;
+ u64 u64reserve;
+ mring_handle msg_pool;
+ char domain_path[NSFW_MGRCOM_PATH_LEN];
} nsfw_mgr_init_cfg;
typedef struct _nsfw_mgrcom_stat
{
- u64 msg_send[MGR_MSG_MAX];
- u64 msg_recv[MGR_MSG_MAX];
- u64 recv_drop[MGR_MSG_MAX];
- u64 msg_alloc;
- u64 msg_free;
- u64 msg_send_failed;
- u64 reconnect_count;
+ u64 msg_send[MGR_MSG_MAX];
+ u64 msg_recv[MGR_MSG_MAX];
+ u64 recv_drop[MGR_MSG_MAX];
+ u64 msg_alloc;
+ u64 msg_free;
+ u64 msg_send_failed;
+ u64 reconnect_count;
} nsfw_mgrcom_stat;
typedef struct _nsfw_mgr_sock_info
{
- u8 proc_type; /*_ns_poc_type*/
- u32 host_pid;
- common_mem_spinlock_t opr_lock;
+ u8 proc_type; /*_ns_poc_type*/
+ u32 host_pid;
+ dmm_spinlock_t opr_lock;
} nsfw_mgr_sock_info;
typedef struct _nsfw_mgr_sock_map
{
- i32 proc_cache[NSFW_PROC_MAX];
- nsfw_mgr_sock_info *sock;
+ i32 proc_cache[NSFW_PROC_MAX];
+ nsfw_mgr_sock_info *sock;
} nsfw_mgr_sock_map;
#define NSFW_SOCK_MAX_PROC_FUN 4
typedef struct _nsfw_mgrcom_proc_fun
{
- i32 fd;
- nsfw_mgr_sock_fun fun;
+ i32 fd;
+ nsfw_mgr_sock_fun fun;
} nsfw_mgrcom_proc_fun;
typedef struct _nsfw_mgrcom_proc
{
- i32 epfd;
- u32 hbt_count;
- pthread_t ep_thread;
- nsfw_mgr_sock_fun *ep_fun;
+ i32 epfd;
+ u32 hbt_count;
+ pthread_t ep_thread;
+ nsfw_mgr_sock_fun *ep_fun;
} nsfw_mgrcom_proc;
-i32 nsfw_set_sock_block (i32 sock, u8 flag);
+i32 nsfw_set_sock_block(i32 sock, u8 flag);
-u8 nsfw_rmv_sock_from_ep (i32 fd);
-u8 nsfw_add_sock_to_ep (i32 fd);
+u8 nsfw_rmv_sock_from_ep(i32 fd);
+u8 nsfw_add_sock_to_ep(i32 fd);
-int nsfw_mgr_new_msg (i32 epfd, i32 socket, u32 events);
+int nsfw_mgr_new_msg(i32 epfd, i32 socket, u32 events);
-u8 nsfw_mgr_ep_start ();
-u8 nsfw_mgr_stop ();
+u8 nsfw_mgr_ep_start();
+u8 nsfw_mgr_stop();
#define LOCK_MGR_FD(_fd){\
- if ((i32)NSFW_MGR_FD_MAX > _fd)\
+ if ((i32)NSFW_MGR_FD_MAX > _fd && g_mgr_sockt_map.sock)\
{\
- common_mem_spinlock_lock(&g_mgr_socket_map.sock[_fd].opr_lock);\
+ dmm_spin_lock(&g_mgr_sockt_map.sock[_fd].opr_lock);\
}\
}
#define UNLOCK_MGR_FD(_fd){\
- if ((i32)NSFW_MGR_FD_MAX > _fd)\
+ if ((i32)NSFW_MGR_FD_MAX > _fd && g_mgr_sockt_map.sock)\
{\
- common_mem_spinlock_unlock(&g_mgr_socket_map.sock[_fd].opr_lock);\
+ dmm_spin_unlock(&g_mgr_sockt_map.sock[_fd].opr_lock);\
}\
}
#define NSFW_MGR_FD_MAX g_mgr_sockfdmax
-extern void set_thread_attr (pthread_attr_t * pattr, int stacksize, int pri,
- int policy);
-
-extern void nsfw_com_attr_set (int policy, int pri);
-
#ifdef __cplusplus
/* *INDENT-OFF* */
}
diff --git a/src/framework/ipc/ps/nsfw_fd_timer.c b/src/framework/ipc/ps/nsfw_fd_timer.c
index cea2486..fc71748 100644
--- a/src/framework/ipc/ps/nsfw_fd_timer.c
+++ b/src/framework/ipc/ps/nsfw_fd_timer.c
@@ -22,10 +22,8 @@
#include "types.h"
#include "list.h"
-#include "common_mem_common.h"
-
#include "nstack_securec.h"
-#include "nsfw_init.h"
+#include "nsfw_init_api.h"
#include "nsfw_mgr_com_api.h"
#include "nsfw_mem_api.h"
#include "nstack_log.h"
@@ -42,11 +40,10 @@ extern "C"{
#define NSFW_TIMER_CYCLE 1
#define NSFW_TIMER_INFO_MAX_COUNT_DEF 8191
#define NSFW_TIMER_INFO_MAX_COUNT (g_timer_cfg.timer_info_size)
-/* *INDENT-OFF* */
+
nsfw_timer_init_cfg g_timer_cfg;
u8 g_hbt_switch = FALSE;
-/* *INDENT-ON* */
/*****************************************************************************
* Prototype : nsfw_timer_reg_timer
@@ -59,38 +56,39 @@ u8 g_hbt_switch = FALSE;
* Return Value : nsfw_timer_info*
* Calls :
* Called By :
-*
*****************************************************************************/
-nsfw_timer_info *
-nsfw_timer_reg_timer (u32 timer_type, void *data,
- nsfw_timer_proc_fun fun, struct timespec time_left)
+nsfw_timer_info *nsfw_timer_reg_timer(u32 timer_type, void *data,
+ nsfw_timer_proc_fun fun,
+ struct timespec time_left)
{
- nsfw_timer_info *tm_info = NULL;
- if (0 ==
- nsfw_mem_ring_dequeue (g_timer_cfg.timer_info_pool, (void *) &tm_info))
+ nsfw_timer_info *tm_info = NULL;
+ if (0 ==
+ nsfw_mem_ring_dequeue(g_timer_cfg.timer_info_pool, (void *) &tm_info))
{
- NSFW_LOGERR ("dequeue error]data=%p,fun=%p", data, fun);
- return NULL;
+ NSFW_LOGERR("dequeue error]data=%p,fun=%p", data, fun);
+ return NULL;
}
- if (EOK != MEMSET_S (tm_info, sizeof (*tm_info), 0, sizeof (*tm_info)))
+ if (EOK != memset_s(tm_info, sizeof(*tm_info), 0, sizeof(*tm_info)))
{
- if (0 == nsfw_mem_ring_enqueue (g_timer_cfg.timer_info_pool, tm_info))
+ if (0 == nsfw_mem_ring_enqueue(g_timer_cfg.timer_info_pool, tm_info))
{
- NSFW_LOGERR ("enqueue error]data=%p,fun=%p", data, fun);
+ NSFW_LOGERR("enqueue error]data=%p,fun=%p", data, fun);
}
- NSFW_LOGERR ("mem set error]data=%p,fun=%p", data, fun);
- return NULL;
+ NSFW_LOGERR("mem set error]data=%p,fun=%p", data, fun);
+ return NULL;
}
- tm_info->fun = fun;
- tm_info->argv = data;
- tm_info->time_left = time_left;
- //tm_info->time_left.tv_sec += NSFW_TIMER_CYCLE;
- tm_info->timer_type = timer_type;
- list_add_tail (&tm_info->node, &g_timer_cfg.timer_head);
- tm_info->alloc_flag = TRUE;
- return tm_info;
+ tm_info->fun = fun;
+ tm_info->argv = data;
+ tm_info->time_left = time_left;
+ tm_info->timer_type = timer_type;
+ tm_info->alloc_flag = TRUE;
+ /* it can start timer after only finish all timer reg, or else it have multi-thread issue */
+ dmm_spin_lock(&g_timer_cfg.timer_lock);
+ list_add_tail(&tm_info->node, &g_timer_cfg.timer_head);
+ dmm_spin_unlock(&g_timer_cfg.timer_lock);
+ return tm_info;
}
/*****************************************************************************
@@ -101,32 +99,34 @@ nsfw_timer_reg_timer (u32 timer_type, void *data,
* Return Value : void
* Calls :
* Called By :
-*
*****************************************************************************/
-void
-nsfw_timer_rmv_timer (nsfw_timer_info * tm_info)
+void nsfw_timer_rmv_timer(nsfw_timer_info * tm_info)
{
- if (NULL == tm_info)
+ if (NULL == tm_info)
{
- NSFW_LOGWAR ("tm_info nul");
- return;
+ NSFW_LOGWAR("tm_info nul");
+ return;
}
+ /* it can start timer after only finish all timer reg, or else it have multi-thread issue */
+ dmm_spin_lock(&g_timer_cfg.timer_lock);
- if (FALSE == tm_info->alloc_flag)
+ if (FALSE == tm_info->alloc_flag)
{
- NSFW_LOGERR ("tm_info refree]tm_info=%p,argv=%p,fun=%p", tm_info,
- tm_info->argv, tm_info->fun);
- return;
+ dmm_spin_unlock(&g_timer_cfg.timer_lock);
+ NSFW_LOGERR("tm_info refree]tm_info=%p,argv=%p,fun=%p", tm_info,
+ tm_info->argv, tm_info->fun);
+ return;
}
- tm_info->alloc_flag = FALSE;
- list_del (&tm_info->node);
- if (0 == nsfw_mem_ring_enqueue (g_timer_cfg.timer_info_pool, tm_info))
+ tm_info->alloc_flag = FALSE;
+ list_del(&tm_info->node);
+ if (0 == nsfw_mem_ring_enqueue(g_timer_cfg.timer_info_pool, tm_info))
{
- NSFW_LOGERR ("tm_info free failed]tm_info=%p,argv=%p,fun=%p", tm_info,
- tm_info->argv, tm_info->fun);
+ NSFW_LOGERR("tm_info free failed]tm_info=%p,argv=%p,fun=%p", tm_info,
+ tm_info->argv, tm_info->fun);
}
- return;
+ dmm_spin_unlock(&g_timer_cfg.timer_lock);
+ return;
}
/*****************************************************************************
@@ -137,41 +137,59 @@ nsfw_timer_rmv_timer (nsfw_timer_info * tm_info)
* Return Value : u8
* Calls :
* Called By :
-*
*****************************************************************************/
-void
-nsfw_timer_exp (u64 count)
+void nsfw_timer_exp(u64 count)
{
- nsfw_timer_info *tm_info = NULL;
- struct list_head *tNode;
- struct list_head *tPretNode;
-
- LINT_LIST ()list_for_each_entry (tm_info, tNode, (&g_timer_cfg.timer_head),
- node)
- {
- tPretNode = tm_info->node.prev;
- if (tm_info->time_left.tv_sec > (long) count * NSFW_TIMER_CYCLE)
- {
- tm_info->time_left.tv_sec -= count * NSFW_TIMER_CYCLE;
- continue;
- }
-
- list_del (&tm_info->node);
- list_add_tail (&tm_info->node, &g_timer_cfg.exp_timer_head);
- tNode = tPretNode;
- }
-
- u32 i = 0;
- while (!list_empty (&g_timer_cfg.exp_timer_head)
- && i++ < NSFW_TIMER_INFO_MAX_COUNT)
+ nsfw_timer_info *tm_info = NULL;
+ struct list_head *tNode;
+ struct list_head *tPretNode;
+
+ /* it can start timer after only finish all timer reg, or else it have multi-thread issue */
+ dmm_spin_lock(&g_timer_cfg.timer_lock);
+
+ list_for_each_entry(tm_info, tNode, (&g_timer_cfg.timer_head), node)
+ {
+
+ tPretNode = tm_info->node.prev;
+ if (tm_info->time_left.tv_sec > (long) count * NSFW_TIMER_CYCLE)
+ {
+ tm_info->time_left.tv_sec -= count * NSFW_TIMER_CYCLE;
+ continue;
+ }
+
+ list_del(&tm_info->node);
+ list_add_tail(&tm_info->node, &g_timer_cfg.exp_timer_head);
+ tNode = tPretNode;
+ }
+ dmm_spin_unlock(&g_timer_cfg.timer_lock);
+
+ u32 i = 0;
+ while (!list_empty(&g_timer_cfg.exp_timer_head)
+ && i++ < NSFW_TIMER_INFO_MAX_COUNT)
{
- tm_info =
- (nsfw_timer_info *) list_get_first (&g_timer_cfg.exp_timer_head);
- if (NULL != tm_info->fun)
+ dmm_spin_lock(&g_timer_cfg.timer_lock);
+ tm_info =
+ (nsfw_timer_info *) list_get_first(&g_timer_cfg.exp_timer_head);
+ if (NULL == tm_info)
+ {
+ dmm_spin_unlock(&g_timer_cfg.timer_lock);
+ continue;
+ }
+ tm_info->alloc_flag = FALSE;
+ list_del(&tm_info->node);
+ dmm_spin_unlock(&g_timer_cfg.timer_lock);
+ /* here can't lock that it is possible that the tm_info->fun call reg timer or remove timer, which will cause deadlock */
+ if (NULL != tm_info->fun)
+ {
+ (void) tm_info->fun(tm_info->timer_type, tm_info->argv);
+ }
+ /* only after finish handle tm_info->fun, it can put it into timer_info_pool, avoid that it is applied by other timer */
+ if (0 == nsfw_mem_ring_enqueue(g_timer_cfg.timer_info_pool, tm_info))
{
- (void) tm_info->fun (tm_info->timer_type, tm_info->argv);
+ NSFW_LOGERR("tm_info free failed]tm_info=%p,argv=%p,fun=%p",
+ tm_info, tm_info->argv, tm_info->fun);
}
- nsfw_timer_rmv_timer (tm_info);
+
}
}
@@ -185,38 +203,32 @@ nsfw_timer_exp (u64 count)
* Calls :
* Called By :
*****************************************************************************/
-i32
-nsfw_get_timer_socket ()
+i32 nsfw_get_timer_socket()
{
- i32 tfd = timerfd_create (CLOCK_MONOTONIC, TFD_NONBLOCK);
- if (tfd == -1)
+
+ i32 tfd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK);
+ if (tfd == -1)
{
- NSFW_LOGERR ("timerfd_create failed!]errno=%d\n", errno);
- return -1;
+ NSFW_LOGERR("timerfd_create failed!]errno=%d\n", errno);
+ return -1;
}
- /* close on exe */
- if (-1 == nsfw_set_close_on_exec (tfd))
+ /* close on exec */
+ if (-1 == nsfw_set_close_on_exec(tfd))
{
- (void) nsfw_base_close (tfd);
- NSFW_LOGERR ("set exec err]fd=%d, errno=%d", tfd, errno);
- return -1;
+ (void) nsfw_base_close(tfd);
+ NSFW_LOGERR("set exec err]fd=%d, errno=%d", tfd, errno);
+ return -1;
}
- struct itimerspec ts;
- ts.it_interval.tv_sec = NSFW_TIMER_CYCLE;
- ts.it_interval.tv_nsec = 0;
- ts.it_value.tv_sec = 0;
- ts.it_value.tv_nsec = NSFW_TIMER_CYCLE;
-
- if (timerfd_settime (tfd, 0, &ts, NULL) < 0)
+ if (timerfd_settime(tfd, 0, &g_timer_cfg.ts, NULL) < 0)
{
- NSFW_LOGERR ("timerfd_settime failed] errno=%d", errno);
- close (tfd);
- return -1;
+ NSFW_LOGERR("timerfd_settime failed] errno=%d", errno);
+ close(tfd);
+ return -1;
}
- return tfd;
+ return tfd;
}
/*****************************************************************************
@@ -230,53 +242,52 @@ nsfw_get_timer_socket ()
* Calls :
* Called By :
*****************************************************************************/
-int
-nsfw_timer_notify_fun (i32 epfd, i32 fd, u32 events)
+int nsfw_timer_notify_fun(i32 epfd, i32 fd, u32 events)
{
- i32 rc;
+ i32 rc;
- if ((events & EPOLLERR) || (events & EPOLLHUP) || (!(events & EPOLLIN)))
+ if ((events & EPOLLERR) || (events & EPOLLHUP) || (!(events & EPOLLIN)))
{
- (void) nsfw_base_close (fd);
- NSFW_LOGWAR ("timer disconnect!]epfd=%d,timer=%d,event=0x%x", epfd,
- fd, events);
+ (void) nsfw_base_close(fd);
+ NSFW_LOGWAR("timer disconnect!]epfd=%d,timer=%d,event=0x%x", epfd,
+ fd, events);
- (void) nsfw_mgr_unreg_sock_fun (fd);
- i32 timer_fd = nsfw_get_timer_socket ();
- if (timer_fd < 0)
+ (void) nsfw_mgr_unreg_sock_fun(fd);
+ i32 timer_fd = nsfw_get_timer_socket();
+ if (timer_fd < 0)
{
- NSFW_LOGERR ("get timer_fd failed!]epfd=%d,timer_fd=%d,event=0x%x",
- epfd, fd, events);
- return FALSE;
+ NSFW_LOGERR("get timer_fd faied!]epfd=%d,timer_fd=%d,event=0x%x",
+ epfd, fd, events);
+ return FALSE;
}
- (void) nsfw_mgr_reg_sock_fun (timer_fd, nsfw_timer_notify_fun);
- return TRUE;
+ (void) nsfw_mgr_reg_sock_fun(timer_fd, nsfw_timer_notify_fun);
+ return TRUE;
}
- u64 data;
- while (1)
+ u64 data;
+ while (1)
{
- rc = nsfw_base_read (fd, &data, sizeof (data));
- if (rc == 0)
+ rc = nsfw_base_read(fd, &data, sizeof(data));
+ if (rc == 0)
{
- NSFW_LOGERR ("timer_fd recv 0]timer_fd=%d,errno=%d", fd, errno);
- break;
+ NSFW_LOGERR("timer_fd recv 0]timer_fd=%d,errno=%d", fd, errno);
+ break;
}
- else if (rc == -1)
+ else if (rc == -1)
{
- if (errno == EINTR || errno == EAGAIN)
+ if (errno == EINTR || errno == EAGAIN)
{
- break;
+ break;
}
- NSMON_LOGERR ("timer_fd recv]timer_fd=%d,errno=%d", fd, errno);
- break;
+ NSMON_LOGERR("timer_fd recv]timer_fd=%d,errno=%d", fd, errno);
+ break;
}
- nsfw_timer_exp (data);
+ nsfw_timer_exp(data);
}
- return TRUE;
+ return TRUE;
}
/*****************************************************************************
@@ -287,21 +298,19 @@ nsfw_timer_notify_fun (i32 epfd, i32 fd, u32 events)
* Return Value : u8
* Calls :
* Called By :
-*
*****************************************************************************/
-u8
-nsfw_timer_start ()
+u8 nsfw_timer_start()
{
- i32 timer_fd = nsfw_get_timer_socket ();
- if (timer_fd < 0)
+ i32 timer_fd = nsfw_get_timer_socket();
+ if (timer_fd < 0)
{
- NSFW_LOGERR ("get timer_fd failed!");
- return FALSE;
+ NSFW_LOGERR("get timer_fd fail");
+ return FALSE;
}
- NSFW_LOGINF ("start timer_fd module!]timer_fd=%d", timer_fd);
- (void) nsfw_mgr_reg_sock_fun (timer_fd, nsfw_timer_notify_fun);
- return TRUE;
+ NSFW_LOGINF("start timer_fd module]timer_fd=%d", timer_fd);
+ (void) nsfw_mgr_reg_sock_fun(timer_fd, nsfw_timer_notify_fun);
+ return TRUE;
}
/*****************************************************************************
@@ -312,64 +321,79 @@ nsfw_timer_start ()
* Return Value : int
* Calls :
* Called By :
-*
*****************************************************************************/
-int
-nsfw_timer_module_init (void *param)
+int nsfw_timer_module_init(void *param)
{
- u32 proc_type = (u32) ((long long) param);
- nsfw_timer_init_cfg *timer_cfg = &g_timer_cfg;
- NSFW_LOGINF ("ps module init]type=%u", proc_type);
- switch (proc_type)
+ u32 proc_type = (u32) ((long long) param);
+ nsfw_timer_init_cfg *timer_cfg = &g_timer_cfg;
+ if (proc_type != NSFW_PROC_CTRL)
{
- case NSFW_PROC_MAIN:
- (void) NSFW_REG_SOFT_INT (NSFW_DBG_MODE_PARAM, g_hbt_switch, 0, 1);
- break;
- case NSFW_PROC_TOOLS:
- case NSFW_PROC_CTRL:
- break;
- default:
- return 0;
+ NSFW_LOGINF("ps module init]type=%u", proc_type);
}
- timer_cfg->timer_info_size = NSFW_TIMER_INFO_MAX_COUNT_DEF;
-
- nsfw_mem_sppool pmpinfo;
- pmpinfo.enmptype = NSFW_MRING_MPMC;
- pmpinfo.usnum = timer_cfg->timer_info_size;
- pmpinfo.useltsize = sizeof (nsfw_timer_info);
- pmpinfo.isocket_id = NSFW_SOCKET_ANY;
- pmpinfo.stname.entype = NSFW_NSHMEM;
- if (-1 ==
- SPRINTF_S (pmpinfo.stname.aname, NSFW_MEM_NAME_LENGTH, "%s",
- "MS_TM_INFOPOOL"))
+ /* The first expiration should be the same as the cyclic interval. This fixs the bug of skipping one beat */
+ timer_cfg->ts.it_interval.tv_sec = NSFW_TIMER_CYCLE;
+ timer_cfg->ts.it_interval.tv_nsec = 0;
+ timer_cfg->ts.it_value.tv_sec = timer_cfg->ts.it_interval.tv_sec;
+ timer_cfg->ts.it_value.tv_nsec = timer_cfg->ts.it_interval.tv_nsec;
+
+ switch (proc_type)
{
- NSFW_LOGERR ("SPRINTF_S failed");
- return -1;
+ case NSFW_PROC_MASTER:
+ /** For nMaster, we call nsfw_mgr_ep_start() after every other module is inited,
+ ** so the first expiration is set to 1 nanosecond for nMaster to bring up nMain ASAP */
+ timer_cfg->ts.it_value.tv_sec = 0;
+ timer_cfg->ts.it_value.tv_nsec = 1;
+ case NSFW_PROC_MAIN:
+ (void) NSFW_REG_SOFT_INT(NSFW_DBG_MODE_PARAM, g_hbt_switch, 0, 1);
+ break;
+ case NSFW_PROC_TOOLS:
+ case NSFW_PROC_CTRL:
+ break;
+ default:
+ return 0;
}
- timer_cfg->timer_info_pool = nsfw_mem_sp_create (&pmpinfo);
- if (!timer_cfg->timer_info_pool)
+ timer_cfg->timer_info_size = NSFW_TIMER_INFO_MAX_COUNT_DEF;
+
+ nsfw_mem_sppool pmpinfo;
+ pmpinfo.enmptype = NSFW_MRING_MPMC;
+ pmpinfo.usnum = timer_cfg->timer_info_size;
+ pmpinfo.useltsize = sizeof(nsfw_timer_info);
+ pmpinfo.isocket_id = NSFW_SOCKET_ANY;
+ pmpinfo.stname.entype = NSFW_NSHMEM;
+ if (-1 ==
+ sprintf_s(pmpinfo.stname.aname, NSFW_MEM_NAME_LENTH, "%s",
+ "MS_TM_INFOPOOL"))
{
- NSFW_LOGERR ("alloc timer info pool_err");
- return -1;
+ NSFW_LOGERR("sprintf_s fail");
+ return -1;
}
+ timer_cfg->timer_info_pool = nsfw_mem_sp_create(&pmpinfo);
+
+ if (!timer_cfg->timer_info_pool)
+ {
+ NSFW_LOGERR("alloc timer info pool_err");
+ return -1;
+ }
+
+ MEM_STAT(NSFW_TIMER_MODULE, pmpinfo.stname.aname, NSFW_NSHMEM,
+ nsfw_mem_get_len(timer_cfg->timer_info_pool, NSFW_MEM_SPOOL));
- MEM_STAT (NSFW_TIMER_MODULE, pmpinfo.stname.aname, NSFW_NSHMEM,
- nsfw_mem_get_len (timer_cfg->timer_info_pool, NSFW_MEM_SPOOL));
+ INIT_LIST_HEAD(&(timer_cfg->timer_head));
+ INIT_LIST_HEAD(&(timer_cfg->exp_timer_head));
- INIT_LIST_HEAD (&(timer_cfg->timer_head));
- INIT_LIST_HEAD (&(timer_cfg->exp_timer_head));
+ dmm_spin_init(&g_timer_cfg.timer_lock);
+ (void) nsfw_timer_start();
- (void) nsfw_timer_start ();
- return 0;
+ return 0;
}
/* *INDENT-OFF* */
-NSFW_MODULE_NAME (NSFW_TIMER_MODULE)
-NSFW_MODULE_PRIORITY (10)
-NSFW_MODULE_DEPENDS (NSFW_MGR_COM_MODULE)
-NSFW_MODULE_INIT (nsfw_timer_module_init)
+NSFW_MODULE_NAME(NSFW_TIMER_MODULE)
+NSFW_MODULE_PRIORITY(10)
+NSFW_MODULE_DEPENDS(NSFW_MGR_COM_MODULE)
+NSFW_MODULE_INIT(nsfw_timer_module_init)
/* *INDENT-ON* */
#ifdef __cplusplus
diff --git a/src/framework/ipc/ps/nsfw_ps_mem_module.c b/src/framework/ipc/ps/nsfw_ps_mem_module.c
index 55af158..57662f9 100644
--- a/src/framework/ipc/ps/nsfw_ps_mem_module.c
+++ b/src/framework/ipc/ps/nsfw_ps_mem_module.c
@@ -17,7 +17,7 @@
#include <stdlib.h>
#include "types.h"
#include "nstack_securec.h"
-#include "nsfw_init.h"
+#include "nsfw_init_api.h"
#include "nsfw_ps_module.h"
#include "nsfw_mgr_com_api.h"
@@ -37,31 +37,30 @@ extern "C"{
ns_mem_mng_init_cfg g_mem_cfg;
-int mem_ps_exiting (void *pps_info, void *argv);
+int mem_ps_exiting(void *pps_info, void *argv);
-int
-nsfw_mem_ps_exit_resend_timeout (u32 timer_type, void *data)
+int nsfw_mem_ps_exit_resend_timeout(u32 timer_type, void *data)
{
- nsfw_ps_info *ps_info = data;
- if (NULL == ps_info)
+ nsfw_ps_info *ps_info = data;
+ if (NULL == ps_info)
{
- NSFW_LOGERR ("ps_info nul!");
- return FALSE;
+ NSFW_LOGERR("ps_info nul!");
+ return FALSE;
}
- if (NSFW_PROC_APP != ps_info->proc_type)
+ if (NSFW_PROC_APP != ps_info->proc_type)
{
- return FALSE;
+ return FALSE;
}
- if (NSFW_PS_EXITING != ps_info->state)
+ if (NSFW_PS_EXITING != ps_info->state)
{
- return FALSE;
+ return FALSE;
}
- ps_info->resend_timer_ptr = NULL;
- (void) mem_ps_exiting (ps_info, NULL);
- return TRUE;
+ ps_info->resend_timer_ptr = NULL;
+ (void) mem_ps_exiting(ps_info, NULL);
+ return TRUE;
}
/*****************************************************************************
@@ -74,143 +73,128 @@ nsfw_mem_ps_exit_resend_timeout (u32 timer_type, void *data)
* Calls :
* Called By :
*****************************************************************************/
-int
-mem_ps_exiting (void *pps_info, void *argv)
+int mem_ps_exiting(void *pps_info, void *argv)
{
- if (NULL == pps_info)
+ if (NULL == pps_info)
{
- NSFW_LOGERR ("ps_info nul!");
- return FALSE;
+ NSFW_LOGERR("ps_info nul!");
+ return FALSE;
}
- if (TRUE == NSFW_SRV_STATE_SUSPEND)
+ if (TRUE == NSFW_SRV_STATE_SUSPEND)
{
- NSFW_LOGERR ("main suspend]ps_info=%d,pid=%u", pps_info,
- ((nsfw_ps_info *) pps_info)->host_pid);
- return FALSE;
+ NSFW_LOGERR("main suspend]ps_info=%p,pid=%u", pps_info,
+ ((nsfw_ps_info *) pps_info)->host_pid);
+ return FALSE;
}
- nsfw_mgr_msg *msg =
- nsfw_mgr_msg_alloc (MGR_MSG_APP_EXIT_REQ, NSFW_PROC_MAIN);
- if (NULL == msg)
+ nsfw_mgr_msg *msg =
+ nsfw_mgr_msg_alloc(MGR_MSG_APP_EXIT_REQ, NSFW_PROC_MAIN);
+ if (NULL == msg)
{
- NSFW_LOGERR ("ps_exit alloc msg failed]ps_info=%p,pid=%u", pps_info,
- ((nsfw_ps_info *) pps_info)->host_pid);
- return FALSE;
+ NSFW_LOGERR("ps_exit alloc msg failed]ps_info=%p,pid=%u", pps_info,
+ ((nsfw_ps_info *) pps_info)->host_pid);
+ return FALSE;
}
- nsfw_ps_info_msg *ps_msg = GET_USER_MSG (nsfw_ps_info_msg, msg);
- ps_msg->host_pid = ((nsfw_ps_info *) pps_info)->host_pid;
+ nsfw_ps_info_msg *ps_msg = GET_USER_MSG(nsfw_ps_info_msg, msg);
+ ps_msg->host_pid = ((nsfw_ps_info *) pps_info)->host_pid;
- (void) nsfw_mgr_send_msg (msg);
- NSFW_LOGINF ("ps_exiting send msg]ps_info=%p,pid=%u", pps_info,
- ps_msg->host_pid);
- nsfw_mgr_msg_free (msg);
- return TRUE;
+ (void) nsfw_mgr_send_msg(msg);
+ NSFW_LOGINF("ps_exiting send msg]ps_info=%p,pid=%u", pps_info,
+ ps_msg->host_pid);
+ nsfw_mgr_msg_free(msg);
+
+ return TRUE;
}
-/*****************************************************************************
-* Prototype : mem_alloc_ps_info
-* Description : alloc ps_info
-* Input : u32 pid
-* u8 proc_type
-* Output : None
-* Return Value : u8
-* Calls :
-* Called By :
-*****************************************************************************/
-u8
-mem_alloc_ps_info (u32 pid, u8 proc_type)
+u8 mem_alloc_ps_info(u32 pid, u8 proc_type)
{
- nsfw_ps_info *pps_info = NULL;
- pps_info = nsfw_ps_info_get (pid);
- if (NULL != pps_info)
+ nsfw_ps_info *pps_info = NULL;
+ pps_info = nsfw_ps_info_get(pid);
+ if (NULL != pps_info)
{
- return TRUE;
+ return TRUE;
}
- pps_info = nsfw_ps_info_alloc (pid, proc_type);
- if (NULL == pps_info)
+ pps_info = nsfw_ps_info_alloc(pid, proc_type, 0);
+ if (NULL == pps_info)
{
- NSFW_LOGERR ("alloc ps_info failed!]pid=%u,proc_type=%u", pid,
- proc_type);
- return FALSE;
+ NSFW_LOGERR("alloc ps_info falied!]pid=%u,proc_type=%u", pid,
+ proc_type);
+ return FALSE;
}
- NSFW_LOGINF ("alloc new ps_info]pps_info=%p,pid=%u", pps_info, pid);
- return TRUE;
+ NSFW_LOGINF("alloc new ps_info]pps_info=%p,pid=%u", pps_info, pid);
+ return TRUE;
}
/*mem alloc by msg begin*/
-void *
-mem_item_zone_create (void *mem_info)
+void *mem_item_zone_create(void *mem_info)
{
- return (void *) nsfw_mem_zone_create ((nsfw_mem_zone *) mem_info);
+ return (void *) nsfw_mem_zone_create((nsfw_mem_zone *) mem_info);
}
-void *
-mem_item_mbfmp_create (void *mem_info)
+void *mem_item_mbfmp_create(void *mem_info)
{
- return (void *) nsfw_mem_mbfmp_create ((nsfw_mem_mbfpool *) mem_info);
+ return (void *) nsfw_mem_mbfmp_create((nsfw_mem_mbfpool *) mem_info);
}
-void *
-mem_item_sp_create (void *mem_info)
+void *mem_item_sp_create(void *mem_info)
{
- return (void *) nsfw_mem_sp_create ((nsfw_mem_sppool *) mem_info);
+ return (void *) nsfw_mem_sp_create((nsfw_mem_sppool *) mem_info);
}
-void *
-mem_item_ring_create (void *mem_info)
+void *mem_item_ring_create(void *mem_info)
{
- return (void *) nsfw_mem_ring_create ((nsfw_mem_mring *) mem_info);
+ return (void *) nsfw_mem_ring_create((nsfw_mem_mring *) mem_info);
}
nsfw_ps_mem_item_cfg g_ps_mem_map[] = {
- {
- NSFW_RESERV_REQ_MSG,
- sizeof (nsfw_shmem_reserv_req),
- NSFW_MEM_MZONE,
- mem_item_zone_create,
- mem_item_get_callargv}
- ,
-
- {
- NSFW_MBUF_REQ_MSG,
- sizeof (nsfw_shmem_mbuf_req),
- NSFW_MEM_MBUF,
- mem_item_mbfmp_create,
- mem_item_get_callargv}
- ,
- {
- NSFW_SPPOOL_REQ_MSG,
- sizeof (nsfw_shmem_sppool_req),
- NSFW_MEM_SPOOL,
- mem_item_sp_create,
- mem_item_get_callargv}
- ,
- {
- NSFW_RING_REQ_MSG,
- sizeof (nsfw_shmem_ring_req),
- NSFW_MEM_RING,
- mem_item_ring_create,
- mem_item_get_callargv}
- ,
- {
- NSFW_RELEASE_REQ_MSG,
- sizeof (nsfw_shmem_free_req),
- 0xFFFF,
- mem_item_free,
- mem_item_get_callargv,
- }
- ,
- {
- NSFW_MEM_LOOKUP_REQ_MSG,
- sizeof (nsfw_shmem_lookup_req),
- 0xFFFF,
- mem_item_lookup,
- mem_item_get_callargv,
- }
+ {
+ NSFW_RESERV_REQ_MSG,
+ sizeof(nsfw_shmem_reserv_req),
+ NSFW_MEM_MZONE,
+ mem_item_zone_create,
+ mem_item_get_callargv}
+ ,
+
+ {
+ NSFW_MBUF_REQ_MSG,
+ sizeof(nsfw_shmem_mbuf_req),
+ NSFW_MEM_MBUF,
+ mem_item_mbfmp_create,
+ mem_item_get_callargv}
+ ,
+ {
+ NSFW_SPPOOL_REQ_MSG,
+ sizeof(nsfw_shmem_sppool_req),
+ NSFW_MEM_SPOOL,
+ mem_item_sp_create,
+ mem_item_get_callargv}
+ ,
+ {
+ NSFW_RING_REQ_MSG,
+ sizeof(nsfw_shmem_ring_req),
+ NSFW_MEM_RING,
+ mem_item_ring_create,
+ mem_item_get_callargv}
+ ,
+ {
+ NSFW_RELEASE_REQ_MSG,
+ sizeof(nsfw_shmem_free_req),
+ 0xFFFF,
+ mem_item_free,
+ mem_item_get_callargv,
+ }
+ ,
+ {
+ NSFW_MEM_LOOKUP_REQ_MSG,
+ sizeof(nsfw_shmem_lookup_req),
+ 0xFFFF,
+ mem_item_lookup,
+ mem_item_get_callargv,
+ }
};
/*****************************************************************************
@@ -222,25 +206,25 @@ nsfw_ps_mem_item_cfg g_ps_mem_map[] = {
* Calls :
* Called By :
*****************************************************************************/
-nsfw_ps_mem_item_cfg *
-mem_item_get_cfg_from_msg (u16 msg_type)
+nsfw_ps_mem_item_cfg *mem_item_get_cfg_from_msg(u16 msg_type)
{
- int idx;
- int map_count = sizeof (g_ps_mem_map) / sizeof (nsfw_ps_mem_item_cfg);
- for (idx = 0; idx < map_count; idx++)
+ int idx;
+ int map_count = sizeof(g_ps_mem_map) / sizeof(nsfw_ps_mem_item_cfg);
+ for (idx = 0; idx < map_count; idx++)
{
- if (g_ps_mem_map[idx].usmsg_type == msg_type)
+ if (g_ps_mem_map[idx].usmsg_type == msg_type)
{
- return &g_ps_mem_map[idx];
+
+ return &g_ps_mem_map[idx];
}
}
- return NULL;
+ return NULL;
}
/*****************************************************************************
* Prototype : mem_item_get_callargv
-* Description : change the message value to structure value
+* Description : change the message value to structur value
* Input : u16 msg_type
* char* msg_body
* char *memstr_buf
@@ -250,163 +234,143 @@ mem_item_get_cfg_from_msg (u16 msg_type)
* Calls :
* Called By :
*****************************************************************************/
-u8
-mem_item_get_callargv (u16 msg_type, char *msg_body, char *memstr_buf,
- i32 buf_len)
+u8 mem_item_get_callargv(u16 msg_type, char *msg_body, char *memstr_buf,
+ i32 buf_len)
{
- switch (msg_type)
- {
- case NSFW_RESERV_REQ_MSG:
- MEM_GET_CALLARGV (length, length, nsfw_mem_zone, nsfw_shmem_reserv_req,
- memstr_buf, msg_body);
- MEM_GET_CALLARGV (isocket_id, isocket_id, nsfw_mem_zone,
- nsfw_shmem_reserv_req, memstr_buf, msg_body);
- break;
- case NSFW_MBUF_REQ_MSG:
- MEM_GET_CALLARGV (usnum, usnum, nsfw_mem_mbfpool, nsfw_shmem_mbuf_req,
- memstr_buf, msg_body);
- MEM_GET_CALLARGV (uscash_size, uscash_size, nsfw_mem_mbfpool,
- nsfw_shmem_mbuf_req, memstr_buf, msg_body);
- MEM_GET_CALLARGV (uspriv_size, uspriv_size, nsfw_mem_mbfpool,
- nsfw_shmem_mbuf_req, memstr_buf, msg_body);
- MEM_GET_CALLARGV (usdata_room, usdata_room, nsfw_mem_mbfpool,
- nsfw_shmem_mbuf_req, memstr_buf, msg_body);
- MEM_GET_CALLARGV (enmptype, enmptype, nsfw_mem_mbfpool,
- nsfw_shmem_mbuf_req, memstr_buf, msg_body);
- MEM_GET_CALLARGV (isocket_id, isocket_id, nsfw_mem_mbfpool,
- nsfw_shmem_mbuf_req, memstr_buf, msg_body);
- break;
- case NSFW_SPPOOL_REQ_MSG:
- MEM_GET_CALLARGV (usnum, usnum, nsfw_mem_sppool,
- nsfw_shmem_sppool_req, memstr_buf, msg_body);
- MEM_GET_CALLARGV (useltsize, useltsize, nsfw_mem_sppool,
- nsfw_shmem_sppool_req, memstr_buf, msg_body);
- MEM_GET_CALLARGV (enmptype, enmptype, nsfw_mem_sppool,
- nsfw_shmem_sppool_req, memstr_buf, msg_body);
- MEM_GET_CALLARGV (isocket_id, isocket_id, nsfw_mem_sppool,
- nsfw_shmem_sppool_req, memstr_buf, msg_body);
- break;
- case NSFW_RING_REQ_MSG:
- MEM_GET_CALLARGV (usnum, usnum, nsfw_mem_mring, nsfw_shmem_ring_req,
- memstr_buf, msg_body);
- MEM_GET_CALLARGV (enmptype, enmptype, nsfw_mem_mring,
- nsfw_shmem_ring_req, memstr_buf, msg_body);
- MEM_GET_CALLARGV (isocket_id, isocket_id, nsfw_mem_mring,
- nsfw_shmem_ring_req, memstr_buf, msg_body);
- break;
- case NSFW_RELEASE_REQ_MSG:
- MEM_GET_CALLARGV (ustype, ustype, nsfw_mem_type_info,
- nsfw_shmem_free_req, memstr_buf, msg_body);
- break;
- case NSFW_MEM_LOOKUP_REQ_MSG:
- MEM_GET_CALLARGV (ustype, ustype, nsfw_mem_type_info,
- nsfw_shmem_lookup_req, memstr_buf, msg_body);
- break;
- default:
- NSFW_LOGERR ("error msg]type=%u", msg_type);
- return FALSE;
- }
- if (EOK !=
- STRCPY_S (((nsfw_mem_zone *) memstr_buf)->stname.aname,
- NSFW_MEM_NAME_LENGTH,
- ((nsfw_shmem_reserv_req *) msg_body)->aname))
- {
- NSFW_LOGERR ("STRCPY_S failed]msg_type=%u", msg_type);
- return FALSE;
- }
-
- ((nsfw_mem_zone *) memstr_buf)->stname.entype = NSFW_SHMEM;
-
- return TRUE;
+ switch (msg_type)
+ {
+ case NSFW_RESERV_REQ_MSG:
+ MEM_GET_CALLARGV(lenth, lenth, nsfw_mem_zone,
+ nsfw_shmem_reserv_req, memstr_buf, msg_body);
+ MEM_GET_CALLARGV(isocket_id, isocket_id, nsfw_mem_zone,
+ nsfw_shmem_reserv_req, memstr_buf, msg_body);
+ break;
+ case NSFW_MBUF_REQ_MSG:
+ MEM_GET_CALLARGV(usnum, usnum, nsfw_mem_mbfpool,
+ nsfw_shmem_mbuf_req, memstr_buf, msg_body);
+ MEM_GET_CALLARGV(uscash_size, uscash_size, nsfw_mem_mbfpool,
+ nsfw_shmem_mbuf_req, memstr_buf, msg_body);
+ MEM_GET_CALLARGV(uspriv_size, uspriv_size, nsfw_mem_mbfpool,
+ nsfw_shmem_mbuf_req, memstr_buf, msg_body);
+ MEM_GET_CALLARGV(usdata_room, usdata_room, nsfw_mem_mbfpool,
+ nsfw_shmem_mbuf_req, memstr_buf, msg_body);
+ MEM_GET_CALLARGV(enmptype, enmptype, nsfw_mem_mbfpool,
+ nsfw_shmem_mbuf_req, memstr_buf, msg_body);
+ MEM_GET_CALLARGV(isocket_id, isocket_id, nsfw_mem_mbfpool,
+ nsfw_shmem_mbuf_req, memstr_buf, msg_body);
+ break;
+ case NSFW_SPPOOL_REQ_MSG:
+ MEM_GET_CALLARGV(usnum, usnum, nsfw_mem_sppool,
+ nsfw_shmem_sppool_req, memstr_buf, msg_body);
+ MEM_GET_CALLARGV(useltsize, useltsize, nsfw_mem_sppool,
+ nsfw_shmem_sppool_req, memstr_buf, msg_body);
+ MEM_GET_CALLARGV(enmptype, enmptype, nsfw_mem_sppool,
+ nsfw_shmem_sppool_req, memstr_buf, msg_body);
+ MEM_GET_CALLARGV(isocket_id, isocket_id, nsfw_mem_sppool,
+ nsfw_shmem_sppool_req, memstr_buf, msg_body);
+ break;
+ case NSFW_RING_REQ_MSG:
+ MEM_GET_CALLARGV(usnum, usnum, nsfw_mem_mring,
+ nsfw_shmem_ring_req, memstr_buf, msg_body);
+ MEM_GET_CALLARGV(enmptype, enmptype, nsfw_mem_mring,
+ nsfw_shmem_ring_req, memstr_buf, msg_body);
+ MEM_GET_CALLARGV(isocket_id, isocket_id, nsfw_mem_mring,
+ nsfw_shmem_ring_req, memstr_buf, msg_body);
+ break;
+ case NSFW_RELEASE_REQ_MSG:
+ MEM_GET_CALLARGV(ustype, ustype, nsfw_mem_type_info,
+ nsfw_shmem_free_req, memstr_buf, msg_body);
+ break;
+ case NSFW_MEM_LOOKUP_REQ_MSG:
+ MEM_GET_CALLARGV(ustype, ustype, nsfw_mem_type_info,
+ nsfw_shmem_lookup_req, memstr_buf, msg_body);
+ break;
+ default:
+ NSFW_LOGERR("error msg]type=%u", msg_type);
+ return FALSE;
+ }
+ /*copy string should use strcpy_s */
+ if (EOK !=
+ strcpy_s(((nsfw_mem_zone *) memstr_buf)->stname.aname,
+ NSFW_MEM_NAME_LENTH,
+ ((nsfw_shmem_reserv_req *) msg_body)->aname))
+ {
+ NSFW_LOGERR("strcpy_s failed]msg_type=%u", msg_type);
+ return FALSE;
+ }
+
+ ((nsfw_mem_zone *) memstr_buf)->stname.entype = NSFW_SHMEM;
+
+ return TRUE;
}
-/*****************************************************************************
-* Prototype : mem_item_free
-* Description : free memory item
-* Input : void *pdata
-* Output : None
-* Return Value : void*
-* Calls :
-* Called By :
-*****************************************************************************/
-void *
-mem_item_free (void *pdata)
+void *mem_item_free(void *pdata)
{
- nsfw_mem_type_info *mem_free = (nsfw_mem_type_info *) pdata;
- i32 ret;
- NSFW_LOGINF ("free mem]type=%u,name=%s", mem_free->ustype,
- mem_free->stname.aname);
- switch (mem_free->ustype)
- {
- case NSFW_MEM_MZONE:
- ret = nsfw_mem_zone_release (&mem_free->stname);
- break;
- case NSFW_MEM_MBUF:
- ret = nsfw_mem_mbfmp_release (&mem_free->stname);
- break;
- case NSFW_MEM_SPOOL:
- ret = nsfw_mem_sp_release (&mem_free->stname);
- break;
- case NSFW_MEM_RING:
- ret = nsfw_mem_ring_release (&mem_free->stname);
- break;
- default:
- NSFW_LOGERR ("free mem err type]type=%u", mem_free->ustype);
- return NULL;
- }
-
- if (NSFW_MEM_OK != ret)
- {
- NSFW_LOGERR ("mem free failed!]ret=%d", ret);
- return NULL;
- }
-
- return pdata;
+ nsfw_mem_type_info *mem_free = (nsfw_mem_type_info *) pdata;
+ i32 ret;
+ NSFW_LOGINF("free mem]type=%u,name=%s", mem_free->ustype,
+ mem_free->stname.aname);
+ switch (mem_free->ustype)
+ {
+ case NSFW_MEM_MZONE:
+ ret = nsfw_mem_zone_release(&mem_free->stname);
+ break;
+ case NSFW_MEM_MBUF:
+ ret = nsfw_mem_mbfmp_release(&mem_free->stname);
+ break;
+ case NSFW_MEM_SPOOL:
+ ret = nsfw_mem_sp_release(&mem_free->stname);
+ break;
+ case NSFW_MEM_RING:
+ ret = nsfw_mem_ring_release(&mem_free->stname);
+ break;
+ default:
+ NSFW_LOGERR("free mem err type]type=%u", mem_free->ustype);
+ return NULL;
+ }
+
+ if (NSFW_MEM_OK != ret)
+ {
+ NSFW_LOGERR("mem free failed!]ret=%d", ret);
+ return NULL;
+ }
+
+ return pdata;
}
-/*****************************************************************************
-* Prototype : mem_item_lookup
-* Description : lookup memory item
-* Input : void *pdata
-* Output : None
-* Return Value : void*
-* Calls :
-* Called By :
-*****************************************************************************/
-void *
-mem_item_lookup (void *pdata)
+void *mem_item_lookup(void *pdata)
{
- nsfw_mem_type_info *mem_lookup = (nsfw_mem_type_info *) pdata;
- void *ret;
- NSFW_LOGDBG ("lookup mem]type=%u,name=%s", mem_lookup->ustype,
- mem_lookup->stname.aname);
- switch (mem_lookup->ustype)
- {
- case NSFW_MEM_MZONE:
- ret = nsfw_mem_zone_lookup (&mem_lookup->stname);
- break;
- case NSFW_MEM_MBUF:
- ret = nsfw_mem_mbfmp_lookup (&mem_lookup->stname);
- break;
- case NSFW_MEM_SPOOL:
- ret = nsfw_mem_sp_lookup (&mem_lookup->stname);
- break;
- case NSFW_MEM_RING:
- ret = nsfw_mem_ring_lookup (&mem_lookup->stname);
- break;
- default:
- NSFW_LOGERR ("lookup mem err type]type=%d", mem_lookup->ustype);
- return NULL;
- }
-
- if (NULL == ret)
- {
- NSFW_LOGERR ("mem lookup failed!]ret=%p,name=%s", ret,
- mem_lookup->stname.aname);
- return NULL;
- }
-
- return ret;
+ nsfw_mem_type_info *mem_lookup = (nsfw_mem_type_info *) pdata;
+ void *ret;
+ NSFW_LOGDBG("lookup mem]type=%u,name=%s", mem_lookup->ustype,
+ mem_lookup->stname.aname);
+ switch (mem_lookup->ustype)
+ {
+ case NSFW_MEM_MZONE:
+ ret = nsfw_mem_zone_lookup(&mem_lookup->stname);
+ break;
+ case NSFW_MEM_MBUF:
+ ret = nsfw_mem_mbfmp_lookup(&mem_lookup->stname);
+ break;
+ case NSFW_MEM_SPOOL:
+ ret = nsfw_mem_sp_lookup(&mem_lookup->stname);
+ break;
+ case NSFW_MEM_RING:
+ ret = nsfw_mem_ring_lookup(&mem_lookup->stname);
+ break;
+ default:
+ NSFW_LOGERR("lookup mem err type]type=%d", mem_lookup->ustype);
+ return NULL;
+ }
+
+ if (NULL == ret)
+ {
+ NSFW_LOGERR("mem lookup failed!]ret=%p,name=%s", ret,
+ mem_lookup->stname.aname);
+ return NULL;
+ }
+
+ return ret;
}
/*****************************************************************************
@@ -419,234 +383,191 @@ mem_item_lookup (void *pdata)
* Calls :
* Called By :
*****************************************************************************/
-void *
-mem_item_proc_by_msg (void *pdata, nsfw_ps_mem_item_cfg * item_cfg)
+void *mem_item_proc_by_msg(void *pdata, nsfw_ps_mem_item_cfg * item_cfg)
{
- char argv_buf[NSFW_MEM_CALL_ARG_BUF] = { 0 };
+ char argv_buf[NSFW_MEM_CALL_ARG_BUF] = { 0 };
- if ((NULL == item_cfg->change_fun) || (NULL == item_cfg->create_fun))
+ if ((NULL == item_cfg->change_fun) || (NULL == item_cfg->create_fun))
{
- NSFW_LOGERR ("item error]change_fun=%p,create_fun=%p",
- item_cfg->change_fun, item_cfg->create_fun);
- return NULL;
+ NSFW_LOGERR("item error]change_fun=%p,create_fun=%p",
+ item_cfg->change_fun, item_cfg->create_fun);
+ return NULL;
}
- if (FALSE ==
- item_cfg->change_fun (item_cfg->usmsg_type, pdata, argv_buf,
- NSFW_MEM_CALL_ARG_BUF))
+ if (FALSE ==
+ item_cfg->change_fun(item_cfg->usmsg_type, pdata, argv_buf,
+ NSFW_MEM_CALL_ARG_BUF))
{
- NSFW_LOGERR ("call change_fun failed!]type=%u", item_cfg->usmsg_type);
- return NULL;
+ NSFW_LOGERR("call change_fun failed!]type=%u", item_cfg->usmsg_type);
+ return NULL;
}
- void *pdataret = NULL;
- pdataret = (item_cfg->create_fun) ((void *) argv_buf);
- return pdataret;
+ void *pdataret = NULL;
+ pdataret = (item_cfg->create_fun) ((void *) argv_buf);
+ return pdataret;
}
-/*****************************************************************************
-* Prototype : mem_init_rsp_msg
-* Description : init the rsp message
-* Input : nsfw_shmem_msg_head* msg
-* nsfw_shmem_msg_head *rsp
-* Output : None
-* Return Value : u8
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-u8
-mem_init_rsp_msg (nsfw_shmem_msg_head * msg, nsfw_shmem_msg_head * rsp)
+u8 mem_init_rsp_msg(nsfw_shmem_msg_head * msg, nsfw_shmem_msg_head * rsp)
{
- nsfw_ps_mem_item_cfg *item_cfg =
- mem_item_get_cfg_from_msg (msg->usmsg_type);
- if (NULL == item_cfg)
+ nsfw_ps_mem_item_cfg *item_cfg =
+ mem_item_get_cfg_from_msg(msg->usmsg_type);
+ if (NULL == item_cfg)
{
- NSFW_LOGERR ("get item cfg failed!]msg_type=%u", msg->usmsg_type);
- return FALSE;
+ NSFW_LOGERR("get item cfg failed!]msg_type=%u", msg->usmsg_type);
+ return FALSE;
}
- int idx;
- int mem_count = msg->uslength / item_cfg->item_size;
+ int idx;
+ int mem_count = msg->uslenth / item_cfg->item_size;
- rsp->usmsg_type = msg->usmsg_type + 1;
- rsp->uslength = mem_count * sizeof (nsfw_shmem_ack);
- nsfw_shmem_ack *pack = (nsfw_shmem_ack *) & (rsp->aidata[0]);
- char *pdata = NULL;
- for (idx = 0; idx < mem_count; idx++)
+ rsp->usmsg_type = msg->usmsg_type + 1;
+ rsp->uslenth = mem_count * sizeof(nsfw_shmem_ack);
+ nsfw_shmem_ack *pack = (nsfw_shmem_ack *) & (rsp->aidata[0]);
+ char *pdata = NULL;
+ for (idx = 0; idx < mem_count; idx++)
{
- pdata = (char *) msg->aidata + idx * item_cfg->item_size;
- pack->pbase_addr = NULL;
- pack->usseq = ((nsfw_shmem_reserv_req *) pdata)->usseq;
- pack->cstate = NSFW_MEM_ALLOC_FAIL;
- pack++;
+
+ pdata = (char *) msg->aidata + idx * item_cfg->item_size;
+ pack->pbase_addr = NULL;
+ pack->usseq = ((nsfw_shmem_reserv_req *) pdata)->usseq;
+ pack->cstate = NSFW_MEM_ALLOC_FAIL;
+ pack++;
}
- NSFW_LOGDBG ("init all rsp ack]mem_count=%d,msg_type=%u", mem_count,
- msg->usmsg_type);
- return TRUE;
+ NSFW_LOGDBG("init all rsp ack]mem_count=%d,msg_type=%u", mem_count,
+ msg->usmsg_type);
+ return TRUE;
}
-/*****************************************************************************
-* Prototype : mem_rel_mem_by_msg
-* Description : release memory by message
-* Input : nsfw_shmem_msg_head* req_msg
-* nsfw_shmem_msg_head *rsp
-* u32 pid
-* Output : None
-* Return Value : u8
-* Calls :
-* Called By :
-*****************************************************************************/
-u8
-mem_rel_mem_by_msg (nsfw_shmem_msg_head * req_msg,
- nsfw_shmem_msg_head * rsp, u32 pid)
+u8 mem_rel_mem_by_msg(nsfw_shmem_msg_head * req_msg,
+ nsfw_shmem_msg_head * rsp, u32 pid)
{
- u32 i;
- nsfw_ps_mem_item_cfg *item_cfg =
- mem_item_get_cfg_from_msg (req_msg->usmsg_type);
- if (NULL == item_cfg)
+ u32 i;
+ nsfw_ps_mem_item_cfg *item_cfg =
+ mem_item_get_cfg_from_msg(req_msg->usmsg_type);
+ if (NULL == item_cfg)
{
- NSFW_LOGERR ("get item cfg failed!]msg_type=%u", req_msg->usmsg_type);
- return FALSE;
+ NSFW_LOGERR("get item cfg failed!]msg_type=%u", req_msg->usmsg_type);
+ return FALSE;
}
- unsigned int mem_count = req_msg->uslength / item_cfg->item_size;
- char *pdata = NULL;
- nsfw_shmem_ack *pack = (nsfw_shmem_ack *) & (rsp->aidata[0]);
- for (i = 0; i < mem_count; i++)
+ unsigned int mem_count = req_msg->uslenth / item_cfg->item_size;
+ char *pdata = NULL;
+ nsfw_shmem_ack *pack = (nsfw_shmem_ack *) & (rsp->aidata[0]);
+ for (i = 0; i < mem_count; i++)
{
- pdata = (char *) req_msg->aidata + i * item_cfg->item_size;
- if (NULL != mem_item_proc_by_msg ((void *) pdata, item_cfg))
+
+ pdata = (char *) req_msg->aidata + i * item_cfg->item_size;
+ if (NULL != mem_item_proc_by_msg((void *) pdata, item_cfg))
{
- pack->cstate = NSFW_MEM_ALLOC_SUCC;
- pack->pbase_addr = NULL;
+ pack->cstate = NSFW_MEM_ALLOC_SUCC;
+ pack->pbase_addr = NULL;
}
- pack++;
+ pack++;
}
- return TRUE;
+ return TRUE;
}
-/*****************************************************************************
-* Prototype : mem_lookup_mem_by_msg
-* Description : lookup memory by message
-* Input : nsfw_shmem_msg_head* mgr_msg
-* nsfw_shmem_msg_head *rsp
-* u32 pid
-* Output : None
-* Return Value : u8
-* Calls :
-* Called By :
-*****************************************************************************/
-u8
-mem_lookup_mem_by_msg (nsfw_shmem_msg_head * mgr_msg,
- nsfw_shmem_msg_head * rsp, u32 pid)
+u8 mem_lookup_mem_by_msg(nsfw_shmem_msg_head * mgr_msg,
+ nsfw_shmem_msg_head * rsp, u32 pid)
{
- i32 idx;
- nsfw_ps_mem_item_cfg *item_cfg =
- mem_item_get_cfg_from_msg (mgr_msg->usmsg_type);
- if (NULL == item_cfg)
+ i32 idx;
+ nsfw_ps_mem_item_cfg *item_cfg =
+ mem_item_get_cfg_from_msg(mgr_msg->usmsg_type);
+ if (NULL == item_cfg)
{
- NSFW_LOGERR ("get item cfg failed!]msg_type=%u", mgr_msg->usmsg_type);
- return FALSE;
+ NSFW_LOGERR("get item cfg failed!]msg_type=%u", mgr_msg->usmsg_type);
+ return FALSE;
}
- int mem_count = mgr_msg->uslength / item_cfg->item_size;
- char *pdata = NULL;
- void *paddr = NULL;
- nsfw_shmem_ack *pack = (nsfw_shmem_ack *) & (rsp->aidata[0]);
+ int mem_count = mgr_msg->uslenth / item_cfg->item_size;
+ char *pdata = NULL;
+ void *paddr = NULL;
+ nsfw_shmem_ack *pack = (nsfw_shmem_ack *) & (rsp->aidata[0]);
- for (idx = 0; idx < mem_count; idx++)
+ for (idx = 0; idx < mem_count; idx++)
{
- pdata = (char *) mgr_msg->aidata + idx * item_cfg->item_size;
- paddr = mem_item_proc_by_msg ((void *) pdata, item_cfg);
- if (NULL != paddr)
+
+ pdata = (char *) mgr_msg->aidata + idx * item_cfg->item_size;
+ paddr = mem_item_proc_by_msg((void *) pdata, item_cfg);
+ if (NULL != paddr)
{
- pack->cstate = NSFW_MEM_ALLOC_SUCC;
- pack->pbase_addr = paddr;
+ pack->cstate = NSFW_MEM_ALLOC_SUCC;
+ pack->pbase_addr = paddr;
}
- pack++;
+ pack++;
}
- return TRUE;
+ return TRUE;
}
-/*****************************************************************************
-* Prototype : mem_alloc_mem_by_msg
-* Description : alloc memory by message
-* Input : nsfw_shmem_msg_head* mem_msg
-* nsfw_shmem_msg_head *rsp
-* Output : None
-* Return Value : ns_mem_info*
-* Calls :
-* Called By :
-*****************************************************************************/
-void *
-mem_alloc_mem_by_msg (nsfw_shmem_msg_head * mem_msg,
- nsfw_shmem_msg_head * rsp)
+void *mem_alloc_mem_by_msg(nsfw_shmem_msg_head * mem_msg,
+ nsfw_shmem_msg_head * rsp)
{
- nsfw_ps_mem_item_cfg *item_cfg =
- mem_item_get_cfg_from_msg (mem_msg->usmsg_type);
- if (NULL == item_cfg)
+ nsfw_ps_mem_item_cfg *item_cfg =
+ mem_item_get_cfg_from_msg(mem_msg->usmsg_type);
+ if (NULL == item_cfg)
{
- NSFW_LOGERR ("get item cfg failed!]msg_type=%u", mem_msg->usmsg_type);
- return NULL;
+ NSFW_LOGERR("get item cfg fail]msg_type=%u", mem_msg->usmsg_type);
+ return NULL;
}
- int i;
- int j;
- nsfw_mem_type_info mem_free;
- char *pdata = NULL;
- void *p_addr = NULL;
+ int i;
+ int j;
+ nsfw_mem_type_info mem_free;
+ char *pdata = NULL;
+ void *p_addr = NULL;
- int mem_count = mem_msg->uslength / item_cfg->item_size;
- nsfw_shmem_ack *pack = (nsfw_shmem_ack *) & (rsp->aidata[0]);
- for (i = 0; i < mem_count; i++)
+ int mem_count = mem_msg->uslenth / item_cfg->item_size;
+ nsfw_shmem_ack *pack = (nsfw_shmem_ack *) & (rsp->aidata[0]);
+ for (i = 0; i < mem_count; i++)
{
- pdata = (char *) mem_msg->aidata + i * item_cfg->item_size;
- p_addr = mem_item_proc_by_msg ((void *) pdata, item_cfg);
- if (NULL == p_addr)
+
+ pdata = (char *) mem_msg->aidata + i * item_cfg->item_size;
+ p_addr = mem_item_proc_by_msg((void *) pdata, item_cfg);
+ if (NULL == p_addr)
{
- NSFW_LOGERR
- ("alloc mem failed!]type=%u,mem_count=%d,item=%d,name=%s",
- mem_msg->usmsg_type, mem_count, i,
- ((nsfw_shmem_reserv_req *) pdata)->aname);
- goto fail_free_mem;
+ NSFW_LOGERR
+ ("alloc mem fail]type=%u,mem_count=%d,item=%d,name=%s",
+ mem_msg->usmsg_type, mem_count, i,
+ ((nsfw_shmem_reserv_req *) pdata)->aname);
+ goto fail_free_mem;
}
- pack->cstate = NSFW_MEM_ALLOC_SUCC;
- pack->pbase_addr = p_addr;
- NSFW_LOGINF
- ("alloc mem suc!]addr=%p,type=%u,mem_count=%d,item=%d,name=%s",
- p_addr, mem_msg->usmsg_type, mem_count, i,
- ((nsfw_shmem_reserv_req *) pdata)->aname);
- pack++;
+ pack->cstate = NSFW_MEM_ALLOC_SUCC;
+ pack->pbase_addr = p_addr;
+ NSFW_LOGINF("alloc suc]addr=%p,type=%u,mem_count=%d,item=%d,name=%s",
+ p_addr, mem_msg->usmsg_type, mem_count, i,
+ ((nsfw_shmem_reserv_req *) pdata)->aname);
+ pack++;
}
- return p_addr;
+ return p_addr;
-fail_free_mem:
- for (j = 0; j < i; j++)
+ fail_free_mem:
+ for (j = 0; j < i; j++)
{
- pdata = (char *) mem_msg->aidata + j * item_cfg->item_size;
- if (EOK !=
- STRCPY_S (mem_free.stname.aname, NSFW_MEM_NAME_LENGTH,
- ((nsfw_shmem_reserv_req *) pdata)->aname))
+
+ pdata = (char *) mem_msg->aidata + j * item_cfg->item_size;
+ /*copy string should use strcpy_s */
+ if (EOK !=
+ strcpy_s(mem_free.stname.aname, NSFW_MEM_NAME_LENTH,
+ ((nsfw_shmem_reserv_req *) pdata)->aname))
{
- NSFW_LOGERR ("STRCPY_S failed]j=%d", j);
- continue;
+ NSFW_LOGERR("strcpy_s fail]j=%d", j);
+ continue;
}
- mem_free.ustype = item_cfg->mem_type;
- mem_free.stname.entype = NSFW_SHMEM;
- (void) mem_item_free (&mem_free);
- NSFW_LOGINF ("free mem]addr=%p,type=%u,mem_count=%d,item=%d,name=%s",
- p_addr, mem_msg->usmsg_type, mem_count, j,
- ((nsfw_shmem_reserv_req *) pdata)->aname);
- pack++;
+ mem_free.ustype = item_cfg->mem_type;
+ mem_free.stname.entype = NSFW_SHMEM;
+ (void) mem_item_free(&mem_free);
+ NSFW_LOGINF("free mem]addr=%p,type=%u,mem_count=%d,item=%d,name=%s",
+ p_addr, mem_msg->usmsg_type, mem_count, j,
+ ((nsfw_shmem_reserv_req *) pdata)->aname);
+ pack++;
}
- return NULL;
+ return NULL;
}
@@ -659,75 +580,75 @@ fail_free_mem:
* Calls :
* Called By :
*****************************************************************************/
-int
-mem_alloc_req_proc (nsfw_mgr_msg * msg)
+int mem_alloc_req_proc(nsfw_mgr_msg * msg)
{
- void *mem_addr = NULL;
-
- if (NULL == msg)
- {
- NSFW_LOGERR ("msg nul");
- return FALSE;
- }
-
- nsfw_shmem_msg_head *mem_msg = GET_USER_MSG (nsfw_shmem_msg_head, msg);
- nsfw_mgr_msg *rsp_msg = nsfw_mgr_rsp_msg_alloc (msg);
- if (NULL == rsp_msg)
- {
- NSFW_LOGERR ("alloc rsp msg failed]msg_type=%u", mem_msg->usmsg_type);
- return FALSE;
- }
-
- nsfw_shmem_msg_head *mem_rsp_msg =
- GET_USER_MSG (nsfw_shmem_msg_head, rsp_msg);
-
- if (!mem_init_rsp_msg (mem_msg, mem_rsp_msg))
- {
- NSFW_LOGERR ("init rsp msg failed]msg_type=%u", mem_msg->usmsg_type);
- nsfw_mgr_msg_free (rsp_msg);
- return FALSE;
- }
-
- switch (mem_msg->usmsg_type)
- {
- case NSFW_MEM_LOOKUP_REQ_MSG:
- if (!mem_lookup_mem_by_msg (mem_msg, mem_rsp_msg, msg->src_pid))
- {
- NSFW_LOGERR ("lookup mem msg failed]msg_type=%u",
- mem_msg->usmsg_type);
- goto sendrspmsg;
- }
- (void) mem_alloc_ps_info (msg->src_pid, msg->src_proc_type);
- break;
- case NSFW_RESERV_REQ_MSG:
- case NSFW_MBUF_REQ_MSG:
- case NSFW_SPPOOL_REQ_MSG:
- case NSFW_RING_REQ_MSG:
- mem_addr = mem_alloc_mem_by_msg (mem_msg, mem_rsp_msg);
- if (NULL == mem_addr)
- {
- NSFW_LOGERR ("alloc mem msg failed]msg_type=%u",
- mem_msg->usmsg_type);
- (void) mem_init_rsp_msg (mem_msg, mem_rsp_msg);
- goto sendrspmsg;
- }
- (void) mem_alloc_ps_info (msg->src_pid, msg->src_proc_type);
- break;
- case NSFW_RELEASE_REQ_MSG:
- if (!mem_rel_mem_by_msg (mem_msg, mem_rsp_msg, msg->src_pid))
- {
- NSFW_LOGERR ("rel mem msg failed]msg_type=%u", mem_msg->usmsg_type);
- goto sendrspmsg;
- }
- break;
- default:
- break;
- }
-
-sendrspmsg:
- (void) nsfw_mgr_send_msg (rsp_msg);
- nsfw_mgr_msg_free (rsp_msg);
- return TRUE;
+ void *mem_addr = NULL;
+
+ if (NULL == msg)
+ {
+ NSFW_LOGERR("msg nul");
+ return FALSE;
+ }
+
+ nsfw_shmem_msg_head *mem_msg = GET_USER_MSG(nsfw_shmem_msg_head, msg);
+ nsfw_mgr_msg *rsp_msg = nsfw_mgr_rsp_msg_alloc(msg);
+ if (NULL == rsp_msg)
+ {
+ NSFW_LOGERR("alloc rsp msg failed]msg_type=%u", mem_msg->usmsg_type);
+ return FALSE;
+ }
+
+ nsfw_shmem_msg_head *mem_rsp_msg =
+ GET_USER_MSG(nsfw_shmem_msg_head, rsp_msg);
+
+ if (!mem_init_rsp_msg(mem_msg, mem_rsp_msg))
+ {
+ NSFW_LOGERR("init rsp msg failed]msg_type=%u", mem_msg->usmsg_type);
+ nsfw_mgr_msg_free(rsp_msg);
+ return FALSE;
+ }
+
+ switch (mem_msg->usmsg_type)
+ {
+ case NSFW_MEM_LOOKUP_REQ_MSG:
+ if (!mem_lookup_mem_by_msg(mem_msg, mem_rsp_msg, msg->src_pid))
+ {
+ NSFW_LOGERR("lookup mem msg failed]msg_type=%u",
+ mem_msg->usmsg_type);
+ goto sendrspmsg;
+ }
+ (void) mem_alloc_ps_info(msg->src_pid, msg->src_proc_type);
+ break;
+ case NSFW_RESERV_REQ_MSG:
+ case NSFW_MBUF_REQ_MSG:
+ case NSFW_SPPOOL_REQ_MSG:
+ case NSFW_RING_REQ_MSG:
+ mem_addr = mem_alloc_mem_by_msg(mem_msg, mem_rsp_msg);
+ if (NULL == mem_addr)
+ {
+ NSFW_LOGERR("alloc mem msg failed]msg_type=%u",
+ mem_msg->usmsg_type);
+ (void) mem_init_rsp_msg(mem_msg, mem_rsp_msg);
+ goto sendrspmsg;
+ }
+ (void) mem_alloc_ps_info(msg->src_pid, msg->src_proc_type);
+ break;
+ case NSFW_RELEASE_REQ_MSG:
+ if (!mem_rel_mem_by_msg(mem_msg, mem_rsp_msg, msg->src_pid))
+ {
+ NSFW_LOGERR("rel mem msg failed]msg_type=%u",
+ mem_msg->usmsg_type);
+ goto sendrspmsg;
+ }
+ break;
+ default:
+ break;
+ }
+
+ sendrspmsg:
+ (void) nsfw_mgr_send_msg(rsp_msg);
+ nsfw_mgr_msg_free(rsp_msg);
+ return TRUE;
}
/*****************************************************************************
@@ -740,47 +661,64 @@ sendrspmsg:
* Calls :
* Called By :
*****************************************************************************/
-int
-mem_ps_exiting_resend (void *pps_info, void *argv)
+int mem_ps_exiting_resend(void *pps_info, void *argv)
{
- u32 *count = argv;
- nsfw_ps_info *ps_info = pps_info;
- if (NULL == ps_info)
+ u32 *count = argv;
+ nsfw_ps_info *ps_info = pps_info;
+ if (NULL == ps_info)
{
- NSFW_LOGERR ("ps_info nul!");
- return FALSE;
+ NSFW_LOGERR("ps_info nul!");
+ return FALSE;
}
- if (NSFW_PROC_APP != ps_info->proc_type)
+ if (NSFW_PROC_APP != ps_info->proc_type)
{
- return FALSE;
+ return FALSE;
}
- if (NSFW_PS_EXITING != ps_info->state)
+ if (NSFW_PS_EXITING != ps_info->state)
{
- return FALSE;
+ return FALSE;
}
- if (NULL != count)
+ if (NULL != count)
{
- NSFW_LOGINF ("send count]count=%u,pid=%u", *count, ps_info->host_pid);
- if (NSFW_PS_SEND_PER_TIME < (*count)++)
+ NSFW_LOGINF("send count]count=%u,pid=%u", *count, ps_info->host_pid);
+ if (NSFW_PS_SEND_PER_TIME < (*count)++)
{
- struct timespec time_left =
- { NSFW_PS_MEM_RESEND_TVLAUE +
+ struct timespec time_left =
+ { NSFW_PS_MEM_RESEND_TVLAUE +
((*count) / NSFW_PS_SEND_PER_TIME), 0
- };
- ps_info->resend_timer_ptr =
- (void *) nsfw_timer_reg_timer (NSFW_PS_MEM_RESEND_TIMER,
- pps_info,
- nsfw_mem_ps_exit_resend_timeout,
- time_left);
- return TRUE;
+ };
+ ps_info->resend_timer_ptr =
+ (void *) nsfw_timer_reg_timer(NSFW_PS_MEM_RESEND_TIMER,
+ pps_info,
+ nsfw_mem_ps_exit_resend_timeout,
+ time_left);
+ return TRUE;
}
}
- (void) mem_ps_exiting (ps_info, NULL);
- return TRUE;
+ (void) mem_ps_exiting(ps_info, NULL);
+ return TRUE;
+}
+
+/*****************************************************************************
+* Prototype : mem_ps_exiting
+* Description : Send exiting message when a single ps_info is exiting.
+* If there have been more than NSFW_PS_SEND_PER_TIME apps
+* in EXITING state, register a resend timer.
+* Input : void *pps_info
+* void* argv
+* Output : None
+* Return Value : int
+* Calls :
+* Called By : See NSFW_PS_EXITING msg
+*****************************************************************************/
+int mem_ps_exiting_send(void *pps_info, void *argv)
+{
+ u32 count = get_ps_exiting_cnt();
+ return mem_ps_exiting_resend(pps_info, (void *) &count);
}
/*****************************************************************************
@@ -793,18 +731,17 @@ mem_ps_exiting_resend (void *pps_info, void *argv)
* Calls :
* Called By :
*****************************************************************************/
-int
-nsfw_mem_srv_restore_timeout (u32 timer_type, void *data)
+int nsfw_mem_srv_restore_timeout(u32 timer_type, void *data)
{
- u32 max_count = 0;
+ u32 max_count = 0;
- g_mem_cfg.p_restore_timer = NULL;
- if (TRUE == NSFW_SRV_STATE_SUSPEND)
+ g_mem_cfg.p_restore_timer = NULL;
+ if (TRUE == NSFW_SRV_STATE_SUSPEND)
{
- NSFW_SRV_STATE_SUSPEND = FALSE;
- (void) nsfw_ps_iterator (mem_ps_exiting_resend, &max_count);
+ NSFW_SRV_STATE_SUSPEND = FALSE;
+ (void) nsfw_ps_iterator(mem_ps_exiting_resend, &max_count);
}
- return TRUE;
+ return TRUE;
}
/*****************************************************************************
@@ -816,105 +753,100 @@ nsfw_mem_srv_restore_timeout (u32 timer_type, void *data)
* Calls :
* Called By :
*****************************************************************************/
-int
-mem_srv_ctrl_proc (nsfw_mgr_msg * msg)
+int mem_srv_ctrl_proc(nsfw_mgr_msg * msg)
{
- if (NULL == msg)
+ if (NULL == msg)
{
- NSFW_LOGERR ("msg nul");
- return FALSE;
+ NSFW_LOGERR("msg nul");
+ return FALSE;
}
- nsfw_srv_ctrl_msg *ctrl_msg = GET_USER_MSG (nsfw_srv_ctrl_msg, msg);
- nsfw_mgr_msg *rsp_msg = nsfw_mgr_rsp_msg_alloc (msg);
- if (NULL == rsp_msg)
+ nsfw_srv_ctrl_msg *ctrl_msg = GET_USER_MSG(nsfw_srv_ctrl_msg, msg);
+ nsfw_mgr_msg *rsp_msg = nsfw_mgr_rsp_msg_alloc(msg);
+ if (NULL == rsp_msg)
{
- NSFW_LOGERR ("alloc rsp msg failed]msg=%p", msg);
- return FALSE;
+ NSFW_LOGERR("alloc rsp msg failed]msg=%p", msg);
+ return FALSE;
}
- nsfw_srv_ctrl_msg *ctrl_rsp_msg = GET_USER_MSG (nsfw_srv_ctrl_msg, rsp_msg);
- NSFW_LOGINF ("get srv ctrl state] state=%d", ctrl_msg->srv_state);
+ nsfw_srv_ctrl_msg *ctrl_rsp_msg =
+ GET_USER_MSG(nsfw_srv_ctrl_msg, rsp_msg);
+ NSFW_LOGINF("get srv ctrl state] state=%d", ctrl_msg->srv_state);
- ctrl_rsp_msg->rsp_code = NSFW_MGR_SUCCESS;
+ ctrl_rsp_msg->rsp_code = NSFW_MGR_SUCESS;
- (void) nsfw_mgr_send_msg (rsp_msg);
- nsfw_mgr_msg_free (rsp_msg);
+ (void) nsfw_mgr_send_msg(rsp_msg);
+ nsfw_mgr_msg_free(rsp_msg);
- if (NSFW_SRV_CTRL_RESUME == ctrl_msg->srv_state)
+ if (NSFW_SRV_CTRL_RESUME == ctrl_msg->srv_state)
{
- if (TRUE == NSFW_SRV_STATE_SUSPEND)
+ if (TRUE == NSFW_SRV_STATE_SUSPEND)
{
- NSFW_SRV_STATE_SUSPEND = FALSE;
+ NSFW_SRV_STATE_SUSPEND = FALSE;
}
- u32 max_count = 0;
- (void) nsfw_ps_iterator (mem_ps_exiting_resend, &max_count);
- if (NULL != g_mem_cfg.p_restore_timer)
+ u32 max_count = 0;
+ (void) nsfw_ps_iterator(mem_ps_exiting_resend, &max_count);
+ if (NULL != g_mem_cfg.p_restore_timer)
{
- nsfw_timer_rmv_timer ((nsfw_timer_info *)
- g_mem_cfg.p_restore_timer);
- g_mem_cfg.p_restore_timer = NULL;
+ nsfw_timer_rmv_timer((nsfw_timer_info *)
+ g_mem_cfg.p_restore_timer);
+ g_mem_cfg.p_restore_timer = NULL;
}
}
- else
+ else
{
- NSFW_SRV_STATE_SUSPEND = TRUE;
- struct timespec time_left = { NSFW_SRV_RESTORE_TVALUE, 0 };
- g_mem_cfg.p_restore_timer =
- (void *) nsfw_timer_reg_timer (0, NULL,
- nsfw_mem_srv_restore_timeout,
- time_left);
+ NSFW_SRV_STATE_SUSPEND = TRUE;
+ struct timespec time_left = { NSFW_SRV_RESTORE_TVALUE, 0 };
+ g_mem_cfg.p_restore_timer =
+ (void *) nsfw_timer_reg_timer(0, NULL,
+ nsfw_mem_srv_restore_timeout,
+ time_left);
}
- return TRUE;
+ return TRUE;
}
-/*****************************************************************************
-* Prototype : nsfw_ps_mem_module_init
-* Description : module init
-* Input : void* param
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*****************************************************************************/
-int
-nsfw_ps_mem_module_init (void *param)
+int nsfw_ps_mem_module_init(void *param)
{
- u32 proc_type = (u32) ((long long) param);
- NSFW_LOGINF ("ps_mem module init]type=%u", proc_type);
- switch (proc_type)
- {
- case NSFW_PROC_MAIN:
- (void) nsfw_ps_reg_global_fun (NSFW_PROC_APP, NSFW_PS_EXITING,
- mem_ps_exiting, NULL);
- (void) nsfw_mgr_reg_msg_fun (MGR_MSG_MEM_ALLOC_REQ, mem_alloc_req_proc);
- (void) NSFW_REG_SOFT_INT (NSFW_SRV_RESTORE_TIMER,
- NSFW_SRV_RESTORE_TVALUE, 1, 0xFFFF);
- (void) NSFW_REG_SOFT_INT (NSFW_APP_RESEND_TIMER,
- NSFW_PS_MEM_RESEND_TVLAUE, 1, 0xFFFF);
- (void) NSFW_REG_SOFT_INT (NSFW_APP_SEND_PER_TIME,
- NSFW_PS_SEND_PER_TIME, 1, 0xFFFF);
- break;
- default:
- if (proc_type < NSFW_PROC_MAX)
- {
- return 0;
- }
- return -1;
- }
-
- g_mem_cfg.srv_restore_tvalue = NSFW_SRV_RESTORE_TVALUE_DEF;
- g_mem_cfg.ps_exit_resend_tvalue = NSFW_PS_MEM_RESEND_TVLAUE_DEF;
- g_mem_cfg.ps_send_per_time = NSFW_PS_SEND_PER_TIME_DEF;
-
- return 0;
+ u32 proc_type = (u32) ((long long) param);
+ NSFW_LOGINF("ps_mem module init]type=%u", proc_type);
+ switch (proc_type)
+ {
+ case NSFW_PROC_MASTER:
+ (void) nsfw_ps_reg_global_fun(NSFW_PROC_APP, NSFW_PS_EXITING,
+ mem_ps_exiting_send, NULL);
+ (void) nsfw_mgr_reg_msg_fun(MGR_MSG_MEM_ALLOC_REQ,
+ mem_alloc_req_proc);
+ (void) nsfw_mgr_reg_msg_fun(MGR_MSG_SRV_CTL_REQ,
+ mem_srv_ctrl_proc);
+ (void) NSFW_REG_SOFT_INT(NSFW_SRV_RESTORE_TIMER,
+ NSFW_SRV_RESTORE_TVALUE, 1, 0xFFFF);
+ (void) NSFW_REG_SOFT_INT(NSFW_APP_RESEND_TIMER,
+ NSFW_PS_MEM_RESEND_TVLAUE, 1, 0xFFFF);
+ (void) NSFW_REG_SOFT_INT(NSFW_APP_SEND_PER_TIME,
+ NSFW_PS_SEND_PER_TIME, 1, 0xFFFF);
+ break;
+ default:
+ if (proc_type < NSFW_PROC_MAX)
+ {
+ return 0;
+ }
+ return -1;
+ }
+
+ g_mem_cfg.srv_restore_tvalue = NSFW_SRV_RESTORE_TVALUE_DEF;
+ g_mem_cfg.ps_exit_resend_tvalue = NSFW_PS_MEM_RESEND_TVLAUE_DEF;
+ g_mem_cfg.ps_send_per_time = NSFW_PS_SEND_PER_TIME_DEF;
+ g_mem_cfg.srv_suspend = 0;
+ g_mem_cfg.p_restore_timer = NULL;
+
+ return 0;
}
/* *INDENT-OFF* */
-NSFW_MODULE_NAME (NSFW_PS_MEM_MODULE)
-NSFW_MODULE_PRIORITY (10)
-NSFW_MODULE_DEPENDS (NSFW_PS_MODULE)
-NSFW_MODULE_INIT (nsfw_ps_mem_module_init)
+NSFW_MODULE_NAME(NSFW_PS_MEM_MODULE)
+NSFW_MODULE_PRIORITY(10)
+NSFW_MODULE_DEPENDS(NSFW_PS_MODULE)
+NSFW_MODULE_INIT(nsfw_ps_mem_module_init)
/* *INDENT-ON* */
#ifdef __cplusplus
diff --git a/src/framework/ipc/ps/nsfw_ps_mem_module.h b/src/framework/ipc/ps/nsfw_ps_mem_module.h
index 6b2b3c9..337b578 100644
--- a/src/framework/ipc/ps/nsfw_ps_mem_module.h
+++ b/src/framework/ipc/ps/nsfw_ps_mem_module.h
@@ -19,6 +19,7 @@
#include "list.h"
#include "pidinfo.h"
+#include "nsfw_mem_api.h"
#ifdef __cplusplus
/* *INDENT-OFF* */
@@ -42,18 +43,18 @@ extern "C"{
typedef struct _ns_mem_mng_init_cfg
{
- u16 srv_restore_tvalue;
- u16 ps_exit_resend_tvalue;
- u16 ps_send_per_time;
- u16 srv_suspend;
- void *p_restore_timer;
+ u16 srv_restore_tvalue;
+ u16 ps_exit_resend_tvalue;
+ u16 ps_send_per_time;
+ u16 srv_suspend;
+ void *p_restore_timer;
} ns_mem_mng_init_cfg;
/*mem alloc by msg begin*/
typedef struct
{
- nsfw_mem_name stname;
- u16 ustype;
+ nsfw_mem_name stname;
+ u16 ustype;
} nsfw_mem_type_info;
#define NSFW_MEM_CALL_ARG_BUF 256
@@ -61,22 +62,22 @@ typedef struct
((_dst_type*)(void*)_dst_buf)->_dst_member = ((_srctype*)(void*)_src_buf)->_src_member
typedef void *(*nsfw_ps_mem_create_fun) (void *memstr);
-typedef u8 (*nsfw_ps_mem_msg_to_memstr) (u16 msg_type, char *msg_body,
- char *memstr_buf, i32 buf_len);
+typedef u8(*nsfw_ps_mem_msg_to_memstr) (u16 msg_type, char *msg_body,
+ char *memstr_buf, i32 buf_len);
typedef struct __nsfw_ps_mem_item_cfg
{
- u16 usmsg_type;
- u16 item_size;
- u16 mem_type;
- nsfw_ps_mem_create_fun create_fun;
- nsfw_ps_mem_msg_to_memstr change_fun;
+ u16 usmsg_type;
+ u16 item_size;
+ u16 mem_type;
+ nsfw_ps_mem_create_fun create_fun;
+ nsfw_ps_mem_msg_to_memstr change_fun;
} nsfw_ps_mem_item_cfg;
-void *mem_item_free (void *pdata);
-void *mem_item_lookup (void *pdata);
-u8 mem_item_get_callargv (u16 msg_type, char *msg_body, char *memstr_buf,
- i32 buf_len);
+void *mem_item_free(void *pdata);
+void *mem_item_lookup(void *pdata);
+u8 mem_item_get_callargv(u16 msg_type, char *msg_body, char *memstr_buf,
+ i32 buf_len);
#ifdef __cplusplus
/* *INDENT-OFF* */
diff --git a/src/framework/ipc/ps/nsfw_ps_module.c b/src/framework/ipc/ps/nsfw_ps_module.c
index 6e03e11..6d11c5f 100644
--- a/src/framework/ipc/ps/nsfw_ps_module.c
+++ b/src/framework/ipc/ps/nsfw_ps_module.c
@@ -17,9 +17,11 @@
#include <stdlib.h>
#include "types.h"
#include "nstack_securec.h"
-#include "nsfw_init.h"
+#include "nsfw_init_api.h"
#include "nsfw_mgr_com_api.h"
+#include "mgr_com.h"
+#include "nsfw_alarm_api.h"
#include "nsfw_ps_api.h"
#include "nsfw_ps_module.h"
#include "nsfw_mem_api.h"
@@ -39,7 +41,6 @@
#include <linux/netlink.h>
#include <dirent.h>
#include <fnmatch.h>
-#include "common_mem_common.h"
#ifdef __cplusplus
/* *INDENT-OFF* */
@@ -57,8 +58,454 @@ struct list_head g_ps_runing_list;
nsfw_ps_callback g_ps_init_callback[NSFW_PROC_MAX][NSFW_PS_MAX_CALLBACK];
nsfw_ps_info g_main_ps_info;
+extern nsfw_mgr_init_cfg g_mgr_com_cfg;
+
void *g_ps_chk_timer = NULL;
+/* keep count of processes being in EXITING state */
+u32 g_ps_exiting_cnt = 0;
+NSTACK_STATIC void inc_ps_exiting_cnt();
+NSTACK_STATIC void dec_ps_exiting_cnt();
+
+typedef struct _omc_alarm_status
+{
+ char send_succ_flag;
+ alarm_flag current_alarm_state;
+ nsfw_timer_info *resend_timer;
+} omc_alarm_stat;
+
+#define SCRIPT_NS_CTL_SND_NSMAIN_NOR_ALM "./nStackCtrl --module alm -n nsMain -t normal"
+#define SCRIPT_NS_CTL_SND_NSMAIN_ABNOR_ALM "./nStackCtrl --module alm -n nsMain -t abnormal"
+#define SCRIPT_NS_CTL_SND_NSMAIN_START "./nStackCtrl --module alm -n nsMain -t normalStart"
+#define SCRIPT_NS_CTL_SND_NSMAIN_EXIT "./nStackCtrl --module alm -n nsMain -t abnormalExit"
+
+#define MASTER_RESEND_NSMAIN_TIMER 1
+
+omc_alarm_stat g_omc_alm_state[ALARM_EVENT_MAX];
+
+typedef struct _omc_hf_alarm_status
+{
+ nsfw_timer_info *resend_timer;
+ hotfix_res res;
+} omc_hf_alarm_stat;
+omc_hf_alarm_stat g_omc_hf_alm_state;
+#define MASTER_RESEND_HOTFIX_TIMER 1
+
+const char *omc_get_nstackctrl_alarm_string(enum_alarm_id alarm_id,
+ alarm_flag alarm_state)
+{
+ const char *alarm_script = NULL;
+
+ switch (alarm_id)
+ {
+ case ALARM_EVENT_NSTACK_MAIN_ABNORMAL_RESTART_FAIL:
+
+ if (ALARM_PRODUCT == alarm_state)
+ {
+ alarm_script = SCRIPT_NS_CTL_SND_NSMAIN_ABNOR_ALM;
+ }
+ else
+ {
+ alarm_script = SCRIPT_NS_CTL_SND_NSMAIN_NOR_ALM;
+ }
+
+ break;
+ case ALARM_EVENT_NSTACK_MAIN_EXIT_CAUSE_FD_FAIL:
+
+ if (ALARM_PRODUCT == alarm_state)
+ {
+ alarm_script = SCRIPT_NS_CTL_SND_NSMAIN_EXIT;
+ }
+ else
+ {
+ alarm_script = SCRIPT_NS_CTL_SND_NSMAIN_START;
+ }
+
+ break;
+ default:
+ NSAM_LOGERR("alarm_id is invalid");
+ break;
+ }
+
+ return alarm_script;
+
+}
+
+/* should send restore alarm when daemon-stack restart successfully*/
+int omc_resend_nsmain_alarm(u32 timer_type, void *argv)
+{
+#define TMP_RESULT_BUF_LEN 128
+
+ int retval;
+ char result[TMP_RESULT_BUF_LEN] = { 0 };
+ int rt_len;
+ const char *alarm_script = NULL;
+ enum_alarm_id tmp_alarm_id = (enum_alarm_id) argv;
+ omc_alarm_stat *tmp_alarm_stat = NULL;
+
+ if (ALARM_ID_NOT_VALID(tmp_alarm_id))
+ {
+ NSAM_LOGERR("alarm_id is invalid");
+ return 0;
+ }
+
+ tmp_alarm_stat = &g_omc_alm_state[tmp_alarm_id];
+
+ /* when timeout, need clear */
+ tmp_alarm_stat->resend_timer = NULL;
+
+ alarm_script =
+ omc_get_nstackctrl_alarm_string(tmp_alarm_id,
+ tmp_alarm_stat->current_alarm_state);
+
+ if (NULL == alarm_script)
+ {
+ NSAM_LOGERR("get alarm_script fail");
+ return 0;
+ }
+
+ if (0 != tmp_alarm_stat->send_succ_flag)
+ {
+ rt_len =
+ nsfw_mgr_run_script(alarm_script, result, TMP_RESULT_BUF_LEN);
+ if (0 == rt_len || -1 == rt_len || (!nsfw_isdigitstr(result))) //also check return -1
+ {
+ retval = -1;
+ }
+ else
+ {
+ retval = atoi(result);
+ }
+ tmp_alarm_stat->send_succ_flag = retval;
+
+ if (0 == tmp_alarm_stat->send_succ_flag)
+ {
+ NSAM_LOGINF("send alarm success]alarm_id=%u,alarm_status=%u",
+ tmp_alarm_id + ALARM_ID_BASE_VALUE,
+ tmp_alarm_stat->current_alarm_state);
+ }
+ else
+ {
+ NSAM_LOGINF("send alarm fail]alarm_id=%u,alarm_status=%u",
+ tmp_alarm_id + ALARM_ID_BASE_VALUE,
+ tmp_alarm_stat->current_alarm_state);
+ /* only when send fail, start resend timer */
+ struct timespec alarm_resend_time =
+ { ALARM_RESEND_TIMER_LENGTH, 0 };
+ tmp_alarm_stat->resend_timer =
+ nsfw_timer_reg_timer(MASTER_RESEND_NSMAIN_TIMER,
+ (void *) tmp_alarm_id,
+ omc_resend_nsmain_alarm,
+ alarm_resend_time);
+ if (NULL == tmp_alarm_stat->resend_timer)
+ {
+ NSFW_LOGERR("start alarm resend timer fail");
+ }
+ }
+
+ }
+
+ return 0;
+
+}
+
+/*****************************************************************************
+* Prototype : omc_remove_resend_timer_inner
+* Description : remove alarm resend timer if exist
+* Input : None
+* Output : None
+* Return Value : None
+* Calls :
+* Called By : omc_send_nsmain_alarm_inner
+*****************************************************************************/
+NSTACK_STATIC void omc_remove_resend_timer_inner(enum_alarm_id alarm_id)
+{
+ omc_alarm_stat *tmp_alarm_stat = NULL;
+ if (ALARM_ID_NOT_VALID(alarm_id))
+ {
+ NSAM_LOGERR("alarm_id is invalid");
+ return;
+ }
+
+ tmp_alarm_stat = &g_omc_alm_state[alarm_id];
+
+ if (NULL == tmp_alarm_stat->resend_timer)
+ {
+ return;
+ }
+
+ nsfw_timer_rmv_timer(tmp_alarm_stat->resend_timer);
+ tmp_alarm_stat->resend_timer = NULL;
+
+}
+
+/*****************************************************************************
+* Prototype : omc_send_nsmain_alarm_inner
+* Description : omc_send_nsmain_alarm_inner process function
+* Input : init_status_flag ; alarm_flag alm_flag
+* Output : None
+* Return Value : int
+* Calls :
+* Called By :
+*****************************************************************************/
+void omc_send_nsmain_alarm_inner(char init_status_flag,
+ enum_alarm_id alarm_id, alarm_flag alm_flag)
+{
+#define TMP_RESULT_BUF_LEN 128
+ int retval;
+ char result[TMP_RESULT_BUF_LEN] = { 0 };
+ int rt_len;
+ omc_alarm_stat *tmp_alarm_stat = NULL;
+
+ const char *alarm_script = NULL;
+
+ if (ALARM_ID_NOT_VALID(alarm_id))
+ {
+ NSAM_LOGDBG("alarm_id is invalid");
+ return;
+ }
+
+ tmp_alarm_stat = &g_omc_alm_state[alarm_id];
+
+ if (1 != init_status_flag)
+ {
+ /* only for alarm status change, can send alarm */
+ if (alm_flag == tmp_alarm_stat->current_alarm_state)
+ {
+ NSAM_LOGDBG("same status, can't send alarm");
+ return;
+ }
+ }
+ else
+ {
+ /* init alarm, use current alarm state stored */
+ alm_flag = tmp_alarm_stat->current_alarm_state;
+ }
+
+ alarm_script = omc_get_nstackctrl_alarm_string(alarm_id, alm_flag);
+
+ if (NULL == alarm_script)
+ {
+ NSAM_LOGERR("get alarm_script fail");
+ return;
+ }
+
+ rt_len = nsfw_mgr_run_script(alarm_script, result, TMP_RESULT_BUF_LEN);
+
+ if (0 == rt_len || -1 == rt_len || (!nsfw_isdigitstr(result)))
+ {
+ retval = -1;
+ }
+ else
+ {
+ retval = atoi(result);
+ }
+ tmp_alarm_stat->current_alarm_state = alm_flag;
+ tmp_alarm_stat->send_succ_flag = retval;
+
+ if (0 == tmp_alarm_stat->send_succ_flag)
+ {
+ NSAM_LOGINF("send alarm success]alarm_id=%d,alarm_status=%d",
+ alarm_id + ALARM_ID_BASE_VALUE,
+ tmp_alarm_stat->current_alarm_state);
+
+ /* when send success, then stop resend timer */
+ omc_remove_resend_timer_inner(alarm_id);
+ }
+ else
+ {
+ NSAM_LOGINF("send alarm fail]alarm_id=%d,alarm_status=%d",
+ alarm_id + ALARM_ID_BASE_VALUE,
+ tmp_alarm_stat->current_alarm_state);
+ struct timespec alarm_resend_time = { ALARM_RESEND_TIMER_LENGTH, 0 };
+
+ /* should clear the old timer before register a new one */
+ omc_remove_resend_timer_inner(alarm_id);
+
+ /* only start resend time when send failed */
+ tmp_alarm_stat->resend_timer =
+ nsfw_timer_reg_timer(MASTER_RESEND_NSMAIN_TIMER,
+ (void *) (alarm_id),
+ omc_resend_nsmain_alarm, alarm_resend_time);
+ if (NULL == tmp_alarm_stat->resend_timer)
+ {
+ NSFW_LOGERR("start alarm resend timer fail");
+ }
+ }
+
+}
+
+void omc_send_init_nsmain_alarm(enum_alarm_id alarm_id)
+{
+ omc_send_nsmain_alarm_inner(1, alarm_id, ALARM_CLEAN);
+}
+
+void omc_send_nsmain_alarm(enum_alarm_id alarm_id, alarm_flag alm_flag)
+{
+ omc_send_nsmain_alarm_inner(0, alarm_id, alm_flag);
+}
+
+/*****************************************************************************
+* Prototype : omc_remove_hf_resend_timer_inner
+* Description : remove hotfix alarm resend timer if exist
+* Input : None
+* Output : None
+* Return Value : None
+* Calls :
+* Called By : omc_send_nsmain_alarm_inner
+*****************************************************************************/
+NSTACK_STATIC void omc_remove_hf_resend_timer_inner()
+{
+ if (NULL != g_omc_hf_alm_state.resend_timer)
+ {
+ nsfw_timer_rmv_timer(g_omc_hf_alm_state.resend_timer);
+ g_omc_hf_alm_state.resend_timer = NULL;
+ }
+}
+
+/*****************************************************************************
+* Prototype : omc_send_hotfix_alarm_inner
+* Description :
+* Input : void
+* Output : None
+* Return Value : int
+* Calls :
+* Called By :
+*****************************************************************************/
+int omc_send_hotfix_alarm_inner()
+{
+ int retval;
+ int rt_len;
+ char alarm_script[512] = { 0 };
+ char res_buffer[128] = { 0 };
+
+ retval = sprintf_s(alarm_script, sizeof(alarm_script),
+ "./nStackCtrl --module alm -n hotfix -a %d -r %d -v\"%s\" -p %d",
+ g_omc_hf_alm_state.res.action,
+ g_omc_hf_alm_state.res.result,
+ g_omc_hf_alm_state.res.patch_version,
+ g_omc_hf_alm_state.res.proc_type);
+ if (-1 == retval)
+ {
+ NSAM_LOGERR("sprintf_s fail]ret=%d", retval);
+ return -1;
+ }
+
+ rt_len =
+ nsfw_mgr_run_script(alarm_script, res_buffer, sizeof(res_buffer));
+ if (0 == rt_len || -1 == rt_len || (!nsfw_isdigitstr(res_buffer)))
+ {
+ retval = -1;
+ }
+ else
+ {
+ retval = atoi(res_buffer);
+ }
+
+ if (0 == retval)
+ {
+ NSAM_LOGINF("send hotfix alarm success]alarm_id=4");
+ /* when send success, then stop resend timer */
+ omc_remove_hf_resend_timer_inner();
+ }
+ else
+ {
+ NSAM_LOGINF("send hotfix alarm fail]alarm_id=4");
+ /* should clear the old timer before register a new one */
+ omc_remove_hf_resend_timer_inner();
+
+ struct timespec alarm_resend_time = { ALARM_RESEND_TIMER_LENGTH, 0 };
+ /* only start resend time when send failed */
+ g_omc_hf_alm_state.resend_timer =
+ nsfw_timer_reg_timer(MASTER_RESEND_HOTFIX_TIMER, NULL,
+ omc_send_hotfix_alarm_inner,
+ alarm_resend_time);
+ if (NULL == g_omc_hf_alm_state.resend_timer)
+ {
+ NSFW_LOGERR("start hotfix alarm resend timer fail");
+ }
+ }
+
+ return 0;
+
+}
+
+/*****************************************************************************
+* Prototype : omc_send_hotfix_alarm
+* Description : called by hotfix module
+* Input : void
+* Output : None
+* Return Value : void
+* Calls :
+* Called By :
+*****************************************************************************/
+void omc_send_hotfix_alarm(int proc_type, int action, int result,
+ const char *version)
+{
+ g_omc_hf_alm_state.res.proc_type = (fw_poc_type) proc_type;
+ g_omc_hf_alm_state.res.action = (hotfix_optype) action;
+ g_omc_hf_alm_state.res.result = result;
+ int ret = strcpy_s(g_omc_hf_alm_state.res.patch_version,
+ sizeof(g_omc_hf_alm_state.res.patch_version),
+ version);
+ if (EOK != ret)
+ {
+ NSFW_LOGERR("strcpy_s failed]ret=%d", ret);
+ }
+
+ (void) omc_send_hotfix_alarm_inner();
+}
+
+/* API for another module to get the global */
+u32 get_ps_exiting_cnt()
+{
+ return g_ps_exiting_cnt;
+}
+
+/*****************************************************************************
+* Prototype : inc_ps_exiting_cnt
+* Description : g_ps_exiting_cnt++
+* Input : None
+* Output : None
+* Return Value : None
+* Calls :
+* Called By : nsfw_sw_ps_state( ,NSFW_PS_EXITING) ONLY!
+*****************************************************************************/
+NSTACK_STATIC void inc_ps_exiting_cnt()
+{
+ if (g_ps_exiting_cnt < NSFW_MAX_PID)
+ {
+ g_ps_exiting_cnt++;
+ }
+ else
+ {
+ NSFW_LOGERR("g_ps_exiting_cnt would exceed NSFW_MAX_PID! now is %u",
+ g_ps_exiting_cnt);
+ }
+}
+
+/*****************************************************************************
+* Prototype : dec_ps_exiting_cnt
+* Description : g_ps_exiting_cnt--
+* Input : None
+* Output : None
+* Return Value : None
+* Calls :
+* Called By : nsfw_sw_ps_state( ,NSFW_PS_EXIT) ONLY!
+*****************************************************************************/
+NSTACK_STATIC void dec_ps_exiting_cnt()
+{
+ if (g_ps_exiting_cnt > 0)
+ {
+ g_ps_exiting_cnt--;
+ }
+ else
+ {
+ NSFW_LOGERR("g_ps_exiting_cnt would drop below zero! now is %u",
+ g_ps_exiting_cnt);
+ }
+}
+
/*****************************************************************************
* Prototype : nsfw_ps_reg_fun
* Description : reg the callback fun when process state change
@@ -71,34 +518,33 @@ void *g_ps_chk_timer = NULL;
* Calls :
* Called By :
*****************************************************************************/
-u8
-nsfw_ps_reg_fun (nsfw_ps_info * pps_info, u8 ps_state,
- nsfw_ps_proc_fun fun, void *argv)
+u8 nsfw_ps_reg_fun(nsfw_ps_info * pps_info, u8 ps_state,
+ nsfw_ps_proc_fun fun, void *argv)
{
- if (NULL == pps_info)
+ if (NULL == pps_info)
{
- NSFW_LOGERR ("reg pps_info nul]state=%d,fun=%p", ps_state, fun);
- return FALSE;
+ NSFW_LOGERR("reg pps_info nul]state=%d,fun=%p", ps_state, fun);
+ return FALSE;
}
- u32 i;
- for (i = 0; i < NSFW_PS_MAX_CALLBACK; i++)
+ u32 i;
+ for (i = 0; i < NSFW_PS_MAX_CALLBACK; i++)
{
- if (NULL == pps_info->callback[i].fun)
+ if (NULL == pps_info->callback[i].fun)
{
- pps_info->callback[i].fun = fun;
- pps_info->callback[i].argv = argv;
- pps_info->callback[i].state = ps_state;
- NSFW_LOGDBG
- ("reg fun suc]ps_info=%p,state=%d,fun=%p,argv=%p,i=%d",
- pps_info, ps_state, fun, argv, i);
- return TRUE;
+ pps_info->callback[i].fun = fun;
+ pps_info->callback[i].argv = argv;
+ pps_info->callback[i].state = ps_state;
+ NSFW_LOGDBG
+ ("reg fun suc]ps_info=%p,state=%d,fun=%p,argv=%p,i=%u",
+ pps_info, ps_state, fun, argv, i);
+ return TRUE;
}
}
- NSFW_LOGERR ("reg fun failed]ps_info=%p,state=%d,fun=%p,argv=%p,i=%d",
- pps_info, ps_state, fun, argv, i);
- return FALSE;
+ NSFW_LOGERR("reg fun failed]ps_info=%p,state=%d,fun=%p,argv=%p,i=%u",
+ pps_info, ps_state, fun, argv, i);
+ return FALSE;
}
/*****************************************************************************
@@ -114,35 +560,34 @@ nsfw_ps_reg_fun (nsfw_ps_info * pps_info, u8 ps_state,
* Calls :
* Called By :
*****************************************************************************/
-u8
-nsfw_ps_reg_global_fun (u8 proc_type, u8 ps_state, nsfw_ps_proc_fun fun,
- void *argv)
+u8 nsfw_ps_reg_global_fun(u8 proc_type, u8 ps_state, nsfw_ps_proc_fun fun,
+ void *argv)
{
- if (NSFW_PROC_MAX <= proc_type)
+ if (NSFW_PROC_MAX <= proc_type)
{
- NSFW_LOGERR ("proc_type err]state=%u,fun=%p,type=%u", ps_state, fun,
- proc_type);
- return FALSE;
+ NSFW_LOGERR("proc_type err]state=%u,fun=%p,type=%u", ps_state, fun,
+ proc_type);
+ return FALSE;
}
- nsfw_ps_callback *cb_fun = g_ps_init_callback[proc_type];
- u32 i;
- for (i = 0; i < NSFW_PS_MAX_CALLBACK; i++)
+ nsfw_ps_callback *cb_fun = g_ps_init_callback[proc_type];
+ u32 i;
+ for (i = 0; i < NSFW_PS_MAX_CALLBACK; i++)
{
- if (NULL == cb_fun[i].fun)
+ if (NULL == cb_fun[i].fun)
{
- cb_fun[i].fun = fun;
- cb_fun[i].argv = argv;
- cb_fun[i].state = ps_state;
- NSFW_LOGINF ("reg fun suc]type=%u,state=%u,fun=%p,argv=%p,i=%u",
- proc_type, ps_state, fun, argv, i);
- return TRUE;
+ cb_fun[i].fun = fun;
+ cb_fun[i].argv = argv;
+ cb_fun[i].state = ps_state;
+ NSFW_LOGINF("reg fun suc]type=%u,state=%u,fun=%p,argv=%p,i=%u",
+ proc_type, ps_state, fun, argv, i);
+ return TRUE;
}
}
- NSFW_LOGERR ("reg fun ful failed]type=%u,state=%u,fun=%p,argv=%p,i=%u",
- proc_type, ps_state, fun, argv, i);
- return FALSE;
+ NSFW_LOGERR("reg fun ful failed]type=%u,state=%u,fun=%p,argv=%p,i=%u",
+ proc_type, ps_state, fun, argv, i);
+ return FALSE;
}
/*****************************************************************************
@@ -155,28 +600,27 @@ nsfw_ps_reg_global_fun (u8 proc_type, u8 ps_state, nsfw_ps_proc_fun fun,
* Calls :
* Called By :
*****************************************************************************/
-int
-nsfw_ps_exit (nsfw_mgr_msg * msg)
+int nsfw_ps_exit(nsfw_mgr_msg * msg)
{
- nsfw_ps_info *pps_info;
- if (NULL == msg)
+ nsfw_ps_info *pps_info;
+ if (NULL == msg)
{
- NSFW_LOGERR ("msg nul!");
- return FALSE;
+ NSFW_LOGERR("msg nul!");
+ return FALSE;
}
- nsfw_ps_info_msg *ps_msg = GET_USER_MSG (nsfw_ps_info_msg, msg);
- pps_info = nsfw_ps_info_get (ps_msg->host_pid);
- NSFW_LOGINF ("recv ps exit]host_pid=%d,ps_info=%p", ps_msg->host_pid,
- pps_info);
+ nsfw_ps_info_msg *ps_msg = GET_USER_MSG(nsfw_ps_info_msg, msg);
+ pps_info = nsfw_ps_info_get(ps_msg->host_pid);
+ NSFW_LOGINF("recv ps exit]host_pid=%u,ps_info=%p", ps_msg->host_pid,
+ pps_info);
- if (NULL == pps_info)
+ if (NULL == pps_info)
{
- NSFW_LOGERR ("error msg pps_info nul]host_pid=%d", ps_msg->host_pid);
- return true;
+ NSFW_LOGERR("error msg pps_info nul]host_pid=%u", ps_msg->host_pid);
+ return true;
}
- (void) nsfw_sw_ps_state (pps_info, NSFW_PS_EXIT);
- return TRUE;
+ (void) nsfw_sw_ps_state(pps_info, NSFW_PS_EXIT);
+ return TRUE;
}
/*****************************************************************************
@@ -189,60 +633,60 @@ nsfw_ps_exit (nsfw_mgr_msg * msg)
* Calls :
* Called By :
*****************************************************************************/
-nsfw_ps_info *
-nsfw_ps_info_fork_alloc (u32 parent_pid, u32 child_pid)
+nsfw_ps_info *nsfw_ps_info_fork_alloc(u32 parent_pid, u32 child_pid)
{
- nsfw_ps_info *pps_info = NULL;
- nsfw_ps_info *pps_info_parent = NULL;
- pps_info_parent = nsfw_ps_info_get (parent_pid);
- if (NULL == pps_info_parent)
+ nsfw_ps_info *pps_info = NULL;
+ nsfw_ps_info *pps_info_parent = NULL;
+ pps_info_parent = nsfw_ps_info_get(parent_pid);
+ if (NULL == pps_info_parent)
{
- NSFW_LOGERR ("pps_info_parent nul");
- return NULL;
+ NSFW_LOGERR("pps_info_parent nul");
+ return NULL;
}
- pps_info = nsfw_ps_info_get (child_pid);
- if (NULL == pps_info)
+ pps_info = nsfw_ps_info_get(child_pid);
+ if (NULL == pps_info)
{
- pps_info = nsfw_ps_info_alloc (child_pid, pps_info_parent->proc_type);
- if (NULL == pps_info)
+ pps_info =
+ nsfw_ps_info_alloc(child_pid, pps_info_parent->proc_type, 0);
+ if (NULL == pps_info)
{
- NSFW_LOGERR
- ("alloc ps_info failed!]ps_info=%p,host_pid=%u,child_pid=%u",
- pps_info_parent, pps_info_parent->host_pid, child_pid);
- return NULL;
+ NSFW_LOGERR
+ ("alloc ps_info failed!]ps_info=%p,host_pid=%u,child_pid=%u",
+ pps_info_parent, pps_info_parent->host_pid, child_pid);
+ return NULL;
}
}
- else
+ else
{
- NSFW_LOGWAR
- ("fork alloc mem before!]ps_info=%p,host_pid=%u,child_pid=%u",
- pps_info_parent, pps_info_parent->host_pid, child_pid);
+ NSFW_LOGWAR
+ ("fork alloc mem before!]ps_info=%p,host_pid=%u,child_pid=%u",
+ pps_info_parent, pps_info_parent->host_pid, child_pid);
}
- NSFW_LOGWAR ("ps_info fork]ps_info=%p,host_pid=%u,child_pid=%u",
- pps_info_parent, pps_info_parent->host_pid, child_pid);
- pps_info->parent_pid = parent_pid;
- if (EOK !=
- MEMCPY_S (pps_info->callback, sizeof (pps_info->callback),
- pps_info_parent->callback,
- sizeof (pps_info_parent->callback)))
+ NSFW_LOGWAR("ps_info fork]ps_info=%p,host_pid=%u,child_pid=%u",
+ pps_info_parent, pps_info_parent->host_pid, child_pid);
+ pps_info->parent_pid = parent_pid;
+ if (EOK !=
+ memcpy_s(pps_info->callback, sizeof(pps_info->callback),
+ pps_info_parent->callback,
+ sizeof(pps_info_parent->callback)))
{
- nsfw_ps_info_free (pps_info);
- NSFW_LOGERR ("ps_info set_failed");
- return NULL;
+ nsfw_ps_info_free(pps_info);
+ NSFW_LOGERR("ps_info set_failed");
+ return NULL;
}
- if (EOK !=
- MEMCPY_S (pps_info->value, sizeof (pps_info->value),
- pps_info_parent->value, sizeof (pps_info_parent->value)))
+ if (EOK !=
+ memcpy_s(pps_info->value, sizeof(pps_info->value),
+ pps_info_parent->value, sizeof(pps_info_parent->value)))
{
- nsfw_ps_info_free (pps_info);
- NSFW_LOGERR ("ps_info cpy_failed");
- return NULL;
+ nsfw_ps_info_free(pps_info);
+ NSFW_LOGERR("ps_info cpy_failed");
+ return NULL;
}
- return pps_info;
+ return pps_info;
}
/*****************************************************************************
@@ -255,64 +699,71 @@ nsfw_ps_info_fork_alloc (u32 parent_pid, u32 child_pid)
* Calls :
* Called By :
*****************************************************************************/
-nsfw_ps_info *
-nsfw_ps_info_alloc (u32 pid, u8 proc_type)
+nsfw_ps_info *nsfw_ps_info_alloc(u32 pid, u8 proc_type, u8 realloc_flg)
{
- nsfw_ps_info *pps_info = NULL;
- if (0 == nsfw_mem_ring_dequeue (g_ps_cfg.ps_info_pool, (void *) &pps_info))
+ nsfw_ps_info *pps_info = NULL;
+ if (0 == nsfw_mem_ring_dequeue(g_ps_cfg.ps_info_pool, (void *) &pps_info))
{
- NSFW_LOGERR ("alloc ps_info failed]pid=%u,type=%u", pid, proc_type);
- return NULL;
+ NSFW_LOGERR("alloc ps_info falied]pid=%u,type=%u", pid, proc_type);
+ return NULL;
}
- if (NULL == pps_info)
+ if (NULL == pps_info)
{
- if (NSFW_PROC_MAIN != proc_type || TRUE == g_main_ps_info.alloc_flag)
+ if (NSFW_PROC_MAIN != proc_type || TRUE == g_main_ps_info.alloc_flag)
{
- NSFW_LOGERR ("alloc ps_info nul]pid=%u,type=%u", pid, proc_type);
- return NULL;
+ NSFW_LOGERR("alloc ps_info nul]pid=%u,type=%u", pid, proc_type);
+ return NULL;
}
- pps_info = &g_main_ps_info;
+ pps_info = &g_main_ps_info;
}
- if (EOK !=
- MEMSET_S (pps_info, sizeof (nsfw_ps_info), 0, sizeof (nsfw_ps_info)))
+ if (EOK !=
+ memset_s(pps_info, sizeof(nsfw_ps_info), 0, sizeof(nsfw_ps_info)))
{
- nsfw_ps_info_free (pps_info);
- NSFW_LOGERR ("set failed");
- return NULL;
+ NSFW_LOGERR("memset_s failed");
+ goto error;
}
- pps_info->proc_type = proc_type;
- pps_info->host_pid = pid;
-
- if (proc_type < NSFW_PROC_MAX)
+ if (proc_type < NSFW_PROC_MAX)
{
- int retval;
- retval =
- MEMCPY_S (pps_info->callback, sizeof (pps_info->callback),
- g_ps_init_callback[proc_type], sizeof (pps_info->callback));
- if (EOK != retval)
+ int retval = memcpy_s(pps_info->callback, sizeof(pps_info->callback),
+ g_ps_init_callback[proc_type],
+ sizeof(pps_info->callback));
+ if (EOK != retval)
{
- NSFW_LOGERR ("Failed to MEMCPY_S]retval=%d", retval);
- nsfw_ps_info_free (pps_info);
- return NULL;
+ NSFW_LOGERR("memcpy failed]retval=%d", retval);
+ goto error;
}
}
- list_add_tail (&pps_info->node, &g_ps_runing_list);
- pps_info->alloc_flag = TRUE;
+ pps_info->proc_type = proc_type;
+ pps_info->host_pid = pid;
+
+ list_add_tail(&pps_info->node, &g_ps_runing_list);
- (void) nsfw_sw_ps_state (pps_info, NSFW_PS_RUNNING);
- if (pid < NSFW_MAX_PID)
+ pps_info->alloc_flag = TRUE;
+ (void) nsfw_sw_ps_state(pps_info, NSFW_PS_RUNNING);
+
+ if (pid < NSFW_MAX_PID)
{
- g_ps_info[pid].ps_info = pps_info;
- g_ps_info[pid].proc_type = proc_type;
+ g_ps_info[pid].ps_info = pps_info;
+ if (!realloc_flg) /* If re-alloced, should keep the same as stored */
+ {
+ g_ps_info[pid].proc_type = proc_type;
+ g_ps_info[pid].starttime =
+ (u32) (nsfw_ps_get_starttime_from_file(pid) & 0xFFFFFFFF);
+ }
}
- NSFW_LOGINF ("ps_info alloc]ps_info=%p,pid=%u,type=%u", pps_info, pid,
- proc_type);
- return pps_info;
-
+ NSFW_LOGINF("ps_info alloc]ps_info=%p,pid=%u,type=%u", pps_info, pid,
+ proc_type);
+ return pps_info;
+ error:
+ if (1 != nsfw_mem_ring_enqueue(g_ps_cfg.ps_info_pool, pps_info))
+ {
+ NSFW_LOGERR("nsfw_mem_ring_enqueue failed]ps_info=%p", pps_info);
+ }
+ return NULL;
}
/*****************************************************************************
@@ -324,94 +775,83 @@ nsfw_ps_info_alloc (u32 pid, u8 proc_type)
* Calls :
* Called By :
*****************************************************************************/
-inline nsfw_ps_info *
-nsfw_ps_info_get (u32 pid)
+inline nsfw_ps_info *nsfw_ps_info_get(u32 pid)
{
- if (pid < NSFW_MAX_PID)
+ if (pid < NSFW_MAX_PID)
{
- return g_ps_info[pid].ps_info;
+ return g_ps_info[pid].ps_info;
}
- return NULL;
+ return NULL;
}
-nsfw_ps_info *
-nsfw_share_ps_info_get (u32 pid)
+nsfw_ps_info *nsfw_share_ps_info_get(u32 pid)
{
- if (pid < NSFW_MAX_PID)
+ if (pid < NSFW_MAX_PID)
{
- return g_master_ps_info[pid].ps_info;
+ return g_master_ps_info[pid].ps_info;
}
- return NULL;
+ return NULL;
}
-/*****************************************************************************
-* Prototype : nsfw_ps_info_free
-* Description : free ps_info
-* Input : nsfw_ps_info *ps_info
-* Output : None
-* Return Value : void
-* Calls :
-* Called By :
-*****************************************************************************/
-void
-nsfw_ps_info_free (nsfw_ps_info * ps_info)
+void nsfw_ps_info_free(nsfw_ps_info * ps_info)
{
- if (NULL == ps_info)
+ if (NULL == ps_info)
{
- NSFW_LOGERR ("ps_info nul");
- return;
+ NSFW_LOGERR("ps_info nul");
+ return;
}
- if (FALSE == ps_info->alloc_flag)
+ if (FALSE == ps_info->alloc_flag)
{
- NSFW_LOGERR ("ps_info refree]ps_info=%p,pid=%u,state=%u", ps_info,
- ps_info->host_pid, ps_info->state);
- return;
+ NSFW_LOGERR("ps_info refree]ps_info=%p,pid=%u,state=%u", ps_info,
+ ps_info->host_pid, ps_info->state);
+ return;
}
- if (NULL != ps_info->exit_timer_ptr)
+ if (NULL != ps_info->exit_timer_ptr)
{
- nsfw_timer_rmv_timer ((nsfw_timer_info *) ps_info->exit_timer_ptr);
- ps_info->exit_timer_ptr = NULL;
+ nsfw_timer_rmv_timer((nsfw_timer_info *) ps_info->exit_timer_ptr);
+ ps_info->exit_timer_ptr = NULL;
}
- if (NULL != ps_info->resend_timer_ptr)
+ if (NULL != ps_info->resend_timer_ptr)
{
- nsfw_timer_rmv_timer ((nsfw_timer_info *) ps_info->resend_timer_ptr);
- ps_info->resend_timer_ptr = NULL;
+ nsfw_timer_rmv_timer((nsfw_timer_info *) ps_info->resend_timer_ptr);
+ ps_info->resend_timer_ptr = NULL;
}
- if (NULL != ps_info->hbt_timer_ptr)
+ if (NULL != ps_info->hbt_timer_ptr)
{
- nsfw_timer_rmv_timer ((nsfw_timer_info *) ps_info->hbt_timer_ptr);
- ps_info->hbt_timer_ptr = NULL;
+ nsfw_timer_rmv_timer((nsfw_timer_info *) ps_info->hbt_timer_ptr);
+ ps_info->hbt_timer_ptr = NULL;
}
- list_del (&ps_info->node);
+ list_del(&ps_info->node);
- ps_info->alloc_flag = FALSE;
+ ps_info->alloc_flag = FALSE;
- NSFW_LOGINF ("ps_info free]ps_info=%p,pid=%u,state=%u", ps_info,
- ps_info->host_pid, ps_info->state);
- if (ps_info != &g_main_ps_info)
+ NSFW_LOGINF("ps_info free]ps_info=%p,pid=%u,state=%u", ps_info,
+ ps_info->host_pid, ps_info->state);
+ if (ps_info != &g_main_ps_info)
{
- if (0 == nsfw_mem_ring_enqueue (g_ps_cfg.ps_info_pool, ps_info))
+ if (0 == nsfw_mem_ring_enqueue(g_ps_cfg.ps_info_pool, ps_info))
{
- NSFW_LOGERR ("ps_info free failed]ps_info=%p,pid=%u,state=%u",
- ps_info, ps_info->host_pid, ps_info->state);
- return;
+ NSFW_LOGERR("ps_info free failed]ps_info=%p,pid=%u,state=%u",
+ ps_info, ps_info->host_pid, ps_info->state);
+ return;
}
}
- if (ps_info->host_pid < NSFW_MAX_PID)
+ if (ps_info->host_pid < NSFW_MAX_PID)
{
- g_ps_info[ps_info->host_pid].proc_type = 0;
- g_ps_info[ps_info->host_pid].ps_info = NULL;
+ g_ps_info[ps_info->host_pid].proc_type = 0;
+ g_ps_info[ps_info->host_pid].ps_info = NULL;
+ g_ps_info[ps_info->host_pid].starttime = 0;
}
- return;
+ return;
}
/*****************************************************************************
@@ -424,35 +864,35 @@ nsfw_ps_info_free (nsfw_ps_info * ps_info)
* Calls :
* Called By :
*****************************************************************************/
-int
-nsfw_ps_exiting_timeout (u32 timer_type, void *data)
+int nsfw_ps_exiting_timeout(u32 timer_type, void *data)
{
- nsfw_ps_info *pps_info = (nsfw_ps_info *) data;
- NSFW_LOGINF ("ps_info timerout]pps_info=%p,pid=%u", pps_info,
- pps_info->host_pid);
- if (NULL == pps_info)
+ nsfw_ps_info *pps_info = (nsfw_ps_info *) data;
+
+ if (NULL == pps_info)
{
- return TRUE;
+ return TRUE;
}
+ NSFW_LOGINF("ps_info timerout]pps_info=%p,pid=%u", pps_info,
+ pps_info->host_pid);
- pps_info->exit_timer_ptr = NULL;
+ pps_info->exit_timer_ptr = NULL;
- if (TRUE == g_hbt_switch)
+ if (TRUE == g_hbt_switch)
{
- NSFW_LOGINF ("hbt off");
- struct timespec time_left = { NSFW_PS_WEXIT_TVLAUE, 0 };
- pps_info->exit_timer_ptr =
- (void *) nsfw_timer_reg_timer (NSFW_PS_WEXIT_TIMER, pps_info,
- nsfw_ps_exiting_timeout, time_left);
- return TRUE;
+ NSFW_LOGINF("hbt off");
+ struct timespec time_left = { NSFW_PS_WEXIT_TVLAUE, 0 };
+ pps_info->exit_timer_ptr =
+ (void *) nsfw_timer_reg_timer(NSFW_PS_WEXIT_TIMER, pps_info,
+ nsfw_ps_exiting_timeout, time_left);
+ return TRUE;
}
- if (NSFW_PS_EXITING == pps_info->state)
+ if (NSFW_PS_EXITING == pps_info->state)
{
- (void) nsfw_sw_ps_state (pps_info, NSFW_PS_EXIT);
+ (void) nsfw_sw_ps_state(pps_info, NSFW_PS_EXIT);
}
- return TRUE;
+ return TRUE;
}
/*****************************************************************************
@@ -464,23 +904,22 @@ nsfw_ps_exiting_timeout (u32 timer_type, void *data)
* Calls :
* Called By :
*****************************************************************************/
-u8
-nsfw_ps_exit_end_notify (u32 pid)
+u8 nsfw_ps_exit_end_notify(u32 pid)
{
- nsfw_mgr_msg *rsp_msg =
- nsfw_mgr_msg_alloc (MGR_MSG_APP_EXIT_RSP, NSFW_PROC_MAIN);
- if (NULL == rsp_msg)
+ nsfw_mgr_msg *rsp_msg =
+ nsfw_mgr_msg_alloc(MGR_MSG_APP_EXIT_RSP, g_mgr_com_cfg.proc_type);
+ if (NULL == rsp_msg)
{
- NSFW_LOGERR ("alloc rsp msg failed]pid=%u", pid);
- return FALSE;
+ NSFW_LOGERR("alloc rsp msg failed]pid=%u", pid);
+ return FALSE;
}
- nsfw_ps_info_msg *ps_msg = GET_USER_MSG (nsfw_ps_info_msg, rsp_msg);
- ps_msg->host_pid = pid;
- (void) nsfw_mgr_send_msg (rsp_msg);
- nsfw_mgr_msg_free (rsp_msg);
- NSFW_LOGINF ("send exit rsp msg]pid=%u", pid);
- return TRUE;
+ nsfw_ps_info_msg *ps_msg = GET_USER_MSG(nsfw_ps_info_msg, rsp_msg);
+ ps_msg->host_pid = pid;
+ (void) nsfw_mgr_send_msg(rsp_msg);
+ nsfw_mgr_msg_free(rsp_msg);
+ NSFW_LOGINF("send exit rsp msg]pid=%u", pid);
+ return TRUE;
}
/*****************************************************************************
@@ -493,57 +932,63 @@ nsfw_ps_exit_end_notify (u32 pid)
* Calls :
* Called By :
*****************************************************************************/
-u8
-nsfw_sw_ps_state (nsfw_ps_info * pps_info, u8 new_state)
+u8 nsfw_sw_ps_state(nsfw_ps_info * pps_info, u8 new_state)
{
- if (NULL == pps_info)
+ if (NULL == pps_info)
{
- NSFW_LOGERR ("pps_info nul!");
- return FALSE;
+ NSFW_LOGERR("pps_info nul!");
+ return FALSE;
}
- NSFW_LOGINF ("sw]ps_info=%p,pid=%u,type=%u,old_state=%u,newstate=%u",
- pps_info, pps_info->host_pid, pps_info->proc_type,
- pps_info->state, new_state);
+ u8 old_state = pps_info->state;
+ NSFW_LOGINF("sw]ps_info=%p,pid=%u,type=%u,old_state=%u,newstate=%u",
+ pps_info, pps_info->host_pid, pps_info->proc_type, old_state,
+ new_state);
+
+ if (NSFW_PS_HBT_FAILED != new_state)
+ {
+ pps_info->state = new_state;
+ }
- i32 i, ret;
- for (i = 0; i < NSFW_PS_MAX_CALLBACK; i++)
+ i32 i, ret;
+ for (i = 0; i < NSFW_PS_MAX_CALLBACK; i++)
{
- if (NULL == pps_info->callback[i].fun)
+ if (NULL == pps_info->callback[i].fun)
{
- /* NULL should be the last fun */
- break;
+ /* NULL should be the last fun */
+ break;
}
- if (new_state == pps_info->callback[i].state)
+ if (new_state == pps_info->callback[i].state)
{
- ret =
- pps_info->callback[i].fun (pps_info, pps_info->callback[i].argv);
- NSFW_LOGINF ("callback fun]ps_info=%p,i=%d,fun=%p,argv=%p,ret=%d",
- pps_info, i, pps_info->callback[i].fun,
- pps_info->callback[i].argv, ret);
+ ret =
+ pps_info->callback[i].fun(pps_info,
+ pps_info->callback[i].argv);
+ NSFW_LOGINF("callback fun]ps_info=%p,i=%d,fun=%p,argv=%p,ret=%d",
+ pps_info, i, pps_info->callback[i].fun,
+ pps_info->callback[i].argv, ret);
}
}
- if (NSFW_PS_HBT_FAILED != new_state)
+ if (NSFW_PS_EXIT == new_state)
{
- pps_info->state = new_state;
- }
-
- if (NSFW_PS_EXIT == new_state)
- {
- nsfw_ps_info_free (pps_info);
+ nsfw_ps_info_free(pps_info);
+ if (NSFW_PS_EXITING == old_state)
+ {
+ dec_ps_exiting_cnt();
+ }
}
- if (NSFW_PS_EXITING == new_state)
+ if (NSFW_PS_EXITING == new_state)
{
- struct timespec time_left = { NSFW_PS_WEXIT_TVLAUE, 0 };
- pps_info->exit_timer_ptr =
- (void *) nsfw_timer_reg_timer (NSFW_PS_WEXIT_TIMER, pps_info,
- nsfw_ps_exiting_timeout, time_left);
+ struct timespec time_left = { NSFW_PS_WEXIT_TVLAUE, 0 };
+ pps_info->exit_timer_ptr =
+ (void *) nsfw_timer_reg_timer(NSFW_PS_WEXIT_TIMER, pps_info,
+ nsfw_ps_exiting_timeout, time_left);
+ inc_ps_exiting_cnt();
}
- return TRUE;
+ return TRUE;
}
/*****************************************************************************
@@ -555,108 +1000,112 @@ nsfw_sw_ps_state (nsfw_ps_info * pps_info, u8 new_state)
* Calls :
* Called By :
*****************************************************************************/
-i32
-nsfw_ps_get_netlink_socket ()
+i32 nsfw_ps_get_netlink_socket()
{
- int rc;
- int nl_sock;
- int size, size_len;
- struct sockaddr_nl sa_nl;
+ int rc;
+ int nl_sock;
+ int size, size_len;
+ struct sockaddr_nl sockad_nl;
- nl_sock = nsfw_base_socket (PF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR);
- if (nl_sock == -1)
+ nl_sock = nsfw_base_socket(PF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR);
+ if (nl_sock == -1)
{
- NSFW_LOGERR ("get netlink socket err]errno=%d", errno);
- return -1;
+ NSFW_LOGERR("get netlink socket err]errno=%d", errno);
+ return -1;
}
- rc = nsfw_set_close_on_exec (nl_sock);
- if (rc == -1)
+ /* close on exec */
+ rc = nsfw_set_close_on_exec(nl_sock);
+ if (rc == -1)
{
- (void) nsfw_base_close (nl_sock);
- NSFW_LOGERR ("set exec err]fd=%d, errno=%d", nl_sock, errno);
- return -1;
+ (void) nsfw_base_close(nl_sock);
+ NSFW_LOGERR("set exec err]fd=%d, errno=%d", nl_sock, errno);
+ return -1;
}
- sa_nl.nl_family = AF_NETLINK;
- sa_nl.nl_groups = CN_IDX_PROC;
- sa_nl.nl_pid = getpid ();
+ sockad_nl.nl_family = AF_NETLINK;
+ sockad_nl.nl_groups = CN_IDX_PROC;
+ sockad_nl.nl_pid = getpid();
- rc = nsfw_base_bind (nl_sock, (struct sockaddr *) &sa_nl, sizeof (sa_nl));
- if (rc == -1)
+ rc = nsfw_base_bind(nl_sock, (struct sockaddr *) &sockad_nl,
+ sizeof(sockad_nl));
+ if (rc == -1)
{
- (void) nsfw_base_close (nl_sock);
- NSFW_LOGERR ("netlink bind err]netlink_fd=%d, errno=%d", nl_sock,
- errno);
- return -1;
+ (void) nsfw_base_close(nl_sock);
+ NSFW_LOGERR("netlink bind err]netlink_fd=%d, errno=%d", nl_sock,
+ errno);
+ return -1;
}
- struct __attribute__ ((aligned (NLMSG_ALIGNTO)))
- {
- struct nlmsghdr nl_hdr;
- struct __attribute__ ((__packed__))
+ /* this struct will be use */
+ struct __attribute__ ((aligned(NLMSG_ALIGNTO)))
{
- struct cn_msg cn_msg;
- enum proc_cn_mcast_op cn_mcast;
- };
- } nlcn_msg;
- if (EOK != MEMSET_S (&nlcn_msg, sizeof (nlcn_msg), 0, sizeof (nlcn_msg)))
+ struct nlmsghdr nl_msg_hdr;
+ struct __attribute__ ((__packed__))
+ {
+ struct cn_msg c_msg;
+ enum proc_cn_mcast_op c_mcast;
+ };
+ } nlc_msg;
+
+ if (EOK != memset_s(&nlc_msg, sizeof(nlc_msg), 0, sizeof(nlc_msg)))
{
- (void) nsfw_base_close (nl_sock);
- NSFW_LOGERR ("netlink set failed]netlink_fd=%d", nl_sock);
- return -1;
+ (void) nsfw_base_close(nl_sock);
+ NSFW_LOGERR("netlink set failed]netlink_fd=%d", nl_sock);
+ return -1;
}
- nlcn_msg.nl_hdr.nlmsg_len = sizeof (nlcn_msg);
- nlcn_msg.nl_hdr.nlmsg_pid = getpid ();
- nlcn_msg.nl_hdr.nlmsg_type = NLMSG_DONE;
+ nlc_msg.nl_msg_hdr.nlmsg_len = sizeof(nlc_msg);
+ nlc_msg.nl_msg_hdr.nlmsg_pid = getpid();
+ nlc_msg.nl_msg_hdr.nlmsg_type = NLMSG_DONE;
- nlcn_msg.cn_msg.id.idx = CN_IDX_PROC;
- nlcn_msg.cn_msg.id.val = CN_VAL_PROC;
- nlcn_msg.cn_msg.len = sizeof (enum proc_cn_mcast_op);
+ nlc_msg.c_msg.id.idx = CN_IDX_PROC;
+ nlc_msg.c_msg.id.val = CN_VAL_PROC;
+ nlc_msg.c_msg.len = sizeof(enum proc_cn_mcast_op);
- nlcn_msg.cn_mcast = PROC_CN_MCAST_LISTEN;
- rc = nsfw_base_send (nl_sock, &nlcn_msg, sizeof (nlcn_msg), 0);
- if (rc == -1)
+ nlc_msg.c_mcast = PROC_CN_MCAST_LISTEN;
+ rc = nsfw_base_send(nl_sock, &nlc_msg, sizeof(nlc_msg), 0);
+ if (rc == -1)
{
- (void) nsfw_base_close (nl_sock);
- NSFW_LOGERR ("netlink send err]netlink_fd=%d, errno=%d", nl_sock,
- errno);
- return -1;
+ (void) nsfw_base_close(nl_sock);
+ NSFW_LOGERR("netlink send err]netlink_fd=%d, errno=%d", nl_sock,
+ errno);
+ return -1;
}
- NSFW_LOGINF ("netlink connect]netlink_fd=%d", nl_sock);
- int val, len;
- len = sizeof (val);
- if (0 >
- nsfw_base_getsockopt (nl_sock, SOL_SOCKET, SO_RCVBUF, &val,
- (socklen_t *) & len))
+ NSFW_LOGINF("netlink connect]netlink_fd=%d", nl_sock);
+
+ int val = 0;
+ int len = sizeof(val);
+ if (0 >
+ nsfw_base_getsockopt(nl_sock, SOL_SOCKET, SO_RCVBUF, &val,
+ (socklen_t *) & len))
{
- NSFW_LOGERR ("get socket opt err!]error=%d", errno);
+ NSFW_LOGERR("get socket opt err]error=%d", errno);
}
- else
+ else
{
- NSFW_LOGINF ("] SO_RCVBUF=0x%x", val);
+ NSFW_LOGINF("]SO_RCVBUF=0x%x", val);
}
- size = MAX_NET_LINK_BUF;
- size_len = sizeof (size);
- if (0 >
- nsfw_base_setsockopt (nl_sock, SOL_SOCKET, SO_RCVBUFFORCE,
- (void *) &size, (socklen_t) size_len))
+ size = MAX_NET_LINK_BUF;
+ size_len = sizeof(size);
+ if (0 >
+ nsfw_base_setsockopt(nl_sock, SOL_SOCKET, SO_RCVBUFFORCE,
+ (void *) &size, (socklen_t) size_len))
{
- NSFW_LOGERR ("set socket opt err!]error=%d", errno);
+ NSFW_LOGERR("set socket opt err]error=%d", errno);
}
- size_len = sizeof (size);
- if (0 >
- nsfw_base_getsockopt (nl_sock, SOL_SOCKET, SO_RCVBUF, (void *) &size,
- (socklen_t *) & size_len))
+ size_len = sizeof(size);
+ if (0 >
+ nsfw_base_getsockopt(nl_sock, SOL_SOCKET, SO_RCVBUF, (void *) &size,
+ (socklen_t *) & size_len))
{
- NSFW_LOGERR ("get socket opt err!]error=%d", errno);
+ NSFW_LOGERR("get socket opt err]error=%d", errno);
}
- NSFW_LOGINF ("] SO_RCVBUF=0x%x", size);
- return nl_sock;
+ NSFW_LOGINF("]SO_RCVBUF=0x%x", size);
+ return nl_sock;
}
/*****************************************************************************
@@ -670,81 +1119,81 @@ nsfw_ps_get_netlink_socket ()
* Calls :
* Called By :
*****************************************************************************/
-int
-nsfw_ps_change_fun (i32 epfd, i32 fd, u32 events)
+int nsfw_ps_change_fun(i32 epfd, i32 fd, u32 events)
{
- i32 rc;
- u32 host_pid;
- nsfw_ps_info *pps_info = NULL;
+ i32 rc;
+ u32 host_pid;
+ nsfw_ps_info *pps_info = NULL;
- struct __attribute__ ((aligned (NLMSG_ALIGNTO)))
- {
- struct nlmsghdr nl_hdr;
- struct __attribute__ ((__packed__))
+ /*this struct will be used */
+ struct __attribute__ ((aligned(NLMSG_ALIGNTO)))
{
- struct cn_msg cn_msg;
- struct proc_event proc_ev;
- };
- } nlcn_msg;
+ struct nlmsghdr nl_msg_hdr;
+ struct __attribute__ ((__packed__))
+ {
+ struct cn_msg c_msg;
+ struct proc_event p_ev;
+ };
+ } nlc_msg;
- if (!(events & EPOLLIN))
+ if (!(events & EPOLLIN))
{
- return TRUE;
+ return TRUE;
}
- while (1)
+ while (1)
{
- rc = nsfw_base_recv (fd, &nlcn_msg, sizeof (nlcn_msg), 0);
- if (rc == 0)
+ rc = nsfw_base_recv(fd, &nlc_msg, sizeof(nlc_msg), 0);
+ if (rc == 0)
{
- NSFW_LOGWAR ("netlink recv 0]netlink_fd=%d,errno=%d", fd, errno);
- break;
+ NSFW_LOGWAR("netlink recv 0]netlink_fd=%d,errno=%d", fd, errno);
+ break;
}
- else if (rc == -1)
+ else if (rc == -1)
{
- if (errno == EINTR || errno == EAGAIN)
+ if (errno == EINTR || errno == EAGAIN)
{
- break;
+ break;
}
- NSMON_LOGERR ("netlink recv]netlink_fd=%d,errno=%d", fd, errno);
- if (errno == ENOBUFS)
+ NSMON_LOGERR("netlink recv]netlink_fd=%d,errno=%d", fd, errno);
+ if (errno == ENOBUFS)
{
- struct timespec time_left = { NSFW_PS_FIRST_CHK_TVLAUE, 0 };
- g_ps_chk_timer =
- (void *) nsfw_timer_reg_timer (NSFW_PS_CHK_TIMER,
- (void *) FALSE,
- nsfw_ps_chk_timeout,
- time_left);
+ struct timespec time_left = { NSFW_PS_FIRST_CHK_TVLAUE, 0 };
+ g_ps_chk_timer =
+ (void *) nsfw_timer_reg_timer(NSFW_PS_CHK_TIMER,
+ (void *) FALSE,
+ nsfw_ps_chk_timeout,
+ time_left);
}
- break;
+ break;
}
- switch (nlcn_msg.proc_ev.what)
+ switch (nlc_msg.p_ev.what)
{
- case PROC_EVENT_EXIT:
- host_pid = nlcn_msg.proc_ev.event_data.exit.process_pid;
- pps_info = nsfw_ps_info_get (host_pid);
- if (NULL == pps_info)
- {
- NSFW_LOGDBG ("pps info is null]host pid=%d", host_pid);
- break;
- }
-
- if (NSFW_PS_EXITING == pps_info->state)
- {
- NSFW_LOGERR ("double pid info]ps_info=%p,pid=%d", pps_info,
- host_pid);
- break;
- }
-
- (void) nsfw_sw_ps_state (pps_info, NSFW_PS_EXITING);
- break;
- default:
- break;
+ case PROC_EVENT_EXIT: /*enum or int no effect here */
+ host_pid = nlc_msg.p_ev.event_data.exit.process_pid;
+ pps_info = nsfw_ps_info_get(host_pid);
+ if (NULL == pps_info)
+ {
+ /*too many useless debug log, del NSFW_LOGDBG("pps info is null]host pid=%u", host_pid); */
+ break;
+ }
+
+ if (NSFW_PS_EXITING == pps_info->state)
+ {
+ NSFW_LOGERR("double pid info]ps_info=%p,pid=%u",
+ pps_info, host_pid);
+ break;
+ }
+
+ (void) nsfw_sw_ps_state(pps_info, NSFW_PS_EXITING);
+ break;
+ default:
+ break;
}
}
- return TRUE;
+ return TRUE;
}
/*****************************************************************************
@@ -755,22 +1204,21 @@ nsfw_ps_change_fun (i32 epfd, i32 fd, u32 events)
* Return Value : u8
* Calls :
* Called By :
-*
*****************************************************************************/
-u8
-nsfw_ps_start_netlink ()
+u8 nsfw_ps_start_netlink()
{
- i32 netlink_fd = nsfw_ps_get_netlink_socket ();
- if (netlink_fd < 0)
+
+ i32 netlink_fd = nsfw_ps_get_netlink_socket();
+ if (netlink_fd < 0)
{
- NSFW_LOGERR ("get netlink failed!");
- return FALSE;
+ NSFW_LOGERR("get netlink failed!");
+ return FALSE;
}
- NSFW_LOGINF ("start ps_info module!]netlink_fd=%d", netlink_fd);
- (void) nsfw_mgr_reg_sock_fun (netlink_fd, nsfw_ps_change_fun);
- (void) nsfw_mgr_reg_msg_fun (MGR_MSG_APP_EXIT_RSP, nsfw_ps_exit);
- return TRUE;
+ NSFW_LOGINF("start ps_info module!]netlink_fd=%d", netlink_fd);
+ (void) nsfw_mgr_reg_sock_fun(netlink_fd, nsfw_ps_change_fun);
+ (void) nsfw_mgr_reg_msg_fun(MGR_MSG_APP_EXIT_RSP, nsfw_ps_exit);
+ return TRUE;
}
/* for heartbeat check*/
@@ -786,26 +1234,32 @@ nsfw_thread_dogs g_thread_dogs[NSFW_MAX_THREAD_DOGS_COUNT];
* Calls :
* Called By :
*****************************************************************************/
-i32
-nsfw_all_thread_chk ()
+i32 nsfw_all_thread_chk()
{
- i32 count = -1;
- u32 i;
- for (i = 0; i < NSFW_MAX_THREAD_DOGS_COUNT; i++)
+ i32 count = -1;
+ u32 i;
+ for (i = 0; i < NSFW_MAX_THREAD_DOGS_COUNT; i++)
{
- if (FALSE == g_thread_dogs[i].alloc_flag)
+ if (FALSE == g_thread_dogs[i].alloc_flag)
{
- continue;
+ continue;
}
- if (count < g_thread_dogs[i].count)
+ if (count < g_thread_dogs[i].count)
{
- count = g_thread_dogs[i].count;
+ count = g_thread_dogs[i].count;
}
- g_thread_dogs[i].count++;
+ /* only if the thread abnormal, then output log */
+ if (g_thread_dogs[i].count > 0)
+ { /* print thread_id, know which thread is abnormal */
+ NSFW_LOGINF("hb_timeout]count=%d,thread_id=%u",
+ g_thread_dogs[i].count, g_thread_dogs[i].thread_id);
+ }
+
+ g_thread_dogs[i].count++;
}
- return count;
+ return count;
}
/*****************************************************************************
@@ -817,17 +1271,16 @@ nsfw_all_thread_chk ()
* Calls :
* Called By :
*****************************************************************************/
-inline u8
-nsfw_thread_chk_unreg ()
+inline u8 nsfw_thread_chk_unreg()
{
- if (t_val_idx > 0 && t_val_idx < NSFW_MAX_THREAD_DOGS_COUNT)
+ if (t_val_idx > 0 && t_val_idx < NSFW_MAX_THREAD_DOGS_COUNT)
{
- g_thread_dogs[t_val_idx].alloc_flag = FALSE;
- g_thread_dogs[t_val_idx].count = 0;
- g_thread_dogs[t_val_idx].thread_id = 0;
- t_val_idx = 0;
+ g_thread_dogs[t_val_idx].alloc_flag = FALSE;
+ g_thread_dogs[t_val_idx].count = 0;
+ g_thread_dogs[t_val_idx].thread_id = 0;
+ t_val_idx = 0;
}
- return TRUE;
+ return TRUE;
}
/*****************************************************************************
@@ -840,86 +1293,86 @@ nsfw_thread_chk_unreg ()
* Calls :
* Called By :
*****************************************************************************/
-inline u8
-nsfw_thread_chk ()
+inline u8 nsfw_thread_chk()
{
- u32 i;
- if (t_val_idx > 0 && t_val_idx < NSFW_MAX_THREAD_DOGS_COUNT)
+ u32 i;
+ if (t_val_idx > 0 && t_val_idx < NSFW_MAX_THREAD_DOGS_COUNT)
{
- g_thread_dogs[t_val_idx].count = 0;
- return TRUE;
+ g_thread_dogs[t_val_idx].count = 0;
+ return TRUE;
}
- for (i = 1; i < NSFW_MAX_THREAD_DOGS_COUNT; i++)
+ for (i = 1; i < NSFW_MAX_THREAD_DOGS_COUNT; i++)
{
- if ((FALSE == g_thread_dogs[i].alloc_flag)
- && __sync_bool_compare_and_swap (&g_thread_dogs[i].alloc_flag,
- FALSE, TRUE))
+ /*
+ (1) use some fixed value but no effect (e506)
+ (2) it don't contain any extra commas (e505)
+ */
+ if ((FALSE == g_thread_dogs[i].alloc_flag)
+ && __sync_bool_compare_and_swap(&g_thread_dogs[i].alloc_flag,
+ FALSE, TRUE))
{
- t_val_idx = i;
- break;
+ t_val_idx = i;
+ break;
}
}
- if (t_val_idx > 0 && t_val_idx < NSFW_MAX_THREAD_DOGS_COUNT)
+ if (t_val_idx > 0 && t_val_idx < NSFW_MAX_THREAD_DOGS_COUNT)
{
- g_thread_dogs[t_val_idx].count = 0;
- g_thread_dogs[t_val_idx].thread_id = syscall (SYS_gettid);
+ g_thread_dogs[t_val_idx].count = 0;
+ g_thread_dogs[t_val_idx].thread_id = syscall(SYS_gettid);
}
- return TRUE;
+ return TRUE;
}
-/*****************************************************************
-Parameters : None
-Return :
-Description :
-*****************************************************************/
-nsfw_thread_dogs *
-nsfw_thread_getDog ()
+nsfw_thread_dogs *nsfw_thread_get_dog()
{
- u32 i;
- nsfw_thread_dogs *retPtr = NULL;
- if (t_val_idx > 0 && t_val_idx < NSFW_MAX_THREAD_DOGS_COUNT)
+ u32 i;
+ nsfw_thread_dogs *retPtr = NULL;
+ if (t_val_idx > 0 && t_val_idx < NSFW_MAX_THREAD_DOGS_COUNT)
{
- return &g_thread_dogs[t_val_idx];
+ return &g_thread_dogs[t_val_idx];
}
- for (i = 1; i < NSFW_MAX_THREAD_DOGS_COUNT; i++)
+ for (i = 1; i < NSFW_MAX_THREAD_DOGS_COUNT; i++)
{
- if ((FALSE == g_thread_dogs[i].alloc_flag)
- && __sync_bool_compare_and_swap (&g_thread_dogs[i].alloc_flag,
- FALSE, TRUE))
+ /*
+ (1) use some fixed value but no effect (e506)
+ (2) it don't contain any extra commas (e505)
+ */
+ if ((FALSE == g_thread_dogs[i].alloc_flag)
+ && __sync_bool_compare_and_swap(&g_thread_dogs[i].alloc_flag,
+ FALSE, TRUE))
{
- t_val_idx = i;
- break;
+ t_val_idx = i;
+ break;
}
}
- if (t_val_idx > 0 && t_val_idx < NSFW_MAX_THREAD_DOGS_COUNT)
+ if (t_val_idx > 0 && t_val_idx < NSFW_MAX_THREAD_DOGS_COUNT)
{
- g_thread_dogs[t_val_idx].count = 0;
- g_thread_dogs[t_val_idx].thread_id = syscall (SYS_gettid);
- retPtr = &g_thread_dogs[t_val_idx];
+ g_thread_dogs[t_val_idx].count = 0;
+ g_thread_dogs[t_val_idx].thread_id = syscall(SYS_gettid);
+ retPtr = &g_thread_dogs[t_val_idx];
}
- return retPtr;
+ return retPtr;
}
pthread_t g_all_thread[MAX_THREAD] = { 0 };
-u8
-nsfw_reg_trace_thread (pthread_t tid)
+u8 nsfw_reg_trace_thread(pthread_t tid)
{
- int i;
- for (i = 0; i < MAX_THREAD; i++)
+ int i;
+ for (i = 0; i < MAX_THREAD; i++)
{
- if ((0 == g_all_thread[i])
- && __sync_bool_compare_and_swap (&g_all_thread[i], 0, tid))
+ if ((0 == g_all_thread[i])
+ && __sync_bool_compare_and_swap(&g_all_thread[i], 0, tid))
{
- return TRUE;
+ return TRUE;
}
}
- return FALSE;
+ return FALSE;
}
/*****************************************************************************
@@ -931,75 +1384,73 @@ nsfw_reg_trace_thread (pthread_t tid)
* Calls :
* Called By :
*****************************************************************************/
-u8
-nsfw_ps_check_dst_init (u8 dst_proc_type)
+u8 nsfw_ps_check_dst_init(u8 dst_proc_type)
{
- u8 ps_state = FALSE;
- nsfw_mgr_msg *msg =
- nsfw_mgr_msg_alloc (MGR_MSG_CHK_INIT_REQ, dst_proc_type);
- if (NULL == msg)
+ u8 ps_state = FALSE;
+ nsfw_mgr_msg *msg =
+ nsfw_mgr_msg_alloc(MGR_MSG_CHK_INIT_REQ, dst_proc_type);
+ if (NULL == msg)
{
- NSFW_LOGERR ("alloc msg failed]dst_typ=%d", dst_proc_type);
- return FALSE;
+ NSFW_LOGERR("alloc msg failed]dst_typ=%d", dst_proc_type);
+ return FALSE;
}
- nsfw_ps_chk_msg *ps_msg = GET_USER_MSG (nsfw_ps_chk_msg, msg);
- ps_msg->ps_state = TRUE;
+ nsfw_ps_chk_msg *ps_msg = GET_USER_MSG(nsfw_ps_chk_msg, msg);
+ ps_msg->ps_state = TRUE;
- nsfw_mgr_msg *rsp_msg = nsfw_mgr_null_rspmsg_alloc ();
- if (NULL == rsp_msg)
+ nsfw_mgr_msg *rsp_msg = nsfw_mgr_null_rspmsg_alloc();
+ if (NULL == rsp_msg)
{
- nsfw_mgr_msg_free (msg);
- NSFW_LOGERR ("alloc rsp msg failed]dst_typ=%d", dst_proc_type);
- return FALSE;
+ nsfw_mgr_msg_free(msg);
+ NSFW_LOGERR("alloc rsp msg failed]dst_typ=%d", dst_proc_type);
+ return FALSE;
}
- (void) nsfw_mgr_send_req_wait_rsp (msg, rsp_msg);
+ (void) nsfw_mgr_send_req_wait_rsp(msg, rsp_msg);
- ps_msg = GET_USER_MSG (nsfw_ps_chk_msg, rsp_msg);
- ps_state = ps_msg->ps_state;
+ ps_msg = GET_USER_MSG(nsfw_ps_chk_msg, rsp_msg);
+ ps_state = ps_msg->ps_state;
- nsfw_mgr_msg_free (msg);
- nsfw_mgr_msg_free (rsp_msg);
- NSFW_LOGINF ("get peer state]dst_type=%d,state=%d", dst_proc_type,
- ps_state);
- return ps_state;
+ nsfw_mgr_msg_free(msg);
+ nsfw_mgr_msg_free(rsp_msg);
+ NSFW_LOGINF("get peer state]dst_type=%d,state=%d", dst_proc_type,
+ ps_state);
+ return ps_state;
}
/*****************************************************************************
* Prototype : nsfw_ps_send_hbt
-* Description : send heart beat message to peer
+* Description : seng heart beat message to peer
* Input : nsfw_ps_info* pps_info
* Output : None
* Return Value : u8
* Calls :
* Called By :
*****************************************************************************/
-u8
-nsfw_ps_send_hbt (nsfw_ps_info * pps_info)
+u8 nsfw_ps_send_hbt(nsfw_ps_info * pps_info)
{
- if (NULL == pps_info)
+ if (NULL == pps_info)
{
- NSFW_LOGERR ("null ps_info!");
- return FALSE;
+ NSFW_LOGERR("null ps_info!");
+ return FALSE;
}
- nsfw_mgr_msg *req_msg =
- nsfw_mgr_msg_alloc (MGR_MSG_CHK_HBT_REQ, pps_info->proc_type);
- if (NULL == req_msg)
+ nsfw_mgr_msg *req_msg =
+ nsfw_mgr_msg_alloc(MGR_MSG_CHK_HBT_REQ, pps_info->proc_type);
+ if (NULL == req_msg)
{
- NSFW_LOGERR ("alloc req msg failed]pps_info=%p", pps_info);
- return FALSE;
+ NSFW_LOGERR("alloc req msg failed]pps_info=%p", pps_info);
+ return FALSE;
}
- req_msg->dst_pid = pps_info->host_pid;
- nsfw_ps_chk_msg *ps_msg = GET_USER_MSG (nsfw_ps_chk_msg, req_msg);
- ps_msg->ps_state = TRUE;
- u8 ret = nsfw_mgr_send_msg (req_msg);
- nsfw_mgr_msg_free (req_msg);
- NSFW_LOGDBG ("send hbt msg]ret=%d,pps_info=%p,pid=%d,type=%d", ret,
- pps_info, pps_info->host_pid, pps_info->proc_type);
- return ret;
+ req_msg->dst_pid = pps_info->host_pid;
+ nsfw_ps_chk_msg *ps_msg = GET_USER_MSG(nsfw_ps_chk_msg, req_msg);
+ ps_msg->ps_state = TRUE;
+ u8 ret = nsfw_mgr_send_msg(req_msg);
+ nsfw_mgr_msg_free(req_msg);
+ NSFW_LOGDBG("send hbt msg]ret=%d,pps_info=%p,pid=%u,type=%d", ret,
+ pps_info, pps_info->host_pid, pps_info->proc_type);
+ return ret;
}
/*****************************************************************************
@@ -1011,29 +1462,51 @@ nsfw_ps_send_hbt (nsfw_ps_info * pps_info)
* Calls :
* Called By :
*****************************************************************************/
-int
-nsfw_ps_recv_hbt (nsfw_mgr_msg * msg)
+int nsfw_ps_recv_hbt(nsfw_mgr_msg * msg)
{
- if (NULL == msg)
+ if (NULL == msg)
{
- NSFW_LOGERR ("error msg nul!");
- return FALSE;
+ NSFW_LOGERR("error msg nul!");
+ return FALSE;
}
- nsfw_mgr_msg *rsp_msg = nsfw_mgr_rsp_msg_alloc (msg);
- if (NULL == rsp_msg)
+ nsfw_mgr_msg *rsp_msg = nsfw_mgr_rsp_msg_alloc(msg);
+ if (NULL == rsp_msg)
{
- NSFW_LOGERR ("alloc rsp failed,drop msg!" MSGINFO, PRTMSG (msg));
- return FALSE;
+ NSFW_LOGERR("alloc rsp failed,drop msg!" MSGINFO, PRTMSG(msg));
+ return FALSE;
}
- nsfw_ps_chk_msg *ps_msg = GET_USER_MSG (nsfw_ps_chk_msg, rsp_msg);
- ps_msg->ps_state = TRUE;
- ps_msg->thread_chk_count = nsfw_all_thread_chk ();
- (void) nsfw_mgr_send_msg (rsp_msg);
- nsfw_mgr_msg_free (rsp_msg);
+ nsfw_ps_chk_msg *ps_msg = GET_USER_MSG(nsfw_ps_chk_msg, rsp_msg);
+ ps_msg->ps_state = TRUE;
+ ps_msg->thread_chk_count = nsfw_all_thread_chk();
+ (void) nsfw_mgr_send_msg(rsp_msg);
+ nsfw_mgr_msg_free(rsp_msg);
- return TRUE;
+ return TRUE;
+}
+
+void log_sys_process_info(void)
+{
+ /* get thread info which is running in 0 core cpu */
+#define GET_SYS_PROCESS_STATUS_INFO "ps c -w -T -e -O user,s,spid,%cpu,%mem,psr,start --sort -pcpu |grep -E 'PSR| R ' |grep -E 'PSR| 0 | 1 '"
+ /* check cpu usage of all thread for daemon-stack process, this cmd running need spend 180ms */
+#define GET_NSTACK_MAIN_PROCESS_STATUS_INFO "top -d 1 -H -p `pidof nStackMain` -n 1 -b"
+ char result[SPL_MAX_BUF_LEN] = { 0 };
+ int retVal =
+ nsfw_mgr_run_script(GET_NSTACK_MAIN_PROCESS_STATUS_INFO, result,
+ SPL_MAX_BUF_LEN);
+ if (-1 != retVal)
+ {
+ NSFW_LOGWAR("NSTACK_MAIN=%d\n%s", retVal, result);
+ }
+ retVal =
+ nsfw_mgr_run_script(GET_SYS_PROCESS_STATUS_INFO, result,
+ SPL_MAX_BUF_LEN);
+ if (-1 != retVal)
+ {
+ NSFW_LOGWAR("SYS=%d\n%s", retVal, result);
+ }
}
/*****************************************************************************
@@ -1045,66 +1518,75 @@ nsfw_ps_recv_hbt (nsfw_mgr_msg * msg)
* Calls :
* Called By :
*****************************************************************************/
-int
-nsfw_ps_recv_hbt_rsp (nsfw_mgr_msg * msg)
+int nsfw_ps_recv_hbt_rsp(nsfw_mgr_msg * msg)
{
- if (NULL == msg)
+ if (NULL == msg)
{
- NSFW_LOGERR ("error msg nul!");
- return FALSE;
+ NSFW_LOGERR("error msg nul!");
+ return FALSE;
}
- nsfw_ps_chk_msg *ps_msg = GET_USER_MSG (nsfw_ps_chk_msg, msg);
- if (TRUE != ps_msg->ps_state)
+ nsfw_ps_chk_msg *ps_msg = GET_USER_MSG(nsfw_ps_chk_msg, msg);
+ if (TRUE != ps_msg->ps_state)
{
- NSFW_LOGERR ("Heartbeat failed]pid=%u,type=%u", msg->src_pid,
- msg->src_proc_type);
- return FALSE;
+ NSFW_LOGERR("Heartbeat failed]pid=%u,type=%u", msg->src_pid,
+ msg->src_proc_type);
+ return FALSE;
}
- nsfw_ps_info *pps_info = nsfw_ps_info_get (msg->src_pid);
- if (NULL == pps_info)
+ nsfw_ps_info *pps_info = nsfw_ps_info_get(msg->src_pid);
+ if (NULL == pps_info)
{
- NSFW_LOGERR ("get ps_info failed]pid=%u,type=%u,count=%d",
- msg->src_pid, msg->src_proc_type,
- ps_msg->thread_chk_count);
- return FALSE;
+ NSFW_LOGERR("get ps_info failed]pid=%u,type=%u,count=%d",
+ msg->src_pid, msg->src_proc_type,
+ ps_msg->thread_chk_count);
+ return FALSE;
}
- if (0 == ps_msg->thread_chk_count)
+ if (0 == ps_msg->thread_chk_count)
{
- pps_info->hbt_failed_count = 0;
- return TRUE;
+ pps_info->hbt_failed_count = 0;
+
+ /* send daemon-stack normal alarm, when hb normal one time */
+ omc_send_nsmain_alarm(ALARM_EVENT_NSTACK_MAIN_ABNORMAL_RESTART_FAIL,
+ ALARM_CLEAN);
+ return TRUE;
}
- if (pps_info->hbt_failed_count > (u32) ps_msg->thread_chk_count)
+ u32 tmp_hbt_failed_count = pps_info->hbt_failed_count;
+
+ if (pps_info->hbt_failed_count > (u32) ps_msg->thread_chk_count)
{
- pps_info->hbt_failed_count = (u32) ps_msg->thread_chk_count;
+ pps_info->hbt_failed_count = (u32) ps_msg->thread_chk_count;
}
- NSFW_LOGERR ("Heartbeat failed]pid=%u,type=%u,count=%d,ps_count=%u",
- msg->src_pid, msg->src_proc_type, ps_msg->thread_chk_count,
- pps_info->hbt_failed_count);
- return FALSE;
+ NSFW_LOGERR("Heartbeat failed]pid=%u,type=%u,count=%d,ps_count=%u",
+ msg->src_pid, msg->src_proc_type, ps_msg->thread_chk_count,
+ pps_info->hbt_failed_count);
+ /* for fast get sys process status info */
+ if (1 == tmp_hbt_failed_count)
+ {
+ log_sys_process_info();
+ }
+ return FALSE;
}
-int
-nsfw_ps_reset_hbt (void *pps_info, void *argv)
+int nsfw_ps_reset_hbt(void *pps_info, void *argv)
{
- nsfw_ps_info *ps_info = pps_info;
- if (NULL == ps_info)
+ nsfw_ps_info *ps_info = pps_info;
+ if (NULL == ps_info)
{
- NSFW_LOGERR ("ps_info nul!");
- return FALSE;
+ NSFW_LOGERR("ps_info nul!");
+ return FALSE;
}
- if (NSFW_PROC_MAIN != ps_info->proc_type)
+ if (NSFW_PROC_MAIN != ps_info->proc_type)
{
- return FALSE;
+ return FALSE;
}
- ps_info->hbt_failed_count = *(u32 *) argv;
- return TRUE;
+ ps_info->hbt_failed_count = *(u32 *) argv;
+ return TRUE;
}
/*****************************************************************************
@@ -1117,69 +1599,70 @@ nsfw_ps_reset_hbt (void *pps_info, void *argv)
* Calls :
* Called By :
*****************************************************************************/
-int
-nsfw_ps_hbt_timeout (u32 timer_type, void *data)
+int nsfw_ps_hbt_timeout(u32 timer_type, void *data)
{
- nsfw_ps_info *pps_info = (nsfw_ps_info *) data;
+ nsfw_ps_info *pps_info = (nsfw_ps_info *) data;
- if (NULL == pps_info)
+ if (NULL == pps_info)
{
- NSFW_LOGERR ("null ps_info!");
- return FALSE;
+ NSFW_LOGERR("null ps_info!");
+ return FALSE;
}
- if (NULL == pps_info->hbt_timer_ptr)
+ if (NULL == pps_info->hbt_timer_ptr)
{
- NSFW_LOGERR ("hbt has stop]pps_info=%p", pps_info);
- pps_info->hbt_failed_count = 0;
- return TRUE;
+ NSFW_LOGERR("hbt has stop]pps_info=%p", pps_info);
+ pps_info->hbt_failed_count = 0;
+ return TRUE;
}
- if (TRUE == g_hbt_switch)
+ if (TRUE == g_hbt_switch)
{
- struct timespec time_left = { NSFW_CHK_HBT_TVLAUE, 0 };
- pps_info->hbt_timer_ptr =
- (void *) nsfw_timer_reg_timer (NSFW_CHK_HBT_TIMER, data,
- nsfw_ps_hbt_timeout, time_left);
- return TRUE;
+ struct timespec time_left = { NSFW_CHK_HBT_TVLAUE, 0 };
+ pps_info->hbt_timer_ptr =
+ (void *) nsfw_timer_reg_timer(NSFW_CHK_HBT_TIMER, data,
+ nsfw_ps_hbt_timeout, time_left);
+ return TRUE;
}
- /* nic init may cost a few seconds, master will restart main if heartbeat timeout */
- if (NSFW_SOFT_HBT_CHK_COUNT != NSFW_MAX_HBT_CHK_COUNT)
+ /* nic init may cost a few seconds, master will restart main if heartbeat timeout- Begin */
+ if (NSFW_SOFT_HBT_CHK_COUNT != NSFW_MAX_HBT_CHK_COUNT)
{
- if (NSFW_SOFT_HBT_CHK_COUNT < NSFW_MAX_HBT_CHK_COUNT)
+ if (NSFW_SOFT_HBT_CHK_COUNT < NSFW_MAX_HBT_CHK_COUNT)
{
- u32 new_hbt_count = 0;
- (void) nsfw_ps_iterator (nsfw_ps_reset_hbt, &new_hbt_count);
+ u32 new_hbt_count = 0;
+ (void) nsfw_ps_iterator(nsfw_ps_reset_hbt, &new_hbt_count);
}
- NSFW_MAX_HBT_CHK_COUNT = NSFW_SOFT_HBT_CHK_COUNT;
+ NSFW_MAX_HBT_CHK_COUNT = NSFW_SOFT_HBT_CHK_COUNT;
}
- if (NSFW_MAX_HBT_CHK_COUNT <= pps_info->hbt_failed_count)
+ if (NSFW_MAX_HBT_CHK_COUNT <= pps_info->hbt_failed_count)
{
- (void) nsfw_sw_ps_state (pps_info, NSFW_PS_HBT_FAILED);
- /*reset counter */
- pps_info->hbt_failed_count = 0;
+ (void) nsfw_sw_ps_state(pps_info, NSFW_PS_HBT_FAILED);
+ /*reset counter */
+ pps_info->hbt_failed_count = 0;
}
- if (TRUE != nsfw_ps_send_hbt (pps_info))
+ if (TRUE != nsfw_ps_send_hbt(pps_info))
{
}
- if (pps_info->hbt_failed_count > 0)
+ struct timespec time_left = { NSFW_CHK_HBT_TVLAUE, 0 };
+ pps_info->hbt_timer_ptr =
+ (void *) nsfw_timer_reg_timer(NSFW_CHK_HBT_TIMER, data,
+ nsfw_ps_hbt_timeout, time_left);
+
+ if (pps_info->hbt_failed_count > 0)
{
- NSFW_LOGWAR ("Heartbeat failed]pid=%u,ps_count=%u, max_count=%d",
- pps_info->host_pid, pps_info->hbt_failed_count,
- NSFW_MAX_HBT_CHK_COUNT);
+ NSFW_LOGWAR("Heartbeat failed]pid=%u,ps_count=%u, max_count=%d",
+ pps_info->host_pid, pps_info->hbt_failed_count,
+ NSFW_MAX_HBT_CHK_COUNT);
+ log_sys_process_info();
}
- pps_info->hbt_failed_count++;
- struct timespec time_left = { NSFW_CHK_HBT_TVLAUE, 0 };
- pps_info->hbt_timer_ptr =
- (void *) nsfw_timer_reg_timer (NSFW_CHK_HBT_TIMER, data,
- nsfw_ps_hbt_timeout, time_left);
- return TRUE;
+ pps_info->hbt_failed_count++;
+ return TRUE;
}
/*****************************************************************************
@@ -1191,29 +1674,28 @@ nsfw_ps_hbt_timeout (u32 timer_type, void *data)
* Calls :
* Called By :
*****************************************************************************/
-u8
-nsfw_ps_hbt_start (nsfw_ps_info * pps_info)
+u8 nsfw_ps_hbt_start(nsfw_ps_info * pps_info)
{
- if (NULL == pps_info)
+ if (NULL == pps_info)
{
- NSFW_LOGERR ("null ps_info!");
- return FALSE;
+ NSFW_LOGERR("null ps_info");
+ return FALSE;
}
- if (NULL != pps_info->hbt_timer_ptr)
+ if (NULL != pps_info->hbt_timer_ptr)
{
- NSFW_LOGERR ("hbt start before!]ps_info=%p,pid=%u,type=%u", pps_info,
- pps_info->host_pid, pps_info->proc_type);
- return FALSE;
+ NSFW_LOGERR("hbt start before]ps_info=%p,pid=%u,type=%u", pps_info,
+ pps_info->host_pid, pps_info->proc_type);
+ return FALSE;
}
- struct timespec time_left = { NSFW_CHK_HBT_TVLAUE, 0 };
- pps_info->hbt_timer_ptr =
- (void *) nsfw_timer_reg_timer (NSFW_CHK_HBT_TIMER, (void *) pps_info,
- nsfw_ps_hbt_timeout, time_left);
- NSFW_LOGINF ("hbt start!]ps_info=%p,pid=%u,type=%u", pps_info,
- pps_info->host_pid, pps_info->proc_type);
- return TRUE;
+ struct timespec time_left = { NSFW_CHK_HBT_TVLAUE, 0 };
+ pps_info->hbt_timer_ptr =
+ (void *) nsfw_timer_reg_timer(NSFW_CHK_HBT_TIMER, (void *) pps_info,
+ nsfw_ps_hbt_timeout, time_left);
+ NSFW_LOGINF("hbt start]ps_info=%p,pid=%u,type=%u", pps_info,
+ pps_info->host_pid, pps_info->proc_type);
+ return TRUE;
}
/*****************************************************************************
@@ -1225,24 +1707,23 @@ nsfw_ps_hbt_start (nsfw_ps_info * pps_info)
* Calls :
* Called By :
*****************************************************************************/
-u8
-nsfw_ps_hbt_stop (nsfw_ps_info * pps_info)
+u8 nsfw_ps_hbt_stop(nsfw_ps_info * pps_info)
{
- if (NULL == pps_info)
+ if (NULL == pps_info)
{
- NSFW_LOGERR ("null ps_info!");
- return FALSE;
+ NSFW_LOGERR("null ps_info!");
+ return FALSE;
}
- if (NULL != pps_info->hbt_timer_ptr)
+ if (NULL != pps_info->hbt_timer_ptr)
{
- nsfw_timer_rmv_timer ((nsfw_timer_info *) pps_info->hbt_timer_ptr);
- pps_info->hbt_timer_ptr = NULL;
+ nsfw_timer_rmv_timer((nsfw_timer_info *) pps_info->hbt_timer_ptr);
+ pps_info->hbt_timer_ptr = NULL;
}
- NSFW_LOGINF ("hbt stop!]ps_info=%p,pid=%d,type=%d", pps_info,
- pps_info->host_pid, pps_info->proc_type);
- return TRUE;
+ NSFW_LOGINF("hbt stop!]ps_info=%p,pid=%u,type=%d", pps_info,
+ pps_info->host_pid, pps_info->proc_type);
+ return TRUE;
}
/*****************************************************************************
@@ -1255,33 +1736,31 @@ nsfw_ps_hbt_stop (nsfw_ps_info * pps_info)
* Calls :
* Called By :
*****************************************************************************/
-u32
-nsfw_ps_iterator (nsfw_ps_proc_fun fun, void *argv)
+u32 nsfw_ps_iterator(nsfw_ps_proc_fun fun, void *argv)
{
- u32 count = 0;
- nsfw_ps_info *pps_info = NULL;
- struct list_head *tNode;
+ u32 count = 0;
+ nsfw_ps_info *pps_info = NULL;
+ struct list_head *tNode;
- if (NULL == fun)
+ if (NULL == fun)
{
- NSFW_LOGERR ("fun null!");
- return count;
+ NSFW_LOGERR("fun null!");
+ return count;
}
- LINT_LIST ()list_for_each_entry (pps_info, tNode, (&g_ps_runing_list), node)
- {
- (void) fun (pps_info, argv);
- count++;
- }
+ list_for_each_entry(pps_info, tNode, (&g_ps_runing_list), node)
+ {
+ (void) fun(pps_info, argv);
+ count++;
+ }
- NSFW_LOGINF ("proc pid]count=%u", count);
- return count;
+ NSFW_LOGINF("proc pid]count=%u", count);
+ return count;
}
-int
-filter (const struct dirent *dir)
+int filter(const struct dirent *dir)
{
- return !fnmatch ("[1-9]*", dir->d_name, 0);
+ return !fnmatch("[1-9]*", dir->d_name, 0);
}
/*****************************************************************************
@@ -1293,37 +1772,36 @@ filter (const struct dirent *dir)
* Calls :
* Called By :
*****************************************************************************/
-inline nsfw_ps_info *
-nsfw_ps_realloc_pid (u32 pid, u8 realloc_flg)
+inline nsfw_ps_info *nsfw_ps_realloc_pid(u32 pid, u8 realloc_flg)
{
- nsfw_ps_info *pps_info = NULL;
- if (pid >= NSFW_MAX_PID)
+ nsfw_ps_info *pps_info = NULL;
+ if (pid >= NSFW_MAX_PID)
{
- return NULL;
+ return NULL;
}
- if (g_ps_info[pid].ps_info == NULL)
+ if (g_ps_info[pid].ps_info == NULL)
{
- return NULL;
+ return NULL;
}
- if (TRUE == realloc_flg)
+ if (TRUE == realloc_flg)
{
- pps_info = nsfw_ps_info_alloc (pid, g_ps_info[pid].proc_type);
- if (NULL == pps_info)
+ pps_info = nsfw_ps_info_alloc(pid, g_ps_info[pid].proc_type, 1);
+ if (NULL == pps_info)
{
- NSFW_LOGERR ("alloc ps_info failed!]pid=%u,type=%u", pid,
- g_ps_info[pid].proc_type);
- return NULL;
+ NSFW_LOGERR("alloc ps_info failed!]pid=%u,type=%u", pid,
+ g_ps_info[pid].proc_type);
+ return NULL;
}
}
- else
+ else
{
- pps_info = g_ps_info[pid].ps_info;
+ pps_info = g_ps_info[pid].ps_info;
}
- pps_info->rechk_flg = TRUE;
- return pps_info;
+ pps_info->rechk_flg = TRUE;
+ return pps_info;
}
/*****************************************************************************
@@ -1335,34 +1813,37 @@ nsfw_ps_realloc_pid (u32 pid, u8 realloc_flg)
* Calls :
* Called By :
*****************************************************************************/
-void
-nsfw_ps_reload_pid ()
+void nsfw_ps_reload_pid()
{
- struct dirent **namelist;
- i32 n;
- u32 host_pid;
- nsfw_ps_info *pps_info = NULL;
+ struct dirent **namelist;
+ i32 n;
+ u32 host_pid;
+ nsfw_ps_info *pps_info = NULL;
- n = scandir ("/proc", &namelist, filter, 0);
- if (n < 0)
+ n = scandir("/proc", &namelist, filter, 0);
+ if (n < 0)
{
- NSFW_LOGERR ("buf null");
+ NSFW_LOGERR("buf null");
}
- else
+ else
{
- while (n--)
+
+ while (n--)
{
- host_pid = strtol (namelist[n]->d_name, NULL, 10);
- pps_info = nsfw_ps_info_get (host_pid);
- if (NULL != pps_info)
+ host_pid = strtol(namelist[n]->d_name, NULL, 10);
+ pps_info = nsfw_ps_info_get(host_pid);
+ if ((NULL != pps_info) && /* There is a nStack app with this pid, and */
+ (nsfw_ps_get_starttime_from_file(host_pid) == nsfw_ps_get_starttime_from_info(host_pid) /* starttime is the same */
+ || 0 == nsfw_ps_get_starttime_from_info(host_pid)) /* or NA in earlier version of Master */
+ )
{
- pps_info->rechk_flg = FALSE;
+ pps_info->rechk_flg = FALSE;
}
- free (namelist[n]);
+ free(namelist[n]);
}
- free (namelist);
+ free(namelist);
}
- return;
+ return;
}
/*****************************************************************************
@@ -1374,19 +1855,18 @@ nsfw_ps_reload_pid ()
* Calls :
* Called By :
*****************************************************************************/
-void
-nsfw_ps_realloc_all_pid (u32 * main_pid, u8 realloc_flg)
+void nsfw_ps_realloc_all_pid(u32 * main_pid, u8 realloc_flg)
{
- u32 i;
- nsfw_ps_info *pps_info = NULL;
- for (i = 0; i < NSFW_MAX_PID; i++)
+ u32 i;
+ nsfw_ps_info *pps_info = NULL;
+ for (i = 0; i < NSFW_MAX_PID; i++)
{
- pps_info = nsfw_ps_realloc_pid (i, realloc_flg);
- if (NULL != main_pid)
+ pps_info = nsfw_ps_realloc_pid(i, realloc_flg);
+ if (NULL != main_pid)
{
- if (NULL != pps_info && NSFW_PROC_MAIN == pps_info->proc_type)
+ if (NULL != pps_info && NSFW_PROC_MAIN == pps_info->proc_type)
{
- (*main_pid) = i;
+ (*main_pid) = i;
}
}
}
@@ -1402,49 +1882,48 @@ nsfw_ps_realloc_all_pid (u32 * main_pid, u8 realloc_flg)
* Calls :
* Called By :
*****************************************************************************/
-int
-nsfw_ps_chk_exit_timeout (u32 timer_type, void *data)
+int nsfw_ps_chk_exit_timeout(u32 timer_type, void *data)
{
- u32 i;
- nsfw_ps_info *pps_info = NULL;
- u32 pid = (u64) data;
+ u32 i;
+ nsfw_ps_info *pps_info = NULL;
+ u32 pid = (u64) data;
- /*main pid exit first */
- if (NULL != data)
+ /*main pid exit first */
+ if (NULL != data)
{
- pps_info = nsfw_ps_info_get (pid);
- if (NULL != pps_info && TRUE == pps_info->rechk_flg)
+ pps_info = nsfw_ps_info_get(pid);
+ if (NULL != pps_info && TRUE == pps_info->rechk_flg)
{
- if (NSFW_PS_EXITING != pps_info->state)
+ if (NSFW_PS_EXITING != pps_info->state)
{
- NSFW_LOGWAR ("rechk pid exit]ps_info=%p,pid=%u", pps_info,
- pps_info->host_pid);
- (void) nsfw_sw_ps_state (pps_info, NSFW_PS_EXITING);
- pps_info->rechk_flg = FALSE;
+ NSFW_LOGWAR("rechk pid exit]ps_info=%p,pid=%u", pps_info,
+ pps_info->host_pid);
+ (void) nsfw_sw_ps_state(pps_info, NSFW_PS_EXITING);
+ pps_info->rechk_flg = FALSE;
}
}
}
- for (i = 0; i < NSFW_MAX_PID; i++)
+ for (i = 0; i < NSFW_MAX_PID; i++)
{
- pps_info = nsfw_ps_info_get (i);
- if (NULL != pps_info && TRUE == pps_info->rechk_flg)
+ pps_info = nsfw_ps_info_get(i);
+ if (NULL != pps_info && TRUE == pps_info->rechk_flg)
{
- if (NSFW_PS_EXITING == pps_info->state)
+ if (NSFW_PS_EXITING == pps_info->state)
{
- NSFW_LOGWAR ("double pid info]ps_info=%p,pid=%u", pps_info,
- pps_info->host_pid);
- continue;
+ NSFW_LOGWAR("double pid info]ps_info=%p,pid=%u", pps_info,
+ pps_info->host_pid);
+ continue;
}
- NSFW_LOGWAR ("rechk pid exit]ps_info=%p,pid=%u", pps_info,
- pps_info->host_pid);
- (void) nsfw_sw_ps_state (pps_info, NSFW_PS_EXITING);
- pps_info->rechk_flg = FALSE;
+ NSFW_LOGWAR("rechk pid exit]ps_info=%p,pid=%u", pps_info,
+ pps_info->host_pid);
+ (void) nsfw_sw_ps_state(pps_info, NSFW_PS_EXITING);
+ pps_info->rechk_flg = FALSE;
}
}
- return TRUE;
+ return TRUE;
}
/*****************************************************************************
@@ -1456,27 +1935,44 @@ nsfw_ps_chk_exit_timeout (u32 timer_type, void *data)
* Return Value : int
* Calls :
* Called By :
-****************************************************************************/
-int
-nsfw_ps_chk_timeout (u32 timer_type, void *data)
+*****************************************************************************/
+int nsfw_ps_chk_timeout(u32 timer_type, void *data)
{
- u32 main_pid = 0;
- u8 realloc_flg = (u8) (u64) data;
-
- nsfw_ps_realloc_all_pid (&main_pid, realloc_flg);
- nsfw_ps_reload_pid ();
-
- struct timespec time_left = { NSFW_PS_CHK_EXIT_TVLAUE, 0 };
- g_ps_chk_timer =
- (void *) nsfw_timer_reg_timer (NSFW_PS_CHK_EXIT_TVLAUE,
- (void *) (u64) main_pid,
- nsfw_ps_chk_exit_timeout, time_left);
- return TRUE;
+ u32 main_pid = 0;
+ u8 realloc_flg = (u8) (u64) data;
+
+ nsfw_ps_realloc_all_pid(&main_pid, realloc_flg);
+ nsfw_ps_reload_pid();
+
+ struct timespec time_left = { NSFW_PS_CHK_EXIT_TVLAUE, 0 };
+ g_ps_chk_timer =
+ (void *) nsfw_timer_reg_timer(NSFW_PS_CHK_EXIT_TVLAUE,
+ (void *) (u64) main_pid,
+ nsfw_ps_chk_exit_timeout, time_left);
+ return TRUE;
+}
+
+int nsfw_ps_check_pid_nstack_status(int pid)
+{
+
+ if (pid < 0 || pid >= NSFW_MAX_PID)
+ {
+ NSFW_LOGWAR("get wrong pid :%d", pid);
+ return -1;
+ }
+
+ if (NULL == g_master_ps_info[pid].ps_info)
+ {
+ return -1;
+ }
+
+ /* pid is using nstack */
+ return 0;
}
/*****************************************************************************
* Prototype : nsfw_ps_rechk_pid_exit
-* Description : recheck pid exit
+* Description : rechck pid exit
* Input : nsfw_ps_proc_fun fun
* void* argv
* Output : None
@@ -1484,203 +1980,329 @@ nsfw_ps_chk_timeout (u32 timer_type, void *data)
* Calls :
* Called By :
*****************************************************************************/
-int
-nsfw_ps_rechk_pid_exit (nsfw_ps_pid_fun fun, void *argv)
+int nsfw_ps_rechk_pid_exit(nsfw_ps_pid_fun fun, void *argv)
{
- u32 ulI = 0;
- if (NULL == fun)
+
+ u32 ulI = 0;
+ if (NULL == fun)
{
- NSFW_LOGERR ("input err! fun null");
- return -1;
+ NSFW_LOGERR("input err! fun null");
+ return -1;
}
- u8 *ps_pid = malloc (NSFW_MAX_PID);
- if (NULL == ps_pid)
+ u8 *ps_pid = malloc(NSFW_MAX_PID);
+ if (NULL == ps_pid)
{
- NSFW_LOGERR ("malloc failed");
- return -1;
+ NSFW_LOGERR("malloc failed");
+ return -1;
}
- int retval = MEMSET_S (ps_pid, NSFW_MAX_PID, 0, NSFW_MAX_PID);
- if (EOK != retval)
+ int retval = memset_s(ps_pid, NSFW_MAX_PID, 0, NSFW_MAX_PID);
+ if (EOK != retval)
{
- NSFW_LOGERR ("MEMSET_S failed]retval=%d", retval);
- free (ps_pid);
- return -1;
+ NSFW_LOGERR("memset_s failed]retval=%d", retval);
+ free(ps_pid);
+ return -1;
}
- struct dirent **namelist;
- i32 n;
- u32 host_pid;
- n = scandir ("/proc", &namelist, filter, 0);
- if (n < 0)
+ struct dirent **namelist;
+ i32 n;
+ u32 host_pid;
+ n = scandir("/proc", &namelist, filter, 0);
+ if (n < 0)
{
- NSFW_LOGERR ("buf null");
- free (ps_pid);
- return -1;
+ NSFW_LOGERR("buf null");
+ free(ps_pid);
+ return -1;
}
- while (n--)
+ while (n--)
{
- host_pid = strtol (namelist[n]->d_name, NULL, 10);
- if (host_pid < NSFW_MAX_PID)
+ host_pid = strtol(namelist[n]->d_name, NULL, 10);
+ /* here should use host_pid as ps_pid's index */
+ if (host_pid < NSFW_MAX_PID)
{
- ps_pid[ulI] = TRUE;
+ ps_pid[host_pid] = TRUE;
}
- free (namelist[n]);
+ free(namelist[n]);
+ namelist[n] = NULL;
}
- free (namelist);
+ free(namelist);
- int count = 0;
- for (ulI = 0; ulI < NSFW_MAX_PID; ulI++)
+ int count = 0;
+ for (ulI = 0; ulI < NSFW_MAX_PID; ulI++)
{
- if ((NULL != g_master_ps_info[ulI].ps_info) && (FALSE == ps_pid[ulI]))
+ if ((NULL != g_master_ps_info[ulI].ps_info) && (FALSE == ps_pid[ulI]))
{
- (void) fun (ulI, g_master_ps_info[ulI].proc_type, argv);
- NSFW_LOGWAR ("rechk pid exit]pid=%d,type=%d", ulI,
- g_master_ps_info[ulI].proc_type);
- count++;
- continue;
+ (void) fun(ulI, g_master_ps_info[ulI].proc_type, argv);
+ NSFW_LOGWAR("rechk pid exit]ulI=%u,type=%d", ulI,
+ g_master_ps_info[ulI].proc_type);
+ count++;
+ continue;
}
}
- free (ps_pid);
- return count;
+ free(ps_pid);
+ return count;
}
-void
-nsfw_ps_cfg_set_chk_count (u16 count)
+void nsfw_ps_cfg_set_chk_count(u16 count)
{
- g_ps_cfg.ps_chk_hbt_count = count;
+ g_ps_cfg.ps_chk_hbt_count = count;
}
-/*****************************************************************************
-* Prototype : nsfw_ps_module_init
-* Description : ps_module init
-* Input : void* param
-* Output : None
-* Return Value : static int
-* Calls :
-* Called By :
-*****************************************************************************/
-int
-nsfw_ps_module_init (void *param)
+u64 nsfw_ps_get_starttime_from_file(u32 pid)
{
- u32 proc_type = (u32) ((long long) param);
- nsfw_ps_init_cfg *ps_cfg = &g_ps_cfg;
- int retval;
- nsfw_pid_item *pid_info = NULL;
- NSFW_LOGINF ("ps module init]type=%u", proc_type);
-
- ps_cfg->ps_chk_hbt_count = NSFW_MAX_HBT_CHK_COUNT_DEF;
- ps_cfg->ps_chk_hbt_tvalue = NSFW_CHK_HBT_TVLAUE_DEF;
- ps_cfg->ps_chk_hbt_soft_count = ps_cfg->ps_chk_hbt_count;
-
- nsfw_mem_zone pzoneinfo;
- pzoneinfo.isocket_id = NSFW_SOCKET_ANY;
- pzoneinfo.stname.entype = NSFW_SHMEM;
- pzoneinfo.length = sizeof (nsfw_pid_item) * NSFW_MAX_PID;
- if (-1 ==
- SPRINTF_S (pzoneinfo.stname.aname, NSFW_MEM_NAME_LENGTH, "%s",
- "MAS_PS_INFO"))
- {
- NSFW_LOGERR ("SPRINTF_S failed]");
- return -1;
- }
-
- switch (proc_type)
- {
- case NSFW_PROC_MAIN:
- {
- pid_info = malloc (sizeof (nsfw_pid_item) * NSFW_MAX_PID);
- if (NULL == pid_info)
- {
- NSFW_LOGERR ("malloc mem failed!");
- return -1;
- }
-
- retval =
- MEMSET_S (pid_info, (sizeof (nsfw_pid_item) * NSFW_MAX_PID), 0,
- (sizeof (nsfw_pid_item) * NSFW_MAX_PID));
- if (EOK != retval)
- {
- NSFW_LOGERR ("MEMSET_S failed]retval=%d.\n", retval);
- free (pid_info);
- return -1;
- }
+ if (pid > NSFW_MAX_PID)
+ {
+ NSFW_LOGERR("Invalid pid=%u", pid);
+ return 0;
+ }
+
+ char str[20];
+ if (sprintf_s(str, sizeof(str), "/proc/%u/stat", pid) < 0)
+ {
+ NSFW_LOGERR("sprintf_s failed, pid=%u", pid);
+ return 0;
+ }
+
+ FILE *psfile = fopen(str, "r");
+ if (NULL == psfile)
+ {
+ NSFW_LOGERR("fopen /proc/%u/stat failed", pid);
+ return 0;
+ }
+
+ u64 starttime = 0;
+ const char PROC_PID_STAT_FORMAT_GET_STARTTIME_ONLY[] = "%*d " /* 1. pid */
+ "%*s " /* 2. filename of exe */
+ "%*c " /* 3. state */
+ "%*d " /* 4. ppid */
+ "%*d " /* 5. process group */
+ "%*d " /* 6. session ID */
+ "%*d " /* 7. tty_nr */
+ "%*d " /* 8. tpgid */
+ "%*u " /* 9. flags */
+ "%*u " /* 10. minflt */
+ "%*u " /* 11. cminflt */
+ "%*u " /* 12. majflt */
+ "%*u " /* 13. cmajflt */
+ "%*u " /* 14. utime */
+ "%*u " /* 15. stime */
+ "%*d " /* 16. cuttime */
+ "%*d " /* 17. cstime */
+ "%*d " /* 18. priority */
+ "%*d " /* 19. nice */
+ "%*d " /* 20. num_threads */
+ "%*d " /* 21. NA since Linux 2.6 */
+ "%llu"; /* 22. starttime, we need this field */
+
+ int ret;
+ if ((ret =
+ fscanf_s(psfile, PROC_PID_STAT_FORMAT_GET_STARTTIME_ONLY,
+ &starttime)) != 1)
+ {
+ NSFW_LOGERR("fscanf_s /proc/%u/stat failed, ret=%d, errno=%d", pid,
+ ret, errno);
+ fclose(psfile); /*no need to check return */
+ return 0;
+ }
+
+ NSFW_LOGDBG("pid:%u, starttime:%llu", pid, starttime);
+ fclose(psfile); /*no need to check return */
+ return starttime;
+}
- g_ps_info = pid_info;
+u64 nsfw_ps_get_starttime_from_info(u32 pid)
+{
+ return (u64) (g_ps_info[pid].starttime);
+}
- pzoneinfo.stname.enowner = NSFW_PROC_MAIN;
- pid_info = nsfw_mem_zone_create (&pzoneinfo);
- if (NULL == pid_info)
- {
- NSFW_LOGERR ("create pid_info failed!");
- return -1;
- }
+int nsfw_ps_module_init(void *param)
+{
+ u32 proc_type = (u32) ((long long) param);
+ nsfw_ps_init_cfg *ps_cfg = &g_ps_cfg;
+ int retval;
+ nsfw_pid_item *pid_info = NULL;
+ enum_alarm_id loop_alarm_id = ALARM_EVENT_BASE;
- g_master_ps_info = pid_info;
- break;
- }
- default:
- return 0;
- }
+ NSFW_LOGINF("ps module init]type=%u", proc_type);
- ps_cfg->ps_info_size = NSFW_PS_INFO_MAX_COUNT;
- ps_cfg->ps_waite_exit_tvalue = NSFW_PS_WEXIT_TVLAUE_DEF;
- ps_cfg->net_link_buf = MAX_NET_LINK_BUF_DEF;
+ ps_cfg->ps_chk_hbt_count = NSFW_MAX_HBT_CHK_COUNT_DEF;
+ ps_cfg->ps_chk_hbt_tvalue = NSFW_CHK_HBT_TVLAUE_DEF;
+ ps_cfg->ps_chk_hbt_soft_count = ps_cfg->ps_chk_hbt_count;
- INIT_LIST_HEAD (&(g_ps_runing_list));
+ nsfw_mem_zone pzoneinfo;
+ pzoneinfo.isocket_id = NSFW_SOCKET_ANY;
+ pzoneinfo.stname.entype = NSFW_SHMEM;
+ pzoneinfo.lenth = sizeof(nsfw_pid_item) * NSFW_MAX_PID;
+ if (-1 ==
+ sprintf_s(pzoneinfo.stname.aname, NSFW_MEM_NAME_LENTH, "%s",
+ "MAS_PS_INFO"))
+ {
+ NSFW_LOGERR("sprintf_s failed]");
+ return -1;
+ }
- nsfw_mem_sppool pmpinfo;
- pmpinfo.enmptype = NSFW_MRING_MPMC;
- pmpinfo.usnum = ps_cfg->ps_info_size;
- pmpinfo.useltsize = sizeof (nsfw_ps_info);
- pmpinfo.isocket_id = NSFW_SOCKET_ANY;
- pmpinfo.stname.entype = NSFW_NSHMEM;
- if (-1 ==
- SPRINTF_S (pmpinfo.stname.aname, NSFW_MEM_NAME_LENGTH, "%s",
- "MAS_PS_INFOPOOL"))
+ switch (proc_type)
{
- NSFW_LOGERR ("SPRINTF_S failed]");
- return -1;
+ case NSFW_PROC_MASTER:
+ {
+ (void) nsfw_mgr_reg_msg_fun(MGR_MSG_CHK_HBT_RSP,
+ nsfw_ps_recv_hbt_rsp);
+ (void) nsfw_mgr_reg_msg_fun(MGR_MSG_CHK_INIT_REQ,
+ nsfw_ps_recv_hbt);
+ (void) nsfw_mgr_reg_msg_fun(MGR_MSG_CHK_HBT_REQ,
+ nsfw_ps_recv_hbt);
+ (void) NSFW_REG_SOFT_INT(NSFW_HBT_TIMER, NSFW_CHK_HBT_TVLAUE,
+ 1, 0xFFFF);
+ (void) NSFW_REG_SOFT_INT(NSFW_HBT_COUNT_PARAM,
+ NSFW_SOFT_HBT_CHK_COUNT, 1, 0xFFFF);
+ (void) NSFW_REG_SOFT_INT(NSFW_APP_EXIT_TIMER,
+ NSFW_PS_WEXIT_TVLAUE, 1, 0xFFFF);
+
+ pid_info = nsfw_mem_zone_lookup(&pzoneinfo.stname);
+ if (NULL == pid_info)
+ {
+ pid_info = nsfw_mem_zone_create(&pzoneinfo);
+ if (NULL == pid_info)
+ {
+ NSFW_LOGERR("alloc rec nul!");
+ return -1;
+ }
+
+ retval =
+ memset_s(pid_info,
+ (sizeof(nsfw_pid_item) * NSFW_MAX_PID), 0,
+ (sizeof(nsfw_pid_item) * NSFW_MAX_PID));
+ if (EOK != retval)
+ {
+ NSFW_LOGERR("memset_s failed]retval=%d.\n", retval);
+ return -1;
+ }
+ }
+ g_master_ps_info = pid_info;
+
+ MEM_STAT(NSFW_PS_MODULE, pzoneinfo.stname.aname, NSFW_SHMEM,
+ pzoneinfo.lenth);
+ g_ps_info = pid_info;
+
+ for (loop_alarm_id = ALARM_EVENT_BASE;
+ loop_alarm_id < ALARM_EVENT_MAX; loop_alarm_id++)
+ {
+ g_omc_alm_state[loop_alarm_id].send_succ_flag = 1;
+ g_omc_alm_state[loop_alarm_id].current_alarm_state =
+ ALARM_CLEAN;
+ g_omc_alm_state[loop_alarm_id].resend_timer = NULL;
+ }
+
+ break;
+ }
+ case NSFW_PROC_MAIN:
+ {
+
+ (void) nsfw_mgr_reg_msg_fun(MGR_MSG_CHK_INIT_REQ,
+ nsfw_ps_recv_hbt);
+ (void) nsfw_mgr_reg_msg_fun(MGR_MSG_CHK_HBT_REQ,
+ nsfw_ps_recv_hbt);
+ pid_info = malloc(sizeof(nsfw_pid_item) * NSFW_MAX_PID);
+ if (NULL == pid_info)
+ {
+ NSFW_LOGERR("malloc mem failed!");
+ return -1;
+ }
+
+ retval =
+ memset_s(pid_info,
+ (sizeof(nsfw_pid_item) * NSFW_MAX_PID), 0,
+ (sizeof(nsfw_pid_item) * NSFW_MAX_PID));
+ if (EOK != retval)
+ {
+ NSFW_LOGERR("memset_s failed]retval=%d.\n", retval);
+ free(pid_info);
+ return -1;
+ }
+
+ g_ps_info = pid_info;
+
+ pzoneinfo.stname.enowner = NSFW_PROC_MASTER;
+ pid_info = nsfw_mem_zone_lookup(&pzoneinfo.stname);
+ if (NULL == pid_info)
+ {
+ NSFW_LOGERR("lookup pid_info failed!");
+ return -1;
+ }
+
+ g_master_ps_info = pid_info;
+ break;
+ }
+ default:
+ return 0;
}
- ps_cfg->ps_info_pool = nsfw_mem_sp_create (&pmpinfo);
+ ps_cfg->ps_info_size = NSFW_PS_INFO_MAX_COUNT;
+ ps_cfg->ps_waite_exit_tvalue = NSFW_PS_WEXIT_TVLAUE_DEF;
+ ps_cfg->net_link_buf = MAX_NET_LINK_BUF_DEF;
- if (!ps_cfg->ps_info_pool)
+ INIT_LIST_HEAD(&(g_ps_runing_list));
+
+ nsfw_mem_sppool pmpinfo;
+ pmpinfo.enmptype = NSFW_MRING_MPMC;
+ pmpinfo.usnum = ps_cfg->ps_info_size;
+ pmpinfo.useltsize = sizeof(nsfw_ps_info);
+ pmpinfo.isocket_id = NSFW_SOCKET_ANY;
+ pmpinfo.stname.entype = NSFW_NSHMEM;
+ if (-1 ==
+ sprintf_s(pmpinfo.stname.aname, NSFW_MEM_NAME_LENTH, "%s",
+ "MAS_PS_INFOPOOL"))
{
- NSFW_LOGERR ("alloc ps info pool_err");
- return -1;
+ NSFW_LOGERR("sprintf_s failed]");
+ return -1;
}
+ ps_cfg->ps_info_pool = nsfw_mem_sp_create(&pmpinfo);
- MEM_STAT (NSFW_PS_MODULE, pmpinfo.stname.aname, NSFW_NSHMEM,
- nsfw_mem_get_len (ps_cfg->ps_info_pool, NSFW_MEM_SPOOL));
+ if (!ps_cfg->ps_info_pool)
+ {
+ NSFW_LOGERR("alloc ps info pool_err");
+ return -1;
+ }
+
+ MEM_STAT(NSFW_PS_MODULE, pmpinfo.stname.aname, NSFW_NSHMEM,
+ nsfw_mem_get_len(ps_cfg->ps_info_pool, NSFW_MEM_SPOOL));
- if (NSFW_PROC_MAIN != proc_type)
+ if (NSFW_PROC_MASTER != proc_type)
{
- return 0;
+ return 0;
}
- struct timespec time_left = { NSFW_PS_FIRST_CHK_TVLAUE, 0 };
- g_ps_chk_timer =
- (void *) nsfw_timer_reg_timer (NSFW_PS_CHK_TIMER, (void *) TRUE,
- nsfw_ps_chk_timeout, time_left);
+ struct timespec time_left = { NSFW_PS_FIRST_CHK_TVLAUE, 0 };
+ g_ps_chk_timer = (void *) nsfw_timer_reg_timer(NSFW_PS_CHK_TIMER, (void *) TRUE, /* the first call will re-alloc all pid */
+ nsfw_ps_chk_timeout,
+ time_left);
+ /* There may be latency from process exiting to /proc being updated, Master needs to check multiple times */
+ int itv;
+ for (itv = 1; itv < 5; itv++)
+ {
+ time_left.tv_sec += itv; /* increasing interval */
+ g_ps_chk_timer = (void *) nsfw_timer_reg_timer(NSFW_PS_CHK_TIMER, (void *) FALSE, /* the latter calls should not re-alloc */
+ nsfw_ps_chk_timeout,
+ time_left);
+ }
- if (TRUE != nsfw_ps_start_netlink ())
+ if (TRUE != nsfw_ps_start_netlink())
{
- return -1;
+ return -1;
}
- return 0;
+ return 0;
}
/* *INDENT-OFF* */
-NSFW_MODULE_NAME (NSFW_PS_MODULE)
-NSFW_MODULE_PRIORITY (10)
-NSFW_MODULE_DEPENDS (NSFW_MGR_COM_MODULE)
-NSFW_MODULE_DEPENDS (NSFW_TIMER_MODULE)
-NSFW_MODULE_INIT (nsfw_ps_module_init)
+NSFW_MODULE_NAME(NSFW_PS_MODULE)
+NSFW_MODULE_PRIORITY(10)
+NSFW_MODULE_DEPENDS(NSFW_MGR_COM_MODULE)
+NSFW_MODULE_DEPENDS(NSFW_TIMER_MODULE)
+NSFW_MODULE_INIT(nsfw_ps_module_init)
/* *INDENT-ON* */
#ifdef __cplusplus
diff --git a/src/framework/ipc/ps/nsfw_ps_module.h b/src/framework/ipc/ps/nsfw_ps_module.h
index b754cea..ce2db13 100644
--- a/src/framework/ipc/ps/nsfw_ps_module.h
+++ b/src/framework/ipc/ps/nsfw_ps_module.h
@@ -29,10 +29,6 @@ extern "C"{
/*==============================================*
* constants or macros define *
*----------------------------------------------*/
-
-#define NSFW_MAX_PID 65535
-COMPAT_PROTECT (NSFW_MAX_PID, 65535);
-
#define NSFW_PS_INFO_MAX_COUNT 4095
#define MAX_NET_LINK_BUF_DEF 0x34000*32
@@ -44,15 +40,15 @@ COMPAT_PROTECT (NSFW_MAX_PID, 65535);
typedef struct _nsfw_ps_init_cfg
{
- u32 ps_info_size;
- u32 net_link_buf;
+ u32 ps_info_size;
+ u32 net_link_buf;
- u16 ps_waite_exit_tvalue;
- u16 ps_chk_hbt_count;
- u16 ps_chk_hbt_soft_count;
- u16 ps_chk_hbt_tvalue;
+ u16 ps_waite_exit_tvalue;
+ u16 ps_chk_hbt_count;
+ u16 ps_chk_hbt_soft_count;
+ u16 ps_chk_hbt_tvalue;
- mring_handle ps_info_pool;
+ mring_handle ps_info_pool;
} nsfw_ps_init_cfg;
#define NSFW_PS_CHK_TIMER 1
@@ -61,22 +57,24 @@ typedef struct _nsfw_ps_init_cfg
typedef struct _nsfw_pid_item
{
- u8 proc_type;
- u8 u8_reserve;
- u16 u16_reserve;
- u32 u32_reserve;
- nsfw_ps_info *ps_info;
+ u8 proc_type;
+ u8 u8_reserve;
+ u16 u16_reserve;
+ u32 starttime;
+ nsfw_ps_info *ps_info;
} nsfw_pid_item;
-int nsfw_ps_change_fun (i32 epfd, i32 socket, u32 events);
-u8 nsfw_sw_ps_state (nsfw_ps_info * pps_info, u8 new_state);
+u32 get_ps_exiting_cnt();
+
+int nsfw_ps_change_fun(i32 epfd, i32 socket, u32 events);
+u8 nsfw_sw_ps_state(nsfw_ps_info * pps_info, u8 new_state);
/* for heartbeat checking*/
#define NSFW_MAX_THREAD_DOGS_COUNT 8
#define NSFW_CHK_HBT_TIMER 1
#define NSFW_MAX_HBT_PROC_FUN 4
-#define NSFW_CHK_HBT_TVLAUE_DEF 1
+#define NSFW_CHK_HBT_TVLAUE_DEF 3
#define NSFW_MAX_HBT_CHK_COUNT (g_ps_cfg.ps_chk_hbt_count)
#define NSFW_SOFT_HBT_CHK_COUNT (g_ps_cfg.ps_chk_hbt_soft_count)
@@ -84,11 +82,11 @@ u8 nsfw_sw_ps_state (nsfw_ps_info * pps_info, u8 new_state);
typedef struct _nsfw_ps_chk_msg
{
- u32 ps_state;
- i32 thread_chk_count;
+ u32 ps_state;
+ i32 thread_chk_count;
} nsfw_ps_chk_msg;
-int nsfw_ps_chk_timeout (u32 timer_type, void *data);
+int nsfw_ps_chk_timeout(u32 timer_type, void *data);
#ifdef __cplusplus
/* *INDENT-OFF* */
diff --git a/src/framework/ipc/ps/nsfw_recycle_module.c b/src/framework/ipc/ps/nsfw_recycle_module.c
index 01e16fb..06d7dd5 100644
--- a/src/framework/ipc/ps/nsfw_recycle_module.c
+++ b/src/framework/ipc/ps/nsfw_recycle_module.c
@@ -17,7 +17,7 @@
#include <stdlib.h>
#include "types.h"
#include "nstack_securec.h"
-#include "nsfw_init.h"
+#include "nsfw_init_api.h"
#include "nsfw_mgr_com_api.h"
#include "nsfw_mem_api.h"
@@ -27,7 +27,6 @@
#include "nsfw_recycle_module.h"
#include "nsfw_maintain_api.h"
#include "nstack_log.h"
-#include "common_mem_api.h"
#ifdef __cplusplus
/* *INDENT-OFF* */
@@ -35,7 +34,7 @@ extern "C"{
/* *INDENT-ON* */
#endif /* __cplusplus */
-/* only work on nStackMain*/
+/* only work on daemon-stack*/
nsfw_recycle_cfg g_rec_cfg;
nsfw_recycle_fun g_rec_fun[NSFW_REC_TYPE_MAX] = { 0 };
@@ -44,7 +43,7 @@ nsfw_rec_fun_info g_rec_lock_fun[NSFW_REC_LOCK_REL_MAX_FUN];
/*****************************************************************************
* Prototype : nsfw_recycle_reg_fun
-* Description : reg one recycle type recycle function
+* Description : reg one recycle type recycle funciton
* Input : u16 rec_type
* nsfw_recycle_fun fun
* Output : None
@@ -52,18 +51,17 @@ nsfw_rec_fun_info g_rec_lock_fun[NSFW_REC_LOCK_REL_MAX_FUN];
* Calls :
* Called By :
*****************************************************************************/
-u8
-nsfw_recycle_reg_fun (u16 rec_type, nsfw_recycle_fun fun)
+u8 nsfw_recycle_reg_fun(u16 rec_type, nsfw_recycle_fun fun)
{
- if (NULL == fun || rec_type >= NSFW_REC_TYPE_MAX)
+ if (NULL == fun || rec_type >= NSFW_REC_TYPE_MAX)
{
- NSFW_LOGERR ("argv err]fun=%p,type=%u", fun, rec_type);
- return FALSE;
+ NSFW_LOGERR("argv err]fun=%p,type=%u", fun, rec_type);
+ return FALSE;
}
- g_rec_fun[rec_type] = fun;
- NSFW_LOGINF ("reg]fun=%d,type=%u", fun, rec_type);
- return TRUE;
+ g_rec_fun[rec_type] = fun;
+ NSFW_LOGINF("reg]fun=%p,type=%u", fun, rec_type);
+ return TRUE;
}
/*****************************************************************************
@@ -77,31 +75,30 @@ nsfw_recycle_reg_fun (u16 rec_type, nsfw_recycle_fun fun)
* Calls :
* Called By :
*****************************************************************************/
-u8
-nsfw_recycle_lock_rel_fun (nsfw_recycle_fun fun, void *data, u8 proc_type)
+u8 nsfw_recycle_lock_rel_fun(nsfw_recycle_fun fun, void *data, u8 proc_type)
{
- if (NULL == fun)
+ if (NULL == fun)
{
- NSFW_LOGERR ("argv err]fun=%p,data=%p", fun, data);
- return FALSE;
+ NSFW_LOGERR("argv err]fun=%p,data=%p", fun, data);
+ return FALSE;
}
- u32 i;
+ u32 i;
- for (i = 0; i < NSFW_REC_LOCK_REL_MAX_FUN; i++)
+ for (i = 0; i < NSFW_REC_LOCK_REL_MAX_FUN; i++)
{
- if (NULL == g_rec_lock_fun[i].rec_fun)
+ if (NULL == g_rec_lock_fun[i].rec_fun)
{
- g_rec_lock_fun[i].rec_fun = fun;
- g_rec_lock_fun[i].data = data;
- g_rec_lock_fun[i].proc_type = proc_type;
- NSFW_LOGINF ("reg mgr_msg fun suc]fun=%p,data=%p", fun, data);
- return TRUE;
+ g_rec_lock_fun[i].rec_fun = fun;
+ g_rec_lock_fun[i].data = data;
+ g_rec_lock_fun[i].proc_type = proc_type;
+ NSFW_LOGINF("reg mgr_msg fun suc]fun=%p,data=%p", fun, data);
+ return TRUE;
}
}
- NSFW_LOGINF ("reg]fun=%p,data=%p", fun, data);
- return TRUE;
+ NSFW_LOGINF("reg]fun=%p,data=%p", fun, data);
+ return TRUE;
}
/*****************************************************************************
@@ -113,26 +110,25 @@ nsfw_recycle_lock_rel_fun (nsfw_recycle_fun fun, void *data, u8 proc_type)
* Calls :
* Called By :
*****************************************************************************/
-int
-nsfw_recycle_exit_pid_lock (u32 pid, u8 proc_type, void *argv)
+int nsfw_recycle_exit_pid_lock(u32 pid, u8 proc_type, void *argv)
{
- u32 i;
- NSFW_LOGINF ("release lock]pid=%d,type=%d", pid, proc_type);
- for (i = 0; i < NSFW_REC_LOCK_REL_MAX_FUN; i++)
+ u32 i;
+ NSFW_LOGINF("release lock]pid=%u,type=%d", pid, proc_type);
+ for (i = 0; i < NSFW_REC_LOCK_REL_MAX_FUN; i++)
{
- if (NULL == g_rec_lock_fun[i].rec_fun)
+ if (NULL == g_rec_lock_fun[i].rec_fun)
{
- break;
+ break;
}
- if ((NSFW_PROC_NULL == g_rec_lock_fun[i].proc_type)
- || (proc_type == g_rec_lock_fun[i].proc_type))
+ if ((NSFW_PROC_NULL == g_rec_lock_fun[i].proc_type)
+ || (proc_type == g_rec_lock_fun[i].proc_type))
{
- (void) g_rec_lock_fun[i].rec_fun (pid, g_rec_lock_fun[i].data, 0);
+ (void) g_rec_lock_fun[i].rec_fun(pid, g_rec_lock_fun[i].data, 0);
}
}
- return 0;
+ return 0;
}
/*****************************************************************************
@@ -144,23 +140,22 @@ nsfw_recycle_exit_pid_lock (u32 pid, u8 proc_type, void *argv)
* Calls :
* Called By :
*****************************************************************************/
-u8
-nsfw_recycle_obj_end (u32 pid)
+u8 nsfw_recycle_obj_end(u32 pid)
{
- nsfw_mgr_msg *rsp_msg =
- nsfw_mgr_msg_alloc (MGR_MSG_RCC_END_REQ, NSFW_PROC_MAIN);
- if (NULL == rsp_msg)
+ nsfw_mgr_msg *rsp_msg =
+ nsfw_mgr_msg_alloc(MGR_MSG_RCC_END_REQ, NSFW_PROC_MAIN);
+ if (NULL == rsp_msg)
{
- NSFW_LOGERR ("alloc rsp msg failed]pid=%u", pid);
- return FALSE;
+ NSFW_LOGERR("alloc rsp msg failed]pid=%u", pid);
+ return FALSE;
}
- nsfw_ps_info_msg *ps_msg = GET_USER_MSG (nsfw_ps_info_msg, rsp_msg);
- ps_msg->host_pid = pid;
- (void) nsfw_mgr_send_msg (rsp_msg);
- nsfw_mgr_msg_free (rsp_msg);
- NSFW_LOGINF ("send obj end msg]pid=%d", pid);
- return TRUE;
+ nsfw_ps_info_msg *ps_msg = GET_USER_MSG(nsfw_ps_info_msg, rsp_msg);
+ ps_msg->host_pid = pid;
+ (void) nsfw_mgr_send_msg(rsp_msg);
+ nsfw_mgr_msg_free(rsp_msg);
+ NSFW_LOGINF("send obj end msg]pid=%u", pid);
+ return TRUE;
}
/*****************************************************************************
@@ -173,74 +168,74 @@ nsfw_recycle_obj_end (u32 pid)
* Calls :
* Called By :
*****************************************************************************/
-nsfw_rcc_stat
-nsfw_recycle_callback_all_obj (u32 pid, nsfw_recycle_pool * rec_pool)
+nsfw_rcc_stat nsfw_recycle_callback_all_obj(u32 pid,
+ nsfw_recycle_pool * rec_pool)
{
- u32 match = 0;
- nsfw_recycle_obj *obj = NULL;
- if (NULL == rec_pool)
+ u32 match = 0;
+ nsfw_recycle_obj *obj = NULL;
+ if (NULL == rec_pool)
{
- return NSFW_RCC_CONTINUE;
+ return NSFW_RCC_CONTINUE;
}
- nsfw_recycle_obj *p_start = rec_pool->obj;
- u32 i;
- u32 size = rec_pool->pool_size;
+ nsfw_recycle_obj *p_start = rec_pool->obj;
+ u32 i;
+ u32 size = rec_pool->pool_size;
- nsfw_ps_info *pps_info;
- pps_info = nsfw_ps_info_get (pid);
- if (NULL == pps_info)
+ nsfw_ps_info *pps_info;
+ pps_info = nsfw_ps_info_get(pid);
+ if (NULL == pps_info)
{
- NSFW_LOGERR ("get ps_info failed!]pid=%d", pid);
- return NSFW_RCC_CONTINUE;
+ NSFW_LOGERR("get ps_info falied!]pid=%d", pid);
+ return NSFW_RCC_CONTINUE;
}
- i32 cur_idx = (i32) (u64) nsfw_ps_get_uv (pps_info, NSFW_REC_IDX);
+ i32 cur_idx = (i32) (u64) nsfw_ps_get_uv(pps_info, NSFW_REC_IDX);
- if (-1 == cur_idx)
+ if (-1 == cur_idx)
{
- cur_idx = 0;
- nsfw_ps_set_uv (pps_info, NSFW_REC_IDX, (void *) (u64) cur_idx);
- (void) nsfw_recycle_exit_pid_lock (pid, NSFW_PROC_APP, NULL);
+ cur_idx = 0;
+ nsfw_ps_set_uv(pps_info, NSFW_REC_IDX, (void *) (u64) cur_idx);
+ (void) nsfw_recycle_exit_pid_lock(pid, NSFW_PROC_APP, NULL);
}
- else
+ else
{
- cur_idx++;
- nsfw_ps_set_uv (pps_info, NSFW_REC_IDX, (void *) (u64) cur_idx);
+ cur_idx++;
+ nsfw_ps_set_uv(pps_info, NSFW_REC_IDX, (void *) (u64) cur_idx);
}
- for (i = cur_idx; i < size; i++)
+ for (i = cur_idx; i < size; i++)
{
- obj = &p_start[i];
- cur_idx = i;
- nsfw_ps_set_uv (pps_info, NSFW_REC_IDX, (void *) (u64) cur_idx);
- if (FALSE == obj->alloc_flag)
+ obj = &p_start[i];
+ cur_idx = i;
+ nsfw_ps_set_uv(pps_info, NSFW_REC_IDX, (void *) (u64) cur_idx);
+ if (FALSE == obj->alloc_flag)
{
- continue;
+ continue;
}
- if ((obj->rec_type < NSFW_REC_TYPE_MAX)
- && (NULL != g_rec_fun[obj->rec_type]))
+ if ((obj->rec_type < NSFW_REC_TYPE_MAX)
+ && (NULL != g_rec_fun[obj->rec_type]))
{
- match++;
- if (NSFW_RCC_SUSPEND ==
- g_rec_fun[obj->rec_type] (pid, obj->data, obj->rec_type))
+ match++;
+ if (NSFW_RCC_SUSPEND ==
+ g_rec_fun[obj->rec_type] (pid, obj->data, obj->rec_type))
{
- NSFW_LOGINF
- ("call suspend]type=%d,obj_pid=%d,pid=%d,count=%d",
- obj->rec_type, obj->host_pid, pid, match);
- return NSFW_RCC_SUSPEND;
+ NSFW_LOGINF
+ ("call suspend]type=%d,obj_pid=%d,pid=%d,count=%d",
+ obj->rec_type, obj->host_pid, pid, match);
+ return NSFW_RCC_SUSPEND;
}
}
- else
+ else
{
- NSFW_LOGERR ("obj_error!drop]type=%d,obj_pid=%d,pid=%d",
- obj->rec_type, obj->host_pid, pid);
+ NSFW_LOGERR("obj_error!drop]type=%d,obj_pid=%u,pid=%u",
+ obj->rec_type, obj->host_pid, pid);
}
}
- NSFW_LOGWAR ("rec obj]pid=%d,count=%d,cur_idx=%d", pid, match, cur_idx);
- return NSFW_RCC_CONTINUE;
+ NSFW_LOGWAR("rec obj]pid=%u,match=%u,cur_idx=%d", pid, match, cur_idx);
+ return NSFW_RCC_CONTINUE;
}
/*****************************************************************************
@@ -252,75 +247,67 @@ nsfw_recycle_callback_all_obj (u32 pid, nsfw_recycle_pool * rec_pool)
* Calls :
* Called By :
*****************************************************************************/
-u8
-nsfw_recycle_pid_obj (u32 pid)
+u8 nsfw_recycle_pid_obj(u32 pid)
{
- nsfw_ps_info *pps_info;
- pps_info = nsfw_ps_info_get (pid);
- if (NULL == pps_info)
+ nsfw_ps_info *pps_info;
+ pps_info = nsfw_ps_info_get(pid);
+ if (NULL == pps_info)
{
- NSFW_LOGERR ("get ps_info failed!]pid=%d", pid);
- return FALSE;
+ NSFW_LOGERR("get ps_info falied]pid=%u", pid);
+ return FALSE;
}
- nsfw_recycle_pool *rec_pool = g_rec_cfg.mem_rec_obj_pool;
- void *timer_ptr = nsfw_ps_get_uv (pps_info, NSFW_REC_TIMER);
- if (NSFW_RCC_SUSPEND == nsfw_recycle_callback_all_obj (pid, rec_pool))
+ nsfw_recycle_pool *rec_pool = g_rec_cfg.mem_rec_obj_pool;
+ void *timer_ptr = nsfw_ps_get_uv(pps_info, NSFW_REC_TIMER);
+ if (NSFW_RCC_SUSPEND == nsfw_recycle_callback_all_obj(pid, rec_pool))
{
- if (NULL != timer_ptr)
+ if (NULL != timer_ptr)
{
- nsfw_timer_rmv_timer (timer_ptr);
- timer_ptr = NULL;
+ nsfw_timer_rmv_timer(timer_ptr);
+ timer_ptr = NULL;
}
- struct timespec time_left = { NSFW_REC_WEND_TVLAUE, 0 };
- timer_ptr =
- (void *) nsfw_timer_reg_timer (NSFW_REC_WEND_TIMER,
- (void *) (u64) pid,
- nsfw_recycle_obj_timeout, time_left);
- nsfw_ps_set_uv (pps_info, NSFW_REC_TIMER, timer_ptr);
- return TRUE;
+ struct timespec time_left = { NSFW_REC_WEND_TVLAUE, 0 };
+ timer_ptr =
+ (void *) nsfw_timer_reg_timer(NSFW_REC_WEND_TIMER,
+ (void *) (u64) pid,
+ nsfw_recycle_obj_timeout,
+ time_left);
+ nsfw_ps_set_uv(pps_info, NSFW_REC_TIMER, timer_ptr);
+ return TRUE;
}
- if (NULL != timer_ptr)
+ if (NULL != timer_ptr)
{
- nsfw_timer_rmv_timer (timer_ptr);
- nsfw_ps_set_uv (pps_info, NSFW_REC_TIMER, NULL);
+ nsfw_timer_rmv_timer(timer_ptr);
+ nsfw_ps_set_uv(pps_info, NSFW_REC_TIMER, NULL);
}
- (void) nsfw_ps_exit_end_notify (pid);
- nsfw_ps_info_free (pps_info);
- return TRUE;
+ (void) nsfw_ps_exit_end_notify(pid);
+ if (pps_info->proc_type == NSFW_PROC_MASTER)
+ {
+ nsfw_ps_info_free(pps_info);
+ }
+ return TRUE;
}
-/*****************************************************************************
-* Prototype : nsfw_recycle_all_obj
-* Description :
-* Input : u32 pid
-* nsfw_mem_addr_msg *addr_msg
-* Output : None
-* Return Value : u8
-* Calls :
-* Called By :
-*****************************************************************************/
-u8
-nsfw_recycle_all_obj (u32 pid)
+u8 nsfw_recycle_all_obj(u32 pid)
{
- nsfw_ps_info *pps_info;
- pps_info = nsfw_ps_info_get (pid);
- if (NULL == pps_info)
+ nsfw_ps_info *pps_info;
+ pps_info = nsfw_ps_info_get(pid);
+ if (NULL == pps_info)
{
- pps_info = nsfw_ps_info_alloc (pid, NSFW_PROC_APP);
- if (NULL == pps_info)
+ pps_info = nsfw_ps_info_alloc(pid, NSFW_PROC_APP, 0);
+ if (NULL == pps_info)
{
- NSFW_LOGERR ("alloc ps_info failed!]pid=%u", pid);
- return FALSE;
+ NSFW_LOGERR("alloc ps_info falied!]pid=%u", pid);
+ return FALSE;
}
}
- nsfw_ps_set_uv (pps_info, NSFW_REC_IDX, (void *) (-1));
- nsfw_ps_set_uv (pps_info, NSFW_REC_TIMER, NULL);
- return nsfw_recycle_pid_obj (pid);
+ nsfw_ps_set_uv(pps_info, NSFW_REC_IDX, (void *) (-1));
+ nsfw_ps_set_uv(pps_info, NSFW_REC_TIMER, NULL);
+ return nsfw_recycle_pid_obj(pid);
}
/*****************************************************************************
@@ -332,27 +319,26 @@ nsfw_recycle_all_obj (u32 pid)
* Calls :
* Called By :
*****************************************************************************/
-int
-mem_app_exit_proc (nsfw_mgr_msg * msg)
+int mem_app_exit_proc(nsfw_mgr_msg * msg)
{
- if (NULL == msg)
+ if (NULL == msg)
{
- NSFW_LOGERR ("msg nul");
- return FALSE;
+ NSFW_LOGERR("msg nul");
+ return FALSE;
}
- nsfw_ps_info_msg *ps_info_msg = GET_USER_MSG (nsfw_ps_info_msg, msg);
+ nsfw_ps_info_msg *ps_info_msg = GET_USER_MSG(nsfw_ps_info_msg, msg);
- /* look up the app rec memzone and release all resource */
- /* no need to send rsp for it will be send after stack process over */
- if (TRUE == nsfw_recycle_all_obj (ps_info_msg->host_pid))
+ /* look up the app rec memzone and release all resource */
+ /* no need to send rsp for it will be send after stack process over */
+ if (TRUE == nsfw_recycle_all_obj(ps_info_msg->host_pid))
{
- NSFW_LOGINF ("obj found!]pid=%d", ps_info_msg->host_pid);
- return TRUE;
+ NSFW_LOGINF("obj found!]pid=%u", ps_info_msg->host_pid);
+ return TRUE;
}
- (void) nsfw_ps_exit_end_notify (ps_info_msg->host_pid);
- return FALSE;
+ (void) nsfw_ps_exit_end_notify(ps_info_msg->host_pid);
+ return FALSE;
}
/*****************************************************************************
@@ -364,18 +350,17 @@ mem_app_exit_proc (nsfw_mgr_msg * msg)
* Calls :
* Called By :
*****************************************************************************/
-int
-nsfw_recycle_obj_end_proc (nsfw_mgr_msg * msg)
+int nsfw_recycle_obj_end_proc(nsfw_mgr_msg * msg)
{
- if (NULL == msg)
+ if (NULL == msg)
{
- NSFW_LOGERR ("msg nul");
- return FALSE;
+ NSFW_LOGERR("msg nul");
+ return FALSE;
}
- nsfw_ps_info_msg *ps_info_msg = GET_USER_MSG (nsfw_ps_info_msg, msg);
+ nsfw_ps_info_msg *ps_info_msg = GET_USER_MSG(nsfw_ps_info_msg, msg);
- return nsfw_recycle_pid_obj (ps_info_msg->host_pid);
+ return nsfw_recycle_pid_obj(ps_info_msg->host_pid);
}
/*****************************************************************************
@@ -388,36 +373,35 @@ nsfw_recycle_obj_end_proc (nsfw_mgr_msg * msg)
* Calls :
* Called By :
*****************************************************************************/
-int
-nsfw_recycle_obj_timeout (u32 timer_type, void *data)
+int nsfw_recycle_obj_timeout(u32 timer_type, void *data)
{
- u32 pid = (u64) data;
- void *timer_ptr = NULL;
- NSFW_LOGINF ("ps_info timerout]pid=%u", pid);
+ u32 pid = (u64) data;
+ void *timer_ptr = NULL;
+ NSFW_LOGINF("ps_info timerout]pid=%u", pid);
- nsfw_ps_info *pps_info;
- pps_info = nsfw_ps_info_get (pid);
- if (NULL != pps_info)
+ nsfw_ps_info *pps_info;
+ pps_info = nsfw_ps_info_get(pid);
+ if (NULL != pps_info)
{
- nsfw_recycle_pool *rec_pool = g_rec_cfg.mem_rec_obj_pool;
- if (NULL != rec_pool)
+ nsfw_recycle_pool *rec_pool = g_rec_cfg.mem_rec_obj_pool;
+ if (NULL != rec_pool)
{
- if (TRUE == g_hbt_switch)
+ if (TRUE == g_hbt_switch)
{
- struct timespec time_left = { NSFW_REC_WEND_TVLAUE, 0 };
- timer_ptr =
- (void *) nsfw_timer_reg_timer (timer_type, data,
- nsfw_recycle_obj_timeout,
- time_left);
- nsfw_ps_set_uv (pps_info, NSFW_REC_TIMER, timer_ptr);
- return TRUE;
+ struct timespec time_left = { NSFW_REC_WEND_TVLAUE, 0 };
+ timer_ptr =
+ (void *) nsfw_timer_reg_timer(timer_type, data,
+ nsfw_recycle_obj_timeout,
+ time_left);
+ nsfw_ps_set_uv(pps_info, NSFW_REC_TIMER, timer_ptr);
+ return TRUE;
}
}
- nsfw_ps_set_uv (pps_info, NSFW_REC_TIMER, timer_ptr);
+ nsfw_ps_set_uv(pps_info, NSFW_REC_TIMER, timer_ptr);
}
- (void) nsfw_recycle_pid_obj (pid);
- return TRUE;
+ (void) nsfw_recycle_pid_obj(pid);
+ return TRUE;
}
/*****************************************************************************
@@ -429,96 +413,95 @@ nsfw_recycle_obj_timeout (u32 timer_type, void *data)
* Calls :
* Called By :
*****************************************************************************/
-u8
-mem_rec_zone_init ()
+u8 mem_rec_zone_init()
{
- nsfw_mem_mring pringinfo;
- pringinfo.enmptype = NSFW_MRING_MPMC;
- pringinfo.isocket_id = NSFW_SOCKET_ANY;
- pringinfo.stname.entype = NSFW_NSHMEM;
- pringinfo.usnum = MEM_RECYCLE_PER_PRO_QUE;
- u32 i;
- for (i = 0; i < NSFW_REC_PRO_MAX; i++)
+ nsfw_mem_mring pringinfo;
+ pringinfo.enmptype = NSFW_MRING_MPMC;
+ pringinfo.isocket_id = NSFW_SOCKET_ANY;
+ pringinfo.stname.entype = NSFW_NSHMEM;
+ pringinfo.usnum = MEM_RECYCLE_PER_PRO_QUE;
+ u32 i;
+ for (i = 0; i < NSFW_REC_PRO_MAX; i++)
{
- if (-1 ==
- SPRINTF_S (pringinfo.stname.aname, NSFW_MEM_NAME_LENGTH, "%s%d",
- MEM_REC_QUEUE_NAME, i))
+ if (-1 ==
+ sprintf_s(pringinfo.stname.aname, NSFW_MEM_NAME_LENTH, "%s%u",
+ MEM_REC_QUEUE_NAME, i))
{
- NSFW_LOGERR ("SPRINTF_S failed]");
- return FALSE;
+ NSFW_LOGERR("sprintf_s fail");
+ return FALSE;
}
- g_rec_cfg.mem_rec_pro[i] = nsfw_mem_ring_create (&pringinfo);
- if (NULL == g_rec_cfg.mem_rec_pro[i])
+ g_rec_cfg.mem_rec_pro[i] = nsfw_mem_ring_create(&pringinfo);
+ if (NULL == g_rec_cfg.mem_rec_pro[i])
{
- NSFW_LOGERR ("alloc rec ring nul!");
- return FALSE;
+ NSFW_LOGERR("alloc rec ring nul");
+ return FALSE;
}
}
- MEM_STAT (NSFW_RECYCLE_MODULE, MEM_REC_QUEUE_NAME, NSFW_NSHMEM,
- NSFW_REC_PRO_MAX * nsfw_mem_get_len (g_rec_cfg.mem_rec_pro[0],
+ MEM_STAT(NSFW_RECYCLE_MODULE, MEM_REC_QUEUE_NAME, NSFW_NSHMEM,
+ NSFW_REC_PRO_MAX * nsfw_mem_get_len(g_rec_cfg.mem_rec_pro[0],
NSFW_MEM_RING));
- nsfw_mem_zone pzoneinfo;
- pzoneinfo.isocket_id = NSFW_SOCKET_ANY;
- pzoneinfo.stname.entype = NSFW_NSHMEM;
- pzoneinfo.length =
- MEM_RECYCLE_OBJ_MAX_NUM * sizeof (nsfw_recycle_obj) +
- sizeof (nsfw_recycle_pool);
- if (-1 ==
- SPRINTF_S (pzoneinfo.stname.aname, NSFW_MEM_NAME_LENGTH, "%s",
- MEM_REC_POOL_NAME))
+ nsfw_mem_zone pzoneinfo;
+ pzoneinfo.isocket_id = NSFW_SOCKET_ANY;
+ pzoneinfo.stname.entype = NSFW_NSHMEM;
+ pzoneinfo.lenth =
+ MEM_RECYCLE_OBJ_MAX_NUM * sizeof(nsfw_recycle_obj) +
+ sizeof(nsfw_recycle_pool);
+ if (-1 ==
+ sprintf_s(pzoneinfo.stname.aname, NSFW_MEM_NAME_LENTH, "%s",
+ MEM_REC_POOL_NAME))
{
- NSFW_LOGERR ("SPRINTF_S failed]");
- return FALSE;
+ NSFW_LOGERR("sprintf_s fail");
+ return FALSE;
}
- g_rec_cfg.mem_rec_obj_pool = nsfw_mem_zone_create (&pzoneinfo);
- if (NULL == g_rec_cfg.mem_rec_obj_pool)
+ g_rec_cfg.mem_rec_obj_pool = nsfw_mem_zone_create(&pzoneinfo);
+ if (NULL == g_rec_cfg.mem_rec_obj_pool)
{
- NSFW_LOGERR ("alloc rec pool nul!");
- return FALSE;
+ NSFW_LOGERR("alloc rec pool nul");
+ return FALSE;
}
- MEM_STAT (NSFW_RECYCLE_MODULE, MEM_REC_POOL_NAME, NSFW_NSHMEM,
- pzoneinfo.length);
+ MEM_STAT(NSFW_RECYCLE_MODULE, MEM_REC_POOL_NAME, NSFW_NSHMEM,
+ pzoneinfo.lenth);
- int retval;
- retval =
- MEMSET_S (g_rec_cfg.mem_rec_obj_pool, pzoneinfo.length, 0,
- pzoneinfo.length);
- if (EOK != retval)
+ int retval;
+ retval =
+ memset_s(g_rec_cfg.mem_rec_obj_pool, pzoneinfo.lenth, 0,
+ pzoneinfo.lenth);
+ if (EOK != retval)
{
- NSFW_LOGERR ("mem set init failed!");
- return FALSE;
+ NSFW_LOGERR("mem set init fail");
+ return FALSE;
}
- i32 j;
- nsfw_recycle_pool *rec_pool =
- (nsfw_recycle_pool *) g_rec_cfg.mem_rec_obj_pool;
- rec_pool->pool_size = MEM_RECYCLE_OBJ_MAX_NUM;
+ i32 j;
+ nsfw_recycle_pool *rec_pool =
+ (nsfw_recycle_pool *) g_rec_cfg.mem_rec_obj_pool;
+ rec_pool->pool_size = MEM_RECYCLE_OBJ_MAX_NUM;
- nsfw_recycle_obj *p_start = rec_pool->obj;
- for (i = 0; i < NSFW_REC_PRO_MAX; i++)
+ nsfw_recycle_obj *p_start = rec_pool->obj;
+ for (i = 0; i < NSFW_REC_PRO_MAX; i++)
{
- for (j = 0; j < MEM_RECYCLE_PER_PRO_QUE; j++)
+ for (j = 0; j < MEM_RECYCLE_PER_PRO_QUE; j++)
{
- if (FALSE == p_start[j].alloc_flag)
+ if (FALSE == p_start[j].alloc_flag)
{
- if (0 ==
- nsfw_mem_ring_enqueue (g_rec_cfg.mem_rec_pro[i],
- &p_start[j]))
+ if (0 ==
+ nsfw_mem_ring_enqueue(g_rec_cfg.mem_rec_pro[i],
+ &p_start[j]))
{
- NSFW_LOGERR ("enqueue failed");
- break;
+ NSFW_LOGERR("enqueue fail");
+ break;
}
}
}
- p_start = p_start + MEM_RECYCLE_PER_PRO_QUE;
+ p_start = p_start + MEM_RECYCLE_PER_PRO_QUE;
}
- NSFW_LOGINF ("init rec pool and ring suc!");
- return TRUE;
+ NSFW_LOGINF("init rec pool and ring suc");
+ return TRUE;
}
/*****************************************************************************
@@ -532,46 +515,45 @@ mem_rec_zone_init ()
* Calls :
* Called By :
*****************************************************************************/
-void *
-nsfw_recycle_reg_obj (u8 priority, u16 rec_type, void *data)
+void *nsfw_recycle_reg_obj(u8 priority, u16 rec_type, void *data)
{
- if (NSFW_REC_PRO_MAX <= priority)
+ if (NSFW_REC_PRO_MAX <= priority)
{
- NSFW_LOGERR ("pro error]priority=%d,rec_type=%d,data=%p", priority,
- rec_type, data);
- return NULL;
+ NSFW_LOGERR("pro error]priority=%d,rec_type=%d,data=%p", priority,
+ rec_type, data);
+ return NULL;
}
- nsfw_recycle_obj *obj = NULL;
- if (0 ==
- nsfw_mem_ring_dequeue (g_rec_cfg.mem_rec_pro[priority], (void *) &obj))
+ nsfw_recycle_obj *obj = NULL;
+ if (0 ==
+ nsfw_mem_ring_dequeue(g_rec_cfg.mem_rec_pro[priority], (void *) &obj))
{
- NSFW_LOGERR ("dequeue error]priority=%d,rec_type=%d,data=%p",
- priority, rec_type, data);
- return NULL;
+ NSFW_LOGERR("dequeue error]priority=%d,rec_type=%d,data=%p",
+ priority, rec_type, data);
+ return NULL;
}
- if (EOK != MEMSET_S (obj, sizeof (*obj), 0, sizeof (*obj)))
+ if (EOK != memset_s(obj, sizeof(*obj), 0, sizeof(*obj)))
{
- if (0 == nsfw_mem_ring_enqueue (g_rec_cfg.mem_rec_pro[priority], obj))
+ if (0 == nsfw_mem_ring_enqueue(g_rec_cfg.mem_rec_pro[priority], obj))
{
- NSFW_LOGERR ("enqueue error]priority=%d,rec_type=%d,data=%p",
- priority, rec_type, data);
+ NSFW_LOGERR("enqueue error]priority=%d,rec_type=%d,data=%p",
+ priority, rec_type, data);
}
- NSFW_LOGERR ("mem set error]priority=%d,rec_type=%d,data=%p",
- priority, rec_type, data);
- return NULL;
+ NSFW_LOGERR("mem set error]priority=%d,rec_type=%d,data=%p",
+ priority, rec_type, data);
+ return NULL;
}
- obj->alloc_flag = TRUE;
- obj->rec_type = rec_type;
- obj->data = data;
- obj->host_pid = get_sys_pid ();
- obj->alloc_flag = TRUE;
- NSFW_LOGINF ("en queue obj]priority=%d,rec_type=%d,data=%p", priority,
- rec_type, data);
- return obj;
+ obj->alloc_flag = TRUE;
+ obj->rec_type = rec_type;
+ obj->data = data;
+ obj->host_pid = get_sys_pid();
+ obj->alloc_flag = TRUE;
+ NSFW_LOGINF("en queue obj]priority=%d,rec_type=%d,data=%p", priority,
+ rec_type, data);
+ return obj;
}
/*****************************************************************************
@@ -583,77 +565,60 @@ nsfw_recycle_reg_obj (u8 priority, u16 rec_type, void *data)
* Calls :
* Called By :
*****************************************************************************/
-int
-nsfw_recycle_rechk_lock ()
+int nsfw_recycle_rechk_lock()
{
- return nsfw_ps_rechk_pid_exit (nsfw_recycle_exit_pid_lock, NULL);
+ return nsfw_ps_rechk_pid_exit(nsfw_recycle_exit_pid_lock, NULL);
}
-/*****************************************************************************
-* Prototype : nsfw_recycle_module_init
-* Description : module init
-* Input : void* param
-* Output : None
-* Return Value : static int
-* Calls :
-* Called By :
-*****************************************************************************/
-NSTACK_STATIC int nsfw_recycle_module_init (void *param);
-NSTACK_STATIC int
-nsfw_recycle_module_init (void *param)
+NSTACK_STATIC int nsfw_recycle_module_init(void *param);
+NSTACK_STATIC int nsfw_recycle_module_init(void *param)
{
- u32 proc_type = (u32) ((long long) param);
- NSFW_LOGINF ("recycle module init]type=%d", proc_type);
- g_rec_cfg.rec_waite_end_tvalue = NSFW_REC_WEND_TVLAUE_DEF;
- switch (proc_type)
+ u32 proc_type = (u32) ((long long) param);
+ NSFW_LOGINF("recycle module init]type=%u", proc_type);
+ g_rec_cfg.rec_waite_end_tvalue = NSFW_REC_WEND_TVLAUE_DEF;
+ switch (proc_type)
{
- case NSFW_PROC_MAIN:
- (void) nsfw_mgr_reg_msg_fun (MGR_MSG_APP_EXIT_REQ, mem_app_exit_proc);
- (void) nsfw_mgr_reg_msg_fun (MGR_MSG_RCC_END_REQ,
- nsfw_recycle_obj_end_proc);
- if (TRUE == mem_rec_zone_init ())
- {
- return 0;
- }
+ case NSFW_PROC_MASTER:
+ return 0;
+ case NSFW_PROC_MAIN:
+ (void) nsfw_mgr_reg_msg_fun(MGR_MSG_APP_EXIT_REQ,
+ mem_app_exit_proc);
+ (void) nsfw_mgr_reg_msg_fun(MGR_MSG_RCC_END_REQ,
+ nsfw_recycle_obj_end_proc);
+ if (TRUE == mem_rec_zone_init())
+ {
+ return 0;
+ }
- return 0;
- default:
- if (proc_type < NSFW_PROC_MAX)
- {
- break;
- }
- return -1;
+ return 0;
+ default:
+ if (proc_type < NSFW_PROC_MAX)
+ {
+ break;
+ }
+ return -1;
}
- return 0;
+ return 0;
}
-/*****************************************************************************
-* Prototype : nsfw_recycle_fork_init
-* Description : fork init
-* Input : None
-* Output : None
-* Return Value : u8
-* Calls :
-* Called By :
-*****************************************************************************/
-u8
-nsfw_recycle_fork_init ()
+u8 nsfw_recycle_fork_init()
{
- /* reconnect to master after fork in child proc */
- nsfw_mgr_close_dst_proc (NSFW_PROC_MAIN, 0);
- if (0 == nsfw_recycle_module_init ((void *) ((long long) NSFW_PROC_APP)))
+ /* reconnect to master after fork in child proc */
+ nsfw_mgr_close_dst_proc(NSFW_PROC_MAIN, 0);
+ nsfw_mgr_close_dst_proc(NSFW_PROC_MASTER, 0);
+ if (0 == nsfw_recycle_module_init((void *) ((long long) NSFW_PROC_APP)))
{
- return TRUE;
+ return TRUE;
}
- return FALSE;
+ return FALSE;
}
/* *INDENT-OFF* */
-NSFW_MODULE_NAME (NSFW_RECYCLE_MODULE)
-NSFW_MODULE_PRIORITY (10)
-NSFW_MODULE_DEPENDS (NSFW_PS_MEM_MODULE)
-NSFW_MODULE_INIT (nsfw_recycle_module_init)
+NSFW_MODULE_NAME(NSFW_RECYCLE_MODULE)
+NSFW_MODULE_PRIORITY(10)
+NSFW_MODULE_DEPENDS(NSFW_PS_MEM_MODULE)
+NSFW_MODULE_INIT(nsfw_recycle_module_init)
/* *INDENT-ON* */
#ifdef __cplusplus
diff --git a/src/framework/ipc/ps/nsfw_recycle_module.h b/src/framework/ipc/ps/nsfw_recycle_module.h
index 694c1d2..ca9ce7e 100644
--- a/src/framework/ipc/ps/nsfw_recycle_module.h
+++ b/src/framework/ipc/ps/nsfw_recycle_module.h
@@ -18,6 +18,8 @@
#define _NSFW_RECYCLE_MODULE_H
#include "nsfw_recycle_api.h"
+#include "nsfw_mem_api.h"
+#include "types.h"
#ifdef __cplusplus
/* *INDENT-OFF* */
@@ -40,40 +42,41 @@ extern "C"{
typedef struct _nsfw_recycle_obj
{
- u8 alloc_flag;
- u8 u8reserve;
- u16 rec_type;
- u32 host_pid;
- void *data;
- u64 u64reserve;
+ u8 alloc_flag;
+ u8 u8reserve;
+ u16 rec_type;
+ u32 host_pid;
+ void *data;
+ u64 u64reserve;
} nsfw_recycle_obj;
#define NSFW_REC_LOCK_REL_MAX_FUN 32
typedef struct _nsfw_rec_fun_info
{
- nsfw_recycle_fun rec_fun;
- void *data;
- u8 proc_type;
+ nsfw_recycle_fun rec_fun;
+ void *data;
+ u8 proc_type;
} nsfw_rec_fun_info;
typedef struct _nsfw_recycle_pool
{
- u32 pool_size;
- nsfw_recycle_obj obj[0];
+ u32 pool_size;
+
+ nsfw_recycle_obj obj[0];
} nsfw_recycle_pool;
typedef struct _nsfw_recycle_cfg
{
- u16 rec_waite_end_tvalue;
- mring_handle mem_rec_obj_pool;
- mzone_handle mem_rec_pro[NSFW_REC_PRO_MAX];
+ u16 rec_waite_end_tvalue;
+ mring_handle mem_rec_obj_pool;
+ mzone_handle mem_rec_pro[NSFW_REC_PRO_MAX];
} nsfw_recycle_cfg;
-extern nsfw_rcc_stat nsfw_recycle_callback_all_obj (u32 pid,
- nsfw_recycle_pool *
- rec_pool);
-extern int nsfw_recycle_obj_timeout (u32 timer_type, void *data);
+extern nsfw_rcc_stat nsfw_recycle_callback_all_obj(u32 pid,
+ nsfw_recycle_pool *
+ rec_pool);
+extern int nsfw_recycle_obj_timeout(u32 timer_type, void *data);
#ifdef __cplusplus
/* *INDENT-OFF* */
diff --git a/src/framework/ipc/ps/nsfw_soft_param.c b/src/framework/ipc/ps/nsfw_soft_param.c
deleted file mode 100644
index 743276f..0000000
--- a/src/framework/ipc/ps/nsfw_soft_param.c
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-/*==============================================*
- * include header files *
- *----------------------------------------------*/
-
-#include <stdlib.h>
-#include "types.h"
-#include "nstack_securec.h"
-#include "nsfw_init.h"
-
-#include "nstack_log.h"
-#include "nsfw_maintain_api.h"
-
-#include "nsfw_mem_api.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C"{
-/* *INDENT-ON* */
-#endif /* __cplusplus */
-
-typedef struct _nsfw_set_soft_item
-{
- void *data;
- u32 size;
- u64 max;
- u64 min;
-} nsfw_set_soft_item;
-
-/* *INDENT-OFF* */
-nsfw_set_soft_fun g_soft_fun[NSFW_MAX_SOFT_PARAM] = { 0 };
-nsfw_set_soft_item g_soft_int_cfg[NSFW_MAX_SOFT_PARAM];
-/* *INDENT-ON* */
-
-int
-nsfw_isdigitstr (const char *str)
-{
- if (NULL == str || '\0' == str[0])
- return 0;
-
- while (*str)
- {
- if (*str < '0' || *str > '9')
- return 0;
- str++;
- }
- return 1;
-}
-
-u8
-nsfw_soft_param_reg_fun (u32 param_name, nsfw_set_soft_fun fun)
-{
- if (NULL == fun || param_name >= NSFW_MAX_SOFT_PARAM)
- {
- NSFW_LOGERR ("argv err]fun=%p,type=%u", fun, param_name);
- return FALSE;
- }
-
- g_soft_fun[param_name] = fun;
- NSFW_LOGINF ("reg]fun=%d,type=%u", fun, param_name);
- return TRUE;
-}
-
-int
-nsfw_soft_set_int (u32 param, char *buf, u32 buf_len)
-{
- u64 buf_value = 0;
- if (NULL == buf || param >= NSFW_MAX_SOFT_PARAM)
- {
- NSFW_LOGERR ("argv err]buf=%p,param=%u", buf, param);
- return FALSE;
- }
-
- if (!nsfw_isdigitstr (buf))
- {
- NSFW_LOGERR ("argv err]buf=%s,param=%u", buf, param);
- return FALSE;
- }
-
- char *parsing_end;
- buf_value = (u64) strtol (buf, &parsing_end, 10);
- nsfw_set_soft_item *int_item = &g_soft_int_cfg[param];
- if (NULL == int_item->data)
- {
- NSFW_LOGERR ("data err]buf=%s,param=%u,min=%llu,max=%llu", buf, param,
- int_item->min, int_item->max);
- return FALSE;
- }
-
- if (buf_value < int_item->min || buf_value > int_item->max)
- {
- NSFW_LOGERR ("argv err]buf=%s,param=%u,min=%llu,max=%llu", buf, param,
- int_item->min, int_item->max);
- return FALSE;
- }
-
- u32 size = int_item->size;
- if (size >= sizeof (u64))
- {
- size = sizeof (u64);
- }
-
- if (EOK != MEMCPY_S (int_item->data, size, &buf_value, size))
- {
- NSFW_LOGERR ("MEMCPY_S failed");
- return FALSE;
- }
-
- NSFW_LOGINF ("set soft param ok]param=%u,value=%llu,size=%u", param,
- buf_value, size);
- return TRUE;
-}
-
-/*****************************************************************************
-* Prototype : nsfw_soft_param_reg_int
-* Description : reg int param set
-* Input : u32 param_name
-* u32 size
-* u32 min
-* u32 max
-* u64 *data
-* Output : None
-* Return Value : u8
-* Calls :
-* Called By :
-*****************************************************************************/
-u8
-nsfw_soft_param_reg_int (u32 param_name, u32 size, u32 min, u32 max,
- u64 * data)
-{
- if (NULL == data || param_name >= NSFW_MAX_SOFT_PARAM)
- {
- NSFW_LOGERR ("argv err]data=%p,type=%u", data, param_name);
- return FALSE;
- }
-
- g_soft_int_cfg[param_name].data = data;
- g_soft_int_cfg[param_name].size = size;
- g_soft_int_cfg[param_name].max = max;
- g_soft_int_cfg[param_name].min = min;
- return nsfw_soft_param_reg_fun (param_name, nsfw_soft_set_int);
-}
-
-void
-nsfw_set_soft_para (fw_poc_type proc_type, u32 para_name, void *value,
- u32 size)
-{
- nsfw_mgr_msg *msg =
- (nsfw_mgr_msg *) nsfw_mgr_msg_alloc (MGR_MSG_SOF_PAR_REQ, proc_type);
- if (NULL == msg)
- {
- NSFW_LOGERR
- ("nsfw_mgr_msg_alloc failed] msg type=%d, proc type=%d, para_name=%u",
- MGR_MSG_SOF_PAR_REQ, proc_type, para_name);
- return;
- }
-
- nsfw_soft_param_msg *soft_msg = GET_USER_MSG (nsfw_soft_param_msg, msg);
-
- soft_msg->param_name = para_name;
- soft_msg->rsp_code = 0;
-
- if (EOK !=
- MEMCPY_S (soft_msg->param_value, sizeof (soft_msg->param_value),
- value, size))
- {
- NSFW_LOGERR
- ("MEMCPY_S failed] msg type=%d, proc type=%d, para_name=%u",
- MGR_MSG_SOF_PAR_REQ, proc_type, para_name);
- nsfw_mgr_msg_free (msg);
- return;
- }
-
- nsfw_mgr_msg *rsp = nsfw_mgr_null_rspmsg_alloc ();
- if (NULL == rsp)
- {
- NSFW_LOGERR
- ("nsfw_mgr_null_rspmsg_alloc failed] msg type=%d, proc type=%d, para_name=%u",
- MGR_MSG_SOF_PAR_REQ, proc_type, para_name);
- nsfw_mgr_msg_free (msg);
- return;
- }
-
- if (!nsfw_mgr_send_req_wait_rsp (msg, rsp))
- {
- NSFW_LOGERR
- ("can not get response] msg type=%d, proc type=%d, para_name=%u",
- MGR_MSG_SOF_PAR_REQ, proc_type, para_name);
- nsfw_mgr_msg_free (msg);
- nsfw_mgr_msg_free (rsp);
- return;
- }
-
- nsfw_soft_param_msg *soft_rsp_msg = GET_USER_MSG (nsfw_soft_param_msg, rsp);
- if (soft_rsp_msg->rsp_code != NSFW_EXIT_SUCCESS)
- {
- NSFW_LOGERR
- ("set soft param failed] msg type=%d, proc type=%d, para_name=%u, rsp code=%u",
- MGR_MSG_SOF_PAR_REQ, proc_type, para_name, soft_rsp_msg->rsp_code);
- nsfw_mgr_msg_free (msg);
- nsfw_mgr_msg_free (rsp);
- return;
- }
-
- NSFW_LOGINF
- ("set soft param success] msg type=%d, proc type=%d, para_name=%u",
- MGR_MSG_SOF_PAR_REQ, proc_type, para_name);
-
- nsfw_mgr_msg_free (msg);
- nsfw_mgr_msg_free (rsp);
- return;
-}
-
-int
-nsfw_softparam_msg_proc (nsfw_mgr_msg * msg)
-{
- nsfw_mgr_msg *rsp_msg = nsfw_mgr_rsp_msg_alloc (msg);
- if (NULL == rsp_msg)
- {
- NSFW_LOGERR ("alloc rsp failed,drop msg!" MSGINFO, PRTMSG (msg));
- return FALSE;
- }
-
- nsfw_soft_param_msg *soft_msg = GET_USER_MSG (nsfw_soft_param_msg, msg);
- nsfw_soft_param_msg *soft_rsp_msg =
- GET_USER_MSG (nsfw_soft_param_msg, rsp_msg);
- if ((soft_msg->param_name < NSFW_MAX_SOFT_PARAM)
- && (NULL != g_soft_fun[soft_msg->param_name]))
- {
- soft_msg->param_value[sizeof (soft_msg->param_value) - 1] = 0;
- (void) g_soft_fun[soft_msg->param_name] (soft_msg->param_name,
- (char *)
- soft_msg->param_value,
- sizeof
- (soft_msg->param_value));
- soft_rsp_msg->rsp_code = NSFW_EXIT_SUCCESS;
- }
- else
- {
- NSFW_LOGERR ("set soft failed!]soft=%u", soft_msg->param_name);
- soft_rsp_msg->rsp_code = NSFW_EXIT_FAILED;
- }
-
- (void) nsfw_mgr_send_msg (rsp_msg);
- nsfw_mgr_msg_free (rsp_msg);
- return TRUE;
-}
-
-int nsfw_softparam_module_init (void *param);
-int
-nsfw_softparam_module_init (void *param)
-{
- u8 proc_type = (u8) ((long long) param);
- NSFW_LOGINF ("softparam module init]type=%u", proc_type);
- switch (proc_type)
- {
- case NSFW_PROC_MAIN:
- (void) nsfw_mgr_reg_msg_fun (MGR_MSG_SOF_PAR_REQ,
- nsfw_softparam_msg_proc);
- return 0;
- default:
- if (proc_type < NSFW_PROC_MAX)
- {
- break;
- }
- return -1;
- }
-
- return 0;
-}
-
-/* *INDENT-OFF* */
-NSFW_MODULE_NAME (NSFW_SOFT_PARAM_MODULE)
-NSFW_MODULE_PRIORITY (99)
-NSFW_MODULE_INIT (nsfw_softparam_module_init)
-/* *INDENT-ON* */
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif /* __cplusplus */
diff --git a/src/framework/lib_common_mem/common_api.c b/src/framework/lib_common_mem/common_api.c
deleted file mode 100644
index cfb869d..0000000
--- a/src/framework/lib_common_mem/common_api.c
+++ /dev/null
@@ -1,325 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include <string.h>
-#include "common_mem_api.h"
-#include "common_mem_pal.h"
-#include "nstack_log.h"
-#include "nstack_securec.h"
-#include "common_func.h"
-
-void
-sys_sem_init_v2 (sys_sem_t_v2 sem)
-{
- sem->locked = 1;
-}
-
-/** Returns the current time in milliseconds,
- * may be the same as sys_jiffies or at least based on it. */
-u32_t
-sys_now (void)
-{
- struct timespec now;
-
- if (unlikely (0 != clock_gettime (CLOCK_MONOTONIC, &now)))
- {
- NSCOMM_LOGERR ("Failed to get time, errno = %d", errno);
- }
-
- return 1000 * now.tv_sec + now.tv_nsec / 1000000;
-}
-
-long
-sys_jiffies (void)
-{
- return sys_now ();
-}
-
-err_t
-sys_sem_new_v2 (sys_sem_t_v2 * sem, u8_t isUnLockd)
-{
- int retVal;
- if (!sem)
- {
- return -1;
- }
- *sem = malloc (sizeof (common_mem_spinlock_t));
-
- if (NULL == *sem)
- {
- return -1;
- }
- else
- {
- retVal =
- MEMSET_S (*sem, sizeof (common_mem_spinlock_t), 0,
- sizeof (common_mem_spinlock_t));
- if (EOK != retVal)
- {
- NSCOMM_LOGERR ("MEMSET_S failed]ret=%d", retVal);
- free (*sem);
- *sem = NULL;
- return -1;
- }
- common_mem_spinlock_init (*sem);
- }
-
- if (!isUnLockd)
- {
- common_mem_spinlock_lock (*sem);
- }
-
- return 0;
-}
-
-void
-sys_sem_free_v2 (sys_sem_t_v2 * sem)
-{
- if ((sem != NULL) && (*sem != NULL))
- {
- free (*sem);
- *sem = NULL;
- }
- else
- {
- }
-}
-
-void
-sys_sem_signal_v2 (sys_sem_t_v2 * sem)
-{
- common_mem_spinlock_unlock (*sem);
-}
-
-void
-sys_sem_signal_s_v2 (sys_sem_t_v2 sem)
-{
- common_mem_spinlock_unlock (sem);
-}
-
-u32_t
-sys_arch_sem_trywait_v2 (sys_sem_t_v2 * sem)
-{
- return (u32_t) common_mem_spinlock_trylock (*sem);
-}
-
-u32_t
-sys_arch_sem_wait_v2 (sys_sem_t_v2 * pstsem)
-{
- common_mem_spinlock_lock (*pstsem);
- return 0;
-}
-
-u32_t
-sys_arch_sem_wait_s_v2 (sys_sem_t_v2 sem)
-{
- common_mem_spinlock_lock (sem);
- return 0;
-}
-
-volatile pid_t g_sys_host_pid = SYS_HOST_INITIAL_PID;
-
-/*****************************************************************************
-* Prototype : get_exec_name_by_pid
-* Description : get exec name by pid
-* Input : pid_t pid
-* char *task_name
-* Output : None
-* Return Value : void
-* Calls :
-* Called By :
-*****************************************************************************/
-void
-get_exec_name_by_pid (pid_t pid, char *task_name, int task_name_len)
-{
- int retVal;
- char path[READ_FILE_BUFLEN] = { 0 };
- char buf[READ_FILE_BUFLEN] = { 0 };
-
- retVal = SPRINTF_S (path, sizeof (path), "/proc/%d/status", pid);
- if (-1 == retVal)
- {
- NSCOMM_LOGERR ("SPRINTF_S failed]ret=%d", retVal);
- return;
- }
-
- FILE *fp = fopen (path, "r");
- if (NULL != fp)
- {
- if (fgets (buf, READ_FILE_BUFLEN - 1, fp) == NULL)
- {
- fclose (fp);
- return;
- }
- fclose (fp);
-
-#ifdef SECUREC_LIB
- retVal = SSCANF_S (buf, "%*s %s", task_name, task_name_len);
-#else
- retVal = SSCANF_S (buf, "%*s %s", task_name);
-#endif
-
- if (1 != retVal)
- {
- NSSOC_LOGERR ("SSCANF_S failed]ret=%d", retVal);
- return;
- }
- }
-}
-
-pid_t
-get_hostpid_from_file_one_time (u32_t pid)
-{
- int retVal;
- char path[READ_FILE_BUFLEN] = { 0 };
- char buf[READ_FILE_BUFLEN] = { 0 };
- char fmt[READ_FILE_BUFLEN] = { 0 };
- char out[READ_FILE_BUFLEN] = { 0 };
- char task_name[BUF_SIZE_FILEPATH] = { 0 };
- pid_t hostpid = SYS_HOST_INITIAL_PID;
- get_exec_name_by_pid (pid, task_name, BUF_SIZE_FILEPATH);
-
- retVal = SPRINTF_S (fmt, sizeof (fmt), "%s%s", task_name, " (%s");
- if (-1 == retVal)
- {
- NSCOMM_LOGERR ("SPRINTF_S failed]ret=%d", retVal);
- return hostpid;
- }
- retVal = SPRINTF_S (path, sizeof (path), "/proc/%d/sched", pid);
- if (-1 == retVal)
- {
- NSCOMM_LOGERR ("SPRINTF_S failed]ret=%d", retVal);
- return hostpid;
- }
- FILE *fp = fopen (path, "r");
- if (NULL != fp)
- {
- if (fgets (buf, READ_FILE_BUFLEN - 1, fp) == NULL)
- {
- fclose (fp);
- return hostpid;
- }
- fclose (fp);
- /* Compiler needs "fmt" to be like "%s%s" to
- understand. But we have "fmt" already prepared and used here. It can
- be suppressed, not an issue
- */
-#pragma GCC diagnostic ignored "-Wformat-nonliteral"
- retVal = SSCANF_S (buf, fmt, out, READ_FILE_BUFLEN);
- if (-1 == retVal)
- {
- NSPOL_LOGERR ("SSCANF_S failed]ret=%d", retVal);
- return hostpid;
- }
- }
-
- hostpid = (pid_t) strtol (out, NULL, 0);
- if (hostpid == 0)
- {
- hostpid = 1;
- }
-
- return hostpid;
-}
-
-#define MAX_GET_PID_TIME 10
-pid_t
-get_hostpid_from_file (u32_t pid)
-{
- pid_t ret_pid = SYS_HOST_INITIAL_PID;
- int i = 0;
- ret_pid = get_hostpid_from_file_one_time (pid);
- while (0 == ret_pid || ret_pid == SYS_HOST_INITIAL_PID)
- {
- i++;
- if (i > MAX_GET_PID_TIME)
- {
- NSFW_LOGERR ("get pid failed]pid=%u,hostpid=%d", pid, ret_pid);
- break;
- }
- sys_sleep_ns (0, 5000000);
- ret_pid = get_hostpid_from_file_one_time (pid);
- }
-
- return ret_pid;
-}
-
-/*****************************************************************************
-* Prototype : get_hostpid_from_file
-* Description : get host pid by sub namespace pid in docker
-* Input : uint32_t pid
-* Output : None
-* Return Value : uint32_t
-* Calls :
-* Called By :
-*****************************************************************************/
-pid_t
-sys_get_hostpid_from_file (pid_t pid)
-{
- g_sys_host_pid = get_hostpid_from_file (pid);
- NSCOMM_LOGDBG ("ok]cur pid=%d, input pid=%d", g_sys_host_pid, pid);
- return g_sys_host_pid;
-}
-
-pid_t
-update_sys_pid ()
-{
- g_sys_host_pid = SYS_HOST_INITIAL_PID;
- return get_sys_pid ();
-}
-
-/*****************************************************************************
-* Prototype : get_pid_namespace
-* Description : Get namespace of pid
-* Input : uint32_t pid
-* Output : None
-* Return Value : uint64_t
-* Calls :
-* Called By :
-*****************************************************************************/
-uint64_t
-get_pid_namespace (pid_t pid)
-{
- char buf[BUF_SIZE_FILEPATH] = { 0 };
- char path[BUF_SIZE_FILEPATH] = { 0 };
- const char *pstart;
- int ret = 0;
- if (!pid)
- {
- NSSOC_LOGERR ("Pid is zero!");
- return 0;
- }
-
- ret =
- SNPRINTF_S (path, sizeof (path), sizeof (path) - 1, "/proc/%d/ns/pid",
- pid);
- if (-1 == ret)
- {
- NSSOC_LOGERR ("SNPRINTF_S failed]ret=%d", ret);
- return 0;
- }
-
- ret = readlink (path, buf, sizeof (buf) - 1);
- if (ret <= (int) sizeof (STR_PID))
- {
- NSSOC_LOGERR ("readlink pid ns file error]ret=%d", ret);
- return 0;
- }
-
- buf[ret - 1] = 0;
- pstart = &(buf[sizeof (STR_PID)]);
- return strtoull (pstart, NULL, 10);
-}
diff --git a/src/framework/lib_common_mem/common_buf.c b/src/framework/lib_common_mem/common_buf.c
deleted file mode 100644
index d31ca83..0000000
--- a/src/framework/lib_common_mem/common_buf.c
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <stdarg.h>
-#include <inttypes.h>
-#include <errno.h>
-#include <ctype.h>
-#include <sys/queue.h>
-
-#include "common_mem_base_type.h"
-
-#include "common_mem_common.h"
-
-#include "common_mem_memzone.h"
-
-#include "common_mem_pal.h"
-
-#include "common_mem_mempool.h"
-#include "common_mem_buf.h"
-
-#include "nstack_log.h"
-#include "nstack_securec.h"
-
-#include "common_func.h"
-#include "common_pal_bitwide_adjust.h"
-
-#define LOG_ERR 0
-#define LOG_WARN 1
-#define LOG_INFO 2
-#define LOG_DEBUG 3
-#define LOG_MAX 4
-
-#define COMMON_LOG_PRINT(level, fmt, args...) \
- if (level <= log_level) NSCOMM_LOGERR("===>[COMMON]"fmt, ##args); \
-
-#define COMMON_PANIC(fmt) \
- NSCOMM_LOGERR("==>[COMMON_PANIC]"fmt); \
- common_dump_stack(); \
-
-#define PARA1_SET(argv, tempargv, Index, para1) do {\
- retVal = STRCPY_S(tempargv[Index], PATA_STRLENT, para1);\
- if (retVal != EOK)\
- {\
- NSCOMM_LOGERR("STRCPY_S failed]ret=%d", retVal);\
- return DMM_MBUF_RET_ERR;\
- }\
- argv[Index] = tempargv[Index]; \
- Index ++; } while (0)
-
-#define PARA2_SET(argv, tempargv, Index, para1, para2) do {\
- retVal = STRCPY_S(tempargv[Index], PATA_STRLENT, para1); \
- if (retVal != EOK)\
- {\
- NSCOMM_LOGERR("STRCPY_S failed]ret=%d", retVal);\
- return DMM_MBUF_RET_ERR;\
- }\
- argv[Index] = tempargv[Index]; \
- Index++; \
- retVal = STRCPY_S(tempargv[Index], PATA_STRLENT, para2); \
- if (retVal != EOK)\
- {\
- NSCOMM_LOGERR("STRCPY_S failed]ret=%d", retVal);\
- return DMM_MBUF_RET_ERR;\
- }\
- argv[Index] = tempargv[Index]; \
- Index ++; } while (0)
-
-#define PATA_STRLENT 64
-#define PATA_NUM_MAX 12
-
-int log_level = LOG_INFO;
-
-int
-nscomm_pal_module_init (nsfw_mem_para * para,
- common_mem_pal_module_info * pinfo, u8 app_mode)
-{
- char tempargv[PATA_NUM_MAX][PATA_STRLENT];
- char *argv[PATA_NUM_MAX];
- char tempbuf[PATA_STRLENT];
- unsigned int Index = 0;
- int ioffset = 0;
- int agindex = 0;
- int intmask = 0;
- int retVal;
- char name[10] = { '\0' };
-
- if (para == NULL)
- {
- NSCOMM_LOGERR ("para is null");
- return DMM_MBUF_RET_ERR;
- }
-
- retVal = MEMSET_S (tempargv, sizeof (tempargv), '\0', sizeof (tempargv));
- if (EOK != retVal)
- {
- NSCOMM_LOGERR ("MEMSET_S failed]ret=%d", retVal);
- return DMM_MBUF_RET_ERR;
- }
- retVal = MEMSET_S (argv, sizeof (argv), 0, sizeof (argv));
- if (EOK != retVal)
- {
- NSCOMM_LOGERR ("MEMSET_S failed]ret=%d", retVal);
- return DMM_MBUF_RET_ERR;
- }
- if (NSFW_PROC_MAIN == para->enflag)
- {
- if (para->iargsnum != 0)
- {
- if (common_mem_pal_init (para->iargsnum, para->pargs) < 0)
- {
- COMMON_LOG_PRINT (LOG_ERR, "Cannot init pal\r\n");
- return DMM_MBUF_RET_ERR;
- }
- else
- {
- return DMM_MBUF_RET_OK;
- }
- }
-
- PARA1_SET (argv, tempargv, agindex, "nStackMain");
- PARA2_SET (argv, tempargv, agindex, "-c", "0x1");
- PARA2_SET (argv, tempargv, agindex, "-n", "4");
- PARA1_SET (argv, tempargv, agindex, "--huge-dir=/mnt/nstackhuge");
- PARA1_SET (argv, tempargv, agindex, "--proc-type=primary");
-
- if (app_mode == 1)
- {
- sprintf (name, "dmm_app_%ld", (long) getpid ());
- PARA2_SET (argv, tempargv, agindex, "--file-prefix", name);
- PARA1_SET (argv, tempargv, agindex, "--no-pci");
-
- // TODO: the size of the memory should not be fixed
- PARA2_SET (argv, tempargv, agindex, "-m", "32");
- }
- else
- {
- // TODO: replay the name 'nStackMain'
- /* snprintf(name, 10, "dmm_main_%ld", (long) getpid()); */
- PARA2_SET (argv, tempargv, agindex, "--file-prefix", "nStackMain");
- PARA2_SET (argv, tempargv, agindex, "-m", "2048");
- }
-
- }
- else
- {
- PARA1_SET (argv, tempargv, agindex, "nStackMain");
- PARA2_SET (argv, tempargv, agindex, "--file-prefix", "nStackMain");
-
- retVal = SPRINTF_S (tempbuf, PATA_STRLENT, "0x");
- if (-1 == retVal)
- {
- NSCOMM_LOGERR ("SPRINTF_S failed]ret=%d", ioffset);
- return DMM_MBUF_RET_ERR;
- }
- ioffset = retVal;
- for (Index = 0; Index < LCORE_MASK_MAX; Index++)
- {
- if (ioffset >= PATA_STRLENT)
- {
- NSCOMM_LOGERR ("SPRINTF_S tempbuf overflow]ioffset=%d",
- ioffset);
- return DMM_MBUF_RET_ERR;
- }
- retVal =
- SPRINTF_S (&(tempbuf[ioffset]), PATA_STRLENT - ioffset, "%8u",
- pinfo->ilcoremask[Index]);
- if (-1 == retVal)
- {
- NSCOMM_LOGERR ("SPRINTF_S failed]ret=%d", ioffset);
- return DMM_MBUF_RET_ERR;
- }
- ioffset = ioffset + retVal;
- intmask |= pinfo->ilcoremask[Index];
- }
- if (0 == intmask)
- {
- PARA2_SET (argv, tempargv, agindex, "-c", "0x1");
- }
- else
- {
- PARA2_SET (argv, tempargv, agindex, "-c", tempbuf);
- }
- if (pinfo->ishare_mem_size > 0)
- {
- retVal = MEMSET_S (tempbuf, PATA_STRLENT, 0, PATA_NUM_MAX);
- if (EOK != retVal)
- {
- NSCOMM_LOGERR ("MEMSET_S failed]ret=%d", retVal);
- return DMM_MBUF_RET_ERR;
- }
- retVal =
- SPRINTF_S (tempbuf, PATA_STRLENT, "%d", pinfo->ishare_mem_size);
- if (-1 == retVal)
- {
- NSCOMM_LOGERR ("SPRINTF_S failed]ret=%d", retVal);
- return DMM_MBUF_RET_ERR;
- }
- PARA2_SET (argv, tempargv, agindex, "-m", tempbuf);
- }
-
- retVal = MEMSET_S (tempbuf, PATA_STRLENT, 0, PATA_NUM_MAX);
- if (EOK != retVal)
- {
- NSCOMM_LOGERR ("MEMSET_S failed]ret=%d", retVal);
- return DMM_MBUF_RET_ERR;
- }
-
- switch (pinfo->ucproctype)
- {
- case DMM_PROC_T_PRIMARY:
- retVal = SPRINTF_S (tempbuf, PATA_STRLENT, "--proc-type=primary");
- if (-1 == retVal)
- {
- NSCOMM_LOGERR ("SPRINTF_S failed]ret=%d", retVal);
- return DMM_MBUF_RET_ERR;
- }
- break;
- case DMM_PROC_T_SECONDARY:
- retVal = SPRINTF_S (tempbuf, PATA_STRLENT, "--proc-type=secondary");
- if (-1 == retVal)
- {
- NSCOMM_LOGERR ("SPRINTF_S failed]ret=%d", retVal);
- return DMM_MBUF_RET_ERR;
- }
- break;
- case DMM_PROC_T_AUTO:
- default:
- retVal = SPRINTF_S (tempbuf, PATA_STRLENT, "--proc-type=auto");
- if (-1 == retVal)
- {
- NSCOMM_LOGERR ("SPRINTF_S failed]ret=%d", retVal);
- return DMM_MBUF_RET_ERR;
- }
- break;
- }
- PARA1_SET (argv, tempargv, agindex, tempbuf);
-
- if (DMM_HUGTBL_DISABLE == pinfo->uchugeflag)
- {
- PARA1_SET (argv, tempargv, agindex, "--no-huge");
- }
- }
- if (common_mem_pal_init (agindex, argv) < 0)
- {
- COMMON_LOG_PRINT (LOG_ERR, "Cannot init pal\r\n");
- return DMM_MBUF_RET_ERR;
- }
- return DMM_MBUF_RET_OK;
-}
-
-void *
-nscomm_memzone_data_reserve_name (const char *name, size_t len, int socket_id)
-{
- const struct common_mem_memzone *mz = NULL;
- /*
- rte_memzone_reserve must Call first, cause rte_memzone_reserve has a globe lock.
- while proc race happen, who(calls A) got lock first will create memzone success.
- others create same memzone proc will got lock after A, and rte_memzone_reserve return NULL;
- so while rte_memzone_reserve return NULL we need do rte_memzone_lookup;
- */
- mz = common_mem_memzone_reserve (name, len, socket_id, 0);
- if (mz == NULL)
- {
- mz = common_mem_memzone_lookup (name);
- }
-
- return mz ? (void *) ADDR_SHTOL (mz->addr_64) : NULL;
-}
-
-void *
-nscomm_memzone_data_lookup_name (const char *name)
-{
- void *addr = NULL;
- const struct common_mem_memzone *mz = NULL;
- mz = common_mem_memzone_lookup (name);
- if (mz == NULL)
- {
- return NULL;
- }
- addr = (void *) ADDR_SHTOL (mz->addr_64);
- return addr;
-}
diff --git a/src/framework/lib_common_mem/common_func.c b/src/framework/lib_common_mem/common_func.c
deleted file mode 100644
index 5220374..0000000
--- a/src/framework/lib_common_mem/common_func.c
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "common_mem_pal_memconfig.h"
-#include "common_mem_mbuf.h"
-#include "common_mem_common.h"
-#include "nstack_log.h"
-#include "common_pal_bitwide_adjust.h"
-
-#include "common_func.h"
-
-#include "nstack_securec.h"
-
-#define COMMON_PROCESS_MAPS "/proc/self/maps"
-
-int g_PrimSameFlg = 1;
-
-NSTACK_STATIC void **g_PrimAddr2LocalMap = NULL;
-NSTACK_STATIC void *g_LocalBaseAddr = NULL;
-NSTACK_STATIC void *g_LocalMaxAddr = NULL;
-NSTACK_STATIC void *g_LocalCfgAddrBase = NULL;
-
-NSTACK_STATIC uint64_t *g_LocalAddr2PrimMap = NULL;
-NSTACK_STATIC uint64_t g_PrimBaseAddr = 0;
-NSTACK_STATIC uint64_t g_PrimMaxAddr = 0;
-NSTACK_STATIC uint64_t g_PrimCfgAddrBase = 0;
-
-NSTACK_STATIC uint64_t g_LBitMask = 0;
-NSTACK_STATIC int g_LBitMaskLen = 0;
-
-uint64_t
-pal_laddr_to_shddr (void *LAddr)
-{
- size_t l2pIdx;
-
- if (g_PrimSameFlg || LAddr == NULL)
- {
- return (uint64_t) LAddr;
- }
-
- /*calculate the IDX */
- l2pIdx = (ALIGN_PTR (LAddr) - ALIGN_PTR (g_LocalBaseAddr)) >> g_LBitMaskLen;
-
- /*check the Hugepage Addr Rang */
- if (LAddr <= g_LocalMaxAddr && LAddr >= g_LocalBaseAddr
- && g_LocalAddr2PrimMap[l2pIdx])
- {
- return g_LocalAddr2PrimMap[l2pIdx] + (ALIGN_PTR (LAddr) & g_LBitMask);
- }
-
- /*check the Cfg Mapping Addr Rang */
- if (LAddr >= g_LocalCfgAddrBase
- && LAddr <=
- (void *) ((char *) g_LocalCfgAddrBase +
- sizeof (struct common_mem_mem_config)))
- {
- return g_PrimCfgAddrBase + ((char *) LAddr -
- (char *) g_LocalCfgAddrBase);
- }
-
- NSCOMM_LOGWAR
- ("WARNING!!! Input invalid LAddr]LAddr=%p, g_LocalBaseAddr=%p, g_LocalMaxAddr=%p, g_LocalCfgAddrBase=%p, g_LocalCfgAddrMax=%p.",
- LAddr, g_LocalBaseAddr, g_LocalMaxAddr, g_LocalCfgAddrBase,
- (char *) g_LocalCfgAddrBase + sizeof (struct common_mem_mem_config));
-
- return (uint64_t) LAddr;
-}
-
-void *
-pal_shddr_to_laddr (uint64_t PAddr)
-{
- size_t p2lIdx;
-
- if (g_PrimSameFlg || PAddr == ALIGN_PTR (NULL))
- {
- return (void *) PAddr;
- }
-
- p2lIdx = (PAddr - g_PrimBaseAddr) >> g_LBitMaskLen;
- /*check the Hugepage Addr Rang */
- if (PAddr <= g_PrimMaxAddr && PAddr >= g_PrimBaseAddr
- && g_PrimAddr2LocalMap[p2lIdx])
- {
- return (void *) ((uint64_t) g_PrimAddr2LocalMap[p2lIdx] +
- (PAddr & g_LBitMask));
- }
-
- /*check the Cfg Mapping Addr Rang */
- if (PAddr >= g_PrimCfgAddrBase
- && PAddr <= g_PrimCfgAddrBase + sizeof (struct common_mem_mem_config))
- {
- return (void *) ((uint64_t) g_LocalCfgAddrBase + PAddr -
- g_PrimCfgAddrBase);
- }
-
- NSCOMM_LOGWAR
- ("WARNING!!! Input invalid PAddr]PAddr=%lx, g_PrimBaseAddr=%lx, g_PrimMaxAddr=%lx, g_PrimCfgAddrBase=%lx, g_PrimCfgAddrMax=%lx.",
- PAddr, g_PrimBaseAddr, g_PrimMaxAddr, g_PrimCfgAddrBase,
- g_PrimCfgAddrBase + sizeof (struct common_mem_mem_config));
-
- return (void *) PAddr;
-}
-
-/*lint +e539 */
-
-int
-dmm_pal_addr_align ()
-{
- return g_PrimSameFlg;
-}
-
-int32_t
-dmm_pktmbuf_pool_iterator (struct common_mem_mempool * mp, uint32_t start,
- uint32_t end, dmm_mbuf_item_fun fun, void *argv)
-{
- if (NULL == mp || fun == NULL)
- {
- return 0;
- }
-
- if (start >= mp->size || end <= start)
- {
- return 0;
- }
-
- int32_t elm_size = mp->elt_size + mp->header_size + mp->trailer_size;
- struct common_mem_mbuf *elm_mbuf = (struct common_mem_mbuf *) (STAILQ_FIRST (&mp->mem_list)->addr + start * elm_size + mp->header_size); /*lint !e647 */
-
- uint32_t i;
- uint32_t mbuf_end = COMMON_MEM_MIN (end, mp->size) - start;
- for (i = 0; i < mbuf_end; i++)
- {
- (void) fun (elm_mbuf, argv);
- elm_mbuf = (struct common_mem_mbuf *) ((char *) elm_mbuf + elm_size);
- }
-
- return mbuf_end;
-}
-
-void
-dmm_addr_print (void)
-{
- const struct common_mem_mem_config *mcfg =
- common_mem_pal_get_configuration ()->mem_config;
- int s;
- FILE *fd;
- char *ptembuf = NULL;
- if (!mcfg)
- {
- NSCOMM_LOGERR ("mcfg is null");
- return;
- }
- /*printf base address */
- NSCOMM_LOGINF ("********master baseaddr begin***************");
- for (s = 0; s < COMMON_MEM_MAX_MEMSEG; ++s)
- {
- if ((mcfg->memseg[s].len > 0) && (mcfg->memseg[s].addr != 0))
- {
- NSCOMM_LOGINF ("addr:%p, len:%u", mcfg->memseg[s].addr,
- mcfg->memseg[s].len);
- }
- }
- NSCOMM_LOGINF ("********master baseaddr end***************");
-
- fd = fopen (COMMON_PROCESS_MAPS, "r");
- if (!fd)
- {
- NSCOMM_LOGERR ("/proc/self/maps open fail, erro:%d", errno);
- return;
- }
-
- ptembuf = (char *) malloc (BUFSIZ);
- if (!ptembuf)
- {
- NSCOMM_LOGERR ("malloc buff failed]buff_len=%d", BUFSIZ);
- fclose (fd);
- return;
- }
- if (EOK != MEMSET_S (ptembuf, BUFSIZ, 0, BUFSIZ))
- {
- NSCOMM_LOGERR ("MEMSET_S failed] buff=%p", ptembuf);
- }
- NSCOMM_LOGINF ("********self process addr space begin***************");
- while (fgets (ptembuf, BUFSIZ, fd) != NULL)
- {
- NSCOMM_LOGERR ("%s", ptembuf);
- }
- NSCOMM_LOGINF ("********self process addr space end*****************");
- fclose (fd);
- free (ptembuf);
- return;
-}
diff --git a/src/framework/log/nsfw_set_log.c b/src/framework/log/nsfw_set_log.c
deleted file mode 100644
index 31241b5..0000000
--- a/src/framework/log/nsfw_set_log.c
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include <stdlib.h>
-#include "types.h"
-#include "nstack_securec.h"
-#include "nsfw_init.h"
-
-#include "nstack_log.h"
-#include "nsfw_maintain_api.h"
-#include "nsfw_mem_api.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C"{
-/* *INDENT-ON* */
-#endif /* __cplusplus */
-
-typedef struct _nsfw_log_cfg
-{
- u8 proc_type;
- char master_log_path[NSFW_LOG_VALUE_LEN];
- char runing_log_path[NSFW_LOG_VALUE_LEN];
- char opr_log_path[NSFW_LOG_VALUE_LEN];
-} nsfw_log_cfg;
-
-nsfw_log_cfg g_log_cfg;
-
-const char nsfw_mas_log[NSFW_LOG_VALUE_LEN] = "maspath";
-const char nsfw_flush_name[NSFW_LOG_VALUE_LEN] = "flush";
-
-enum _set_log_type
-{
- SET_LOG_LEVEL = 0,
- SET_LOG_FLUSH,
- SET_LOG_MASTER,
- SET_LOG_MAIN,
-
- SET_LOG_INVALID
-};
-
-/*****************************************************************************
-* Prototype : nsfw_set_log_path
-* Description : set log path
-* Input : const char *param
-* const char *value
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*****************************************************************************/
-int
-nsfw_set_log_path (const char *param, const char *value)
-{
- if (NULL == param || NULL == value)
- {
- NSFW_LOGERR ("log param error!]param=%p,value=%p", param, value);
- return FALSE;
- }
-
- if (cmp_log_path (value))
- {
- if (check_log_dir_valid (value) < 0)
- {
- NSFW_LOGERR ("path is invalid]value=%s", value);
- return FALSE;
- }
- if (EOK !=
- STRCPY_S (g_log_cfg.master_log_path, NSFW_LOG_VALUE_LEN, value))
- {
- NSFW_LOGERR ("strcpy error!");
- return FALSE;
- }
-
- NSFW_LOGINF ("renew log path]%s", g_log_cfg.master_log_path);
- nstack_modify_log_dir (g_log_cfg.master_log_path);
- NSFW_LOGINF ("set log success]newpath=%s!", g_log_cfg.master_log_path);
- return TRUE;
- }
- return FALSE;
-}
-
-/*****************************************************************************
-* Prototype : nsfw_flush_log_info
-* Description : flush the log info
-* Input : const char *param
-* u8 proc_type
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*****************************************************************************/
-int
-nsfw_flush_log_info (const char *param, u8 proc_type)
-{
- if (NULL == param)
- {
- NSFW_LOGERR ("log param error!]param=%p", param);
- return FALSE;
- }
- glogFlushLogFiles (GLOG_LEVEL_DEBUG);
- NSFW_LOGINF ("flush log success]proc_type=%u", proc_type);
- return TRUE;
-}
-
-/*****************************************************************************
-* Prototype : nsfw_set_log_msg_proc
-* Description : set log message process
-* Input : nsfw_mgr_msg* msg
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*****************************************************************************/
-int
-nsfw_set_log_msg_proc (nsfw_mgr_msg * msg)
-{
- int ret = -1;
- int status = -1;
- if (NULL == msg)
- {
- NSFW_LOGERR ("msg nul");
- return FALSE;
- }
-
- nsfw_set_log_msg *set_log_msg = GET_USER_MSG (nsfw_set_log_msg, msg);
-
- if (0 == strcmp (set_log_msg->module, nsfw_mas_log))
- {
- status = SET_LOG_MASTER;
- }
- else if (0 == strcmp (set_log_msg->module, nsfw_flush_name))
- {
- status = SET_LOG_FLUSH;
- }
- else if (nsfw_isdigitstr (set_log_msg->module))
- {
- status = SET_LOG_LEVEL;
- }
-
- switch (status)
- {
- case SET_LOG_LEVEL:
- ret = setlog_level_value (set_log_msg->module, set_log_msg->log_level);
- break;
- case SET_LOG_FLUSH:
- ret = nsfw_flush_log_info (set_log_msg->module, msg->dst_proc_type);
- break;
- case SET_LOG_MASTER:
- ret = nsfw_set_log_path (set_log_msg->module, set_log_msg->log_level);
- break;
- default:
- NSFW_LOGERR ("default error]status=%d,set_log_msg->module=%s", status,
- set_log_msg->module);
- return FALSE;
- }
-
- nsfw_mgr_msg *rsp_msg = nsfw_mgr_rsp_msg_alloc (msg);
- if (NULL == rsp_msg)
- {
- NSFW_LOGERR ("alloc rsp failed,drop msg!" MSGINFO, PRTMSG (msg));
- return FALSE;
- }
- nsfw_set_log_msg *log_rsp_msg = GET_USER_MSG (nsfw_set_log_msg, rsp_msg);
- log_rsp_msg->rsp_code = ret;
- (void) nsfw_mgr_send_msg (rsp_msg);
- nsfw_mgr_msg_free (rsp_msg);
- return TRUE;
-}
-
-/*****************************************************************************
-* Prototype : nsfw_cfg_module_init
-* Description : module init
-* Input : void* param
-* Output : None
-* Return Value : static int
-* Calls :
-* Called By :
-*****************************************************************************/
-static int nsfw_cfg_module_init (void *param);
-static int
-nsfw_cfg_module_init (void *param)
-{
- u8 proc_type = (u8) ((long long) param);
- NSFW_LOGINF ("log cfg module init]type=%u", proc_type);
- switch (proc_type)
- {
- case NSFW_PROC_MAIN:
- (void) nsfw_mgr_reg_msg_fun (MGR_MSG_SET_LOG_REQ,
- nsfw_set_log_msg_proc);
- g_log_cfg.proc_type = proc_type;
- return 0;
- default:
- if (proc_type < NSFW_PROC_MAX)
- {
- break;
- }
- return -1;
- }
-
- return 0;
-}
-
-/* *INDENT-OFF* */
-NSFW_MODULE_NAME (NSFW_LOG_CFG_MODULE)
-NSFW_MODULE_PRIORITY (99)
-NSFW_MODULE_INIT (nsfw_cfg_module_init)
-/* *INDENT-ON* */
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif /* __cplusplus */
diff --git a/src/framework/log/nstack_log.c b/src/framework/log/nstack_log.c
index 483a10a..d760648 100644
--- a/src/framework/log/nstack_log.c
+++ b/src/framework/log/nstack_log.c
@@ -17,8 +17,8 @@
/*==============================================*
* include header files *
*----------------------------------------------*/
-
-#include "nstack_log.h"
+#include "nstack_log_base.h"
+#include "nstack_log_async.h"
#include <sys/stat.h>
#include <dirent.h>
#include <time.h>
@@ -26,6 +26,7 @@
#include <execinfo.h>
#include <fcntl.h>
#include "nstack_securec.h"
+#include "nsfw_maintain_api.h"
#include <pthread.h>
/*==============================================*
@@ -33,177 +34,258 @@
*----------------------------------------------*/
#define FILE_NAME_LEN 256
-#define MAX_PRE_INIT_LOG_COUNT 256
-#define MAX_LOCK_RETRY_COUNT 50000 /* changed MAX_LOCK_RETRY_COUNT to 50000 to avoid function being blocked for too long */
-/* *INDENT-OFF* */
+
int g_l4_dump_enable = 0;
-static int pre_init_log_count = 0;
-static struct pre_init_info pre_init_log[MAX_PRE_INIT_LOG_COUNT] = {{0, ""}};
-/* *INDENT-ON* */
+
__thread unsigned int nstack_log_nonreentry = 0;
-int ctrl_log_switch = 0;
+//ctrl log switch just for ctrl now
+bool ctrl_log_switch = FALSE;
/*==============================================*
* project-wide global variables *
*----------------------------------------------*/
struct nstack_logs g_nstack_logs[MAX_LOG_MODULE] = { {0, 0, 0, 0}, {0xFFFF, 0, 0, 0} }; /* Clear compile warning */
+
struct log_init_para g_log_init_para =
- { 50, 10, NSTACK_LOG_NAME, 10, 10, NSTACK_LOG_NAME };
+ { 50, 10, NSTACK_LOG_NAME, 10, 10, NSTACK_LOG_NAME };
+
static int g_my_pro_type = LOG_PRO_INVALID;
#define DEFAULT_LOG_CTR_TIME 5
static struct log_ctrl_info g_log_ctrl_info[LOG_CTRL_ID_MAX];
+//better put in the struct for file_type
+bool log_asyn_inited = FALSE;
+
/*==============================================*
* routines' or functions' implementations *
*----------------------------------------------*/
-/* change the print level, not only has err, Begin.*/
-void
-save_pre_init_log (uint32_t level, char *fmt, ...)
+void write_pre_init_log(bool type)
{
- va_list ap;
- int ret = 0;
- /* add pre_init_log_count rang check */
- if (level > NSLOG_DBG || pre_init_log_count >= MAX_PRE_INIT_LOG_COUNT
- || pre_init_log_count < 0)
+ int i = 0;
+ int ret = -1;
+ int count = get_pre_init_log_count();
+ size_t size = MAX_PRE_INIT_LOG_COUNT * sizeof(struct pre_init_info);
+ unsigned int level = 0;
+ struct pre_init_info *pre_buf = (struct pre_init_info *) malloc(size); /*malloc() can be used */
+ if (!pre_buf)
{
- return;
+ NSPOL_LOGERR("malloc fail]count=%d", count);
+ return;
}
- pre_init_log[pre_init_log_count].log_buffer[PRE_INIT_LOG_LENGTH - 1] = '\0';
- (void) va_start (ap, fmt);
- ret =
- VSNPRINTF_S (pre_init_log[pre_init_log_count].log_buffer,
- PRE_INIT_LOG_LENGTH, PRE_INIT_LOG_LENGTH - 1, fmt, ap);
- if (-1 == ret)
+
+ ret = memset_s(pre_buf, size, 0, size);
+ if (EOK != ret)
{
- va_end (ap);
- return;
+ NSPOL_LOGERR("memset_s fail]ret=%d,count=%d", ret, count);
+ free(pre_buf); /*free() can be used */
+ return;
}
- va_end (ap);
- pre_init_log[pre_init_log_count].level = level;
- pre_init_log_count++;
-}
-void
-write_pre_init_log ()
-{
- int i = 0;
- for (; i < pre_init_log_count; i++)
+ ret = get_pre_init_log_buffer(pre_buf, MAX_PRE_INIT_LOG_COUNT);
+ if (ret < 0)
{
- if (NSLOG_ERR == pre_init_log[i].level)
- {
- NSPOL_LOGERR ("pre init log: %s", pre_init_log[i].log_buffer);
- }
- else if (NSLOG_WAR == pre_init_log[i].level)
+ NSPOL_LOGERR("get the init log fail]ret=%d,count=%d", ret, count);
+ free(pre_buf); /*free() can be used */
+ return;
+ }
+
+ for (; i < count; i++)
+ {
+ level = pre_buf[i].level;
+ if (type && (level >= NSLOG_INF))
{
- NSPOL_LOGWAR (NS_LOG_STACKX_ON, "pre init log: %s",
- pre_init_log[i].log_buffer);
+ continue;
}
- else if (NSLOG_INF == pre_init_log[i].level)
+
+ switch (level)
{
- NSPOL_LOGINF (NS_LOG_STACKX_ON, "pre init log: %s",
- pre_init_log[i].log_buffer);
+ case NSLOG_ERR:
+ NSPOL_LOGERR("pre init log: %s", pre_buf[i].log_buffer);
+ break;
+ case NSLOG_WAR:
+ NSPOL_LOGWAR(NS_LOG_STACKPOOL_ON, "pre init log: %s",
+ pre_buf[i].log_buffer);
+ break;
+ case NSLOG_INF:
+ NSPOL_LOGINF(NS_LOG_STACKPOOL_ON, "pre init log: %s",
+ pre_buf[i].log_buffer);
+ break;
+ case NSLOG_DBG:
+ NSPOL_LOGDBG(NS_LOG_STACKPOOL_ON, "pre init log: %s",
+ pre_buf[i].log_buffer);
+ break;
+ default:
+ break;
}
}
+
+ free(pre_buf); /*free() can be used */
+ return;
}
-int
-cmp_log_path (const char *path)
+void get_current_time(char *buf, const int len)
{
- if (NULL == path)
+ if (NULL == buf || len <= 0)
{
- return 1;
+ return;
}
- /* remove struct log_info g_nstack_log_info */
- if (NULL != g_log_init_para.mon_log_path)
+ int retVal;
+ time_t cur_tick;
+ struct tm cur_time;
+
+ (void) time(&cur_tick); /*time() can be used */
+ if (NULL == localtime_r(&cur_tick, &cur_time))
{
- if (strcmp (g_log_init_para.mon_log_path, path) == 0)
- {
- return 0;
- }
+ return;
+ }
+
+ // from man page of localtime_r:
+ // tm_year The number of years since 1900.
+ // tm_mon The number of months since January, in the range 0 to 11.
+ /* There are some unsafe function ,need to be replace with safe function */
+ retVal = snprintf_s(buf, len, len - 1, "%04d%02d%02d%02d%02d%02d",
+ cur_time.tm_year + 1900, cur_time.tm_mon + 1,
+ cur_time.tm_mday, cur_time.tm_hour, cur_time.tm_min,
+ cur_time.tm_sec);
+ if (-1 == retVal)
+ {
+ return;
}
- return 1;
+ buf[len - 1] = 0;
}
-void
-get_current_time (char *buf, const int len)
+void nstack_setlog_level(int module, uint32_t level)
{
- int retVal;
- time_t cur_tick;
- struct tm cur_time;
- (void) time (&cur_tick);
- /* add return value check, */
- if (NULL == localtime_r (&cur_tick, &cur_time))
+ if (MAX_LOG_MODULE <= module || module < 0)
{
- return;
+ return;
+ }
+ g_nstack_logs[module].level = level;
+ /* log suppression switched off when level set to DBG */
+ g_nstack_logs[module].suppress_off = (NSLOG_DBG == level) ? 1 : 0;
+}
+
+bool nstack_log_info_check(uint32_t module, uint32_t level)
+{
+ if ((MAX_LOG_MODULE <= module) || !nstack_log_level_valid(level))
+ {
+ return FALSE;
}
- // from man page of localtime_r:
- // tm_year The number of years since 1900.
- // tm_mon The number of months since January, in the range 0 to 11.
- retVal =
- SNPRINTF_S (buf, len, len - 1, "%04d%02d%02d%02d%02d%02d",
- cur_time.tm_year + 1900, cur_time.tm_mon + 1,
- cur_time.tm_mday, cur_time.tm_hour, cur_time.tm_min,
- cur_time.tm_sec);
- if (-1 == retVal)
+ /* no need compare module ,which is done ahead */
+ if ((LOG_PRO_INVALID == g_my_pro_type) || (FALSE != ctrl_log_switch))
{
- return;
+ return FALSE;
}
- buf[len - 1] = 0;
+
+ return TRUE;
+
}
/*****************************************************************************
-* Prototype : nstack_setlog_level
-* Description : Set global log level
-* Input : int module
-* uint32_t level
+* Prototype : nstack_log_method_check
+* Description : log print method choice, process main, master, nStackCtrl use
+* domain socket to log, app and segment error use orginal method.
+* Input : uint32_t level
+* ...
* Output : None
-* Return Value : void
+* Return Value : bool
* Calls :
* Called By :
*****************************************************************************/
-void
-nstack_setlog_level (int module, uint32_t level)
+bool nstack_log_method_check(uint32_t level)
{
- if (MAX_LOG_MODULE <= module || module < 0)
+ if (LOG_PRO_APP <= g_my_pro_type)
+ {
+ return FALSE;
+ }
+
+ //for segment error log
+ if (level == NSLOG_EMG)
{
- return;
+ return FALSE;
}
- g_nstack_logs[module].level = level;
+
+ if (!log_asyn_inited)
+ {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+NSTACK_STATIC int get_file_type(uint32_t module)
+{
+ return g_nstack_logs[module].file_type;
}
/*****************************************************************************
-* Prototype : nstack_log_info_check
-* Description : log info check
+* Prototype : nstack_log
+* Description : log print
* Input : uint32_t module
-* uint32_t level
+* const char *format
* ...
* Output : None
-* Return Value : bool
+* Return Value : None
* Calls :
* Called By :
*****************************************************************************/
-bool
-nstack_log_info_check (uint32_t module, uint32_t level)
+NSTACK_FMT_CHECK(3)
+ void nstack_log(uint32_t module, uint32_t level, const char *format, ...)
{
- if (MAX_LOG_MODULE <= module)
+ va_list ap;
+ int ret;
+ char pre_buf[PRE_INIT_LOG_LENGTH] = { 0 };
+ char buf[MAX_BUFFER_LEN] = { 0 };
+ char format_buf[MAX_BUFFER_LEN];
+ format_buf[sizeof(format_buf) - 1] = 0;
+ int file_type = 0;
+
+ if (NULL == format)
+ {
+ return;
+ }
+
+ ret = nstack_log_get_prefix(level, pre_buf, sizeof(pre_buf));
+ if (ret < 0)
{
- return false;
+ return;
}
- /* no need compare module ,which is done ahead */
- if (LOG_PRO_INVALID == g_my_pro_type)
+ ret = sprintf_s(format_buf, sizeof(format_buf), "%s %s", pre_buf, format);
+ if (-1 == ret)
{
- return false;
+ return;
}
- return true;
+
+ va_start(ap, format); /*no need to check return */
+ ret = vsprintf_s(buf, sizeof(buf), format_buf, ap);
+ if (-1 == ret)
+ {
+ va_end(ap);
+ return;
+ }
+ va_end(ap);
+
+ buf[sizeof(buf) - 1] = '\0';
+
+ //get the file type
+ if (MAX_LOG_MODULE <= module)
+ {
+ return; //something wrong, but can't print log here
+ }
+ file_type = get_file_type(module);
+
+ // send the buf and write to client fd
+ (void) nstack_log_client_send(file_type, buf, ret);
+
+ return;
}
-/* *INDENT-OFF* */
NSTACK_STATIC inline void init_operation_log_para()
{
g_nstack_logs[OPERATION].file_type = LOG_TYPE_OPERATION;
@@ -213,24 +295,28 @@ NSTACK_STATIC inline void init_nstack_log_para()
{
int i = 0;
- (void)glogLevelSet(GLOG_LEVEL_DEBUG);
+ /* change to glog functions,no need file type control */
+ (void) glogLevelSet(GLOG_LEVEL_DEBUG);
glogBufLevelSet(GLOG_LEVEL_WARNING);
- for(; i<GLOG_LEVEL_BUTT; i++)
- glogSetLogSymlink(i,"");
+ for (; i < GLOG_LEVEL_BUTT; i++)
+ glogSetLogSymlink(i, "");
glogDir(g_log_init_para.run_log_path);
nstack_log_count_set(g_log_init_para.run_log_count);
glogMaxLogSizeSet(g_log_init_para.run_log_size);
- glogSetLogFilenameExtension(STACKX_LOG_NAME);
+ glogSetLogFilenameExtension(STACKPOOL_LOG_NAME);
glogFlushLogSecsSet(FLUSH_TIME);
- for (i = 0; i < MAX_LOG_MODULE ; i++ )
+ /* Fix nstack_log_init file type */
+ for (i = 0; i < MAX_LOG_MODULE; i++)
{
if (i == OPERATION)
{
continue;
}
+
g_nstack_logs[i].file_type = LOG_TYPE_NSTACK;
}
+
init_operation_log_para();
}
@@ -238,36 +324,44 @@ NSTACK_STATIC inline void init_ctrl_log_para()
{
int i = 0;
- (void)glogLevelSet(GLOG_LEVEL_DEBUG);
+ /* change to glog functions,no need file type control */
+ /* omc_ctrl single log file should be 10M [Start] */
+ (void) glogLevelSet(GLOG_LEVEL_DEBUG);
glogBufLevelSet(GLOG_LEVEL_WARNING);
- for(; i<GLOG_LEVEL_BUTT; i++)
- glogSetLogSymlink(i,"");
+ for (; i < GLOG_LEVEL_BUTT; i++)
+ glogSetLogSymlink(i, "");
glogDir(g_log_init_para.mon_log_path);
nstack_log_count_set(g_log_init_para.mon_log_count);
glogMaxLogSizeSet(g_log_init_para.mon_log_size);
glogSetLogFilenameExtension(OMC_CTRL_LOG_NAME);
glogFlushLogSecsSet(FLUSH_TIME);
+
+ for (i = 0; i < MAX_LOG_MODULE; i++)
+ {
+ g_nstack_logs[i].file_type = LOG_TYPE_CTRL;
+ }
}
NSTACK_STATIC inline void init_master_log_para()
{
int i = 0;
- (void)glogLevelSet(GLOG_LEVEL_DEBUG);
+ /* change to glog functions,no need file type control */
+ (void) glogLevelSet(GLOG_LEVEL_DEBUG);
glogBufLevelSet(GLOG_LEVEL_WARNING);
- for(; i<GLOG_LEVEL_BUTT; i++)
- glogSetLogSymlink(i,"");
+ for (; i < GLOG_LEVEL_BUTT; i++)
+ glogSetLogSymlink(i, "");
glogDir(g_log_init_para.mon_log_path);
nstack_log_count_set(g_log_init_para.mon_log_count);
glogMaxLogSizeSet(g_log_init_para.mon_log_size);
glogSetLogFilenameExtension(MASTER_LOG_NAME);
glogFlushLogSecsSet(FLUSH_TIME);
- for (i = 0; i < MAX_LOG_MODULE ; i++ )
+
+ for (i = 0; i < MAX_LOG_MODULE; i++)
{
g_nstack_logs[i].file_type = LOG_TYPE_MASTER;
}
}
-/* *INDENT-OFF* */
/*****************************************************************************
* Prototype : nstack_log_init
@@ -280,83 +374,116 @@ NSTACK_STATIC inline void init_master_log_para()
*****************************************************************************/
int nstack_log_init()
{
- char *pst_temp = NULL;
- int log_level = NSLOG_INF;
- pst_temp = getenv("NSTACK_LOG_ON");
- if (pst_temp)
- {
- if (strcmp (pst_temp, "INF") == 0)
- {
- log_level = NSLOG_INF;
- }
- else if (strcmp (pst_temp, "DBG") == 0)
- {
- log_level = NSLOG_DBG;
- }
- else if (strcmp (pst_temp, "WAR") == 0)
- {
- log_level = NSLOG_WAR;
- }
- else if (strcmp (pst_temp, "ERR") == 0)
+ char *pst_temp = NULL;
+ uint32_t log_level = NSLOG_INF;
+ int proc_type = g_my_pro_type;
+ int ret_client = 0;
+ int ret_server = 0;
+ bool type = FALSE;
+
+ pst_temp = getenv("NSTACK_LOG_ON"); /*getenv() can be used */
+
+ if (pst_temp)
{
- log_level = NSLOG_ERR;
+ if (strcmp(pst_temp, "INF") == 0)
+ {
+ log_level = NSLOG_INF;
+ }
+ else if (strcmp(pst_temp, "DBG") == 0)
+ {
+ log_level = NSLOG_DBG;
+ }
+ else if (strcmp(pst_temp, "WAR") == 0)
+ {
+ log_level = NSLOG_WAR;
+ }
+ else if (strcmp(pst_temp, "ERR") == 0)
+ {
+ log_level = NSLOG_ERR;
+ }
+ else if (strcmp(pst_temp, "EMG") == 0)
+ {
+ log_level = NSLOG_EMG;
+ }
+ else
+ {
+ log_level = NSLOG_ERR;
+ }
+
}
- else if (strcmp (pst_temp, "EMG") == 0)
+ else
{
- log_level = NSLOG_EMG;
+ log_level = NSLOG_INF;
}
- else if (strcmp (pst_temp, "PERF") == 0)
+
+ int i = 0;
+ for (i = 0; i < MAX_LOG_MODULE; i++)
{
- ctrl_log_switch = 1;
+ nstack_setlog_level(i, log_level);
}
- else
+
+ if (log_level <= NSLOG_WAR)
{
- log_level = NSLOG_ERR;
+ /*MONITR log level must set to larger than warning */
+ nstack_setlog_level(MASTER, NSLOG_WAR);
}
- }
- else
+
+ /* monitr and nstack write the same file, it will cause synchronize problem */
+ switch (proc_type)
{
- log_level = NSLOG_INF;
+ case LOG_PRO_NSTACK:
+ glogInit("NSTACK");
+ init_nstack_log_para();
+ break;
+ case LOG_PRO_OMC_CTRL:
+ glogInit("CTRL");
+ init_ctrl_log_para();
+ type = TRUE;
+ break;
+ case LOG_PRO_MASTER:
+ glogInit("MASTER");
+ init_master_log_para();
+ break;
+ default:
+ return 0;
}
- int i = 0;
- for (i = 0; i < MAX_LOG_MODULE; i++)
+
+ init_log_ctrl_info();
+
+ // this is for monitr to check whether log has beed inited
+ g_nstack_logs[NSOCKET].inited = 1;
+
+ /* init the asyn log method for */
+ ret_server = nstack_log_server_init(proc_type);
+
+ ret_client = nstack_log_client_init(proc_type);
+
+ /* if async log init fail,
+ * use synchron log method and record it.*/
+
+ if ((ret_client == 0) && (ret_server == 0))
{
- nstack_setlog_level (i, log_level);
+ log_asyn_inited = TRUE;
}
- if (log_level <= NSLOG_WAR)
+ else
{
- /*MONITOR log level must set to larger than warning */
- nstack_setlog_level (MASTER, NSLOG_WAR);
+ NSPOL_LOGWAR(NS_LOG_STACKPOOL_ON,
+ "async log module init fail, use synchron log");
}
- /* monitor and nstack write the same file, it will cause synchronize problem */
- switch (g_my_pro_type)
- {
- case LOG_PRO_NSTACK:
- glogInit ("NSTACK");
- init_nstack_log_para ();
- break;
- case LOG_PRO_OMC_CTRL:
- glogInit ("CTRL");
- init_ctrl_log_para ();
- break;
- case LOG_PRO_MASTER:
- glogInit ("MASTER");
- init_master_log_para ();
- break;
- default:
- return 0;
- }
+ NSPOL_LOGINF(NS_LOG_STACKPOOL_ON, "daemon-stack_version=%s",
+ NSTACK_VERSION);
+ NSPOL_LOGINF(NS_LOG_STACKPOOL_ON,
+ "ret_client=%d,ret_server=%d,log_asyn_inited=%d",
+ ret_client, ret_server, log_asyn_inited);
- init_log_ctrl_info();
+ /* omc log restrain */
+ write_pre_init_log(type);
- // this is for monitr to check whether log has beed inited
- g_nstack_logs[NSOCKET].inited = 1;
- NSPOL_LOGERR ("nStackMain_version=%s", NSTACK_VERSION);
- write_pre_init_log();
- return 0;
+ return 0;
}
+/* nStack Log print */
/*****************************************************************************
* Prototype : get_str_value
* Description : get int value
@@ -366,27 +493,26 @@ int nstack_log_init()
* Calls :
* Called By :
*****************************************************************************/
-int
-get_str_value (const char *arg)
+int get_str_value(const char *arg)
{
- char *parsing_end;
- int iValue = 0;
- int oldErrno = errno;
- if (arg == NULL)
+ char *parsing_end;
+ int iValue = 0;
+ int oldErrno = errno;
+
+ if (arg == NULL)
{
- return -1;
+ return -1;
}
- errno = 0;
- iValue = (int) strtol (arg, &parsing_end, 0);
- if (errno || (!parsing_end) || parsing_end[0] != 0)
+ errno = 0;
+ iValue = (int) strtol(arg, &parsing_end, 0);
+ if (errno || (!parsing_end) || parsing_end[0] != 0)
{
- iValue = -1;
+ iValue = -1;
}
errno = oldErrno;
- return iValue;
+ return iValue;
}
-
/*****************************************************************************
* Prototype : setlog_level_value
* Description : proc log level config
@@ -397,61 +523,62 @@ get_str_value (const char *arg)
* Calls :
* Called By :
*****************************************************************************/
-int
-setlog_level_value (const char *param, const char *value)
+int setlog_level_value(const char *param, const char *value)
{
- int i = 0;
- int module = 0;
- int logLevel = 0;
- module = get_str_value (param);
- if ((module < 0) || (MAX_LOG_MODULE <= module))
+ int i = 0;
+ int module = 0;
+ int logLevel = 0;
+ module = get_str_value(param);
+ if ((module < 0) || (MAX_LOG_MODULE <= module))
{
- NSOPR_LOGERR ("input module error]param=%s,module=%d", param, module);
- return 1;
+ NSOPR_LOGERR("input module error]param=%s,module=%d", param, module);
+ return 1;
}
-
- if (strcmp (value, LOG_LEVEL_ERR) == 0)
+ if (strcmp(value, LOG_LEVEL_ERR) == 0)
{
- logLevel = NSLOG_ERR;
+ logLevel = NSLOG_ERR;
}
- else if (strcmp (value, LOG_LEVEL_WAR) == 0)
+ else if (strcmp(value, LOG_LEVEL_WAR) == 0)
{
- logLevel = NSLOG_WAR;
+ logLevel = NSLOG_WAR;
}
- else if (strcmp (value, LOG_LEVEL_DBG) == 0)
+ else if (strcmp(value, LOG_LEVEL_DBG) == 0)
{
- logLevel = NSLOG_DBG;
+ logLevel = NSLOG_DBG;
}
- else if (strcmp (value, LOG_LEVEL_INF) == 0)
+ else if (strcmp(value, LOG_LEVEL_INF) == 0)
{
- logLevel = NSLOG_INF;
+ logLevel = NSLOG_INF;
}
- else if (strcmp (value, LOG_LEVEL_EMG) == 0)
+ else if (strcmp(value, LOG_LEVEL_EMG) == 0)
{
- logLevel = NSLOG_EMG;
+ logLevel = NSLOG_EMG;
}
- else
+ else
{
- NSOPR_LOGERR ("input log level error!");
- return 1;
+ NSOPR_LOGERR("input log level error!");
+ return 1;
}
- NSOPR_LOGINF ("set module log with level]module=%d,logLevel=0x%x",
- module, logLevel);
- if (module > 0)
+
+ NSOPR_LOGINF("set module log with level]module=%d,logLevel=0x%x", module,
+ logLevel);
+
+ if (module > 0)
{
- nstack_setlog_level (module, logLevel);
- return 0;
+ nstack_setlog_level(module, logLevel);
+ return 0;
}
- if (0 == module)
+
+ if (0 == module)
{
- for ( i = 0; i < MAX_LOG_MODULE ; i++ )
+ for (i = 0; i < MAX_LOG_MODULE; i++)
{
- nstack_setlog_level(i,logLevel);
+ nstack_setlog_level(i, logLevel);
}
}
- return 0;
-}
+ return 0;
+}
/*****************************************************************************
* Prototype : check_log_dir_valid
@@ -462,39 +589,39 @@ setlog_level_value (const char *param, const char *value)
* Calls :
* Called By :
*****************************************************************************/
-int
-check_log_dir_valid (const char *path)
+int check_log_dir_valid(const char *path)
{
- size_t length;
- struct stat statbuf;
- if (NULL == path)
+ size_t length;
+ struct stat statbuf;
+ if (NULL == path)
{
- return -1;
+ return -1;
}
- length = strlen (path) + 1;
- if ((length <= 1) || (length > FILE_NAME_LEN))
+
+ length = strlen(path) + 1;
+ if ((length <= 1) || (length > FILE_NAME_LEN))
{
- return -1;
+ return -1;
}
- /* only write permission is allowed */
- if ((0 != access (path, W_OK)))
+ /* only write permission is legal */
+ if ((0 != access(path, W_OK)))
{
- /* if path can access, use env path */
- return -1;
+ /* if path can access, use env path */
+ return -1;
}
- if ((0 == lstat (path, &statbuf)) && S_ISDIR (statbuf.st_mode))
+ if ((0 == lstat(path, &statbuf)) && S_ISDIR(statbuf.st_mode))
{
- return 0;
- }
- else
+ return 0;
+
+ }
+ else
{
- return -1;
+ return -1;
}
}
-
/*****************************************************************************
* Prototype : get_app_env_log_path
* Description : called by environment-specific log init function
@@ -505,49 +632,48 @@ check_log_dir_valid (const char *path)
* Calls :
* Called By :
*****************************************************************************/
-int
-get_app_env_log_path (char *app_file_path, unsigned int app_file_size)
+int get_app_env_log_path(char *app_file_path, unsigned int app_file_size)
{
- char *pst_app_log_path_flag = NULL;
- char *pst_app_log_path_string = NULL;
- int log_to_file = 0;
- int ret = -1;
- char *app_dir = NULL;
+ char *pst_app_log_path_flag = NULL;
+ char *pst_app_log_path_string = NULL;
+ int log_to_file = 0;
+ int ret = -1;
+ char *app_dir = NULL;
- if ((NULL == app_file_path) || (0 == app_file_size))
+ if ((NULL == app_file_path) || (0 == app_file_size))
{
- return 0;
+ return 0;
}
- pst_app_log_path_flag = getenv ("NSTACK_LOG_FILE_FLAG");
- if (pst_app_log_path_flag && strcmp (pst_app_log_path_flag, "1") == 0)
+
+ pst_app_log_path_flag = getenv("NSTACK_LOG_FILE_FLAG"); /* getenv() can be used */
+
+ if (pst_app_log_path_flag && strcmp(pst_app_log_path_flag, "1") == 0)
{
- /* if set environment variable to 1,then output to file*/
+ /* if set enviroment variable to 1,then output to file */
log_to_file = 1;
}
- else
+ else
{
- /* if environment variable is not equal 1 or
- don't set this environment variable ,output to STDOUT */
+ /* if enviroment variable is not equal 1 or don't set this enviroment variable ,output to STDOUT */
return 0;
}
/* add the realpath and dir check */
/* APP LOG can be set by user */
- pst_app_log_path_string = getenv("NSTACK_APP_LOG_PATH");
-
+ pst_app_log_path_string = getenv("NSTACK_APP_LOG_PATH"); /* getenv() can be used */
if ((NULL == pst_app_log_path_string)
- ||(strlen (pst_app_log_path_string) > FILE_NAME_LEN - 1))
+ || (strlen(pst_app_log_path_string) > FILE_NAME_LEN - 1))
{
- goto app_default;
+ goto app_default;
}
- app_dir = realpath (pst_app_log_path_string, NULL);
- if (check_log_dir_valid (pst_app_log_path_string) < 0)
+ app_dir = realpath(pst_app_log_path_string, NULL);
+ if (check_log_dir_valid(pst_app_log_path_string) < 0)
{
- goto app_default;
+ goto app_default;
}
- ret = STRCPY_S (app_file_path, app_file_size, app_dir);
- if(EOK != ret)
+ ret = strcpy_s(app_file_path, app_file_size, app_dir);
+ if (EOK != ret)
{
log_to_file = 0;
}
@@ -555,53 +681,28 @@ get_app_env_log_path (char *app_file_path, unsigned int app_file_size)
free(app_dir);
return log_to_file;
-app_default:
+ app_default:
- if ((0 == access (APP_LOG_PATH, W_OK)))
+ if ((0 == access(APP_LOG_PATH, W_OK)))
{
- ret = STRCPY_S (app_file_path, app_file_size, APP_LOG_PATH);
- if (EOK != ret)
+ ret = strcpy_s(app_file_path, app_file_size, APP_LOG_PATH);
+ if (EOK != ret)
{
- log_to_file = 0;
+ log_to_file = 0;
}
}
- else
+ else
{
- log_to_file = 0;
+ log_to_file = 0;
}
- if (NULL != app_dir)
+ if (NULL != app_dir)
{
- free (app_dir);
+ free(app_dir);
}
- return log_to_file;
-
-}
-
-/*****************************************************************************
-* Prototype : nstack_get_app_logname
-* Description : get the name of app's log
-* Input : None
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*****************************************************************************/
-int
-nstack_get_app_logname (char* log_name)
-{
- int pid = getpid ();
- char processname[FILE_NAME_LEN] = {0};
-
- if (log_name == NULL)
- return 1;
-
- strncpy (processname, program_invocation_short_name, 10);
-
- snprintf (log_name, FILE_NAME_LEN, "app_%s_%d.log", processname, pid);
+ return log_to_file;
- return 0;
}
/*****************************************************************************
@@ -613,252 +714,290 @@ nstack_get_app_logname (char* log_name)
* Calls :
* Called By :
*****************************************************************************/
-void
-nstack_log_init_app ()
+void nstack_log_init_app()
{
- char *pc_temp = NULL;
- int log_level = NSLOG_ERR;
- int i = 0;
- int file_flag = 0;
- char app_log_path[FILE_NAME_LEN] = { 0 };
- int ret = 0;
- char app_log_name[FILE_NAME_LEN] = { 0 };
+ char *pc_temp = NULL;
+ uint32_t log_level = NSLOG_ERR;
+ int i = 0;
+ int file_flag = 0;
+ char app_log_path[FILE_NAME_LEN] = { 0 };
- /* log already initialized, just return */
- if (LOG_PRO_INVALID != g_my_pro_type)
+ /* log alread initialized, just return */
+ if (LOG_PRO_INVALID != g_my_pro_type)
{
- return;
+ return;
}
- /* Add app log hook module init */
- nstack_log_hook_init ();
- if (0 != g_nstack_logs[NSOCKET].inited)
+ /* Add app log hook module init */
+ nstack_log_hook_init();
+
+ if (0 != g_nstack_logs[NSOCKET].inited)
{
- return;
+ return;
}
- glogInit ("APP");
- pc_temp = getenv ("NSTACK_LOG_ON");
- if (pc_temp)
+ glogInit("APP");
+
+ pc_temp = getenv("NSTACK_LOG_ON"); /*getenv() can be used */
+
+ if (pc_temp)
{
- if (strcmp (pc_temp, "INF") == 0)
- {
- log_level = NSLOG_INF;
- }
- else if (strcmp (pc_temp, "DBG") == 0)
+ if (strcmp(pc_temp, "INF") == 0)
{
- log_level = NSLOG_DBG;
+ log_level = NSLOG_INF;
}
- else if (strcmp (pc_temp, "WAR") == 0)
+ else if (strcmp(pc_temp, "DBG") == 0)
{
- log_level = NSLOG_WAR;
+ log_level = NSLOG_DBG;
}
- else if (strcmp (pc_temp, "ERR") == 0)
+ else if (strcmp(pc_temp, "WAR") == 0)
{
- log_level = NSLOG_ERR;
+ log_level = NSLOG_WAR;
}
- else if (strcmp (pc_temp, "EMG") == 0)
+ else if (strcmp(pc_temp, "ERR") == 0)
{
- log_level = NSLOG_EMG;
+ log_level = NSLOG_ERR;
}
- else if (strcmp (pc_temp, "PERF") == 0)
+ else if (strcmp(pc_temp, "EMG") == 0)
{
- ctrl_log_switch = 1;
+ log_level = NSLOG_EMG;
}
- else
+ else
{
- log_level = NSLOG_ERR;
+ log_level = NSLOG_ERR;
}
}
- else
+ else
{
- log_level = NSLOG_ERR;
+ log_level = NSLOG_ERR;
}
- /* socket interface APP called include both stack-x and nstack module! */
- nstack_setlog_level (STACKX, log_level);
- nstack_setlog_level (NSOCKET, log_level);
- nstack_setlog_level (LOGRTE, log_level);
- nstack_setlog_level (LOGDFX, log_level);
- nstack_setlog_level (LOGFW, log_level);
- nstack_setlog_level (LOGHAL, log_level);
- nstack_setlog_level (LOGSBR, log_level);
+ /* socket interface APP called include both stackpool and nstack module! */
+ nstack_setlog_level(STACKPOOL, log_level);
+ nstack_setlog_level(NSOCKET, log_level);
+ nstack_setlog_level(LOGRTP, log_level);
+ nstack_setlog_level(LOGDFX, log_level);
+ nstack_setlog_level(LOGFW, log_level);
+ nstack_setlog_level(LOGHAL, log_level);
+ nstack_setlog_level(LOGSBR, log_level);
- /* package the app env handle function, Begin */
- file_flag = get_app_env_log_path (app_log_path, FILE_NAME_LEN);
- if ((1 == file_flag) && (strlen (app_log_path) > 0))
+ file_flag = get_app_env_log_path(app_log_path, FILE_NAME_LEN);
+ if ((1 == file_flag) && (strlen(app_log_path) > 0))
{
- glogDir (app_log_path);
- glogBufLevelSet (GLOG_LEVEL_WARNING);
- (void) glogLevelSet (GLOG_LEVEL_DEBUG);
- for (i = 0; i < GLOG_LEVEL_BUTT; i++)
- glogSetLogSymlink (i, "");
- nstack_log_count_set (APP_LOG_COUNT);
- glogMaxLogSizeSet (APP_LOG_SIZE);
- ret = nstack_get_app_logname (app_log_name);
- if (ret == 0)
- {
- glogSetLogFilenameExtension (app_log_name);
- }
- else
- {
- glogSetLogFilenameExtension (APP_LOG_NAME);
- }
- glogFlushLogSecsSet (FLUSH_TIME);
+ /* change to glog functions,no need file type control */
+ glogDir(app_log_path);
+ glogBufLevelSet(GLOG_LEVEL_WARNING);
+ (void) glogLevelSet(GLOG_LEVEL_DEBUG);
+ for (i = 0; i < GLOG_LEVEL_BUTT; i++)
+ glogSetLogSymlink(i, "");
+ nstack_log_count_set(APP_LOG_COUNT);
+ glogMaxLogSizeSet(APP_LOG_SIZE);
+ glogSetLogFilenameExtension(APP_LOG_NAME);
+ glogFlushLogSecsSet(FLUSH_TIME);
}
- else
+ else
{
- glogToStderrSet (1);
+ glogToStderrSet(1);
}
- for (i = 0; i < MAX_LOG_MODULE; i++)
+ for (i = 0; i < MAX_LOG_MODULE; i++)
{
- g_nstack_logs[i].file_type = LOG_TYPE_APP;
+ g_nstack_logs[i].file_type = LOG_TYPE_APP;
}
- init_log_ctrl_info ();
- g_my_pro_type = LOG_PRO_APP;
- SetGlogCtrlOpt (TRUE);
- NSPOL_LOGERR ("app_nStack_version=%s", NSTACK_VERSION);
- return;
+
+ init_log_ctrl_info();
+
+ g_my_pro_type = LOG_PRO_APP;
+ SetGlogCtrlOpt(TRUE);
+
+ NSPOL_LOGCUSINF("app_nStack_version=%s", NSTACK_VERSION);
+ return;
}
-void
-nstack_segment_error (int s)
+void nstack_segment_error(int s)
{
-
#define BACKTRACE_SIZ 20
- void *array[BACKTRACE_SIZ];
- int size;
- int i;
- char **strings = NULL;
- /*if set, flush the log immediately */
- glogFlushLogFiles (GLOG_LEVEL_DEBUG);
+ void *array[BACKTRACE_SIZ];
+ int size;
+ int i;
+ char **strings = NULL;
- size = backtrace (array, BACKTRACE_SIZ);
- NSPOL_LOGEMG
- ("------------------DUMP_BACKTRACE[%d]--------------------------------\n",
- size);
+ /*if set, flush the log immediately */
+ glogFlushLogFiles(GLOG_LEVEL_DEBUG);
- /* easy to view signal in separate log file */
- NSPOL_LOGEMG ("Received signal s=%d", s);
+ size = backtrace(array, BACKTRACE_SIZ);
+ NSPOL_LOGEMG
+ ("------------------DUMP_BACKTRACE[%d]--------------------------------\n",
+ size);
- for (i = 0; i < size; i++)
+ /*easy to view signal in separate log file */
+ NSPOL_LOGEMG("Received signal s=%d", s);
+
+ for (i = 0; i < size; i++)
{
- NSPOL_LOGEMG ("[%d]:%p\n", i, array[i]);
+ NSPOL_LOGEMG("[%d]:%p\n", i, array[i]);
}
- strings = backtrace_symbols (array, size);
- if (NULL == strings)
+
+ strings = backtrace_symbols(array, size);
+ if (NULL == strings)
{
- return;
+ return;
}
- for (i = 0; i < size; i++)
+ for (i = 0; i < size; i++)
{
- NSPOL_LOGEMG ("[%d]:%s\n", i, strings[i]);
+ NSPOL_LOGEMG("[%d]:%s\n", i, strings[i]);
}
- NSPOL_LOGEMG
- ("-------------------------------------------------------------------\n");
- free (strings);
+
+ NSPOL_LOGEMG
+ ("-------------------------------------------------------------------\n");
+ free(strings); /*free() can be used */
+
}
-void
-set_log_init_para (struct log_init_para *para)
+void set_log_init_para(struct log_init_para *para)
{
- if (NULL == para)
-
+ if (NULL == para)
{
- return;
+ return;
}
- if (EOK !=
- MEMCPY_S (&g_log_init_para, sizeof (struct log_init_para), para,
- sizeof (struct log_init_para)))
+ if (EOK !=
+ memcpy_s(&g_log_init_para, sizeof(struct log_init_para), para,
+ sizeof(struct log_init_para)))
{
- return;
+ return;
}
}
/* control log printed counts */
-static inline void
-update_log_prt_time (struct timespec *cur_time, struct timespec *log_prt_time)
+static inline void update_log_prt_time(struct timespec *cur_time,
+ struct timespec *log_prt_time)
{
- log_prt_time->tv_sec = cur_time->tv_sec;
- log_prt_time->tv_nsec = cur_time->tv_nsec;
+ log_prt_time->tv_sec = cur_time->tv_sec;
+ log_prt_time->tv_nsec = cur_time->tv_nsec;
}
-int
-check_log_prt_time (int id)
+bool check_log_prt_time(int id)
{
- struct timespec cur_time;
- struct timespec *log_prt_time = NULL;
- if (id >= LOG_CTRL_ID_MAX || id < 0)
+ struct timespec cur_time;
+ struct timespec *log_prt_time = NULL;
+
+ if (id >= LOG_CTRL_ID_MAX || id < 0)
+ {
+ return FALSE;
+ }
+
+ (void) clock_gettime(CLOCK_MONOTONIC, &cur_time);
+ log_prt_time = &g_log_ctrl_info[id].last_log_time;
+ if (cur_time.tv_sec - log_prt_time->tv_sec >=
+ g_log_ctrl_info[id].expire_time)
{
- return 0;
+ /*first log need print, Begin */
+ set_log_ctrl_time(id, DEFAULT_LOG_CTR_TIME);
+ update_log_prt_time(&cur_time, log_prt_time);
+ return TRUE;
}
- (void) clock_gettime (CLOCK_MONOTONIC, &cur_time);
- log_prt_time = &g_log_ctrl_info[id].last_log_time;
- if (cur_time.tv_sec - log_prt_time->tv_sec >=
- g_log_ctrl_info[id].expire_time)
+
+ g_log_ctrl_info[id].unprint_count++;
+ return FALSE;
+}
+
+/*****************************************************************************
+* Prototype : check_log_restrain_valid
+* Description : check if the log if valid and ctrl restrain time expire.
+* Input : int id
+* : uint32_t module,
+* : uint32_t level
+* ...
+* Output : None
+* Return Value : bool
+* Calls :
+* Called By :
+*****************************************************************************/
+bool check_log_restrain_valid(int id, uint32_t module, uint32_t level)
+{
+ if (nstack_log_info_check(module, level) && check_log_prt_time(id))
{
- /* first log need print */
- set_log_ctrl_time (id, DEFAULT_LOG_CTR_TIME);
- update_log_prt_time (&cur_time, log_prt_time);
- return 1;
+ return TRUE;
}
- g_log_ctrl_info[id].unprint_count++;
- return 0;
+
+ return FALSE;
}
-int
-get_unprt_log_count (int id)
+int get_unprt_log_count(int id)
{
- return g_log_ctrl_info[id].unprint_count;
+ return g_log_ctrl_info[id].unprint_count;
}
-void
-clr_unprt_log_count (int id)
+void clr_unprt_log_count(int id)
{
- g_log_ctrl_info[id].unprint_count = 0;
+ g_log_ctrl_info[id].unprint_count = 0;
}
-void
-set_log_ctrl_time (int id, int ctrl_time)
+void set_log_ctrl_time(int id, int ctrl_time)
{
- if (id >= LOG_CTRL_ID_MAX || id < 0)
+ if (id >= LOG_CTRL_ID_MAX || id < 0)
{
- return;
+ return;
}
- if (ctrl_time <= 0)
+ if (ctrl_time <= 0)
+ {
+ return;
+ }
+
+ g_log_ctrl_info[id].expire_time = ctrl_time;
+}
+
+void init_log_ctrl_info()
+{
+ int i = 0;
+ for (; i < LOG_CTRL_ID_MAX; i++)
{
- return;
+ /*first log need print */
+ g_log_ctrl_info[i].expire_time = 0;
+ g_log_ctrl_info[i].unprint_count = 0;
+ g_log_ctrl_info[i].last_log_time.tv_sec = 0;
+ g_log_ctrl_info[i].last_log_time.tv_nsec = 0;
}
- g_log_ctrl_info[id].expire_time = ctrl_time;
+ // for every socket api, need different log id
+
+ // for nstack inner
+}
+
+void set_log_proc_type(int log_proc_type)
+{
+ g_my_pro_type = log_proc_type;
}
-void
-init_log_ctrl_info ()
+int nstack_log_flush(unsigned long long timeout)
{
- int i = 0;
- for (; i < LOG_CTRL_ID_MAX; i++)
+ if (LOG_PRO_APP <= g_my_pro_type)
{
- /* first log need print */
- g_log_ctrl_info[i].expire_time = 0;
- g_log_ctrl_info[i].unprint_count = 0;
- g_log_ctrl_info[i].last_log_time.tv_sec = 0;
- g_log_ctrl_info[i].last_log_time.tv_nsec = 0;
+ glogFlushLogFiles(GLOG_LEVEL_DEBUG);
+ return 0;
}
- // for every socket api, need different log id
+ if (log_asyn_inited)
+ {
+ return nstack_log_server_flush(g_my_pro_type, timeout);
+ }
+ else
+ {
+ return -1;
+ }
+}
- // for nstack inner
+void set_nstack_log_nonreentry(uint32_t val)
+{
+ nstack_log_nonreentry = val;
}
-void
-set_log_proc_type (int log_proc_type)
+unsigned int get_nstack_log_nonreentry(void)
{
- g_my_pro_type = log_proc_type;
+ return nstack_log_nonreentry;
}
diff --git a/src/framework/log/nstack_log_async.c b/src/framework/log/nstack_log_async.c
new file mode 100644
index 0000000..1b17d8d
--- /dev/null
+++ b/src/framework/log/nstack_log_async.c
@@ -0,0 +1,1427 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+/*==============================================*
+ * include header files *
+ *----------------------------------------------*/
+
+#include <fcntl.h>
+#include <sys/epoll.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <pthread.h>
+#include "types.h"
+#include "nstack_securec.h"
+#include "nsfw_base_linux_api.h"
+#include "nstack_log_async.h"
+
+#include <signal.h>
+#include <syscall.h>
+
+/*sockaddr_un.sun_path is an array of 108 bytes*/
+#define UNIX_SOCK_MAX_PATH_LEN 108
+#define MAX_CONN_NUM 5
+#define MAX_LOG_RECV_BUF 0x34000*2
+#define ASYNLOG_THREAD_NAME "nstk_log_asyn"
+
+NSTACK_STATIC char nstack_sock_running[UNIX_SOCK_MAX_PATH_LEN + 1];
+NSTACK_STATIC char nstack_sock_operation[UNIX_SOCK_MAX_PATH_LEN + 1];
+NSTACK_STATIC char nstack_sock_master[UNIX_SOCK_MAX_PATH_LEN + 1];
+NSTACK_STATIC char nstack_sock_ctrl[UNIX_SOCK_MAX_PATH_LEN + 1];
+NSTACK_STATIC char nstack_sock_dir[UNIX_SOCK_MAX_PATH_LEN + 1];
+
+int g_nstack_log_client_fd[MAX_LOG_TYPE] = { -1, -1, -1, -1, -1 };
+int g_nstack_log_server_fd[MAX_LOG_TYPE] = { -1, -1, -1, -1, -1 };
+
+#define NSTACK_LOG_SER_STATE_RUNNING 0
+#define NSTACK_LOG_SER_STATE_FLUSHING 1
+
+#define NSTACK_LOG_SER_FLUSH_SIG '\5'
+
+NSTACK_STATIC int g_nstack_log_server_state[MAX_LOG_TYPE] = { NSTACK_LOG_SER_STATE_RUNNING }; /*can be used */
+
+static int pre_init_log_count = 0;
+static struct pre_init_info pre_init_log[MAX_PRE_INIT_LOG_COUNT] =
+ { {0, ""} };
+__thread unsigned int pre_log_nonreentry = 0;
+extern bool log_asyn_inited;
+
+/*****************************************************************************
+* Prototype : nstack_log_sock_set
+* Description : set the sockfd state, for example O_NONBLOCK and so on,
+* Input : int sock: fd.
+* : int type: module type.
+* ...
+* Output : None
+* Return Value : 0 means success, -1 means fail.
+* Calls :
+* Called By :
+*****************************************************************************/
+NSTACK_STATIC inline int nstack_log_sock_set(int sock, int type)
+{
+ int flags;
+
+ if (type < 0)
+ {
+ return -1;
+ }
+
+ flags = nsfw_base_fcntl(sock, F_GETFD, 0);
+ if (flags < 0)
+ {
+ return -1;
+ }
+
+ flags |= type;
+
+ if (nsfw_base_fcntl(sock, F_SETFD, flags) < 0)
+ {
+ return -1;
+ }
+
+ return 0;
+}
+
+/*****************************************************************************
+* Prototype : unlink_log_servername
+* Description : unlink the servername
+* Input : int log_type:
+* ...
+* Output : None
+* Return Value : void
+* Calls :
+* Called By :
+*****************************************************************************/
+
+void unlink_log_servername(int log_type)
+{
+ switch (log_type)
+ {
+ case LOG_TYPE_NSTACK:
+ unlink(nstack_sock_running);
+ break;
+ case LOG_TYPE_OPERATION:
+ unlink(nstack_sock_operation);
+ break;
+ case LOG_TYPE_MASTER:
+ unlink(nstack_sock_master);
+ break;
+ case LOG_TYPE_CTRL:
+ unlink(nstack_sock_ctrl);
+ break;
+ default:
+ break;
+ }
+ return;
+
+}
+
+/*****************************************************************************
+* Prototype : nstack_log_sock_path
+* Description : init the nstack log domain socket path which use to handle
+* the log with a thread of long connect
+* Input : int proc_type
+* ...
+* Output : static varible store
+* Return Value : >=0 means success, -1 means fail.
+* Calls :
+* Called By :
+*****************************************************************************/
+NSTACK_STATIC int nstack_log_sock_path(int proc_type)
+{
+ char *directory = "/var/run";
+ const char *home_dir = getenv("HOME"); /*can be used */
+ bool env_path = FALSE;
+ int ret = -1;
+ int val = -1;
+ int val_opera = -1;
+ pid_t pid = getpid();
+
+ if (getuid() != 0 && home_dir != NULL)
+ {
+ directory = realpath(home_dir, NULL);
+ if (!directory)
+ {
+ save_pre_init_log(NSLOG_ERR, "directory is NULL]errno=%d", errno);
+ return -1;
+ }
+ env_path = TRUE;
+ }
+
+ if (EOK != (ret = strcpy_s(nstack_sock_dir, UNIX_SOCK_MAX_PATH_LEN, directory))) /* check return value with EOK */
+ {
+ save_pre_init_log(NSLOG_ERR, "strcpy_s fail]ret=%d", ret);
+ goto err_init;
+ }
+
+ /*modify 'destMax' and return value check */
+ if (EOK !=
+ (ret =
+ strcat_s(nstack_sock_dir, sizeof(nstack_sock_dir), "/ip_module")))
+ {
+ save_pre_init_log(NSLOG_ERR, "strcat_s fail]ret=%d", ret);
+ goto err_init;
+ }
+
+ switch (proc_type)
+ {
+ case LOG_PRO_NSTACK:
+ val =
+ sprintf_s(nstack_sock_running, UNIX_SOCK_MAX_PATH_LEN,
+ "%s/%s_%d", nstack_sock_dir, "nStackMainRunLog",
+ pid);
+ val_opera =
+ sprintf_s(nstack_sock_operation, UNIX_SOCK_MAX_PATH_LEN,
+ "%s/%s_%d", nstack_sock_dir, "nStackMainOpeLog",
+ pid);
+ if (val_opera < 0)
+ {
+ save_pre_init_log(NSLOG_ERR, "sprintf_s fail]val_opera=%d",
+ val_opera);
+ ret = -1;
+ goto err_init;
+ }
+ break;
+ case LOG_PRO_MASTER:
+ val =
+ sprintf_s(nstack_sock_master, UNIX_SOCK_MAX_PATH_LEN,
+ "%s/%s_%d", nstack_sock_dir, "nStackMasterLog",
+ pid);
+ break;
+ case LOG_PRO_OMC_CTRL:
+ // nStackCtrl don't add pid, as it may exit before unlink which may leave a useless file in ip_module directory.
+ // this will cause losing some log sometime, but it's ok.
+ val =
+ sprintf_s(nstack_sock_ctrl, UNIX_SOCK_MAX_PATH_LEN, "%s/%s",
+ nstack_sock_dir, "nStackCtrlLog");
+ break;
+ default:
+ save_pre_init_log(NSLOG_ERR, "process invalid]proc_type=%d",
+ proc_type);
+ ret = -1;
+ goto err_init;
+ }
+
+ if ((val < 0))
+ {
+ save_pre_init_log(NSLOG_ERR, "sprintf_s fail]proc_type=%d,val=%d",
+ proc_type, val);
+ ret = -1;
+ goto err_init;
+ }
+
+ ret = 0;
+
+ err_init:
+
+ if (env_path == TRUE)
+ {
+ free(directory);
+ }
+ return ret;
+}
+
+/*****************************************************************************
+* Prototype : nstack_log_sock_listen
+* Description : create the nstack log domain socket, bind the share domain file,
+* listen the client connect, for server side.
+* Input : const char *servername, file name for the domain
+* ...
+* Output : listen fd
+* Return Value : >=0 means success, -1 means fail.
+* Calls :
+* Called By :
+*****************************************************************************/
+NSTACK_STATIC int nstack_log_sock_listen(const char *servername)
+{
+ int fd, ret;
+ unsigned int len;
+ struct stat st;
+ struct sockaddr_un un;
+ int opt = 1;
+
+ if ((ret = stat(nstack_sock_dir, &st)) != 0)
+ {
+ save_pre_init_log(NSLOG_ERR,
+ "stat get file info fail]ret=%d,nstack_sock_dir=%s",
+ ret, nstack_sock_dir);
+ return -1;
+ }
+
+ if ((fd = nsfw_base_socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
+ {
+ save_pre_init_log(NSLOG_ERR, "create socket fail]fd=%d,errno=%d", fd,
+ errno);
+ return -1;
+ }
+
+ if ((ret =
+ nsfw_base_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt,
+ sizeof(opt))) < 0)
+ {
+ save_pre_init_log(NSLOG_ERR, "set socket reuse fail]ret=%d,errno=%d",
+ ret, errno);
+ goto listen_err;
+ }
+
+ unlink(servername); /* in case it already exists */
+
+ ret = memset_s(&un, sizeof(un), 0, sizeof(un));
+ if (EOK != ret)
+ {
+ save_pre_init_log(NSLOG_ERR, "memset_s fail]ret=%d", ret);
+ goto listen_err;
+ }
+
+ un.sun_family = AF_UNIX;
+ ret = strcpy_s(un.sun_path, sizeof(un.sun_path), servername);
+ if (EOK != ret)
+ {
+ save_pre_init_log(NSLOG_ERR, "strcpy_s fail]ret=%d", ret);
+ goto listen_err;
+ }
+
+ len =
+ (unsigned int) (offsetof(struct sockaddr_un, sun_path) +
+ strlen(servername));
+
+ if ((ret = nsfw_base_bind(fd, (struct sockaddr *) &un, len)) < 0)
+ {
+ save_pre_init_log(NSLOG_ERR,
+ "bind domain socket fail]ret=%d,errno=%d", ret,
+ errno);
+ goto listen_err;
+ }
+
+ if ((ret = nsfw_base_listen(fd, MAX_CONN_NUM)) < 0)
+ {
+ save_pre_init_log(NSLOG_ERR, "listen fail]ret=%d,errno=%d", ret,
+ errno);
+ goto listen_err;
+ }
+
+ return fd;
+
+ listen_err:
+
+ (void) nsfw_base_close(fd);
+
+ return -1;
+
+}
+
+/*****************************************************************************
+* Prototype : nstack_log_fd_to_type
+* Description : traverse the fd from fds to get the fd num, it returns
+* the file type, which matches the fd.
+* Input : int *fds
+* : int fd
+* ...
+* Output : fd
+* Return Value : >=0 means success, -1 means fail.
+* Calls :
+* Called By :
+*****************************************************************************/
+NSTACK_STATIC inline int nstack_log_fd_to_type(const int *fds, int fd)
+{
+ int i;
+ for (i = 0; i <= LOG_TYPE_CTRL; i++)
+ {
+ if (fd == fds[i])
+ {
+ return i;
+ }
+ }
+ return -1;
+}
+
+/*****************************************************************************
+* Prototype : nstack_log_signal_handler
+* Description : syn Leibniz issue, the signal interrupt 34, the log collect
+* thread create early as process signal handle too late.
+* Input : None
+* ...
+* Output : None
+* Return Value : 0 success, -1 false
+* Calls :
+* Called By :
+*****************************************************************************/
+int nstack_log_signal_handler()
+{
+ sigset_t waitset, oset;
+ int s = -1;
+
+ if (0 != sigemptyset(&waitset))
+ {
+ NS_PTHREADLOG(LOG_TYPE_UNRECOGNIZED, NSLOG_ERR, "sigemptyset fail");
+ return -1;
+ }
+
+ if (0 != sigaddset(&waitset, SIGRTMIN))
+ {
+ NS_PTHREADLOG(LOG_TYPE_UNRECOGNIZED, NSLOG_ERR,
+ "sigaddset fail]SIGRTMIN");
+ return -1;
+ }
+
+ if (0 != sigaddset(&waitset, SIGRTMIN + 2))
+ {
+ NS_PTHREADLOG(LOG_TYPE_UNRECOGNIZED, NSLOG_ERR,
+ "sigaddset fail]SIGRTMIN+2");
+ return -1;
+ }
+
+ if ((s = pthread_sigmask(SIG_BLOCK, &waitset, &oset)) != 0)
+ {
+ NS_PTHREADLOG(LOG_TYPE_UNRECOGNIZED, NSLOG_ERR,
+ "pthread_sigmask fail]s=%d", s);
+ return -1;
+ }
+
+ return 0;
+
+}
+
+#define ASYNC_MAXEVENTS 20
+NSTACK_STATIC int nstack_log_server_prepare(int proc_type,
+ struct epoll_event *ev,
+ int *epfd,
+ struct epoll_event *events)
+{
+ int ret;
+ int listen_fd;
+
+ /* thread signal mask handle */
+ if (nstack_log_signal_handler() < 0)
+ {
+ NS_PTHREADLOG(LOG_TYPE_UNRECOGNIZED, NSLOG_ERR,
+ "signal handle fail]proc_type=%d", proc_type);
+ return -1;
+ }
+
+ /* init the array */
+ ret =
+ memset_s(events, sizeof(struct epoll_event) * ASYNC_MAXEVENTS, 0,
+ sizeof(struct epoll_event) * ASYNC_MAXEVENTS);
+ if (EOK != ret)
+ {
+ NS_PTHREADLOG(LOG_TYPE_UNRECOGNIZED, NSLOG_ERR,
+ "memset_s fail]ret=%d,proc_type=%d", ret, proc_type);
+ return -1;
+ }
+
+ // create ep fd, the max scope of epoll is 256
+ *epfd = nsfw_base_epoll_create(256);
+ if (*epfd < 0)
+ {
+ NS_PTHREADLOG(LOG_TYPE_UNRECOGNIZED, NSLOG_ERR,
+ "create epoll fail]epfd=%d,proc_type=%d,errno=%d",
+ *epfd, proc_type, errno);
+ return -1;
+ }
+
+ int i;
+ for (i = 0; i <= LOG_TYPE_CTRL; i++)
+ {
+ if ((listen_fd = g_nstack_log_server_fd[i]) <= 0)
+ {
+ continue;
+ }
+ ev->data.fd = listen_fd;
+ ev->events = EPOLLIN;
+
+ // add server listen fd to epoll
+ if ((ret =
+ nsfw_base_epoll_ctl(*epfd, EPOLL_CTL_ADD, listen_fd, ev)) < 0)
+ {
+ NS_PTHREADLOG(LOG_TYPE_UNRECOGNIZED, NSLOG_ERR,
+ "epoll ctl add fail]ret=%d,epfd=%d,listen_fd=%d,errno=%d",
+ ret, *epfd, listen_fd, errno);
+ return -1;
+ }
+ }
+ return 0;
+
+}
+
+NSTACK_STATIC int nstack_log_server_recv_old(int *accepted_fd,
+ struct epoll_event *event)
+{
+ int sockfd;
+ int log_type;
+ //one log content 2048 enough.
+ char buffer[MAX_BUFFER_LEN];
+ ssize_t num;
+
+ log_type = nstack_log_fd_to_type(accepted_fd, event->data.fd);
+ /*log_type has been protected */
+ if ((log_type >= 0) && (log_type < MAX_LOG_TYPE))
+ {
+ if ((sockfd = event->data.fd) < 0)
+ {
+ NS_PTHREADLOG(log_type, NSLOG_WAR,
+ "accept fd invalid]sockfd=%d,log_type=%d", sockfd,
+ log_type);
+ return -1;
+ }
+
+ /* change 3th param from 'sizeof(buffer)' to 'sizeof(buffer)-1', make room for '\0' terminated */
+ if ((num =
+ nsfw_base_recv(sockfd, buffer, sizeof(buffer) - 1, 0)) <= 0)
+ {
+ if (num == 0 || (errno != EAGAIN && errno != EINTR))
+ {
+ //if server close, client side will recv EPIPE
+ NS_PTHREADLOG(log_type, NSLOG_ERR,
+ "recv the msg fail]sockfd=%d,num=%ld,log_type=%d,errno=%d",
+ sockfd, num, log_type, errno);
+ (void) nsfw_base_close(accepted_fd[log_type]);
+ accepted_fd[log_type] = -1;
+ }
+ return -1;
+ }
+
+ int offset = 0;
+ int j;
+ if (g_nstack_log_server_state[log_type] ==
+ NSTACK_LOG_SER_STATE_FLUSHING)
+ {
+ for (j = 0; j < num; j++)
+ {
+ if (buffer[j] == NSTACK_LOG_SER_FLUSH_SIG)
+ {
+ buffer[j] = '\0';
+ glog_print_buffer(log_type, buffer, j);
+ glogFlushLogFiles(GLOG_LEVEL_DEBUG);
+
+ (void) (__sync_bool_compare_and_swap
+ (&g_nstack_log_server_state[log_type],
+ NSTACK_LOG_SER_STATE_FLUSHING,
+ NSTACK_LOG_SER_STATE_RUNNING));
+
+ offset = j + 1;
+ break;
+ }
+ }
+ }
+
+ /* make buffer '\0' terminated. glog_print_buffer() need a '\0' terminated string, or it will coredump!!! */
+ buffer[num] = '\0';
+
+ if (offset < num)
+ {
+ // write file
+ glog_print_buffer(log_type, buffer + offset, num - offset);
+ }
+
+ return -1;
+ }
+
+ return 0;
+}
+
+NSTACK_STATIC int nstack_log_server_accept_new(int *accepted_fd,
+ struct epoll_event *ev,
+ int epfd,
+ struct epoll_event *event)
+{
+ int ret;
+ int log_type;
+
+ log_type = nstack_log_fd_to_type(g_nstack_log_server_fd, event->data.fd);
+ /*log_type has been protected */
+ if ((log_type >= 0) && (log_type < MAX_LOG_TYPE))
+ {
+ struct sockaddr_un un_cli;
+ socklen_t clilen = sizeof(un_cli);
+ accepted_fd[log_type] =
+ nsfw_base_accept(event->data.fd, (struct sockaddr *) &un_cli,
+ &clilen);
+ if (accepted_fd[log_type] < 0)
+ {
+ NS_PTHREADLOG(log_type, NSLOG_WAR,
+ "accept the socket fail]accepted_fd[%d]=%d,errno=%d",
+ log_type, accepted_fd[log_type], errno);
+ return -1;
+ }
+ ev->data.fd = accepted_fd[log_type];
+
+ int size, size_len;
+ size = MAX_LOG_RECV_BUF;
+ size_len = sizeof(size);
+ if ((ret =
+ nsfw_base_setsockopt(accepted_fd[log_type], SOL_SOCKET,
+ SO_RCVBUF, (void *) &size,
+ (socklen_t) size_len)) < 0)
+ {
+ NS_PTHREADLOG(log_type, NSLOG_WAR,
+ "set the socket sendbuf fail]accepted_fd[%d]=%d,ret=%d,errno=%d",
+ log_type, accepted_fd[log_type], ret, errno);
+ (void) nsfw_base_close(accepted_fd[log_type]);
+ accepted_fd[log_type] = -1;
+ return -1;
+ }
+
+ //set the non_blocking mode.
+ if ((ret =
+ nstack_log_sock_set(accepted_fd[log_type], O_NONBLOCK)) < 0)
+ {
+ NS_PTHREADLOG(log_type, NSLOG_WAR,
+ "set the socket non_blocking fail]accepted_fd[%d]=%d,ret=%d",
+ log_type, accepted_fd[log_type], ret);
+ (void) nsfw_base_close(accepted_fd[log_type]);
+ accepted_fd[log_type] = -1;
+ return -1;
+ }
+
+ if ((ret =
+ nsfw_base_epoll_ctl(epfd, EPOLL_CTL_ADD, accepted_fd[log_type],
+ ev)) < 0)
+ {
+ NS_PTHREADLOG(log_type, NSLOG_WAR,
+ "add epoll fail]accepted_fd[%d]=%d,ret=%d,errno=%d",
+ log_type, accepted_fd[log_type], ret, errno);
+ (void) nsfw_base_close(accepted_fd[log_type]);
+ accepted_fd[log_type] = -1;
+ return -1;
+ }
+
+ if ((ret =
+ nsfw_base_epoll_ctl(epfd, EPOLL_CTL_DEL, event->data.fd,
+ NULL)) < 0)
+ {
+ NS_PTHREADLOG(log_type, NSLOG_WAR,
+ "delete the epoll listen fail]event->data.fd=%d,ret=%d,errno=%d",
+ event->data.fd, ret, errno);
+ }
+
+ // remove server listening fd and servername as no use then
+ (void) nsfw_base_close(event->data.fd);
+
+ unlink_log_servername(log_type);
+
+ }
+
+ return 0;
+}
+
+/*****************************************************************************
+* Prototype : nstack_log_server_process
+* Description : init the nstack log domain socket for server side, and create
+* a thread to wait the client conect or data come.
+* Input : int proc_type
+* ...
+* Output : None
+* Return Value : void*
+* Calls :
+* Called By :
+*****************************************************************************/
+void *nstack_log_server_process(void *args)
+{
+ int epfd;
+ struct epoll_event ev, events[ASYNC_MAXEVENTS];
+ int accepted_fd[MAX_LOG_TYPE] = { -1, -1, -1, -1, -1 };
+ int proc_type = (int) (u64) args;
+
+ if (0 != nstack_log_server_prepare(proc_type, &ev, &epfd, events))
+ {
+ /* err msg has been printed */
+ return ((void *) 0);
+ }
+
+ while (1)
+ {
+ int i;
+ int nfds = nsfw_base_epoll_wait(epfd, events, ASYNC_MAXEVENTS, -1);
+
+ for (i = 0; i < nfds; i++)
+ {
+ /*Notes: it listen the epoll all of the process, cannot save the log by save_pre_init_log
+ * for the log recv module*/
+ if (0 != nstack_log_server_recv_old(accepted_fd, &events[i]))
+ continue;
+
+ /*Notes: accept the client fd */
+ if (0 !=
+ nstack_log_server_accept_new(accepted_fd, &ev, epfd,
+ &events[i]))
+ continue;
+ }
+
+ }
+
+ return ((void *) 0); /*can be used, should never get here */
+}
+
+/*****************************************************************************
+* Prototype : nstack_log_sock_conn
+* Description : create the nstack log domain socket, and connect the server,
+* for client side.
+* Input : const char *servername, file name for the domain
+* ...
+* Output : fd
+* Return Value : >=0 means success, -1 means fail.
+* Calls :
+* Called By :
+*****************************************************************************/
+NSTACK_STATIC int nstack_log_sock_conn(const char *servername)
+{
+ int fd = -1;
+ unsigned int len;
+ struct sockaddr_un un;
+ int opt = 1;
+ int ret = -1;
+ int size = MAX_LOG_RECV_BUF;
+ size_t size_len;
+ size_len = sizeof(size);
+
+ if (NULL == servername)
+ {
+ save_pre_init_log(NSLOG_ERR,
+ "invalid input parameter]servername=NULL");
+ return -1;
+ }
+
+ //create a UNIX domain stream socket and it is non blocking
+ if ((fd = nsfw_base_socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0)) < 0) /*can be used */
+ {
+ save_pre_init_log(NSLOG_ERR,
+ "client create the domain socket fail]fd=%d,errno=%d",
+ fd, errno);
+ return -1;
+ }
+
+ if ((ret =
+ nsfw_base_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt,
+ sizeof(opt))) < 0)
+ {
+ save_pre_init_log(NSLOG_ERR,
+ "client set domain socket reuse fail]fd=%d,ret=%d,errno=%d",
+ fd, ret, errno);
+ goto connect_err;
+ }
+
+ if ((ret =
+ nsfw_base_setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (void *) &size,
+ (socklen_t) size_len)) < 0)
+ {
+ save_pre_init_log(NSLOG_ERR,
+ "client set domain socket sendbuf fail]fd=%d,ret=%d,errno=%d",
+ fd, ret, errno);
+ goto connect_err;
+ }
+
+ ret = memset_s(&un, sizeof(un), 0, sizeof(un));
+ if (EOK != ret)
+ {
+ save_pre_init_log(NSLOG_ERR, "memset_s fail]ret=%d", ret);
+ goto connect_err;
+ }
+ un.sun_family = AF_UNIX;
+ if (strlen(servername) > UNIX_SOCK_MAX_PATH_LEN)
+ {
+ save_pre_init_log(NSLOG_ERR,
+ "servername string is %d bigger than %d",
+ strlen(servername), UNIX_SOCK_MAX_PATH_LEN);
+ goto connect_err;
+ }
+ ret = strcpy_s(un.sun_path, sizeof(un.sun_path), servername);
+ if (EOK != ret)
+ {
+ save_pre_init_log(NSLOG_ERR, "strcpy_s fail]ret=%d", ret);
+ goto connect_err;
+ }
+
+ len =
+ (unsigned int) (offsetof(struct sockaddr_un, sun_path) +
+ strlen(servername));
+
+ //connect the server
+ if ((ret = nsfw_base_connect(fd, (struct sockaddr *) &un, len)) < 0)
+ {
+ save_pre_init_log(NSLOG_ERR,
+ "client connect the server fail]ret=%d,errno=%d",
+ ret, errno);
+ goto connect_err;
+ }
+
+ return fd;
+
+ connect_err:
+
+ (void) nsfw_base_close(fd);
+
+ return -1;
+
+}
+
+/*****************************************************************************
+* Prototype : nstack_log_server_init
+* Description : init the nstack log domain socket for server side, and create
+* a thread to wait the client conect or data come.
+* Input : int proc_type
+* ...
+* Output : None
+* Return Value : 0 means success, -1 means fail.
+* Calls :
+* Called By :
+*****************************************************************************/
+int nstack_log_server_init(int proc_type)
+{
+ int ret = -1;
+ int listen_fd = -1;
+ int listen_fd_opera = -1;
+
+ if ((ret = nstack_log_sock_path(proc_type)) < 0)
+ {
+ save_pre_init_log(NSLOG_ERR, "asyn server get path fail]ret=%d", ret);
+ return -1;
+ }
+
+ switch (proc_type)
+ {
+ case LOG_PRO_NSTACK:
+ g_nstack_log_server_state[LOG_TYPE_NSTACK] =
+ NSTACK_LOG_SER_STATE_RUNNING;
+ g_nstack_log_server_state[LOG_TYPE_OPERATION] =
+ NSTACK_LOG_SER_STATE_RUNNING;
+ listen_fd = nstack_log_sock_listen(nstack_sock_running);
+ g_nstack_log_server_fd[LOG_TYPE_NSTACK] = listen_fd;
+ listen_fd_opera = nstack_log_sock_listen(nstack_sock_operation);
+ g_nstack_log_server_fd[LOG_TYPE_OPERATION] = listen_fd_opera;
+ if (listen_fd_opera < 0)
+ {
+ save_pre_init_log(NSLOG_ERR,
+ "asyn server operation fd listen fail]listen_fd_opera=%d",
+ listen_fd_opera);
+ return -1;
+ }
+ break;
+ case LOG_PRO_MASTER:
+ g_nstack_log_server_state[LOG_TYPE_MASTER] =
+ NSTACK_LOG_SER_STATE_RUNNING;
+ listen_fd = nstack_log_sock_listen(nstack_sock_master);
+ g_nstack_log_server_fd[LOG_TYPE_MASTER] = listen_fd;
+ break;
+ case LOG_PRO_OMC_CTRL:
+ g_nstack_log_server_state[LOG_TYPE_CTRL] =
+ NSTACK_LOG_SER_STATE_RUNNING;
+ listen_fd = nstack_log_sock_listen(nstack_sock_ctrl);
+ g_nstack_log_server_fd[LOG_TYPE_CTRL] = listen_fd;
+ break;
+ default:
+ save_pre_init_log(NSLOG_ERR, "process invalid]proc_type=%d",
+ proc_type);
+ return -1;
+ }
+
+ if (listen_fd < 0)
+ {
+ save_pre_init_log(NSLOG_ERR, "asyn server listen fail]listen_fd=%d",
+ listen_fd);
+ return -1;
+ }
+
+ pthread_t t;
+ if ((ret =
+ pthread_create(&t, NULL, nstack_log_server_process,
+ (void *) (u64) proc_type)) != 0)
+ {
+ save_pre_init_log(NSLOG_ERR, "asyn server create thread fail]ret=%d",
+ ret);
+ return -1;
+ }
+
+ /* thread name string should smaller than 16 bytes */
+
+ ret = pthread_setname_np(t, ASYNLOG_THREAD_NAME);
+ if (ret != 0)
+ {
+ save_pre_init_log(NSLOG_WAR,
+ "asyn server set thread name fail, use process name]ret=%d",
+ ret);
+ }
+ else
+ {
+ save_pre_init_log(NSLOG_INF,
+ "asyn server set thread name success]thread name=%s",
+ ASYNLOG_THREAD_NAME);
+ }
+
+ if (proc_type == LOG_PRO_NSTACK)
+ {
+ save_pre_init_log(NSLOG_INF,
+ "asyn server init success]listen_fd=%d,listen_fd_opera=%d",
+ listen_fd, listen_fd_opera);
+ }
+ else
+ {
+ save_pre_init_log(NSLOG_INF, "asyn server init success]listen_fd=%d",
+ listen_fd);
+ }
+
+ return 0;
+}
+
+#define NSTACK_LOG_SEND_FLUSH_SIG(fd, ret) \
+do \
+{\
+ if (fd > 0) \
+ { \
+ ret = nsfw_base_send(fd, "\5" /* NSTACK_LOG_SER_FLUSH_SIG */, 1, MSG_NOSIGNAL); \
+ } else { \
+ ret = -1; \
+ }\
+} while(0)
+
+#ifndef MAX_U64_NUM
+#define MAX_U64_NUM ((unsigned long long)0xffffffffffffffff)
+#endif
+
+NSTACK_STATIC int nstack_log_current_time2msec(unsigned long long *msec)
+{
+ struct timespec tout;
+ if (0 != clock_gettime(CLOCK_MONOTONIC, &tout))
+ {
+ return -1;
+ }
+
+ if (MAX_U64_NUM / 1000 < (unsigned long long) tout.tv_sec)
+ {
+ return -1;
+ }
+ unsigned long long sec2msec = 1000 * tout.tv_sec;
+ unsigned long long nsec2msec =
+ (unsigned long long) tout.tv_nsec / 1000000;
+
+ if (MAX_U64_NUM - sec2msec < nsec2msec)
+ {
+ return -1;
+ }
+
+ *msec = sec2msec + nsec2msec;
+ return 0;
+}
+
+int nstack_log_server_flush(int proc_type, unsigned long long timeout)
+{
+ int i = 0;
+ unsigned long long start = 0;
+ unsigned long long end = 0;
+ int flushed = 0;
+ int ret = 0;
+
+ switch (proc_type)
+ {
+ case LOG_PRO_NSTACK:
+ g_nstack_log_server_state[LOG_TYPE_NSTACK] =
+ NSTACK_LOG_SER_STATE_FLUSHING;
+ g_nstack_log_server_state[LOG_TYPE_OPERATION] =
+ NSTACK_LOG_SER_STATE_FLUSHING;
+
+ // send ENQ
+ NSTACK_LOG_SEND_FLUSH_SIG(g_nstack_log_client_fd
+ [LOG_TYPE_NSTACK], ret);
+ if (ret < 0)
+ {
+ g_nstack_log_server_state[LOG_TYPE_NSTACK] =
+ NSTACK_LOG_SER_STATE_RUNNING;
+ g_nstack_log_server_state[LOG_TYPE_OPERATION] =
+ NSTACK_LOG_SER_STATE_RUNNING;
+ return -1;
+ }
+ NSTACK_LOG_SEND_FLUSH_SIG(g_nstack_log_client_fd
+ [LOG_TYPE_OPERATION], ret);
+ if (ret < 0)
+ {
+ g_nstack_log_server_state[LOG_TYPE_OPERATION] =
+ NSTACK_LOG_SER_STATE_RUNNING;
+ return -1;
+ }
+ break;
+ case LOG_PRO_MASTER:
+ g_nstack_log_server_state[LOG_TYPE_MASTER] =
+ NSTACK_LOG_SER_STATE_FLUSHING;
+ // send ENQ
+ NSTACK_LOG_SEND_FLUSH_SIG(g_nstack_log_client_fd
+ [LOG_TYPE_MASTER], ret);
+ if (ret < 0)
+ {
+ g_nstack_log_server_state[LOG_TYPE_MASTER] =
+ NSTACK_LOG_SER_STATE_RUNNING;
+ return -1;
+ }
+ break;
+ case LOG_PRO_OMC_CTRL:
+ g_nstack_log_server_state[LOG_TYPE_CTRL] =
+ NSTACK_LOG_SER_STATE_FLUSHING;
+ // send ENQ
+ NSTACK_LOG_SEND_FLUSH_SIG(g_nstack_log_client_fd[LOG_TYPE_CTRL],
+ ret);
+ if (ret < 0)
+ {
+ g_nstack_log_server_state[LOG_TYPE_CTRL] =
+ NSTACK_LOG_SER_STATE_RUNNING;
+ return -1;
+ }
+ break;
+ default:
+ return 0;
+ }
+
+ if (nstack_log_current_time2msec(&start))
+ {
+ return -1;
+ }
+
+ while (1)
+ {
+ if (timeout > 0)
+ {
+ if (nstack_log_current_time2msec(&end))
+ {
+ break;
+ }
+ if (end < start || (end - start) > timeout)
+ {
+ break;
+ }
+ }
+
+ flushed = 1;
+ for (i = 0; i < MAX_LOG_TYPE; i++)
+ {
+ if (g_nstack_log_server_state[i] != NSTACK_LOG_SER_STATE_RUNNING)
+ {
+ flushed = 0;
+ break;
+ }
+ }
+ if (flushed)
+ {
+ return 0;
+ }
+ sys_sleep_ns(0, 500000);
+ }
+
+ return -1;
+}
+
+/*****************************************************************************
+* Prototype : nstack_log_client_init
+* Description : init the nstack log domain socket, which use to handle
+* the log with a thread of the domain connect, store the
+* client fd, for client side.
+* Input : int proc_type
+* ...
+* Output : None
+* Return Value : 0 means success, -1 means fail.
+* Calls :
+* Called By :
+*****************************************************************************/
+int nstack_log_client_init(int proc_type)
+{
+ int connfd = -1;
+ int connfd_opt = -1;
+
+ switch (proc_type)
+ {
+ case LOG_PRO_NSTACK:
+ //get the con fd and store the fd to g_nstack_log_client_fd
+ connfd = nstack_log_sock_conn(nstack_sock_running);
+ g_nstack_log_client_fd[LOG_TYPE_NSTACK] = connfd;
+ connfd_opt = nstack_log_sock_conn(nstack_sock_operation);
+ if (connfd_opt < 0)
+ {
+ save_pre_init_log(NSLOG_ERR,
+ "asyn client init fail]connfd_opt=%d",
+ connfd_opt);
+ return -1;
+ }
+ g_nstack_log_client_fd[LOG_TYPE_OPERATION] = connfd_opt;
+ break;
+ case LOG_PRO_MASTER:
+ connfd = nstack_log_sock_conn(nstack_sock_master);
+ g_nstack_log_client_fd[LOG_TYPE_MASTER] = connfd;
+ break;
+ case LOG_PRO_OMC_CTRL:
+ connfd = nstack_log_sock_conn(nstack_sock_ctrl);
+ g_nstack_log_client_fd[LOG_TYPE_CTRL] = connfd;
+ break;
+ default:
+ save_pre_init_log(NSLOG_ERR, "process invalid]proc_type=%d",
+ proc_type);
+ return -1;
+ }
+
+ if (connfd < 0)
+ {
+ save_pre_init_log(NSLOG_ERR, "asyn client init fail]connfd=%d",
+ connfd);
+ return -1;
+ }
+
+ if (proc_type == LOG_PRO_NSTACK)
+ {
+ save_pre_init_log(NSLOG_INF,
+ "asyn client init success]connfd=%d,connfd_opt=%d",
+ connfd, connfd_opt);
+ }
+ else
+ {
+ save_pre_init_log(NSLOG_INF, "asyn client init success]connfd=%d",
+ connfd);
+ }
+
+ return 0;
+}
+
+/*****************************************************************************
+* Prototype : nstack_log_client_send
+* Description : send the log data to the file, file_type will get the fd
+* for the specified conn.
+* Input : int file_type
+* : char *buffer
+* : size_t buflen
+* ...
+* Output : None
+* Return Value : 0 means success, -1 means fail.
+* Calls :
+* Called By :
+*****************************************************************************/
+int nstack_log_client_send(int file_type, char *buffer, size_t buflen)
+{
+ int connfd = -1;
+ int num = -1;
+ int count = 2; //if errno is EAGAIN or EINTR, try twice
+ if ((NULL == buffer) || (buflen == 0) || (file_type < 0)
+ || (file_type > LOG_TYPE_CTRL))
+ {
+ return -1;
+ }
+
+ //get the fd as the file_type specified.
+ connfd = g_nstack_log_client_fd[file_type];
+ if (connfd < 0)
+ {
+ NS_PTHREADLOG(file_type, NSLOG_ERR,
+ "connfd invalid]connfd=%d,file_type=%d", connfd,
+ file_type);
+ goto async_err;
+ }
+
+ while (count-- > 0)
+ {
+ // write to client fd
+ if ((num =
+ nsfw_base_send(connfd, buffer, buflen, MSG_NOSIGNAL)) == buflen)
+ {
+ break;
+ }
+ else if (num <= 0)
+ {
+ if (num == 0 || ((errno != EAGAIN) && (errno != EINTR)))
+ {
+ NS_PTHREADLOG(file_type, NSLOG_ERR,
+ "async log module fail, domain socket close]g_nstack_log_client_fd[%d]=%d,num=%d,errno=%d",
+ file_type, connfd, num, errno);
+ (void) nsfw_base_close(connfd);
+ g_nstack_log_client_fd[file_type] = -1;
+ goto async_err;
+ }
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ return 0;
+
+ async_err:
+ NS_PTHREADLOG(file_type, NSLOG_ERR,
+ "current process will turn DIO synchron log module]buflen=%zu,buffer=%s",
+ buflen, buffer);
+ log_asyn_inited = FALSE;
+
+ return -1;
+}
+
+/*****************************************************************************
+* Prototype : nstack_log_level_valid
+* Description : check if the level is valid.
+* Input : uint32_t level
+* ...
+* Output : None
+* Return Value : TRUE means success, FALSE means fail
+* Calls :
+* Called By :
+*****************************************************************************/
+bool nstack_log_level_valid(uint32_t level)
+{
+ switch (level)
+ {
+ case NSLOG_CUS:
+ case NSLOG_DBG:
+ case NSLOG_INF:
+ case NSLOG_WAR:
+ case NSLOG_ERR:
+ case NSLOG_EMG:
+ break;
+ default:
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/*****************************************************************************
+* Prototype : save_pre_init_log
+* Description : save the pre init log for nstack as the log module still
+* be unavailable.
+* Input : uint32_t level
+* : char *fmt
+* ...
+* Output : None
+* Return Value : void
+* Calls :
+* Called By :
+*****************************************************************************/
+
+/* change the print level, not only has err */
+void save_pre_init_log(uint32_t level, char *fmt, ...)
+{
+ va_list ap;
+ int ret = 0;
+ /*add pre_init_log_count rang check */
+ if (!nstack_log_level_valid(level)
+ || pre_init_log_count >= MAX_PRE_INIT_LOG_COUNT
+ || pre_init_log_count < 0)
+ {
+ return;
+ }
+
+ pre_init_log[pre_init_log_count].log_buffer[PRE_INIT_LOG_LENGTH - 1] =
+ '\0';
+
+ (void) va_start(ap, fmt); /*keep behavior same with C00,and it won't any effect here */
+ ret =
+ vsnprintf_s(pre_init_log[pre_init_log_count].log_buffer,
+ PRE_INIT_LOG_LENGTH, PRE_INIT_LOG_LENGTH - 1, fmt, ap);
+ if (-1 == ret)
+ {
+ va_end(ap);
+ return;
+ }
+ va_end(ap);
+ pre_init_log[pre_init_log_count].level = level;
+ pre_init_log_count++;
+ return;
+}
+
+/*****************************************************************************
+* Prototype : get_pre_init_log_count
+* Description : get the count value of the pre log record.
+* Input : None
+* ...
+* Output : log count num
+* Return Value : nonnegative number
+* Calls :
+* Called By :
+*****************************************************************************/
+int get_pre_init_log_count()
+{
+ int count = pre_init_log_count;
+ if ((count < 0) || (count >= MAX_PRE_INIT_LOG_COUNT))
+ {
+ return 0;
+ }
+ return count;
+}
+
+/*****************************************************************************
+* Prototype : get_pre_init_log_buffer
+* Description : get the stored log content of the pre log, the content will
+* copy to the input parameter array for print.
+* Input : struct pre_init_info pre_buf[]
+* : uint32_t size
+* ...
+* Output : None
+* Return Value : 0 means success, -1 means fail.
+* Calls :
+* Called By :
+*****************************************************************************/
+int get_pre_init_log_buffer(struct pre_init_info *pre_buf, uint32_t size)
+{
+ int ret = -1;
+ size_t array_size = sizeof(struct pre_init_info) * size;
+ if (NULL == pre_buf || size > MAX_PRE_INIT_LOG_COUNT
+ || (sizeof(pre_init_log) != array_size))
+ {
+ return -1;
+ }
+
+ ret = memcpy_s(pre_buf, array_size, pre_init_log, array_size);
+ if (EOK != ret)
+ {
+ return -1;
+ }
+ return 0;
+}
+
+/*****************************************************************************
+* Prototype : get_level_desc
+* Description : get the first letter as the level.
+* Input : uint32_t level
+* ...
+* Output : first letter of the level
+* Return Value : char *
+* Calls :
+* Called By :
+*****************************************************************************/
+char *get_level_desc(uint32_t level)
+{
+ switch (level)
+ {
+ case NSLOG_DBG:
+ return "D";
+ case NSLOG_INF:
+ return "I";
+ case NSLOG_WAR:
+ return "W";
+ case NSLOG_ERR:
+ return "E";
+ case NSLOG_EMG:
+ /* PDT use fatal, so here use F */
+ return "F";
+ default:
+ return "E";
+ }
+}
+
+/*****************************************************************************
+* Prototype : nstack_log_get_prefix
+* Description : assemble the log prefix content, the content contain the level
+* first letter, and timestamp
+* Input : uint32_t level
+* : char *buffer
+* : uint32_t length
+* ...
+* Output : buffer store the pre_log
+* Return Value : >=0 means success, -1 means fail.
+* Calls :
+* Called By :
+*****************************************************************************/
+int nstack_log_get_prefix(uint32_t level, char *buffer, uint32_t length)
+{
+ if ((NULL == buffer) || length == 0)
+ {
+ return -1;
+ }
+
+ int ret = -1;
+ char *level_str = "E";
+ struct timeval t_val;
+ struct tm now_time;
+
+ /* limit log file size and log file count- Begin */
+ /*gettimeofday is not change to clock_gettime as this is for log and gettimeofday only
+ makes sense here */
+ (void) gettimeofday(&t_val, NULL);
+ time_t t_sec = (time_t) t_val.tv_sec;
+ (void) gmtime_r(&t_sec, &now_time);
+
+ level_str = get_level_desc(level);
+
+ /* There are some unsafe function ,need to be replace with safe function */
+ /* modify %02d:%02d:%02d:%06ld:%s to "%02d:%02d:%02d.%06ld %s" */
+ ret = sprintf_s(buffer, length, "%s%02d%02d %02d:%02d:%02d.%06ld",
+ level_str, now_time.tm_mon + 1, now_time.tm_mday,
+ now_time.tm_hour, now_time.tm_min, now_time.tm_sec,
+ (long) t_val.tv_usec);
+ if (-1 == ret)
+ {
+ return -1;
+ }
+
+ return ret;
+
+}
+
+/*****************************************************************************
+* Prototype : nstack_log_print_buffer
+* Description : get the log prefix content, and assemble the log with format,
+* then use glog print direct, as in a single thread, no block.
+* Input : uint32_t file_type
+* : uint32_t level
+* : const char *format
+* ...
+* Output : NA
+* Return Value : void
+* Calls :
+* Called By : nstack_log_server_process
+*****************************************************************************/
+void nstack_log_print_buffer(uint32_t log_type, uint32_t level,
+ const char *format, ...)
+{
+ if (NULL == format)
+ {
+ return;
+ }
+
+ va_list ap;
+ int ret;
+ char pre_buffer[PRE_INIT_LOG_LENGTH] = { 0 };
+ char buffer[MAX_BUFFER_LEN] = { 0 };
+ char format_buffer[MAX_BUFFER_LEN] = { 0 };
+
+ ret = nstack_log_get_prefix(level, pre_buffer, sizeof(pre_buffer));
+ if (ret < 0)
+ {
+ return;
+ }
+
+ ret =
+ sprintf_s(format_buffer, sizeof(format_buffer), "%s %s", pre_buffer,
+ format);
+ if (ret < 0)
+ {
+ return;
+ }
+
+ va_start(ap, format); /*no need to check return */
+ ret = vsprintf_s(buffer, sizeof(buffer), format_buffer, ap);
+ if (-1 == ret)
+ {
+ va_end(ap);
+ return;
+ }
+ va_end(ap);
+
+ buffer[sizeof(buffer) - 1] = '\0';
+
+ // print the buf
+ glog_print_buffer(log_type, buffer, ret);
+
+ return;
+}
diff --git a/src/framework/log/nstack_log_async.h b/src/framework/log/nstack_log_async.h
new file mode 100644
index 0000000..1ae1865
--- /dev/null
+++ b/src/framework/log/nstack_log_async.h
@@ -0,0 +1,93 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#ifndef _NSTACK_LOG_SOCK_H_
+#define _NSTACK_LOG_SOCK_H_
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <sys/time.h>
+#include <sys/syscall.h>
+#include <time.h>
+#include <errno.h>
+#include "types.h"
+#include "nstack_log.h"
+
+#define PRE_INIT_LOG_LENGTH 128
+#define MAX_PRE_INIT_LOG_COUNT 256
+#define MAX_BUFFER_LEN 2048 //buffer len for the domain socket recv
+
+//Note: need match with _NLOG_TYPE in glog
+enum _LOG_TYPE
+{
+ LOG_TYPE_NSTACK = 0,
+ LOG_TYPE_OPERATION,
+ LOG_TYPE_MASTER,
+ LOG_TYPE_CTRL,
+ LOG_TYPE_SEGMENT,
+ LOG_TYPE_APP,
+ LOG_TYPE_UNRECOGNIZED,
+ MAX_LOG_TYPE
+};
+
+/*change the print level, not only has err*/
+
+struct pre_init_info
+{
+ uint32_t level; /**< Log level. */
+ char log_buffer[PRE_INIT_LOG_LENGTH];
+};
+
+extern __thread unsigned int pre_log_nonreentry;
+
+/*change the log type check*/
+#define pre_log_shooting(_type,_level) \
+ (((_type >= MAX_LOG_TYPE) || (g_nstack_logs[LOGASYNC].level < _level) || (!nstack_log_level_valid(_level))) ? FALSE: TRUE)
+
+#define NS_PTHREADLOG(_type,_level,fmt, ...) \
+{\
+ if (pre_log_shooting(_type, _level) && (0 == pre_log_nonreentry))\
+ {\
+ pre_log_nonreentry = 1;\
+ nstack_log_print_buffer(_type, _level, \
+ "%d %s:%d] %d,%s <NSTHREAD>" fmt "\r\n", (int)syscall(SYS_gettid), GET_FILE_NAME(__FILE__), \
+ __LINE__, getpid(),__func__, ##__VA_ARGS__);\
+ pre_log_nonreentry = 0;\
+ }\
+}
+
+int nstack_log_server_init(int proc_type);
+
+int nstack_log_client_init(int proc_type);
+
+int nstack_log_client_send(int file_type, char *buffer, size_t buflen);
+
+int nstack_log_server_flush(int proc_type, unsigned long long timeout);
+
+bool nstack_log_level_valid(uint32_t level);
+
+int get_pre_init_log_count();
+
+int get_pre_init_log_buffer(struct pre_init_info *pre_buf, uint32_t size);
+
+char *get_level_desc(uint32_t level);
+
+int nstack_log_get_prefix(uint32_t level, char *buffer, uint32_t length);
+
+void nstack_log_print_buffer(uint32_t log_type, uint32_t level,
+ const char *format, ...);
+
+#endif /*_NSTACK_LOG_SOCK_H_*/
diff --git a/src/framework/log/nstack_log_auto_suppress.c b/src/framework/log/nstack_log_auto_suppress.c
new file mode 100644
index 0000000..4296b47
--- /dev/null
+++ b/src/framework/log/nstack_log_auto_suppress.c
@@ -0,0 +1,376 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+/*==============================================*
+ * include header files *
+ *----------------------------------------------*/
+#include "nsfw_init_api.h"
+#include "nstack_log_async.h"
+#include "nstack_log_auto_suppress.h"
+#include "nsfw_fd_timer_api.h"
+#include "nsfw_mgr_com_api.h"
+#include "nstack_securec.h"
+#include <unistd.h>
+#include "nstack_log_auto_suppress_rb_tree.h"
+
+/*==============================================*
+ * project-wide global variables *
+ *----------------------------------------------*/
+__thread log_sup_table gt_log_sup_table = { 0 };
+NSTACK_STATIC log_sup_summary g_log_sup_summary = { {0, 0, 0, 0, 0, 0, 0, 0}
+, 0, 0
+};
+
+NSTACK_STATIC u32 g_log_sup_thresh = LOG_SUP_THRESH_DEFAULT;
+
+/*==============================================*
+ * routines' or functions' implementations *
+ *----------------------------------------------*/
+inline bool is_log_sup_switched_off(const u8 module)
+{
+ return ((MAX_LOG_MODULE > module) && g_nstack_logs[module].suppress_off);
+}
+
+inline log_sup_table *get_log_sup_table_addr()
+{
+ return &gt_log_sup_table;
+}
+
+inline int log_entry_cmp(const log_entry * left, const log_entry * right)
+{
+ u64 key_left = GET_TAG_FROM_FILE_AND_LINE(left->file, left->line);
+ u64 key_right = GET_TAG_FROM_FILE_AND_LINE(right->file, right->line);
+
+ if (key_left > key_right)
+ {
+ return 1;
+ }
+ else if (key_left < key_right)
+ {
+ return -1;
+ }
+ else
+ {
+ return 0;
+ }
+}
+
+/* CAUTION: Only given the limited scenario in regard of `gt_log_sup_table` can we simplify the malloc/free mechanism like below.
+ * 1. `gt_log_sup_table` is thread-independent;
+ * 2. there are only 2 possible malloc scenario:
+ * (a) when table is not full, create a new node;
+ * (b) when table is full, add a node right after deleting the old one, so we just take its place */
+log_sup_node *malloc_one_node()
+{
+ if (gt_log_sup_table.count >= gt_log_sup_table.size)
+ {
+ /* full or uninited, don't print log here */
+ return NULL;
+ }
+ log_sup_node *node;
+ if (gt_log_sup_table.just_been_freed)
+ {
+ /* when table is full, add a node right after deleting the old one, so we just take its place */
+ node = gt_log_sup_table.just_been_freed;
+ }
+ else
+ {
+ /* when table is not full, create a new node */
+ node = gt_log_sup_table.nodepool + gt_log_sup_table.count;
+ }
+ gt_log_sup_table.count++;
+
+ return node;
+}
+
+void free_one_node(log_sup_node * node)
+{
+ gt_log_sup_table.just_been_freed = node; /* mark the place */
+ gt_log_sup_table.count--;
+}
+
+/* CAUTION: log printing can be used in this function ONLY when we have confirmed that
+ * gt_log_sup_table is initialized, whether successfully or not. */
+log_sup_table *init_sup_table(int table_size)
+{
+ /* Prevent `g_log_sup_thresh` from being optimized out, so that we can enforce it by gdb. Not needed in UT */
+ g_log_sup_thresh = LOG_SUP_THRESH_DEFAULT;
+ gt_log_sup_table.root = NULL;
+ gt_log_sup_table.nodepool = NULL;
+ gt_log_sup_table.just_been_freed = NULL;
+ gt_log_sup_table.size = 0;
+ gt_log_sup_table.count = 0;
+
+ if (table_size <= 0 || table_size > LOG_SUP_TABLE_SIZE_UPPER_LIMIT)
+ {
+ NSFW_LOGERR("invalid gt_log_sup_table size=%d!", table_size);
+ return NULL;
+ }
+
+ gt_log_sup_table.nodepool =
+ (log_sup_node *) malloc(table_size * sizeof(log_sup_node));
+ if (NULL == gt_log_sup_table.nodepool)
+ {
+ NSFW_LOGERR("malloc gt_log_sup_table failed!");
+ return NULL;
+ }
+
+ int ret = memset_s(gt_log_sup_table.nodepool,
+ (table_size * sizeof(log_sup_node)), 0,
+ (table_size * sizeof(log_sup_node)));
+ if (EOK != ret)
+ {
+ free(gt_log_sup_table.nodepool);
+ gt_log_sup_table.nodepool = NULL;
+ NSFW_LOGERR("memset_s gt_log_sup_table failed! ret=%d", ret);
+ return NULL;
+ }
+
+ int dlc = 10000;
+
+ while (!__sync_bool_compare_and_swap(&g_log_sup_summary.lock, 0, 1)) //LOCK
+ {
+ if (--dlc == 0)
+ {
+ free(gt_log_sup_table.nodepool);
+ gt_log_sup_table.nodepool = NULL;
+ NSFW_LOGERR("can't get the lock of g_log_sup_summary");
+ return NULL;
+ }
+ /* use nanosleep() instead of usleep() */
+ struct timespec delay;
+ delay.tv_sec = 0;
+ delay.tv_nsec = 10000;
+ (void) nanosleep(&delay, NULL); /* don't care for precission, so no need to check return value or output param */
+ }
+ if (g_log_sup_summary.table_cnt < MAX_NUM_OF_LOG_SUP_TABLE)
+ {
+ g_log_sup_summary.tables[g_log_sup_summary.table_cnt] =
+ &gt_log_sup_table;
+ g_log_sup_summary.table_cnt++;
+ g_log_sup_summary.lock = 0; //UNLOCK
+ }
+ else
+ {
+ free(gt_log_sup_table.nodepool);
+ gt_log_sup_table.nodepool = NULL;
+ g_log_sup_summary.lock = 0; //UNLOCK
+ NSFW_LOGERR("g_log_sup_summary is full");
+ return NULL;
+ }
+
+ gt_log_sup_table.size = table_size;
+ NSFW_LOGINF("init gt_log_sup_table succ]nodepool=%p",
+ gt_log_sup_table.nodepool);
+ return &gt_log_sup_table;
+}
+
+/* Mid-layer for datastruture methods. DO NOT print log in these functions - Begin */
+NSTACK_STATIC inline log_sup_node *_log_sup_search(const log_entry * entry,
+ log_sup_table * table)
+{
+ return __log_sup_rb_search(entry, table->root);
+}
+
+NSTACK_STATIC inline void _log_sup_erase(log_sup_node * node,
+ log_sup_table * table)
+{
+ return __log_sup_rb_erase(node, &(table->root));
+}
+
+NSTACK_STATIC inline log_sup_node *_log_sup_insert(log_entry * entry,
+ log_sup_table * table)
+{
+ return __log_sup_rb_insert(entry, &(table->root));
+}
+
+/* Mid-layer for datastruture methods. DO NOT print log in these functions - End */
+
+static inline int is_node_to_delete(log_entry * entry)
+{
+ return !ISSET_BITS(entry->ctrl_bits, CTRL_BIT__KEEP);
+}
+
+bool update_sup_table_on_logging(const char *file, const u16 line,
+ const u8 log_type, const u16 level,
+ log_sup_table * table, u32 * dup_cnt)
+{
+ log_entry ent;
+ ent.ctrl_bits = 0;
+ ent.level = level;
+ ent.log_type = log_type;
+ ent.last_epoch_dup_cnt = 0;
+ ent.file = file;
+ ent.line = line;
+
+ if (NULL == table->nodepool) ///not inited, abort
+ {
+ return FALSE;
+ }
+
+ log_sup_node *node = _log_sup_search(&ent, table);
+ if (NULL == node) //no match found, insert one
+ {
+ if (NULL == (node = _log_sup_insert(&ent, table))) //table is full, try to replace
+ {
+ log_sup_node *node2del = NULL;
+ int recur_cnt = table->size;
+ __log_sup_rb_traversal_preorder(table->root, is_node_to_delete,
+ &node2del, &recur_cnt);
+ if (node2del)
+ {
+ _log_sup_erase(node2del, table);
+ node = _log_sup_insert(&ent, table);
+ if (NULL == node)
+ {
+ /* should never happen */
+ return FALSE; /* The conservative choice is not to suppress */
+ }
+ }
+ else
+ {
+ /* No entry can be replaced, should happen very rarely */
+ return FALSE;
+ }
+ }
+ }
+
+ /* ASSERT: node != NULL when reaching here */
+ node->entry.last_epoch_dup_cnt++;
+ if (dup_cnt) /* can be NULL */
+ {
+ *dup_cnt = node->entry.last_epoch_dup_cnt;
+ }
+ SET_BITS(node->entry.ctrl_bits, CTRL_BIT__KEEP);
+ if (node->entry.last_epoch_dup_cnt > g_log_sup_thresh)
+ {
+ SET_BITS(node->entry.ctrl_bits, CTRL_BIT__SUPPRESSED);
+ }
+ return ISSET_BITS(node->entry.ctrl_bits, CTRL_BIT__SUPPRESSED);
+}
+
+static inline void print_suppressed_log(log_entry * entry)
+{
+ if (ISSET_BITS(entry->ctrl_bits, CTRL_BIT__SUPPRESSED))
+ {
+ u16 _level = entry->level;
+ u8 _module = entry->log_type;
+
+ if (entry->last_epoch_dup_cnt > g_log_sup_thresh)
+ {
+ NS_LOGPID(_module, "SUP", _level, "%s:%u repeated %u times",
+ GET_FILE_NAME(entry->file), entry->line,
+ entry->last_epoch_dup_cnt);
+ }
+ else
+ {
+ NS_LOGPID(_module, "SUP", _level,
+ "%s:%u repeated %u times (may release)",
+ GET_FILE_NAME(entry->file), entry->line,
+ entry->last_epoch_dup_cnt);
+ }
+
+ }
+}
+
+static inline void update_log_sup_ctrl(log_entry * entry)
+{
+ if (entry->last_epoch_dup_cnt > g_log_sup_thresh)
+ {
+ SET_BITS(entry->ctrl_bits, (CTRL_BIT__SUPPRESSED | CTRL_BIT__KEEP));
+ }
+ else
+ {
+ CLR_BITS(entry->ctrl_bits, (CTRL_BIT__SUPPRESSED | CTRL_BIT__KEEP));
+ }
+ entry->last_epoch_dup_cnt = 0;
+}
+
+static inline int print_update_sup_entry(log_entry * entry)
+{
+ print_suppressed_log(entry);
+ update_log_sup_ctrl(entry);
+ return 0;
+}
+
+void update_sup_table_on_timer(void)
+{
+ int i;
+ for (i = 0; i < g_log_sup_summary.table_cnt; i++)
+ {
+ log_sup_table *table = g_log_sup_summary.tables[i];
+ int recur_cnt = table->size;
+ __log_sup_rb_traversal_preorder(table->root, print_update_sup_entry,
+ NULL, &recur_cnt);
+ }
+}
+
+int nsfw_log_sup_timeout(u32 timer_type, void *data)
+{
+ update_sup_table_on_timer();
+ struct timespec time_left = { 1, 0 };
+ void *ptr = (void *) nsfw_timer_reg_timer(777, NULL, nsfw_log_sup_timeout,
+ time_left);
+ if (!ptr)
+ {
+ NSFW_LOGERR("re-register log_sup_timer fail!");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+int nsfw_log_sup_module_init(void *param)
+{
+ u32 proc_type = (u32) ((long long) param);
+ int table_size;
+
+ switch (proc_type)
+ {
+ case NSFW_PROC_MASTER:
+ table_size = LOG_SUP_TABLE_SIZE_FOR_MASTER;
+ break;
+ case NSFW_PROC_MAIN:
+ table_size = LOG_SUP_TABLE_SIZE_FOR_MAIN;
+ break;
+ default:
+ return 0;
+ }
+
+ /* Init log suppression for this thread */
+ if (NULL == init_sup_table(table_size))
+ {
+ NSFW_LOGWAR("log suppression init failed in main thread");
+ }
+
+ struct timespec time_left = { 1, 0 };
+ void *ptr = (void *) nsfw_timer_reg_timer(777, NULL, nsfw_log_sup_timeout,
+ time_left);
+ if (!ptr)
+ {
+ NSFW_LOGERR("init log_sup_timer fail!");
+ return -1;
+ }
+
+ NSFW_LOGINF("init log_sup_module succ");
+ return 0;
+}
+
+/* *INDENT-OFF* */
+NSFW_MODULE_NAME(NSFW_LOG_SUP_MODULE)
+NSFW_MODULE_PRIORITY(10)
+NSFW_MODULE_DEPENDS(NSFW_TIMER_MODULE)
+NSFW_MODULE_INIT(nsfw_log_sup_module_init)
+/* *INDENT-ON* */
diff --git a/src/framework/log/nstack_log_auto_suppress.h b/src/framework/log/nstack_log_auto_suppress.h
new file mode 100644
index 0000000..0c59172
--- /dev/null
+++ b/src/framework/log/nstack_log_auto_suppress.h
@@ -0,0 +1,67 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#ifndef _NSTACK_LOG_SUPPRESS_H_
+#define _NSTACK_LOG_SUPPRESS_H_
+
+#include "types.h"
+#include "nstack_log.h"
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C"{
+/* *INDENT-ON* */
+#endif /* __cplusplus */
+
+#define NSFW_LOG_SUP_MODULE "nsfw_log_sup"
+
+#define CTRL_BIT__SUPPRESSED (1 << 0)
+#define CTRL_BIT__KEEP (1 << 1)
+
+/* The threshold must be larger than the size of log_sup_table, otherwise the suppress report itself may be suppressed */
+#define LOG_SUP_THRESH_DEFAULT 8192
+
+/* Must be larger than the number of threads in non-App processes */
+#define MAX_NUM_OF_LOG_SUP_TABLE 8
+
+#define SET_BITS(x,bits) (x)|=(bits)
+#define CLR_BITS(x,bits) (x)&=~(bits)
+#define ISSET_BITS(x,bits) ((x)&(bits))
+
+#define GET_TAG_FROM_FILE_AND_LINE(_file,_line) \
+ (u64)(((u64)(_file) & 0x00FFFFFFFFFFFFFF) | ((u64)(_line) << 48))
+
+typedef struct _log_sup_summary
+{
+ log_sup_table *tables[MAX_NUM_OF_LOG_SUP_TABLE];
+ int table_cnt;
+ volatile int lock;
+} log_sup_summary;
+
+extern __thread log_sup_table gt_log_sup_table;
+
+inline int log_entry_cmp(const log_entry * left, const log_entry * right);
+log_sup_node *malloc_one_node();
+void free_one_node(log_sup_node * node);
+void update_sup_table_on_timer(void);
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif /* __cplusplus */
+
+#endif
diff --git a/src/framework/log/nstack_log_auto_suppress_rb_tree.c b/src/framework/log/nstack_log_auto_suppress_rb_tree.c
new file mode 100644
index 0000000..d067cca
--- /dev/null
+++ b/src/framework/log/nstack_log_auto_suppress_rb_tree.c
@@ -0,0 +1,506 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#include <stdlib.h>
+#include "nstack_log_auto_suppress.h"
+#include "nstack_log_auto_suppress_rb_tree.h"
+
+#define RB_RED 0
+#define RB_BLACK 1
+
+NSTACK_STATIC void ___RB_rotate_left(log_sup_node * X, log_sup_node ** root)
+{
+ /**************************
+ * rotate Node X to left *
+ **************************/
+
+ log_sup_node *Y = X->rb_right;
+
+ /* estblish X->Right link */
+ X->rb_right = Y->rb_left;
+ if (Y->rb_left != NULL)
+ Y->rb_left->rb_parent = X;
+
+ /* estblish Y->Parent link */
+ Y->rb_parent = X->rb_parent;
+ if (X->rb_parent)
+ {
+ if (X == X->rb_parent->rb_left)
+ X->rb_parent->rb_left = Y;
+ else
+ X->rb_parent->rb_right = Y;
+ }
+ else
+ {
+ *root = Y;
+ }
+
+ /* link X and Y */
+ Y->rb_left = X;
+ X->rb_parent = Y;
+
+ return;
+}
+
+NSTACK_STATIC void ___RB_rotate_right(log_sup_node * X, log_sup_node ** root)
+{
+ /****************************
+ * rotate Node X to right *
+ ****************************/
+
+ log_sup_node *Y = X->rb_left;
+
+ /* estblish X->Left link */
+ X->rb_left = Y->rb_right;
+ if (Y->rb_right != NULL)
+ Y->rb_right->rb_parent = X;
+
+ /* estblish Y->Parent link */
+ Y->rb_parent = X->rb_parent;
+ if (X->rb_parent)
+ {
+ if (X == X->rb_parent->rb_right)
+ X->rb_parent->rb_right = Y;
+ else
+ X->rb_parent->rb_left = Y;
+ }
+ else
+ {
+ *root = Y;
+ }
+
+ /* link X and Y */
+ Y->rb_right = X;
+ X->rb_parent = Y;
+
+ return;
+}
+
+static inline int ___RB_is_color(log_sup_node * node, int color)
+{
+ return (!node || node->color == color);
+}
+
+static inline void ___RB_set_color(log_sup_node * node, int color)
+{
+ if (node != NULL)
+ {
+ node->color = color;
+ }
+}
+
+/* Oops... What's the proper name? */
+static inline void ___RB_adjust(log_sup_node * X, log_sup_node ** root,
+ log_sup_node * node)
+{
+ log_sup_node *Parent = node->rb_parent;
+ if (Parent)
+ {
+ if (Parent->rb_left == node)
+ {
+ Parent->rb_left = X;
+ }
+ else
+ {
+ Parent->rb_right = X;
+ }
+ }
+ else
+ {
+ *root = X;
+ }
+}
+
+/* X, Y are for application */
+NSTACK_STATIC void ___RB_erase_color(log_sup_node * X, log_sup_node * Parent,
+ log_sup_node ** root)
+{
+ /*************************************
+ * maintain red-black tree balance *
+ * after deleting node X *
+ *************************************/
+
+ while (X != *root && ___RB_is_color(X, RB_BLACK))
+ {
+
+ if (Parent == NULL)
+ {
+ break;
+ }
+
+ if (X == Parent->rb_left)
+ {
+ log_sup_node *W = Parent->rb_right;
+ if (W->color == RB_RED)
+ {
+ W->color = RB_BLACK;
+ Parent->color = RB_RED; /* Parent != NIL? */
+ ___RB_rotate_left(Parent, root);
+ W = Parent->rb_right;
+ }
+
+ if (___RB_is_color(W->rb_left, RB_BLACK)
+ && ___RB_is_color(W->rb_right, RB_BLACK))
+ {
+ W->color = RB_RED;
+ X = Parent;
+ Parent = X->rb_parent;
+ }
+ else
+ {
+ if (___RB_is_color(W->rb_right, RB_BLACK))
+ {
+ ___RB_set_color(W->rb_left, RB_BLACK);
+ W->color = RB_RED;
+ ___RB_rotate_right(W, root);
+ W = Parent->rb_right;
+ }
+
+ W->color = Parent->color;
+ Parent->color = RB_BLACK;
+ if (W->rb_right->color != RB_BLACK)
+ {
+ W->rb_right->color = RB_BLACK;
+ }
+ ___RB_rotate_left(Parent, root);
+ X = *root;
+ break;
+ }
+ }
+ else
+ {
+
+ log_sup_node *W = Parent->rb_left;
+ if (W->color == RB_RED)
+ {
+ W->color = RB_BLACK;
+ Parent->color = RB_RED; /* Parent != NIL? */
+ ___RB_rotate_right(Parent, root);
+ W = Parent->rb_left;
+ }
+
+ if (___RB_is_color(W->rb_left, RB_BLACK)
+ && ___RB_is_color(W->rb_right, RB_BLACK))
+ {
+ W->color = RB_RED;
+ X = Parent;
+ Parent = X->rb_parent;
+ }
+ else
+ {
+ if (___RB_is_color(W->rb_left, RB_BLACK))
+ {
+ ___RB_set_color(W->rb_right, RB_BLACK);
+ W->color = RB_RED;
+ ___RB_rotate_left(W, root);
+ W = Parent->rb_left;
+ }
+
+ W->color = Parent->color;
+ Parent->color = RB_BLACK;
+ if (W->rb_left->color != RB_BLACK)
+ {
+ W->rb_left->color = RB_BLACK;
+ }
+ ___RB_rotate_right(Parent, root);
+ X = *root;
+ break;
+ }
+ }
+ }
+
+ if (X)
+ {
+ X->color = RB_BLACK;
+ }
+
+ return;
+}
+
+static void ___RB_insert_color(log_sup_node * X, log_sup_node ** root)
+{
+ /*************************************
+ * maintain red-black tree balance *
+ * after inserting node X *
+ *************************************/
+
+ /* check red-black properties */
+ while (X != *root && X->rb_parent->color == RB_RED)
+ {
+ /* we have a violation */
+ if (X->rb_parent == X->rb_parent->rb_parent->rb_left)
+ {
+ log_sup_node *Y = X->rb_parent->rb_parent->rb_right;
+ if (!___RB_is_color(Y, RB_BLACK))
+ {
+
+ /* uncle is red */
+ X->rb_parent->color = RB_BLACK;
+ Y->color = RB_BLACK;
+ X->rb_parent->rb_parent->color = RB_RED;
+ X = X->rb_parent->rb_parent;
+ }
+ else
+ {
+
+ /* uncle is black */
+ if (X == X->rb_parent->rb_right)
+ {
+ /* make X a left child */
+ X = X->rb_parent;
+ ___RB_rotate_left(X, root);
+ }
+
+ /* recolor and rotate */
+ X->rb_parent->color = RB_BLACK;
+ X->rb_parent->rb_parent->color = RB_RED;
+ ___RB_rotate_right(X->rb_parent->rb_parent, root);
+ }
+ }
+ else
+ {
+
+ /* miror image of above code */
+ log_sup_node *Y = X->rb_parent->rb_parent->rb_left;
+ if (!___RB_is_color(Y, RB_BLACK))
+ {
+
+ /* uncle is red */
+ X->rb_parent->color = RB_BLACK;
+ Y->color = RB_BLACK;
+ X->rb_parent->rb_parent->color = RB_RED;
+ X = X->rb_parent->rb_parent;
+ }
+ else
+ {
+
+ /* uncle is black */
+ if (X == X->rb_parent->rb_left)
+ {
+ X = X->rb_parent;
+ ___RB_rotate_right(X, root);
+ }
+ X->rb_parent->color = RB_BLACK;
+ X->rb_parent->rb_parent->color = RB_RED;
+ ___RB_rotate_left(X->rb_parent->rb_parent, root);
+ }
+ }
+ }
+
+ (*root)->color = RB_BLACK;
+
+ return;
+}
+
+static void ___RB_erase(log_sup_node * node, log_sup_node ** root)
+{
+ log_sup_node *child, *parent;
+ bool color;
+
+ if (!node->rb_left)
+ {
+ child = node->rb_right;
+ }
+ else if (!node->rb_right)
+ {
+ child = node->rb_left;
+ }
+ else
+ {
+ log_sup_node *old = node, *left;
+
+ node = node->rb_right;
+ while ((left = node->rb_left) != NULL)
+ {
+ node = left;
+ }
+
+ ___RB_adjust(node, root, old);
+
+ child = node->rb_right;
+ parent = node->rb_parent;
+ color = node->color;
+
+ if (parent == old)
+ {
+ parent = node;
+ }
+ else
+ {
+ if (child)
+ {
+ child->rb_parent = parent;
+ }
+
+ parent->rb_left = child;
+
+ node->rb_right = old->rb_right;
+ old->rb_right->rb_parent = node;
+ }
+
+ node->color = old->color;
+ node->rb_parent = old->rb_parent;
+ node->rb_left = old->rb_left;
+ old->rb_left->rb_parent = node;
+
+ if (color == RB_BLACK)
+ {
+ ___RB_erase_color(child, parent, root);
+ }
+
+ return;
+
+ }
+
+ parent = node->rb_parent;
+ color = node->color;
+
+ if (child)
+ {
+ child->rb_parent = parent;
+ }
+
+ ___RB_adjust(child, root, node);
+
+ if (color == RB_BLACK)
+ {
+ ___RB_erase_color(child, parent, root);
+ }
+
+ return;
+}
+
+inline log_sup_node *__log_sup_rb_insert(log_entry * entry,
+ log_sup_node ** root)
+{
+ log_sup_node *node = *root;
+ log_sup_node *parent = NULL;
+ int ret = 0;
+ while (node)
+ {
+ parent = node;
+ ret = log_entry_cmp(&node->entry, entry);
+ if (0 < ret)
+ {
+ node = node->rb_left;
+ }
+ else if (0 > ret)
+ {
+ node = node->rb_right;
+ }
+ else
+ {
+ return NULL;
+ }
+ }
+
+ node = malloc_one_node();
+ if (!node)
+ {
+ return NULL;
+ }
+ node->entry = *entry; //copy the content, not the ptr
+ node->rb_parent = parent;
+ node->rb_left = node->rb_right = NULL;
+ node->color = RB_RED;
+
+ if (parent)
+ {
+ if (ret > 0)
+ {
+ parent->rb_left = node;
+ }
+ else
+ {
+ parent->rb_right = node;
+ }
+ }
+ else
+ {
+ *root = node;
+ }
+
+ ___RB_insert_color(node, root);
+ return node;
+}
+
+inline log_sup_node *__log_sup_rb_search(const log_entry * entry,
+ log_sup_node * root)
+{
+ log_sup_node *node = root;
+ int ret;
+ while (node)
+ {
+ ret = log_entry_cmp(&node->entry, entry);
+ if (0 < ret)
+ {
+ node = node->rb_left;
+ }
+ else if (0 > ret)
+ {
+ node = node->rb_right;
+ }
+ else
+ {
+ return node;
+ }
+ }
+
+ return NULL;
+}
+
+inline void __log_sup_rb_erase(log_sup_node * node, log_sup_node ** root)
+{
+ ___RB_erase(node, root);
+ free_one_node(node);
+}
+
+void __log_sup_rb_traversal_preorder(log_sup_node * root,
+ log_entry_worker_fn foo,
+ log_sup_node ** resnode, int *recur_cnt)
+{
+ /* avoid infinite recursion or empty tree */
+ if (!recur_cnt || (0 > *recur_cnt) || !root)
+ {
+ return;
+ }
+
+ /* NOTE: recur_cnt decreases along with foo call and does not bounce back,
+ * so it should be the numbur of nodes, not the depth */
+ (*recur_cnt)--;
+
+ int ret = foo(&(root->entry));
+ if (0 != ret)
+ {
+ if (resnode)
+ {
+ *recur_cnt = 0; /* immediate return */
+ *resnode = root;
+ }
+ return;
+ }
+
+ if ((root->rb_left) != NULL)
+ {
+ __log_sup_rb_traversal_preorder(root->rb_left, foo, resnode,
+ recur_cnt);
+ }
+ if ((root->rb_right) != NULL)
+ {
+ __log_sup_rb_traversal_preorder(root->rb_right, foo, resnode,
+ recur_cnt);
+ }
+}
diff --git a/src/framework/log/nstack_log_auto_suppress_rb_tree.h b/src/framework/log/nstack_log_auto_suppress_rb_tree.h
new file mode 100644
index 0000000..628c466
--- /dev/null
+++ b/src/framework/log/nstack_log_auto_suppress_rb_tree.h
@@ -0,0 +1,37 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#ifndef _NSTACK_LOG_SUPPRESS_RB_TREE_H_
+#define _NSTACK_LOG_SUPPRESS_RB_TREE_H_
+
+#include "nstack_log.h"
+
+typedef int (*log_entry_worker_fn) (log_entry * entry);
+typedef int (*log_entry_cpmpare_fn) (const log_entry * left,
+ const log_entry * right);
+
+log_sup_node *__log_sup_rb_insert(log_entry * entry, log_sup_node ** root);
+
+log_sup_node *__log_sup_rb_search(const log_entry * entry,
+ log_sup_node * root);
+
+void __log_sup_rb_erase(log_sup_node * node, log_sup_node ** root);
+
+void __log_sup_rb_traversal_preorder(log_sup_node * root,
+ log_entry_worker_fn foo,
+ log_sup_node ** resnode, int *recur_cnt);
+
+#endif
diff --git a/src/framework/log/nstack_log_base.h b/src/framework/log/nstack_log_base.h
new file mode 100644
index 0000000..d43c98e
--- /dev/null
+++ b/src/framework/log/nstack_log_base.h
@@ -0,0 +1,97 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#ifndef _NSTACK_LOG_BASE_H_
+#define _NSTACK_LOG_BASE_H_
+
+#include "types.h"
+#include "nstack_log.h"
+
+#define LOG_LEVEL_EMG "emg"
+#define LOG_LEVEL_ERR "err"
+#define LOG_LEVEL_WAR "war"
+#define LOG_LEVEL_DBG "dbg"
+#define LOG_LEVEL_INF "inf"
+
+#define STACKPOOL_LOG_NAME "running.log"
+
+#define OPERATION_LOG_NAME "operation.log"
+
+#define MASTER_LOG_NAME "master.log"
+
+#define OMC_CTRL_LOG_NAME "omc_ctrl.log"
+
+#define FAILURE_LOG_NAME "fail_dump.log"
+
+#define FLUSH_TIME 30
+
+#define APP_LOG_SIZE 30
+#define APP_LOG_COUNT 10
+#define APP_LOG_PATH "/var/log"
+#define APP_LOG_NAME "nStack_nSocket.log"
+
+struct log_ctrl_info
+{
+ u32 expire_time;
+ u32 unprint_count;
+ struct timespec last_log_time;
+};
+
+/* NS_LOG_CTRL use to inhibit the repeated log*/
+/* add the non reentry protection */
+extern __thread unsigned int nstack_log_nonreentry;
+
+/* if buf can't load more data(in other words, sprintf_s return -1 and set buf[pos]='\0'),
+ print the existing data, and once more try to load the data, to the beginning of the buffer,
+ if still failed, return -1.*/
+#define NSDFX_CACHE_RETURN(pos, buf, buflen, fmt, ...) do { \
+ int cache_ret = 0; \
+ if ((pos) < (buflen)) { \
+ cache_ret = sprintf_s((buf) + (pos), (buflen) - (pos), fmt, ##__VA_ARGS__); \
+ if (-1 == cache_ret) { \
+ NSDFX_LOGINF("%s", (buf)); \
+ (pos) = 0; \
+ cache_ret = sprintf_s((buf), (buflen), fmt, ##__VA_ARGS__); \
+ if (-1 == cache_ret){ \
+ NSDFX_LOGERR("NSDFX_CACHE_RETURN sprintf_s failed second time"); \
+ return -1; \
+ } \
+ } \
+ (pos) += cache_ret; \
+ } else { \
+ NSDFX_LOGERR("DFX cache buffer overflow!!!!!!"); \
+ return -1; \
+ } \
+}while(0)
+
+#define NSDFX_CACHE_FLAG_RETURN(log_flag,pos, buf, buflen, fmt, ...) do { \
+ if (log_flag) \
+ { \
+ NSDFX_CACHE_RETURN(pos, buf, buflen, fmt, ##__VA_ARGS__); \
+ } \
+}while(0)
+
+/* Utilities, placed here for convenience */
+#define STRING_IS_VALID_WITH_LENGTH(str,len) ((str) && (*str) && (strlen(str) < len))
+
+#define EACH_OF_2_ITEMS_NOT_NULL(a0,a1) ((a0)&&(a1))
+#define EACH_OF_3_ITEMS_NOT_NULL(a0,a1,a2) ((a0)&&(a1)&&(a2))
+#define EACH_OF_4_ITEMS_NOT_NULL(a0,a1,a2,a3) ((a0)&&(a1)&&(a2)&&(a3))
+#define EACH_OF_5_ITEMS_NOT_NULL(a0,a1,a2,a3,a4) ((a0)&&(a1)&&(a2)&&(a3)&&(a4))
+#define EACH_OF_6_ITEMS_NOT_NULL(a0,a1,a2,a3,a4,a5) ((a0)&&(a1)&&(a2)&&(a3)&&(a4)&&(a5))
+/* Utilities, placed here for convenience */
+
+#endif /*_NSTACK_LOG_BASE_H_*/
diff --git a/src/framework/maintain/fw_mt_config.c b/src/framework/maintain/fw_mt_config.c
new file mode 100644
index 0000000..27c2ef6
--- /dev/null
+++ b/src/framework/maintain/fw_mt_config.c
@@ -0,0 +1,78 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#include "nsfw_maintain_api.h"
+#include "nstack_securec.h"
+
+u32 g_base_cfg_items[MAX_BASE_CFG] = { 0 };
+
+u32 g_custom_cfg_items[MAX_CUSTOM_CFG] = { 0 };
+
+u32 g_macro_custom_cfg_items[CFG_ITEM_MACRO_CUSTOM_MAX] = { 0 };
+
+struct cfg_item_info g_cfg_item_info[CFG_SEG_MAX][MAX_CFG_ITEM];
+
+u32 get_cfg_info(int tag, int item)
+{
+ return (u32) g_cfg_item_info[tag][item].value;
+}
+
+u32 get_cfg_share_mem_size()
+{
+ return sizeof(g_base_cfg_items) + sizeof(g_custom_cfg_items) +
+ sizeof(g_macro_custom_cfg_items);
+}
+
+int get_share_cfg_from_mem(void *mem)
+{
+ if (EOK !=
+ memcpy_s(g_base_cfg_items, sizeof(g_base_cfg_items), mem,
+ sizeof(g_base_cfg_items)))
+ {
+ return -1;
+ }
+
+ char *custom_cfg_mem = (char *) mem + sizeof(g_base_cfg_items);
+ if (EOK !=
+ memcpy_s(g_custom_cfg_items, sizeof(g_custom_cfg_items),
+ custom_cfg_mem, sizeof(g_custom_cfg_items)))
+ {
+ return -1;
+ }
+
+ char *macro_cfg_mem = custom_cfg_mem + sizeof(g_custom_cfg_items);
+ if (EOK !=
+ memcpy_s(g_macro_custom_cfg_items, sizeof(g_macro_custom_cfg_items),
+ macro_cfg_mem, sizeof(g_macro_custom_cfg_items)))
+ {
+ return -1;
+ }
+
+ return 0;
+}
+
+void get_default_base_cfg(u32 thread_num)
+{
+ g_base_cfg_items[CFG_BASE_THREAD_NUM] = thread_num;
+ g_base_cfg_items[CFG_BASE_RING_SIZE] = DEF_RING_BASE_SIZE;
+ g_base_cfg_items[CFG_BASE_HAL_PORT_NUM] = DEF_HAL_PORT_NUM;
+
+ g_base_cfg_items[CFG_BASE_SOCKET_NUM] = 1024;
+ g_base_cfg_items[CFG_BASE_ARP_STALE_TIME] = DEF_ARP_STACLE_TIME;
+ g_base_cfg_items[CFG_BASE_ARP_BC_RETRANS_NUM] = DEF_ARP_BC_RETRANS_NUM;
+
+ return;
+}
diff --git a/src/framework/maintain/nsfw_lock_file.c b/src/framework/maintain/nsfw_lock_file.c
new file mode 100644
index 0000000..289bdde
--- /dev/null
+++ b/src/framework/maintain/nsfw_lock_file.c
@@ -0,0 +1,174 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "types.h"
+#include "nstack_securec.h"
+#include "nsfw_init_api.h"
+
+#include "nsfw_base_linux_api.h"
+#include "nstack_log.h"
+#include "nsfw_maintain_api.h"
+#include "nsfw_mgr_com_api.h"
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C"{
+/* *INDENT-ON* */
+#endif /* __cplusplus */
+
+#define NSFW_FILE_PATH_LEN 128
+#define LOCK_FOLDER "/ip_module/"
+#define LOCK_SUFFIX ".pid"
+
+#define read_lock(fd, offset, whence, len) nsfw_lock_reg((fd), F_SETLK, F_RDLCK, (offset), (whence), (len))
+#define readw_lock(fd, offset, whence, len) nsfw_lock_reg((fd), F_SETLKW, F_RDLCK, (offset), (whence), (len))
+#define write_lock(fd, offset, whence, len) nsfw_lock_reg((fd), F_SETLK, F_WRLCK, (offset), (whence), (len))
+#define writew_lock(fd, offset, whence, len) nsfw_lock_reg((fd), F_SETLKW, F_WRLCK, (offset), (whence), (len))
+#define un_lock(fd, offset, whence, len) nsfw_lock_reg((fd), F_SETLK, F_UNLCK, (offset), (whence), (len))
+
+i32 nsfw_lock_reg(i32 fd, i32 cmd, i32 type, off_t offset, i32 whence,
+ off_t len)
+{
+ struct flock lock_file;
+ lock_file.l_type = type;
+ lock_file.l_start = offset;
+ lock_file.l_whence = whence;
+ lock_file.l_len = len;
+ return (fcntl(fd, cmd, &lock_file));
+}
+
+/*****************************************************************************
+* Prototype : nsfw_proc_start_with_lock
+* Description : lock file start
+* Input : u8 proc_type
+* Output : None
+* Return Value : i32
+* Calls :
+* Called By :
+*****************************************************************************/
+i32 nsfw_proc_start_with_lock(u8 proc_type)
+{
+ NSFW_LOGINF("lock_file init]type=%u", proc_type);
+ char *module_name = nsfw_get_proc_name(proc_type);
+ if (NULL == module_name)
+ {
+ NSFW_LOGERR("proc type error]proc_type=%u", proc_type);
+ return 0;
+ }
+
+ const char *directory = NSFW_DOMAIN_DIR;
+ const char *home_dir = get_home_path();
+ if (home_dir)
+ {
+ directory = home_dir;
+ }
+
+ int ret = -1;
+ char lock_fpath[NSFW_FILE_PATH_LEN] = { 0 };
+ ret = strcpy_s(lock_fpath, NSFW_FILE_PATH_LEN, directory);
+ if (EOK != ret)
+ {
+ NSFW_LOGERR("lock init strcpy_s failed]ret=%d", ret);
+ return -1;
+ }
+
+ ret = strcat_s(lock_fpath, NSFW_FILE_PATH_LEN, LOCK_FOLDER);
+ if (EOK != ret)
+ {
+ NSFW_LOGERR("lock init strcat_s failed]ret=%d", ret);
+ return -1;
+ }
+
+ ret = strcat_s(lock_fpath, NSFW_FILE_PATH_LEN, module_name);
+ if (EOK != ret)
+ {
+ NSFW_LOGERR("lock init strcat_s failed]ret=%d", ret);
+ return -1;
+ }
+
+ ret = strcat_s(lock_fpath, NSFW_FILE_PATH_LEN, LOCK_SUFFIX);
+ if (EOK != ret)
+ {
+ NSFW_LOGERR("lock init strcat_s failed]ret=%d", ret);
+ return -1;
+ }
+
+ i32 fd;
+
+ if ((fd = open(lock_fpath, O_RDWR | O_CREAT, 0640)) == -1) /* file permission no large than 0640 */
+ {
+ NSFW_LOGERR("open lock file error!]path=%s,error = %d", lock_fpath,
+ errno);
+ return -1;
+ }
+
+ /* close on exec */
+ int rc = nsfw_set_close_on_exec(fd);
+ if (rc == -1)
+ {
+ (void) nsfw_base_close(fd);
+ NSFW_LOGERR("set exec err]fd=%d, errno=%d", fd, errno);
+ return -1;
+ }
+
+ if (write_lock(fd, 0, SEEK_SET, 0) < 0)
+ {
+ (void) nsfw_base_close(fd);
+ NSFW_LOGERR("get lock file error!]path=%s,error = %d", lock_fpath,
+ errno);
+ return -1;
+ }
+
+ char buf[32] = { 0 };
+ if (ftruncate(fd, 0) < 0)
+ {
+ (void) nsfw_base_close(fd);
+ NSFW_LOGERR("ftruncate file error!]path=%s,error = %d", lock_fpath,
+ errno);
+ return -1;
+ }
+
+ ret =
+ snprintf_s(buf, sizeof(buf), sizeof(buf) - 1, "%ld", (long) getpid());
+ if (-1 == ret)
+ {
+ NSTCP_LOGERR("snprintf_s failed]ret=%d", ret);
+ (void) nsfw_base_close(fd);
+ return -1;
+ }
+
+ if (write(fd, buf, strlen(buf)) < 0)
+ {
+ (void) nsfw_base_close(fd);
+ NSFW_LOGERR("write file error!]path=%s,error = %d", lock_fpath,
+ errno);
+ return -1;
+ }
+// (void)nsfw_base_close(fd); /*no nee to close fd because its used to lock file*/
+ return 0;
+}
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif /* __cplusplus */
diff --git a/src/framework/maintain/nsfw_mem_stat.c b/src/framework/maintain/nsfw_mem_stat.c
new file mode 100644
index 0000000..f78f51c
--- /dev/null
+++ b/src/framework/maintain/nsfw_mem_stat.c
@@ -0,0 +1,286 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#include <stdlib.h>
+#include "types.h"
+#include "nstack_securec.h"
+#include "nsfw_init_api.h"
+
+#include "nstack_log.h"
+#include "nsfw_maintain_api.h"
+#include "nsfw_mem_api.h"
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C"{
+/* *INDENT-ON* */
+#endif /* __cplusplus */
+
+#define NSFW_MEM_STAT_NUM 512
+
+#define NSFW_MEM_STAT_MODULE "nsfw_mem_stat_module"
+
+typedef struct _nsfw_mem_stat
+{
+ u8 mem_type;
+ u8 alloc_flag;
+ char module[NSFW_MEM_MODULE_LEN];
+ char mem_name[NSFW_MEM_NAME_LEN];
+ u32 mem_size;
+} nsfw_mem_stat_t;
+
+nsfw_mem_stat_t g_mem_stat[NSFW_MEM_STAT_NUM];
+
+#ifdef SYS_MEM_RES_STAT
+#define MAX_STAT_ITEM_NUM 20
+typedef struct _mem_stat_item_t
+{
+ char name[32];
+ u64 size;
+} mem_stat_item_t;
+
+typedef struct _mem_stat_mgr_t
+{
+ u32 item_num;
+ mem_stat_item_t item[MAX_STAT_ITEM_NUM];
+} mem_stat_mgr;
+
+mem_stat_mgr g_max_mem_list;
+#endif
+
+/*****************************************************************************
+* Prototype : nsfw_mem_stat
+* Description : add memory stat
+* Input : char *module
+* char *mem_name
+* u8 mem_type
+* u32 mem_size
+* Output : None
+* Return Value : void
+* Calls :
+* Called By :
+*****************************************************************************/
+void nsfw_mem_stat(char *module, char *mem_name, u8 mem_type, u64 mem_size)
+{
+ if (NULL == module || NULL == mem_name)
+ {
+ NSFW_LOGERR("argv err]module=%p,mem_name=%p", module, mem_name);
+ return;
+ }
+
+ int i;
+ nsfw_mem_stat_t *mem_stat_item = NULL;
+ for (i = 0; i < NSFW_MEM_STAT_NUM; i++)
+ {
+ if (FALSE == g_mem_stat[i].alloc_flag)
+ {
+ g_mem_stat[i].alloc_flag = TRUE;
+ mem_stat_item = &g_mem_stat[i];
+ break;
+ }
+ }
+
+ if (NULL == mem_stat_item)
+ {
+ NSFW_LOGERR("mem stat full]module=%s,type=%u,name=%s,size=%lu",
+ module, mem_type, mem_name, mem_size);
+ return;
+ }
+
+ mem_stat_item->mem_type = mem_type;
+ mem_stat_item->mem_size = mem_size;
+
+ /* we'd better use `strlen(src)` or `sizeof(dst)` to explain copying length of src string.
+ it's meaningless using `sizeof(dst) - 1` to reserve 1 byte for '\0'.
+ if copying length equals to or bigger than dst length, just let strncpy_s() returns failure. */
+
+ /* change param 'count' from NSFW_MEM_MODULE_LEN to NSFW_MEM_MODULE_LEN-1 */
+ if (EOK != strcpy_s(mem_stat_item->module, NSFW_MEM_MODULE_LEN, module)) // remove needless 'count' param and change strncpy_s to strcpy_s
+ {
+ NSFW_LOGERR("strncpy_s failed");
+ return;
+ }
+
+ /* change param 'count' from NSFW_MEM_NAME_LEN to NSFW_MEM_NAME_LEN-1 */
+ if (EOK != strcpy_s(mem_stat_item->mem_name, NSFW_MEM_NAME_LEN, mem_name)) // remove needless 'count' param and change strncpy_s to strcpy_s
+ {
+ NSFW_LOGERR("strncpy_s failed");
+ return;
+ }
+
+ return;
+}
+
+void nsfw_mem_stat_print()
+{
+ int i;
+ for (i = 0; i < NSFW_MEM_STAT_NUM; i++)
+ {
+ if (TRUE == g_mem_stat[i].alloc_flag)
+ {
+ NSFW_LOGINF("mem_module=%s,name=%s,type=%u,size=%u",
+ g_mem_stat[i].module, g_mem_stat[i].mem_name,
+ g_mem_stat[i].mem_type, g_mem_stat[i].mem_size);
+ }
+ }
+
+}
+
+#ifdef SYS_MEM_RES_STAT
+void clear_mem_stat_item()
+{
+ if (EOK != memset_s((char *) &g_max_mem_list, sizeof(mem_stat_mgr),
+ 0, sizeof(mem_stat_mgr)))
+ {
+ NSFW_LOGERR("memset_s failed");
+ }
+}
+
+void insert_mem_stat_item(char *name, u64 len)
+{
+ int j, temp;
+
+ if (g_max_mem_list.item_num == 0)
+ {
+ /* copy string should use strcpy_s */
+ if (EOK !=
+ strcpy_s(g_max_mem_list.item[0].name,
+ sizeof(g_max_mem_list.item[0].name), name))
+ {
+ NSFW_LOGERR("strcpy_s failed");
+ }
+ g_max_mem_list.item[0].size = len;
+ g_max_mem_list.item_num++;
+ return;
+ }
+ else if (g_max_mem_list.item_num < MAX_STAT_ITEM_NUM)
+ {
+ if (len <= g_max_mem_list.item[g_max_mem_list.item_num - 1].size)
+ {
+ /* copy string should use strcpy_s */
+ if (EOK !=
+ strcpy_s(g_max_mem_list.item[g_max_mem_list.item_num].name,
+ sizeof(g_max_mem_list.item
+ [g_max_mem_list.item_num].name), name))
+ {
+ NSFW_LOGERR("strcpy_s failed");
+ }
+ g_max_mem_list.item[g_max_mem_list.item_num].size = len;
+ g_max_mem_list.item_num++;
+ return;
+ }
+ j = 0;
+ temp = g_max_mem_list.item_num;
+ while (j < temp)
+ {
+ if (len >= g_max_mem_list.item[j].size)
+ {
+ goto insert_it;
+ }
+ j++;
+ }
+ if (j == temp)
+ {
+ /* copy string should use strcpy_s */
+ if (EOK !=
+ strcpy_s(g_max_mem_list.item[j].name,
+ sizeof(g_max_mem_list.item[j].name), name))
+ {
+ NSFW_LOGERR("strcpy_s failed");
+ }
+ g_max_mem_list.item[j].size = len;
+ g_max_mem_list.item_num++;
+ return;
+ }
+ }
+ else
+ {
+ j = 0;
+ temp = MAX_STAT_ITEM_NUM - 1;
+ while (j < MAX_STAT_ITEM_NUM)
+ {
+ if (len >= g_max_mem_list.item[j].size)
+ {
+ goto insert_it;
+ }
+ j++;
+ }
+ }
+
+ return;
+
+ while (temp - 1 >= j)
+ {
+ /* copy string should use strcpy_s */
+ if (EOK !=
+ strcpy_s(g_max_mem_list.item[temp].name,
+ sizeof(g_max_mem_list.item[temp].name),
+ g_max_mem_list.item[temp - 1].name))
+ {
+ NSFW_LOGERR("strcpy_s failed");
+ }
+ g_max_mem_list.item[temp].size = g_max_mem_list.item[temp - 1].size;
+ temp--;
+ }
+ /* copy string should use strcpy_s */
+ if (EOK !=
+ strcpy_s(g_max_mem_list.item[j].name,
+ sizeof(g_max_mem_list.item[j].name), name))
+ {
+ NSFW_LOGERR("strcpy_s failed");
+ }
+ g_max_mem_list.item[j].size = len;
+ g_max_mem_list.item_num++;
+ return;
+}
+
+int get_mem_stat_item(int idx, char **name, u64 * len)
+{
+ if (idx < 0 || idx >= MAX_STAT_ITEM_NUM)
+ {
+ return -1;
+ }
+
+ *name = g_max_mem_list.item[idx].name;
+ *len = g_max_mem_list.item[idx].size;
+
+ return 0;
+}
+#endif
+
+int nsfw_mem_stat_init(void *param);
+int nsfw_mem_stat_init(void *param)
+{
+ MEM_STAT(NSFW_MEM_STAT_MODULE, "g_mem_stat", NSFW_NSHMEM,
+ sizeof(g_mem_stat));
+ nsfw_mem_stat_print();
+#ifdef SYS_MEM_RES_STAT
+ clear_mem_stat_item();
+#endif
+ return 0;
+}
+
+/* *INDENT-OFF* */
+NSFW_MODULE_NAME(NSFW_MEM_STAT_MODULE)
+NSFW_MODULE_PRIORITY(99)
+NSFW_MODULE_INIT(nsfw_mem_stat_init)
+/* *INDENT-ON* */
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif /* __cplusplus */
diff --git a/src/framework/maintain/nsfw_res_mgr.c b/src/framework/maintain/nsfw_res_mgr.c
new file mode 100644
index 0000000..36ce6d4
--- /dev/null
+++ b/src/framework/maintain/nsfw_res_mgr.c
@@ -0,0 +1,70 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#include <stdlib.h>
+#include "types.h"
+#include "nstack_securec.h"
+#include "nsfw_init_api.h"
+
+#include "nstack_log.h"
+#include "nsfw_maintain_api.h"
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C"{
+/* *INDENT-ON* */
+#endif /* __cplusplus */
+
+nsfw_res_mgr_item_cfg g_all_res_can[NSFW_MAX_RES_SCAN_COUNT];
+
+u8 nsfw_res_mgr_reg(nsfw_res_scn_cfg * cfg)
+{
+ if (NULL == cfg)
+ {
+ NSFW_LOGERR("argv err!");
+ return FALSE;
+ }
+
+ u32 i;
+ for (i = 0; i < NSFW_MAX_RES_SCAN_COUNT; i++)
+ {
+
+ if ((NULL == g_all_res_can[i].scn_cfg.free_fun)
+ &&
+ (__sync_bool_compare_and_swap
+ (&g_all_res_can[i].scn_cfg.free_fun, 0, cfg->free_fun)))
+ {
+ g_all_res_can[i].scn_cfg = *cfg;
+ NSFW_LOGINF("reg res_mgr fun suc]fun=%p,data=%p", cfg->free_fun,
+ cfg->data);
+ return TRUE;
+ }
+ }
+
+ /* here is fail branch, should log ERR level and return false */
+ NSFW_LOGERR
+ ("reg]type=%u,per=%u,chk=%u,cyc=%u,total=%u,size=%u,offset=%u,fun=%p,data=%p",
+ cfg->type, cfg->force_free_percent, cfg->force_free_chk_num,
+ cfg->num_per_cyc, cfg->total_num, cfg->elm_size, cfg->res_mem_offset,
+ cfg->free_fun, cfg->data);
+ return FALSE;
+}
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif /* __cplusplus */
diff --git a/src/framework/maintain/nsfw_set_log.c b/src/framework/maintain/nsfw_set_log.c
new file mode 100644
index 0000000..c8125ec
--- /dev/null
+++ b/src/framework/maintain/nsfw_set_log.c
@@ -0,0 +1,196 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#include <stdlib.h>
+#include "types.h"
+#include "nstack_securec.h"
+#include "nsfw_init_api.h"
+
+#include "nstack_log.h"
+#include "nsfw_maintain_api.h"
+#include "nsfw_mem_api.h"
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C"{
+/* *INDENT-ON* */
+#endif /* __cplusplus */
+
+typedef struct _nsfw_log_cfg
+{
+ u8 proc_type;
+ char master_log_path[NSFW_LOG_VALUE_LEN];
+ char runing_log_path[NSFW_LOG_VALUE_LEN];
+ char opr_log_path[NSFW_LOG_VALUE_LEN];
+} nsfw_log_cfg;
+
+nsfw_log_cfg g_log_cfg;
+
+const char nsfw_mas_log[NSFW_LOG_VALUE_LEN] = "maspath";
+const char nsfw_flush_name[NSFW_LOG_VALUE_LEN] = "flush";
+
+enum _set_log_type
+{
+ SET_LOG_LEVEL = 0,
+ SET_LOG_FLUSH,
+ SET_LOG_MASTER,
+ SET_LOG_MAIN,
+
+ SET_LOG_INVALID
+};
+extern struct log_init_para g_log_init_para;
+
+int nsfw_set_log_path(const char *param, const char *value)
+{
+ if (NULL == param || NULL == value)
+ {
+ NSFW_LOGERR("log param error!]param=%p,value=%p", param, value);
+ return 1;
+ }
+
+ if (strcmp(g_log_init_para.mon_log_path, value) == 0)
+ {
+ NSFW_LOGWAR("Enter the address the same as the original address");
+ return 0;
+ }
+
+ /* add the path valid check */
+ if (check_log_dir_valid(value) < 0)
+ {
+ NSFW_LOGERR("path is invalid]value=%s", value);
+ return 1;
+ }
+ if (EOK != strcpy_s(g_log_cfg.master_log_path, NSFW_LOG_VALUE_LEN, value))
+ {
+ NSFW_LOGERR("strcpy error!");
+ return 1;
+ }
+
+ NSFW_LOGINF("renew log path]%s", g_log_cfg.master_log_path);
+ /* set log in glog, no need log lock now */
+ nstack_modify_log_dir(g_log_cfg.master_log_path);
+ NSFW_LOGINF("set log sucess]newpath=%s!", g_log_cfg.master_log_path);
+ return 0;
+}
+
+int nsfw_flush_log_info(const char *param, u8 proc_type)
+{
+ if (NULL == param)
+ {
+ NSFW_LOGERR("log param error!]param=%p", param);
+ return 1;
+ }
+ glogFlushLogFiles(GLOG_LEVEL_DEBUG);
+ NSFW_LOGINF("flush log sucess]proc_type=%u", proc_type);
+ return 0;
+}
+
+int nsfw_set_log_msg_proc(nsfw_mgr_msg * msg)
+{
+ int ret = -1;
+ int status = -1;
+ if (NULL == msg)
+ {
+ NSFW_LOGERR("msg nul");
+ return FALSE;
+ }
+
+ nsfw_set_log_msg *set_log_msg = GET_USER_MSG(nsfw_set_log_msg, msg);
+
+ /* add the flush branch handle */
+ if (0 == strcmp(set_log_msg->module, nsfw_mas_log))
+ {
+ status = SET_LOG_MASTER;
+ }
+ else if (0 == strcmp(set_log_msg->module, nsfw_flush_name))
+ {
+ status = SET_LOG_FLUSH;
+ }
+ else if (nsfw_isdigitstr(set_log_msg->module))
+ {
+ status = SET_LOG_LEVEL;
+ }
+
+ switch (status)
+ {
+ case SET_LOG_LEVEL:
+ ret =
+ setlog_level_value(set_log_msg->module,
+ set_log_msg->log_level);
+ break;
+ case SET_LOG_FLUSH:
+ ret =
+ nsfw_flush_log_info(set_log_msg->module, msg->dst_proc_type);
+ break;
+ case SET_LOG_MASTER:
+ ret =
+ nsfw_set_log_path(set_log_msg->module,
+ set_log_msg->log_level);
+ break;
+ default:
+ NSFW_LOGERR("default error]status=%d,set_log_msg->module=%s",
+ status, set_log_msg->module);
+ break;
+ }
+
+ nsfw_mgr_msg *rsp_msg = nsfw_mgr_rsp_msg_alloc(msg);
+ if (NULL == rsp_msg)
+ {
+ NSFW_LOGERR("alloc rsp failed,drop msg!" MSGINFO, PRTMSG(msg));
+ return FALSE;
+ }
+ nsfw_set_log_msg *log_rsp_msg = GET_USER_MSG(nsfw_set_log_msg, rsp_msg);
+ log_rsp_msg->rsp_code = ret;
+ (void) nsfw_mgr_send_msg(rsp_msg);
+ nsfw_mgr_msg_free(rsp_msg);
+ return TRUE;
+}
+
+static int nsfw_cfg_module_init(void *param);
+static int nsfw_cfg_module_init(void *param)
+{
+ u8 proc_type = (u8) ((long long) param);
+ NSFW_LOGINF("log cfg module init]type=%u", proc_type);
+ switch (proc_type)
+ {
+ case NSFW_PROC_MAIN:
+ case NSFW_PROC_MASTER:
+ (void) nsfw_mgr_reg_msg_fun(MGR_MSG_SET_LOG_REQ,
+ nsfw_set_log_msg_proc);
+ g_log_cfg.proc_type = proc_type;
+ return 0;
+ default:
+ if (proc_type < NSFW_PROC_MAX)
+ {
+ break;
+ }
+ return -1;
+ }
+
+ return 0;
+}
+
+/* *INDENT-OFF* */
+NSFW_MODULE_NAME(NSFW_LOG_CFG_MODULE)
+NSFW_MODULE_PRIORITY(99)
+NSFW_MODULE_INIT(nsfw_cfg_module_init)
+/* *INDENT-ON* */
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif /* __cplusplus */
diff --git a/src/framework/maintain/nsfw_soft_param.c b/src/framework/maintain/nsfw_soft_param.c
new file mode 100644
index 0000000..c99f785
--- /dev/null
+++ b/src/framework/maintain/nsfw_soft_param.c
@@ -0,0 +1,289 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+/*==============================================*
+ * include header files *
+ *----------------------------------------------*/
+
+#include <stdlib.h>
+#include "types.h"
+#include "nstack_securec.h"
+#include "nsfw_init_api.h"
+#include "nstack_log.h"
+#include "nsfw_maintain_api.h"
+#include "nsfw_mem_api.h"
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C"{
+/* *INDENT-ON* */
+#endif /* __cplusplus */
+
+typedef struct _nsfw_set_soft_item
+{
+ void *data;
+ u32 size;
+ u64 max;
+ u64 min;
+} nsfw_set_soft_item;
+
+nsfw_set_soft_fun g_soft_fun[NSFW_MAX_SOFT_PARAM] = { 0 };
+
+nsfw_set_soft_item g_soft_int_cfg[NSFW_MAX_SOFT_PARAM];
+
+int nsfw_isdigitstr(const char *str)
+{
+ if (NULL == str || '\0' == str[0])
+ return 0;
+
+ while (*str)
+ {
+ if (*str < '0' || *str > '9')
+ return 0;
+ str++;
+ }
+ return 1;
+}
+
+u8 nsfw_soft_param_reg_fun(u32 param_name, nsfw_set_soft_fun fun)
+{
+ if (NULL == fun || param_name >= NSFW_MAX_SOFT_PARAM)
+ {
+ NSFW_LOGERR("argv err]fun=%p,type=%u", fun, param_name);
+ return FALSE;
+ }
+
+ g_soft_fun[param_name] = fun;
+ NSFW_LOGINF("reg]fun=%p,type=%u", fun, param_name);
+ return TRUE;
+}
+
+int nsfw_soft_set_int(u32 param, char *buf, u32 buf_len)
+{
+ u64 buf_value = 0;
+ if (NULL == buf || param >= NSFW_MAX_SOFT_PARAM)
+ {
+ NSFW_LOGERR("argv err]buf=%p,param=%u", buf, param);
+ return FALSE;
+ }
+
+ if (!nsfw_isdigitstr(buf))
+ {
+ NSFW_LOGERR("argv err]buf=%s,param=%u", buf, param);
+ return FALSE;
+ }
+
+ char *parsing_end;
+ buf_value = (u64) strtol(buf, &parsing_end, 10);
+ nsfw_set_soft_item *int_item = &g_soft_int_cfg[param];
+ if (NULL == int_item->data)
+ {
+ NSFW_LOGERR("data err]buf=%s,param=%u,min=%llu,max=%llu", buf, param, int_item->min, int_item->max); //fix type dismatch
+ return FALSE;
+ }
+
+ if (buf_value < int_item->min || buf_value > int_item->max)
+ {
+ NSFW_LOGERR("argv err]buf=%s,param=%u,min=%llu,max=%llu", buf, param, int_item->min, int_item->max); //fix type dismatch
+ return FALSE;
+ }
+
+ u32 size = int_item->size;
+ if (size >= sizeof(u64))
+ {
+ size = sizeof(u64);
+ }
+
+ if (EOK != memcpy_s(int_item->data, size, &buf_value, size))
+ {
+ NSFW_LOGERR("memcpy_s failed");
+ return FALSE;
+ }
+
+ NSFW_LOGDBG("set soft param ok]param=%u,value=%llu,size=%u", param,
+ buf_value, size);
+ return TRUE;
+}
+
+/*****************************************************************************
+* Prototype : nsfw_soft_param_reg_int
+* Description : reg int param set
+* Input : u32 param_name
+* u32 size
+* u32 min
+* u32 max
+* u64 *data
+* Output : None
+* Return Value : u8
+* Calls :
+* Called By :
+*****************************************************************************/
+u8 nsfw_soft_param_reg_int(u32 param_name, u32 size, u32 min, u32 max,
+ u64 * data)
+{
+ if (NULL == data || param_name >= NSFW_MAX_SOFT_PARAM)
+ {
+ NSFW_LOGERR("argv err]data=%p,type=%u", data, param_name);
+ return FALSE;
+ }
+
+ g_soft_int_cfg[param_name].data = data;
+ g_soft_int_cfg[param_name].size = size;
+ g_soft_int_cfg[param_name].max = max;
+ g_soft_int_cfg[param_name].min = min;
+ return nsfw_soft_param_reg_fun(param_name, nsfw_soft_set_int);
+}
+
+void nsfw_set_soft_para(fw_poc_type proc_type, u32 para_name, void *value,
+ u32 size)
+{
+ nsfw_mgr_msg *msg =
+ (nsfw_mgr_msg *) nsfw_mgr_msg_alloc(MGR_MSG_SOF_PAR_REQ, proc_type);
+ if (NULL == msg)
+ {
+ NSFW_LOGERR
+ ("nsfw_mgr_msg_alloc failed] msg type=%d, proc type=%d, para_name=%u",
+ MGR_MSG_SOF_PAR_REQ, proc_type, para_name);
+ return;
+ }
+
+ nsfw_soft_param_msg *soft_msg = GET_USER_MSG(nsfw_soft_param_msg, msg);
+
+ soft_msg->param_name = para_name;
+ soft_msg->rsp_code = 0;
+
+ if (EOK !=
+ memcpy_s(soft_msg->param_value, sizeof(soft_msg->param_value),
+ value, size))
+ {
+ NSFW_LOGERR
+ ("memcpy_s failed] msg type=%d, proc type=%d, para_name=%u",
+ MGR_MSG_SOF_PAR_REQ, proc_type, para_name);
+ nsfw_mgr_msg_free(msg);
+ return;
+ }
+
+ nsfw_mgr_msg *rsp = nsfw_mgr_null_rspmsg_alloc();
+ if (NULL == rsp)
+ {
+ NSFW_LOGERR
+ ("nsfw_mgr_null_rspmsg_alloc failed] msg type=%d, proc type=%d, para_name=%u",
+ MGR_MSG_SOF_PAR_REQ, proc_type, para_name);
+ nsfw_mgr_msg_free(msg);
+ return;
+ }
+
+ if (!nsfw_mgr_send_req_wait_rsp(msg, rsp))
+ {
+ NSFW_LOGERR
+ ("can not get response] msg type=%d, proc type=%d, para_name=%u",
+ MGR_MSG_SOF_PAR_REQ, proc_type, para_name);
+ nsfw_mgr_msg_free(msg);
+ nsfw_mgr_msg_free(rsp);
+ return;
+ }
+
+ nsfw_soft_param_msg *soft_rsp_msg =
+ GET_USER_MSG(nsfw_soft_param_msg, rsp);
+ if (soft_rsp_msg->rsp_code != NSFW_EXIT_SUCCESS)
+ {
+ NSFW_LOGERR
+ ("set soft param failed] msg type=%d, proc type=%d, para_name=%u, rsp code=%u",
+ MGR_MSG_SOF_PAR_REQ, proc_type, para_name,
+ soft_rsp_msg->rsp_code);
+ nsfw_mgr_msg_free(msg);
+ nsfw_mgr_msg_free(rsp);
+ return;
+ }
+
+ NSFW_LOGDBG
+ ("set soft param success] msg type=%d, proc type=%d, para_name=%u",
+ MGR_MSG_SOF_PAR_REQ, proc_type, para_name);
+
+ nsfw_mgr_msg_free(msg);
+ nsfw_mgr_msg_free(rsp);
+ return;
+}
+
+int nsfw_softparam_msg_proc(nsfw_mgr_msg * msg)
+{
+ nsfw_mgr_msg *rsp_msg = nsfw_mgr_rsp_msg_alloc(msg);
+ if (NULL == rsp_msg)
+ {
+ NSFW_LOGERR("alloc rsp failed,drop msg!" MSGINFO, PRTMSG(msg));
+ return FALSE;
+ }
+
+ nsfw_soft_param_msg *soft_msg = GET_USER_MSG(nsfw_soft_param_msg, msg);
+ nsfw_soft_param_msg *soft_rsp_msg =
+ GET_USER_MSG(nsfw_soft_param_msg, rsp_msg);
+ if ((soft_msg->param_name < NSFW_MAX_SOFT_PARAM)
+ && (NULL != g_soft_fun[soft_msg->param_name]))
+ {
+ soft_msg->param_value[sizeof(soft_msg->param_value) - 1] = 0;
+ (void) g_soft_fun[soft_msg->param_name] (soft_msg->param_name,
+ (char *)
+ soft_msg->param_value,
+ sizeof
+ (soft_msg->param_value));
+ //NSFW_LOGERR("set soft!]soft=%d,value=%s,ret=%d",soft_msg->param_name,soft_msg->param_value,ret);
+ soft_rsp_msg->rsp_code = NSFW_EXIT_SUCCESS;
+ }
+ else
+ {
+ NSFW_LOGERR("set soft failed!]soft=%u", soft_msg->param_name);
+ soft_rsp_msg->rsp_code = NSFW_EXIT_FAILED;
+ }
+
+ (void) nsfw_mgr_send_msg(rsp_msg);
+ nsfw_mgr_msg_free(rsp_msg);
+ return TRUE;
+}
+
+int nsfw_softparam_module_init(void *param);
+int nsfw_softparam_module_init(void *param)
+{
+ u8 proc_type = (u8) ((long long) param);
+ NSFW_LOGINF("softparam module init]type=%u", proc_type);
+ switch (proc_type)
+ {
+ case NSFW_PROC_MAIN:
+ case NSFW_PROC_MASTER:
+ (void) nsfw_mgr_reg_msg_fun(MGR_MSG_SOF_PAR_REQ,
+ nsfw_softparam_msg_proc);
+ return 0;
+ default:
+ if (proc_type < NSFW_PROC_MAX)
+ {
+ break;
+ }
+ return -1;
+ }
+
+ return 0;
+}
+
+/* *INDENT-OFF* */
+NSFW_MODULE_NAME(NSFW_SOFT_PARAM_MODULE)
+NSFW_MODULE_PRIORITY(99)
+NSFW_MODULE_INIT(nsfw_softparam_module_init)
+/* *INDENT-ON* */
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif /* __cplusplus */
diff --git a/src/framework/maintain/nsfw_ver_mgr.c b/src/framework/maintain/nsfw_ver_mgr.c
new file mode 100644
index 0000000..993fd49
--- /dev/null
+++ b/src/framework/maintain/nsfw_ver_mgr.c
@@ -0,0 +1,391 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#include <stdlib.h>
+#include "types.h"
+#include "nstack_securec.h"
+#include "nsfw_init_api.h"
+#include "nstack_log.h"
+#include "nsfw_maintain_api.h"
+#include "nsfw_mem_api.h"
+
+nsfw_ver_info g_ver_info;
+
+int g_cur_upg_state = 0;
+int g_start_type = 0;
+
+#define NSFW_VER_UPG_KILL_TIME 5
+
+u8 nsfw_init_version_info(u8 proc_type)
+{
+ int retVal;
+ char *module_name = nsfw_get_proc_name(proc_type);
+ if (NULL == module_name)
+ {
+ return FALSE;
+ }
+
+ retVal =
+ strcpy_s(g_ver_info.module_name, NSTACK_MAX_MODULE_LEN, module_name);
+ if (EOK != retVal)
+ {
+ NSFW_LOGERR("strcpy_s failed]ret=%d.", retVal);
+ return FALSE;
+ }
+
+ /* `sizeof(constant string) -1` equals to `strlen(constant string)` */
+ retVal = strcpy_s(g_ver_info.version, NSTACK_MAX_VERSION_LEN, NSTACK_GETVER_VERSION); //remove needless 'count' param and change strncpy_s to strcpy_s
+ if (EOK != retVal)
+ {
+ NSFW_LOGERR("strncpy_s failed]ret=%d.", retVal);
+ return FALSE;
+ }
+
+ retVal = strcpy_s(g_ver_info.build_time, NSTACK_MAX_BUILDTIME_LEN, NSTACK_GETVER_BUILDTIME); //remove needless 'count' param and change strncpy_s to strcpy_s
+ if (EOK != retVal)
+ {
+ NSFW_LOGERR("strncpy_s failed]ret=%d.", retVal);
+ return FALSE;
+ }
+ NSFW_LOGINF("init version]daemon-stack_version=%s", NSTACK_VERSION);
+ return TRUE;
+}
+
+/*****************************************************************************
+* Prototype : nsfw_srv_ctrl_send
+* Description : send service control message
+* Input : nsfw_srv_ctrl_state state
+* Output : None
+* Return Value : u8
+* Calls :
+* Called By :
+*****************************************************************************/
+u8 nsfw_srv_ctrl_send(nsfw_srv_ctrl_state state, u8 rsp_flag)
+{
+ nsfw_mgr_msg *req_msg =
+ nsfw_mgr_msg_alloc(MGR_MSG_SRV_CTL_REQ, NSFW_PROC_MASTER);
+ if (NULL == req_msg)
+ {
+ NSFW_LOGERR("alloc req msg failed]state=%d", state);
+ return FALSE;
+ }
+
+ nsfw_mgr_msg *rsp_msg = NULL;
+ if (TRUE == rsp_flag)
+ {
+ rsp_msg = nsfw_mgr_null_rspmsg_alloc();
+ if (NULL == rsp_msg)
+ {
+ nsfw_mgr_msg_free(req_msg);
+ NSFW_LOGERR("alloc rsp msg failed]state=%d", state);
+ return FALSE;
+ }
+ }
+
+ nsfw_srv_ctrl_msg *ctrl_msg = GET_USER_MSG(nsfw_srv_ctrl_msg, req_msg);
+ ctrl_msg->srv_state = state;
+
+ u8 ret;
+ ret = nsfw_mgr_send_req_wait_rsp(req_msg, rsp_msg);
+ NSFW_LOGINF("send srv ctrl end msg]state=%d,ret=%u,rsp=%u", state, ret,
+ rsp_flag);
+ nsfw_mgr_msg_free(req_msg);
+ if (NULL != rsp_msg)
+ {
+ nsfw_mgr_msg_free(rsp_msg);
+ }
+ return ret;
+}
+
+/*****************************************************************************
+* Prototype : nsfw_ver_mgr_rsq
+* Description : send version mgr message
+* Input : u16 rsp_code
+* Output : None
+* Return Value : u8
+* Calls :
+* Called By :
+*****************************************************************************/
+u8 nsfw_ver_mgr_rsq(u16 rsp_code, u32 src_pid)
+{
+ nsfw_mgr_msg *rsp_msg =
+ nsfw_mgr_msg_alloc(MGR_MSG_VER_MGR_RSP, NSFW_PROC_CTRL);
+ if (NULL == rsp_msg)
+ {
+ NSFW_LOGERR("alloc rsp msg failed]rsp_code=%u", rsp_code);
+ return FALSE;
+ }
+
+ rsp_msg->dst_pid = src_pid;
+ if (rsp_code != 0)
+ {
+ g_cur_upg_state = 0;
+ }
+
+ nsfw_ver_mgr_msg *ver_msg = GET_USER_MSG(nsfw_ver_mgr_msg, rsp_msg);
+ ver_msg->rsp_code = rsp_code;
+ (void) nsfw_mgr_send_msg(rsp_msg);
+ nsfw_mgr_msg_free(rsp_msg);
+ NSFW_LOGINF("send ver mgr rsp msg]state=%u", rsp_code);
+ return TRUE;
+}
+
+/*****************************************************************************
+* Prototype : nsfw_ver_mgr_req
+* Description : send ver mgr request message
+* Input : nsfw_ver_mgr_state state
+* char *src_ver
+* char* dst_ver
+* Output : None
+* Return Value : u8
+* Calls :
+* Called By :
+*****************************************************************************/
+u8 nsfw_ver_mgr_req(nsfw_ver_mgr_state state, char *src_ver, char *dst_ver)
+{
+ nsfw_mgr_msg *req_msg =
+ nsfw_mgr_msg_alloc(MGR_MSG_VER_MGR_REQ, NSFW_PROC_MAIN);
+ if (NULL == req_msg)
+ {
+ NSFW_LOGERR("alloc rsp msg failed]state=%d", state);
+ return FALSE;
+ }
+
+ nsfw_ver_mgr_msg *ver_msg = GET_USER_MSG(nsfw_ver_mgr_msg, req_msg);
+ ver_msg->ver_state = state;
+
+ /* we'd better use `strlen(src)` or `sizeof(dst)` to explain copying length of src string.
+ it's meaningless using `sizeof(dst) - 1` to reserve 1 byte for '\0'.
+ if copying length equals to or bigger than dst length, just let strncpy_s() returns failure. */
+ int retVal;
+ retVal = strcpy_s(ver_msg->src_ver, NSTACK_MAX_VERSION_LEN, src_ver); //remove needless 'count' param and change strncpy_s to strcpy_s
+ if (EOK != retVal)
+ {
+ NSFW_LOGERR("strncpy_s failed]ret=%d.", retVal);
+ nsfw_mgr_msg_free(req_msg);
+ return FALSE;
+ }
+
+ retVal = strcpy_s(ver_msg->dst_ver, NSTACK_MAX_VERSION_LEN, dst_ver); //remove needless 'count' param and change strncpy_s to strcpy_s
+ if (EOK != retVal)
+ {
+ NSFW_LOGERR("strncpy_s failed]ret=%d.", retVal);
+ nsfw_mgr_msg_free(req_msg);
+ return FALSE;
+ }
+
+ (void) nsfw_mgr_send_msg(req_msg);
+ nsfw_mgr_msg_free(req_msg);
+ NSFW_LOGINF("send srv ctrl end msg]state=%d", state);
+ return TRUE;
+}
+
+/*****************************************************************************
+* Prototype : nsfw_ver_mgr_msg_proc
+* Description : version info query message process
+* Input : nsfw_mgr_msg* msg
+* Output : None
+* Return Value : int
+* Calls :
+* Called By :
+*****************************************************************************/
+int nsfw_ver_mgr_msg_proc(nsfw_mgr_msg * msg)
+{
+ if (NULL == msg)
+ {
+ NSFW_LOGERR("msg nul");
+ return FALSE;
+ }
+
+ nsfw_ver_mgr_msg *ver_mgr_msg = GET_USER_MSG(nsfw_ver_mgr_msg, msg);
+ NSFW_LOGDBG("recv ver mgr msg]state=%d,src_ver=%s,dst_ver=%s",
+ ver_mgr_msg->ver_state, ver_mgr_msg->src_ver,
+ ver_mgr_msg->dst_ver);
+
+ if (NSFW_VER_QRY == ver_mgr_msg->ver_state)
+ {
+ nsfw_mgr_msg *rsp_msg = nsfw_mgr_rsp_msg_alloc(msg);
+ if (NULL == rsp_msg)
+ {
+ NSFW_LOGERR("alloc rsp failed,drop msg!" MSGINFO, PRTMSG(msg));
+ return FALSE;
+ }
+
+ nsfw_ver_mgr_msg *ver_rsp_msg =
+ GET_USER_MSG(nsfw_ver_mgr_msg, rsp_msg);
+
+ /* we'd better use `strlen(src)` or `sizeof(dst)` to explain copying length of src string.
+ it's meaningless using `sizeof(dst) - 1` to reserve 1 byte for '\0'.
+ if copying length equals to or bigger than dst length, just let strncpy_s() returns failure. */
+
+ /* change strncpy_s's param 'count' from XXX to XXX-1 */
+ int retVal;
+ retVal = strcpy_s(ver_rsp_msg->module_name, NSTACK_MAX_MODULE_LEN, g_ver_info.module_name); //remove needless 'count' param and change strncpy_s to strcpy_s
+ if (EOK != retVal)
+ {
+ NSFW_LOGERR("strncpy_s failed]ret=%d.", retVal);
+ nsfw_mgr_msg_free(rsp_msg);
+ return FALSE;
+ }
+
+ retVal = strcpy_s(ver_rsp_msg->src_ver, NSTACK_MAX_VERSION_LEN, g_ver_info.version); //remove needless 'count' param and change strncpy_s to strcpy_s
+ if (EOK != retVal)
+ {
+ NSFW_LOGERR("strncpy_s failed]ret=%d.", retVal);
+ nsfw_mgr_msg_free(rsp_msg);
+ return FALSE;
+ }
+
+ retVal = strcpy_s(ver_rsp_msg->build_time, NSTACK_MAX_BUILDTIME_LEN, g_ver_info.build_time); //remove needless 'count' param and change strncpy_s to strcpy_s
+ if (EOK != retVal)
+ {
+ NSFW_LOGERR("strncpy_s failed]ret=%d.", retVal);
+ nsfw_mgr_msg_free(rsp_msg);
+ return FALSE;
+ }
+
+ ver_rsp_msg->ver_state = ver_mgr_msg->ver_state;
+ (void) nsfw_mgr_send_msg(rsp_msg);
+ nsfw_mgr_msg_free(rsp_msg);
+ }
+
+ return TRUE;
+}
+
+/*****************************************************************************
+* Prototype : nsfw_ver_mgr_upg_msg_proc
+* Description : master upg
+* Input : nsfw_mgr_msg* msg
+* Output : None
+* Return Value : int
+* Calls :
+* Called By :
+*****************************************************************************/
+int nsfw_ver_mgr_upg_msg_proc(nsfw_mgr_msg * msg)
+{
+ if (NULL == msg)
+ {
+ NSFW_LOGERR("msg nul");
+ return FALSE;
+ }
+
+ nsfw_ver_mgr_msg *ver_mgr_msg = GET_USER_MSG(nsfw_ver_mgr_msg, msg); /*not redeclared */
+ NSFW_LOGDBG("recv ver mgr msg]state=%d,src_ver=%s,dst_ver=%s",
+ ver_mgr_msg->ver_state, ver_mgr_msg->src_ver,
+ ver_mgr_msg->dst_ver);
+
+ if ((NSFW_VER_UPG != ver_mgr_msg->ver_state)
+ && (NSFW_VER_RBK != ver_mgr_msg->ver_state))
+ {
+ return FALSE;
+ }
+
+ if (TRUE == nsfw_ver_mgr_rsq(0, msg->src_pid))
+ {
+ int i = 0;
+ while (i < NSFW_VER_UPG_KILL_TIME)
+ {
+ NSFW_LOGINF("wait nStackKill!]i=%d", i);
+ (void) sleep(1);
+ i++;
+ }
+
+ exit(0);
+ }
+ return TRUE;
+}
+
+u8 nsfw_init_result_send(u8 local_proc, nsfw_init_state state, u8 rsp_flag)
+{
+ nsfw_mgr_msg *req_msg =
+ nsfw_mgr_msg_alloc(MGR_MSG_INIT_NTY_REQ, NSFW_PROC_MASTER);
+ if (NULL == req_msg)
+ {
+ NSFW_LOGERR("alloc req msg failed]state=%d", state);
+ return FALSE;
+ }
+
+ nsfw_mgr_msg *rsp_msg = NULL;
+ if (TRUE == rsp_flag)
+ {
+ rsp_msg = nsfw_mgr_rsp_msg_alloc(req_msg);
+ if (NULL == rsp_msg)
+ {
+ NSFW_LOGERR("alloc rsp msg failed]state=%d", state);
+ nsfw_mgr_msg_free(req_msg);
+ return FALSE;
+ }
+ }
+
+ if (TRUE == req_msg->from_mem)
+ {
+ req_msg->src_proc_type = local_proc;
+ }
+
+ nsfw_init_nty_msg *init_msg = GET_USER_MSG(nsfw_init_nty_msg, req_msg);
+ init_msg->init_state = state;
+
+ u8 ret;
+ ret = nsfw_mgr_send_req_wait_rsp(req_msg, rsp_msg);
+ NSFW_LOGINF("send init end msg]state=%d,ret=%u,rsp=%u", state, ret,
+ rsp_flag);
+ nsfw_mgr_msg_free(req_msg);
+ if (NULL != rsp_msg)
+ {
+ nsfw_mgr_msg_free(rsp_msg);
+ }
+
+ return ret;
+}
+
+int nsfw_vermgr_module_init(void *param);
+int nsfw_vermgr_module_init(void *param)
+{
+ u8 proc_type = (u8) ((long long) param);
+ if (proc_type != NSFW_PROC_CTRL)
+ {
+ NSFW_LOGINF("verupg module init]type=%d", proc_type);
+ }
+ (void) nsfw_init_version_info(proc_type);
+ switch (proc_type)
+ {
+ case NSFW_PROC_MASTER:
+ (void) nsfw_mgr_reg_msg_fun(MGR_MSG_VER_MGR_REQ,
+ nsfw_ver_mgr_upg_msg_proc);
+ (void) nsfw_mgr_reg_msg_fun(MGR_MSG_VER_MGR_REQ,
+ nsfw_ver_mgr_msg_proc);
+ return 0;
+ case NSFW_PROC_MAIN:
+ case NSFW_PROC_CTRL:
+ (void) nsfw_mgr_reg_msg_fun(MGR_MSG_VER_MGR_REQ,
+ nsfw_ver_mgr_msg_proc);
+ return 0;
+ default:
+ if (proc_type < NSFW_PROC_MAX)
+ {
+ break;
+ }
+ return -1;
+ }
+
+ return 0;
+}
+
+/* *INDENT-OFF* */
+NSFW_MODULE_NAME(NSFW_VER_MGR_MODULE)
+NSFW_MODULE_PRIORITY(99)
+NSFW_MODULE_INIT(nsfw_vermgr_module_init)
+/* *INDENT-ON* */
diff --git a/src/framework/mem/basic_mem/dmm_fshm.c b/src/framework/mem/basic_mem/dmm_fshm.c
new file mode 100644
index 0000000..ab8665f
--- /dev/null
+++ b/src/framework/mem/basic_mem/dmm_fshm.c
@@ -0,0 +1,200 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <errno.h>
+
+#include "nstack_securec.h"
+#include "nstack_log.h"
+#include "nsfw_base_linux_api.h"
+
+#include "dmm_config.h"
+#include "dmm_share.h"
+#include "dmm_fs.h"
+
+#define DMM_FSHM_FMT "%s/dmm-fshm-%d" /* VAR_DIR pid */
+
+inline static void set_fshm_path(char path[DMM_SHARE_PATH_MAX], pid_t pid)
+{
+ (void) snprintf_s(path, DMM_SHARE_PATH_MAX, DMM_SHARE_PATH_MAX - 1,
+ DMM_FSHM_FMT, DMM_VAR_DIR, pid);
+
+ path[DMM_SHARE_PATH_MAX - 1] = 0;
+}
+
+/*
+input: share->path, share->size, share->pid
+output: share->base
+*/
+int dmm_fshm_create(struct dmm_share *share)
+{
+ int fd, ret;
+ void *base, *hint = (void *) DMM_MAIN_SHARE_BASE;
+
+ if (share->type != DMM_SHARE_FSHM)
+ {
+ NSFW_LOGERR("type error, type:%d", share->type);
+ return -1;
+ }
+
+ set_fshm_path(share->path, share->pid);
+
+ NSFW_LOGINF("Start create share memory, path:'%s' size:%lu",
+ share->path, share->size);
+
+ fd = open(share->path, O_RDWR | O_CREAT, 0666);
+ if (fd < 0)
+ {
+ NSFW_LOGERR("Open file failed, path:'%s', errno=%d",
+ share->path, errno);
+ return -1;
+ }
+
+ ret = ftruncate(fd, (off_t) share->size);
+ if (ret < 0)
+ {
+ NSFW_LOGERR("Set file size failed, path:'%s', errno=%d",
+ share->path, errno);
+ (void) nsfw_base_close(fd);
+ return -1;
+ }
+
+ base = mmap(hint, share->size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ if (base == MAP_FAILED)
+ {
+ NSFW_LOGERR("Map failed, path:'%s' size:%lu, errno=%d",
+ share->path, share->size, errno);
+ (void) nsfw_base_close(fd);
+ return -1;
+ }
+ else if (hint && hint != MAP_FAILED && base != hint)
+ {
+ NSFW_LOGERR
+ ("Map address failed, path:'%s' hint:%p size:%lu, base:%p",
+ share->path, hint, share->size, base);
+ (void) munmap(base, share->size);
+ (void) nsfw_base_close(fd);
+ return -1;
+ }
+
+ share->base = base;
+
+ NSFW_LOGINF("Share memory created, size:%lu, base=%p", share->size, base);
+
+ (void) nsfw_base_close(fd);
+ return 0;
+
+}
+
+int dmm_fshm_delete(struct dmm_share *share)
+{
+ (void) munmap(share->base, share->size);
+ (void) unlink(share->path);
+
+ return 0;
+}
+
+/*
+input: share->path, share->size, share->base(OPT)
+output: share->base(if-null)
+*/
+int dmm_fshm_attach(struct dmm_share *share)
+{
+ int fd;
+ void *base;
+
+ NSFW_LOGINF("Start attach, share:%p"
+ " {type:%d pid:%d base:%p size:%lu path:'%s'}",
+ share, share->type, share->pid,
+ share->base, share->size, share->path);
+
+ if (share->type != DMM_SHARE_FSHM)
+ {
+ NSFW_LOGERR("type error, type:%d", share->type);
+ return -1;
+ }
+
+ char *real_path = realpath(share->path, NULL);
+ if (NULL == real_path)
+ {
+ NSFW_LOGERR("Open file failed, path:'%s', errno=%d",
+ share->path, errno);
+ return -1;
+ }
+ fd = open(real_path, O_RDWR);
+ if (fd < 0)
+ {
+ NSFW_LOGERR("Open file failed, path:'%s', errno=%d",
+ share->path, errno);
+ (void) free(real_path);
+ return -1;
+ }
+
+ if (share->size <= 0)
+ {
+ share->size = dmm_file_size(fd);
+ if (share->size == 0)
+ {
+ NSFW_LOGERR("No file size '%s'", share->path);
+ (void) nsfw_base_close(fd);
+ (void) free(real_path);
+ return -1;
+ }
+ }
+
+ base = mmap(share->base, share->size, PROT_READ | PROT_WRITE,
+ MAP_SHARED, fd, 0);
+ if (base == MAP_FAILED)
+ {
+ NSFW_LOGERR("Map failed, path:'%s' base:%p size:%lu, errno=%d",
+ share->path, share->base, share->size, errno);
+ (void) nsfw_base_close(fd);
+ (void) free(real_path);
+ return -1;
+ }
+
+ if (NULL == share->base)
+ {
+ share->base = base;
+ }
+ else if (base != share->base)
+ {
+ NSFW_LOGERR("Map address error, path:'%s' share->base:%p, base:%p",
+ share->path, share->base, base);
+ (void) munmap(base, share->size);
+ (void) nsfw_base_close(fd);
+ (void) free(real_path);
+ return -1;
+ }
+
+ NSFW_LOGINF("Memory attached, base=%p", base);
+
+ (void) nsfw_base_close(fd);
+ (void) free(real_path);
+ return 0;
+}
+
+int dmm_fshm_detach(struct dmm_share *share)
+{
+ (void) munmap(share->base, share->size);
+
+ return 0;
+}
diff --git a/src/framework/mem/basic_mem/dmm_group.c b/src/framework/mem/basic_mem/dmm_group.c
new file mode 100644
index 0000000..8a2d318
--- /dev/null
+++ b/src/framework/mem/basic_mem/dmm_group.c
@@ -0,0 +1,212 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <limits.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+
+#include "nsfw_base_linux_api.h"
+#include "nstack_log.h"
+#include "dmm_config.h"
+#include "dmm_group.h"
+#include "dmm_pause.h"
+#include "nstack_securec.h"
+
+#define DMM_GROUP_ACTIVE 0x55D5551
+#define DMM_GROUP_GLOBAL "global"
+#define DMM_GROUP_ENV "DMM_GROUP"
+#define DMM_GROUP_FMT "%s/dmm-group-%s" /* VAR_DIR group-name */
+
+static struct flock group_lock = {
+ .l_type = F_WRLCK,
+ .l_whence = SEEK_SET,
+ .l_start = 0,
+ .l_len = sizeof(struct dmm_group),
+};
+
+static int group_fd = -1;
+struct dmm_group *main_group = NULL;
+
+inline static const char *get_group_path()
+{
+ static char group_path[PATH_MAX] = "";
+
+ if (!group_path[0])
+ {
+ const char *group = getenv(DMM_GROUP_ENV);
+
+ if (!group || !group[0])
+ group = DMM_GROUP_GLOBAL;
+
+ (void) snprintf_s(group_path, sizeof(group_path),
+ sizeof(group_path) - 1, DMM_GROUP_FMT,
+ DMM_VAR_DIR, group);
+ group_path[sizeof(group_path) - 1] = 0;
+ }
+
+ return group_path;
+}
+
+void dmm_group_active()
+{
+ main_group->group_init = DMM_GROUP_ACTIVE;
+ NSFW_LOGINF("main group actived");
+}
+
+int dmm_group_create_main()
+{
+ int ret;
+ const char *path = get_group_path();
+
+ NSFW_LOGINF("start create main group '%s'", path);
+
+ group_fd = open(path, O_RDWR | O_CREAT, 0600);
+ if (group_fd < 0)
+ {
+ NSFW_LOGERR("open file failed, path:'%s', errno=%d", path, errno);
+ return -1;
+ }
+
+ ret = ftruncate(group_fd, sizeof(struct dmm_group));
+ if (ret < 0)
+ {
+ NSFW_LOGERR("set size failed, path:'%s' size:%lu, errno=%d",
+ path, sizeof(struct dmm_group), errno);
+ (void) nsfw_base_close(group_fd);
+ group_fd = -1;
+ return -1;
+ }
+
+ ret = fcntl(group_fd, F_SETLK, &group_lock);
+ if (ret < 0)
+ {
+ NSFW_LOGERR("lock file failed, path:'%s', errno=%d", path, errno);
+ (void) nsfw_base_close(group_fd);
+ group_fd = -1;
+ return -1;
+ }
+
+ main_group = (struct dmm_group *) mmap(NULL, sizeof(struct dmm_group),
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED, group_fd, 0);
+
+ if (main_group == MAP_FAILED)
+ {
+ NSFW_LOGERR("mmap failed, path:'%s' size:%lu, errno:%d",
+ path, sizeof(struct dmm_group), errno);
+ (void) nsfw_base_close(group_fd);
+ group_fd = -1;
+ return -1;
+ }
+
+ NSFW_LOGINF("main group created, main_group:%p size:%lu",
+ main_group, sizeof(struct dmm_group));
+
+ return 0;
+}
+
+int dmm_group_delete_main()
+{
+ if (main_group)
+ {
+ (void) munmap(main_group, sizeof(struct dmm_group));
+ main_group = NULL;
+ }
+
+ if (group_fd >= 0)
+ {
+ (void) nsfw_base_close(group_fd);
+ group_fd = -1;
+ }
+
+ (void) unlink(get_group_path());
+
+ return 0;
+}
+
+int dmm_group_attach_main()
+{
+ const char *path = get_group_path();
+
+ NSFW_LOGINF("Start attach main group '%s'", path);
+
+ group_fd = open(path, O_RDONLY);
+ if (group_fd < 0)
+ {
+ //NSFW_LOGERR ("open group file failed, path:'%s', errno=%d",
+ //path, errno);
+ return -1;
+ }
+
+ main_group = (struct dmm_group *) mmap(NULL, sizeof(struct dmm_group),
+ PROT_READ, MAP_SHARED, group_fd,
+ 0);
+ if (main_group == MAP_FAILED)
+ {
+ NSFW_LOGERR("mmap failed, path:'%s', errno=%d", path, errno);
+ (void) nsfw_base_close(group_fd);
+ group_fd = -1;
+ return -1;
+ }
+
+ while (main_group->group_init != DMM_GROUP_ACTIVE)
+ {
+ dmm_pause();
+ }
+
+ if (kill(main_group->share.pid, 0))
+ {
+ NSFW_LOGERR
+ ("main group process not exist, path:'%s' pid:%d errno=%d", path,
+ main_group->share.pid, errno);
+ (void) munmap(main_group->share.base, main_group->share.size);
+ (void) nsfw_base_close(group_fd);
+ (void) unlink(path);
+ group_fd = -1;
+ return -1;
+ }
+
+ NSFW_LOGINF("main group attached, main_group=%p"
+ " {type=%d pid=%d base=%p size=%zd path='%s'}",
+ main_group, main_group->share.type, main_group->share.pid,
+ main_group->share.base, main_group->share.size,
+ main_group->share.path);
+
+ return 0;
+}
+
+int dmm_group_detach_main()
+{
+ if (main_group)
+ {
+ (void) munmap(main_group, sizeof(struct dmm_group));
+ main_group = NULL;
+ }
+
+ if (group_fd >= 0)
+ {
+ (void) nsfw_base_close(group_fd);
+ group_fd = -1;
+ }
+
+ return 0;
+}
diff --git a/src/framework/mem/dmm_group.h b/src/framework/mem/basic_mem/dmm_group.h
index b11a22b..a07c8d6 100644
--- a/src/framework/mem/dmm_group.h
+++ b/src/framework/mem/basic_mem/dmm_group.h
@@ -21,16 +21,16 @@
struct dmm_group
{
- volatile int group_init;
- struct dmm_share share;
+ volatile int group_init;
+ struct dmm_share share;
};
extern struct dmm_group *main_group;
-void dmm_group_active ();
-int dmm_group_create_main ();
-int dmm_group_delete_main ();
-int dmm_group_attach_main ();
-int dmm_group_detach_main ();
+void dmm_group_active();
+int dmm_group_create_main();
+int dmm_group_delete_main();
+int dmm_group_attach_main();
+int dmm_group_detach_main();
#endif /* _DMM_GROUP_H_ */
diff --git a/src/framework/mem/basic_mem/dmm_heap.c b/src/framework/mem/basic_mem/dmm_heap.c
new file mode 100644
index 0000000..0efd0b4
--- /dev/null
+++ b/src/framework/mem/basic_mem/dmm_heap.c
@@ -0,0 +1,82 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#include <stdlib.h>
+#include <sys/types.h>
+
+#include "dmm_config.h"
+#include "dmm_share.h"
+
+struct heap_path
+{
+ void *base;
+ size_t size;
+};
+
+int dmm_heap_create(struct dmm_share *share)
+{
+ share->base = malloc(share->size);
+
+ if (share->base)
+ {
+ struct heap_path *hp = (struct heap_path *) share->path;
+ hp->base = share->base;
+ hp->size = share->size;
+ return 0;
+ }
+
+ return -1;
+}
+
+int dmm_heap_delete(struct dmm_share *share)
+{
+ void *point = share->base;
+ share->base = NULL;
+ free(point);
+ return 0;
+}
+
+int dmm_heap_attach(struct dmm_share *share)
+{
+ struct heap_path *hp = (struct heap_path *) share->path;
+
+ if (share->base)
+ {
+ if (hp->base != share->base)
+ return -1;
+ }
+ else
+ {
+ share->base = hp->base;
+ }
+
+ if (share->size)
+ {
+ if (share->size != hp->size)
+ return -1;
+ }
+ else
+ {
+ share->size = hp->size;
+ }
+
+ return 0;
+}
+
+int dmm_heap_detach(struct dmm_share *share)
+{
+ return 0;
+}
diff --git a/src/framework/mem/basic_mem/dmm_huge.c b/src/framework/mem/basic_mem/dmm_huge.c
new file mode 100644
index 0000000..6267b6c
--- /dev/null
+++ b/src/framework/mem/basic_mem/dmm_huge.c
@@ -0,0 +1,192 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <errno.h>
+
+#include "nstack_securec.h"
+#include "nstack_log.h"
+#include "nsfw_base_linux_api.h"
+
+#include "dmm_config.h"
+#include "dmm_share.h"
+#include "dmm_fs.h"
+
+#define DMM_HUGE_FMT "%s/dmm-%d-%d" /* HUGE_DIR/dmm-pid-index */
+
+inline static void
+huge_set_path(char path[DMM_SHARE_PATH_MAX], pid_t pid, int index)
+{
+ (void) snprintf_s(path, DMM_SHARE_PATH_MAX, DMM_SHARE_PATH_MAX - 1,
+ DMM_HUGE_FMT, DMM_HUGE_DIR, pid, index);
+ path[DMM_SHARE_PATH_MAX - 1] = 0;
+}
+
+int dmm_huge_create(struct dmm_share *share)
+{
+ int fd, ret;
+ void *base, *hint = (void *) DMM_MAIN_SHARE_BASE;
+
+ if (share->type != DMM_SHARE_HUGE)
+ {
+ NSFW_LOGERR("Type error, type:%d", share->type);
+ return -1;
+ }
+
+ huge_set_path(share->path, share->pid, 0);
+
+ NSFW_LOGINF("Start create share memory, path:'%s' size:%lu",
+ share->path, share->size);
+
+ fd = open(share->path, O_RDWR | O_CREAT, 0666);
+ if (fd < 0)
+ {
+ NSFW_LOGERR("Open file failed, path:'%s', errno=%d",
+ share->path, errno);
+ return -1;
+ }
+
+ ret = ftruncate(fd, (off_t) share->size);
+ if (ret < 0)
+ {
+ NSFW_LOGERR("Set file size failed, path:'%s', errno=%d",
+ share->path, errno);
+ (void) nsfw_base_close(fd);
+ return -1;
+ }
+
+ base = mmap(hint, share->size, PROT_READ | PROT_WRITE,
+ MAP_HUGETLB | MAP_SHARED | MAP_POPULATE, fd, 0);
+ if (base == MAP_FAILED)
+ {
+ NSFW_LOGERR("Map failed, path:'%s' size:%lu, errno=%d",
+ share->path, share->size, errno);
+ (void) nsfw_base_close(fd);
+ return -1;
+ }
+ else if (hint && hint != MAP_FAILED && hint != base)
+ {
+ NSFW_LOGERR
+ ("Map address failed, path:'%s' hint:%p size:%lu, base:%p",
+ share->path, hint, share->size, base);
+ (void) munmap(base, share->size);
+ (void) nsfw_base_close(fd);
+ return -1;
+ }
+
+ share->base = base;
+
+ NSFW_LOGINF("Share memory created, size:%lu, base=%p", share->size, base);
+
+ (void) nsfw_base_close(fd);
+ return 0;
+}
+
+int dmm_huge_delete(struct dmm_share *share)
+{
+ (void) munmap(share->base, share->size);
+ (void) unlink(share->path);
+
+ return 0;
+}
+
+int dmm_huge_attach(struct dmm_share *share)
+{
+ int fd;
+ void *base;
+
+ NSFW_LOGINF("Start attach, share:%p"
+ " {type:%d pid:%d base:%p size:%lu path:'%s'}",
+ share, share->type, share->pid,
+ share->base, share->size, share->path);
+
+ if (share->type != DMM_SHARE_HUGE)
+ {
+ NSFW_LOGERR("Type error, type:%d", share->type);
+ return -1;
+ }
+
+ char *real_path = realpath(share->path, NULL);
+ if (NULL == real_path)
+ {
+ NSFW_LOGERR("Open file failed, path:'%s', errno=%d",
+ share->path, errno);
+ return -1;
+ }
+ fd = open(real_path, O_RDWR);
+ if (fd < 0)
+ {
+ NSFW_LOGERR("Open file failed, path:'%s', errno=%d",
+ share->path, errno);
+ (void) free(real_path);
+ return -1;
+ }
+
+ if (share->size <= 0)
+ {
+ share->size = dmm_file_size(fd);
+ if (share->size == 0)
+ {
+ NSFW_LOGERR("No file size '%s'", share->path);
+ (void) nsfw_base_close(fd);
+ (void) free(real_path);
+ return -1;
+ }
+ }
+
+ base = mmap(share->base, share->size, PROT_READ | PROT_WRITE,
+ MAP_SHARED, fd, 0);
+ if (base == MAP_FAILED)
+ {
+ NSFW_LOGERR("mmap failed, path:'%s' base:%p size:%lu, errno=%d",
+ share->path, share->base, share->size, errno);
+ (void) nsfw_base_close(fd);
+ (void) free(real_path);
+ return -1;
+ }
+
+ if (NULL == share->base)
+ {
+ share->base = base;
+ }
+ else if (base != share->base)
+ {
+ NSFW_LOGERR("mmap address error, path:'%s' share->base:%p, base:%p",
+ share->path, share->base, base);
+ (void) munmap(base, share->size);
+ (void) nsfw_base_close(fd);
+ (void) free(real_path);
+ return -1;
+ }
+
+ NSFW_LOGINF("Memory attached, base=%p", base);
+
+ (void) nsfw_base_close(fd);
+ (void) free(real_path);
+ return 0;
+}
+
+int dmm_huge_detach(struct dmm_share *share)
+{
+ (void) munmap(share->base, share->size);
+
+ return 0;
+}
diff --git a/src/framework/mem/basic_mem/dmm_memory.c b/src/framework/mem/basic_mem/dmm_memory.c
new file mode 100644
index 0000000..affa0f6
--- /dev/null
+++ b/src/framework/mem/basic_mem/dmm_memory.c
@@ -0,0 +1,284 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+#include "types.h"
+#include "dmm_config.h"
+#include "dmm_memory.h"
+#include "dmm_group.h"
+
+#include "nsfw_init_api.h"
+#include "nsfw_mgr_com_api.h"
+#include "nstack_log.h"
+#include "nsfw_mem_api.h"
+
+#define DMM_MEGABYTE (1024 * 1024)
+
+/* shared from main process */
+static struct dmm_share *main_share = NULL;
+struct dmm_segment *main_seg = NULL;
+
+/* shared by process tree */
+static struct dmm_share base_share = { 0 };
+
+struct dmm_segment *base_seg = NULL;
+
+int dmm_mem_main_init()
+{
+ int ret;
+
+ ret = dmm_group_create_main();
+ if (ret)
+ {
+ return -1;
+ }
+
+ main_share = &main_group->share;
+ main_share->type = DMM_MAIN_SHARE_TYPE;
+ main_share->size = DMM_MAIN_SHARE_SIZE;
+ main_share->size *= DMM_MEGABYTE;
+ main_share->base = NULL;
+ main_share->pid = getpid();
+ ret = dmm_share_create(main_share);
+ if (ret)
+ {
+ return -1;
+ }
+
+ main_seg = dmm_seg_create(main_share->base, main_share->size);
+ if (!main_seg)
+ {
+ return -1;
+ }
+
+ base_seg = main_seg;
+
+ dmm_group_active();
+
+ return 0;
+}
+
+int dmm_mem_main_exit()
+{
+ dmm_group_delete_main();
+ return 0;
+}
+
+int dmm_mem_app_init()
+{
+ int ret;
+
+ ret = dmm_group_attach_main();
+ if (0 == ret)
+ {
+ main_share = &main_group->share;
+ ret = dmm_share_attach(main_share);
+ if (ret)
+ {
+ NSFW_LOGERR
+ ("share attach failed, type:%d pid:%d base:%p size:%lu path:%s",
+ main_share->type, main_share->pid, main_share->base,
+ main_share->size, main_share->path);
+ return -1;
+ }
+
+ main_seg = dmm_seg_attach(main_share->base, main_share->size);
+ if (!main_seg)
+ {
+ NSFW_LOGERR("segment attach failed, base:%p size:%lu",
+ main_share->base, main_share->size);
+ return -1;
+ }
+
+ /* now share main process share-memory */
+ base_seg = main_seg;
+ }
+ else
+ {
+ base_share.type = DMM_SHARE_TYPE;
+ base_share.size = 128 * DMM_MEGABYTE;
+ base_share.base = NULL;
+ base_share.pid = getpid();
+ ret = dmm_share_create(&base_share);
+ if (ret)
+ {
+ return -1;
+ }
+
+ base_seg = dmm_seg_create(base_share.base, base_share.size);
+ if (!base_seg)
+ {
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+void dmm_share_destroy()
+{
+ (void) dmm_share_delete(&base_share);
+ return;
+}
+
+int dmm_mem_app_exit()
+{
+ dmm_group_detach_main();
+
+ if (base_share.base)
+ dmm_share_delete(&base_share);
+
+ base_share.base = NULL;
+ base_seg = NULL;
+ main_seg = NULL;
+
+ return 0;
+}
+
+struct dmm_ring *dmm_create_ring(int num, int flag,
+ const char name[DMM_MEM_NAME_SIZE])
+{
+ struct dmm_ring *ring;
+ const size_t bufsize = dmm_ring_bufsize(num);
+
+ dmm_lock_map();
+
+ ring = dmm_map(bufsize, name);
+
+ if (ring)
+ {
+ if (0 != dmm_ring_init(ring, num, 0, flag, NSFW_SHMEM))
+ {
+ (void) dmm_unmap(ring);
+ ring = NULL;
+ }
+ }
+
+ dmm_unlock_map();
+
+ return ring;
+}
+
+struct dmm_ring *dmm_attach_ring(const char name[DMM_MEM_NAME_SIZE])
+{
+ return (struct dmm_ring *) dmm_lookup(name);
+}
+
+struct dmm_ring *dmm_malloc_ring(int num, int flag)
+{
+ const size_t size = dmm_ring_bufsize(num);
+ if (0 == size)
+ {
+ return NULL;
+ }
+ struct dmm_ring *ring = malloc(size);
+
+ if (!ring)
+ return NULL;
+
+ if (0 != dmm_ring_init(ring, num, 0, flag, NSFW_NSHMEM))
+ {
+ free(ring);
+ return NULL;
+ }
+
+ return ring;
+}
+
+struct dmm_ring *dmm_create_pool(size_t elt_size, int num, int flag,
+ const char name[DMM_MEM_NAME_SIZE])
+{
+ struct dmm_ring *pool;
+ const size_t pool_size = dmm_pool_bufsize(num, elt_size);
+
+ dmm_lock_map();
+
+ pool = dmm_map(pool_size, name);
+
+ if (pool)
+ {
+ if (0 != dmm_pool_init(pool, elt_size, num, flag, NSFW_SHMEM))
+ {
+ (void) dmm_unmap(pool);
+ pool = NULL;
+ }
+ }
+
+ dmm_unlock_map();
+
+ return pool;
+}
+
+struct dmm_ring *dmm_attach_pool(const char name[DMM_MEM_NAME_SIZE])
+{
+ return (struct dmm_ring *) dmm_lookup(name);
+}
+
+struct dmm_ring *dmm_malloc_pool(size_t elt_size, int num, int flag)
+{
+ const size_t size = dmm_pool_bufsize(num, elt_size);
+
+ if (0 == size)
+ {
+ return NULL;
+ }
+ struct dmm_ring *pool = malloc(size);
+
+ if (!pool)
+ {
+ return NULL;
+ }
+
+ if (0 != dmm_pool_init(pool, elt_size, num, flag, NSFW_NSHMEM))
+ {
+ free(pool);
+ return NULL;
+ }
+
+ return pool;
+}
+
+int dmm_mem_module_init(void *param)
+{
+ int ret;
+ const u32 proc_type = (u32) ((long) param);
+
+ NSFW_LOGINF("dmm mem module init]type=%u", proc_type);
+
+ switch (proc_type)
+ {
+ case NSFW_PROC_MAIN:
+ ret = dmm_mem_main_init();
+ break;
+ case NSFW_PROC_NULL:
+ ret = 0;
+ break;
+ default:
+ ret = dmm_mem_app_init();
+ break;
+ }
+
+ return ret;
+}
+
+/* *INDENT-OFF* */
+//NSFW_MODULE_NAME (DMM_MEMORY_MODULE)
+//NSFW_MODULE_PRIORITY (10)
+//NSFW_MODULE_INIT (dmm_mem_module_init)
+/* *INDENT-ON* */
diff --git a/src/framework/mem/basic_mem/dmm_memory.h b/src/framework/mem/basic_mem/dmm_memory.h
new file mode 100644
index 0000000..6fc6a24
--- /dev/null
+++ b/src/framework/mem/basic_mem/dmm_memory.h
@@ -0,0 +1,126 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#ifndef _DMM_MEMORY_H_
+#define _DMM_MEMORY_H_
+#include <stdio.h>
+#include <stdarg.h>
+#include "dmm_share.h"
+#include "dmm_segment.h"
+#include "dmm_ring.h"
+#include "nstack_securec.h"
+
+#define DMM_MEMORY_MODULE "DMM_MEMORY_MODULE"
+
+extern struct dmm_segment *main_seg;
+extern struct dmm_segment *base_seg;
+
+inline static void dmm_lock_map()
+{
+ dmm_seg_lock(base_seg);
+}
+
+inline static void dmm_unlock_map()
+{
+ dmm_seg_unlock(base_seg);
+}
+
+inline static int dmm_unmap(void *mem)
+{
+ return dmm_mem_unmap(base_seg, mem);
+}
+
+inline static void *dmm_locked_map(size_t size,
+ const char name[DMM_MEM_NAME_SIZE])
+{
+ void *mem;
+ dmm_lock_map();
+ mem = dmm_mem_map(base_seg, size, name);
+ dmm_unlock_map();
+ return mem;
+}
+
+inline static void *dmm_map(size_t size, const char name[DMM_MEM_NAME_SIZE])
+{
+ return dmm_mem_map(base_seg, size, name);
+}
+
+inline static void *dmm_mapv(size_t size, const char *name_fmt, ...)
+{
+ int len;
+ char name[DMM_MEM_NAME_SIZE];
+ va_list ap;
+
+ va_start(ap, name_fmt);
+ len =
+ vsnprintf_s(name, DMM_MEM_NAME_SIZE, DMM_MEM_NAME_SIZE - 1, name_fmt,
+ ap);
+ va_end(ap);
+
+ if (len >= DMM_MEM_NAME_SIZE)
+ return NULL;
+
+ return dmm_map(size, name);
+}
+
+inline static void *dmm_lookup(const char name[DMM_MEM_NAME_SIZE])
+{
+ return dmm_mem_lookup(base_seg, name);
+}
+
+inline static void *dmm_lookupv(const char *name_fmt, ...)
+{
+ int len;
+ char name[DMM_MEM_NAME_SIZE];
+ va_list ap;
+
+ va_start(ap, name_fmt);
+ len =
+ vsnprintf_s(name, DMM_MEM_NAME_SIZE, DMM_MEM_NAME_SIZE - 1, name_fmt,
+ ap);
+ va_end(ap);
+
+ if (len >= DMM_MEM_NAME_SIZE)
+ return NULL;
+
+ return dmm_mem_lookup(base_seg, name);
+}
+
+int dmm_mem_main_init();
+int dmm_mem_main_exit();
+int dmm_mem_app_init();
+int dmm_mem_app_exit();
+
+struct dmm_ring *dmm_create_ring(int num, int flag,
+ const char name[DMM_MEM_NAME_SIZE]);
+
+struct dmm_ring *dmm_attach_ring(const char name[DMM_MEM_NAME_SIZE]);
+
+struct dmm_ring *dmm_malloc_ring(int num, int flag);
+
+struct dmm_ring *dmm_create_pool(size_t elt_size, int num, int flag,
+ const char name[DMM_MEM_NAME_SIZE]);
+
+struct dmm_ring *dmm_attach_pool(const char name[DMM_MEM_NAME_SIZE]);
+
+/* allocate pool from heap */
+struct dmm_ring *dmm_malloc_pool(size_t elt_size, int num, int flag);
+
+int dmm_mem_module_init(void *param);
+
+void dmm_share_destroy();
+
+#endif /* _DMM_MEMORY_H_ */
diff --git a/src/framework/mem/basic_mem/dmm_segment.c b/src/framework/mem/basic_mem/dmm_segment.c
new file mode 100644
index 0000000..3b92a55
--- /dev/null
+++ b/src/framework/mem/basic_mem/dmm_segment.c
@@ -0,0 +1,536 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#include <stdio.h>
+#include <string.h>
+#include <limits.h>
+#include "dmm_common.h"
+#include "dmm_rwlock.h"
+#include "dmm_segment.h"
+#include "nstack_log.h"
+#include "nstack_securec.h"
+
+#define BLOCK_SIZE 64 /* cache line size */
+#define BLOCK_MASK (BLOCK_SIZE - 1)
+
+#define FIRST_NAME "FIRST SECTION FOR SEGMENT"
+#define LAST_NAME "LAST SECTION FOR FREE HEAD"
+
+#define MEM_ERR(fmt, ...) \
+ NS_LOGPID(LOGFW, "DMM-MEM", NSLOG_ERR, fmt, ##__VA_ARGS__)
+
+typedef struct
+{
+ char _dummy_block_size[BLOCK_SIZE];
+} _dmm_packed __BLOCK;
+
+/*
+init create:
+ \--total number
+ /--head no align \ can be used \--tail no align
+ / ___________________/\___________________ \
+/\/ \/\
+__<F>{S}[ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]<L>__
+^ \ /\ /\____________ ________________/\ /
+| | | \ / |
+| | +--the segment | +--last section(free:0 used:0)
+| +--first section(prev_rel:0 used:2 free:11 req_size:sizeof(dmm_segment))
++--base address
+
+init: <F>{S}[ ]<L>
+alloc A: <F>{S}[ ]<A>#########<L>
+alloc B: <F>{S}[ ]<B>#########<A>#########<L>
+free A: <F>{S}[ ]<B>#########[ ]<L>
+alloc C: <F>{S}[ ]<C>###<B>#########[ ]<L>
+*/
+
+typedef struct dmm_section
+{
+ int prev_rel;
+ int used_num;
+ int free_num;
+ int flags; /* reserved */
+ size_t req_size; /* in bytes */
+ int less_rel; /* for free list */
+ int more_rel; /* for free list */
+ char name[DMM_MEM_NAME_SIZE];
+} _dmm_cache_aligned section_t;
+
+/* dmm_section struct hold blocks number */
+#define SECTION_HOLD ((sizeof(struct dmm_section) + (BLOCK_SIZE - 1)) / BLOCK_SIZE)
+
+struct dmm_segment
+{
+ void *base; /* base address(maybe not align) */
+ size_t size; /* full size */
+ section_t *first; /* aligned 64 */
+ section_t *last; /* last section used to handle free list */
+ dmm_rwlock_t lock;
+ int total_num; /* MAX:2147483647 ==> MAX size: 128M-64 */
+ int used_num;
+ int sec_num;
+ size_t used_size; /* real alloc size bytes */
+};
+
+/* calculate segment number, auto align 64, include 1 section_t */
+inline static int CALC_NUM(size_t size)
+{
+ if (size)
+ {
+ return SECTION_HOLD + (size + BLOCK_MASK) / BLOCK_SIZE;
+ }
+
+ return SECTION_HOLD + 1; /* if size is 0, then alloc 1 block */
+}
+
+inline static int SEC_REL(const section_t * base, const section_t * sec)
+{
+ return (__BLOCK *) sec - (__BLOCK *) base;
+}
+
+section_t *REL_SEC(section_t * base, int rel)
+{
+ return (section_t *) ((__BLOCK *) base + rel);
+}
+
+inline static int SEC_INDEX(struct dmm_segment *seg, section_t * sec)
+{
+ return SEC_REL(seg->first, sec);
+}
+
+inline static section_t *LESS_SEC(section_t * sec)
+{
+ return REL_SEC(sec, sec->less_rel);
+}
+
+inline static section_t *MORE_SEC(section_t * sec)
+{
+ return REL_SEC(sec, sec->more_rel);
+}
+
+inline static section_t *PREV_SEC(section_t * sec)
+{
+ return REL_SEC(sec, sec->prev_rel);
+}
+
+inline static section_t *NEXT_SEC(section_t * sec)
+{
+ return REL_SEC(sec, sec->free_num + sec->used_num);
+}
+
+inline static int CHECK_ADDR(struct dmm_segment *seg, void *mem)
+{
+ if (mem < (void *) seg->first)
+ return -1;
+ if (mem > (void *) seg->last)
+ return -1;
+ if ((long) mem & BLOCK_MASK)
+ return -1;
+
+ return 0;
+}
+
+inline static section_t *mem_lookup(struct dmm_segment *seg,
+ const char name[DMM_MEM_NAME_SIZE])
+{
+ section_t *sec;
+
+ /* caller ensures the validity of the name */
+
+ for (sec = seg->last; sec != seg->first; sec = PREV_SEC(sec))
+ {
+ if (sec->name[0] == 0)
+ continue;
+ if (0 == strcmp(sec->name, name))
+ return sec;
+ }
+
+ return NULL;
+}
+
+static section_t *mem_alloc(struct dmm_segment *seg, size_t size)
+{
+ const int num = CALC_NUM(size);
+ section_t *sec, *pos, *next, *less, *more;
+
+ if (num > seg->total_num - seg->used_num)
+ {
+ /* no enough memory */
+ return NULL;
+ }
+
+ /* find enough free space */
+ pos = seg->last;
+ do
+ {
+ pos = MORE_SEC(pos);
+ if (pos == seg->last)
+ {
+ /* no enough memory */
+ return NULL;
+ }
+ }
+ while (num > pos->free_num);
+
+ /* allocate from pos section's tail */
+
+ /* change next section's prev possion */
+ next = NEXT_SEC(pos);
+ next->prev_rel = -num;
+
+ /* create new section */
+ sec = PREV_SEC(next);
+ sec->prev_rel = SEC_REL(sec, pos);
+ sec->used_num = num;
+ sec->req_size = size;
+ sec->free_num = 0; /* no free space */
+ sec->less_rel = 0;
+ sec->more_rel = 0;
+ sec->name[0] = 0;
+
+ /* adjust pos section */
+ pos->free_num -= num;
+
+ less = LESS_SEC(pos);
+ more = MORE_SEC(pos);
+
+ /* remove from free list */
+ less->more_rel = SEC_REL(less, more);
+ more->less_rel = SEC_REL(more, less);
+ pos->more_rel = 0;
+ pos->less_rel = 0;
+
+ /* find position */
+ while (less != seg->last)
+ {
+ if (pos->free_num >= less->free_num)
+ break;
+ less = LESS_SEC(less);
+ }
+
+ /* insert into free list */
+ more = MORE_SEC(less);
+ less->more_rel = SEC_REL(less, pos);
+ more->less_rel = SEC_REL(more, pos);
+ pos->more_rel = SEC_REL(pos, more);
+ pos->less_rel = SEC_REL(pos, less);
+
+ /* adjust segment */
+ seg->used_size += size;
+ seg->used_num += num;
+ seg->sec_num++;
+
+ /* victory */
+ return sec;
+}
+
+static void mem_free(struct dmm_segment *seg, section_t * sec)
+{
+ const int num = sec->used_num + sec->free_num;
+ section_t *next = NEXT_SEC(sec);
+ section_t *prev = PREV_SEC(sec);
+ section_t *more, *less;
+
+ /* adjust next section's prev */
+ next->prev_rel = SEC_REL(next, prev);
+
+ if (sec->free_num)
+ {
+ /* remove from free list */
+ more = MORE_SEC(sec);
+ less = LESS_SEC(sec);
+ more->less_rel = SEC_REL(more, less);
+ less->more_rel = SEC_REL(less, more);
+ }
+
+ if (prev->free_num)
+ {
+ /* remove from free list */
+ more = MORE_SEC(prev);
+ less = LESS_SEC(prev);
+ more->less_rel = SEC_REL(more, less);
+ less->more_rel = SEC_REL(less, more);
+ }
+ else
+ {
+ more = MORE_SEC(seg->last);
+ }
+
+ /* put the space to prev's free space */
+ prev->free_num += num;
+
+ while (more != seg->last)
+ {
+ if (prev->free_num <= more->free_num)
+ break;
+ more = MORE_SEC(more);
+ }
+ less = LESS_SEC(more);
+
+ /* insert */
+ less->more_rel = SEC_REL(less, prev);
+ more->less_rel = SEC_REL(more, prev);
+ prev->more_rel = SEC_REL(prev, more);
+ prev->less_rel = SEC_REL(prev, less);
+
+ /* adjust segment */
+ seg->used_size -= sec->req_size;
+ seg->used_num -= sec->used_num;
+ seg->sec_num--;
+}
+
+void dmm_seg_lock(struct dmm_segment *seg)
+{
+ dmm_write_lock(&seg->lock);
+}
+
+void dmm_seg_unlock(struct dmm_segment *seg)
+{
+ dmm_write_unlock(&seg->lock);
+}
+
+void dmm_seg_dump(struct dmm_segment *seg)
+{
+ section_t *sec;
+
+ dmm_read_lock(&seg->lock);
+
+ NSFW_LOGINF
+ ("---- segment:%p base:%p size:%lu ---- BS:%u SS:%lu SH:%lu ----\n"
+ " first[%d]:%p last[%d]:%p total_num:%d used_num:%d\n"
+ " sec_num:%d used_size:%lu use%%:%lu%% free%%:%lu%%\n", seg,
+ seg->base, seg->size, BLOCK_SIZE, sizeof(struct dmm_section),
+ SECTION_HOLD, SEC_INDEX(seg, seg->first), seg->first,
+ SEC_INDEX(seg, seg->last), seg->last, seg->total_num, seg->used_num,
+ seg->sec_num, seg->used_size, seg->used_size * 100 / seg->size,
+ (seg->total_num - seg->used_num) * (BLOCK_SIZE * 100) / seg->size);
+
+ NSFW_LOGINF("----------------------------------------\n"
+ "%18s %9s %9s %9s %9s %10s %9s %9s %s\n",
+ "PHYSICAL-ORDER", "section", "prev_rel", "used_num",
+ "free_num", "req_size", "less_rel", "more_rel", "name");
+
+ sec = seg->first;
+ while (1)
+ {
+ NSFW_LOGINF("%18p %9d %9d %9d %9d %10lu %9d %9d '%s'\n",
+ sec, SEC_INDEX(seg, sec),
+ sec->prev_rel, sec->used_num, sec->free_num,
+ sec->req_size, sec->less_rel, sec->more_rel, sec->name);
+ if (sec == seg->last)
+ break;
+ sec = NEXT_SEC(sec);
+ }
+
+ NSFW_LOGINF("----------------------------------------\n"
+ "%18s %9s %9s\n", "FREE-ORDER", "section", "free_num");
+ for (sec = MORE_SEC(seg->last); sec != seg->last; sec = MORE_SEC(sec))
+ {
+ NSFW_LOGINF("%18p %9d %9d\n",
+ sec, SEC_INDEX(seg, sec), sec->free_num);
+ }
+
+ NSFW_LOGINF("----------------------------------------\n");
+
+ dmm_read_unlock(&seg->lock);
+
+}
+
+inline static int align_section(void *base, size_t size, section_t ** first)
+{
+ const int SEG_NUM = CALC_NUM(sizeof(struct dmm_segment));
+
+ const long align = (long) base;
+ const long addr = (align + BLOCK_MASK) & (~BLOCK_MASK);
+ const size_t total = (size - (addr - align)) / BLOCK_SIZE;
+
+ if (total > INT_MAX)
+ return -1;
+ if (total < SEG_NUM + SECTION_HOLD) /* first+segment + last */
+ return -1;
+
+ *first = (section_t *) addr;
+ return (int) total;
+}
+
+struct dmm_segment *dmm_seg_create(void *base, size_t size)
+{
+ section_t *first, *last;
+ struct dmm_segment *seg;
+ const int total = align_section(base, size, &first);
+ const int SEG_NUM = CALC_NUM(sizeof(struct dmm_segment));
+
+ if (total <= 0)
+ return NULL;
+
+ last = first + (total - SECTION_HOLD);
+
+ /* first section */
+ first->prev_rel = 0;
+ first->used_num = SEG_NUM;
+ first->req_size = sizeof(struct dmm_segment);
+ first->free_num = total - (SEG_NUM + SECTION_HOLD);
+ first->less_rel = SEC_REL(first, last);
+ first->more_rel = SEC_REL(first, last);
+ first->name[0] = 0;
+ (void) strncpy_s(&first->name[1], DMM_MEM_NAME_SIZE, FIRST_NAME,
+ sizeof(first->name) - 1);
+
+ /* last section */
+ last->prev_rel = SEC_REL(last, first);
+ last->used_num = 0;
+ last->req_size = 0;
+ last->free_num = 0;
+ last->less_rel = SEC_REL(last, first);
+ last->more_rel = SEC_REL(last, first);
+ last->name[0] = 0;
+ (void) strncpy_s(&last->name[1], DMM_MEM_NAME_SIZE, LAST_NAME,
+ sizeof(first->name) - 1);
+
+ /* segment */
+ seg = (struct dmm_segment *) (first + 1);
+ dmm_rwlock_init(&seg->lock);
+ seg->base = base;
+ seg->size = size;
+ seg->first = first;
+ seg->last = last;
+ seg->total_num = total;
+ seg->sec_num = 2; /* first and tail */
+ seg->used_size = sizeof(struct dmm_segment);
+ seg->used_num = first->used_num + SECTION_HOLD;
+
+ return seg;
+}
+
+struct dmm_segment *dmm_seg_attach(void *base, size_t size)
+{
+ section_t *first, *last;
+ struct dmm_segment *seg;
+ const int total = align_section(base, size, &first);
+
+ if (total <= 0)
+ return NULL;
+
+ last = first + (total - SECTION_HOLD);
+ seg = (struct dmm_segment *) (first + 1);
+
+ if (seg->base != base)
+ return NULL;
+ if (seg->size != size)
+ return NULL;
+ if (seg->total_num != total)
+ return NULL;
+
+ if (seg->first != first)
+ return NULL;
+ if (first->name[0] != 0)
+ return NULL;
+ if (strncmp(&first->name[1], FIRST_NAME, sizeof(first->name) - 1))
+ return NULL;
+
+ if (seg->last != last)
+ return NULL;
+ if (last->name[0] != 0)
+ return NULL;
+ if (strncmp(&last->name[1], LAST_NAME, sizeof(last->name) - 1))
+ return NULL;
+
+ return seg;
+}
+
+void *dmm_mem_alloc(struct dmm_segment *seg, size_t size)
+{
+ section_t *sec;
+
+ dmm_seg_lock(seg);
+ sec = mem_alloc(seg, size);
+ dmm_seg_unlock(seg);
+
+ return sec ? sec + 1 : NULL;
+}
+
+int dmm_mem_free(struct dmm_segment *seg, void *mem)
+{
+ if (CHECK_ADDR(seg, mem))
+ {
+ MEM_ERR("Invalid address:%p", mem);
+ return -1;
+ }
+
+ dmm_seg_lock(seg);
+ mem_free(seg, ((section_t *) mem) - 1);
+ dmm_seg_unlock(seg);
+
+ return 0;
+}
+
+void *dmm_mem_lookup(struct dmm_segment *seg,
+ const char name[DMM_MEM_NAME_SIZE])
+{
+ section_t *sec;
+
+ if (!name || !name[0])
+ return NULL;
+
+ dmm_read_lock(&seg->lock);
+ sec = mem_lookup(seg, name);
+ dmm_read_unlock(&seg->lock);
+
+ return sec ? sec + 1 : NULL;
+}
+
+void *dmm_mem_map(struct dmm_segment *seg, size_t size,
+ const char name[DMM_MEM_NAME_SIZE])
+{
+ void *mem;
+ section_t *sec;
+
+ if (!name || !name[0] || strlen(name) >= DMM_MEM_NAME_SIZE)
+ return NULL;
+
+ sec = mem_lookup(seg, name);
+ if (sec)
+ {
+ MEM_ERR("Map '%s' exist", name);
+ mem = NULL;
+ }
+ else if (NULL != (sec = mem_alloc(seg, size)))
+ {
+ (void) strncpy_s(sec->name, DMM_MEM_NAME_SIZE, name,
+ sizeof(sec->name) - 1);
+ mem = sec + 1;
+ }
+ else
+ {
+ MEM_ERR("alloc '%s' failed for size %lu", name, size);
+ mem = NULL;
+ }
+
+ return mem;
+}
+
+int dmm_mem_unmap(struct dmm_segment *seg, void *mem)
+{
+ if (CHECK_ADDR(seg, mem))
+ {
+ MEM_ERR("Invalid address:%p", mem);
+ return -1;
+ }
+
+ mem_free(seg, ((section_t *) mem) - 1);
+
+ return 0;
+}
diff --git a/src/framework/mem/dmm_segment.h b/src/framework/mem/basic_mem/dmm_segment.h
index 135f347..f8b3dca 100644
--- a/src/framework/mem/dmm_segment.h
+++ b/src/framework/mem/basic_mem/dmm_segment.h
@@ -13,23 +13,30 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
#ifndef _DMM_SEGMENT_H_
#define _DMM_SEGMENT_H_
+#include <stdlib.h>
+
#define DMM_MEM_NAME_SIZE 32
-struct dmm_segment *dmm_seg_create (void *base, size_t size);
-struct dmm_segment *dmm_seg_attach (void *base, size_t size);
-void dmm_seg_dump (struct dmm_segment *seg);
+struct dmm_segment;
+
+void dmm_seg_lock(struct dmm_segment *seg);
+void dmm_seg_unlock(struct dmm_segment *seg);
+
+struct dmm_segment *dmm_seg_create(void *base, size_t size);
+struct dmm_segment *dmm_seg_attach(void *base, size_t size);
+void dmm_seg_dump(struct dmm_segment *seg);
-void *dmm_mem_alloc (struct dmm_segment *seg, size_t size);
-int dmm_mem_free (struct dmm_segment *seg, void *mem);
+void *dmm_mem_alloc(struct dmm_segment *seg, size_t size);
+int dmm_mem_free(struct dmm_segment *seg, void *mem);
-void *dmm_mem_lookup (struct dmm_segment *seg,
- const char name[DMM_MEM_NAME_SIZE]);
-void *dmm_mem_map (struct dmm_segment *seg, size_t size,
- const char name[DMM_MEM_NAME_SIZE]);
-int dmm_mem_unmap (struct dmm_segment *seg,
- const char name[DMM_MEM_NAME_SIZE]);
+void *dmm_mem_lookup(struct dmm_segment *seg,
+ const char name[DMM_MEM_NAME_SIZE]);
+void *dmm_mem_map(struct dmm_segment *seg, size_t size,
+ const char name[DMM_MEM_NAME_SIZE]);
+int dmm_mem_unmap(struct dmm_segment *seg, void *mem);
#endif /* #ifndef _DMM_SEGMENT_H_ */
diff --git a/src/framework/mem/dmm_share.h b/src/framework/mem/basic_mem/dmm_share.h
index 0d0ff8f..8db19fc 100644
--- a/src/framework/mem/dmm_share.h
+++ b/src/framework/mem/basic_mem/dmm_share.h
@@ -13,43 +13,48 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
#ifndef _DMM_SHARE_H_
#define _DMM_SHARE_H_
+#include <sys/types.h>
+#include <unistd.h>
+#include <stdlib.h>
+
#define DMM_SHARE_PATH_MAX 100
enum dmm_share_type
{
- DMM_SHARE_HEAP,
- DMM_SHARE_FSHM,
- DMM_SHARE_HUGE,
+ DMM_SHARE_HEAP,
+ DMM_SHARE_FSHM,
+ DMM_SHARE_HUGE,
- DMM_SHARE_ANY = -1
+ DMM_SHARE_ANY = -1
};
struct dmm_share
{
- int type; /* share type enum dmm_share_type */
- pid_t pid; /* owner/creator pid */
- void *base; /* base logical address */
- size_t size; /* memory size */
- char path[DMM_SHARE_PATH_MAX]; /* share path */
+ int type; /* share type enum dmm_share_type */
+ pid_t pid; /* owner/creator pid */
+ void *base; /* base logical address */
+ size_t size; /* memory size */
+ char path[DMM_SHARE_PATH_MAX]; /* share path */
};
-int dmm_heap_create (struct dmm_share *share);
-int dmm_heap_delete (struct dmm_share *share);
-int dmm_heap_attach (struct dmm_share *share);
-int dmm_heap_detach (struct dmm_share *share);
+int dmm_heap_create(struct dmm_share *share);
+int dmm_heap_delete(struct dmm_share *share);
+int dmm_heap_attach(struct dmm_share *share);
+int dmm_heap_detach(struct dmm_share *share);
-int dmm_fshm_create (struct dmm_share *share);
-int dmm_fshm_delete (struct dmm_share *share);
-int dmm_fshm_attach (struct dmm_share *share);
-int dmm_fshm_detach (struct dmm_share *share);
+int dmm_fshm_create(struct dmm_share *share);
+int dmm_fshm_delete(struct dmm_share *share);
+int dmm_fshm_attach(struct dmm_share *share);
+int dmm_fshm_detach(struct dmm_share *share);
-int dmm_huge_create (struct dmm_share *share);
-int dmm_huge_delete (struct dmm_share *share);
-int dmm_huge_attach (struct dmm_share *share);
-int dmm_huge_detach (struct dmm_share *share);
+int dmm_huge_create(struct dmm_share *share);
+int dmm_huge_delete(struct dmm_share *share);
+int dmm_huge_attach(struct dmm_share *share);
+int dmm_huge_detach(struct dmm_share *share);
#define DMM_SHARE_DISPATCH(share, action) \
({ \
@@ -75,38 +80,34 @@ int dmm_huge_detach (struct dmm_share *share);
input: share->type, share->size, share->pid
output: share->base, share->path
*/
-inline static int
-dmm_share_create (struct dmm_share *share)
+inline static int dmm_share_create(struct dmm_share *share)
{
- return DMM_SHARE_DISPATCH (share, create);
+ return DMM_SHARE_DISPATCH(share, create);
}
/* delete share memory
input: share->type, share->base, share->size, share->path
*/
-inline static int
-dmm_share_delete (struct dmm_share *share)
+inline static int dmm_share_delete(struct dmm_share *share)
{
- return DMM_SHARE_DISPATCH (share, delete);
+ return DMM_SHARE_DISPATCH(share, delete);
}
/* attach share memory
input: share->type share->path [share->size] [share->base]
output: share->base, share->size
*/
-inline static int
-dmm_share_attach (struct dmm_share *share)
+inline static int dmm_share_attach(struct dmm_share *share)
{
- return DMM_SHARE_DISPATCH (share, attach);
+ return DMM_SHARE_DISPATCH(share, attach);
}
/* attach share memory
input: share->type share->size share->base
*/
-inline static int
-dmm_share_detach (struct dmm_share *share)
+inline static int dmm_share_detach(struct dmm_share *share)
{
- return DMM_SHARE_DISPATCH (share, detach);
+ return DMM_SHARE_DISPATCH(share, detach);
}
#undef DMM_SHARE_DISPATCH
diff --git a/src/framework/mem/dmm_fshm.c b/src/framework/mem/dmm_fshm.c
deleted file mode 100644
index 605c728..0000000
--- a/src/framework/mem/dmm_fshm.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-
-#include "dmm_config.h"
-#include "dmm_share.h"
-#include "dmm_fs.h"
-
-#define DMM_FSHM_FMT "%s/dmm-fshm-%d" /* VAR_DIR pid */
-
-inline static void
-set_fshm_path (struct dmm_share *share)
-{
- (void) snprintf (share->path, sizeof (share->path), DMM_FSHM_FMT,
- DMM_VAR_DIR, share->pid);
-}
-
-/*
-input: share->path, share->size, share->pid
-output: share->base
-*/
-int
-dmm_fshm_create (struct dmm_share *share)
-{
- int fd, ret;
- void *base;
-
- set_fshm_path (share);
-
- fd = open (share->path, O_RDWR | O_CREAT, 0666);
- if (fd < 0)
- {
- return -1;
- }
-
- ret = ftruncate (fd, share->size);
- if (ret < 0)
- {
- (void) close (fd);
- return -1;
- }
-
- base = mmap (NULL, share->size,
- PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, fd, 0);
- if (base == MAP_FAILED)
- {
- (void) close (fd);
- return -1;
- }
-
- share->base = base;
-
- (void) close (fd);
- return 0;
-}
-
-int
-dmm_fshm_delete (struct dmm_share *share)
-{
- (void) munmap (share->base, share->size);
- (void) unlink (share->path);
-
- return 0;
-}
-
-/*
-input: share->path, share->size, share->base(OPT)
-output: share->base(if-null)
-*/
-int
-dmm_fshm_attach (struct dmm_share *share)
-{
- int fd;
- void *base;
-
- if (share->type != DMM_SHARE_FSHM)
- {
- return -1;
- }
-
- fd = open (share->path, O_RDWR);
- if (fd < 0)
- {
- return -1;
- }
-
- if (share->size <= 0)
- {
- share->size = dmm_file_size (fd);
- if (share->size == 0)
- {
- (void) close (fd);
- return -1;
- }
- }
-
- base = mmap (share->base, share->size,
- PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, fd, 0);
- if (base == MAP_FAILED)
- {
- (void) close (fd);
- return -1;
- }
-
- if (NULL == share->base)
- {
- share->base = base;
- }
- else if (base != share->base)
- {
- (void) munmap (base, share->size);
- (void) close (fd);
- return -1;
- }
-
- (void) close (fd);
- return 0;
-}
-
-int
-dmm_fshm_detach (struct dmm_share *share)
-{
- (void) munmap (share->base, share->size);
-
- return 0;
-}
diff --git a/src/framework/mem/dmm_group.c b/src/framework/mem/dmm_group.c
deleted file mode 100644
index 35e6100..0000000
--- a/src/framework/mem/dmm_group.c
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <limits.h>
-#include <sys/types.h>
-#include <signal.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-
-//#include "dmm_memory.h"
-#include "dmm_config.h"
-#include "dmm_group.h"
-#include "dmm_pause.h"
-
-#define DMM_GROUP_ACTIVE 0x55D5551
-#define DMM_GROUP_GLOBAL "global"
-#define DMM_GROUP_ENV "DMM_GROUP"
-#define DMM_GROUP_FMT "%s/dmm-group-%s" /* VAR_DIR group-name */
-
-static struct flock group_lock = {
- .l_type = F_WRLCK,
- .l_whence = SEEK_SET,
- .l_start = 0,
- .l_len = sizeof (struct dmm_group),
-};
-
-static int group_fd = -1;
-struct dmm_group *main_group = NULL;
-
-inline static const char *
-get_group_path ()
-{
- static char group_path[PATH_MAX] = "";
-
- if (!group_path[0])
- {
- const char *group = getenv (DMM_GROUP_ENV);
-
- if (!group || !group[0])
- group = DMM_GROUP_GLOBAL;
-
- (void) snprintf (group_path, sizeof (group_path), DMM_GROUP_FMT,
- DMM_VAR_DIR, group);
- group_path[sizeof (group_path) - 1] = 0;
- }
-
- return group_path;
-}
-
-void
-dmm_group_active ()
-{
- main_group->group_init = DMM_GROUP_ACTIVE;
-}
-
-int
-dmm_group_create_main ()
-{
- int ret;
- const char *path = get_group_path ();
-
- group_fd = open (path, O_RDWR | O_CREAT, 0664);
- if (group_fd < 0)
- {
- return -1;
- }
-
- ret = ftruncate (group_fd, sizeof (struct dmm_group));
- if (ret < 0)
- {
- (void) close (group_fd);
- group_fd = -1;
- return -1;
- }
-
- ret = fcntl (group_fd, F_SETLK, &group_lock);
- if (ret < 0)
- {
- (void) close (group_fd);
- group_fd = -1;
- return -1;
- }
-
- main_group = (struct dmm_group *) mmap (NULL, sizeof (struct dmm_group),
- PROT_READ | PROT_WRITE, MAP_SHARED,
- group_fd, 0);
-
- if (main_group == MAP_FAILED)
- {
- (void) close (group_fd);
- group_fd = -1;
- return -1;
- }
-
- return 0;
-}
-
-int
-dmm_group_delete_main ()
-{
- if (main_group)
- {
- (void) munmap (main_group, sizeof (struct dmm_group));
- main_group = NULL;
- }
-
- if (group_fd >= 0)
- {
- (void) close (group_fd);
- group_fd = -1;
- }
-
- (void) unlink (get_group_path ());
-
- return 0;
-}
-
-int
-dmm_group_attach_main ()
-{
- const char *path = get_group_path ();
-
- group_fd = open (path, O_RDONLY);
- if (group_fd < 0)
- {
- return -1;
- }
-
- main_group = (struct dmm_group *) mmap (NULL, sizeof (struct dmm_group *),
- PROT_READ, MAP_SHARED, group_fd, 0);
- if (main_group == MAP_FAILED)
- {
- (void) close (group_fd);
- group_fd = -1;
- return -1;
- }
-
- while (main_group->group_init != DMM_GROUP_ACTIVE)
- {
- dmm_pause ();
- }
-
- if (kill (main_group->share.pid, 0))
- {
- (void) munmap (main_group->share.base, main_group->share.size);
- (void) close (group_fd);
- group_fd = -1;
- return -1;
- }
-
- return 0;
-}
-
-int
-dmm_group_detach_main ()
-{
- if (main_group)
- {
- (void) munmap (main_group, sizeof (struct dmm_group));
- main_group = NULL;
- }
-
- if (group_fd >= 0)
- {
- (void) close (group_fd);
- group_fd = -1;
- }
-
- return 0;
-}
diff --git a/src/framework/mem/dmm_heap.c b/src/framework/mem/dmm_heap.c
deleted file mode 100644
index bc966ef..0000000
--- a/src/framework/mem/dmm_heap.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-#include <stdlib.h>
-#include <sys/types.h>
-
-#include "dmm_config.h"
-#include "dmm_share.h"
-
-struct heap_path
-{
- void *base;
- size_t size;
-};
-
-int
-dmm_heap_create (struct dmm_share *share)
-{
- share->base = malloc (share->size);
-
- if (share->base)
- {
- struct heap_path *hp = (struct heap_path *) share->path;
- hp->base = share->base;
- hp->size = share->size;
- return 0;
- }
-
- return -1;
-}
-
-int
-dmm_heap_delete (struct dmm_share *share)
-{
- free (share->base);
- return 0;
-}
-
-int
-dmm_heap_attach (struct dmm_share *share)
-{
- struct heap_path *hp = (struct heap_path *) share->path;
-
- if (share->base)
- {
- if (hp->base != share->base)
- return -1;
- }
- else
- {
- share->base = hp->base;
- }
-
- if (share->size)
- {
- if (share->size != hp->size)
- return -1;
- }
- else
- {
- share->size = hp->size;
- }
-
- return 0;
-}
-
-int
-dmm_heap_detach (struct dmm_share *share)
-{
- return 0;
-}
diff --git a/src/framework/mem/dmm_huge.c b/src/framework/mem/dmm_huge.c
deleted file mode 100644
index 735c507..0000000
--- a/src/framework/mem/dmm_huge.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-#include <stdio.h>
-#include <sys/types.h>
-
-#include "dmm_config.h"
-#include "dmm_share.h"
-
-#define DMM_HUGE_FMT "%s/dmm-%d-%d" /* HUGE_DIR pid index */
-
-inline static void
-huge_set_path (struct dmm_share *share, int index)
-{
- (void) snprintf (share->path, sizeof (share->path), DMM_HUGE_FMT,
- DMM_HUGE_DIR, share->pid, index);
-}
-
-int
-dmm_huge_create (struct dmm_share *share)
-{
- return -1;
-}
-
-int
-dmm_huge_delete (struct dmm_share *share)
-{
- return -1;
-}
-
-int
-dmm_huge_attach (struct dmm_share *share)
-{
- return -1;
-}
-
-int
-dmm_huge_detach (struct dmm_share *share)
-{
- return -1;
-}
diff --git a/src/framework/mem/dmm_memory.c b/src/framework/mem/dmm_memory.c
deleted file mode 100644
index 0352432..0000000
--- a/src/framework/mem/dmm_memory.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-#include <sys/types.h>
-#include <unistd.h>
-
-#include "dmm_config.h"
-#include "dmm_memory.h"
-#include "dmm_group.h"
-
-#define DMM_MEGABYTE (1024 * 1024)
-
-/* shared from main process */
-static struct dmm_share *main_share = NULL;
-struct dmm_segment *main_seg = NULL;
-
-/* shared by process tree */
-static struct dmm_share base_share = { 0 };
-
-struct dmm_segment *base_seg = NULL;
-
-int
-dmm_mem_main_init ()
-{
- int ret;
-
- ret = dmm_group_create_main ();
- if (ret)
- {
- return -1;
- }
-
- main_share = &main_group->share;
- main_share->type = DMM_MAIN_SHARE_TYPE;
- main_share->size = DMM_MAIN_SHARE_SIZE * DMM_MEGABYTE;
- main_share->base = NULL;
- main_share->pid = getpid ();
- ret = dmm_share_create (main_share);
- if (ret)
- {
- return -1;
- }
-
- main_seg = dmm_seg_create (main_share->base, main_share->size);
- if (!main_seg)
- {
- return -1;
- }
-
- dmm_group_active ();
-
- return 0;
-}
-
-int
-dmm_mem_main_exit ()
-{
- dmm_group_delete_main ();
- return 0;
-}
-
-int
-dmm_mem_app_init ()
-{
- int ret;
-
- ret = dmm_group_attach_main ();
- if (0 == ret)
- {
- main_share = &main_group->share;
- ret = dmm_share_attach (main_share);
- if (ret)
- {
- return -1;
- }
-
- main_seg = dmm_seg_attach (main_share->base, main_share->size);
- if (!main_seg)
- {
- return -1;
- }
-
- /* now share main process share-memory */
- base_seg = main_seg;
- }
- else
- {
- base_share.type = DMM_SHARE_TYPE;
- base_share.size = DMM_SHARE_SIZE * DMM_MEGABYTE;
- base_share.base = NULL;
- base_share.pid = getpid ();
- ret = dmm_share_create (&base_share);
- if (ret)
- {
- return -1;
- }
-
- base_seg = dmm_seg_create (base_share.base, base_share.size);
- if (!base_seg)
- {
- return -1;
- }
- }
-
- return 0;
-}
-
-int
-dmm_mem_app_exit ()
-{
- dmm_group_detach_main ();
-
- if (base_share.base)
- dmm_share_delete (&base_share);
-
- base_share.base = NULL;
- base_seg = NULL;
- main_seg = NULL;
-
- return 0;
-}
diff --git a/src/framework/mem/dmm_memory.h b/src/framework/mem/dmm_memory.h
deleted file mode 100644
index 2fac118..0000000
--- a/src/framework/mem/dmm_memory.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-#ifndef _DMM_MEMORY_H_
-#define _DMM_MEMORY_H_
-#include <stdio.h>
-#include <stdarg.h>
-#include "dmm_share.h"
-#include "dmm_segment.h"
-
-int dmm_mem_main_init ();
-int dmm_mem_main_exit ();
-
-int dmm_mem_app_init ();
-int dmm_mem_app_exit ();
-
-extern struct dmm_segment *main_seg;
-extern struct dmm_segment *base_seg;
-
-inline static void *
-dmm_map (size_t size, const char name[DMM_MEM_NAME_SIZE])
-{
- return dmm_mem_map (base_seg, size, name);
-}
-
-inline static void *
-dmm_mapv (size_t size, const char *name_fmt, ...)
-{
- int len;
- char name[DMM_MEM_NAME_SIZE];
- va_list ap;
-
- va_start (ap, name_fmt);
- len = vsnprintf (name, DMM_MEM_NAME_SIZE, name_fmt, ap);
- va_end (ap);
-
- if (len >= DMM_MEM_NAME_SIZE)
- return NULL;
-
- return dmm_map (size, name);
-}
-
-inline static void *
-dmm_lookup (const char name[DMM_MEM_NAME_SIZE])
-{
- return dmm_mem_lookup (base_seg, name);
-}
-
-inline static void *
-dmm_lookupv (const char *name_fmt, ...)
-{
- int len;
- char name[DMM_MEM_NAME_SIZE];
- va_list ap;
-
- va_start (ap, name_fmt);
- len = vsnprintf (name, DMM_MEM_NAME_SIZE, name_fmt, ap);
- va_end (ap);
-
- if (len >= DMM_MEM_NAME_SIZE)
- return NULL;
-
- return dmm_mem_lookup (base_seg, name);
-}
-
-#endif /* _DMM_MEMORY_H_ */
diff --git a/src/framework/mem/dmm_nshmem_mng.c b/src/framework/mem/dmm_nshmem_mng.c
new file mode 100644
index 0000000..515975c
--- /dev/null
+++ b/src/framework/mem/dmm_nshmem_mng.c
@@ -0,0 +1,126 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#include<stdlib.h>
+#include "nsfw_mem_api.h"
+#include "dmm_ring.h"
+#include "dmm_memory.h"
+#include "dmm_nshmem_mng.h"
+
+i32 dmm_nshmem_init(nsfw_mem_para * para)
+{
+ return NSFW_MEM_OK;
+}
+
+/*
+ * memory destory
+ */
+void dmm_nshmem_destory(void)
+{
+ return;
+}
+
+mzone_handle dmm_nshmem_create(nsfw_mem_zone * pinfo)
+{
+ if (!pinfo->lenth)
+ {
+ return NULL;
+ }
+ return calloc(1, pinfo->lenth);
+}
+
+mring_handle dmm_nshmem_spcreate(nsfw_mem_sppool * pmpinfo)
+{
+ struct dmm_ring *ring;
+
+ ring =
+ dmm_malloc_pool(pmpinfo->useltsize, (int) pmpinfo->usnum,
+ DMM_RING_INIT_MPMC);
+ if (ring == NULL)
+ {
+ NSSOC_LOGERR("nshmem sp create faild num:%u eltsize:%u",
+ pmpinfo->usnum, pmpinfo->useltsize);
+ return NULL;
+ }
+ return (mring_handle) (ring);
+}
+
+i32 dmm_nshmem_sprelease(nsfw_mem_name * pname)
+{
+ return NSFW_MEM_OK;
+}
+
+mring_handle dmm_nshmem_ringcreate(nsfw_mem_mring * pringinfo)
+{
+ struct dmm_ring *ring = NULL;
+
+ ring = dmm_malloc_ring((int) pringinfo->usnum, DMM_RING_INIT_MPMC);
+ if (ring == NULL)
+ {
+ NSSOC_LOGERR("nshmem ring create faild num:%u", pringinfo->usnum);
+ return NULL;
+ }
+ return (mring_handle) (ring);
+}
+
+i32 dmm_nshmem_ringrelease(nsfw_mem_name * pname)
+{
+ return NSFW_MEM_OK;
+}
+
+ssize_t dmm_nshmem_sppool_statics(mring_handle sppool)
+{
+ size_t size = 0;
+ struct dmm_ring *ring = (struct dmm_ring *) sppool;
+ if (ring == NULL)
+ {
+ NSSOC_LOGERR("nshmem sppool stat para errer");
+ return 0;
+ }
+
+ size = dmm_ring_bufsize(ring->size - 1);
+ size = size + dmm_pool_arraysize((ring->size - 1), ring->eltsize);
+
+ return size;
+}
+
+ssize_t dmm_nshmem_ring_statics(mring_handle handle)
+{
+ struct dmm_ring *ring = (struct dmm_ring *) handle;
+ if (ring == NULL)
+ {
+ NSSOC_LOGERR("nshmem ring stat para errer");
+ return 0;
+ }
+
+ return dmm_ring_bufsize(ring->size - 1);
+}
+
+ssize_t dmm_nshmem_stactic(void *handle, nsfw_mem_struct_type type)
+{
+ switch (type)
+ {
+ case NSFW_MEM_MBUF:
+ return -1;
+ case NSFW_MEM_SPOOL:
+ return dmm_nshmem_sppool_statics(handle);
+ case NSFW_MEM_RING:
+ return dmm_nshmem_ring_statics(handle);
+ default:
+ break;
+ }
+ return -1;
+}
diff --git a/stacks/lwip_stack/lwip_src/common/stackx_tx_box.h b/src/framework/mem/dmm_nshmem_mng.h
index edfba5c..d25c365 100644
--- a/stacks/lwip_stack/lwip_src/common/stackx_tx_box.h
+++ b/src/framework/mem/dmm_nshmem_mng.h
@@ -14,26 +14,22 @@
* limitations under the License.
*/
-#ifndef STACKX_TX_BOX_H
-#define STACKX_TX_BOX_H
-#include "sys/types.h"
-#include "nsfw_mem_api.h"
-#include "stackx_common.h"
-#include "nsfw_mt_config.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
+#ifndef _DMM_NSHMEM_MNG_H
+#define _DMM_NSHMEM_MNG_H
-const char *get_stackx_ring_name ();
-const char *get_stackx_priority_ring_name (unsigned priority);
+#include "nsfw_mem_api.h"
+#include "types.h"
+#include <unistd.h>
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
+i32 dmm_nshmem_init(nsfw_mem_para * para);
+void dmm_nshmem_destory(void);
+mzone_handle dmm_nshmem_create(nsfw_mem_zone * pinfo);
+mring_handle dmm_nshmem_spcreate(nsfw_mem_sppool * pmpinfo);
+i32 dmm_nshmem_sprelease(nsfw_mem_name * pname);
+mring_handle dmm_nshmem_ringcreate(nsfw_mem_mring * pringinfo);
+i32 dmm_nshmem_ringrelease(nsfw_mem_name * pname);
+ssize_t dmm_nshmem_sppool_statics(mring_handle sppool);
+ssize_t dmm_nshmem_ring_statics(mring_handle handle);
+ssize_t dmm_nshmem_stactic(void *handle, nsfw_mem_struct_type type);
#endif
diff --git a/src/framework/mem/dmm_segment.c b/src/framework/mem/dmm_segment.c
deleted file mode 100644
index 6358506..0000000
--- a/src/framework/mem/dmm_segment.c
+++ /dev/null
@@ -1,543 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include <stdio.h>
-#include <string.h>
-#include "dmm_rwlock.h"
-#include "dmm_segment.h"
-#include "nstack_log.h"
-
-#define SECTION_SIZE 64 /* cache line size */
-
-#define FIRST_NAME "FIRST SECTION FOR SEGMENT"
-#define LAST_NAME "LAST SECTION FOR FREE HEAD"
-
-#define MEM_ERR(fmt, ...) \
- NS_LOGPID(LOGFW, "DMM-MEM", NSLOG_ERR, fmt, ##__VA_ARGS__)
-
-/*
-init create:
- \--total number
- /--head no align \ can be used \--tail no align
- / ___________________/\___________________ \
-/\/ \/\
-__<F>{S}[ ][ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]<L>__
-^ \ /\ /\____________ ________________/\ /
-| | | \ / |
-| | +--the segment | +--last section(free:0 used:0)
-| +--first section(prev_rel:0 used:2 free:11 req_size:sizeof(dmm_segment))
-+--base address
-
-init: <F>{S}[ ]<L>
-alloc A: <F>{S}[ ]<A>#########<L>
-alloc B: <F>{S}[ ]<B>#########<A>#########<L>
-free A: <F>{S}[ ]<B>#########[ ]<L>
-alloc C: <F>{S}[ ]<C>###<B>#########[ ]<L>
-*/
-
-typedef struct dmm_section
-{
- int prev_rel;
- int used_num;
- int free_num;
- int __flags; /* reserved */
- size_t req_size; /* in bytes */
- int less_rel; /* for free list */
- int more_rel; /* for free list */
- char name[DMM_MEM_NAME_SIZE];
-} __attribute__ ((__aligned__ (SECTION_SIZE))) section_t;
-SIZE_OF_TYPE_EQUAL_TO (section_t, SECTION_SIZE);
-
-struct dmm_segment
-{
- void *base; /* base address(maybe not align) */
- size_t size; /* full size */
- section_t *first; /* aligned 64 */
- section_t *last; /* last section used to handle free list */
- dmm_rwlock_t lock;
- int total_num; /* MAX:2147483647 ==> MAX size: 128M-64 */
- int used_num;
- int sec_num;
- size_t used_size; /* real alloc size bytes */
-};
-
-/* calculate segment number, auto align 64, include 1 section_t */
-inline static int
-CALC_NUM (size_t size)
-{
- if (size)
- {
- const size_t MASK = SECTION_SIZE - 1;
- return (size + MASK) / SECTION_SIZE + 1;
- }
-
- return 2; /* if size is 0, then alloc 1 block */
-}
-
-inline static int
-SEC_REL (const section_t * base, const section_t * sec)
-{
- return sec - base;
-}
-
-section_t *
-REL_SEC (section_t * base, int rel)
-{
- return base + rel;
-}
-
-inline static int
-SEC_INDEX (struct dmm_segment *seg, section_t * sec)
-{
- return SEC_REL (seg->first, sec);
-}
-
-inline static section_t *
-LESS_SEC (section_t * sec)
-{
- return sec + sec->less_rel;
-}
-
-inline static section_t *
-MORE_SEC (section_t * sec)
-{
- return sec + sec->more_rel;
-}
-
-inline static section_t *
-PREV_SEC (section_t * sec)
-{
- return sec + sec->prev_rel;
-}
-
-inline static section_t *
-NEXT_SEC (section_t * sec)
-{
- return sec + (sec->free_num + sec->used_num);
-}
-
-inline static int
-CHECK_ADDR (struct dmm_segment *seg, void *mem)
-{
- if (mem < (void *) seg->first)
- return -1;
- if (mem > (void *) seg->last)
- return -1;
- if ((long) mem & (SECTION_SIZE - 1))
- return -1;
-
- return 0;
-}
-
-inline static section_t *
-mem_lookup (struct dmm_segment *seg, const char name[DMM_MEM_NAME_SIZE])
-{
- section_t *sec;
-
- /* caller ensures the validity of the name */
-
- for (sec = seg->last; sec != seg->first; sec = PREV_SEC (sec))
- {
- if (sec->name[0] == 0)
- continue;
- if (0 == strcmp (sec->name, name))
- return sec;
- }
-
- return NULL;
-}
-
-static section_t *
-mem_alloc (struct dmm_segment *seg, size_t size)
-{
- const int num = CALC_NUM (size);
- section_t *sec, *pos, *next, *less, *more;
-
- if (num > seg->total_num - seg->used_num)
- {
- /* no enough memory */
- return NULL;
- }
-
- /* find enough free space */
- pos = seg->last;
- do
- {
- pos = MORE_SEC (pos);
- if (pos == seg->last)
- {
- /* no enough memory */
- return NULL;
- }
- }
- while (num > pos->free_num);
-
- /* allocate pos pos section tail */
-
- /* change next section's prev possion */
- next = NEXT_SEC (pos);
- next->prev_rel = -num;
-
- /* create new section */
- sec = PREV_SEC (next);
- sec->prev_rel = SEC_REL (sec, pos);
- sec->used_num = num;
- sec->req_size = size;
- sec->free_num = 0; /* no free space */
- sec->less_rel = 0;
- sec->more_rel = 0;
- sec->name[0] = 0;
-
- /* adjust pos */
- pos->free_num -= num;
-
- less = LESS_SEC (pos);
- more = MORE_SEC (pos);
-
- /* remove pos free list */
- less->more_rel = SEC_REL (less, more);
- more->less_rel = SEC_REL (more, less);
- pos->more_rel = 0;
- pos->less_rel = 0;
-
- /* find position */
- while (less != seg->last)
- {
- if (pos->free_num >= less->free_num)
- break;
- less = LESS_SEC (less);
- }
-
- /* insert into free list */
- more = MORE_SEC (less);
- less->more_rel = SEC_REL (less, pos);
- more->less_rel = SEC_REL (more, pos);
- pos->more_rel = SEC_REL (pos, more);
- pos->less_rel = SEC_REL (pos, less);
-
- /* adjust segment */
- seg->used_size += size;
- seg->used_num += num;
- seg->sec_num++;
-
- /* victory */
- return sec;
-}
-
-static void
-mem_free (struct dmm_segment *seg, section_t * sec)
-{
- const int num = sec->used_num + sec->free_num;
- section_t *next = NEXT_SEC (sec);
- section_t *prev = PREV_SEC (sec);
- section_t *more, *less;
-
- /* adjust next section's prev */
- next->prev_rel = SEC_REL (next, prev);
-
- if (sec->free_num)
- {
- /* remove from free list */
- more = MORE_SEC (sec);
- less = LESS_SEC (sec);
- more->less_rel = SEC_REL (more, less);
- less->more_rel = SEC_REL (less, more);
- }
-
- if (prev->free_num)
- {
- /* remove from free list */
- more = MORE_SEC (prev);
- less = LESS_SEC (prev);
- more->less_rel = SEC_REL (more, less);
- less->more_rel = SEC_REL (less, more);
- }
- else
- {
- more = MORE_SEC (seg->last);
- }
-
- /* put the space to prev's free space */
- prev->free_num += num;
-
- while (more != seg->last)
- {
- if (prev->free_num <= more->free_num)
- break;
- more = MORE_SEC (more);
- }
- less = LESS_SEC (more);
-
- /* insert */
- less->more_rel = SEC_REL (less, prev);
- more->less_rel = SEC_REL (more, prev);
- prev->more_rel = SEC_REL (prev, more);
- prev->less_rel = SEC_REL (prev, less);
-
- /* adjust segment */
- seg->used_size -= sec->req_size;
- seg->used_num -= sec->used_num;
- seg->sec_num--;
-}
-
-void
-dmm_seg_dump (struct dmm_segment *seg)
-{
- section_t *sec;
-
- dmm_read_lock (&seg->lock);
-
- (void) printf ("---- segment:%p base:%p size:%lu --------------\n"
- " first[%d]:%p last[%d]:%p total_num:%d used_num:%d\n"
- " sec_num:%d used_size:%lu use%%:%lu%% free%%:%lu%%\n",
- seg, seg->base, seg->size,
- SEC_INDEX (seg, seg->first), seg->first,
- SEC_INDEX (seg, seg->last), seg->last,
- seg->total_num, seg->used_num,
- seg->sec_num, seg->used_size,
- seg->used_size * 100 / seg->size,
- (seg->total_num -
- seg->used_num) * SECTION_SIZE * 100 / seg->size);
-
- (void) printf ("----------------------------------------\n"
- "%18s %9s %9s %9s %9s %10s %9s %9s %s\n",
- "PHYSICAL-ORDER", "section", "prev_rel", "used_num",
- "free_num", "req_size", "less_rel", "more_rel", "name");
-
- sec = seg->first;
- while (1)
- {
- (void) printf ("%18p %9d %9d %9d %9d %10lu %9d %9d '%s'\n",
- sec, SEC_INDEX (seg, sec),
- sec->prev_rel, sec->used_num, sec->free_num,
- sec->req_size, sec->less_rel, sec->more_rel, sec->name);
- if (sec == seg->last)
- break;
- sec = NEXT_SEC (sec);
- }
-
- (void) printf ("----------------------------------------\n"
- "%18s %9s %9s\n", "FREE-ORDER", "section", "free_num");
- for (sec = MORE_SEC (seg->last); sec != seg->last; sec = MORE_SEC (sec))
- {
- (void) printf ("%18p %9d %9d\n",
- sec, SEC_INDEX (seg, sec), sec->free_num);
- }
-
- (void) printf ("----------------------------------------\n");
-
- dmm_read_unlock (&seg->lock);
-}
-
-inline static int
-align_section (void *base, size_t size, section_t ** first)
-{
- const long MASK = ((long) SECTION_SIZE - 1);
- const int SEG_NUM = CALC_NUM (sizeof (struct dmm_segment));
-
- const long align = (long) base;
- const long addr = (align + MASK) & (~MASK);
- const size_t total = (size - (addr - align)) / SECTION_SIZE;
-
- if (total > 0x7fffFFFF)
- return -1;
- if (total < SEG_NUM + 1) /* first+segment + last */
- return -1;
-
- *first = (section_t *) addr;
- return (int) total;
-}
-
-struct dmm_segment *
-dmm_seg_create (void *base, size_t size)
-{
- const int SEG_NUM = CALC_NUM (sizeof (struct dmm_segment));
- section_t *first, *last;
- struct dmm_segment *seg;
- int total = align_section (base, size, &first);
-
- if (total <= 0)
- return NULL;
-
- last = first + (total - 1);
-
- /* first section */
- first->prev_rel = 0;
- first->used_num = SEG_NUM;
- first->req_size = sizeof (struct dmm_segment);
- first->free_num = total - (SEG_NUM + 1);
- first->less_rel = SEC_REL (first, last);
- first->more_rel = SEC_REL (first, last);
- first->name[0] = 0;
- (void) strncpy (&first->name[1], FIRST_NAME, sizeof (first->name) - 1);
-
- /* last section */
- last->prev_rel = SEC_REL (last, first);
- last->used_num = 0;
- last->req_size = 0;
- last->free_num = 0;
- last->less_rel = SEC_REL (last, first);
- last->more_rel = SEC_REL (last, first);
- last->name[0] = 0;
- (void) strncpy (&last->name[1], LAST_NAME, sizeof (first->name) - 1);
-
- /* segment */
- seg = (struct dmm_segment *) (first + 1);
- dmm_rwlock_init (&seg->lock);
- seg->base = base;
- seg->size = size;
- seg->first = first;
- seg->last = last;
- seg->total_num = total;
- seg->sec_num = 2;
- seg->used_size = sizeof (struct dmm_segment);
- seg->used_num = first->used_num;
-
- return seg;
-}
-
-struct dmm_segment *
-dmm_seg_attach (void *base, size_t size)
-{
- section_t *first, *last;
- struct dmm_segment *seg;
- int total = align_section (base, size, &first);
-
- if (total <= 0)
- return NULL;
-
- last = first + (total - 1);
- seg = (struct dmm_segment *) (first + 1);
-
- if (seg->base != base)
- return NULL;
- if (seg->size != size)
- return NULL;
- if (seg->total_num != total)
- return NULL;
-
- if (seg->first != first)
- return NULL;
- if (first->name[0] != 0)
- return NULL;
- if (strncmp (&first->name[1], FIRST_NAME, sizeof (first->name) - 1))
- return NULL;
-
- if (seg->last != last)
- return NULL;
- if (last->name[0] != 0)
- return NULL;
- if (strncmp (&last->name[1], LAST_NAME, sizeof (last->name) - 1))
- return NULL;
-
- return seg;
-}
-
-void *
-dmm_mem_alloc (struct dmm_segment *seg, size_t size)
-{
- section_t *sec;
-
- dmm_write_lock (&seg->lock);
- sec = mem_alloc (seg, size);
- dmm_write_unlock (&seg->lock);
-
- return sec ? sec + 1 : NULL;
-}
-
-int
-dmm_mem_free (struct dmm_segment *seg, void *mem)
-{
- if (CHECK_ADDR (seg, mem))
- {
- MEM_ERR ("Invalid address:%p", mem);
- return -1;
- }
-
- dmm_write_lock (&seg->lock);
- mem_free (seg, ((section_t *) mem) - 1);
- dmm_write_unlock (&seg->lock);
-
- return 0;
-}
-
-void *
-dmm_mem_lookup (struct dmm_segment *seg, const char name[DMM_MEM_NAME_SIZE])
-{
- section_t *sec;
-
- if (!name || !name[0])
- return NULL;
-
- dmm_read_lock (&seg->lock);
- sec = mem_lookup (seg, name);
- dmm_read_unlock (&seg->lock);
-
- return sec ? sec + 1 : NULL;
-}
-
-void *
-dmm_mem_map (struct dmm_segment *seg, size_t size,
- const char name[DMM_MEM_NAME_SIZE])
-{
- void *mem;
- section_t *sec;
-
- if (!name || !name[0] || strlen (name) >= DMM_MEM_NAME_SIZE)
- return NULL;
-
- dmm_write_lock (&seg->lock);
-
- sec = mem_lookup (seg, name);
- if (sec)
- {
- MEM_ERR ("Map '%s' exist", name);
- mem = NULL;
- }
- else if (!(sec = mem_alloc (seg, size)))
- {
- MEM_ERR ("alloc '%s' failed for size %lu", name, size);
- mem = NULL;
- }
- else
- {
- (void) strncpy (sec->name, name, sizeof (sec->name));
- mem = sec + 1;
- }
-
- dmm_write_unlock (&seg->lock);
-
- return mem;
-}
-
-int
-dmm_mem_unmap (struct dmm_segment *seg, const char name[DMM_MEM_NAME_SIZE])
-{
- section_t *sec;
-
- if (!name || !name[0])
- return -1;
-
- dmm_write_lock (&seg->lock);
-
- sec = mem_lookup (seg, name);
- if (sec)
- mem_free (seg, sec);
-
- dmm_write_unlock (&seg->lock);
-
- return sec != NULL ? 0 : -1;
-}
diff --git a/src/framework/mem/dmm_shmem_mng.c b/src/framework/mem/dmm_shmem_mng.c
new file mode 100644
index 0000000..7dee6dc
--- /dev/null
+++ b/src/framework/mem/dmm_shmem_mng.c
@@ -0,0 +1,287 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#include "nsfw_mem_api.h"
+#include "dmm_memory.h"
+#include "dmm_ring.h"
+#include "dmm_shmem_mng.h"
+#include "nstack_securec.h"
+
+/*
+ *share memory mng module init
+ *
+ */
+i32 dmm_shmem_init(nsfw_mem_para * para)
+{
+ i32 iret = NSFW_MEM_OK;
+
+ NSSOC_LOGINF("shmem init begin");
+
+ if (NSFW_PROC_APP != para->enflag)
+ {
+ NSSOC_LOGERR("shmem init with error proc type");
+ return NSFW_MEM_ERR;
+ }
+ else
+ {
+ iret = dmm_mem_module_init((void *) ((u64) (para->enflag)));
+ }
+
+ if (NSFW_MEM_OK != iret)
+ {
+ NSSOC_LOGERR("shmem init fail]ret=0x%x", iret);
+ return NSFW_MEM_RTP_FAIL;
+ }
+
+ NSRTP_LOGINF("shmem init end]flag=%d", para->enflag);
+ return NSFW_MEM_OK;
+}
+
+/*
+ *module destroy
+ */
+void dmm_shmem_destroy(void)
+{
+ (void) dmm_share_destroy();
+
+ return;
+}
+
+/*
+ * create a shared memory
+ * nsfw_mem_zone::stname memory name
+ * nsfw_mem_zone::isize
+ */
+mzone_handle dmm_shmem_create(nsfw_mem_zone * pinfo)
+{
+ return dmm_locked_map(pinfo->lenth, pinfo->stname.aname);
+}
+
+/*
+ *create some memory
+ *inum must be equal iarray_num
+ */
+i32 dmm_shmem_createv(nsfw_mem_zone * pmeminfo, i32 inum,
+ mzone_handle * paddr_array, i32 iarray_num)
+{
+ return NSFW_MEM_OK;
+}
+
+mzone_handle dmm_shmem_lookup(nsfw_mem_name * pname)
+{
+ return dmm_lookup(pname->aname);
+}
+
+i32 dmm_shmem_release(nsfw_mem_name * pname)
+{
+ void *ptr = NULL;
+
+ ptr = dmm_lookup(pname->aname);
+ if (ptr == NULL)
+ {
+ NSSOC_LOGERR("shmem[%s] release fail", pname->aname);
+ return NSFW_MEM_ERR;
+ }
+
+ return dmm_unmap(ptr);
+}
+
+mpool_handle dmm_shmem_mbfmpcreate(nsfw_mem_mbfpool * pbufinfo)
+{
+ return NULL;
+}
+
+/*
+ *create some mbuf pools
+ */
+i32 dmm_shmem_mbfmpcreatev(nsfw_mem_mbfpool * pmbfname, i32 inum,
+ mpool_handle * phandle_array, i32 iarray_num)
+{
+ return 0;
+}
+
+mpool_handle dmm_shmem_mbfmplookup(nsfw_mem_name * pmbfname)
+{
+ return NULL;
+}
+
+i32 dmm_shmem_mbfmprelease(nsfw_mem_name * pname)
+{
+ return NSFW_MEM_OK;
+}
+
+mring_handle dmm_shmem_spcreate(nsfw_mem_sppool * pmpinfo)
+{
+ struct dmm_ring *ring;
+
+ ring =
+ dmm_create_pool(pmpinfo->useltsize, (int) pmpinfo->usnum,
+ DMM_RING_INIT_MPMC, pmpinfo->stname.aname);
+ if (ring == NULL)
+ {
+ NSSOC_LOGERR("shmem sp create faild num:%u eltsize:%u",
+ pmpinfo->usnum, pmpinfo->useltsize);
+ return NULL;
+ }
+
+ return (mring_handle) (ring);
+}
+
+i32 dmm_shmem_spcreatev(nsfw_mem_sppool * pmpinfo, i32 inum,
+ mring_handle * pringhandle_array, i32 iarray_num)
+{
+ return NSFW_MEM_OK;
+}
+
+i32 dmm_shmem_sp_ringcreate(nsfw_mem_mring * prpoolinfo,
+ mring_handle * pringhandle_array, i32 iringnum)
+{
+ i32 i = 0;
+ size_t eltsize = 0;
+ mring_handle ring = NULL;
+ size_t ring_size = 0;
+ nsfw_mem_sppool mpinfo;
+ char *pool = NULL;
+
+ eltsize = dmm_ring_bufsize((int) prpoolinfo->usnum);
+ mpinfo.useltsize = eltsize;
+ mpinfo.usnum = iringnum;
+ (void) strncpy_s(mpinfo.stname.aname, sizeof(mpinfo.stname.aname),
+ prpoolinfo->stname.aname,
+ sizeof(mpinfo.stname.aname) - 1);
+
+ ring = dmm_shmem_spcreate(&mpinfo);
+ if (ring == NULL)
+ {
+ NSSOC_LOGERR("shmem spring create faild num:%u eltsize:%u",
+ mpinfo.usnum, mpinfo.useltsize);
+ return NSFW_MEM_ERR;
+ }
+
+ ring_size = dmm_ring_bufsize(iringnum);
+ pool = (char *) ring + ring_size;
+ for (i = 0; i < iringnum; i++)
+ {
+ pringhandle_array[i] = pool;
+ if (0 !=
+ dmm_ring_init((struct dmm_ring *) pringhandle_array[i],
+ (int) prpoolinfo->usnum, eltsize,
+ DMM_RING_INIT_MPMC, NSFW_SHMEM))
+ {
+ NSSOC_LOGERR("ring init faild index:%d", i);
+ return NSFW_MEM_ERR;
+ }
+ pool = pool + eltsize;
+ }
+
+ return NSFW_MEM_OK;
+}
+
+i32 dmm_shmem_sprelease(nsfw_mem_name * pname)
+{
+ return dmm_shmem_release(pname);
+}
+
+mring_handle dmm_shmem_sp_lookup(nsfw_mem_name * pname)
+{
+ return dmm_lookup(pname->aname);
+}
+
+mring_handle dmm_shmem_ringcreate(nsfw_mem_mring * pringinfo)
+{
+ struct dmm_ring *ring;
+
+ ring =
+ dmm_create_ring((int) pringinfo->usnum, DMM_RING_INIT_MPMC,
+ pringinfo->stname.aname);
+
+ return (mring_handle) (ring);
+}
+
+mring_handle dmm_shmem_ring_lookup(nsfw_mem_name * pname)
+{
+ return dmm_lookup(pname->aname);
+}
+
+i32 dmm_shmem_ringrelease(nsfw_mem_name * pname)
+{
+ return dmm_shmem_release(pname);
+}
+
+size_t dmm_shmem_sppool_statics(mring_handle sppool)
+{
+ size_t size = 0;
+ struct dmm_ring *ring = (struct dmm_ring *) sppool;
+ if (ring == NULL)
+ {
+ NSSOC_LOGERR("shmem sppool stat para errer");
+ return 0;
+ }
+
+ size = dmm_ring_bufsize(ring->size - 1);
+ size = size + dmm_pool_arraysize((ring->size - 1), ring->eltsize);
+
+ return size;
+}
+
+size_t dmm_shmem_ring_statics(mring_handle handle)
+{
+ struct dmm_ring *ring = (struct dmm_ring *) handle;
+ if (ring == NULL)
+ {
+ NSSOC_LOGERR("shmem ring stat para errer");
+ return 0;
+ }
+
+ return dmm_ring_bufsize(ring->size - 1);
+}
+
+ssize_t dmm_shmem_stactic(void *handle, nsfw_mem_struct_type type)
+{
+ switch (type)
+ {
+ case NSFW_MEM_MBUF:
+ return 0;
+ case NSFW_MEM_SPOOL:
+ return dmm_shmem_sppool_statics(handle);
+ case NSFW_MEM_RING:
+ return dmm_shmem_ring_statics(handle);
+ default:
+ break;
+ }
+ return -1;
+}
+
+i32 dmm_shmem_sp_iterator(mpool_handle handle, u32 start, u32 end,
+ nsfw_mem_item_fun fun, void *argv)
+{
+ return 0;
+}
+
+void *dmm_shmem_shddr_to_laddr(void *addr)
+{
+ return addr;
+}
+
+uint64_t dmm_shmem_laddr_to_shddr(void *addr)
+{
+ return (uint64_t) (addr);
+}
+
+int dmm_attach_core_id(nsfw_mem_name * name)
+{
+ return 0;
+}
diff --git a/src/framework/mem/dmm_shmem_mng.h b/src/framework/mem/dmm_shmem_mng.h
new file mode 100644
index 0000000..c267858
--- /dev/null
+++ b/src/framework/mem/dmm_shmem_mng.h
@@ -0,0 +1,54 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#ifndef _DMM_SHMEM_MNG_H
+#define _DMM_SHMEM_MNG_H
+
+#include <unistd.h>
+#include <stdlib.h>
+#include "nsfw_mem_api.h"
+#include "types.h"
+
+i32 dmm_shmem_init(nsfw_mem_para * para);
+void dmm_shmem_destroy(void);
+mzone_handle dmm_shmem_create(nsfw_mem_zone * pinfo);
+i32 dmm_shmem_createv(nsfw_mem_zone * pmeminfo, i32 inum,
+ mzone_handle * paddr_array, i32 iarray_num);
+mzone_handle dmm_shmem_lookup(nsfw_mem_name * pname);
+i32 dmm_shmem_release(nsfw_mem_name * pname);
+mpool_handle dmm_shmem_mbfmpcreate(nsfw_mem_mbfpool * pbufinfo);
+i32 dmm_shmem_mbfmpcreatev(nsfw_mem_mbfpool * pmbfname, i32 inum,
+ mpool_handle * phandle_array, i32 iarray_num);
+mpool_handle dmm_shmem_mbfmplookup(nsfw_mem_name * pmbfname);
+i32 dmm_shmem_mbfmprelease(nsfw_mem_name * pname);
+i32 dmm_shmem_spcreatev(nsfw_mem_sppool * pmpinfo, i32 inum,
+ mring_handle * pringhandle_array, i32 iarray_num);
+i32 dmm_shmem_sp_ringcreate(nsfw_mem_mring * prpoolinfo,
+ mring_handle * pringhandle_array, i32 iringnum);
+i32 dmm_shmem_sprelease(nsfw_mem_name * pname);
+mring_handle dmm_shmem_sp_lookup(nsfw_mem_name * pname);
+mring_handle dmm_shmem_ringcreate(nsfw_mem_mring * pringinfo);
+mring_handle dmm_shmem_ring_lookup(nsfw_mem_name * pname);
+i32 dmm_shmem_ringrelease(nsfw_mem_name * pname);
+size_t dmm_shmem_sppool_statics(mring_handle sppool);
+size_t dmm_shmem_ring_statics(mring_handle handle);
+ssize_t dmm_shmem_stactic(void *handle, nsfw_mem_struct_type type);
+i32 dmm_shmem_sp_iterator(mpool_handle handle, u32 start, u32 end,
+ nsfw_mem_item_fun fun, void *argv);
+void *dmm_shmem_shddr_to_laddr(void *addr);
+uint64_t dmm_shmem_laddr_to_shddr(void *addr);
+int dmm_attach_core_id(nsfw_mem_name * name);
+#endif
diff --git a/src/framework/mem/nsfw_mem_api.c b/src/framework/mem/nsfw_mem_api.c
new file mode 100644
index 0000000..7517faa
--- /dev/null
+++ b/src/framework/mem/nsfw_mem_api.c
@@ -0,0 +1,932 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <dlfcn.h>
+#include "nsfw_mem_api.h"
+#include "nstack_securec.h"
+#include "nsfw_ring_data.h"
+#include "nsfw_init_api.h"
+
+#define MEM_OP_CALL_OK_RET(mtype, fun, para) { \
+ if (g_nsfw_mem_ops[mtype].stmemop->fun) \
+ { \
+ return g_nsfw_mem_ops[mtype].stmemop->fun para; \
+ } \
+ }
+#define NSFW_MEM_NAME_CHECK_RET_ERR(pname, desc) {\
+ if ((NULL == (pname)) || ((pname)->entype >= NSFW_MEM_TYPEMAX)) \
+ { \
+ NSRTP_LOGERR("input para error]desc=%s,pname=%p,mtype=%d", desc, pname, (pname) ? (pname)->entype:-1); \
+ return NSFW_MEM_ERR; \
+ } \
+ }
+
+#define NSFW_MEM_NAME_CHECK_RET_NULL(pname, desc) {\
+ if ((NULL == (pname)) || ((pname)->entype >= NSFW_MEM_TYPEMAX)) \
+ { \
+ NSRTP_LOGERR("input para error]desc=%s,pname=%p,mtype=%d", desc, pname, (pname) ? (pname)->entype:-1); \
+ return NULL; \
+ } \
+ }
+
+#define NSFW_MEM_RING_CHECK_RET(pringinfo, pringhandle_array, iringnum) {\
+ if ((NULL == pringinfo) || (NULL == pringhandle_array) || (pringinfo[0].stname.entype >= NSFW_MEM_TYPEMAX)) \
+ { \
+ NSRTP_LOGERR("input para error]pringinfo=%p,iringnum=%d,pringhandle_array=%p,mtype=%d", \
+ pringinfo, iringnum, pringhandle_array, pringinfo ? pringinfo[0].stname.entype : (-1)); \
+ return NSFW_MEM_ERR; \
+ } \
+ }
+
+#define NSFW_MEM_RINGV_CHECK_RET(pmpinfo, inum, pringhandle_array, iarray_num) { \
+ if ((NULL == pmpinfo) || (NULL == pringhandle_array) \
+ || (inum != iarray_num) || (inum <= 0) || (pmpinfo[0].stname.entype >= NSFW_MEM_TYPEMAX)) \
+ { \
+ NSRTP_LOGERR("input para error]pmpinfo=%p,inum=%d,pringhandle_array=%p,iarray_num=%d,entype=%d", \
+ pmpinfo, inum, pringhandle_array, iarray_num, pmpinfo ? pmpinfo[0].stname.entype : (-1)); \
+ return NSFW_MEM_ERR; \
+ } \
+ }
+
+#ifndef FOR_ATTACH_COREID
+/*
+ * attach core id when malloc resource
+ */
+static int nsfw_attach_core_id(nsfw_mem_name * name)
+{
+ MEM_OP_CALL_OK_RET(NSFW_SHMEM, mem_ops_attach_core_id, (name));
+ NSRTP_LOGINF
+ ("nsfw_attach_core_id failed]field mem_ops_attach_core_id is NULL");
+ return -1;
+}
+#endif
+
+i32 nsfw_mem_init(void *para)
+{
+ nsfw_mem_para *ptempara = NULL;
+ i32 iret = NSFW_MEM_OK;
+ i32 icount = 0;
+ i32 iindex = 0;
+
+ if (NULL == para)
+ {
+ NSRTP_LOGERR("ns mem init input error");
+ return NSFW_MEM_ERR;
+ }
+
+ ptempara = (nsfw_mem_para *) para;
+
+ if (ptempara->enflag >= NSFW_PROC_MAX)
+ {
+ NSRTP_LOGERR("ns mem init input enflag invalid]enflag=%d",
+ ptempara->enflag);
+ return NSFW_MEM_ERR;
+ }
+
+ NSRTP_LOGINF("ns mem init begin]enflag=%d,iargsnum=%d", ptempara->enflag,
+ ptempara->iargsnum);
+
+ for (iindex = 0; iindex < ptempara->iargsnum; iindex++)
+ {
+ NSRTP_LOGINF("%s", ptempara->pargs[iindex]);
+ }
+
+ for (icount = 0; icount < g_mem_type_num; icount++)
+ {
+ if ((NULL != g_nsfw_mem_ops[icount].stmemop)
+ && (NULL != g_nsfw_mem_ops[icount].stmemop->mem_ops_init))
+ {
+ iret = g_nsfw_mem_ops[icount].stmemop->mem_ops_init(ptempara);
+
+ if (NSFW_MEM_OK != iret)
+ {
+ NSRTP_LOGERR("mem init failed]index=%d,memtype=%d", icount,
+ g_nsfw_mem_ops[icount].entype);
+ break;
+ }
+ }
+ }
+
+ /* if some module init fail, destory the modules that succeeded */
+ if (icount < g_mem_type_num)
+ {
+ for (iindex = 0; iindex < icount; iindex++)
+ {
+ if (g_nsfw_mem_ops[icount].stmemop->mem_ops_destroy)
+ {
+ g_nsfw_mem_ops[icount].stmemop->mem_ops_destroy();
+ }
+ }
+
+ return iret; /* return errcode to caller */
+ }
+
+ NSRTP_LOGINF("mem init end");
+ return NSFW_MEM_OK;
+}
+
+/*****************************************************************************
+* Prototype : nsfw_mem_zone_create
+* Description : create a block memory with name
+* nsfw_mem_zone::stname
+* nsfw_mem_zone::isize
+* note : 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
+* Input : nsfw_mem_zone* pinfo
+* Output : None
+* Return Value : mzone_handle
+* Calls :
+* Called By :
+*****************************************************************************/
+mzone_handle nsfw_mem_zone_create(nsfw_mem_zone * pinfo)
+{
+ if ((NULL == pinfo) || (pinfo->stname.entype >= NSFW_MEM_TYPEMAX))
+ {
+ NSRTP_LOGERR("zone create input para error] pinfo=%p, mtype=%d",
+ pinfo, pinfo ? pinfo->stname.entype : (-1));
+ return NULL;
+ }
+
+#ifndef FOR_ATTACH_COREID
+ if (nsfw_attach_core_id(&pinfo->stname) != 0)
+ {
+ return NULL;
+ }
+#endif
+
+ MEM_OP_CALL_OK_RET(pinfo->stname.entype, mem_ops_zone_creae, (pinfo));
+ NSRTP_LOGINF("mem create fail] memtype=%d, name=%s, size=%zu",
+ pinfo->stname.entype, pinfo->stname.aname, pinfo->lenth);
+ return NULL;
+}
+
+/*****************************************************************************
+* Prototype : nsfw_mem_zone_createv
+* Description : create some memory blocks
+* note : 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
+* Input : nsfw_mem_zone* pmeminfo
+* i32 inum
+* mzone_handle* paddr_array
+* i32 iarray_num
+* Output : None
+* Return Value : i32
+* Calls :
+* Called By :
+*****************************************************************************/
+i32 nsfw_mem_zone_createv(nsfw_mem_zone * pmeminfo, i32 inum,
+ mzone_handle * paddr_array, i32 iarray_num)
+{
+ if ((NULL == pmeminfo) || (NULL == paddr_array)
+ || (inum != iarray_num) || (inum <= 0)
+ || (pmeminfo[0].stname.entype >= NSFW_MEM_TYPEMAX))
+ {
+ NSRTP_LOGERR
+ ("input para error] pmeminfo=%p, inum=%d, paddr_array=%p, iarray_num=%d, mtype=%d",
+ pmeminfo, inum, paddr_array, iarray_num,
+ pmeminfo ? pmeminfo[0].stname.entype : (-1));
+ return NSFW_MEM_ERR;
+ }
+
+#ifndef FOR_ATTACH_COREID
+ i32 i;
+ for (i = 0; i < inum; ++i)
+ {
+ if (nsfw_attach_core_id(&pmeminfo[i].stname) != 0)
+ {
+ return NSFW_MEM_ERR;
+ }
+ }
+#endif
+
+ MEM_OP_CALL_OK_RET(pmeminfo[0].stname.entype, mem_ops_zone_createv,
+ (pmeminfo, inum, paddr_array, iarray_num));
+ NSRTP_LOGINF("mem create fail] memtype=%d", pmeminfo[0].stname.entype);
+ return NSFW_MEM_ERR;
+}
+
+/*****************************************************************************
+* Prototype : nsfw_mem_zone_lookup
+* Description : look up a memory
+* 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
+* 2. if the memory is shared, pname->enowner indicate that who create this memory.
+* note : 1. when calling any shared memory create inferface, the name of memory end with _0 created by daemon-stack,
+* end with none created by nStackMaster, and end with _<pid> created by other.
+* 2. pname->enowner is available only when call look up shared memory.
+* 3. if the roles of process is NSFW_PROC_MASTER but the memory was created by others, or pname->enowner is NSFW_PROC_NULL,
+* the name must be full name.
+* for examles if the memory was created by daemon-stack and pname->enowner is NSFW_PROC_NULL,
+* must add '_0' at the end of name, if the memory was created by app and the role of process is NSFW_PROC_MASTER, must add
+* _(pid) at the end of name, nstack_123.
+* Input : nsfw_mem_name* pname
+* Output : None
+* Return Value : mzone_handle
+* Calls :
+* Called By :
+*****************************************************************************/
+mzone_handle nsfw_mem_zone_lookup(nsfw_mem_name * pname)
+{
+ NSFW_MEM_NAME_CHECK_RET_NULL(pname, "mem zone look up");
+
+#ifndef FOR_ATTACH_COREID
+ if (nsfw_attach_core_id(pname) != 0)
+ {
+ return NULL;
+ }
+#endif
+
+ MEM_OP_CALL_OK_RET(pname->entype, mem_ops_zone_lookup, (pname));
+ NSRTP_LOGERR("mem lookup fail] memtype=%d, name=%s ", pname->entype,
+ pname->aname);
+ return NULL;
+}
+
+i32 nsfw_mem_zone_release(nsfw_mem_name * pname)
+{
+ NSFW_MEM_NAME_CHECK_RET_ERR(pname, "mem zone release");
+
+#ifndef FOR_ATTACH_COREID
+ if (nsfw_attach_core_id(pname) != 0)
+ {
+ return NSFW_MEM_ERR;
+ }
+#endif
+
+ MEM_OP_CALL_OK_RET(pname->entype, mem_ops_mzone_release, (pname));
+ NSRTP_LOGERR("mem release fail] memtype=%d, name=%s", pname->entype,
+ pname->aname);
+ return NSFW_MEM_ERR;
+
+}
+
+/*****************************************************************************
+* Prototype : nsfw_mem_mbfmp_create
+* Description : create a mbuf pool
+* Input : nsfw_mem_mbfpool* pbufinfo
+* Output : None
+* Return Value : mpool_handle
+* Calls :
+* Called By :
+*****************************************************************************/
+mpool_handle nsfw_mem_mbfmp_create(nsfw_mem_mbfpool * pbufinfo)
+{
+ if ((NULL == pbufinfo) || (pbufinfo->stname.entype >= NSFW_MEM_TYPEMAX))
+ {
+ NSRTP_LOGERR("input para error] pbufinfo=%p, mtype=%d", pbufinfo,
+ pbufinfo ? pbufinfo->stname.entype : (-1));
+ return NULL;
+ }
+
+#ifndef FOR_ATTACH_COREID
+ if (nsfw_attach_core_id(&pbufinfo->stname) != 0)
+ {
+ return NULL;
+ }
+#endif
+
+ MEM_OP_CALL_OK_RET(pbufinfo->stname.entype, mem_ops_mbfmp_create,
+ (pbufinfo));
+ NSRTP_LOGERR("mbufmp create fail] memtype=%d, name=%s ",
+ pbufinfo->stname.entype, pbufinfo->stname.aname);
+ return NULL;
+}
+
+/*****************************************************************************
+* Prototype : nsfw_mem_mbfmp_createv
+* Description : create some mbuf pools
+* 1. the name of lenth must be less than NSFW_MEM_APPNAME_LENTH.
+* Input : nsfw_mem_mbfpool* pmbfname
+* i32 inum
+* mpool_handle* phandle_array
+* i32 iarray_num
+* Output : None
+* Return Value : i32
+* Calls :
+* Called By :
+*****************************************************************************/
+i32 nsfw_mem_mbfmp_createv(nsfw_mem_mbfpool * pmbfname, i32 inum,
+ mpool_handle * phandle_array, i32 iarray_num)
+{
+ if ((NULL == pmbfname) || (NULL == phandle_array)
+ || (inum != iarray_num) || (inum <= 0)
+ || (pmbfname[0].stname.entype >= NSFW_MEM_TYPEMAX))
+ {
+ NSRTP_LOGERR
+ ("input para error] pmbfname=%p, inum=%d, phandle_array=%p, iarray_num=%d,entype=%d",
+ pmbfname, inum, phandle_array, iarray_num,
+ pmbfname ? pmbfname[0].stname.entype : (-1));
+ return NSFW_MEM_ERR;
+ }
+
+#ifndef FOR_ATTACH_COREID
+ i32 i;
+ for (i = 0; i < inum; ++i)
+ {
+ if (nsfw_attach_core_id(&pmbfname[i].stname) != 0)
+ {
+ return NSFW_MEM_ERR;
+ }
+ }
+#endif
+
+ MEM_OP_CALL_OK_RET(pmbfname[0].stname.entype, mem_ops_mbfmp_createv,
+ (pmbfname, inum, phandle_array, iarray_num));
+ NSRTP_LOGERR("mbufmp createv fail] memtype=%d",
+ pmbfname[0].stname.entype);
+ return NSFW_MEM_ERR;
+}
+
+/*****************************************************************************
+* Prototype : nsfw_mem_mbfmp_lookup
+* Description : look up mbuf mpool
+* 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
+* 2. if the memory is shared, pname->enowner indicate that who create this memory.
+* note : 1. when calling any shared memory create inferface, the name of memory end with _0 created by daemon-stack,
+* end with none created by nStackMaster, and end with _<pid> created by other.
+* 2. pname->enowner is available only when call look up shared memory.
+* 3. if the roles of process is NSFW_PROC_MASTER but the memory was created by others, or pname->enowner is NSFW_PROC_NULL,
+* the name must be full name.
+* for examles if the memory was created by daemon-stack and pname->enowner is NSFW_PROC_NULL,
+* must add '_0' at the end of name, if the memory was created by app and the role of process is NSFW_PROC_MASTER, must add
+* _(pid) at the end of name, nstack_123.
+* Input : nsfw_mem_name* pmbfname
+* Output : None
+* Return Value : mpool_handle
+* Calls :
+* Called By :
+*****************************************************************************/
+mpool_handle nsfw_mem_mbfmp_lookup(nsfw_mem_name * pmbfname)
+{
+ NSFW_MEM_NAME_CHECK_RET_NULL(pmbfname, "mbuf pool look up");
+
+#ifndef FOR_ATTACH_COREID
+ if (nsfw_attach_core_id(pmbfname) != 0)
+ {
+ return NULL;
+ }
+#endif
+
+ MEM_OP_CALL_OK_RET(pmbfname->entype, mem_ops_mbfmp_lookup, (pmbfname));
+ NSRTP_LOGERR("mbufmp lookup fail] memtype=%d, name=%s ",
+ pmbfname->entype, pmbfname->aname);
+ return NULL;
+}
+
+/*****************************************************************************
+* Prototype : nsfw_mem_mbfmp_release
+* Description : release mbuf pool
+* note : 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
+* Input : nsfw_mem_name* pname
+* Output : None
+* Return Value : i32
+* Calls :
+* Called By :
+*****************************************************************************/
+i32 nsfw_mem_mbfmp_release(nsfw_mem_name * pname)
+{
+ NSFW_MEM_NAME_CHECK_RET_ERR(pname, "mbuf mp release");
+
+#ifndef FOR_ATTACH_COREID
+ if (nsfw_attach_core_id(pname) != 0)
+ {
+ return NSFW_MEM_ERR;
+ }
+#endif
+
+ MEM_OP_CALL_OK_RET(pname->entype, mem_ops_mbfmp_release, (pname));
+ NSRTP_LOGERR("mbfmp release fail] memtype=%d, name=%s", pname->entype,
+ pname->aname);
+ return NSFW_MEM_ERR;
+}
+
+/*****************************************************************************
+* Prototype : nsfw_mem_sp_create
+* Description : create a simple pool
+* note : 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
+* Input : nsfw_mem_sppool* pmpinfo
+* Output : None
+* Return Value : mring_handle
+* Calls :
+* Called By :
+*****************************************************************************/
+mring_handle nsfw_mem_sp_create(nsfw_mem_sppool * pmpinfo)
+{
+ if ((NULL == pmpinfo) || (pmpinfo->stname.entype >= NSFW_MEM_TYPEMAX))
+ {
+ NSRTP_LOGERR("input para error] pmpinfo=%p, mtype=%d", pmpinfo,
+ pmpinfo ? pmpinfo->stname.entype : (-1));
+ return NULL;
+ }
+
+#ifndef FOR_ATTACH_COREID
+ if (nsfw_attach_core_id(&pmpinfo->stname) != 0)
+ {
+ return NULL;
+ }
+#endif
+
+ MEM_OP_CALL_OK_RET(pmpinfo->stname.entype, mem_ops_sp_create, (pmpinfo));
+ NSRTP_LOGERR("sp create fail] memtype=%d, name=%s ",
+ pmpinfo->stname.entype, pmpinfo->stname.aname);
+ return NULL;
+
+}
+
+/*****************************************************************************
+* Prototype : nsfw_mem_sp_createv
+* Description : create some simple pools one time
+* note : 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
+* Input : nsfw_mem_sppool* pmpinfo
+* i32 inum
+* mring_handle* pringhandle_array
+* i32 iarray_num
+* Output : None
+* Return Value : i32
+* Calls :
+* Called By :
+*****************************************************************************/
+i32 nsfw_mem_sp_createv(nsfw_mem_sppool * pmpinfo, i32 inum,
+ mring_handle * pringhandle_array, i32 iarray_num)
+{
+ NSFW_MEM_RINGV_CHECK_RET(pmpinfo, inum, pringhandle_array, iarray_num);
+
+#ifndef FOR_ATTACH_COREID
+ i32 i;
+ for (i = 0; i < inum; ++i)
+ {
+ if (nsfw_attach_core_id(&pmpinfo[i].stname) != 0)
+ {
+ return NSFW_MEM_ERR;
+ }
+ }
+#endif
+
+ MEM_OP_CALL_OK_RET(pmpinfo[0].stname.entype, mem_ops_sp_createv,
+ (pmpinfo, inum, pringhandle_array, iarray_num));
+ NSRTP_LOGERR("sp createv fail] memtype=%d", pmpinfo[0].stname.entype);
+ return NSFW_MEM_ERR;
+
+}
+
+/*****************************************************************************
+* Prototype : nsfw_mem_sp_ring_create
+* Description : create a simple pool with many rings
+* note : 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
+* Input : nsfw_mem_mring* pringinfo
+* mring_handle* pringhandle_array
+* i32 iringnum
+* Output : None
+* Return Value : i32
+* Calls :
+* Called By :
+*****************************************************************************/
+i32 nsfw_mem_sp_ring_create(nsfw_mem_mring * pringinfo,
+ mring_handle * pringhandle_array, i32 iringnum)
+{
+ NSFW_MEM_RING_CHECK_RET(pringinfo, pringhandle_array, iringnum);
+
+#ifndef FOR_ATTACH_COREID
+ if (nsfw_attach_core_id(&pringinfo->stname) != 0)
+ {
+ return NSFW_MEM_ERR;
+ }
+#endif
+
+ MEM_OP_CALL_OK_RET(pringinfo[0].stname.entype, mem_ops_spring_create,
+ (pringinfo, pringhandle_array, iringnum));
+ NSRTP_LOGERR("mppool spring creat fail] memtype=%d",
+ pringinfo[0].stname.entype);
+ return NSFW_MEM_ERR;
+
+}
+
+/*****************************************************************************
+* Prototype : nsfw_mem_sp_release
+* Description : release a simple mempool
+* note : 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
+* Input : nsfw_mem_name* pname
+* Output : None
+* Return Value : i32
+* Calls :
+* Called By :
+*****************************************************************************/
+i32 nsfw_mem_sp_release(nsfw_mem_name * pname)
+{
+ NSFW_MEM_NAME_CHECK_RET_ERR(pname, "sp release");
+
+#ifndef FOR_ATTACH_COREID
+ if (nsfw_attach_core_id(pname) != 0)
+ {
+ return NSFW_MEM_ERR;
+ }
+#endif
+
+ MEM_OP_CALL_OK_RET(pname->entype, mem_ops_sp_release, (pname));
+ NSRTP_LOGERR("sp release fail] memtype=%d, name=%s ", pname->entype,
+ pname->aname);
+ return NSFW_MEM_ERR;
+}
+
+/*****************************************************************************
+* Prototype : nsfw_mem_sp_lookup
+* Description : look up a simpile ring
+* 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
+* 2. if the memory is shared, pname->enowner indicate that who create this memory.
+* note : 1. when calling any shared memory create inferface, the name of memory end with _0 created by daemon-stack,
+* end with none created by nStackMaster, and end with _<pid> created by other.
+* 2. pname->enowner is available only when call look up shared memory.
+* 3. if the roles of process is NSFW_PROC_MASTER but the memory was created by others, or pname->enowner is NSFW_PROC_NULL,
+* the name must be full name.
+* for examles if the memory was created by daemon-stack and pname->enowner is NSFW_PROC_NULL,
+* must add '_0' at the end of name, if the memory was created by app and the role of process is NSFW_PROC_MASTER, must add
+* _(pid) at the end of name, nstack_123.
+* Input : nsfw_mem_name* pname
+* Output : None
+* Return Value : mring_handle
+* Calls :
+* Called By :
+*****************************************************************************/
+mring_handle nsfw_mem_sp_lookup(nsfw_mem_name * pname)
+{
+ NSFW_MEM_NAME_CHECK_RET_NULL(pname, "sp look up");
+
+#ifndef FOR_ATTACH_COREID
+ if (nsfw_attach_core_id(pname) != 0)
+ {
+ return NULL;
+ }
+#endif
+
+ MEM_OP_CALL_OK_RET(pname->entype, mem_ops_sp_lookup, (pname));
+ NSRTP_LOGERR("sp lookup fail] memtype=%d, name=%s", pname->entype,
+ pname->aname);
+ return NULL;
+
+}
+
+/*****************************************************************************
+* Prototype : nsfw_mem_ring_create
+* Description : create a ring
+* note : 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
+* 2. shared memory ring (NSFW_SHMEM) just can put a pointor into the queue, the queue also point to a shared block memory.
+* no shared memory ring(NSFW_NSHMEM) is other wise.
+* Input : nsfw_mem_mring* pringinfo
+* Output : None
+* Return Value : mring_handle
+* Calls :
+* Called By :
+*****************************************************************************/
+mring_handle nsfw_mem_ring_create(nsfw_mem_mring * pringinfo)
+{
+ if ((NULL == pringinfo) || (pringinfo->stname.entype >= NSFW_MEM_TYPEMAX))
+ {
+ NSRTP_LOGERR("input para error] pmpinfo=%p, mtype=%d", pringinfo,
+ pringinfo ? pringinfo->stname.entype : (-1));
+ return NULL;
+ }
+
+#ifndef FOR_ATTACH_COREID
+ if (nsfw_attach_core_id(&pringinfo->stname) != 0)
+ {
+ NSRTP_LOGERR
+ ("nsfw_attach_core_id failed] type=%d, owner=%d, name=%s",
+ pringinfo->stname.entype, pringinfo->stname.enowner,
+ pringinfo->stname.aname);
+ return NULL;
+ }
+#endif
+
+ MEM_OP_CALL_OK_RET(pringinfo->stname.entype, mem_ops_ring_create,
+ (pringinfo));
+ NSRTP_LOGERR("ring create fail] memtype=%d, name=%s ",
+ pringinfo->stname.entype, pringinfo->stname.aname);
+ return NULL;
+}
+
+/*****************************************************************************
+* Prototype : nsfw_mem_ring_lookup
+* Description : look up a ring by name
+* 1. the lenth of name must be less than NSFW_MEM_APPNAME_LENTH.
+* 2. if the memory is shared, pname->enowner indicate that who create this memory.
+* note:
+* 1. when calling any shared memory create inferface, the name of memory end with _0 created by daemon-stack,
+* end with none created by nStackMaster, and end with _<pid> created by other.
+* 2. pname->enowner is available only when call look up shared memory.
+* 3. if the roles of process is NSFW_PROC_MASTER but the memory was created by others, or pname->enowner is NSFW_PROC_NULL,
+* the name must be full name.
+* for examles if the memory was created by daemon-stack and pname->enowner is NSFW_PROC_NULL,
+* must add '_0' at the end of name, if the memory was created by app and the role of process is NSFW_PROC_MASTER, must add
+* _(pid) at the end of name, nstack_123.
+* Input : nsfw_mem_name* pname
+* Output : None
+* Return Value : mring_handle
+* Calls :
+* Called By :
+*****************************************************************************/
+mring_handle nsfw_mem_ring_lookup(nsfw_mem_name * pname)
+{
+ NSFW_MEM_NAME_CHECK_RET_NULL(pname, "ring lookup");
+
+#ifndef FOR_ATTACH_COREID
+ if (nsfw_attach_core_id(pname) != 0)
+ {
+ return NULL;
+ }
+#endif
+
+ MEM_OP_CALL_OK_RET(pname->entype, mem_ops_ring_lookup, (pname));
+ NSRTP_LOGERR("ring lookup fail] memtype=%d, name=%s", pname->entype,
+ pname->aname);
+ return NULL;
+}
+
+/*****************************************************************************
+* Prototype : nsfw_mem_ring_reset
+* Description : reset the number of producer and consumer, also, the
+* state of ring reset to empty
+* notes : must be called before doing any operations base on the ring
+* Input : mring_handle mhandle
+* nsfw_mpool_type entype
+* Output : None
+* Return Value : void
+* Calls :
+* Called By :
+*****************************************************************************/
+void nsfw_mem_ring_reset(mring_handle mhandle, nsfw_mpool_type entype)
+{
+ u32 loop = 0;
+ struct nsfw_mem_ring *ring = (struct nsfw_mem_ring *) mhandle;
+
+ if (!ring)
+ {
+ return;
+ }
+
+ ring->prod.head = 0;
+ ring->cons.tail = 0;
+ ring->ringflag = (u8) entype;
+
+ /*init Ring */
+ for (loop = 0; loop < ring->size; loop++)
+ {
+ /*
+ for a empty ring, version is the mapping head val - size
+ so the empty ring's ver is loop-size;
+ */
+ ring->ring[loop].data_s.ver = (loop - ring->size);
+ ring->ring[loop].data_s.val = 0;
+ }
+
+ return;
+}
+
+/*****************************************************************************
+* Prototype : nsfw_mem_ring_free_count
+* Description : get the free number of ring
+* Input : mring_handle mhandle
+* Output : None
+* Return Value : u32
+* Calls :
+* Called By :
+*****************************************************************************/
+u32 nsfw_mem_ring_free_count(mring_handle mhandle)
+{
+ struct nsfw_mem_ring *temp = NULL;
+ u32 thead = 0;
+ u32 ttail = 0;
+ u32 using_count = 0;
+ if (NULL == mhandle)
+ {
+ NSRTP_LOGERR("input para error] mhandle=%p", mhandle);
+ return 0;
+ }
+
+ temp = (struct nsfw_mem_ring *) mhandle;
+
+ /* avoid multi-thread issue, here we should get cons.tail firstly, get prod.head later
+ because tail and head is always ++ */
+ /* optimize nsfw_mem_ring_using_count(), avoid return abnormal value */
+ ttail = temp->cons.tail;
+ thead = temp->prod.head;
+
+ using_count = thead - ttail;
+ if (using_count > temp->size)
+ {
+ /* nsfw_mem_ring_using_count will return abnormal lagre value */
+ using_count = 0;
+ }
+
+ return temp->size - (using_count);
+}
+
+/*****************************************************************************
+* Prototype : nsfw_mem_ring_using_count
+* Description : get the in using number of ring
+* Input : mring_handle mhandle
+* Output : None
+* Return Value : u32
+* Calls :
+* Called By :
+*****************************************************************************/
+u32 nsfw_mem_ring_using_count(mring_handle mhandle)
+{
+ struct nsfw_mem_ring *temp = NULL;
+ u32 thead = 0;
+ u32 ttail = 0;
+ u32 using_count = 0;
+ if (NULL == mhandle)
+ {
+ NSRTP_LOGERR("input para error] mhandle=%p", mhandle);
+ return 0;
+ }
+
+ temp = (struct nsfw_mem_ring *) mhandle;
+ /* avoid multi-thread issue, here we should get cons.tail firstly, get prod.head later
+ because tail and head is always ++ */
+ /* optimize nsfw_mem_ring_using_count(), avoid return abnormal value */
+
+ ttail = temp->cons.tail;
+ thead = temp->prod.head;
+
+ using_count = thead - ttail;
+ if (using_count > temp->size)
+ {
+ /* nsfw_mem_ring_using_count will return abnormal lagre value */
+ using_count = 0;
+ }
+
+ return using_count;
+}
+
+u32 nsfw_mem_ring_size(mring_handle mhandle)
+{
+ struct nsfw_mem_ring *temp = NULL;
+
+ if (NULL == mhandle)
+ {
+ NSRTP_LOGERR("input para error] mhandle=%p", mhandle);
+ return 0;
+ }
+
+ temp = (struct nsfw_mem_ring *) mhandle;
+
+ return temp->size;
+}
+
+i32 nsfw_mem_ring_release(nsfw_mem_name * pname)
+{
+ NSFW_MEM_NAME_CHECK_RET_ERR(pname, "ring release");
+
+#ifndef FOR_ATTACH_COREID
+ if (nsfw_attach_core_id(pname) != 0)
+ {
+ return NSFW_MEM_ERR;
+ }
+#endif
+
+ MEM_OP_CALL_OK_RET(pname->entype, mem_ops_ring_release, (pname));
+ NSRTP_LOGERR("ring release fail] name=%s, type=%d", pname->aname,
+ pname->entype);
+ return NSFW_MEM_ERR;
+
+}
+
+/*****************************************************************************
+* Prototype : nsfw_mem_get_len
+* Description : statics mbufpool, sppool, ring mem size.
+* return: <=0, err happen, >0 mem size
+* NSFW_MEM_MZONE: not surport because you already know the lenth when create
+* Input : void * handle
+* nsfw_mem_struct_type type
+* Output : None
+* Return Value : ssize_t
+* Calls :
+* Called By :
+*****************************************************************************/
+ssize_t nsfw_mem_get_len(void *handle, nsfw_mem_struct_type type)
+{
+ if (NULL == handle)
+ {
+ NSRTP_LOGERR("input para error] handle=%p", handle);
+ return -1;
+ }
+ if ((NSFW_MEM_SPOOL == type) || (NSFW_MEM_RING == type))
+ {
+ struct nsfw_mem_ring *ring = (struct nsfw_mem_ring *) handle;
+ if (ring->memtype >= NSFW_MEM_TYPEMAX)
+ {
+ NSRTP_LOGERR("invalid ring] ring type=%u ,handle=%p",
+ ring->memtype, handle);
+ return -1;
+ }
+ MEM_OP_CALL_OK_RET(ring->memtype, mem_ops_mem_statics,
+ (handle, type));
+ }
+ else
+ {
+ MEM_OP_CALL_OK_RET(NSFW_SHMEM, mem_ops_mem_statics, (handle, type));
+ }
+ return -1;
+}
+
+/*****************************************************************************
+* Prototype : nsfw_mem_sp_iterator
+* Description : spool iterator
+* Input : mpool_handle handle
+* u32 start
+* u32 end
+* nsfw_mem_item_fun fun
+* void *argv
+* Output : None
+* Return Value : i32
+* Calls :
+* Called By :
+*****************************************************************************/
+i32 nsfw_mem_sp_iterator(mpool_handle handle, u32 start, u32 end,
+ nsfw_mem_item_fun fun, void *argv)
+{
+ MEM_OP_CALL_OK_RET(NSFW_SHMEM, mem_ops_sp_iterator,
+ (handle, start, end, fun, argv));
+ return -1;
+}
+
+i32 nsfw_mem_mbuf_iterator(mpool_handle handle, u32 start, u32 end,
+ nsfw_mem_item_fun fun, void *argv)
+{
+ MEM_OP_CALL_OK_RET(NSFW_SHMEM, mem_ops_mbuf_iterator,
+ (handle, start, end, fun, argv));
+ return -1;
+}
+
+i32 nsfw_mem_ring_iterator(mpool_handle handle, nsfw_mem_item_fun fun,
+ void *argv)
+{
+ MEM_OP_CALL_OK_RET(NSFW_SHMEM, mem_ops_ring_iterator,
+ (handle, fun, argv));
+ return -1;
+}
+
+/*****************************************************************************
+* Prototype : nsfw_mem_get_health_info
+* Description : get overflow flag and other info
+* Input : mring_handle mhandle
+* Output : None
+* Return Value :
+* Calls :
+* Called By :
+*****************************************************************************/
+nsfw_mem_ring_health_info nsfw_mem_get_health_info(mring_handle mhandle)
+{
+ struct nsfw_mem_ring *temp = (struct nsfw_mem_ring *) mhandle;
+ nsfw_mem_ring_health_info ring_health_info;
+
+ ring_health_info.overflow_count = 0;
+ ring_health_info.overflow_time.tv_sec = 0;
+ ring_health_info.overflow_time.tv_usec = 0;
+
+ ring_health_info.prod.head = 0;
+ ring_health_info.prod.tail = 0;
+
+ ring_health_info.cons.head = 0;
+ ring_health_info.cons.tail = 0;
+
+ ring_health_info.size = 0;
+ ring_health_info.mask = 0;
+
+ if (NULL == temp)
+ {
+ NSRTP_LOGERR("invalid parameter]");
+ return ring_health_info;
+ }
+ ring_health_info.overflow_count = temp->overflow_count;
+ ring_health_info.overflow_time = temp->overflow_time;
+ ring_health_info.prod.head = temp->prod.head;
+ ring_health_info.prod.tail = temp->prod.tail;
+
+ ring_health_info.cons.head = temp->cons.head;
+ ring_health_info.cons.tail = temp->cons.tail;
+
+ ring_health_info.size = temp->size;
+ ring_health_info.mask = temp->mask;
+
+ return ring_health_info;
+}
+
+/* *INDENT-OFF* */
+NSFW_MODULE_NAME(NSFW_MEM_MGR_MODULE)
+NSFW_MODULE_PRIORITY(10)
+NSFW_MODULE_INIT(nsfw_mem_init)
+/* *INDENT-ON* */
diff --git a/src/framework/mem/nsfw_mem_desc.c b/src/framework/mem/nsfw_mem_desc.c
new file mode 100644
index 0000000..ddb9c94
--- /dev/null
+++ b/src/framework/mem/nsfw_mem_desc.c
@@ -0,0 +1,104 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#include <sys/types.h>
+#include <unistd.h>
+#include "nsfw_mem_api.h"
+#include "dmm_shmem_mng.h"
+#include "dmm_nshmem_mng.h"
+#include "dmm_ring.h"
+
+/* *INDENT-OFF* */
+/*the inferaces accessing memory*/
+static nsfw_mem_ops dmm_shmem_ops =
+{
+ dmm_shmem_init,
+ dmm_shmem_destroy,
+ dmm_shmem_create,
+ NULL,//nsfw_shmem_createv,
+ dmm_shmem_lookup,
+ dmm_shmem_release,
+ NULL,//dmm_shmem_mbfmpcreate,
+ NULL,//dmm_shmem_mbfmpcreatev,
+ NULL,//dmm_shmem_mbfmplookup,
+ NULL,//dmm_shmem_mbfmprelease,
+ NULL,//dmm_shmem_spcreate,
+ NULL,//dmm_shmem_spcreatev,
+ dmm_shmem_sp_ringcreate,
+ dmm_shmem_sprelease,
+ dmm_shmem_sp_lookup,
+ dmm_shmem_ringcreate,
+ dmm_shmem_ring_lookup,
+ dmm_shmem_ringrelease,
+ dmm_shmem_stactic,
+ NULL,//dmm_shmem_sp_iterator,
+ NULL,//nsfw_shmem_mbuf_iterator,
+ NULL,//nsfw_shmem_ring_iterator,
+ dmm_shmem_shddr_to_laddr,
+ dmm_shmem_laddr_to_shddr,
+ dmm_attach_core_id
+};
+
+/*no share memory access inferface*/
+static nsfw_mem_ops dmm_nshmem_ops =
+{
+ dmm_nshmem_init,
+ dmm_nshmem_destory,
+ dmm_nshmem_create,
+ NULL,
+ NULL,//nsfw_nshmem_lookup,
+ NULL,//nsfw_nshmem_release,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ dmm_nshmem_spcreate,
+ NULL,
+ NULL,
+ dmm_nshmem_sprelease,
+ NULL,//nsfw_nshmem_sp_lookup,
+ dmm_nshmem_ringcreate,
+ NULL,
+ dmm_nshmem_ringrelease,
+ dmm_nshmem_stactic,
+ //NULL,
+ NULL,/*mem_ops_sp_iterator*/
+ NULL,/*mem_ops_mbuf_iterator*/
+};
+
+/*the order you add must be NSFW_SHMEM, NSFW_NSHMEM*/
+nsfw_mem_attr g_nsfw_mem_ops[] =
+{
+ {NSFW_SHMEM, &dmm_shmem_ops},
+ {NSFW_NSHMEM, &dmm_nshmem_ops}
+};
+/* *INDENT-ON* */
+
+i32 g_mem_type_num = sizeof(g_nsfw_mem_ops) / sizeof(nsfw_mem_attr);
+
+nsfw_ring_ops g_ring_ops_arry[NSFW_MEM_TYPEMAX][NSFW_MPOOL_TYPEMAX] = {
+ {
+ [NSFW_MRING_MPMC] = {
+ .ring_ops_enqueue = dmm_mem_enqueue,
+ .ring_ops_dequeue = dmm_mem_dequeue}
+ }
+ ,
+ {
+ [NSFW_MRING_MPMC] = {
+ .ring_ops_enqueue = dmm_mem_enqueue,
+ .ring_ops_dequeue = dmm_mem_dequeue}
+ }
+};
diff --git a/src/framework/rd/nstack_rd_api.c b/src/framework/rd/nstack_rd_api.c
new file mode 100644
index 0000000..e791e04
--- /dev/null
+++ b/src/framework/rd/nstack_rd_api.c
@@ -0,0 +1,766 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#include <stdlib.h>
+#include <arpa/inet.h>
+#include "nstack_rd_api.h"
+#include "nstack_rd_data.h"
+#include "nsfw_mem_api.h"
+#include "nsfw_recycle_api.h"
+#include "nstack_log.h"
+#include "nstack_securec.h"
+#include "nsfw_common_defs.h"
+#include "nstack_ip_addr.h"
+
+#define RD_AGE_MAX_TIME 3
+
+rd_route_table *g_rd_table_handle[NSTACK_MAX_MODULE_NUM];
+
+void *nstack_rd_malloc(const char *name)
+{
+ void *p = NULL;
+
+ if (!name)
+ {
+ NSSOC_LOGERR("NULL pointer is not allowed!");
+ return NULL;
+ }
+ if (strlen(name) >= NSFW_MEM_NAME_LENTH)
+ {
+ NSSOC_LOGERR("name length overflow!");
+ return NULL;
+ }
+
+ nsfw_mem_zone zone = {
+ {NSFW_SHMEM, NSFW_PROC_APP, {0}
+ }
+ ,
+ sizeof(rd_route_table),
+ NSFW_SOCKET_ANY,
+ 0
+ };
+
+ if (EOK != strcpy_s(zone.stname.aname, NSFW_MEM_NAME_LENTH, name))
+ {
+ NSSOC_LOGERR("strcpy_s failed!");
+ return NULL;
+ }
+
+ p = nsfw_mem_zone_create(&zone);
+ if (!p)
+ {
+ NSSOC_LOGERR("nstack_rd_malloc failed!");
+ return NULL;
+ }
+
+ nstack_rd_table_clear(p);
+
+ return p;
+}
+
+void *nstack_local_rd_malloc(void)
+{
+ void *p;
+
+ p = malloc(sizeof(rd_route_table));
+ if (!p)
+ {
+ return NULL;
+ }
+ nstack_rd_table_clear(p);
+ return p;
+}
+
+void nstack_local_rd_free(void *p)
+{
+ if (p)
+ free(p);
+}
+
+int nstack_rd_free(const char *name)
+{
+ if (!name)
+ {
+ NSSOC_LOGERR("NULL pointer is not allowed!");
+ return -1;
+ }
+ if (strlen(name) >= NSFW_MEM_NAME_LENTH)
+ {
+ NSSOC_LOGERR("name length overflow!");
+ return -1;
+ }
+
+ nsfw_mem_name pname = {
+ NSFW_SHMEM,
+ NSFW_PROC_APP,
+ {0}
+ };
+
+ if (EOK != strcpy_s(pname.aname, NSFW_MEM_NAME_LENTH, name))
+ {
+ NSSOC_LOGERR("strcpy_s failed!");
+ return -1;
+ }
+
+ return nsfw_mem_zone_release(&pname);
+}
+
+void nstack_rd_table_clear(void *p)
+{
+ rd_route_table *table = (rd_route_table *) p;
+
+ (void) memset_s(table, sizeof(rd_route_table), 0, sizeof(rd_route_table));
+ table->size = NSTACK_RD_DATA_MAX;
+ table->icnt = 0;
+ table->rdtbl_ver = 0;
+ DMM_SPINLOCK_MALLOC(table->rd_lock, 1);
+}
+
+/*****************************************************************************
+* Prototype : nstack_rd_ip_node_insert
+* Description : insert a rd_ip_data into list
+* Input : char *name
+* rd_ip_data *data
+* Output : None
+* Return Value : int
+* Calls :
+* Called By : daemon-stack
+*****************************************************************************/
+int nstack_rd_ip_node_insert(const char *name, rd_ip_data * data, void *table)
+{
+ rd_route_table *handle = (rd_route_table *) table;
+ if (!handle)
+ {
+ NSSOC_LOGERR("nstack rd mng not inited");
+ return -1;
+ }
+ int iindex = 0;
+ rd_route_node *pnode = NULL;
+ int agetime = 0;
+ int ageindex = -1;
+ int freeindex = -1;
+ int repeatflag = 0;
+
+ for (iindex = 0; iindex < NSTACK_RD_DATA_MAX; iindex++)
+ {
+ pnode = &(handle->node[iindex]);
+ /*record the index of first free element */
+ if (RD_NODE_USELESS == pnode->flag)
+ {
+ if (-1 == freeindex)
+ {
+ freeindex = iindex;
+ NSSOC_LOGINF("nstack rd ip free element index:%d was found",
+ iindex);
+ }
+ continue;
+ }
+
+ /*if is using, and repeat just set flag */
+ if (RD_NODE_USING == pnode->flag)
+ {
+ if (MASK_V(pnode->data.ipdata.addr, pnode->data.ipdata.masklen)
+ == MASK_V(data->addr, data->masklen))
+ {
+ NSSOC_LOGWAR
+ ("stack=%s, ip addr=*.*.%u.%u, masklen:%u was repeat",
+ name, FUZZY_IP_VAR(&data->addr), data->masklen);
+ repeatflag = 1;
+ }
+ continue;
+ }
+
+ /*if flag is deleting, just update the age time, if agetime is on, just set flag to free */
+ if (RD_NODE_DELETING == pnode->flag)
+ {
+ pnode->agetime++;
+ if (pnode->agetime >= RD_AGE_MAX_TIME)
+ {
+ pnode->flag = RD_NODE_USELESS;
+ NSSOC_LOGINF
+ ("nstack rd ip element index=%d,addr=*.*.%u.%u,masklen=%u was delete and set to free",
+ iindex, FUZZY_IP_VAR(&pnode->data.ipdata.addr),
+ pnode->data.ipdata.masklen);
+ }
+ /*record delete time */
+ if (agetime < pnode->agetime)
+ {
+ agetime = pnode->agetime;
+ ageindex = iindex;
+ }
+ continue;
+ }
+ }
+
+ /*if repeat, just return */
+ if (1 == repeatflag)
+ {
+ return 0;
+ }
+ if (-1 == freeindex)
+ {
+ if (-1 != ageindex)
+ {
+ freeindex = ageindex;
+ }
+ else
+ {
+ NSSOC_LOGERR
+ ("the rd table is full,nstack=%s, rd addr=*.*.%u.%u, masklen=%u can't be inserted",
+ name, FUZZY_IP_VAR(&data->addr), data->masklen);
+ return -1;
+ }
+ }
+ pnode = &(handle->node[freeindex]);
+ /*if no free found, just reuse the big agetime */
+ dmm_spin_lock_with_pid(&handle->rd_lock);
+ if (EOK != strcpy_s(pnode->data.stack_name, RD_PLANE_NAMELEN, name))
+ {
+ NSSOC_LOGERR("strcpy_s failed]copy_name=%s", name);
+ }
+ pnode->data.type = RD_DATA_TYPE_IP;
+ pnode->agetime = 0;
+ pnode->data.ipdata.addr = data->addr;
+ pnode->data.ipdata.masklen = data->masklen;
+ pnode->data.ipdata.resev[0] = 0;
+ pnode->data.ipdata.resev[1] = 0;
+ pnode->flag = RD_NODE_USING; /*last set */
+ handle->icnt++;
+ __sync_fetch_and_add(&handle->rdtbl_ver, 1); /*[MISRA 2004 Rule 14.2] */
+ dmm_spin_unlock(&handle->rd_lock);
+ NSSOC_LOGINF
+ ("nstack=%s, rd addr=*.*.%u.%u, masklen=%u index was inserted", name,
+ FUZZY_IP_VAR(&data->addr), data->masklen);
+ return 0;
+}
+
+/*****************************************************************************
+* Prototype : nstack_rd_ip_node_delete
+* Description : rd data delete
+* Input : rd_ip_data *data
+* Output : None
+* Return Value : int
+* Calls :
+* Called By : daemon-stack
+*****************************************************************************/
+int nstack_rd_ip_node_delete(rd_ip_data * data, void *table)
+{
+ int iindex = 0;
+ rd_route_table *handle = (rd_route_table *) table;
+ rd_route_node *pnode = NULL;
+
+ if (!handle)
+ {
+ NSSOC_LOGERR("nstack rd mng not inited");
+ return -1;
+ }
+
+ for (iindex = 0; iindex < NSTACK_RD_DATA_MAX; iindex++)
+ {
+ pnode = &(handle->node[iindex]);
+ if ((RD_NODE_USING == pnode->flag)
+ && (MASK_V(pnode->data.ipdata.addr, pnode->data.ipdata.masklen)
+ == MASK_V(data->addr, data->masklen)))
+ {
+ dmm_spin_lock_with_pid(&handle->rd_lock);
+ pnode->flag = RD_NODE_DELETING; /*just set deleting state */
+ pnode->agetime = 0;
+ handle->icnt--;
+ NSSOC_LOGINF
+ ("nstack rd delete:%s, addr=*.*.%u.%u, masklen=%u index:%d was delete",
+ pnode->data.stack_name, FUZZY_IP_VAR(&data->addr),
+ data->masklen, iindex);
+ __sync_fetch_and_add(&handle->rdtbl_ver, 1);
+ dmm_spin_unlock(&handle->rd_lock);
+ NSSOC_LOGINF
+ ("nstack rd delete:%s, addr:0x%x, masklen:%u index:%d was delete",
+ pnode->data.stack_name, ntohl(data->addr), data->masklen,
+ iindex);
+ return 0;
+ }
+ }
+ NSSOC_LOGINF
+ ("nstack rd delete, addr=*.*.%u.%u, masklen=%u index was not found",
+ FUZZY_IP_VAR(&data->addr), data->masklen);
+ return 0;
+}
+
+char *ipv6_ntop(ip6_addr_t host_addr)
+{
+ static char buf[INET6_ADDRSTRLEN];
+ ip6_addr_t net_addr;
+
+ net_addr = host_addr;
+ if (inet_ntop(AF_INET6, &net_addr.addr32, buf, INET6_ADDRSTRLEN) == NULL)
+ {
+ return "invalid IPv6 address";
+ }
+ return buf;
+}
+
+/*****************************************************************************
+* Description : insert a rd_ip6_data into list
+* Called By : daemon-stack
+* Notice : the IP insert is in network order byte
+*****************************************************************************/
+int nstack_rd_ip6_node_insert(const char *name, rd_ip6_data * data,
+ void *table)
+{
+ rd_route_table *handle = (rd_route_table *) table;
+ if (!handle)
+ {
+ NSSOC_LOGERR("nstack rd mng not inited");
+ return -1;
+ }
+ int iindex = 0;
+ rd_route_node *pnode = NULL;
+ int agetime = 0;
+ int ageindex = -1;
+ int freeindex = -1;
+ int repeatflag = 0;
+
+ for (iindex = 0; iindex < NSTACK_RD_DATA_MAX; iindex++)
+ {
+ pnode = &(handle->node[iindex]);
+ /*record the index of first free element */
+ if (RD_NODE_USELESS == pnode->flag)
+ {
+ if (-1 == freeindex)
+ {
+ freeindex = iindex;
+ NSSOC_LOGINF("nstack rd ip free element index:%d was found",
+ iindex);
+ }
+ continue;
+ }
+
+ /*if is using, and repeat just set flag */
+ if (RD_NODE_USING == pnode->flag)
+ {
+ if (ip6_addr_match
+ (&pnode->data.ip6data.addr, &data->addr, data->masklen))
+ {
+ NSSOC_LOGWAR
+ ("nstack:%s, index:%d, old_addr:%s, masklen:%u was repeat",
+ name, iindex, ipv6_ntop(pnode->data.ip6data.addr),
+ data->masklen);
+ repeatflag = 1;
+ }
+ continue;
+ }
+
+ /*if flag is deleting, just update the age time, if agetime is on, just set flag to free */
+ if (RD_NODE_DELETING == pnode->flag)
+ {
+ pnode->agetime++;
+ if (pnode->agetime >= RD_AGE_MAX_TIME)
+ {
+ pnode->flag = RD_NODE_USELESS;
+ NSSOC_LOGINF
+ ("nstack rd ip element index:%d addr:%s, masklen:%u was delete and set to free",
+ iindex, ipv6_ntop(pnode->data.ip6data.addr),
+ pnode->data.ipdata.masklen);
+ }
+ /*record delete time */
+ if (agetime < pnode->agetime)
+ {
+ agetime = pnode->agetime;
+ ageindex = iindex;
+ }
+ continue;
+ }
+ }
+
+ /*if repeat, just return */
+ if (1 == repeatflag)
+ {
+ return 0;
+ }
+ if (-1 == freeindex)
+ {
+ if (-1 != ageindex)
+ {
+ freeindex = ageindex;
+ }
+ else
+ {
+ NSSOC_LOGERR
+ ("the rd table is full,nstack:%s, rd addr:%s, masklen:%u can't be inserted",
+ name, ipv6_ntop(data->addr), data->masklen);
+ return -1;
+ }
+ }
+ pnode = &(handle->node[freeindex]);
+ /*if no free found, just reuse the big agetime */
+ dmm_spin_lock_with_pid(&handle->rd_lock);
+ if (EOK != strcpy_s(pnode->data.stack_name, RD_PLANE_NAMELEN, name))
+ {
+ NSSOC_LOGERR("strcpy_s failed]copy_name=%s", name);
+ }
+ pnode->data.type = RD_DATA_TYPE_IP6;
+ pnode->agetime = 0;
+ pnode->data.ip6data.addr.addr32[0] = data->addr.addr32[0];
+ pnode->data.ip6data.addr.addr32[1] = data->addr.addr32[1];
+ pnode->data.ip6data.addr.addr32[2] = data->addr.addr32[2];
+ pnode->data.ip6data.addr.addr32[3] = data->addr.addr32[3];
+ pnode->data.ip6data.masklen = data->masklen;
+ pnode->flag = RD_NODE_USING; /*last set */
+ handle->icnt++;
+ __sync_fetch_and_add(&handle->rdtbl_ver, 1);
+ dmm_spin_unlock(&handle->rd_lock);
+ NSSOC_LOGINF("nstack:%s, rd addr:%s, masklen:%u index was inserted",
+ name, ipv6_ntop(data->addr), data->masklen);
+ return 0;
+}
+
+/*****************************************************************************
+* Prototype : nstack_rd_ip6_node_delete
+* Description : rd data delete, only set flag
+* Called By : daemon-stack
+* Notice : the IP delete is in network order byte
+*****************************************************************************/
+int nstack_rd_ip6_node_delete(rd_ip6_data * data, void *table)
+{
+ int iindex = 0;
+ rd_route_table *handle = (rd_route_table *) table;
+ rd_route_node *pnode = NULL;
+
+ if (!handle)
+ {
+ NSSOC_LOGERR("nstack rd mng not inited");
+ return -1;
+ }
+
+ for (iindex = 0; iindex < NSTACK_RD_DATA_MAX; iindex++)
+ {
+ pnode = &(handle->node[iindex]);
+ if ((RD_NODE_USING == pnode->flag)
+ &&
+ (ip6_addr_match
+ (&pnode->data.ip6data.addr, &data->addr, data->masklen)))
+ {
+ dmm_spin_lock_with_pid(&handle->rd_lock);
+ pnode->flag = RD_NODE_DELETING; /*just set deleting state */
+ pnode->agetime = 0;
+ handle->icnt--;
+ __sync_fetch_and_add(&handle->rdtbl_ver, 1);
+ dmm_spin_unlock(&handle->rd_lock);
+ NSSOC_LOGINF
+ ("nstack rd delete:%s, addr:%s, masklen:%u index:%d was delete",
+ pnode->data.stack_name, ipv6_ntop(data->addr),
+ data->masklen, iindex);
+ return 0;
+ }
+ }
+ NSSOC_LOGINF("nstack rd delete, addr:%s, masklen:%u index was not found",
+ ipv6_ntop(data->addr), data->masklen);
+ return 0;
+}
+
+NSTACK_STATIC nsfw_rcc_stat rd_recyle_lock(u32 pid, void *pdata, u16 rec_type)
+{
+ int i;
+
+ for (i = 0; i < NSTACK_MAX_MODULE_NUM; i++)
+ {
+ if (g_rd_table_handle[i] && pid == g_rd_table_handle[i]->rd_lock.lock)
+ {
+ (void)
+ __sync_bool_compare_and_swap(&g_rd_table_handle[i]->rd_lock.
+ lock, pid, 0);
+ NSFW_LOGWAR("rd locked]pid=%u", pid);
+ }
+ }
+
+ return NSFW_RCC_CONTINUE;
+}
+
+REGIST_RECYCLE_LOCK_REL(rd_recyle_lock, NULL, NSFW_PROC_NULL)
+ int nstack_rd_type_node_insert(const char *name, rd_type_data * data,
+ void *table)
+{
+ rd_route_table *handle = (rd_route_table *) table;
+ if (!handle || !data)
+ {
+ NSSOC_LOGERR("invalid parameters!");
+ return -1;
+ }
+ int iindex = 0;
+ rd_route_node *pnode = NULL;
+ int agetime = 0;
+ int ageindex = -1;
+ int freeindex = -1;
+ int repeatflag = 0;
+
+ for (iindex = 0; iindex < NSTACK_RD_DATA_MAX; iindex++)
+ {
+ pnode = &(handle->node[iindex]);
+ /*record the index of first free element */
+ if (RD_NODE_USELESS == pnode->flag)
+ {
+ if (-1 == freeindex)
+ {
+ freeindex = iindex;
+ NSSOC_LOGINF("free element index:%d was found", iindex);
+ }
+ continue;
+ }
+
+ /*if is using, and repeat just set flag */
+ if (RD_NODE_USING == pnode->flag)
+ {
+ if (pnode->data.type_data.value == data->value
+ && pnode->data.type_data.attr == data->attr)
+ {
+ NSSOC_LOGWAR("find duplicate node, type:%u", data->value);
+ repeatflag = 1;
+ }
+ continue;
+ }
+
+ /*if flag is deleting, just update the age time, if agetime is on, just set flag to free */
+ if (RD_NODE_DELETING == pnode->flag)
+ {
+ pnode->agetime++;
+ if (pnode->agetime >= RD_AGE_MAX_TIME)
+ {
+ pnode->flag = RD_NODE_USELESS;
+ NSSOC_LOGINF("goint to free node at index:%d", iindex);
+ }
+ /*record delete time */
+ if (agetime < pnode->agetime)
+ {
+ agetime = pnode->agetime;
+ ageindex = iindex;
+ }
+ continue;
+ }
+ }
+
+ /*if repeat, just return */
+ if (1 == repeatflag)
+ {
+ return 0;
+ }
+ if (-1 == freeindex)
+ {
+ if (-1 != ageindex)
+ {
+ freeindex = ageindex;
+ }
+ else
+ {
+ NSSOC_LOGERR("the rd route table:%p is full", handle);
+ return -1;
+ }
+ }
+ pnode = &(handle->node[freeindex]);
+ /*if no free found, just reuse the big agetime */
+ dmm_spin_lock_with_pid(&handle->rd_lock);
+ if (EOK != strcpy_s(pnode->data.stack_name, RD_PLANE_NAMELEN, name))
+ {
+ NSSOC_LOGERR("strcpy_s failed]copy_name=%s", name);
+ }
+ pnode->data.type = RD_DATA_TYPE_TYPE;
+ pnode->data.type_data.value = data->value;
+ pnode->data.type_data.attr = data->attr;
+ pnode->data.type_data.reserved[0] = data->reserved[0];
+ pnode->data.type_data.reserved[1] = data->reserved[1];
+ pnode->data.type_data.reserved[2] = data->reserved[2];
+ pnode->data.type_data.reserved[3] = data->reserved[3];
+ pnode->flag = RD_NODE_USING; /*last set */
+ handle->icnt++;
+ __sync_fetch_and_add(&handle->rdtbl_ver, 1); /*[MISRA 2004 Rule 14.2] */
+ dmm_spin_unlock(&handle->rd_lock);
+ NSSOC_LOGINF("nstack=%s, type:%u attr:%u was inserted", name,
+ data->value, data->attr);
+ return 0;
+}
+
+int nstack_rd_type_node_delete(rd_type_data * data, void *table)
+{
+ int iindex = 0;
+ rd_route_table *handle = (rd_route_table *) table;
+ rd_route_node *pnode = NULL;
+
+ if (!handle || !data)
+ {
+ NSSOC_LOGERR("invalid parameters");
+ return -1;
+ }
+
+ for (iindex = 0; iindex < NSTACK_RD_DATA_MAX; iindex++)
+ {
+ pnode = &(handle->node[iindex]);
+ if ((RD_NODE_USING == pnode->flag)
+ && pnode->data.type_data.value == data->value
+ && pnode->data.type_data.attr == data->attr)
+ {
+ dmm_spin_lock_with_pid(&handle->rd_lock);
+ pnode->flag = RD_NODE_DELETING; /*just set deleting state */
+ pnode->agetime = 0;
+ handle->icnt--;
+ NSSOC_LOGINF
+ ("nstack rd:%s, type:%u, attr:%u at index:%d will be deleted",
+ pnode->data.stack_name, data->value, data->attr, iindex);
+ __sync_fetch_and_add(&handle->rdtbl_ver, 1);
+ dmm_spin_unlock(&handle->rd_lock);
+ NSSOC_LOGINF
+ ("nstack rd:%s, type:%u, attr:%u at index:%d was deleted",
+ pnode->data.stack_name, data->value, data->attr, iindex);
+ return 0;
+ }
+ }
+ NSSOC_LOGINF("nstack rd delete, type:%u attr:%u was not found",
+ data->value, data->attr);
+ return 0;
+}
+
+int nstack_rd_proto_node_insert(const char *name, rd_proto_data * data,
+ void *table)
+{
+ rd_route_table *handle = (rd_route_table *) table;
+ if (!handle || !data)
+ {
+ NSSOC_LOGERR("invalid parameters!");
+ return -1;
+ }
+ int iindex = 0;
+ rd_route_node *pnode = NULL;
+ int agetime = 0;
+ int ageindex = -1;
+ int freeindex = -1;
+ int repeatflag = 0;
+
+ for (iindex = 0; iindex < NSTACK_RD_DATA_MAX; iindex++)
+ {
+ pnode = &(handle->node[iindex]);
+ /*record the index of first free element */
+ if (RD_NODE_USELESS == pnode->flag)
+ {
+ if (-1 == freeindex)
+ {
+ freeindex = iindex;
+ NSSOC_LOGINF("free element index:%d was found", iindex);
+ }
+ continue;
+ }
+
+ /*if is using, and repeat just set flag */
+ if (RD_NODE_USING == pnode->flag)
+ {
+ if (pnode->data.proto_data.value == data->value
+ && pnode->data.proto_data.attr == data->attr)
+ {
+ NSSOC_LOGWAR("find duplicate node, proto:%u", data->value);
+ repeatflag = 1;
+ }
+ continue;
+ }
+
+ /*if flag is deleting, just update the age time, if agetime is on, just set flag to free */
+ if (RD_NODE_DELETING == pnode->flag)
+ {
+ pnode->agetime++;
+ if (pnode->agetime >= RD_AGE_MAX_TIME)
+ {
+ pnode->flag = RD_NODE_USELESS;
+ NSSOC_LOGINF("goint to free node at index:%d", iindex);
+ }
+ /*record delete time */
+ if (agetime < pnode->agetime)
+ {
+ agetime = pnode->agetime;
+ ageindex = iindex;
+ }
+ continue;
+ }
+ }
+
+ /*if repeat, just return */
+ if (1 == repeatflag)
+ {
+ return 0;
+ }
+ if (-1 == freeindex)
+ {
+ if (-1 != ageindex)
+ {
+ freeindex = ageindex;
+ }
+ else
+ {
+ NSSOC_LOGERR("the rd route table:%p is full", handle);
+ return -1;
+ }
+ }
+ pnode = &(handle->node[freeindex]);
+ /*if no free found, just reuse the big agetime */
+ dmm_spin_lock_with_pid(&handle->rd_lock);
+ if (EOK != strcpy_s(pnode->data.stack_name, RD_PLANE_NAMELEN, name))
+ {
+ NSSOC_LOGERR("strcpy_s failed]copy_name=%s", name);
+ }
+ pnode->data.type = RD_DATA_TYPE_PROTO;
+ pnode->data.proto_data.value = data->value;
+ pnode->data.proto_data.attr = data->attr;
+ pnode->flag = RD_NODE_USING; /*last set */
+ handle->icnt++;
+ __sync_fetch_and_add(&handle->rdtbl_ver, 1);
+ dmm_spin_unlock(&handle->rd_lock);
+ NSSOC_LOGINF("nstack=%s, proto:%u attr:%u was inserted", name,
+ data->value, data->attr);
+ return 0;
+}
+
+int nstack_rd_proto_node_delete(rd_proto_data * data, void *table)
+{
+ int iindex = 0;
+ rd_route_table *handle = (rd_route_table *) table;
+ rd_route_node *pnode = NULL;
+
+ if (!handle || !data)
+ {
+ NSSOC_LOGERR("invalid parameters");
+ return -1;
+ }
+
+ for (iindex = 0; iindex < NSTACK_RD_DATA_MAX; iindex++)
+ {
+ pnode = &(handle->node[iindex]);
+ if ((RD_NODE_USING == pnode->flag)
+ && pnode->data.proto_data.value == data->value
+ && pnode->data.proto_data.attr == data->attr)
+ {
+ dmm_spin_lock_with_pid(&handle->rd_lock);
+ pnode->flag = RD_NODE_DELETING; /*just set deleting state */
+ pnode->agetime = 0;
+ handle->icnt--;
+ NSSOC_LOGINF
+ ("nstack rd:%s, proto:%u, attr:%u at index:%d will be deleted",
+ pnode->data.stack_name, data->value, data->attr, iindex);
+ __sync_fetch_and_add(&handle->rdtbl_ver, 1);
+ dmm_spin_unlock(&handle->rd_lock);
+ NSSOC_LOGINF
+ ("nstack rd:%s, proto:%u, attr:%u at index:%d was deleted",
+ pnode->data.stack_name, data->value, data->attr, iindex);
+ return 0;
+ }
+ }
+ NSSOC_LOGINF("nstack rd delete, proto:%u attr:%u was not found",
+ data->value, data->attr);
+ return 0;
+}
diff --git a/src/framework/res/nstack_share_res.c b/src/framework/res/nstack_share_res.c
new file mode 100644
index 0000000..d6024cf
--- /dev/null
+++ b/src/framework/res/nstack_share_res.c
@@ -0,0 +1,270 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#include "nstack_share_res.h"
+#include "nsfw_mem_api.h"
+#include "types.h"
+#include "nstack_securec.h"
+#include "nstack_log.h"
+#include "nsfw_maintain_api.h"
+
+#include "nsfw_ps_api.h"
+
+#define NSTACK_SHARE_RES "nstack_share_res"
+
+#define MAX_DELAY_RECYCLE_SEC 15
+
+typedef struct
+{
+ volatile u16 forking;
+ u8 delay_recycle;
+ u8 delay_tick;
+ volatile u16 child_hbt;
+ u16 old_child_hbt;
+} nstack_fork_recycle;
+
+typedef struct
+{
+ nstack_fork_recycle fork_recycle[NSFW_MAX_PID];
+} nstack_share_res;
+
+NSTACK_STATIC nstack_share_res *g_nstack_share_res;
+NSTACK_STATIC volatile int g_enable_child_hbt = 0;
+
+/* Add dfx timer tick */
+/** global timer tick */
+u64 g_nstack_timer_init_value = 0;
+nstack_tick_info_t g_nstack_timer_tick = {.tick_ptr =
+ &g_nstack_timer_init_value,
+};
+
+int nstack_init_share_res()
+{
+ mzone_handle zone;
+ nsfw_mem_zone param;
+ int ret;
+
+ param.isocket_id = -1;
+ param.lenth = sizeof(nstack_share_res);
+ param.stname.entype = NSFW_SHMEM;
+
+ ret = strcpy_s(param.stname.aname, NSFW_MEM_NAME_LENTH, NSTACK_SHARE_RES);
+ if (EOK != ret)
+ {
+ NSSOC_LOGERR("strcpy_s failed]name=%s,ret=%d", NSTACK_SHARE_RES, ret);
+ return -1;
+ }
+
+ zone = nsfw_mem_zone_create(&param);
+ if (!zone)
+ {
+ NSSOC_LOGERR("nsfw_mem_zone_create failed]name=%s", NSTACK_SHARE_RES);
+ return -1;
+ }
+
+ g_nstack_share_res = (nstack_share_res *) zone;
+ if (EOK !=
+ memset_s(g_nstack_share_res, sizeof(nstack_share_res), 0,
+ sizeof(nstack_share_res)))
+ {
+ NSSOC_LOGERR("memset failed");
+ return -1;
+ }
+
+ NSSOC_LOGDBG("ok");
+ return 0;
+}
+
+NSTACK_STATIC int nstack_lookup_share_res()
+{
+ mzone_handle zone;
+ nsfw_mem_name param;
+
+ param.entype = NSFW_SHMEM;
+ param.enowner = NSFW_PROC_MAIN;
+ if (strcpy_s(param.aname, NSFW_MEM_NAME_LENTH, NSTACK_SHARE_RES) != 0)
+ {
+ NSSOC_LOGERR("strcpy_s failed]name=%s", NSTACK_SHARE_RES);
+ return -1;
+ }
+
+ zone = nsfw_mem_zone_lookup(&param);
+ if (!zone)
+ {
+ NSSOC_LOGERR("nsfw_mem_zone_lookup failed]name=%s", NSTACK_SHARE_RES);
+ return -1;
+ }
+
+ g_nstack_share_res = (nstack_share_res *) zone;
+ NSSOC_LOGDBG("ok");
+ return 0;
+}
+
+/* Add dfx timer tick */
+NSTACK_STATIC int nstack_lookup_share_global_tick()
+{
+ int ret;
+ nsfw_mem_name name = {.entype = NSFW_SHMEM,.enowner = NSFW_PROC_MAIN };
+
+ ret = strcpy_s(name.aname, NSFW_MEM_NAME_LENTH, NSTACK_GLOBAL_TICK_SHM);
+ if (EOK != ret)
+ {
+ NSSOC_LOGERR("strcpy_s failed]name=%s,ret=%d",
+ NSTACK_GLOBAL_TICK_SHM, ret);
+ return -1;
+ }
+
+ g_nstack_timer_tick.tick_ptr = (u64 *) nsfw_mem_zone_lookup(&name);
+ if (NULL == g_nstack_timer_tick.tick_ptr)
+ {
+ NSSOC_LOGERR("Failed to lookup global timer tick memory");
+ return -1;
+ }
+
+ NSSOC_LOGDBG("ok");
+ return 0;
+}
+
+int nstack_attach_share_res()
+{
+ if (nstack_lookup_share_res() != 0)
+ {
+ return -1;
+ }
+
+ /* Add dfx timer tick */
+ if (nstack_lookup_share_global_tick() != 0)
+ {
+ return -1;
+ }
+
+ return 0;
+}
+
+void fork_parent_start(i32 ppid)
+{
+ g_nstack_share_res->fork_recycle[ppid].forking = 1;
+}
+
+/*
+ * if child die, child_hbt will stop changing, parent wait FORK_WAIT_SEC seconds.
+ * otherwise, parent wait until child fork done.
+ */
+void fork_wait_child_done(u32 ppid)
+{
+#define FORK_WAIT_SEC 5
+#define FORK_SLEEP_MS 10
+#define FORK_WAIT_CNT (FORK_WAIT_SEC * 1000 / FORK_SLEEP_MS)
+ u32 wait_cnt = FORK_WAIT_CNT;
+ nstack_fork_recycle *recycle = &g_nstack_share_res->fork_recycle[ppid];
+ while (recycle->forking && wait_cnt)
+ {
+ --wait_cnt;
+ sys_sleep_ns(0, 1000000 * FORK_SLEEP_MS);
+
+ if (recycle->old_child_hbt != recycle->child_hbt)
+ {
+ recycle->old_child_hbt = recycle->child_hbt;
+ wait_cnt = FORK_WAIT_CNT;
+ }
+ }
+
+ if ((0 == wait_cnt) && recycle->forking)
+ {
+ NSSOC_LOGWAR("timeout] waited time=%u,ppid=%u", FORK_WAIT_SEC, ppid);
+ recycle->forking = 0;
+ }
+}
+
+void fork_parent_failed(u32 ppid)
+{
+ g_nstack_share_res->fork_recycle[ppid].forking = 0;
+}
+
+NSTACK_STATIC void *fork_start_child_hbt(void *arg)
+{
+ u32 ppid = (u32) (u64) arg;
+ nstack_fork_recycle *recycle = &g_nstack_share_res->fork_recycle[ppid];
+
+ while (g_enable_child_hbt)
+ {
+ ++recycle->child_hbt;
+ sys_sleep_ns(0, 10);
+ }
+
+ return NULL;
+}
+
+void fork_child_start(u32 ppid)
+{
+ g_enable_child_hbt = 1;
+ pthread_t t;
+ if (pthread_create(&t, NULL, fork_start_child_hbt, (void *) (u64) ppid))
+ {
+ NSPOL_LOGERR("pthread_create failed]ppid=%u", ppid);
+ }
+}
+
+void fork_child_done(u32 ppid)
+{
+ g_enable_child_hbt = 0;
+ g_nstack_share_res->fork_recycle[ppid].forking = 0;
+}
+
+int fork_recycle_check(u32 pid)
+{
+ if (g_nstack_share_res->fork_recycle[pid].forking)
+ {
+ g_nstack_share_res->fork_recycle[pid].delay_recycle = 1;
+ return -1;
+ }
+
+ return 0;
+}
+
+/*
+ * if child die, child_hbt will stop changing, daemon-stack delay MAX_DELAY_RECYCLE_SEC seconds to recycle.
+ * otherwise, daemon-stack delay recycle until child fork done.
+ */
+void fork_delay_recycle(u8 sec, nsfw_recycle_fun fun)
+{
+ u32 i;
+
+ for (i = 0; i < NSFW_MAX_PID; ++i)
+ {
+ nstack_fork_recycle *recycle = &g_nstack_share_res->fork_recycle[i];
+ if (recycle->delay_recycle)
+ {
+ if (recycle->old_child_hbt != recycle->child_hbt)
+ {
+ recycle->old_child_hbt = recycle->child_hbt;
+ recycle->delay_tick = 0;
+ }
+ else
+ {
+ recycle->delay_tick += sec;
+ if (!recycle->forking
+ || (recycle->delay_tick > MAX_DELAY_RECYCLE_SEC))
+ {
+ recycle->delay_recycle = 0;
+ recycle->delay_tick = 0;
+ recycle->forking = 0;
+ (void) fun(i, NULL, 0);
+ }
+ }
+ }
+ }
+}
diff --git a/src/framework/ring/dmm_ring.c b/src/framework/ring/dmm_ring.c
new file mode 100644
index 0000000..24bcf33
--- /dev/null
+++ b/src/framework/ring/dmm_ring.c
@@ -0,0 +1,214 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#include <stdio.h>
+#include <string.h>
+
+#include "nstack_log.h"
+
+#include "dmm_ring.h"
+#include "dmm_ring_base.h"
+#include "nsfw_mem_api.h"
+#include "nstack_securec.h"
+/* enqueue several objects in a ring.
+ ring: point to the ring
+ p: object pointer list array
+ num: number of object
+ fixed: enqueue fixed number
+single_cons: is single producer
+ <return>: number of enqueued object, 0: queue is full
+*/
+inline static int
+dmm_ring_enqueue(struct dmm_ring *ring, void **p, int num,
+ int fixed, int is_sp)
+{
+ int n, pos, new_pos;
+
+ n = dmm_enqueue_prep(ring, num, &pos, fixed, is_sp);
+
+ if (n == 0)
+ return 0;
+
+ new_pos = dmm_enqueue_copy(ring, pos, p, n);
+
+ dmm_enqueue_done(ring, pos, new_pos, is_sp);
+
+ return n;
+}
+
+inline static int dmm_fix_enqueue(struct dmm_ring *ring, void **p, int num)
+{
+ return dmm_ring_enqueue(ring, p, num, 1, ring->is_sp);
+}
+
+inline static int dmm_var_enqueue(struct dmm_ring *ring, void **p, int num)
+{
+ return dmm_ring_enqueue(ring, p, num, 0, ring->is_sp);
+}
+
+inline static int dmm_enqueue(struct dmm_ring *ring, void *p)
+{
+ return dmm_var_enqueue(ring, &p, 1);
+}
+
+inline static int
+dmm_array_enqueue(struct dmm_ring *ring, void *array,
+ int num, size_t elt_size)
+{
+ int n, pos, new_pos;
+
+ n = dmm_enqueue_prep(ring, num, &pos, 0, ring->is_sp);
+
+ if (n == 0)
+ return 0;
+
+ new_pos = dmm_enqueue_copy_array(ring, pos, array, n, elt_size);
+
+ dmm_enqueue_done(ring, pos, new_pos, ring->is_sp);
+
+ return n;
+}
+
+void dmm_ring_dump(struct dmm_ring *ring, int list)
+{
+ if (!ring)
+ return;
+
+ NSFW_LOGINF("ring:%p size:%d flag:0x%x prod:%d-%d/%d cons:%d-%d/%d",
+ ring, ring->size, ring->flag,
+ ring->prod_head, ring->prod_tail, ring->is_sp,
+ ring->cons_head, ring->cons_tail, ring->is_sc);
+ if (list && dmm_ring_count(ring))
+ {
+ int count = 0;
+ void **p = (void **) (ring + 1);
+ int i = ring->cons_head;
+ while (i != ring->prod_tail)
+ {
+ if ((count++ & 3) == 0)
+ NSFW_LOGINF("\n");
+ NSFW_LOGINF(" %d:%p", i, p[i]);
+ if (++i >= ring->size)
+ i = 0;
+ }
+ }
+ NSFW_LOGINF("\n----------------\n");
+}
+
+int
+dmm_ring_init(struct dmm_ring *ring, int num, size_t eltsize, int flag,
+ unsigned char mem_type)
+{
+ if (num > DMM_RING_MAX_NUM)
+ return -1;
+
+ (void) memset_s(ring, sizeof(struct dmm_ring), 0,
+ sizeof(struct dmm_ring));
+
+ ring->memtype = mem_type;
+ ring->ringflag = NSFW_MRING_MPMC;
+
+ ring->size = num + 1;
+ ring->eltsize = eltsize;
+
+ ring->prod_head = 0;
+ ring->prod_tail = 0;
+ ring->is_sp = flag & DMM_RING_INIT_SP;
+
+ ring->cons_head = 0;
+ ring->cons_tail = 0;
+ ring->is_sc = flag & DMM_RING_INIT_SC;
+
+ return 0;
+}
+
+/* dequeue several objects from a ring.
+ ring: point to the ring
+ p: save object array
+ num: number of p
+ fixed: dequeue fixed number
+single_cons: is single consumer
+ <return>: number of dequeued object, 0: queue is empty
+*/
+inline static int
+dmm_ring_dequeue(struct dmm_ring *ring, void **p, int num,
+ int fixed, int single_cons)
+{
+ int n, pos, new_pos;
+
+ n = dmm_dequeue_prep(ring, num, &pos, fixed, single_cons);
+
+ if (n == 0)
+ return 0;
+
+ new_pos = dmm_dequeue_copy(ring, pos, p, n);
+
+ dmm_dequeue_done(ring, pos, new_pos, single_cons);
+
+ return n;
+}
+
+inline static int dmm_fix_dequeue(struct dmm_ring *ring, void **p, int num)
+{
+ return dmm_ring_dequeue(ring, p, num, 1, ring->is_sc);
+}
+
+inline static int dmm_var_dequeue(struct dmm_ring *ring, void **p, int num)
+{
+ return dmm_ring_dequeue(ring, p, num, 0, ring->is_sc);
+}
+
+inline static int dmm_dequeue(struct dmm_ring *ring, void **p)
+{
+ return dmm_var_dequeue(ring, p, 1);
+}
+
+int
+dmm_pool_init(struct dmm_ring *pool, size_t elt_size, int num, int flag,
+ unsigned char memtype)
+{
+ int ret;
+ void *array;
+ const size_t ring_size = dmm_ring_bufsize(num);
+
+ if (0 != dmm_ring_init(pool, num, elt_size, flag, memtype))
+ {
+ NSFW_LOGERR
+ ("init pool's ring failed, num:%d flag:0x%x ring_size:%lu", num,
+ flag, ring_size);
+ return -1;
+ }
+
+ array = (char *) pool + ring_size;
+ ret = dmm_array_enqueue(pool, array, num, elt_size);
+ if (ret != num)
+ {
+ NSFW_LOGERR("enqueue failed, num:%d elt_size:%lu", num, elt_size);
+ return -1;
+ }
+
+ return 0;
+}
+
+int dmm_mem_enqueue(void *ring, void *p)
+{
+ return dmm_enqueue((struct dmm_ring *) ring, p);
+}
+
+int dmm_mem_dequeue(void *ring, void **p)
+{
+ return dmm_dequeue((struct dmm_ring *) ring, p);
+}
diff --git a/src/framework/ring/dmm_ring_base.h b/src/framework/ring/dmm_ring_base.h
new file mode 100644
index 0000000..1f2ce35
--- /dev/null
+++ b/src/framework/ring/dmm_ring_base.h
@@ -0,0 +1,190 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#ifndef _DMM_RING_BASE_H_
+#define _DMM_RING_BASE_H_
+
+#ifndef _DMM_RING_H_
+#error include dmm_ring.h please
+#endif
+
+inline static int
+__move_head(volatile int *head, int ring_size,
+ int old_head, int real_num, int is_single)
+{
+ int new_head = old_head + real_num;
+
+ if (new_head >= ring_size)
+ {
+ new_head -= ring_size;
+ }
+
+ if (is_single)
+ {
+ *head = new_head;
+ return 1;
+ }
+
+ return dmm_atomic_swap((dmm_atomic_t *) head, old_head, new_head);
+}
+
+inline static int
+dmm_enqueue_prep(struct dmm_ring *ring, const int num,
+ int *pos, const int fixed, int is_sp)
+{
+ int succ, real, head;
+ const int ring_size = ring->size;
+
+ do
+ {
+ head = ring->prod_head;
+
+ dmm_barrier();
+
+ if ((real = ring->cons_tail - head - 1) < 0)
+ real += ring_size;
+
+ if (real >= num)
+ real = num;
+ else if (fixed)
+ return 0;
+
+ if (real <= 0)
+ return 0;
+
+ succ = __move_head(&ring->prod_head, ring_size, head, real, is_sp);
+ }
+ while (!succ);
+
+ *pos = head;
+ return real;
+}
+
+inline static int
+dmm_enqueue_copy(struct dmm_ring *ring, int pos, void **from, int num)
+{
+ const int ring_size = ring->size;
+ void **box = (void **) (ring + 1);
+
+ while (num > 0)
+ {
+ box[pos++] = *from++;
+ if (pos >= ring_size)
+ pos = 0;
+ --num;
+ }
+
+ return pos;
+}
+
+inline static void
+dmm_enqueue_done(struct dmm_ring *ring, int pos, int new_pos, int is_sp)
+{
+ dmm_barrier();
+
+ if (!is_sp)
+ {
+ while (ring->prod_tail != pos)
+ dmm_pause();
+ }
+
+ ring->prod_tail = new_pos;
+}
+
+inline static int
+dmm_enqueue_copy_array(struct dmm_ring *ring, int pos,
+ void *array, int num, size_t elt_size)
+{
+ const int ring_size = ring->size;
+ void **box = (void **) (ring + 1);
+ char *from = (char *) array;
+
+ while (num > 0)
+ {
+ box[pos++] = from;
+ if (pos >= ring_size)
+ pos = 0;
+ from += elt_size;
+ --num;
+ }
+
+ return pos;
+}
+
+inline static int
+dmm_dequeue_prep(struct dmm_ring *ring, const int num, int *pos,
+ const int fixed, int is_sc)
+{
+ int succ, real, head;
+ const int ring_size = ring->size;
+
+ do
+ {
+ head = ring->cons_head;
+
+ dmm_barrier();
+
+ if ((real = ring->prod_tail - head) < 0)
+ real += ring_size;
+
+ if (real >= num)
+ real = num;
+ else if (fixed)
+ return 0;
+
+ if (real <= 0)
+ return 0;
+
+ succ = __move_head(&ring->cons_head, ring_size, head, real, is_sc);
+ }
+ while (!succ);
+
+ *pos = head;
+ return real;
+}
+
+inline static int
+dmm_dequeue_copy(struct dmm_ring *ring, int pos, void **to, int num)
+{
+ const int ring_size = ring->size;
+ void **box = (void **) (ring + 1);
+
+ while (num > 0)
+ {
+ *to++ = box[pos++];
+ if (pos >= ring_size)
+ pos = 0;
+ --num;
+ }
+
+ return pos;
+}
+
+inline static void
+dmm_dequeue_done(struct dmm_ring *ring, int pos, int new_pos, int is_sc)
+{
+ dmm_barrier();
+
+ if (!is_sc)
+ {
+ while (ring->cons_tail != pos)
+ dmm_pause();
+ }
+
+ ring->cons_tail = new_pos;
+}
+
+#endif
diff --git a/src/framework/snapshot/fw_snapshot.c b/src/framework/snapshot/fw_snapshot.c
index c68d3e0..cb571e2 100644
--- a/src/framework/snapshot/fw_snapshot.c
+++ b/src/framework/snapshot/fw_snapshot.c
@@ -15,9 +15,9 @@
*/
#include "nstack_securec.h"
-#include "nsfw_snapshot.h"
+#include "nsfw_snapshot_api.h"
#include "nstack_log.h"
-#include "fw_ss_tlv.h"
+#include "fw_snapshot.h"
#ifdef __cplusplus
/* *INDENT-OFF* */
@@ -25,455 +25,504 @@ extern "C"{
/* *INDENT-ON* */
#endif /* __cplusplus */
-/* *INDENT-OFF* */
-nsfw_ss_objDescManager_t g_nsfw_ss_objDescManager =
+nsfw_ss_obj_desc_manager_t g_nsfw_ss_obj_desc_manager =
+ {.g_nsfw_ss_obj_des_num = 0 };
+
+void nsfw_ss_register_obj_desc(nsfw_ss_obj_desc_t * objDesc)
{
-.g_nsfw_ss_objDesNum = 0};
+ if (objDesc == NULL)
+ return;
-/* *INDENT-ON* */
+ nsfw_ss_obj_desc_manager_t *manager = nsfw_ss_get_obj_desc_manager_inst();
-void
-nsfw_ss_register_ObjDesc (nsfw_ss_objDesc_t * objDesc)
-{
- if (objDesc == NULL)
- return;
- nsfw_ss_objDescManager_t *manager = nsfw_ss_getObjDescManagerInst ();
- if (manager->g_nsfw_ss_objDesNum >= NSFW_SS_MAX_OBJDESC_NUM)
- return;
- manager->g_nsfw_ss_objDescs[manager->g_nsfw_ss_objDesNum++] = objDesc;
+ if (manager->g_nsfw_ss_obj_des_num >= NSFW_SS_MAX_OBJDESC_NUM)
+ return;
+
+ manager->g_nsfw_ss_obj_descs[manager->g_nsfw_ss_obj_des_num++] = objDesc;
}
-static nsfw_ss_objDesc_t *
-nsfw_ss_getObjDescFromType (u16 objType)
+static nsfw_ss_obj_desc_t *nsfw_ss_get_obj_desc_from_type(u16 objType)
{
- nsfw_ss_objDescManager_t *manager = nsfw_ss_getObjDescManagerInst ();
- int i;
- for (i = 0; i < manager->g_nsfw_ss_objDesNum && i < NSFW_SS_MAX_OBJDESC_NUM;
- i++)
+ nsfw_ss_obj_desc_manager_t *manager = nsfw_ss_get_obj_desc_manager_inst();
+ int i;
+ for (i = 0;
+ i < manager->g_nsfw_ss_obj_des_num && i < NSFW_SS_MAX_OBJDESC_NUM;
+ i++)
{
- if (manager->g_nsfw_ss_objDescs[i]->objType == objType)
- return manager->g_nsfw_ss_objDescs[i];
+ if (manager->g_nsfw_ss_obj_descs[i]->objType == objType)
+ return manager->g_nsfw_ss_obj_descs[i];
}
- return NULL;
+ return NULL;
}
-static nsfw_ss_objMemDesc_t *
-nsfw_ss_getMemDescFromType (u16 objType, nsfw_ss_objDesc_t * objDesc)
+static nsfw_ss_obj_mem_desc_t *nsfw_ss_get_mem_desc_from_type(u16 objType,
+ nsfw_ss_obj_desc_t
+ * objDesc)
{
- int i;
- for (i = 0; i < objDesc->memNum; i++)
+ int i;
+ for (i = 0; i < objDesc->memNum; i++)
{
- if (objDesc->memDesc[i].type == objType)
+ if (objDesc->memDesc[i].type == objType)
{
- return &objDesc->memDesc[i];
+ return &objDesc->memDesc[i];
}
}
- return NULL;
+ return NULL;
}
/**
* @Function nsfw_ss_store
* @Description store object to memory
* @param (in) objType - type of object with member description
- * @param (in) obj - address of object memory
+ * @param (in) obj - adderss of object memory
* @param (in) storeMem - address of memory to store object data
* @param (in) storeMemLen - maximal length of storage memory
* @return positive integer means length of memory cost on success. return -1 if error
*/
-int
-nsfw_ss_storeObjMem (u16 objMemType, void *obj, void *storeMem,
- u32 storeMemLen)
+int nsfw_ss_store_obj_mem(u16 objMemType, void *obj, void *storeMem,
+ u32 storeMemLen)
{
- if (NULL == obj || NULL == storeMem)
- return -1;
-
- // example of object
- /* struct A{ */
- /* int a1; */
- /* struct A2 a2; --> struct A2 {int a2} */
- /* struct A3 a3[2]; --> struct A3 [{int a3}, {int a3}] */
- /* } */
-
- /* -------------------------------------------- */
- /* | type(object) | length | */
- /* | -------------------------------------- | */// --
- /* | | type(item) | length | | */// member a1
- /* | | item value (object->member) | | */// --
- /* | -------------------------------------- | */// object a2
- /* | | type(object) | length | | */// --
- /* | | ------------------------------- | | */// member a2
- /* | | | type(item) | length | | | */// --
- /* | | | item value (object->member) | | | */// --
- /* | | ------------------------------- | | *///
- /* | -------------------------------------- | *///
- /* | | type(object array) | length | | */// array member a3
- /* | | ------------------------------- | | */// --
- /* | | | type(object) | length | | | */// object a3_1
- /* | | | ----------------------------| | | */// --
- /* | | | type(item) | length | | | */// member a3_1_1
- /* | | | item value (object->member) | | | */
- /* | | | ----------------------------| | | */
- /* | | ------------------------------- | | */
- /* | | | type(object) | length | | | */
- /* | | | ----------------------------| | | */
- /* | | | type(item) | length | | | */
- /* | | | item value (object->member) | | | */
- /* | | | ----------------------------| | | */
- /* | | ------------------------------- | | */
- /* | |------------------------------------| | */
- /* -------------------------------------------- */
- nsfw_ss_objDesc_t *objDesc =
- nsfw_ss_getObjDescFromType (NSFW_SS_TYPE_GETOBJ (objMemType));
- if (NULL == objDesc)
- return -1;
-
- /* Get object header tlv */
- if (storeMemLen < tlv_header_length ())
- return -1;
- nsfw_ss_tlv_t *tlv = (nsfw_ss_tlv_t *) storeMem;
- tlv->type = objMemType;
- tlv->length = 0;
- tlv_header (storeMem);
- storeMemLen -= tlv_header_length ();
-
- /* Search every object member */
-
- /* For base item(including array of base item), it should start with a tlv header */
- /* For object array, it should start with one tlv header including array information */
- /* For object, it should call nsfw_ss_store recursively */
- int i;
- for (i = 0; i < objDesc->memNum; i++)
+ if (NULL == obj || NULL == storeMem)
{
- nsfw_ss_objMemDesc_t *memDesc = &objDesc->memDesc[i];
- if (NSFW_SS_TYPE_IS_MEMBER_OBJ (memDesc->type))
+ return -1;
+ }
+
+ // example of object
+ /* struct A{ */
+ /* int a1; */
+ /* struct A2 a2; --> struct A2 {int a2} */
+ /* struct A3 a3[2]; --> struct A3 [{int a3}, {int a3}] */
+ /* } */
+
+ /* -------------------------------------------- */
+ /* | type(object) | length | */
+ /* | -------------------------------------- | */// --
+ /* | | type(item) | length | | */// member a1
+ /* | | item value (object->member) | | */// --
+ /* | -------------------------------------- | */// object a2
+ /* | | type(object) | length | | */// --
+ /* | | ------------------------------- | | */// member a2
+ /* | | | type(item) | length | | | */// --
+ /* | | | item value (object->member) | | | */// --
+ /* | | ------------------------------- | | */
+ /* | -------------------------------------- | */
+ /* | | type(object array) | length | | */// array member a3
+ /* | | ------------------------------- | | */// --
+ /* | | | type(object) | length | | | */// object a3_1
+ /* | | | ----------------------------| | | */// --
+ /* | | | type(item) | length | | | */// member a3_1_1
+ /* | | | item value (object->member) | | | */
+ /* | | | ----------------------------| | | */
+ /* | | ------------------------------- | | */
+ /* | | | type(object) | length | | | */
+ /* | | | ----------------------------| | | */
+ /* | | | type(item) | length | | | */
+ /* | | | item value (object->member) | | | */
+ /* | | | ----------------------------| | | */
+ /* | | ------------------------------- | | */
+ /* | |------------------------------------| | */
+ /* -------------------------------------------- */
+
+ nsfw_ss_obj_desc_t *objDesc =
+ nsfw_ss_get_obj_desc_from_type(NSFW_SS_TYPE_GETOBJ(objMemType));
+ if (NULL == objDesc)
+ return -1;
+
+ /* Get object header tlv */
+ if (storeMemLen < tlv_header_length())
+ return -1;
+ nsfw_ss_tlv_t *tlv = (nsfw_ss_tlv_t *) storeMem;
+ tlv->type = objMemType;
+ tlv->length = 0;
+
+ tlv_header(storeMem);
+ storeMemLen -= tlv_header_length();
+
+ /* Search every object member */
+
+ /* For base item(including array of base item), it should start with a tlv header */
+ /* For object array, it should start with one tlv header including array information */
+ /* For object, it should call nsfw_ss_store recursively */
+
+ int i;
+ for (i = 0; i < objDesc->memNum; i++)
+ {
+ nsfw_ss_obj_mem_desc_t *memDesc = &objDesc->memDesc[i];
+
+ if (NSFW_SS_TYPE_IS_MEMBER_OBJ(memDesc->type))
{
- if (NSFW_SS_TYPE_IS_MEMBER_ARRAY (memDesc->type))
+ if (NSFW_SS_TYPE_IS_MEMBER_ARRAY(memDesc->type))
{
- /* array object should includes one array tlv header, shows the array informations */
- if (storeMemLen < tlv_header_length ())
- return -1;
- nsfw_ss_tlv_t *arrayTlv = (nsfw_ss_tlv_t *) storeMem;
- arrayTlv->type = memDesc->type;
- arrayTlv->length = 0;
- tlv_header (storeMem);
- storeMemLen -= tlv_header_length ();
- nsfw_ss_objDesc_t *memObjDesc =
- nsfw_ss_getObjDescFromType (NSFW_SS_TYPE_GETOBJ
- (memDesc->type));
- if (NULL == memObjDesc)
- return -1;
- u32 arraySize = memDesc->length / memObjDesc->objSize;
- u32 j;
- for (j = 0; j < arraySize; j++)
- {
- int ret =
- nsfw_ss_storeObjMem (NSFW_SS_TYPE_SET_MEMBER_OBJ
- (NSFW_SS_TYPE_GETOBJ (memDesc->type),
- 0),
- (char *) obj +
- (u64) (memDesc->offset) +
- (u64) j * memObjDesc->objSize,
- storeMem, storeMemLen);
- if ((-1 == ret) || (storeMemLen < (u32) ret))
+ /* array object should includes one array tlv header, shows the array informations */
+
+ if (storeMemLen < tlv_header_length())
return -1;
- tlv_mem_forward (storeMem, ret);
- storeMemLen -= (u32) ret;
- arrayTlv->length += (u32) ret;
+
+ nsfw_ss_tlv_t *arrayTlv = (nsfw_ss_tlv_t *) storeMem;
+ arrayTlv->type = memDesc->type;
+ arrayTlv->length = 0;
+
+ tlv_header(storeMem);
+ storeMemLen -= tlv_header_length();
+
+ nsfw_ss_obj_desc_t *memObjDesc =
+ nsfw_ss_get_obj_desc_from_type(NSFW_SS_TYPE_GETOBJ
+ (memDesc->type));
+ if (NULL == memObjDesc)
+ return -1;
+
+ u32 arraySize = memDesc->length / memObjDesc->objSize;
+ u32 j;
+ for (j = 0; j < arraySize; j++)
+ {
+ int ret =
+ nsfw_ss_store_obj_mem(NSFW_SS_TYPE_SET_MEMBER_OBJ
+ (NSFW_SS_TYPE_GETOBJ
+ (memDesc->type), 0),
+ (char *) obj +
+ (u64) (memDesc->offset) +
+ (u64) j * memObjDesc->objSize,
+ storeMem,
+ storeMemLen);
+
+ if ((-1 == ret) || (storeMemLen < (u32) ret))
+ return -1;
+
+ tlv_mem_forward(storeMem, ret);
+ storeMemLen -= (u32) ret;
+ arrayTlv->length += (u32) ret;
}
- tlv->length += (arrayTlv->length + (u32) tlv_header_length ());
+
+ tlv->length += (arrayTlv->length + (u32) tlv_header_length());
}
- else
+ else
{
- int ret = nsfw_ss_storeObjMem (memDesc->type,
- ((char *) obj + memDesc->offset),
- storeMem, storeMemLen);
- if (ret < 0 || (storeMemLen < (u32) ret))
- return -1;
- storeMemLen -= (u32) ret;
- tlv_mem_forward (storeMem, ret);
- tlv->length += (u32) ret;
+ int ret = nsfw_ss_store_obj_mem(memDesc->type,
+ ((char *) obj +
+ memDesc->offset),
+ storeMem, storeMemLen);
+ if (ret < 0 || (storeMemLen < (u32) ret))
+ return -1;
+
+ storeMemLen -= (u32) ret;
+ tlv_mem_forward(storeMem, ret);
+ tlv->length += (u32) ret;
}
}
- else
+ else
{
- // Base Item
- if (storeMemLen < tlv_header_length ())
+ // Base Item
+ if (storeMemLen < tlv_header_length())
{
- return -1;
+ return -1;
}
- nsfw_ss_tlv_t *curtlv = (nsfw_ss_tlv_t *) storeMem; // curTlv means next tlv elem
- curtlv->type = memDesc->type;
- curtlv->length = memDesc->length;
- tlv_header (storeMem);
- storeMemLen -= tlv_header_length ();
- if (storeMemLen < curtlv->length)
- return -1;
- if (EOK !=
- MEMCPY_S (storeMem, (size_t) storeMemLen,
- ((char *) obj + memDesc->offset),
- (size_t) memDesc->length))
+
+ nsfw_ss_tlv_t *curtlv = (nsfw_ss_tlv_t *) storeMem; // curTlv means next tlv elem
+ curtlv->type = memDesc->type;
+ curtlv->length = memDesc->length;
+
+ tlv_header(storeMem);
+ storeMemLen -= tlv_header_length();
+
+ if (storeMemLen < curtlv->length)
+ return -1;
+
+ if (EOK !=
+ memcpy_s(storeMem, (size_t) storeMemLen,
+ ((char *) obj + memDesc->offset),
+ (size_t) memDesc->length))
{
- return -1;
+ return -1;
}
- tlv_mem_forward (storeMem, memDesc->length);
- storeMemLen -= memDesc->length;
- tlv->length += (curtlv->length + (u32) tlv_header_length ());
+ tlv_mem_forward(storeMem, memDesc->length);
+ storeMemLen -= memDesc->length;
+ tlv->length += (curtlv->length + (u32) tlv_header_length());
}
}
- return (int) (tlv->length + tlv_header_length ());
+
+ return (int) (tlv->length + tlv_header_length());
}
/**
* @Function nsfw_ss_store
* @Description store object to memory
* @param (in) objType - type of object
- * @param (in) obj - address of object memory
+ * @param (in) obj - adderss of object memory
* @param (in) storeMem - address of memory to store object data
* @param (in) storeMemLen - maximal length of storage memory
* @return positive integer means length of memory cost on success. return -1 if error
*/
-int
-nsfw_ss_store (u16 objType, void *obj, void *storeMem, u32 storeMemLen)
+int nsfw_ss_store(u16 objType, void *obj, void *storeMem, u32 storeMemLen)
{
- return nsfw_ss_storeObjMem (NSFW_SS_TYPE_SET_MEMBER_OBJ (objType, 0),
- obj, storeMem, storeMemLen);
+ return nsfw_ss_store_obj_mem(NSFW_SS_TYPE_SET_MEMBER_OBJ(objType, 0),
+ obj, storeMem, storeMemLen);
}
/**
- * @Function nsfw_ss_restoreObjArray
+ * @Function nsfw_ss_restore_obj_array
* @Description restore array of objects
* @param (in) objType - type of object
- * @param (in) objMem - object memory to restore
- * @param (in) mem - memory of storage
- * @param (in) storeMemLength - maximal length of storage memory
- * @return 0 on success , -1 on error
+ * @param (in) obj_update - memory of object/storage memory info
+ * @return 0 on succss , -1 on error
*/
-NSTACK_STATIC int
-nsfw_ss_restoreObjArray (int objType, void *objMem, void *mem,
- u32 storeMemLength)
+NSTACK_STATIC int nsfw_ss_restore_obj_array(int objType,
+ nsfw_ss_obj_restore_t *
+ obj_update)
{
- if (storeMemLength < tlv_header_length ())
- return -1;
- nsfw_ss_tlv_t *arrayTlv = (nsfw_ss_tlv_t *) mem;
- storeMemLength -= tlv_header_length ();
- tlv_header (mem);
- if (0 == arrayTlv->length || storeMemLength < arrayTlv->length)
- return -1;
- storeMemLength = arrayTlv->length; // Only cares tlv->value
- nsfw_ss_objDesc_t *objDesc = nsfw_ss_getObjDescFromType ((u16) objType);
- if (NULL == objDesc)
- return -1;
-
- /* Now we are going to iterate every object */
- u32 objCnt = 0;
- while (storeMemLength)
+ if (obj_update->storeMemLen < tlv_header_length())
+ return -1;
+
+ nsfw_ss_obj_restore_t obj_res = { NULL, NULL, 0, 0 };
+ nsfw_ss_tlv_t *arrayTlv = (nsfw_ss_tlv_t *) (obj_update->mem);
+ obj_update->storeMemLen -= tlv_header_length();
+ tlv_header(obj_update->mem);
+ if (0 == arrayTlv->length || obj_update->storeMemLen < arrayTlv->length)
+ return -1;
+ obj_update->storeMemLen = arrayTlv->length; // Only cares tlv->value
+
+ nsfw_ss_obj_desc_t *objDesc =
+ nsfw_ss_get_obj_desc_from_type((u16) objType);
+ if (NULL == objDesc)
+ return -1;
+
+ /* Now we are going to iterate every object */
+ u32 objCnt = 0;
+ while (obj_update->storeMemLen)
{
- if (storeMemLength < tlv_header_length ())
- return -1; // Format error
- nsfw_ss_tlv_t *objTlv = (nsfw_ss_tlv_t *) mem;
- if ((int) NSFW_SS_TYPE_GETOBJ (objTlv->type) != objType)
+ if (obj_update->storeMemLen < tlv_header_length())
+ return -1; // Format error
+
+ nsfw_ss_tlv_t *objTlv = (nsfw_ss_tlv_t *) (obj_update->mem);
+ if ((int) NSFW_SS_TYPE_GETOBJ(objTlv->type) != objType)
{
- return -1;
+ return -1;
}
- int ret =
- nsfw_ss_restore ((char *) objMem + (u64) objDesc->objSize * objCnt,
- mem, storeMemLength);
- if (-1 == ret)
- return -1;
- objCnt++;
- tlv_mem_forward (mem, (objTlv->length + tlv_header_length ()));
- storeMemLength -= (objTlv->length + tlv_header_length ());
+
+ obj_res.objMem =
+ (void *) ((char *) (obj_update->objMem) +
+ (u64) objDesc->objSize * objCnt);
+ obj_res.mem = obj_update->mem;
+ obj_res.storeMemLen = obj_update->storeMemLen;
+
+ int ret = nsfw_ss_restore(&obj_res);
+ if (-1 == ret)
+ return -1;
+ objCnt++;
+ tlv_mem_forward(obj_update->mem,
+ (objTlv->length + tlv_header_length()));
+ obj_update->storeMemLen -= (objTlv->length + tlv_header_length());
}
- return 0;
+
+ return 0;
}
/**
* @Function nsfw_ss_restore
* @Description restore object from memory
- * @param (in) objMem - memory of object
- * @param (in) mem - memory of storage
- * @param (in) storeMemLen - maximal length of storage memory
+ * @param (in) obj_res - memory of object/storage memory info
* @return positive integer stands on object type, -1 on error
*/
-int
-nsfw_ss_restore (void *objMem, void *mem, u32 storeMemLen)
+int nsfw_ss_restore(nsfw_ss_obj_restore_t * obj_res)
{
- if (NULL == objMem || NULL == mem || 0 == storeMemLen)
- return -1;
-
- // example of object
- /* struct A{ */
- /* int a1; */
- /* struct A2 a2; --> struct A2 {int a2} */
- /* struct A3 a3[2]; --> struct A3 [{int a3}, {int a3}] */
- /* } */
-
- /* -------------------------------------------- */// --
- /* | type(object) | length | */// type length
- /* | -------------------------------------- | */// --
- /* | | type(item) | length | | */// member a1
- /* | | item value (object->member) | | */// --
- /* | -------------------------------------- | */// object a2
- /* | | type(object) | length | | */// --
- /* | | ------------------------------- | | */// member a2
- /* | | | type(item) | length | | | */// --
- /* | | | item value (object->member) | | | */// --
- /* | | ------------------------------- | | *///
- /* | -------------------------------------- | *///
- /* | | type(object array) | length | | */// array member a3
- /* | | ------------------------------- | | */// --
- /* | | | type(object) | length | | | */// object a3_1
- /* | | | ----------------------------| | | */// --
- /* | | | type(item) | length | | | */// member a3_1_1
- /* | | | item value (object->member) | | | */
- /* | | | ----------------------------| | | */
- /* | | ------------------------------- | | */
- /* | | | type(object) | length | | | */
- /* | | | ----------------------------| | | */
- /* | | | type(item) | length | | | */
- /* | | | item value (object->member) | | | */
- /* | | | ----------------------------| | | */
- /* | | ------------------------------- | | */
- /* | |------------------------------------| | */
- /* -------------------------------------------- */
- if (storeMemLen < tlv_header_length ())
- return -1;
- nsfw_ss_tlv_t *tlv = (nsfw_ss_tlv_t *) mem;
- storeMemLen -= tlv_header_length ();
- tlv_header (mem);
- nsfw_ss_objDesc_t *objDesc =
- nsfw_ss_getObjDescFromType (NSFW_SS_TYPE_GETOBJ (tlv->type));
- if (NULL == objDesc)
+ if (NULL == obj_res || NULL == obj_res->objMem || NULL == obj_res->mem
+ || 0 == obj_res->storeMemLen)
+ return -1;
+
+ // example of object
+ /* struct A{ */
+ /* int a1; */
+ /* struct A2 a2; --> struct A2 {int a2} */
+ /* struct A3 a3[2]; --> struct A3 [{int a3}, {int a3}] */
+ /* } */
+
+ /* -------------------------------------------- */// --
+ /* | type(object) | length | */// type length
+ /* | -------------------------------------- | */// --
+ /* | | type(item) | length | | */// member a1
+ /* | | item value (object->member) | | */// --
+ /* | -------------------------------------- | */// object a2
+ /* | | type(object) | length | | */// --
+ /* | | ------------------------------- | | */// member a2
+ /* | | | type(item) | length | | | */// --
+ /* | | | item value (object->member) | | | */// --
+ /* | | ------------------------------- | | */
+ /* | -------------------------------------- | */
+ /* | | type(object array) | length | | */// array member a3
+ /* | | ------------------------------- | | */// --
+ /* | | | type(object) | length | | | */// object a3_1
+ /* | | | ----------------------------| | | */// --
+ /* | | | type(item) | length | | | */// member a3_1_1
+ /* | | | item value (object->member) | | | */
+ /* | | | ----------------------------| | | */
+ /* | | ------------------------------- | | */
+ /* | | | type(object) | length | | | */
+ /* | | | ----------------------------| | | */
+ /* | | | type(item) | length | | | */
+ /* | | | item value (object->member) | | | */
+ /* | | | ----------------------------| | | */
+ /* | | ------------------------------- | | */
+ /* | |------------------------------------| | */
+ /* -------------------------------------------- */
+
+ if (obj_res->storeMemLen < tlv_header_length())
+ return -1;
+
+ nsfw_ss_tlv_t *tlv = (nsfw_ss_tlv_t *) (obj_res->mem);
+ obj_res->storeMemLen -= tlv_header_length();
+ tlv_header(obj_res->mem);
+
+ nsfw_ss_obj_restore_t obj_update = { NULL, NULL, 0, 0 };
+ nsfw_ss_obj_desc_t *objDesc =
+ nsfw_ss_get_obj_desc_from_type(NSFW_SS_TYPE_GETOBJ(tlv->type));
+ if (NULL == objDesc)
{
- return -1;
+ return -1;
}
- if (!NSFW_SS_TYPE_IS_MEMBER_OBJ (tlv->type))
- return -1;
- if (0 == tlv->length || storeMemLen < tlv->length)
- return -1;
-
- /* Now we go to inner of object */
- storeMemLen = tlv->length; /* Only care about tlv values */
- while (storeMemLen)
+
+ if (!NSFW_SS_TYPE_IS_MEMBER_OBJ(tlv->type))
+ return -1;
+
+ if (0 == tlv->length || obj_res->storeMemLen < tlv->length)
+ return -1;
+
+ /* Now we go to inner of object */
+ obj_res->storeMemLen = tlv->length; /* Only care about tlv values */
+ while (obj_res->storeMemLen)
{
- if (storeMemLen < tlv_header_length ())
- return -1; // Format error
- nsfw_ss_tlv_t *curtlv = (nsfw_ss_tlv_t *) mem;
- nsfw_ss_objMemDesc_t *memDesc =
- nsfw_ss_getMemDescFromType (curtlv->type, objDesc);
- if (NULL == memDesc)
+ if (obj_res->storeMemLen < tlv_header_length())
+ return -1; // Format error
+
+ nsfw_ss_tlv_t *curtlv = (nsfw_ss_tlv_t *) (obj_res->mem);
+
+ nsfw_ss_obj_mem_desc_t *memDesc =
+ nsfw_ss_get_mem_desc_from_type(curtlv->type, objDesc);
+ if (NULL == memDesc)
{ // This type not support
- storeMemLen -= tlv_header_length ();
- tlv_header (mem);
- if (storeMemLen < curtlv->length)
- return -1;
- tlv_mem_forward (mem, curtlv->length);
- storeMemLen -= curtlv->length;
- continue;
+ obj_res->storeMemLen -= tlv_header_length();
+ tlv_header(obj_res->mem);
+ if (obj_res->storeMemLen < curtlv->length)
+ return -1;
+ tlv_mem_forward(obj_res->mem, curtlv->length);
+ obj_res->storeMemLen -= curtlv->length;
+ continue;
}
- if (NSFW_SS_TYPE_IS_MEMBER_OBJ (curtlv->type))
+
+ obj_update.objMem =
+ (void *) ((char *) (obj_res->objMem) + memDesc->offset);
+ obj_update.mem = obj_res->mem;
+ obj_update.storeMemLen = obj_res->storeMemLen;
+
+ if (NSFW_SS_TYPE_IS_MEMBER_OBJ(curtlv->type))
{
- if (NSFW_SS_TYPE_IS_MEMBER_ARRAY (curtlv->type))
+ if (NSFW_SS_TYPE_IS_MEMBER_ARRAY(curtlv->type))
{
- int ret =
- nsfw_ss_restoreObjArray ((int)
- NSFW_SS_TYPE_GETOBJ (curtlv->type),
- (void *) ((char *) objMem +
- memDesc->offset), mem,
- storeMemLen);
- if (-1 == ret)
- return -1;
+ int ret =
+ nsfw_ss_restore_obj_array((int)
+ NSFW_SS_TYPE_GETOBJ
+ (curtlv->type),
+ &obj_update);
+ if (-1 == ret)
+ return -1;
}
- else
+ else
{
- int ret =
- nsfw_ss_restore ((void *) ((char *) objMem +
- memDesc->offset), mem,
- storeMemLen);
- if (-1 == ret)
- return -1;
+ int ret = nsfw_ss_restore(&obj_update);
+ if (-1 == ret)
+ return -1;
}
- tlv_mem_forward (mem, (curtlv->length + tlv_header_length ()));
- storeMemLen -= (curtlv->length + tlv_header_length ());
+
+ tlv_mem_forward(obj_res->mem,
+ (curtlv->length + tlv_header_length()));
+ obj_res->storeMemLen -= (curtlv->length + tlv_header_length());
}
- else
+ else
{
- tlv_header (mem);
- storeMemLen -= tlv_header_length ();
- NSFW_LOGDBG
- ("curtlv->type(%u), curtlv->length(%u), memDesc->offset(%u), memDesc->length(%u), mem(%u)",
- curtlv->type, curtlv->length, memDesc->offset, memDesc->length,
- *(u32 *) mem);
- if (storeMemLen < curtlv->length)
- return -1;
- if (EOK !=
- MEMCPY_S ((void *) ((char *) objMem + memDesc->offset),
- (size_t) memDesc->length, mem,
- (size_t) curtlv->length))
+ tlv_header(obj_res->mem);
+ obj_res->storeMemLen -= tlv_header_length();
+
+ NSFW_LOGDBG
+ ("curtlv->type(%u), curtlv->length(%u), memDesc->offset(%u), memDesc->length(%u), mem(%u)",
+ curtlv->type, curtlv->length, memDesc->offset,
+ memDesc->length, *(u32 *) (obj_res->mem));
+
+ if (obj_res->storeMemLen < curtlv->length)
+ return -1;
+ if (EOK !=
+ memcpy_s((void *) ((char *) (obj_res->objMem) +
+ memDesc->offset),
+ (size_t) memDesc->length, obj_res->mem,
+ (size_t) curtlv->length))
{
- return -1;
+ return -1;
}
- tlv_mem_forward (mem, curtlv->length);
- storeMemLen -= curtlv->length;
+
+ tlv_mem_forward(obj_res->mem, curtlv->length);
+ obj_res->storeMemLen -= curtlv->length;
}
}
- return (int) tlv->type;
+
+ return (int) tlv->type;
}
/**
- * @Function nsfw_ss_getObjStoreMemLen
+ * @Function nsfw_ss_get_obj_store_mem_len
* @Description Get the maximal memory it needs
* @param (in) objType - type of object
* @return length of memory needs, -1 if error
*/
-int
-nsfw_ss_getObjStoreMemLen (int objType)
+int nsfw_ss_get_obj_store_mem_len(int objType)
{
- u32 maxlength = tlv_header_length ();
- u32 i;
- nsfw_ss_objDesc_t *objDesc = nsfw_ss_getObjDescFromType ((u16) objType);
- if (!objDesc)
- return -1;
- for (i = 0; i < objDesc->memNum; i++)
+ u32 maxlength = tlv_header_length();
+ u32 i;
+
+ nsfw_ss_obj_desc_t *objDesc =
+ nsfw_ss_get_obj_desc_from_type((u16) objType);
+ if (!objDesc)
+ return -1;
+ for (i = 0; i < objDesc->memNum; i++)
{
- nsfw_ss_objMemDesc_t *memDesc = &objDesc->memDesc[i];
- int temp_len;
- if (NSFW_SS_TYPE_IS_MEMBER_OBJ (memDesc->type))
+ nsfw_ss_obj_mem_desc_t *memDesc = &objDesc->memDesc[i];
+ int temp_len;
+ if (NSFW_SS_TYPE_IS_MEMBER_OBJ(memDesc->type))
{
- nsfw_ss_objDesc_t *curObjDesc =
- nsfw_ss_getObjDescFromType (NSFW_SS_TYPE_GETOBJ (memDesc->type));
- if (NULL == curObjDesc)
- return -1;
- if (NSFW_SS_TYPE_IS_MEMBER_ARRAY (memDesc->type))
+ nsfw_ss_obj_desc_t *curObjDesc =
+ nsfw_ss_get_obj_desc_from_type(NSFW_SS_TYPE_GETOBJ
+ (memDesc->type));
+ if (NULL == curObjDesc)
+ return -1;
+
+ if (NSFW_SS_TYPE_IS_MEMBER_ARRAY(memDesc->type))
{
- maxlength += tlv_header_length (); // array length
- u32 arrSize = memDesc->length / curObjDesc->objSize;
- u32 j;
- for (j = 0; j < arrSize; j++)
+ maxlength += tlv_header_length(); // array length
+
+ u32 arrSize = memDesc->length / curObjDesc->objSize;
+ u32 j;
+ for (j = 0; j < arrSize; j++)
{
- temp_len =
- nsfw_ss_getObjStoreMemLen ((int) curObjDesc->objType);
- if (temp_len < 0)
- return -1;
- maxlength += (u32) temp_len;
+ temp_len =
+ nsfw_ss_get_obj_store_mem_len((int)
+ curObjDesc->objType);
+ if (temp_len < 0)
+ return -1;
+ maxlength += (u32) temp_len;
}
}
- else
+ else
{
- temp_len =
- nsfw_ss_getObjStoreMemLen ((int) curObjDesc->objType);
- if (temp_len < 0)
- return -1;
- maxlength += (u32) temp_len;
+ temp_len =
+ nsfw_ss_get_obj_store_mem_len((int) curObjDesc->objType);
+ if (temp_len < 0)
+ return -1;
+ maxlength += (u32) temp_len;
}
}
- else
+ else
{
- maxlength += ((u32) tlv_header_length () + memDesc->length);
+ maxlength += ((u32) tlv_header_length() + memDesc->length);
}
}
- return (int) maxlength;
+ return (int) maxlength;
}
#ifdef __cplusplus
diff --git a/src/framework/snapshot/fw_ss_tlv.h b/src/framework/snapshot/fw_snapshot.h
index 0bfbd91..810f289 100644
--- a/src/framework/snapshot/fw_ss_tlv.h
+++ b/src/framework/snapshot/fw_snapshot.h
@@ -28,9 +28,9 @@ extern "C"{
typedef struct _nsfw_ss_tlv
{
- u16 type;
- u32 length;
- void *value;
+ u16 type;
+ u32 length;
+ void *value;
} nsfw_ss_tlv_t;
#define tlv_header_length() ((size_t)(&((nsfw_ss_tlv_t*)0)->value))
diff --git a/src/include/declare_syscalls.h.tmpl b/src/include/declare_syscalls.h.tmpl
new file mode 100644
index 0000000..ec3b158
--- /dev/null
+++ b/src/include/declare_syscalls.h.tmpl
@@ -0,0 +1,56 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+
+
+
+NSTACK_MK_DECL(int , socket , (int, int, int));
+NSTACK_MK_DECL(int , bind , (int, const struct sockaddr*, socklen_t));
+NSTACK_MK_DECL(int , listen , (int, int));
+NSTACK_MK_DECL(int , shutdown , (int, int));
+NSTACK_MK_DECL(int , getaddrinfo, (const char *, const char *, const struct addrinfo *, struct addrinfo **));
+NSTACK_MK_DECL(int , getsockname, (int, struct sockaddr*, socklen_t*));
+NSTACK_MK_DECL(int , getpeername, (int, struct sockaddr*, socklen_t*));
+NSTACK_MK_DECL(int , getsockopt , (int, int, int, void*, socklen_t*));
+NSTACK_MK_DECL(int , setsockopt , (int, int, int, const void*, socklen_t));
+NSTACK_MK_DECL(int , accept , (int, struct sockaddr*, socklen_t*));
+NSTACK_MK_DECL(int , accept4 , (int, struct sockaddr*, socklen_t*, int flags));
+NSTACK_MK_DECL(int , connect , (int, const struct sockaddr*, socklen_t));
+NSTACK_MK_DECL(ssize_t , recv , (int , void*, size_t, int));
+NSTACK_MK_DECL(ssize_t , send , (int, const void*, size_t, int));
+NSTACK_MK_DECL(ssize_t , read , (int, void*, size_t));
+NSTACK_MK_DECL(ssize_t , write , (int, const void*, size_t));
+NSTACK_MK_DECL(ssize_t , writev , (int, const struct iovec *, int));
+NSTACK_MK_DECL(ssize_t , readv , (int, const struct iovec *, int));
+NSTACK_MK_DECL(ssize_t , sendto , (int, const void *, size_t, int, const struct sockaddr *, socklen_t));
+NSTACK_MK_DECL(ssize_t , recvfrom , (int, void *, size_t, int,struct sockaddr *, socklen_t *));
+NSTACK_MK_DECL(ssize_t , sendmsg , (int, const struct msghdr *, int flags));
+NSTACK_MK_DECL(ssize_t , recvmsg , (int, struct msghdr *, int flags));
+NSTACK_MK_DECL(int , close , (int));
+//NSTACK_MK_DECL(int , poll , (struct pollfd *, nfds_t, int));
+NSTACK_MK_DECL(int , select , (int, fd_set*, fd_set*, fd_set*, struct timeval*));
+NSTACK_MK_DECL(int , ioctl , (int, unsigned long, unsigned long));
+NSTACK_MK_DECL(int , fcntl , (int, int, unsigned long));
+NSTACK_MK_DECL(int , epoll_create,(int));
+//NSTACK_MK_DECL(int , epoll_create1,(int));
+NSTACK_MK_DECL(int , epoll_ctl, (int, int, int, struct epoll_event *));
+NSTACK_MK_DECL(int , epoll_wait, (int, struct epoll_event *, int, int));
+NSTACK_MK_DECL(pid_t , fork , (void));
+#undef NSTACK_MK_DECL
+
+
+
+
diff --git a/src/include/nstack_callback_ops.h b/src/include/nstack_callback_ops.h
new file mode 100644
index 0000000..ab90cea
--- /dev/null
+++ b/src/include/nstack_callback_ops.h
@@ -0,0 +1,95 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#ifndef __NSOCKET_CALLBACK_OPS_H__
+#define __NSOCKET_CALLBACK_OPS_H__
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/epoll.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <netdb.h>
+
+/*
+ *Standard api interface definition.
+ *these interface is provided by Protocol stack to nStack
+ */
+typedef struct __nstack_socket_ops
+{
+#undef NSTACK_MK_DECL
+#define NSTACK_MK_DECL(ret, fn, args) ret (*pf##fn) args
+#include "declare_syscalls.h.tmpl"
+} nstack_socket_ops;
+
+typedef struct nstack_dmm_stack_ops_s
+{
+ void (*update_dfx_data) (uint64_t s, int type, void *data);
+ void (*get_stack_tick) (void *data);
+ int type;
+} nstack_dmm_stack_ops_t;
+
+/*
+ *Interactive interface for Protocol stack and nStack defined here
+ *these interface is provided by Protocol stack to nStack
+ */
+typedef struct __nstack_proc_ops
+{
+ int (*module_init) (void);
+ int (*fork_init_child) (pid_t p, pid_t c);
+ void (*fork_fd) (int s, pid_t p, pid_t c);
+ void (*fork_free_fd) (int s);
+ void (*(*ep_triggle)
+ (int proFD, int triggle_ops, void *epinfo, void *epitem));
+ int (*ep_getEvt) (int proFD);
+ int (*route_match_byip) (void *addr);
+ int (*peak) (int s);
+ void (*set_app_info) (int proFD, void *appinfo);
+ /* set param list to void if not need param */
+ void (*app_touch) (void); /* app send its version info to daemon-stack */
+ void (*set_close_stat) (int s, int status);
+ void (*update_dfx_data) (uint64_t s, int type, void *data);
+ void (*get_stack_tick) (void *data);
+ void *(*get_ip_shmem) (void);
+ int (*module_init_pre) (void *, void *, int, int);
+} nstack_proc_ops;
+
+/*
+ *The event notify interface provided to the protocol stack by nStack
+ *these interface is provided by nStack to Protocol stack
+ */
+typedef struct __nstack_event_ops
+{
+ void *handle; /*current so file handler */
+ int type; /*nstack is assigned to the protocol stack and needs to be passed to nstack when the event is reported */
+ void (*event_cb) (void *epif, int event, int postFlag);
+} nstack_event_ops;
+
+/*
+ *Module registration interface.
+ *ouput param:posix_ps,proc_ops
+ *input param:event_ops
+ */
+typedef int (*nstack_stack_register_fn) (nstack_socket_ops * socketops,
+ nstack_event_ops * event_ops,
+ nstack_proc_ops * proc_ops);
+int nstack_dfx_init_ops(nstack_dmm_stack_ops_t * ops);
+
+int nstack_epoll_init(int flag, int ns_sync_mod);
+
+#endif
diff --git a/src/include/nstack_epoll_api.h b/src/include/nstack_epoll_api.h
new file mode 100644
index 0000000..26063d9
--- /dev/null
+++ b/src/include/nstack_epoll_api.h
@@ -0,0 +1,53 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#ifndef __NSTACK_EPOLL_API_H__
+#define __NSTACK_EPOLL_API_H__
+#include "types.h"
+
+int nstack_epoll_init(int flag, int ns_sync_mod);
+
+enum event_inform_state
+{
+ EVENT_NO_INFORM_APP, /*just push the event, must following EVENT_MUST_INFORM_APP to wake up epoll */
+ EVENT_INFORM_APP, /*push event and wake up epoll */
+ EVENT_MUST_INFORM_APP /*merge all events not pulled by app */
+};
+
+typedef enum
+{
+ nstack_ep_triggle_add,
+ nstack_ep_triggle_mod,
+ nstack_ep_triggle_del,
+ nstack_ep_triggle_inform_app,
+ nstack_ep_event_max
+} nstack_ep_triggle_ops_t;
+void nsep_recycle_epfd(void *epinfo, u32 pid);
+extern void nstack_epoll_event_enqueue(void *epif, int event, int postFlag);
+
+extern int nstack_epoll_event_dequeue(void *epi_addr, int events);
+
+#define NSTACK_EPOLL_EVENT_ADD(epInfo, event, flag) do\
+{\
+ nstack_epoll_event_enqueue(epInfo, event, flag);\
+}while(0)
+
+#define NSTACK_EPOLL_EVENT_DEL(epitem, events) do\
+{\
+ nstack_epoll_event_dequeue(epitem, events);\
+}while(0)
+
+#endif
diff --git a/src/include/nstack_ip_addr.h b/src/include/nstack_ip_addr.h
new file mode 100644
index 0000000..5bf3b5d
--- /dev/null
+++ b/src/include/nstack_ip_addr.h
@@ -0,0 +1,95 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#ifndef __NSTACK_IP_ADDR_H
+#define __NSTACK_IP_ADDR_H
+
+#ifndef ipv4_addr1_u16
+#include "types.h"
+
+/* Get one byte from the 4-byte address */
+#define ip4_addr1(ipaddr) (((u8_t*)(ipaddr))[0])
+#define ip4_addr2(ipaddr) (((u8_t*)(ipaddr))[1])
+#define ip4_addr3(ipaddr) (((u8_t*)(ipaddr))[2])
+#define ip4_addr4(ipaddr) (((u8_t*)(ipaddr))[3])
+
+/* These are cast to u16_t, with the intent that they are often arguments
+ * to printf using the U16_F format from cc.h. */
+#define ipv4_addr1_u16(ipaddr) ((u16_t)ip4_addr1(ipaddr))
+#define ipv4_addr2_u16(ipaddr) ((u16_t)ip4_addr2(ipaddr))
+#define ipv4_addr3_u16(ipaddr) ((u16_t)ip4_addr3(ipaddr))
+#define ipv4_addr4_u16(ipaddr) ((u16_t)ip4_addr4(ipaddr))
+#define FUZZY_IP_VAR(ipaddr) ipv4_addr3_u16((ipaddr)),ipv4_addr4_u16((ipaddr))
+#endif
+
+#include <netinet/in.h>
+#include "nstack_securec.h"
+#include "nstack_rd_api.h"
+
+static inline int in6_ntoa(char *buf, int size, const struct in6_addr *in6)
+{
+ return snprintf_s(buf, size, size - 1, "*:*:*:%x:%x:%x:%x:%x",
+ htons(in6->s6_addr16[3]),
+ htons(in6->s6_addr16[4]), htons(in6->s6_addr16[5]),
+ htons(in6->s6_addr16[6]), htons(in6->s6_addr16[7]));
+}
+
+static inline const char *inet6_ntoa(const struct in6_addr *addr)
+{
+ static char buf[64];
+
+ (void) in6_ntoa(buf, sizeof(buf), addr);
+
+ return buf;
+}
+
+inline static const char *inet_ntoa_x(const struct sockaddr *addr)
+{
+ static char buf[32];
+ int ret;
+ if (addr->sa_family == AF_INET)
+ {
+ const uint8_t *p =
+ (const uint8_t *) &((const struct sockaddr_in *) addr)->
+ sin_addr.s_addr;
+ ret =
+ snprintf_s(buf, sizeof(buf), sizeof(buf) - 1, "*.*.%u.%u", p[2],
+ p[3]);
+ if (-1 == ret)
+ {
+ return "NULL";
+ }
+
+ return buf;
+ }
+
+ if (addr->sa_family == AF_INET6)
+ return inet6_ntoa(&((const struct sockaddr_in6 *) addr)->sin6_addr);
+
+ {
+ ret =
+ snprintf_s(buf, sizeof(buf), sizeof(buf) - 1, "family:%d",
+ addr->sa_family);
+ if (-1 == ret)
+ {
+ return "NULL";
+ }
+
+ return buf;
+ }
+}
+
+#endif // __NSTACK_IP_ADDR_H
diff --git a/src/include/nstack_log.h b/src/include/nstack_log.h
new file mode 100644
index 0000000..f81efc3
--- /dev/null
+++ b/src/include/nstack_log.h
@@ -0,0 +1,596 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#ifndef _NSTACK_LOG_H_
+#define _NSTACK_LOG_H_
+/*==============================================*
+ * include header files *
+ *----------------------------------------------*/
+/* Suppressing _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
+ _FORTIFY_SOURCE only for optimized release builds.
+ This warning can be suppressed, in DMM build we use -O2.
+*/
+#pragma GCC diagnostic ignored "-Wcpp"
+#include <stdio.h>
+#include <string.h>
+#include <stdint.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/syscall.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <signal.h>
+#include <errno.h>
+#include "types.h"
+
+#include "glog/nstack_glog.ph"
+#include "glog/nstack_glog_in.h"
+
+#define NSTACK_FMT_CHECK(fmt_pos) __attribute__((format(printf, fmt_pos, (fmt_pos + 1))))
+
+/* for getVersion response */
+#define NSTACK_GETVER_MODULE "nStack"
+/* for Leibniz and CDN */
+#define NSTACK_GETVER_NUM "nStack_N100 V100R003C40B002"
+
+#define NSTACK_GETVER_VERSION "VPP2.0 " NSTACK_GETVER_NUM
+#define NSTACK_GETVER_BUILDTIME "[" __DATE__ "]" "[" __TIME__ "]"
+#define NSTACK_VERSION NSTACK_GETVER_VERSION " (" NSTACK_GETVER_MODULE ") " NSTACK_GETVER_BUILDTIME
+
+#define LOG_TIME_STAMP_LEN 17 // "YYYYMMDDHHMMSS";
+#define SPL_MAX_BUF_LEN 2048 // to be remove
+
+#define NSLOG_DEFAULT_FLUSH_TIMEOUT 50
+#define REAL_THREAD_SLEEP_TIME 20000
+#define REAL_THREAD_RETRY_COUNT 100
+/*==============================================*
+ * constants or macros define *
+ *----------------------------------------------*/
+
+#define LOG_INVALID_VALUE 0xFFFF
+
+#define NSTACK_LOG_NAME "/product/gpaas/log/nStack"
+
+typedef struct _log_entry
+{
+ const char *file;
+ u16 line;
+ u8 ctrl_bits;
+ u8 log_type;
+ u16 level;
+ u32 last_epoch_dup_cnt;
+} log_entry;
+
+typedef struct _log_sup_node
+{
+ /* data field */
+ log_entry entry;
+ /* structure indices */
+ struct _log_sup_node *rb_parent;
+ struct _log_sup_node *rb_left;
+ struct _log_sup_node *rb_right;
+ bool color;
+} log_sup_node;
+
+typedef struct _log_sup_table
+{
+ log_sup_node *root;
+ log_sup_node *nodepool;
+ log_sup_node *just_been_freed;
+ int count;
+ int size;
+} log_sup_table;
+
+struct log_init_para
+{
+ uint32_t run_log_size;
+ uint32_t run_log_count;
+ char *run_log_path;
+ uint32_t mon_log_size; //master and ctrl both use the parameter to reduce the redundancy
+ uint32_t mon_log_count; //master and ctrl both use the parameter to reduce the redundancy
+ char *mon_log_path; //master and ctrl both use the parameter to reduce the redundancy
+};
+
+struct nstack_logs
+{
+ uint32_t level; /**< Log level. */
+ int suppress_off;
+ int inited;
+ int file_type;
+};
+
+#define NS_LOG_STACKPOOL_ON 0x80U
+#define NS_LOG_STACKPOOL_TRACE 0x40U
+#define NS_LOG_STACKPOOL_STATE 0x20U
+#define NS_LOG_STACKPOOL_FRESH 0x10U
+#define NS_LOG_STACKPOOL_HALT 0x08U
+#define NS_LOG_STACKPOOL_OFF 0x00U
+
+/* LOG_SUP_TABLLE_SIZE_UPPER_LIMIT should be 2^n */
+#define LOG_SUP_TABLE_SIZE_UPPER_LIMIT 8192
+
+#define LOG_SUP_TABLE_SIZE_FOR_APP 64
+#define LOG_SUP_TABLE_SIZE_FOR_MAIN 1024
+#define LOG_SUP_TABLE_SIZE_FOR_MASTER 256
+#define LOG_SUP_TABLE_SIZE_FOR_MGR_COM_THREAD 1024
+#define LOG_SUP_TABLE_SIZE_FOR_TCPIP_THREAD 1024
+#define LOG_SUP_TABLE_SIZE_FOR_PTIMER_THREAD 256
+
+#define NULL_STRING ""
+#define MODULE_INIT_FORMAT_STRING "module %s]name=[%s]%s"
+#define MODULE_INIT_START "init"
+#define MODULE_INIT_FAIL "start failed"
+#define MODULE_INIT_SUCCESS "start success"
+
+/*log restrain id only canbe used once*/
+
+enum LOG_CTRL_ID
+{
+ // for socket api
+ LOG_CTRL_SEND = 0,
+ LOG_CTRL_DO_SEND,
+ LOG_CTRL_UDP_SEND,
+ LOG_CTRL_RECV,
+ LOG_CTRL_DO_RECV,
+ LOG_CTRL_SENDMSG,
+ LOG_CTRL_RECVMSG,
+ LOG_CTRL_READ,
+ LOG_CTRL_WRITE,
+ LOG_CTRL_DO_WRITE,
+ LOG_CTRL_READV,
+ LOG_CTRL_WRITEV,
+ LOG_CTRL_GETSOCKNAME,
+ LOG_CTRL_DO_GETSOCKNAME,
+ LOG_CTRL_GETPEERNAME,
+ LOG_CTRL_GETSOCKOPT,
+ LOG_CTRL_WAIT_NEW_CONN,
+
+ // for nstack service
+ LOG_CTRL_RECV_QUEUE_FULL,
+ LOG_CTRL_RECV_QUEUE_REST,
+ LOG_CTRL_RECV_QUEUE_TIMEOUT,
+ LOG_CTRL_L4_RECV_QUEUE_FULL,
+ LOG_CTRL_HUGEPAGE_ALLOC_FAIL,
+ LOG_CTRL_RX_HUGEPAGE_ALLOC_FAIL,
+ LOG_CTRL_PBUF_MEMP_ALLOC_FAIL,
+ LOG_CTRL_MEMP_ALLOC_FAIL,
+ LOG_CTRL_ICMP_ALLOC_FAIL,
+ LOG_CTRL_PBUF_NULL,
+ LOG_CTRL_INSTANCE_MEMP_FAIL,
+ LOG_CTRL_TCP_MEM_NOT_ENOUGH,
+ LOG_CTRL_IPREASS_OVERFLOW,
+ LOG_CTRL_DFX_CONN_STAT,
+ LOG_CTRL_CHECK_PCI,
+ LOG_CTRL_ID_MAX
+};
+
+typedef enum _LOG_MODULE
+{
+ NSOCKET = 1,
+ STACKPOOL,
+ OPERATION,
+ MASTER,
+ LOGTCP,
+ LOGUDP,
+ LOGIP,
+ LOGCMP,
+ LOGARP,
+ LOGRTP,
+ LOGHAL,
+ LOGDFX,
+ LOGFW,
+ LOGSBR,
+ LOGASYNC,
+ MAX_LOG_MODULE
+} LOG_MODULE;
+
+enum _LOG_PROCESS
+{
+ LOG_PRO_NSTACK = 0,
+ LOG_PRO_MASTER,
+ LOG_PRO_OMC_CTRL,
+ LOG_PRO_APP,
+ LOG_PRO_INVALID
+};
+
+extern struct nstack_logs g_nstack_logs[MAX_LOG_MODULE];
+
+#define NSLOG_CUS 0x20
+#define NSLOG_DBG 0x10
+#define NSLOG_INF 0x08
+#define NSLOG_WAR 0x04
+#define NSLOG_ERR 0x02
+#define NSLOG_EMG 0x01
+#define NSLOG_OFF 0x00
+static inline uint32_t nstack_get_log_level(int module)
+{
+ /* add validity check for path */
+ if ((MAX_LOG_MODULE <= module) || (module < 0))
+ {
+ return -1; /* clear compile warning */
+ }
+
+ return g_nstack_logs[module].level;
+}
+
+void write_pre_init_log(bool type);
+
+void set_log_init_para(struct log_init_para *para);
+
+void nstack_setlog_level(int module, uint32_t level);
+bool nstack_log_info_check(uint32_t module, uint32_t level);
+bool nstack_log_method_check(uint32_t level);
+bool check_log_restrain_valid(int id, uint32_t module, uint32_t level);
+void nstack_log(uint32_t module, uint32_t level, const char *format, ...);
+
+int nstack_log_init();
+void nstack_log_init_app();
+void set_log_proc_type(int log_proc_type);
+
+/* timeout in ms, 0 for infinite */
+int nstack_log_flush(unsigned long long timeout);
+
+int setlog_level_value(const char *param, const char *value);
+int get_str_value(const char *arg);
+int check_log_dir_valid(const char *path);
+void nstack_segment_error(int s);
+void init_log_ctrl_info();
+void set_log_ctrl_time(int id, int ctrl_time);
+
+bool check_log_prt_time(int id);
+int get_unprt_log_count(int id);
+void clr_unprt_log_count(int id);
+
+void get_current_time(char *buf, const int len);
+
+/*****************************************************************************
+* Prototype : level_stoa
+* Description : convert stack log level to app log level
+* Input : unsigned int nstack_level
+* Output : None
+* Return Value : int
+* Calls :
+* Called By :
+*****************************************************************************/
+static inline unsigned int level_stoa(unsigned int level)
+{
+ unsigned int golg_level;
+ switch (level)
+ {
+ case NSLOG_CUS:
+ golg_level = GLOG_LEVEL_CUSTOM;
+ break;
+ case NSLOG_DBG:
+ golg_level = GLOG_LEVEL_DEBUG;
+ break;
+ case NSLOG_INF:
+ golg_level = GLOG_LEVEL_INFO;
+ break;
+ case NSLOG_WAR:
+ golg_level = GLOG_LEVEL_WARNING;
+ break;
+ case NSLOG_ERR:
+ golg_level = GLOG_LEVEL_ERROR;
+ break;
+ case NSLOG_EMG:
+ golg_level = GLOG_LEVEL_FATAL;
+ break;
+ default:
+ golg_level = GLOG_LEVEL_BUTT;
+ break;
+ }
+ return golg_level;
+}
+
+void set_nstack_log_nonreentry(uint32_t val);
+unsigned int get_nstack_log_nonreentry(void);
+bool is_log_sup_switched_off(const u8 module);
+log_sup_table *get_log_sup_table_addr();
+bool update_sup_table_on_logging(const char *file, const u16 line,
+ const u8 log_type, const u16 level,
+ log_sup_table * table, u32 * dup_cnt);
+log_sup_table *init_sup_table(int table_size);
+void save_pre_init_log(uint32_t level, char *fmt, ...);
+#define GET_FILE_NAME(name_have_path) strrchr(name_have_path,'/')?strrchr(name_have_path,'/')+1:name_have_path
+#ifndef sys_sleep_ns
+#define sys_sleep_ns(_s, _ns)\
+ {\
+ if ((_s) >= 0 && (_ns) >= 0){\
+ struct timespec delay, remain;\
+ delay.tv_sec=(_s);\
+ delay.tv_nsec=(_ns);\
+ remain.tv_sec = 0; \
+ remain.tv_nsec = 0; \
+ while (nanosleep (&delay, &remain) < 0 && errno == EINTR)\
+ {\
+ delay = remain;\
+ }\
+ }\
+ }
+#endif /* sys_sleep_ns */
+
+/* segregate the dump info */
+#define LOG_TYPE(_module, _level) \
+ (((STACKPOOL == _module) && (NSLOG_EMG == _level)) ? GLOG_LEVEL_ERROR : ((OPERATION == _module) ? GLOG_LEVEL_WARNING : GLOG_LEVEL_INFO))
+
+#define log_shooting(_module,_level) \
+ ((NULL == g_log_hook_tag.log_hook) ? (nstack_get_log_level(_module) >= _level) : (level_stoa(_level) >= g_log_hook_tag.level))
+
+#define log_not_suppressed(_module, _level) \
+ (is_log_sup_switched_off(_module) \
+ || !update_sup_table_on_logging(__FILE__, (u16)__LINE__, _module, _level, get_log_sup_table_addr(), NULL))
+
+#define NS_LOGPID(_module,_prestr,_level,fmt, ...) \
+{\
+ if (log_shooting(_module, _level) && (0 == get_nstack_log_nonreentry()) && nstack_log_info_check(_module, _level))\
+ {\
+ if (log_not_suppressed(_module, _level))\
+ {\
+ set_nstack_log_nonreentry(1);\
+ \
+ \
+ \
+ if(nstack_log_method_check(_level))\
+ {\
+ nstack_log(_module, _level, \
+ "%d %s:%d] %d,%s<%s>" fmt "\r\n", (int)syscall(SYS_gettid), GET_FILE_NAME(__FILE__), \
+ __LINE__, getpid(),__func__, _prestr, ##__VA_ARGS__);\
+ }\
+ else\
+ {\
+ glog_print(LOG_TYPE(_module,_level),_prestr,level_stoa(_level),-1,GET_FILE_NAME(__FILE__),\
+ __LINE__,__func__,fmt, ##__VA_ARGS__);\
+ }\
+ set_nstack_log_nonreentry(0);\
+ }\
+ }\
+}
+
+#define NS_LOG_CTRL(_id, _module, _prestr, _level, fmt, ...) \
+{\
+ if (log_shooting(_module, _level) && (0 == get_nstack_log_nonreentry()) && check_log_restrain_valid(_id, _module, _level))\
+ {\
+ if (log_not_suppressed(_module, _level))\
+ {\
+ set_nstack_log_nonreentry(1);\
+ \
+ if(nstack_log_method_check(_level))\
+ {\
+ nstack_log(_module, _level, \
+ "%d %s:%d] %d,%s %d<%s>" fmt "\r\n", (int)syscall(SYS_gettid), GET_FILE_NAME(__FILE__), \
+ __LINE__, getpid(),__func__,get_unprt_log_count(_id), _prestr, ##__VA_ARGS__);\
+ }\
+ else\
+ {\
+ glog_print(LOG_TYPE(_module,_level),_prestr,level_stoa(_level),get_unprt_log_count(_id),\
+ GET_FILE_NAME(__FILE__),__LINE__,__func__,fmt, ##__VA_ARGS__);\
+ }\
+ clr_unprt_log_count(_id);\
+ set_nstack_log_nonreentry(0);\
+ }\
+ }\
+}
+
+#define NS_LOG_STACKPOOL(dbug,_module,_prestr,_level,fmt, ...) \
+{\
+ if ((dbug) & NS_LOG_STACKPOOL_ON)\
+ {\
+ NS_LOGPID(_module,_prestr,_level,fmt,##__VA_ARGS__);\
+ }\
+}\
+
+#define NS_LOGPID_CHK(_module,_level) log_shooting(_module, _level)
+
+/* hanging up version check log need restrain*/
+/* add a asyn log record method*/
+#define NS_LOGCUSTOM(_module,_prestr,_level,fmt, ...) \
+{\
+ if ((0 == get_nstack_log_nonreentry()) && nstack_log_info_check(_module, _level))\
+ {\
+ set_nstack_log_nonreentry(1);\
+ glog_print(GLOG_LEVEL_INFO,_prestr,level_stoa(_level),-1,GET_FILE_NAME(__FILE__),\
+ __LINE__,__func__,fmt, ##__VA_ARGS__);\
+ set_nstack_log_nonreentry(0);\
+ }\
+}
+
+/*for every log modules should def marcos below use a sort module name, just like MON means Monitor*/
+#define NSMON_LOGINF(fmt, ...) NS_LOGPID(MASTER,"MON",NSLOG_INF,fmt,##__VA_ARGS__)
+#define NSMON_LOGDBG(fmt, ...) NS_LOGPID(MASTER,"MON",NSLOG_DBG,fmt,##__VA_ARGS__)
+#define NSMON_LOGWAR(fmt, ...) NS_LOGPID(MASTER,"MON",NSLOG_WAR,fmt,##__VA_ARGS__)
+#define NSMON_LOGERR(fmt, ...) NS_LOGPID(MASTER,"MON",NSLOG_ERR,fmt,##__VA_ARGS__)
+
+#define NSPOL_LOGINF(debug,fmt, ...) NS_LOG_STACKPOOL(debug,STACKPOOL,"POL",NSLOG_INF,fmt,##__VA_ARGS__)
+#define NSPOL_LOGDBG(debug,fmt, ...) NS_LOG_STACKPOOL(debug,STACKPOOL,"POL",NSLOG_DBG,fmt,##__VA_ARGS__)
+#define NSPOL_LOGWAR(debug,fmt, ...) NS_LOG_STACKPOOL(debug,STACKPOOL,"POL",NSLOG_WAR,fmt,##__VA_ARGS__)
+#define NSPOL_LOGERR(fmt, ...) NS_LOGPID(STACKPOOL,"POL",NSLOG_ERR,fmt,##__VA_ARGS__)
+#define NSPOL_LOGEMG(fmt, ...) NS_LOGPID(STACKPOOL,"POL",NSLOG_EMG,fmt,##__VA_ARGS__)
+#define NSPOL_LOGCUSINF(fmt, ...) NS_LOGCUSTOM(STACKPOOL,"POL",NSLOG_CUS,fmt,##__VA_ARGS__)
+
+#define NSOPR_LOGINF(fmt, ...) NS_LOGPID(OPERATION,"OPR",NSLOG_INF,fmt,##__VA_ARGS__)
+#define NSOPR_LOGDBG(fmt, ...) NS_LOGPID(OPERATION,"OPR",NSLOG_DBG,fmt,##__VA_ARGS__)
+#define NSOPR_LOGWAR(fmt, ...) NS_LOGPID(OPERATION,"OPR",NSLOG_WAR,fmt,##__VA_ARGS__)
+#define NSOPR_LOGERR(fmt, ...) NS_LOGPID(OPERATION,"orchestration",NSLOG_ERR,fmt,##__VA_ARGS__)
+
+#define NSSOC_LOGINF(fmt, ...) NS_LOGPID(NSOCKET,"SOC",NSLOG_INF,fmt,##__VA_ARGS__)
+#define NSSOC_LOGDBG(fmt, ...) NS_LOGPID(NSOCKET,"SOC",NSLOG_DBG,fmt,##__VA_ARGS__)
+#define NSSOC_LOGWAR(fmt, ...) NS_LOGPID(NSOCKET,"SOC",NSLOG_WAR,fmt,##__VA_ARGS__)
+#define NSSOC_LOGERR(fmt, ...) NS_LOGPID(NSOCKET,"SOC",NSLOG_ERR,fmt,##__VA_ARGS__)
+
+#define NSSBR_LOGINF(fmt, ...) NS_LOGPID(LOGSBR,"SBR",NSLOG_INF,fmt,##__VA_ARGS__)
+#define NSSBR_LOGDBG(fmt, ...) NS_LOGPID(LOGSBR,"SBR",NSLOG_DBG,fmt,##__VA_ARGS__)
+#define NSSBR_LOGWAR(fmt, ...) NS_LOGPID(LOGSBR,"SBR",NSLOG_WAR,fmt,##__VA_ARGS__)
+#define NSSBR_LOGERR(fmt, ...) NS_LOGPID(LOGSBR,"SBR",NSLOG_ERR,fmt,##__VA_ARGS__)
+
+#define NSRTP_LOGINF(fmt, ...) NS_LOGPID(LOGRTP, "RTP",NSLOG_INF,fmt,##__VA_ARGS__)
+#define NSRTP_LOGDBG(fmt, ...) NS_LOGPID(LOGRTP, "RTP",NSLOG_DBG,fmt,##__VA_ARGS__)
+#define NSRTP_LOGWAR(fmt, ...) NS_LOGPID(LOGRTP, "RTP",NSLOG_WAR,fmt,##__VA_ARGS__)
+#define NSRTP_LOGERR(fmt, ...) NS_LOGPID(LOGRTP, "RTP",NSLOG_ERR,fmt,##__VA_ARGS__)
+
+#define NSTCP_LOGINF(fmt, ...) NS_LOGPID(LOGTCP,"TCP",NSLOG_INF,fmt,##__VA_ARGS__)
+#define NSTCP_LOGDBG(fmt, ...) NS_LOGPID(LOGTCP,"TCP",NSLOG_DBG,fmt,##__VA_ARGS__)
+#define NSTCP_LOGWAR(fmt, ...) NS_LOGPID(LOGTCP,"TCP",NSLOG_WAR,fmt,##__VA_ARGS__)
+#define NSTCP_LOGERR(fmt, ...) NS_LOGPID(LOGTCP,"TCP",NSLOG_ERR,fmt,##__VA_ARGS__)
+
+#define NSIP_LOGINF(fmt, ...) NS_LOGPID(LOGIP,"IP",NSLOG_INF,fmt,##__VA_ARGS__)
+#define NSIP_LOGDBG(fmt, ...) NS_LOGPID(LOGIP,"IP",NSLOG_DBG,fmt,##__VA_ARGS__)
+#define NSIP_LOGWAR(fmt, ...) NS_LOGPID(LOGIP,"IP",NSLOG_WAR,fmt,##__VA_ARGS__)
+#define NSIP_LOGERR(fmt, ...) NS_LOGPID(LOGIP,"IP",NSLOG_ERR,fmt,##__VA_ARGS__)
+#define NSIP_LOGDBG_OPEN !(NS_LOGPID_CHK(LOGIP,NSLOG_DBG))
+
+#define NSUDP_LOGINF(fmt, ...) NS_LOGPID(LOGUDP,"UDP",NSLOG_INF,fmt,##__VA_ARGS__)
+#define NSUDP_LOGDBG(fmt, ...) NS_LOGPID(LOGUDP,"UDP",NSLOG_DBG,fmt,##__VA_ARGS__)
+#define NSUDP_LOGWAR(fmt, ...) NS_LOGPID(LOGUDP,"UDP",NSLOG_WAR,fmt,##__VA_ARGS__)
+#define NSUDP_LOGERR(fmt, ...) NS_LOGPID(LOGUDP,"UDP",NSLOG_ERR,fmt,##__VA_ARGS__)
+
+#define NSHAL_LOGINF(fmt, ...) NS_LOGPID(LOGHAL,"HAL",NSLOG_INF,fmt,##__VA_ARGS__)
+#define NSHAL_LOGDBG(fmt, ...) NS_LOGPID(LOGHAL,"HAL",NSLOG_DBG,fmt,##__VA_ARGS__)
+#define NSHAL_LOGWAR(fmt, ...) NS_LOGPID(LOGHAL,"HAL",NSLOG_WAR,fmt,##__VA_ARGS__)
+#define NSHAL_LOGERR(fmt, ...) NS_LOGPID(LOGHAL,"HAL",NSLOG_ERR,fmt,##__VA_ARGS__)
+
+#define NSARP_LOGINF(fmt, ...) NS_LOGPID(LOGARP,"ARP",NSLOG_INF,fmt,##__VA_ARGS__)
+#define NSARP_LOGDBG(fmt, ...) NS_LOGPID(LOGARP,"ARP",NSLOG_DBG,fmt,##__VA_ARGS__)
+#define NSARP_LOGWAR(fmt, ...) NS_LOGPID(LOGARP,"ARP",NSLOG_WAR,fmt,##__VA_ARGS__)
+#define NSARP_LOGERR(fmt, ...) NS_LOGPID(LOGARP,"ARP",NSLOG_ERR,fmt,##__VA_ARGS__)
+
+#define NSDFX_LOGINF(fmt, ...) NS_LOGPID(LOGDFX,"DFX",NSLOG_INF,fmt,##__VA_ARGS__)
+#define NSDFX_LOGDBG(fmt, ...) NS_LOGPID(LOGDFX,"DFX",NSLOG_DBG,fmt,##__VA_ARGS__)
+#define NSDFX_LOGWAR(fmt, ...) NS_LOGPID(LOGDFX,"DFX",NSLOG_WAR,fmt,##__VA_ARGS__)
+#define NSDFX_LOGERR(fmt, ...) NS_LOGPID(LOGDFX,"DFX",NSLOG_ERR,fmt,##__VA_ARGS__)
+
+#define NSFW_LOGINF(fmt, ...) NS_LOGPID(LOGFW,"FW",NSLOG_INF,fmt,##__VA_ARGS__)
+#define NSFW_LOGDBG(fmt, ...) NS_LOGPID(LOGFW,"FW",NSLOG_DBG,fmt,##__VA_ARGS__)
+#define NSFW_LOGERR(fmt, ...) NS_LOGPID(LOGFW,"FW",NSLOG_ERR,fmt,##__VA_ARGS__)
+#define NSFW_LOGWAR(fmt, ...) NS_LOGPID(LOGFW,"FW",NSLOG_WAR,fmt,##__VA_ARGS__)
+
+#define NSAM_LOGINF(fmt, ...) NS_LOGPID(LOGFW,"AM",NSLOG_INF,fmt,##__VA_ARGS__)
+#define NSAM_LOGDBG(fmt, ...) NS_LOGPID(LOGFW,"AM",NSLOG_DBG,fmt,##__VA_ARGS__)
+#define NSAM_LOGERR(fmt, ...) NS_LOGPID(LOGFW,"AM",NSLOG_ERR,fmt,##__VA_ARGS__)
+#define NSAM_LOGWAR(fmt, ...) NS_LOGPID(LOGFW,"AM",NSLOG_WAR,fmt,##__VA_ARGS__)
+
+// TODO: HotFix need remove
+/* for HotFix module */
+#define NSHF_LOGINF(fmt, ...) NS_LOGPID(LOGFW,"HF",NSLOG_INF,fmt,##__VA_ARGS__)
+#define NSHF_LOGDBG(fmt, ...) NS_LOGPID(LOGFW,"HF",NSLOG_DBG,fmt,##__VA_ARGS__)
+#define NSHF_LOGERR(fmt, ...) NS_LOGPID(LOGFW,"HF",NSLOG_ERR,fmt,##__VA_ARGS__)
+#define NSHF_LOGWAR(fmt, ...) NS_LOGPID(LOGFW,"HF",NSLOG_WAR,fmt,##__VA_ARGS__)
+
+#define INIT_LOG_ASSEM(log_module,_prestr,_level, init_module , function, errString, errValue, status) \
+ \
+ if ((LOG_INVALID_VALUE <= errValue) && (1 == sizeof(errString))) \
+ { \
+ NS_LOGPID(log_module,_prestr, _level,MODULE_INIT_FORMAT_STRING, (char*)status, init_module, function ); \
+ } \
+ else if (LOG_INVALID_VALUE <= errValue)\
+ { \
+ NS_LOGPID(log_module,_prestr, _level,MODULE_INIT_FORMAT_STRING",err_string=%s", (char*)status, init_module, function, errString ); \
+ } \
+ else if (1 == sizeof(errString))\
+ { \
+ NS_LOGPID(log_module,_prestr, _level,MODULE_INIT_FORMAT_STRING",err_value=%d", (char*)status, init_module, function, errValue ); \
+ } \
+ else \
+ { \
+ NS_LOGPID(log_module,_prestr, _level,MODULE_INIT_FORMAT_STRING",err_string=%s,err_value=%d", (char*)status, init_module, function, errString, errValue ); \
+ } \
+
+
+#define INITPOL_LOGINF(init_module_name, function, err_string, err_value, status) \
+ \
+ INIT_LOG_ASSEM(STACKPOOL,"POL",NSLOG_INF,init_module_name , function, err_string, err_value, status)\
+
+
+#define INITPOL_LOGERR(init_module_name, function, err_string, err_value, status) \
+ \
+ INIT_LOG_ASSEM(STACKPOOL,"POL",NSLOG_ERR,init_module_name , function, err_string, err_value, status)\
+
+
+#define INITTCP_LOGINF(init_module_name , function, err_string, err_value, status) \
+ \
+ INIT_LOG_ASSEM(LOGTCP,"TCP",NSLOG_INF,init_module_name , function, err_string, err_value, status)\
+
+
+#define INITTCP_LOGERR(init_module_name , function, err_string, err_value, status) \
+ \
+ INIT_LOG_ASSEM(LOGTCP,"TCP",NSLOG_ERR,init_module_name , function, err_string, err_value, status)\
+
+
+#define INITMON_LOGERR(init_module_name , function, err_string, err_value, status) \
+ \
+ INIT_LOG_ASSEM(MASTER,"MON",NSLOG_ERR,init_module_name , function, err_string, err_value, status)\
+
+
+/*add the init log info*/
+#define INITSOC_LOGERR(init_module_name , function, err_string, err_value, status) \
+ INIT_LOG_ASSEM(NSOCKET,"SOC",NSLOG_ERR,init_module_name , function, err_string, err_value, status)
+
+#define NSPOL_DUMP_LOGINF(fmt, ...) NSPOL_LOGINF(0x80, fmt, ##__VA_ARGS__)
+#define NSPOL_DUMP_LOGDBG(fmt, ...) NSPOL_LOGDBG(0x80, fmt, ##__VA_ARGS__)
+#define NSPOL_DUMP_LOGERR(fmt, ...) NSPOL_LOGERR(fmt, ##__VA_ARGS__)
+#define NSPOL_DUMP_LOGWAR(fmt, ...) NSPOL_LOGWAR(0x80, fmt, ##__VA_ARGS__)
+
+/*==============================================*
+ * project-wide global variables *
+ *----------------------------------------------*/
+
+#define fuzzy_uint32(src) ((src) & 0x0000ffff)
+#define fuzzy_uint64(src) ((src) & 0x00000000ffffffff)
+
+/*==============================================*
+ * routines' or functions' implementations *
+ *----------------------------------------------*/
+/* *INDENT-OFF* */
+#ifndef FREE_IF_NOT_NULL
+#define FREE_IF_NOT_NULL(mem) \
+ if (mem) \
+ {\
+ free(mem); \
+ mem = NULL; \
+ }
+#endif
+/* *INDENT-ON* */
+//#define CPU_CYCLES
+#ifdef CPU_CYCLES
+static __inline__ unsigned long long nstack_rdtsc(void)
+{
+ unsigned hi, lo;
+ __asm__ __volatile__("rdtsc":"=a"(lo), "=d"(hi));
+ return ((unsigned long long) lo) | (((unsigned long long) hi) << 32);
+}
+
+#define CPUB(name) \
+unsigned long long start##name = 0;\
+unsigned long long stop##name = 0;\
+static unsigned long long total##name = 0;\
+static unsigned long long total_cout##name = 0;\
+start##name = nstack_rdtsc();
+
+#define CPUE(name) \
+stop##name = nstack_rdtsc();\
+total##name += (stop##name - start##name);\
+if(++total_cout##name == 1000000)\
+{\
+ NSSOC_LOGINF(#name" cpu %llu-------\n", total##name / total_cout##name);\
+ total##name = 0;\
+ total_cout##name = 0;\
+}
+#else
+#define CPUB(name)
+#define CPUE(name)
+#endif
+
+#endif
diff --git a/src/include/nstack_rd_api.h b/src/include/nstack_rd_api.h
new file mode 100644
index 0000000..894cae1
--- /dev/null
+++ b/src/include/nstack_rd_api.h
@@ -0,0 +1,124 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#ifndef __NSTACK_RD_API_H
+#define __NSTACK_RD_API_H
+
+#define NSTACK_IP_BIT_MAX 32
+
+#define MASK_V(ipaddr, masklen) ((ipaddr) & htonl(~0 << (NSTACK_IP_BIT_MAX - (masklen))))
+
+typedef struct __rd_route_ip_data
+{
+ unsigned int addr;
+ unsigned int masklen;
+ unsigned int resev[2];
+} rd_ip_data;
+
+typedef struct __rd_type_data
+{
+ unsigned int value;
+ unsigned int attr;
+ unsigned char reserved[4];
+} rd_type_data;
+
+typedef struct __rd_proto_data
+{
+ unsigned int value;
+ unsigned int attr;
+} rd_proto_data;
+
+/* rd table manipulation */
+void *nstack_rd_malloc(const char *name);
+void *nstack_local_rd_malloc(void);
+int nstack_rd_free(const char *name);
+void nstack_local_rd_free(void *p);
+void nstack_rd_table_clear(void *table);
+
+/* parse rd_config.json */
+int nstack_rd_parse(const char *name, void *table);
+
+/* manually insert/delete rd node */
+int nstack_rd_ip_node_insert(const char *name, rd_ip_data * data,
+ void *table);
+int nstack_rd_ip_node_delete(rd_ip_data * data, void *table);
+int nstack_rd_type_node_insert(const char *name, rd_type_data * data,
+ void *table);
+int nstack_rd_type_node_delete(rd_type_data * data, void *table);
+int nstack_rd_proto_node_insert(const char *name, rd_proto_data * data,
+ void *table);
+int nstack_rd_proto_node_delete(rd_proto_data * data, void *table);
+
+#include <netinet/in.h>
+
+#ifndef NSTACK_IP6_ADDR_DEF
+#define NSTACK_IP6_ADDR_DEF
+typedef struct ip6_addr
+{
+ union
+ {
+ uint32_t addr32[4];
+ uint16_t addr16[8];
+ uint8_t addr8[16];
+ };
+} ip6_addr_t;
+#endif
+
+typedef struct __rd_route_ip6_data
+{
+ ip6_addr_t addr;
+ unsigned int masklen;
+} rd_ip6_data;
+
+char *ipv6_ntop(ip6_addr_t host_addr);
+int nstack_rd_ip6_node_insert(const char *name, rd_ip6_data * data,
+ void *table);
+int nstack_rd_ip6_node_delete(rd_ip6_data * data, void *table);
+
+#define IPV6_ADDR32_IDX 4
+#define IPV6_ADDR32_SIZE 32
+
+static inline int ip6_addr_match(struct ip6_addr *a, struct ip6_addr *b,
+ unsigned int masklen)
+{
+ int index;
+ uint32_t mask;
+
+ for (index = 0; index < IPV6_ADDR32_IDX && masklen >= IPV6_ADDR32_SIZE;
+ ++index)
+ {
+ if (a->addr32[index] != b->addr32[index])
+ return 0;
+
+ masklen -= IPV6_ADDR32_SIZE;
+ }
+
+ /* masklen is 128 */
+ if (index == IPV6_ADDR32_IDX)
+ {
+ return 1;
+ }
+
+ if (index > IPV6_ADDR32_IDX)
+ return 0;
+
+ /*compare in network order byte */
+ mask = htonl(~0 << (IPV6_ADDR32_SIZE - masklen));
+
+ return (a->addr32[index] & mask) == (b->addr32[index] & mask);
+}
+
+#endif // __NSTACK_RD_API_H
diff --git a/src/include/nstack_securec.h b/src/include/nstack_securec.h
new file mode 100644
index 0000000..f87e7c1
--- /dev/null
+++ b/src/include/nstack_securec.h
@@ -0,0 +1,114 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#ifndef _NSTACK_SECUREC_H_
+#define _NSTACK_SECUREC_H_
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
+#ifndef SYSTEMC_LIB
+/* use libsecurec.so as usual */
+#include "securec.h"
+
+#else
+#include "stdio.h"
+#include "stdarg.h"
+#include "string.h"
+
+#ifndef NULL
+#define NULL ((void *)0)
+#endif
+
+#ifndef errno_t
+typedef int errno_t;
+#endif
+
+#ifndef EOK
+#define EOK (0)
+#endif
+
+#ifndef EINVAL
+#define EINVAL (22)
+#endif
+
+#ifndef EINVAL_AND_RESET
+#define EINVAL_AND_RESET (22 | 0X80)
+#endif
+
+#ifndef ERANGE
+#define ERANGE (34)
+#endif
+
+#ifndef ERANGE_AND_RESET
+#define ERANGE_AND_RESET (34 | 0X80)
+#endif
+
+#ifndef EOVERLAP_AND_RESET
+#define EOVERLAP_AND_RESET (54 | 0X80)
+#endif
+
+#define scanf_s scanf
+#define wscanf_s wscanf
+#define vscanf_s vscanf
+#define vwscanf_s vwscanf
+#define fscanf_s fscanf
+#define fwscanf_s fwscanf
+#define vfscanf_s vfscanf
+#define vfwscanf_s vfwscanf
+#define sscanf_s sscanf
+#define swscanf_s swscanf
+#define vsscanf_s vsscanf
+#define vswscanf_s vswscanf
+
+#define sprintf_s(a, b, ...) sprintf(a, ##__VA_ARGS__)
+#define swprintf_s(a, b, c, ...) swprintf(a, b, c, ##__VA_ARGS__)
+#define vsprintf_s(a, b, c, d) vsprintf(a, c, d)
+#define vswprintf_s(a, b, c, d) vswprintf(a, b, c, d)
+#define vsnprintf_s(a, b, c, d, e) vsnprintf(a, c, d, e)
+#define snprintf_s(a, b, c, d, ...) snprintf(a, c, d, ##__VA_ARGS__)
+
+#define wmemcpy_s(a, b, c, d) ((NULL == wmemcpy(a, c, d)) ? EINVAL : EOK)
+#define memmove_s(a, b, c, d) ((NULL == memmove(a, c, d)) ? EINVAL : EOK)
+#define wmemmove_s(a, b, c, d) ((NULL == wmemmove(a, c, d)) ? EINVAL : EOK)
+#define wcscpy_s(a, b, c) ((NULL == wcscpy(a, c)) ? EINVAL : EOK)
+#define wcsncpy_s(a, b, c, d) ((NULL == wcsncpy(a, c, d)) ? EINVAL : EOK)
+#define wcscat_s(a, b, c) ((NULL == wcscat(a, c)) ? EINVAL : EOK)
+#define wcsncat_s(a, b, c, d) ((NULL == wcsncat(a, c, d)) ? EINVAL : EOK)
+
+#define memset_s(a, b, c, d) ((NULL == memset(a, c, d)) ? EINVAL : EOK)
+#define memcpy_s(a, b, c, d) ((NULL == memcpy(a, c, d)) ? EINVAL : EOK)
+#define strcpy_s(a, b, c) ((NULL == strcpy(a, c )) ? EINVAL : EOK)
+#define strncpy_s(a, b, c, d) ((NULL == strncpy(a, c, d)) ? EINVAL : EOK)
+#define strcat_s(a, b, c) ((NULL == strcat(a, c)) ? EINVAL : EOK)
+#define strncat_s(a, b, c, d) ((NULL == strncat(a, c, d)) ? EINVAL : EOK)
+
+#define strtok_s(a, b, c) strtok(a, b)
+#define wcstok_s(a, b, c) wcstok(a, b)
+#define gets_s(a, b) gets(a)
+
+#endif
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif
+
+#endif
diff --git a/src/nSocket/include/nstack_types.h b/src/include/types.h
index 90b538e..21e0dde 100644
--- a/src/nSocket/include/nstack_types.h
+++ b/src/include/types.h
@@ -14,19 +14,28 @@
* limitations under the License.
*/
-#ifndef _NSTACK_TYPES_H_
-#define _NSTACK_TYPES_H_
+#ifndef clib_types_h
+#define clib_types_h
+#include <stddef.h>
#include <semaphore.h>
#include <time.h>
#include <stdint.h>
#include <stdlib.h>
-#include <common_pal_bitwide_adjust.h>
+/* Standard CLIB types. */
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C"{
-/* *INDENT-ON* */
-#endif
+/* Define signed and unsigned 8, 16, 32, and 64 bit types
+ and machine signed/unsigned word for all architectures. */
+typedef char i8;
+typedef short i16;
+
+typedef unsigned char u8;
+typedef unsigned short u16;
+
+typedef int i32;
+typedef long long i64;
+
+typedef unsigned int u32;
+typedef unsigned long long u64;
#ifndef NSTACK_MAX_U32_NUM
#define NSTACK_MAX_U32_NUM ((u32_t)0xffffffff)
@@ -60,9 +69,6 @@ typedef uintptr_t mem_ptr_t;
typedef s8_t err_t;
-#define ERR_OK 0 /* No error, everything OK. */
-#define ERR_MEM -1 /* Out of memory error. */
-
#ifndef ns_bool
typedef unsigned char ns_bool;
#endif
@@ -143,10 +149,67 @@ typedef signed long ns_slong;
typedef unsigned long ns_ulong;
#endif
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
+#ifndef bool
+#define bool int
#endif
-#endif /* _NSTACK_TYPES_H_ */
+#ifndef TRUE
+#define TRUE 0x1
+#endif
+
+#ifndef true
+#define true 0x1
+#endif
+
+#ifndef FALSE
+#define FALSE 0x0
+#endif
+
+#ifndef false
+#define false 0x0
+#endif
+
+#ifndef NULL
+#define NULL ((void *)0)
+#endif
+
+#ifndef container_of
+#define container_of(ptr, type, member) ( \
+ \
+ (type *)((char *)(ptr) - offsetof(type,member)) \
+ \
+ )
+#endif
+
+#define PRIMARY_ADDR
+
+typedef struct _nsfw_res
+{
+ u8 alloc_flag;
+ u8 u8Reserve;
+ u16 chk_count;
+ u32 data;
+} nsfw_res;
+
+static inline void res_alloc(nsfw_res * res)
+{
+ res->alloc_flag = TRUE;
+ res->chk_count = 0;
+ /*solve the issue that tx and app tx buf leak in upgrade process */
+ res->u8Reserve = 0;
+}
+
+static inline int res_free(nsfw_res * res)
+{
+ if (TRUE != res->alloc_flag)
+ {
+ return -1;
+ }
+ res->chk_count = 0;
+ res->alloc_flag = FALSE;
+ return 0;
+}
+
+#define NSFW_THREAD __thread
+
+#endif /*clib_types_h */
diff --git a/src/nSocket/CMakeLists.txt b/src/nSocket/CMakeLists.txt
index 5701e8e..ec1f944 100644
--- a/src/nSocket/CMakeLists.txt
+++ b/src/nSocket/CMakeLists.txt
@@ -14,25 +14,22 @@
# limitations under the License.
#########################################################################
-
-if(WITH_HAL_LIB)
-else()
- SET(PAL_H_DIRECTORIES "/usr/include/dpdk/")
-endif()
-
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
INCLUDE_DIRECTORIES(
- include/
- kernel/
- nstack/
- nstack/event/
- nstack/event/epoll
- nstack/event/select
- ${SECUREC_SRC_H}
- ${PAL_H_DIRECTORIES}
- ${CMAKE_CURRENT_LIST_DIR}/../adapt
- ${CMAKE_CURRENT_LIST_DIR}/../../thirdparty/json/json-c-0.12.1
+ ${JSON_C_SRC}
+ ${CMAKE_CURRENT_LIST_DIR}/include
+ ${CMAKE_CURRENT_LIST_DIR}/kernel
+ ${CMAKE_CURRENT_LIST_DIR}/nstack
+ ${CMAKE_CURRENT_LIST_DIR}/nstack/event/
+ ${CMAKE_CURRENT_LIST_DIR}/nstack/event/epoll
+ ${CMAKE_SOURCE_DIR}/src/framework/event/epoll
+ ${CMAKE_CURRENT_LIST_DIR}/nstack/event/select
+ ${CMAKE_SOURCE_DIR}/src/framework/include
+ ${CMAKE_SOURCE_DIR}/src/framework/include/common/generic
+ ${CMAKE_SOURCE_DIR}/src/framework/include/common/
+ ${CMAKE_SOURCE_DIR}/src/framework/dfx
+ ${CMAKE_SOURCE_DIR}/src/include
)
-
FILE(GLOB_RECURSE nSocket *.c)
ADD_LIBRARY(nStackAPI SHARED ${nSocket})
TARGET_LINK_LIBRARIES(
@@ -40,10 +37,6 @@ TARGET_LINK_LIBRARIES(
-Wl,--whole-archive
${LIB_PATH_STATIC}/libjson-c.a
${LIB_PATH_STATIC}/libglog.a
- dmm_api
- -Wl,--no-whole-archive,-lstdc++
- rte_eal
- rte_mempool
- rte_mbuf
- rte_ring)
-ADD_DEPENDENCIES(nStackAPI dmm_api)
+ nStackFw
+ -Wl,--no-whole-archive,-lstdc++)
+ADD_DEPENDENCIES(nStackAPI nStackFw)
diff --git a/src/nSocket/include/declare_syscalls.h b/src/nSocket/include/declare_syscalls.h
deleted file mode 100644
index c4810f5..0000000
--- a/src/nSocket/include/declare_syscalls.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-NSTACK_MK_DECL (int, socket, (int, int, int));
-NSTACK_MK_DECL (int, bind, (int, const struct sockaddr *, socklen_t));
-NSTACK_MK_DECL (int, listen, (int, int));
-NSTACK_MK_DECL (int, shutdown, (int, int));
-NSTACK_MK_DECL (int, getsockname, (int, struct sockaddr *, socklen_t *));
-NSTACK_MK_DECL (int, getpeername, (int, struct sockaddr *, socklen_t *));
-NSTACK_MK_DECL (int, getsockopt, (int, int, int, void *, socklen_t *));
-NSTACK_MK_DECL (int, setsockopt, (int, int, int, const void *, socklen_t));
-NSTACK_MK_DECL (int, accept, (int, struct sockaddr *, socklen_t *));
-NSTACK_MK_DECL (int, accept4,
- (int, struct sockaddr *, socklen_t *, int flags));
-NSTACK_MK_DECL (int, connect, (int, const struct sockaddr *, socklen_t));
-NSTACK_MK_DECL (ssize_t, recv, (int, void *, size_t, int));
-NSTACK_MK_DECL (ssize_t, send, (int, const void *, size_t, int));
-NSTACK_MK_DECL (ssize_t, read, (int, void *, size_t));
-NSTACK_MK_DECL (ssize_t, write, (int, const void *, size_t));
-NSTACK_MK_DECL (ssize_t, writev, (int, const struct iovec *, int));
-NSTACK_MK_DECL (ssize_t, readv, (int, const struct iovec *, int));
-NSTACK_MK_DECL (ssize_t, sendto,
- (int, const void *, size_t, int, const struct sockaddr *,
- socklen_t));
-NSTACK_MK_DECL (ssize_t, recvfrom,
- (int, void *, size_t, int, struct sockaddr *, socklen_t *));
-NSTACK_MK_DECL (ssize_t, sendmsg, (int, const struct msghdr *, int flags));
-NSTACK_MK_DECL (ssize_t, recvmsg, (int, struct msghdr *, int flags));
-NSTACK_MK_DECL (int, close, (int));
-NSTACK_MK_DECL (int, select,
- (int, fd_set *, fd_set *, fd_set *, struct timeval *));
-NSTACK_MK_DECL (int, ioctl, (int, unsigned long, unsigned long));
-NSTACK_MK_DECL (int, fcntl, (int, int, unsigned long));
-NSTACK_MK_DECL (int, epoll_create, (int));
-NSTACK_MK_DECL (int, epoll_ctl, (int, int, int, struct epoll_event *));
-NSTACK_MK_DECL (int, epoll_wait, (int, struct epoll_event *, int, int));
-NSTACK_MK_DECL (pid_t, fork, (void));
-#undef NSTACK_MK_DECL
diff --git a/src/nSocket/include/nstack_atomic.h b/src/nSocket/include/nstack_atomic.h
index bb5ec13..119002e 100644
--- a/src/nSocket/include/nstack_atomic.h
+++ b/src/nSocket/include/nstack_atomic.h
@@ -19,7 +19,7 @@
#include <stdio.h>
#include <stdlib.h>
-#include "nstack_types.h"
+#include "types.h"
#ifdef __cplusplus
/* *INDENT-OFF* */
@@ -29,7 +29,7 @@ extern "C"{
typedef struct
{
- volatile ns_int32 counter;
+ volatile ns_int32 counter;
} atomic_t;
#define atomic_set(v, i) ((v)->counter = (i))
@@ -42,11 +42,11 @@ typedef struct
#define atomic_read(v) atomic_fetch_and_add(v, 0)
#define atomic_inc(v) atomic_add_and_fetch(v, 1)
-#define atomic_dec(v)atomic_sub_and_fetch(v, 1)
+#define atomic_dec(v) atomic_sub_and_fetch(v, 1)
#define atomic_add(v, i) atomic_add_and_fetch(v, i)
#define atomic_sub(v, i) atomic_sub_and_fetch(v,i)
-#define cas(ptr, oldValue, exchange) __sync_bool_compare_and_swap(ptr, oldValue, exchange)
+#define cas(ptr, oldValue, exchage) __sync_bool_compare_and_swap(ptr, oldValue, exchage)
#ifdef __cplusplus
/* *INDENT-OFF* */
diff --git a/src/nSocket/include/nstack_dmm_api.h b/src/nSocket/include/nstack_dmm_api.h
deleted file mode 100644
index ab06650..0000000
--- a/src/nSocket/include/nstack_dmm_api.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef __NSOCKET_DMM_API_H__
-#define __NSOCKET_DMM_API_H__
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/epoll.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include "nstack_rd_data.h"
-
-/*
- *Standard api interface definition.
- *these interface is provided by Protocol stack to nStack
- */
-typedef struct __nstack_socket_ops
-{
-#undef NSTACK_MK_DECL
-#define NSTACK_MK_DECL(ret, fn, args) ret (*pf##fn) args
-#include "declare_syscalls.h"
-} nstack_socket_ops;
-
-typedef enum
-{
- STACK_FD_INVALID_CHECK, /*check wether fd is created by this stack */
- STACK_FD_FUNCALL_CHECK, /*check this stack support default call */
-} nstack_fd_check;
-
-typedef enum
-{
- nstack_ep_triggle_add,
- nstack_ep_triggle_mod,
- nstack_ep_triggle_del
-} nstack_ep_triggle_ops_t;
-
-/*
- *Interactive interface for Protocol stack and nStack defined here
- *these interface is provided by Protocol stack to nStack
- */
-typedef struct __nstack_extern_ops
-{
- int (*module_init) (void); /*stack module init */
- int (*module_init_child) (void); /*stack module init for child process */
- int (*fork_init_child) (pid_t p, pid_t c); /*after fork, stack child process init again if needed. */
- void (*fork_parent_fd) (int s, pid_t p); /*after fork, stack parent process proc again if needed. */
- void (*fork_child_fd) (int s, pid_t p, pid_t c); /*after fork, child record pid for recycle if needed. */
- void (*fork_free_fd) (int s, pid_t p, pid_t c); /*for SOCK_CLOEXEC when fork if needed. */
- unsigned int (*ep_ctl) (int epFD, int proFD, int ctl_ops, struct epoll_event * event, void *pdata); /*when fd add to epoll fd, triggle stack to proc if need */
- unsigned int (*ep_getevt) (int epFD, int profd, unsigned int events); /*check whether some events exist really */
- int (*ep_prewait_proc) (int epfd);
- int (*stack_fd_check) (int s, int flag); /*check whether fd belong to stack, if belong, return 1, else return 0 */
- int (*stack_alloc_fd) (); /*alloc a fd id for epoll */
- int (*peak) (int s); /*used for stack-x , isource maybe no need */
-} nstack_extern_ops;
-
-/*
- *The event notify interface provided to the protocol stack by nStack
- *these interface is provided by nStack to Protocol stack
- */
-typedef struct __nstack_event_cb
-{
- void *handle; /*current so file handler */
- int type; /*nstack is assigned to the protocol stack and needs to be passed to nstack when the event is reported */
- int (*event_cb) (void *pdata, int events);
-} nstack_event_cb;
-
-typedef struct __nstack_proc_cb
-{
- nstack_socket_ops socket_ops; /*posix socket api */
- nstack_extern_ops extern_ops; /*other proc callback */
-} nstack_proc_cb;
-
-typedef int (*nstack_stack_register_fn) (nstack_proc_cb * proc_fun,
- nstack_event_cb * event_ops);
-
-#endif
diff --git a/src/nSocket/include/nstack_eventpoll.h b/src/nSocket/include/nstack_eventpoll.h
deleted file mode 100644
index afb0b05..0000000
--- a/src/nSocket/include/nstack_eventpoll.h
+++ /dev/null
@@ -1,338 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _NSTACK_EVENTPOOL_H
-#define _NSTACK_EVENTPOOL_H
-
-#include "ephlist.h"
-#include "eprb_tree.h"
-#include "common_mem_api.h"
-#include "types.h"
-#include <semaphore.h>
-#include <sys/epoll.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "nstack_securec.h"
-#include "nstack_log.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C"{
-/* *INDENT-ON* */
-#endif /* __cplusplus */
-
-#define NSTACK_MAX_EPOLL_INFO_NUM 8192
-#define NSTACK_MAX_EPOLL_NUM NSTACK_MAX_EPOLL_INFO_NUM
-#define NSTACK_MAX_EPITEM_NUM (NSTACK_MAX_EPOLL_NUM*2)
-
-#define MP_NSTACK_EPOLL_INFO_NAME "nsep_info"
-#define MP_NSTACK_EVENTPOLL_POOL "nsep_eventpoll" /* Pool of struct eventpoll */
-#define MP_NSTACK_EPITEM_POOL "nsep_epitem" /* Pool of struct epitem */
-
-#define MP_NSTACK_EPINFO_RING_NAME "nsep_info_ring"
-#define MP_NSTACK_EPITEM_RING_NAME "nsep_item_ring"
-#define MP_NSTACK_EVENTPOOL_RING_NAME "nsep_event_ring"
-
-#define NSTACK_FORK_NUM 32
-#define NSTACK_EPOL_FD 1
-
-#define NSEP_SMOD_MAX 8
-
-#define NSEP_EP_UNACTIVE_PTR ((void *) -1L)
-
-COMPAT_PROTECT (NSEP_SMOD_MAX, 8);
-
-typedef struct
-{
- u32 pid_used_size;
- u32 pid_array[NSTACK_FORK_NUM];
-} nsep_pidinfo;
-
-struct eventpoll
-{
-
- /*
- * Protect the this structure access
- * This is for event add to ready list and poll out
- */
- sys_sem_st lock;
-
- /*
- * This semaphore is used to ensure that files are not removed
- * while epoll is using them. This is read-held during the event
- * processing loop and it is write-held during the file cleanup
- * path, the epoll file exit code and the ctl operations.
- * When we do epoll_ctl, we write lock
- * When we collecting data , we read lock
- */
- sys_sem_st sem;
-
- /*
- * This semaphore is used to block epoll_wait function
- */
- sem_t waitSem;
-
- /* List of ready file descriptors */
- struct ep_hlist rdlist;
-
- /* When poll data out, we need this list to store tmp epitems */
- struct epitem *ovflist;
-
- /* RB-Tree root used to store mastered fd structs */
- struct ep_rb_root rbr;
-
- /* This specifies the file descriptor value of epoll instance, currenlty it is just used for debugging */
- int epfd;
- u32 pid;
- nsfw_res res_chk;
-};
-
-struct eventpoll_pool
-{
- void *ring;
- struct eventpoll *pool;
-};
-
-typedef struct
-{
- int iindex;
- int iNext;
- int fd;
- i32 epaddflag;
- i32 fdtype; /*0: socket fd, 1: epoll fd */
- i32 rlfd; /* copy of fdInf->rlfd */
- i32 rmidx; /* copy of fdInf->rmidx */
- i32 protoFD[NSEP_SMOD_MAX]; /* copy of fdInf->protoFD */// Here we need to set router infomations dependency
- struct eventpoll *ep;
- sys_sem_st epiLock;
- sys_sem_st freeLock;
- struct ep_list epiList; /* This restore the epitem of this file descriptor */
- u32 sleepTime; //add for NSTACK_SEM_SLEEP
- nsep_pidinfo pidinfo;
- nsfw_res res_chk;
- void *private_data; /*add for debug, just used to record extern infomation, for example sbr conn */
- i32 reserv[4];
-} nsep_epollInfo_t;
-
-typedef struct
-{
- void *ring;
- nsep_epollInfo_t *pool;
- char last_reserve[8]; //reserve for update
-} nsep_infoPool_t;
-
-struct epitem
-{
- struct ep_rb_node rbn;
- struct ep_hlist_node rdllink;
- struct ep_hlist_node lkFDllink;
- int nwait;
- struct eventpoll *ep;
- nsep_epollInfo_t *epInfo;
- struct epitem *next;
- struct epoll_event event;
- struct list_node fllink;
- unsigned int revents;
- unsigned int ovf_revents;
- int fd;
- u32 pid;
- void *private_data;
- nsfw_res res_chk;
-};
-
-struct epitem_pool
-{
- void *ring;
- struct epitem *pool;
-};
-
-typedef struct
-{
- struct eventpoll_pool epollPool;
- struct epitem_pool epitemPool;
- nsep_infoPool_t infoPool;
- nsep_epollInfo_t **infoSockMap; // The map of epInfo and socket
-
-} nsep_epollManager_t;
-extern nsep_epollManager_t g_epollMng;
-#define nsep_getManager() (&g_epollMng)
-
-extern int nsep_alloc_eventpoll (struct eventpoll **data);
-extern int nsep_free_eventpoll (struct eventpoll *ep);
-extern int nsep_alloc_epitem (struct epitem **data);
-extern int nsep_free_epitem (struct epitem *data);
-extern int nsep_alloc_epinfo (nsep_epollInfo_t ** data);
-extern int nsep_free_epinfo (nsep_epollInfo_t * info);
-
-extern int nsep_epitem_remove (nsep_epollInfo_t * pinfo, u32 pid);
-
-extern struct epitem *nsep_find_ep (struct eventpoll *ep, int fd);
-extern int nsep_epctl_add (struct eventpoll *ep, int fd,
- struct epoll_event *events);
-extern int nsep_epctl_del (struct eventpoll *ep, struct epitem *epi);
-extern int nsep_epctl_mod (struct eventpoll *ep,
- nsep_epollInfo_t * epInfo,
- struct epitem *epi, struct epoll_event *events);
-extern int nsep_ep_poll (struct eventpoll *ep, struct epoll_event *events,
- int maxevents, int *eventflag, int num);
-extern void nsep_remove_epfd (nsep_epollInfo_t * info);
-extern void nsep_close_epfd (struct eventpoll *ep);
-
-/**
- * @Function nsep_init_infoSockMap
- * @Description initial map of epoll info and socket
- * @param none
- * @return 0 on success, -1 on error
- */
-extern int nsep_init_infoSockMap ();
-extern void nsep_set_infoSockMap (int sock, nsep_epollInfo_t * info);
-extern nsep_epollInfo_t *nsep_get_infoBySock (int sock);
-extern int nsep_alloc_infoWithSock (int nfd);
-extern void nsep_set_infoProtoFD (int fd, int modInx, int protoFD);
-extern int nsep_get_infoProtoFD (int fd, int modInx);
-extern void nsep_set_infomdix (int fd, int rmidx);
-extern int nsep_get_infoMidx (int fd);
-extern void nsep_set_infoRlfd (int fd, int rlfd);
-extern int nsep_get_infoRlfd (int fd);
-extern void nsep_set_infoSleepTime (int fd, u32 sleepTime);
-extern int nsep_get_infoSleepTime (int fd);
-extern void nsep_set_infoEp (int fd, struct eventpoll *ep);
-extern struct eventpoll *nsep_get_infoEp (int fd);
-extern int nsep_free_infoWithSock (int sock);
-extern int nstack_ep_unlink (struct eventpoll *ep, struct epitem *epi);
-
-/* Attach shared memory */
-extern int nsep_create_memory ();
-extern int nsep_attach_memory ();
-extern int nsep_ep_fdinfo_release (int sock);
-extern int nsep_epoll_close (int sock);
-extern void nsep_fork_child_proc (u32_t ppid);
-extern void nsep_fork_parent_proc (u32_t ppid, u32_t cpid);
-
-static inline i32
-nsep_for_pidinfo_init (nsep_pidinfo * pidinfo)
-{
- int ret;
- ret = MEMSET_S (pidinfo, sizeof (*pidinfo), 0, sizeof (*pidinfo));
- if (EOK != ret)
- {
- NSSOC_LOGERR ("MEMSET_S failed]ret=%d", ret);
- return -1;
- }
- return 0;
-}
-
-static inline int
-nsep_add_pid (nsep_pidinfo * pidinfo, pid_t pid)
-{
- int i;
-
- for (i = 0; i < NSTACK_FORK_NUM; i++)
- {
- if ((0 == pidinfo->pid_array[i])
- && (__sync_bool_compare_and_swap (&pidinfo->pid_array[i], 0, pid)))
- {
- if (pidinfo->pid_used_size < i + 1)
- {
- pidinfo->pid_used_size = i + 1;
- }
- return 0;
- }
- }
- return -1;
-}
-
-static inline int
-nsep_del_pid (nsep_pidinfo * pidinfo, pid_t pid)
-{
- int i;
-
- for (i = 0; i < pidinfo->pid_used_size && i < NSTACK_FORK_NUM; i++)
- {
- if (pid == pidinfo->pid_array[i])
- {
- pidinfo->pid_array[i] = 0;
- return 0;
- }
- }
- return -1;
-}
-
-static inline int
-nsep_del_last_pid (nsep_pidinfo * pidinfo, pid_t pid)
-{
- int i;
- int count = 0;
- int deleted = 0;
- for (i = 0; i < pidinfo->pid_used_size && i < NSTACK_FORK_NUM; i++)
- {
- if (pid == pidinfo->pid_array[i])
- {
- pidinfo->pid_array[i] = 0;
- deleted = 1;
- continue;
- }
-
- if (pidinfo->pid_array[i] != 0)
- {
- ++count;
- }
- }
-
- if (!deleted)
- {
- return -1;
- }
-
- return count;
-}
-
-static inline int
-nsep_is_pid_exist (nsep_pidinfo * epinf, pid_t pid)
-{
- int i;
-
- for (i = 0; i < epinf->pid_used_size && i < NSTACK_FORK_NUM; i++)
- {
- if (pid == epinf->pid_array[i])
- {
- return 1;
- }
- }
- return 0;
-}
-
-static inline int
-nsep_is_pid_array_empty (nsep_pidinfo * epinf)
-{
- int i;
- for (i = 0; i < epinf->pid_used_size && i < NSTACK_FORK_NUM; i++)
- {
- if (epinf->pid_array[i] != 0)
- {
- return 0;
- }
- }
- return 1;
-}
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif /* __cplusplus */
-
-#endif /* _NSTACK_EVENTPOLL_H */
diff --git a/src/nSocket/include/nstack_ip_addr.h b/src/nSocket/include/nstack_ip_addr.h
deleted file mode 100644
index 8b15854..0000000
--- a/src/nSocket/include/nstack_ip_addr.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef __NSTACK_IP_ADDR_H__
-#define __NSTACK_IP_ADDR_H__
-
-#ifndef ip4_addr1_16
-#include "nstack_types.h"
-
-/* Get one byte from the 4-byte address */
-#define ip4_addr1(ipaddr) (((u8_t*)(ipaddr))[0]) /* ip4_addr1(ipaddr) */
-#define ip4_addr2(ipaddr) (((u8_t*)(ipaddr))[1]) /* ip4_addr2(ipaddr) */
-#define ip4_addr3(ipaddr) (((u8_t*)(ipaddr))[2]) /* ip4_addr3(ipaddr) */
-#define ip4_addr4(ipaddr) (((u8_t*)(ipaddr))[3]) /* ip4_addr4(ipaddr) */
-
-/* These are cast to u16_t, with the intent that they are often arguments
- * to printf using the U16_F format from cc.h. */
-#define ip4_addr1_16(ipaddr) ((u16_t)ip4_addr1(ipaddr)) /*ip4_addr1_16(ipaddr) */
-#define ip4_addr2_16(ipaddr) ((u16_t)ip4_addr2(ipaddr)) /*ip4_addr2_16(ipaddr) */
-#define ip4_addr3_16(ipaddr) ((u16_t)ip4_addr3(ipaddr)) /*ip4_addr3_16(ipaddr) */
-#define ip4_addr4_16(ipaddr) ((u16_t)ip4_addr4(ipaddr)) /*ip4_addr4_16(ipaddr) */
-#endif
-#endif
diff --git a/src/nSocket/include/nstack_rd.h b/src/nSocket/include/nstack_rd.h
index a93f6a6..0df64b2 100644
--- a/src/nSocket/include/nstack_rd.h
+++ b/src/nSocket/include/nstack_rd.h
@@ -17,31 +17,38 @@
#ifndef __NSTACK_RD_H
#define __NSTACK_RD_H
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include "nstack_rd_priv.h"
+
/*look up chose info by key*/
typedef struct __nstack_rd_key
{
- int type;
- union
- {
- unsigned int ip_addr;
- unsigned int proto_type;
- };
+ int type;
+ union
+ {
+ unsigned int ip_addr;
+ int socket_type;
+ int proto;
+ struct in6_addr in6_addr;
+ };
} nstack_rd_key;
-#define NSTACK_RD_MAX (1 * 1024 * 1024)
-
/*
*rd synchronism
*
*/
-int nstack_rd_sys ();
-int nstack_rd_age ();
+int nstack_rd_init(nstack_rd_stack_info * pstack, int num);
+int nstack_rd_sys();
+int nstack_rd_age();
+int nstack_rd_match_pre(int domain, int type, int protocol,
+ rd_data_item * item);
/*
*get stackid by some info
*if input is ip, the value must be net order
*
*/
-int nstack_rd_get_stackid (nstack_rd_key * addr, int *stackid);
+int nstack_rd_get_stackid(nstack_rd_key * addr, rd_data_item * item);
#endif
diff --git a/src/nSocket/include/nstack_rd_init.h b/src/nSocket/include/nstack_rd_init.h
deleted file mode 100644
index a8b2e9e..0000000
--- a/src/nSocket/include/nstack_rd_init.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _NSTACK_RD_INIT_H_
-#define _NSTACK_RD_INIT_H_
-#include "nstack_rd_data.h"
-
-#define NSTACK_RD_CHECK_BELONG (1)
-#define NSTACK_RD_CHECK_NOT_BELONG (0)
-
-typedef struct __nstack_stack_info
-{
- /*stack name */
- char name[STACK_NAME_MAX];
- /*stack id */
- int stack_id;
- /*when route info not found, high priority stack was chose, same priority chose fist input one */
- int priority; /*0: highest: route info not found choose first */
-} nstack_stack_info;
-
-/*get rd info. if return ok, data callee alloc memory, caller free, else caller don't free*/
-typedef int (*nstack_get_route_data) (rd_route_data ** data, int *num);
-
-/*
- *rd init
- *default id: if all module check fail, just return default id
- *return : 0 success, -1 fail
- */
-int nstack_rd_init (nstack_stack_info * pstack, int num,
- nstack_get_route_data * pfun, int fun_num);
-
-#endif
diff --git a/src/nSocket/nstack_rd/nstack_rd_priv.h b/src/nSocket/include/nstack_rd_priv.h
index 7179364..4069571 100644
--- a/src/nSocket/nstack_rd/nstack_rd_priv.h
+++ b/src/nSocket/include/nstack_rd_priv.h
@@ -17,17 +17,16 @@
#ifndef __NSTACK_RD_PRIV_H
#define __NSTACK_RD_PRIV_H
#include "list.h"
+#include "nstack_rd_data.h"
#define NSTACK_RD_SUCCESS (0)
#define NSTACK_RD_FAIL (-1)
#define NSTACK_RD_ITEM_MAX (1024)
#define NSTACK_RD_AGETIME_MAX (1)
-#define NSTACK_SYS_FUN_MAX (16)
-
-#define RD_LWIP "lwip"
-#define RD_KERNEL "kernel"
+#define RD_STACKPOOL_NAME "stackpool"
+#define RD_KERNEL_NAME "kernel"
#define NSTACK_RD_INDEX_BYIP(ip) (((ip) & 0xff) \
+ (((ip) >> 8)&0xff) \
+ (((ip) >> 16)&0xff) \
@@ -36,57 +35,64 @@
/*route data*/
typedef struct __rd_data_item
{
- /*route info type , for example base on ip */
- rd_data_type type;
- int stack_id;
- int agetime;
- union
- {
- rd_ip_data ipdata;
- unsigned int proto_type;
- };
+ /*route info type , for example base on ip */
+ rd_data_type type;
+ int stack_id;
+ int agetime;
+ union
+ {
+ rd_ip_data ipdata;
+ rd_type_data type_data;
+ rd_proto_data proto_data;
+ rd_ip6_data ip6data;
+ };
} rd_data_item;
/*stack rd node*/
typedef struct __nstack_rd_node
{
- struct hlist_node rdnode;
- rd_data_item item;
+ struct hlist_node rdnode;
+ rd_data_item item;
} nstack_rd_node;
typedef struct __nstack_rd_list
{
- struct hlist_head headlist;
+ struct hlist_head headlist;
} nstack_rd_list;
typedef struct __nstack_rd_stack_info
{
- /*stack name */
- char name[STACK_NAME_MAX];
- /*stack id */
- int stack_id;
- /*when route info not found, high priority stack was chose, same priority chose fist input one */
- int priority; /*0: highest: route info not found choose first */
+ /*stack name */
+ char name[STACK_NAME_MAX];
+ /*stack id */
+ int stack_id;
+ /*when route info not found, high priority stack was chose, same priority chose fist input one */
+ int priority; /*0: highest: route info not found choose first */
} nstack_rd_stack_info;
+typedef int (*nstack_get_route_data) (rd_route_data ** data, int *num,
+ int *ver, rd_route_table * handle);
+typedef int (*nstack_get_rdtble_ver) (int *ver, rd_route_table * handle);
+
/*rd local data*/
typedef struct __rd_local_data
{
- nstack_rd_stack_info *pstack_info;
- int stack_num;
- nstack_rd_list route_list[RD_DATA_TYPE_MAX]; /*route table */
- nstack_get_route_data sys_fun[NSTACK_SYS_FUN_MAX]; /*rd data sys proc function list */
- int fun_num;
+ int *rdlocal_ver;
+ nstack_rd_stack_info *pstack_info;
+ int stack_num;
+ nstack_rd_list route_list[RD_DATA_TYPE_MAX]; /*route table */
+ nstack_get_route_data sys_fun;
+ nstack_get_rdtble_ver rdtbl_ver_get_fun;
} rd_local_data;
typedef struct __rd_data_proc
{
- int (*rd_item_cpy) (void *destdata, void *srcdata);
- int (*rd_item_inset) (nstack_rd_list * hlist, void *rditem);
- int (*rd_item_age) (nstack_rd_list * hlist);
- int (*rd_item_find) (nstack_rd_list * hlist, void *rdkey, void *outitem);
- int (*rd_item_spec) (void *rdkey);
- int (*rd_item_default) (void *rdkey);
+ int (*rd_item_copy) (void *destdata, void *srcdata);
+ int (*rd_item_insert) (nstack_rd_list * hlist, void *rditem);
+ int (*rd_item_age) (nstack_rd_list * hlist);
+ void (*rd_item_clean) (nstack_rd_list * hlist);
+ int (*rd_item_find) (nstack_rd_list * hlist, void *rdkey, void *outitem);
+ int (*rd_item_spec) (void *rdkey);
} rd_data_proc;
extern rd_local_data *g_rd_local_data;
@@ -96,6 +102,4 @@ extern rd_data_proc g_rd_cpy[RD_DATA_TYPE_MAX];
#define NSTACK_RD_LIST(type) (&(g_rd_local_data->route_list[(type)]))
#define NSTACK_GET_STACK(idx) ((g_rd_local_data->pstack_info)[idx].stack_id)
-int nstack_get_stackid_byname (char *name);
-
#endif
diff --git a/src/nSocket/include/nstack_select.h b/src/nSocket/include/nstack_select.h
index 659c477..6c67c95 100644
--- a/src/nSocket/include/nstack_select.h
+++ b/src/nSocket/include/nstack_select.h
@@ -14,22 +14,6 @@
* limitations under the License.
*/
-/*==============================================*
- * include header files *
- *----------------------------------------------*/
-
-/*==============================================*
- * constants or macros define *
- *----------------------------------------------*/
-
-/*==============================================*
- * project-wide global variables *
- *----------------------------------------------*/
-
-/*==============================================*
- * routines' or functions' implementations *
- *----------------------------------------------*/
-
#define NSTACK_SELECT_MODULE
#ifdef NSTACK_SELECT_MODULE
@@ -37,6 +21,7 @@
#ifndef __NSTACK_SELECT_H__
#define __NSTACK_SELECT_H__
+/* move include files outside the extern C */
#include <sys/types.h>
#include <sys/time.h>
#include <stdio.h>
@@ -49,101 +34,153 @@ extern "C" {
/* *INDENT-ON* */
#endif
-typedef int (*get_select_event) (int nfds, fd_set * readfd,
- fd_set * writefd, fd_set * exceptfd,
- struct timeval * timeout);
+typedef int (*get_select_event) (int nfds, fd_set * readfd, fd_set * writefd,
+ fd_set * exceptfd, struct timeval * timeout);
typedef struct
{
- unsigned char fds_bits[(NSTACK_SETSIZE + 7) >> 3];
+ unsigned char *fds_bits; // (NSTACK_SETSIZE+7)>>3
} __attribute__ ((packed)) nstack_fd_set;
-#define NSTACK_FD_SET(n, p) ((p)->fds_bits[(n)>>3]|=1U<<((n)&0x07))
-#define NSTACK_FD_ISSET(n,p) (((p)->fds_bits[(n)>>3]&(1U<<((n)&0x07)))?1:0)
-#define NSTACK_FD_CLR(n,p) ((p)->fds_bits[(n)>>3]&=~(1U<<((n)&0x07)))
-#define NSTACK_FD_ZERO(p) (MEMSET_S((void *)(p), sizeof(*(p)),0,sizeof(*(p))))
+#define NSTACK_FD_SET(n, p) ((p)->fds_bits[(n)>>3]|=1U<<((n)&0x07))
+#define NSTACK_FD_ISSET(n,p) (((p)->fds_bits[(n)>>3]&(1U<<((n)&0x07)))?1:0)
+#define NSTACK_FD_CLR(n,p) ((p)->fds_bits[(n)>>3]&=~(1U<<((n)&0x07)))
+#define NSTACK_FD_ZERO(p, mem_size) (memset_s((void *)(p->fds_bits), mem_size,0,mem_size))
#define NSTACK_FD_OR(p1 ,p2) {\
int i;\
- for(i = 0; i < (NSTACK_SETSIZE+7)>>3; i++){\
+ for(i = 0; i < (NSTACK_SELECT_MAX_FD+7)>>3; i++){\
(p1)->fds_bits[i] |= (p2)->fds_bits[i];\
}\
}
struct select_cb_p
{
- union
- {
nstack_fd_set nstack_readset;
- fd_set readset;
- };
- union
- {
nstack_fd_set nstack_writeset;
- fd_set writeset;
- };
- union
- {
nstack_fd_set nstack_exceptset;
+
+ fd_set readset;
+ fd_set writeset;
fd_set exceptset;
- };
- union
- {
- i32 count;
- i32 readyset;
- };
+ union
+ {
+ i32 count;
+ i32 readyset;
+ };
- i32 inx;
- i32 select_errno;
+ i32 inx;
+ i32 select_errno;
};
struct select_entry_info
{
- i32 set_num; //how many select_c_p is set
- i32 index; //the first cb was set
+ i32 set_num; //how many select_c_p is set
+ i32 index; //the frist cb was set
};
struct select_entry
{
- struct select_cb_p cb[NSTACK_MAX_MODULE_NUM];
- struct select_cb_p ready;
- struct select_entry *next;
- struct select_entry *prev;
- struct select_entry_info info;
- select_sem_t sem;
+ struct select_cb_p cb[NSTACK_MAX_MODULE_NUM];
+ struct select_cb_p ready;
+ struct select_entry *next;
+ struct select_entry *prev;
+ struct select_entry_info info;
+ select_sem_t sem;
};
struct select_module_info
{
- struct select_entry *entry_head;
- struct select_entry *entry_tail;
- get_select_event get_select_fun_nonblock[NSTACK_MAX_MODULE_NUM];
- get_select_event get_select_fun_block[NSTACK_MAX_MODULE_NUM];
- get_select_event default_fun;
- i32 default_mod;
- volatile i32 inited;
- select_spinlock_t lock;
- select_sem_t sem;
+ struct select_entry *entry_head;
+ struct select_entry *entry_tail;
+ get_select_event get_select_fun_nonblock[NSTACK_MAX_MODULE_NUM];
+ get_select_event get_select_fun_block[NSTACK_MAX_MODULE_NUM];
+ get_select_event default_fun;
+ i32 default_mod;
+ volatile i32 inited;
+ select_spinlock_t lock;
+ select_sem_t sem;
};
-extern i32 select_cb_split_by_mod (i32 nfds,
- fd_set * readfd,
- fd_set * writefd,
- fd_set * exceptfd,
- struct select_entry *entry);
-extern void entry_module_fdset (struct select_entry *entry,
- i32 fd_size,
- nstack_fd_set * readfd,
- nstack_fd_set * writefd,
- nstack_fd_set * exceptfd, i32 inx);
-extern i32 select_scan (struct select_entry *entry);
-extern i32 select_add_cb (struct select_entry *entry);
-extern i32 select_rm_cb (struct select_entry *entry);
-extern i32 select_entry_reset (struct select_entry *entry);
-extern i32 select_module_init ();
-extern i32 select_module_init_child ();
-
-extern struct select_module_info *get_select_module (void);
+extern i32 select_cb_split_by_mod(i32 nfds,
+ fd_set * readfd,
+ fd_set * writefd,
+ fd_set * exceptfd,
+ struct select_entry *entry);
+extern void entry_module_fdset(struct select_entry *entry,
+ i32 fd_size,
+ nstack_fd_set * readfd,
+ nstack_fd_set * writefd,
+ nstack_fd_set * exceptfd, i32 inx);
+
+extern int nstack_select_processing(int nfds,
+ fd_set * readfds,
+ fd_set * writefds,
+ fd_set * exceptfds,
+ struct timeval *timeout);
+extern i32 select_scan(struct select_entry *entry);
+extern i32 select_add_cb(struct select_entry *entry);
+extern i32 select_rm_cb(struct select_entry *entry);
+extern i32 select_entry_reset(struct select_entry *entry);
+extern i32 select_module_init();
+extern struct select_module_info *get_select_module(void);
+
+#define NS_FD_ISSET(fd,set) ((set) &&(FD_ISSET(fd,set)))
+#define NFDS_NOT_VALID(nfds) (((nfds)>__FD_SETSIZE)||((nfds)<0))
+#define TIMEVAL_NOT_VALID(time) ((time)&&(((time)->tv_sec<0)||((time)->tv_usec<0)))
+#define TIMEVAL_EQUAL_ZERO(time) ((time)&&(((time)->tv_sec==0)&&((time)->tv_usec==0)))
+static inline void print_select_dbg(int nfds, fd_set * readfds,
+ fd_set * writefds, fd_set * exceptfds)
+{
+ int i;
+ for (i = 0; i < nfds; i++)
+ {
+
+ if (NS_FD_ISSET(i, readfds))
+ {
+ NSSOC_LOGDBG("input readfd set=%d", i);
+ }
+ if (NS_FD_ISSET(i, writefds))
+ {
+ NSSOC_LOGDBG("input writefd set=%d", i);
+ }
+ if (NS_FD_ISSET(i, exceptfds))
+ {
+ NSSOC_LOGDBG("input exceptfds set=%d", i);
+ }
+
+ }
+}
+
+static inline bool is_select_used_as_timer(int nfds, fd_set * readfds,
+ fd_set * writefds,
+ fd_set * exceptfds)
+{
+ return ((nfds <= 0)
+ || ((NULL == readfds) && (NULL == writefds)
+ && (NULL == exceptfds)));
+}
+
+static inline void *select_fd_set_bits_alloc()
+{
+ void *addr;
+ addr =
+ select_alloc(sizeof(unsigned char) *
+ ((NSTACK_SELECT_MAX_FD + 7) >> 3));
+ return addr;
+}
+
+static inline void select_fd_set_free(nstack_fd_set * addr)
+{
+ select_free(addr);
+}
+
+#define FREE_SELECT_FD_SET(readfd, writefd, exceptfd) {\
+ select_free(readfd);\
+ select_free(writefd);\
+ select_free(exceptfd);\
+}
+
#ifdef __cplusplus
/* *INDENT-OFF* */
}
diff --git a/src/nSocket/include/nstack_sockops.h b/src/nSocket/include/nstack_sockops.h
index 63fefee..3d86559 100644
--- a/src/nSocket/include/nstack_sockops.h
+++ b/src/nSocket/include/nstack_sockops.h
@@ -27,16 +27,19 @@ extern "C"{
#define NSTACK_CAL_FUN(ops, fun, args, retval) \
{\
+ /* reset retval before invoke api */ \
+ retval = -1;\
if(NULL != (ops) && NULL != (ops)->pf##fun)\
{\
if((retval = ((ops)->pf##fun args)) == -1)\
{\
- NSSOC_LOGDBG("function=%s execute failed,ret=%d.errno=%d.", #fun, retval, errno); \
+ NSSOC_LOGDBG("function excute failed] func=%s,ret=%d,errno=%d.", #fun, retval, errno); \
}\
}\
else\
{\
- NSSOC_LOGERR("NULL address erro, ops_pointer=%p,function=%s", (ops), #fun); \
+ /* the error info when it works well */ \
+ NSSOC_LOGDBG("NSTACK_CAL_FUN NULL] ops_pointer=%p,function=%s", (ops), #fun); \
errno = EBADF; \
}\
}
diff --git a/src/nSocket/include/select_adapt.h b/src/nSocket/include/select_adapt.h
index 2898c76..b655cf8 100644
--- a/src/nSocket/include/select_adapt.h
+++ b/src/nSocket/include/select_adapt.h
@@ -14,51 +14,23 @@
* limitations under the License.
*/
-/*==============================================*
- * include header files *
- *----------------------------------------------*/
-
-/*==============================================*
- * constants or macros define *
- *----------------------------------------------*/
-
-/*==============================================*
- * project-wide global variables *
- *----------------------------------------------*/
-
-/*==============================================*
- * routines' or functions' implementations *
- *----------------------------------------------*/
-
#ifndef __SELECT_ADAPT_H__
#define __SELECT_ADAPT_H__
#include "types.h"
#include "nstack_module.h"
-#include "common_mem_spinlock.h"
#include "nstack_securec.h"
-#include "common_func.h"
-
-#define SBR_MAX_FD_NUM MAX_SOCKET_NUM
-
-#define NSTACK_SELECT_MAX_FD 8192
-#define NSTACK_SETSIZE 8192
+#include "dmm_spinlock.h"
+#include "nsfw_maintain_api.h"
-#define FREE_FD_SET(readfd, writefd, exceptfd) {\
- if(readfd)\
- free(readfd);\
- if(writefd)\
- free(writefd);\
- if(exceptfd)\
- free(exceptfd);\
-}
+#define NSTACK_SELECT_MAX_FD MAX_SOCKET_NUM //CFG(CFG_MAX_SOCKET_NUM)
typedef sem_t select_sem_t;
-typedef common_mem_spinlock_t select_spinlock_t;
+typedef dmm_spinlock_t select_spinlock_t;
-#define select_spin_lock(lock) (common_mem_spinlock_lock((lock)))
-#define select_spin_unlock(lock) (common_mem_spinlock_unlock((lock)))
-#define select_spin_lock_init(lock) (common_mem_spinlock_init((lock)))
+#define select_spin_lock(lock) (dmm_spin_lock((lock)))
+#define select_spin_unlock(lock) (dmm_spin_unlock((lock)))
+#define select_spin_lock_init(lock) (dmm_spin_init((lock)))
#define select_sem_wait(sem) (sem_wait((sem)))
#define select_sem_init(sem, share, val) (sem_init((sem), (share), (val)))
@@ -66,40 +38,38 @@ typedef common_mem_spinlock_t select_spinlock_t;
/*************input form other modules***************************/
extern nstack_module_info g_nstack_modules;
-#define get_mode_num() (g_nstack_modules.modNum)
-#define get_mode_linux_index() (g_nstack_modules.fix_mid)
struct select_comm_fd_map
{
- i32 mod_fd[NSTACK_MAX_MODULE_NUM]; //save modules fd
- i32 index; //-1 mean not select modules
+ i32 mod_fd[NSTACK_MAX_MODULE_NUM]; //save modules fd
+ i32 index; //-1 mean not select modules
};
struct select_mod_fd_map
{
- i32 *comm_fd; //the fd app used
+ i32 *comm_fd; //the fd app used
};
struct select_fd_map_inf
{
- struct select_comm_fd_map *fdinf; //NSTACK_MAX_SOCK_NUM
- struct select_mod_fd_map modinf[NSTACK_MAX_MODULE_NUM];
+ struct select_comm_fd_map *fdinf; //NSTACK_MAX_SOCK_NUM
+ struct select_mod_fd_map modinf[NSTACK_MAX_MODULE_NUM];
};
-void *select_alloc (int size);
-void select_free (char *p);
-void reset_select_fdinf (i32 fd);
-i32 select_get_modfd (i32 fd, i32 inx);
-i32 select_set_modfd (i32 fd, i32 inx, i32 modfd);
-i32 select_get_modindex (i32 fd);
-i32 select_get_commfd (i32 modfd, i32 inx);
-i32 select_set_commfd (i32 modfd, i32 inx, i32 fd);
-i32 fdmapping_init (void);
-i32 select_set_index (i32 fd, i32 inx);
-i32 select_set_profd (i32 fd, i32 profd);
-void nssct_close (i32 cfd, i32 inx);
-void nssct_create (i32 cfd, i32 mfd, i32 inx);
-void nssct_set_index (i32 fd, i32 inx);
+void *select_alloc(int size);
+void select_free(void *p);
+void reset_select_fdinf(i32 fd);
+i32 select_get_modfd(i32 fd, i32 inx);
+i32 select_set_modfd(i32 fd, i32 inx, i32 modfd);
+i32 select_get_modindex(i32 fd);
+i32 select_get_commfd(i32 modfd, i32 inx);
+i32 select_set_commfd(i32 modfd, i32 inx, i32 fd);
+i32 fdmapping_init(void);
+i32 select_set_index(i32 fd, i32 inx);
+i32 select_set_profd(i32 fd, i32 profd);
+void nssct_close(i32 cfd, i32 inx);
+void nssct_create(i32 cfd, i32 mfd, i32 inx);
+void nssct_set_index(i32 fd, i32 inx);
#endif
diff --git a/src/nSocket/kernel/linux_kernel_module.c b/src/nSocket/kernel/linux_kernel_module.c
index eb3dd8d..71371bb 100644
--- a/src/nSocket/kernel/linux_kernel_module.c
+++ b/src/nSocket/kernel/linux_kernel_module.c
@@ -24,310 +24,313 @@
#include<unistd.h>
#include <string.h>
#include <pthread.h>
-#include "nstack_types.h"
+#include "types.h"
#include "nstack_sockops.h"
#include "nstack_log.h"
#include "linux_kernel_module.h"
#include "linux_kernel_socket.h"
#include "nsfw_base_linux_api.h"
#include "nstack_fd_mng.h"
-#include "nstack_dmm_api.h"
+#include "nstack_epoll_api.h"
+#include "dmm_spinlock.h"
+#include "nsfw_mem_api.h"
+#include "nstack_info_parse.h"
+#include "nstack_eventpoll.h"
+#include "nstack_rd_api.h"
#define SK_MAX_EP_EVENT 1024
-kernel_stack_info_t g_ksInfo = {.thread_inited = ks_false,.epfd =
- -1,.checkEpollFD = -1
-};
+void *krd_table = NULL;
+kernel_stack_info_t g_ksInfo = {.thread_inited = ks_false };
/*design ensures that g_ksInfo is not write accessed at the same time.
only read is done simultaneously with no chance of other thread writing it.
so no protection needed.*/
-/* Custodial pointer not freed for events at end of this function */
-/* This can be ignored as this is a thread and runs in infinite loop. Hence will never return */
-void *
-ks_ep_thread (void *arg)
+
+/*no need to free these points because the function is always running */
+/*point is set to NULL because it's freeed */
+void *ks_ep_thread(void *arg)
{
- int eventNum = 0;
- int loop = 0;
- struct epoll_event *events =
- (struct epoll_event *) malloc (SK_MAX_EP_EVENT *
- sizeof (struct epoll_event));
- struct epoll_event *innerEvt =
- (struct epoll_event *) malloc (SK_MAX_EP_EVENT *
- sizeof (struct epoll_event));
-
- if (NULL == events || NULL == innerEvt)
+ int eventNum = 0;
+ int loop = 0;
+ int retval = 0;
+ int ret;
+ nsep_epollInfo_t *epInfo;
+ struct epoll_event *events =
+ (struct epoll_event *) malloc(SK_MAX_EP_EVENT *
+ sizeof(struct epoll_event));
+ struct epoll_event *innerEvt =
+ (struct epoll_event *) malloc(SK_MAX_EP_EVENT *
+ sizeof(struct epoll_event));
+ struct list_node *fdEpiHead;
+ struct list_node *node;
+ struct epitem *epi = NULL;
+ struct eventpoll *ep = NULL;
+
+ if (NULL == events || NULL == innerEvt)
{
- NSSOC_LOGERR ("malloc events failed");
+ NSSOC_LOGERR("malloc events failed");
- if (events)
+ if (events)
{
- free (events);
- events = NULL; /* Set NULL to pointer after free */
+ free(events);
+ events = NULL; /* Set NULL to pointer after free */
}
- if (innerEvt)
+ if (innerEvt)
{
- free (innerEvt);
- innerEvt = NULL; /* Set NULL to pointer after free */
+ free(innerEvt);
+ innerEvt = NULL; /* Set NULL to pointer after free */
}
- /* When ks_ep_thread failed, it should set g_ksInfo.thread_inited ks_true, otherwise,it will result kernel_stack_register in dead loop */
- g_ksInfo.thread_inited = ks_true;
- return NULL;
+
+ /* When ks_ep_thread failed, it should set g_ksInfo.thread_inited ks_true, otherwise,it will result kernel_stack_register in dead loop */
+ g_ksInfo.thread_inited = ks_true;
+ return NULL;
}
- if (-1 == g_ksInfo.epfd)
+ retval =
+ memset_s(events, SK_MAX_EP_EVENT * sizeof(struct epoll_event), 0,
+ SK_MAX_EP_EVENT * sizeof(struct epoll_event));
+ retval |=
+ memset_s(innerEvt, SK_MAX_EP_EVENT * sizeof(struct epoll_event), 0,
+ SK_MAX_EP_EVENT * sizeof(struct epoll_event));
+
+ if (EOK != retval)
{
- NSTACK_CAL_FUN (&g_ksInfo.libcOps, epoll_create, (1), g_ksInfo.epfd);
+ free(events);
+ events = NULL;
+ free(innerEvt);
+ innerEvt = NULL;
+ g_ksInfo.thread_inited = ks_true;
+ return NULL;
}
- if (-1 == g_ksInfo.epfd)
+ NSTACK_CAL_FUN(&g_ksInfo.libcOps, epoll_create, (1), g_ksInfo.epfd);
+
+ if (-1 == g_ksInfo.epfd)
{
- g_ksInfo.thread_inited = ks_true;
+ g_ksInfo.thread_inited = ks_true;
- if (events)
+ if (events)
{
- free (events);
- events = NULL; /* Set NULL to pointer after free */
+ free(events);
+ events = NULL; /* Set NULL to pointer after free */
}
- if (innerEvt)
+ if (innerEvt)
{
- free (innerEvt);
- innerEvt = NULL; /* Set NULL to pointer after free */
+ free(innerEvt);
+ innerEvt = NULL; /* Set NULL to pointer after free */
}
- return NULL;
+ return NULL;
}
- g_ksInfo.thread_inited = ks_true;
+ g_ksInfo.thread_inited = ks_true;
- do
+ do
{
- NSTACK_CAL_FUN (&g_ksInfo.libcOps, epoll_wait,
- (g_ksInfo.epfd, events, SK_MAX_EP_EVENT, -1), eventNum);
+ NSTACK_CAL_FUN(&g_ksInfo.libcOps, epoll_wait,
+ (g_ksInfo.epfd, events, SK_MAX_EP_EVENT, -1),
+ eventNum);
- if (0 == eventNum)
+ if (0 == eventNum)
{
- sys_sleep_ns (0, 100000);
+ sys_sleep_ns(0, 100000);
}
- for (loop = 0; loop < eventNum; loop++)
+ for (loop = 0; loop < eventNum; loop++)
{
- NSSOC_LOGDBG ("Epoll]events=%u,epfd=%d", events[loop].events,
- events[loop].data.fd);
+ NSSOC_LOGDBG("Epoll]events=%u,epfd=%d", events[loop].events,
+ events[loop].data.fd);
- if (events[loop].events & EPOLLIN)
+ if (events[loop].events & EPOLLIN)
{
- int i = 0, num = 0, ret = 0, epfd = events[loop].data.fd;
- NSTACK_CAL_FUN (&g_ksInfo.libcOps, epoll_wait,
- (epfd, innerEvt, SK_MAX_EP_EVENT, 0), num);
+ int i = 0, num = 0, epfd = events[loop].data.fd;
+ NSTACK_CAL_FUN(&g_ksInfo.libcOps, epoll_wait,
+ (epfd, innerEvt, SK_MAX_EP_EVENT, 0), num);
- if (0 == num)
+ if (0 == num)
{
- NSSOC_LOGWAR ("Num is zero");
- continue;
+ /* remove it becasue print in normal scenario */
+ NSSOC_LOGDBG("Num is zero]epfd=%d", epfd);
+ continue;
}
- NSTACK_CAL_FUN (&g_ksInfo.libcOps, epoll_ctl,
- (g_ksInfo.epfd, EPOLL_CTL_DEL, epfd, NULL),
- ret);
+ NSTACK_CAL_FUN(&g_ksInfo.libcOps, epoll_ctl,
+ (g_ksInfo.epfd, EPOLL_CTL_DEL, epfd, NULL),
+ ret);
- ret = -1;
- for (i = 0; i < num; i++)
+ for (i = 0; i < num; i++)
{
- ret &=
- g_ksInfo.regVal.event_cb (innerEvt[i].data.ptr,
- innerEvt[i].events);
- NSSOC_LOGDBG ("Kernel got one event]i=%d,ptr=%d,events=%u",
- i, innerEvt[i].data.ptr, innerEvt[i].events);
- }
+ epInfo = nsep_get_info_by_sock(innerEvt[i].data.fd);
+
+ if (epInfo
+ && (epInfo->rmidx < 0
+ || epInfo->rmidx == g_ksInfo.regVal.type))
+ {
+ dmm_spin_lock_with_pid((dmm_spinlock_t
+ *) (&epInfo->epiLock));
+ fdEpiHead =
+ (struct list_node *)
+ SHMEM_ADDR_SHTOL(epInfo->epiList.head);
+ node =
+ (struct list_node *)
+ SHMEM_ADDR_SHTOL(fdEpiHead->next);
+ while (node)
+ {
+
+ epi =
+ (struct epitem *) ep_list_entry(node,
+ struct
+ epitem,
+ fllink);
+
+ node =
+ (struct list_node *)
+ SHMEM_ADDR_SHTOL(node->next);
+ ep = (struct eventpoll *)
+ SHMEM_ADDR_SHTOL(epi->ep);
+
+ if (!(epi->event.events & innerEvt[i].events))
+ {
+ continue;
+ }
+
+ if (ep->pid != get_sys_pid())
+ {
+ continue;
+ }
+
+ epi->revents |= innerEvt[i].events;
+ }
+
+ dmm_spin_unlock((dmm_spinlock_t
+ *) (&epInfo->epiLock));
+ g_ksInfo.regVal.event_cb(epInfo, innerEvt[i].events,
+ EVENT_INFORM_APP);
+ NSSOC_LOGDBG
+ ("Kernel got one event]i=%d,fd=%d,events=%u", i,
+ innerEvt[i].data.fd, innerEvt[i].events);
+ }
- if (ret)
- {
- struct epoll_event ev;
- ev.data.fd = epfd;
- ev.events = EPOLLIN;
- NSTACK_CAL_FUN (&g_ksInfo.libcOps, epoll_ctl,
- (g_ksInfo.epfd, EPOLL_CTL_ADD, epfd, &ev),
- ret);
}
}
}
}
- while (1);
+ while (1);
+}
+int kernel_load_default_rd(void *table)
+{
+ rd_ip_data ip_data;
+ ip_data.addr = inet_addr("127.0.0.1"); // loopback address
+ ip_data.masklen = 0;
+ ip_data.resev[0] = ip_data.resev[1] = 0;
+ (void) nstack_rd_ip_node_insert(RD_KERNEL_NAME, &ip_data, table);
+ NSSOC_LOGINF("successfully load default rd");
+ return 0;
}
-int
-kernel_fd_check (int fd, int flag)
+void *kernel_get_ip_shmem()
{
- struct epoll_event event;
- event.data.fd = fd;
- event.events = EPOLLIN | EPOLLERR;
- if (fd == g_ksInfo.checkEpollFD)
- {
- return 0;
- }
+ return krd_table;
+}
- /*in order to reduce the cost of epoll ctl */
- if (STACK_FD_FUNCALL_CHECK == flag)
- {
- return 1;
- }
+int kernel_module_init()
+{
+ krd_table = nstack_local_rd_malloc();
- if (-1 ==
- nsfw_base_epoll_ctl (g_ksInfo.checkEpollFD, EPOLL_CTL_ADD, fd, &event))
+ if (!krd_table)
{
- return 0;
+ NSSOC_LOGERR("kernel rd table create failed!");
+ return -1;
}
- nsfw_base_epoll_ctl (g_ksInfo.checkEpollFD, EPOLL_CTL_DEL, fd, NULL);
- return 1;
-}
-
-int
-kernel_prewait_proc (int epfd)
-{
- int ret = 0;
- struct epoll_event ep_event;
-
- NSSOC_LOGINF ("epfd=%d was added", epfd);
- if (epfd < 0)
+ if (nstack_rd_parse(RD_KERNEL_NAME, krd_table))
{
- return -1;
+ NSSOC_LOGWAR("kernel parse rd data failed, load default instead");
+ nstack_rd_table_clear(krd_table);
+ return kernel_load_default_rd(krd_table);
}
- ep_event.data.fd = epfd;
- ep_event.events = EPOLLIN | EPOLLET;
- ret = lk_epollctl (0, EPOLL_CTL_ADD, epfd, &ep_event);
- return ret;
+
+ return 0;
}
-unsigned int
-kernel_ep_fd_add (int epFD, int proFD, int ctl_ops,
- struct epoll_event *events, void *pdata)
+int kernel_stack_register
+ (nstack_socket_ops * ops,
+ nstack_event_ops * val, nstack_proc_ops * fddeal)
{
- struct epoll_event tmpEvt;
- int ret = 0;
- tmpEvt.data.ptr = pdata;
- tmpEvt.events = events->events;
- NSSOC_LOGINF ("epfd=%d,fd=%d,ops=%d, events=%u", epFD, proFD, ctl_ops,
- events->events);
- switch (ctl_ops)
+ /* Input parameter validation */
+ if ((NULL == ops) || (NULL == val) || (NULL == fddeal))
{
- case nstack_ep_triggle_add:
- ret = nsfw_base_epoll_ctl (epFD, EPOLL_CTL_ADD, proFD, &tmpEvt);
- break;
- case nstack_ep_triggle_mod:
- ret = nsfw_base_epoll_ctl (epFD, EPOLL_CTL_MOD, proFD, &tmpEvt);
- break;
- case nstack_ep_triggle_del:
- ret = nsfw_base_epoll_ctl (epFD, EPOLL_CTL_DEL, proFD, &tmpEvt);
- break;
- default:
- ret = -1;
- break;
+ NSPOL_LOGERR("input param is NULL");
+ return ks_fail;
}
- return ret;
-}
-int
-kernel_socket (int a, int b, int c)
-{
+#undef NSTACK_MK_DECL
+#define NSTACK_MK_DECL(ret, fn, args) \
+ g_ksInfo.libcOps.pf##fn = nsfw_base_##fn;
+/*this file can be included more than once */
+#include "declare_syscalls.h.tmpl"
- return nsfw_base_socket (a, b, c);
-}
+ g_ksInfo.epfd = -1;
+ g_ksInfo.regVal = *val;
-int
-kernel_module_init ()
-{
- int retval = 0;
+#ifdef KERNEL_FD_SUPPORT
+ g_ksInfo.thread_inited = ks_false;
- g_ksInfo.thread_inited = ks_false;
- retval = pthread_create (&g_ksInfo.ep_thread, NULL, ks_ep_thread, NULL);
- if (retval != 0)
- {
- NSPOL_LOGERR ("kernel ep thread create fail, errno:%d!", errno);
- return ks_fail;
- }
+ NSSOC_LOGDBG("start to regist stack");
- /* The earlier thread "ep_thread" created will exit automatically when
- return failure from below if any failure */
- retval = pthread_setname_np (g_ksInfo.ep_thread, K_EPOLL_THREAD_NAME);
- if (retval != 0)
+ if (pthread_create(&g_ksInfo.ep_thread, NULL, ks_ep_thread, NULL))
{
- NSMON_LOGERR
- ("pthread_setname_np failed for ep_thread]retval=%d, errno:%d",
- retval, errno);
- /*set thread name failed no need to return */
+ NSPOL_LOGERR("Err!");
+ return ks_fail;
}
- NSSOC_LOGDBG ("New thread started");
+ /* The earlier thread "ep_thread" created will exit automatically when
+ return failure from below if any failure */
+ int retval = 0;
- do
+ if (pthread_setname_np(g_ksInfo.ep_thread, K_EPOLL_THREAD_NAME))
{
- sys_sleep_ns (0, 0);
+ NSMON_LOGERR("pthread_setname_np failed for ep_thread]retval=%d",
+ retval);
+ /*set thread name failed no need to return */
}
- while (!g_ksInfo.thread_inited);
- if (-1 == g_ksInfo.epfd)
+ NSSOC_LOGDBG("New thread started");
+
+ do
{
- NSPOL_LOGERR ("thread epoll create Err!");
- retval |= -1;
+ sys_sleep_ns(0, 0);
}
- return retval;
-}
-
-int
-kernel_fd_alloc ()
-{
- return nsfw_base_socket (AF_UNIX, SOCK_DGRAM, 0);
-}
+ while (!g_ksInfo.thread_inited);
-int
-kernel_stack_register (nstack_proc_cb * ops, nstack_event_cb * val)
-{
- int retval = 0;
- /* Input parameter validation */
- if ((NULL == ops) || (NULL == val))
+ if (-1 == g_ksInfo.epfd)
{
- NSPOL_LOGERR ("input param is NULL");
- return ks_fail;
+ NSPOL_LOGERR("Err!");
+ retval = -1;
}
-#undef NSTACK_MK_DECL
-#define NSTACK_MK_DECL(ret, fn, args) \
- g_ksInfo.libcOps.pf##fn = nsfw_base_##fn;
-
-#include "declare_syscalls.h"
-
- g_ksInfo.regVal = *val;
+#endif
- /*create a efpd to check fd is ok */
- if (g_ksInfo.checkEpollFD == -1)
- {
- g_ksInfo.checkEpollFD = nsfw_base_epoll_create (1);
- }
+ *ops = g_ksInfo.libcOps;
- NSSOC_LOGDBG ("start to regist stack");
+ NSTACK_SET_OPS_FUN(ops, listen, lk_listen);
+ NSTACK_SET_OPS_FUN(ops, epoll_ctl, lk_epollctl);
- ops->socket_ops = g_ksInfo.libcOps;
- MEMSET_S (&(ops->extern_ops), sizeof (ops->extern_ops), 0,
- sizeof (ops->extern_ops));
- NSTACK_SET_OPS_FUN (&(ops->socket_ops), listen, lk_listen);
- NSTACK_SET_OPS_FUN (&(ops->socket_ops), epoll_ctl, lk_epollctl);
- NSTACK_SET_OPS_FUN (&(ops->socket_ops), socket, kernel_socket);
- ops->extern_ops.stack_fd_check = kernel_fd_check;
- ops->extern_ops.ep_ctl = kernel_ep_fd_add;
- ops->extern_ops.ep_prewait_proc = kernel_prewait_proc;
- ops->extern_ops.module_init = kernel_module_init;
- ops->extern_ops.module_init_child = kernel_module_init;
- ops->extern_ops.stack_alloc_fd = kernel_fd_alloc;
+ /* don't close file descriptor */
- /* don't close file descriptor */
+ fddeal->module_init = kernel_module_init;
+ fddeal->get_ip_shmem = kernel_get_ip_shmem;
- return retval ? ks_fail : ks_success;
+#ifdef KERNEL_FD_SUPPORT
+ return retval ? ks_fail : ks_success;
+#else
+ return ks_success;
+#endif
}
diff --git a/src/nSocket/kernel/linux_kernel_module.h b/src/nSocket/kernel/linux_kernel_module.h
index 01e0330..cdb88f0 100644
--- a/src/nSocket/kernel/linux_kernel_module.h
+++ b/src/nSocket/kernel/linux_kernel_module.h
@@ -17,10 +17,11 @@
#ifndef _LINUX_KERNEL_MODULE_H_
#define _LINUX_KERNEL_MODULE_H_
-#include "nstack_dmm_api.h"
+#include "nstack_callback_ops.h"
-#define K_SELECT_THREAD_NAME "kernel_select"
-#define K_EPOLL_THREAD_NAME "kernel_epoll"
+#define DMM_MEM_LIB_PATH_LEN 256
+
+#define K_EPOLL_THREAD_NAME "nstk_ker_epoll"
#ifndef ks_success
#define ks_success 0
@@ -42,20 +43,21 @@ typedef char ks_bool;
#define ks_true 1
#endif
-int kernel_stack_register (nstack_proc_cb * ops, nstack_event_cb * val);
+int kernel_stack_register
+ (nstack_socket_ops * ops,
+ nstack_event_ops * val, nstack_proc_ops * fddeal);
typedef struct
{
- nstack_event_cb regVal;
- int epfd;
- int checkEpollFD;
- pthread_t ep_thread;
- ks_bool thread_inited;
- pthread_t select_thread; //listen select events
- nstack_socket_ops libcOps;
+ nstack_event_ops regVal;
+ int epfd;
+ pthread_t ep_thread;
+ ks_bool thread_inited;
+ pthread_t select_thread; //listen select events
+ nstack_socket_ops libcOps;
} kernel_stack_info_t;
extern kernel_stack_info_t g_ksInfo;
-extern int linux_kernel_stack_init (void);
+extern int linux_kernel_stack_init(void);
#endif
diff --git a/src/nSocket/kernel/linux_kernel_socket.c b/src/nSocket/kernel/linux_kernel_socket.c
index b7ac028..5b7c9fd 100644
--- a/src/nSocket/kernel/linux_kernel_socket.c
+++ b/src/nSocket/kernel/linux_kernel_socket.c
@@ -29,36 +29,36 @@
#include "nstack_sockops.h"
#include "nstack_securec.h"
-int
-lk_listen (int sockfd, int backlog)
+int lk_listen(int sockfd, int backlog)
{
- int ret = -1;
+ int ret = -1;
- NSTACK_CAL_FUN (&g_ksInfo.libcOps, listen, (sockfd, backlog), ret);
- return ret;
+ NSTACK_CAL_FUN(&g_ksInfo.libcOps, listen, (sockfd, backlog), ret);
+
+ return ret;
}
-int
-lk_epollctl (int epfd, int op, int protoFd, struct epoll_event *event)
+int lk_epollctl(int epfd, int op, int protoFd, struct epoll_event *event)
{
- int retVal;
- struct epoll_event ev;
+ int retVal;
+ struct epoll_event ev;
- /* Input parameter validation */
- if (NULL == event)
+ /* Input parameter validation */
+ if (NULL == event)
{
- NSSOC_LOGERR ("input param event is NULL");
- return -1;
+ NSSOC_LOGERR("input param event is NULL");
+ return -1;
}
- retVal =
- MEMCPY_S (&ev, sizeof (struct epoll_event), event,
- sizeof (struct epoll_event));
- if (EOK != retVal)
+ /*There are some unsafe function ,need to be replace with safe function */
+ retVal =
+ memcpy_s(&ev, sizeof(struct epoll_event), event,
+ sizeof(struct epoll_event));
+ if (EOK != retVal)
{
- NSSOC_LOGERR ("MEMCPY_S failed]ret=%d", retVal);
- return -1;
+ NSSOC_LOGERR("memcpy_s failed]ret=%d", retVal);
+ return -1;
}
- ev.data.fd = protoFd;
- return g_ksInfo.libcOps.pfepoll_ctl (g_ksInfo.epfd, op, protoFd, &ev);
+ ev.data.fd = protoFd;
+ return g_ksInfo.libcOps.pfepoll_ctl(g_ksInfo.epfd, op, protoFd, &ev);
}
diff --git a/src/nSocket/kernel/linux_kernel_socket.h b/src/nSocket/kernel/linux_kernel_socket.h
index 9c3d692..790ab2c 100644
--- a/src/nSocket/kernel/linux_kernel_socket.h
+++ b/src/nSocket/kernel/linux_kernel_socket.h
@@ -23,9 +23,9 @@ extern "C"{
/* *INDENT-ON* */
#endif
-extern int lk_listen (int sockfd, int backlog);
-extern int lk_epollctl (int epfd, int op, int protoFd,
- struct epoll_event *event);
+extern int lk_listen(int sockfd, int backlog);
+extern int lk_epollctl(int epfd, int op, int protoFd,
+ struct epoll_event *event);
#ifdef __cplusplus
/* *INDENT-OFF* */
diff --git a/src/nSocket/nstack/event/epoll/nstack_epoll.c b/src/nSocket/nstack/event/epoll/nstack_epoll.c
new file mode 100644
index 0000000..d1a006f
--- /dev/null
+++ b/src/nSocket/nstack/event/epoll/nstack_epoll.c
@@ -0,0 +1,887 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#include "nstack_eventpoll.h"
+#include "nstack_log.h"
+#include "nsfw_recycle_api.h"
+#include "nstack_securec.h"
+#include "nstack_module.h"
+#include "nstack_sockops.h"
+#include "nsfw_mem_api.h"
+#include "nstack_fd_mng.h"
+#include "nstack.h"
+#include "dmm_spinlock.h"
+#include "nsfw_base_linux_api.h"
+#include "nstack_dmm_dfx.h"
+#include "nstack_epoll_api.h"
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C"{
+/* *INDENT-ON* */
+#endif /* __cplusplus */
+
+const int EPOLL_DFX_OPS_MAP[nstack_ep_event_max] =
+ { DMM_APP_EPOLL_ADD_TICK, DMM_APP_EPOLL_MOD_TICK, DMM_APP_EPOLL_DEL_TICK,
+ DMM_DFX_MAX
+};
+
+static inline void *nstack_ep_triggle
+ (int proFD,
+ int modInx,
+ int triggle_ops, struct epitem *epi, nsep_epollInfo_t * epinfo)
+{
+ void *data = NULL;
+ int events = 0;
+
+ if (nstack_fd_deal[modInx].ep_triggle != NULL)
+ {
+ data =
+ nstack_fd_deal[modInx].ep_triggle(proFD, triggle_ops, epinfo,
+ &events);
+ if (data && epi)
+ {
+ struct stat_epfd_info tmp_epfd_info;
+ struct eventpoll *ep =
+ (struct eventpoll *) SHMEM_ADDR_SHTOL(epi->ep);
+ switch (triggle_ops)
+ {
+ case nstack_ep_triggle_add:
+ if (epi->event.events & events)
+ {
+ NSTACK_EPOLL_EVENT_ADD(epinfo, events,
+ EVENT_INFORM_APP);
+ }
+ break;
+ case nstack_ep_triggle_mod:
+ if (epi->event.events & events)
+ {
+ NSTACK_EPOLL_EVENT_ADD(epinfo, events,
+ EVENT_INFORM_APP);
+ }
+ else
+ {
+ NSTACK_EPOLL_EVENT_DEL(epi, EPOLLET);
+ }
+ break;
+ default:
+ break;
+ }
+ tmp_epfd_info.epoll_wait_tick = ep->epoll_wait_tick;
+ tmp_epfd_info.epfd = ep->epfd;
+ tmp_epfd_info.epoll_fork_flag = ep->epoll_fork_flag;
+ tmp_epfd_info.hhpid = get_sys_pid();
+ nsep_epollInfo_t *epfd_info = nsep_get_info_by_sock(ep->epfd);
+ if (NULL != epfd_info)
+ tmp_epfd_info.ep_sleepTime = epfd_info->sleepTime;
+ else
+ tmp_epfd_info.ep_sleepTime = 0;
+ nstack_dfx_state_update((u64) proFD, modInx,
+ EPOLL_DFX_OPS_MAP[triggle_ops],
+ &tmp_epfd_info);
+ }
+ }
+ return data;
+}
+
+#define nstack_ep_get_evt(_epInfo, _epi) do\
+{\
+ if ((_epInfo)->rmidx != -1 && nstack_fd_deal[(_epInfo)->rmidx].ep_getEvt != NULL)\
+ {\
+ int evt_events;\
+ evt_events= nstack_fd_deal[(_epInfo)->rmidx].ep_getEvt((_epInfo)->rlfd);\
+ if(((_epi)->event.events & EPOLLIN) && (evt_events & EPOLLIN))\
+ (_epi)->revents |=EPOLLIN;\
+ if(((_epi)->event.events & EPOLLOUT) && (evt_events & EPOLLOUT))\
+ (_epi)->revents |=EPOLLOUT; \
+ }\
+}while(0)\
+
+#define NSEP_IS_SOCK_VALID(_sock) ((_sock) >= 0 && (u32_t)(_sock) < NSTACK_KERNEL_FD_MAX)
+
+/*
+ * Triggle epoll events of stack
+ * ep - eventpoll instance
+ * fdInf - file descriptor of stack
+ * triggle_ops - why triggle
+ */
+/*no need null pointer check*/
+void nsep_epctl_triggle(struct epitem *epi, nsep_epollInfo_t * info,
+ int triggle_ops)
+{
+ int modInx;
+ int protoFd = -1;
+ void *data = NULL;
+
+ NSSOC_LOGDBG("info=%p,info->rmidx=%d,triggle_ops=%d", info, info->rmidx,
+ triggle_ops);
+
+ /* Now need to triggle userspace network stack events after add operation */
+ if (info->rmidx >= 0)
+ {
+ if (info->rmidx != nstack_get_linux_mid())
+ {
+ /* fix overflow type */
+ if ((info->rmidx >= NSEP_SMOD_MAX)
+ || (info->rmidx >= NSTACK_MAX_MODULE_NUM))
+ {
+ return;
+ }
+ data =
+ nstack_ep_triggle(info->rlfd, info->rmidx, triggle_ops, epi,
+ info);
+ if ((NULL != data) && (nstack_ep_triggle_add == triggle_ops))
+ {
+ info->private_data = (void *) SHMEM_ADDR_LTOSH(data);
+ info->epaddflag[info->rmidx] = 1;
+ }
+ NSSOC_LOGDBG
+ ("info=%p,module=%s,protoFd=%d,triggle_ops=%d, ret:%p", info,
+ nstack_get_module_name_by_idx(info->rmidx), info->rlfd,
+ triggle_ops, data);
+ }
+ }
+ else
+ {
+ nstack_each_mod_inx(modInx)
+ {
+ if ((modInx >= NSEP_SMOD_MAX)
+ || (modInx >= NSTACK_MAX_MODULE_NUM))
+ {
+ return;
+ }
+ protoFd = info->protoFD[modInx];
+ if (modInx == nstack_get_linux_mid() || -1 == protoFd)
+ continue; // Don't do anything , epoll_wait will do for you
+
+ data = nstack_ep_triggle(protoFd, modInx, triggle_ops, epi, info);
+ if ((NULL != data) && (nstack_ep_triggle_add == triggle_ops))
+ {
+ info->private_data = (void *) SHMEM_ADDR_LTOSH(data);
+ info->epaddflag[modInx] = 1;
+ }
+ NSSOC_LOGDBG
+ ("info=%p,module=%s,protoFd=%d,triggle_ops=%d, ret:%p", info,
+ nstack_get_module_name_by_idx(modInx), protoFd, triggle_ops,
+ data);
+ }
+ }
+}
+
+NSTACK_STATIC
+ void nsep_rbtree_insert(struct eventpoll *ep, struct epitem *epi)
+{
+
+ struct ep_rb_node **p = &ep->rbr.rb_node, *parent = NULL; /*not null here */
+ struct epitem *epic;
+ u32_t loopCnt = 0;
+
+ while (*p)
+ {
+ ++loopCnt;
+ if (loopCnt > NSTACK_MAX_EPITEM_NUM)
+ {
+ NSSOC_LOGERR("Loop out of range!!!!");
+ break;
+ }
+
+ parent = (struct ep_rb_node *) SHMEM_ADDR_SHTOL(*p);
+
+ epic = ep_rb_entry(parent, struct epitem, rbn);
+
+ if (epi->fd > epic->fd)
+ {
+ p = &(parent->rb_right);
+ }
+ else
+ {
+ p = &(parent->rb_left);
+ }
+ }
+
+ ep_rb_link_node(&epi->rbn, parent, p);
+ ep_rb_insert_color(&epi->rbn, &ep->rbr); /*not null here */
+
+}
+
+void _InOrder(struct ep_rb_node *root)
+{
+ struct epitem *epi = NULL;
+ nsep_epollInfo_t *epInfo = NULL;
+ stat_epitem_info_t epitem_info;
+
+ if (NULL == root)
+ {
+ return;
+ }
+
+ _InOrder((struct ep_rb_node *) SHMEM_ADDR_SHTOL(root->rb_left));
+
+ epi = ep_rb_entry(root, struct epitem, rbn);
+
+ epInfo = (nsep_epollInfo_t *) SHMEM_ADDR_SHTOL(epi->private_data);
+ if (NULL != epInfo)
+ {
+ epitem_info.event = epi->event;
+ epitem_info.is_linked = EP_HLIST_NODE_LINKED(&epi->rdllink);
+ nstack_dfx_state_update((u64) epInfo->rlfd, epInfo->rmidx,
+ DMM_APP_EPOLL_WAIT_FAIL, &epitem_info);
+ }
+ _InOrder((struct ep_rb_node *) SHMEM_ADDR_SHTOL(root->rb_right));
+
+}
+
+void nsep_notify_fd_epoll_wait_fail(struct eventpoll *ep)
+{
+
+ if (!ep)
+ return;
+
+ dmm_spin_lock_with_pid((dmm_spinlock_t *) (&ep->sem)); /*do not need return value */
+ _InOrder((struct ep_rb_node *) SHMEM_ADDR_SHTOL(ep->rbr.rb_node));
+ dmm_spin_unlock((dmm_spinlock_t *) (&ep->sem));
+}
+
+/*
+ * This function is called by epctl_add , it will create one epitem of fd, and insert to eventpoll
+ */
+NSTACK_STATIC
+ int nsep_insert_node(struct eventpoll *ep,
+ nsep_epollInfo_t * epfd_epInfo,
+ struct epoll_event *event, nsep_epollInfo_t * epInfo)
+{
+ struct epitem *epi;
+
+ if (nsep_alloc_epitem(&epi))
+ {
+ NSSOC_LOGERR("Can't alloc epitem");
+ errno = ENOMEM;
+ return -1;
+ }
+
+ EP_HLIST_INIT_NODE(&epi->rdllink);
+
+ epi->ptr_reserve = NULL;
+ epi->ep_spl = (struct spl_conn_pool *) (epfd_epInfo->ep_conn);
+ epi->ep = (struct eventpoll *) SHMEM_ADDR_LTOSH_EXT(ep);
+ epi->epInfo = (nsep_epollInfo_t *) SHMEM_ADDR_LTOSH_EXT(epInfo);
+ epi->revents = 0;
+ epi->event = *event; /*no need null pointer check */
+
+ EP_LIST_INIT_NODE(&epi->fllink);
+ EP_HLIST_INIT_NODE(&epi->txlink);
+ epi->fd = epInfo->fd; /*no need null pointer check */
+
+ /* Add the current item to the list of active epoll hook for this file
+ This should lock because file descriptor may be called by other eventpoll */
+
+ dmm_spin_lock_with_pid((dmm_spinlock_t *) (&epInfo->epiLock)); /*do not need return value */
+ ep_list_add_tail(&epInfo->epiList, &epi->fllink);
+ epi->private_data = (void *) SHMEM_ADDR_LTOSH_EXT(epInfo);
+ dmm_spin_unlock((dmm_spinlock_t *) (&epInfo->epiLock));
+
+ /* Add epitem to eventpoll fd list, don't need lock here because epoll_ctl will lock before calling this function */
+ nsep_rbtree_insert(ep, epi);
+
+ /* Need to poll the events already stored in stack */
+ nsep_epctl_triggle(epi, epInfo, nstack_ep_triggle_add);
+
+ NSSOC_LOGINF("epfd=%d,ep=%p,fd=%d,epi=%p", ep->epfd, ep, epInfo->fd, epi);
+
+ return 0;
+}
+
+#ifdef KERNEL_FD_SUPPORT
+NSTACK_STATIC int nsep_is_add_valid(int fd, struct epoll_event *events)
+{
+ if (-1 == nsep_get_manager()->checkEpollFD)
+ {
+ return -1;
+ }
+ if (-1 ==
+ nsfw_base_epoll_ctl(nsep_get_manager()->checkEpollFD, EPOLL_CTL_ADD,
+ fd, events))
+ {
+ return -1;
+ }
+
+ nsfw_base_epoll_ctl(nsep_get_manager()->checkEpollFD, EPOLL_CTL_DEL, fd, NULL); /*do not need return value */
+ return 0;
+}
+
+NSTACK_STATIC
+ int nsep_add_to_kernel(int epfd, int fd, const struct epoll_event *events)
+{
+ struct epoll_event tmpEvt;
+ tmpEvt.data.fd = fd;
+ tmpEvt.events = events->events; /*no need null pointer check */
+ NSSOC_LOGINF("epfd=%d,fd=%d,events=%u", epfd, fd, events->events);
+ return nsfw_base_epoll_ctl(epfd, EPOLL_CTL_ADD, fd, &tmpEvt);
+}
+
+NSTACK_STATIC
+ int nsep_mod_to_kernel(int epfd, int fd, const struct epoll_event *events)
+{
+ struct epoll_event tmpEvt;
+ tmpEvt.data.fd = fd;
+ tmpEvt.events = events->events; /*no need null pointer check */
+ NSSOC_LOGINF("epfd=%d,fd=%d,events=%u", epfd, fd, events->events);
+ return nsfw_base_epoll_ctl(epfd, EPOLL_CTL_MOD, fd, &tmpEvt);
+}
+#endif
+
+int nsep_epctl_add(struct eventpoll *ep, nsep_epollInfo_t * epfd_epInfo,
+ int fd, struct epoll_event *events)
+{
+
+ int ret = 0;
+
+ NSSOC_LOGINF("epfd=%d,fd=%d,events=%u", ep->epfd, fd, events->events);
+
+ nsep_epollInfo_t *epInfo = nsep_get_info_by_sock(fd);
+
+ if (NULL == epInfo)
+ {
+#ifdef KERNEL_FD_SUPPORT
+ if (-1 == nsep_is_add_valid(fd, events))
+ {
+ NSSOC_LOGERR("Invalid add check nfd=%d]", fd);
+ return -1;
+ }
+ if (-1 == nsep_alloc_info_with_sock(fd))
+ {
+ NSSOC_LOGERR("Can't alloc epInfo for nfd]nfd=%d", fd);
+ return -1;
+ }
+ nsep_set_info_proto_fd(fd, nstack_get_linux_mid(), fd);
+ epInfo = nsep_get_info_by_sock(fd);
+#else
+ /*if FD is not in use, epoll_ctl_add return fail */
+ NSSOC_LOGERR("Invalid add check nfd]nfd=%d", fd);
+ return -1;
+#endif
+ }
+
+ if (NULL == epfd_epInfo)
+ {
+ NSSOC_LOGWAR("epfd_epInfo is NULL]epfd=%d,fd=%d ", ep->epfd,
+ epInfo->fd);
+ return -1;
+ }
+
+ ret = nsep_insert_node(ep, epfd_epInfo, events, epInfo);
+ if (0 != ret)
+ {
+ NSSOC_LOGWAR("insert fail]epfd=%d,fd=%d ", ep->epfd, epInfo->fd);
+ return -1;
+ }
+
+#ifdef KERNEL_FD_SUPPORT
+ /* Add fd to epoll fd to support kernel epoll thread */
+ if (-1 == epInfo->rmidx || epInfo->rmidx == nstack_get_linux_mid())
+ {
+ if (-1 == nsep_add_to_kernel(ep->epfd, epInfo->fd, events))
+ { /*no need null pointer check */
+ NSSOC_LOGWAR("epctl fail]epfd=%d,fd=%d,errno=%d", ep->epfd,
+ epInfo->fd, errno);
+ return -1;
+ }
+ }
+#endif
+
+ return 0;
+}
+
+int nsep_epctl_del(struct eventpoll *ep, struct epitem *epi)
+{
+ int ret = 0;
+
+ nsep_epollInfo_t *epInfo = (nsep_epollInfo_t *) SHMEM_ADDR_SHTOL(epi->private_data); /*no need null pointer check */
+ NSSOC_LOGINF("epfd=%d,fd=%d,epi=%p", ep->epfd, epi->fd, epi);
+
+#ifdef KERNEL_FD_SUPPORT
+ nsfw_base_epoll_ctl(ep->epfd, EPOLL_CTL_DEL, epi->fd, NULL); /*do not need return value */
+#endif
+ nsep_epctl_triggle(epi, epInfo, nstack_ep_triggle_del);
+
+ dmm_spin_lock_with_pid((dmm_spinlock_t *) (&epInfo->epiLock)); /*do not need return value */
+ /* Here need to check because nstack_close may has removed this epi->fllink */
+ ep_list_del(&epInfo->epiList, &epi->fllink); /*no need null pointer check */
+ /* after close fd in epfd, epfd still can epoll_wait EPOLLIN event for these fd */
+ (void) nstack_epoll_event_dequeue(epi, 0);
+ dmm_spin_unlock((dmm_spinlock_t *) (&epInfo->epiLock));
+ nsep_epctl_triggle(NULL, epInfo, nstack_ep_triggle_inform_app);
+
+ dmm_spin_lock_with_pid((dmm_spinlock_t *) (&ep->lock)); /*do not need return value */
+ ret = nstack_ep_unlink(ep, epi);
+ dmm_spin_unlock((dmm_spinlock_t *) (&ep->lock)); /*no need null pointer check */
+ nsep_free_epitem(epi); /*do not need return value */
+
+ return ret;
+}
+
+/*no need null pointer check*/
+int nsep_epctl_mod(struct eventpoll *ep,
+ nsep_epollInfo_t * epInfo,
+ struct epitem *epi, struct epoll_event *events)
+{
+ if (NULL == epInfo)
+ {
+ errno = EINVAL;
+ NSSOC_LOGWAR("epfd=%d, intput epInfo is null err", ep->epfd);
+ return -1;
+ }
+
+ NSSOC_LOGINF("epfd=%d,fd=%d,events=%u", ep->epfd, epInfo->fd,
+ events->events);
+
+ dmm_spin_lock_with_pid((dmm_spinlock_t *) (&ep->lock)); /*do not need return value */
+ epi->event = *events; /* kernel tells me that I need to modify epi->event in lock context */
+ dmm_spin_unlock((dmm_spinlock_t *) (&ep->lock));
+
+#ifdef KERNEL_FD_SUPPORT
+ /* Modify fd to epoll fd to support kernel epoll thread */
+ if (-1 == epInfo->rmidx || epInfo->rmidx == nstack_get_linux_mid())
+ {
+ if (-1 == nsep_mod_to_kernel(ep->epfd, epInfo->fd, events))
+ {
+ NSSOC_LOGWAR("epctl fail]epfd=%d,fd=%d,errno=%d", ep->epfd,
+ epInfo->fd, errno);
+ return -1;
+ }
+ }
+#endif
+
+ nsep_epctl_triggle(epi, epInfo, nstack_ep_triggle_mod);
+ return 0;
+}
+
+/*
+ * Called by epoll_wait
+ * Wait until events come or timeout
+ */
+ /*no need to check return value */
+int nsep_ep_poll(struct eventpoll *ep, struct epoll_event *events,
+ int maxevents, struct spl_conn_pool *ep_conn)
+{
+ int evt = 0;
+ struct ep_hlist_node *node = NULL;
+ struct epitem *epi = NULL;
+ i32 enQueRet = 0;
+ void *ring_hd = NULL;
+ unsigned int tmp_revents = 0;
+
+ if (maxevents <= 0 || !events)
+ return 0;
+
+ if (NULL == ep_conn)
+ {
+ goto rdlist_check;
+ }
+
+ ring_hd = SHMEM_ADDR_SHTOL(ep_conn->ring_hd);
+
+ dmm_spin_lock_with_pid((dmm_spinlock_t *) (&ep->sem));
+ dmm_spin_lock_with_pid((dmm_spinlock_t *) (&ep->lock));
+ while (1)
+ {
+ enQueRet = nsfw_mem_ring_dequeue(ring_hd, (void **) &epi);
+ if (1 != enQueRet)
+ {
+ break;
+ }
+ /* dont clear epi successfully, it cause app coredump */
+ nsep_epollInfo_t *epInfo =
+ (nsep_epollInfo_t *) SHMEM_ADDR_SHTOL(epi->private_data);
+ if ((NULL == epInfo) || (NULL == epi->ep))
+ {
+ NSPOL_LOGERR
+ ("epInfo or ep is NULL]ep_conn=%p,ep=%p,ring_hd=%p,epi=%p,epi->ep=%p,epInfo=%p",
+ ep_conn, ep, ring_hd, epi, SHMEM_ADDR_SHTOL(epi->ep),
+ epInfo);
+ continue;
+ }
+ epi->app_poll_count = epi->spl_enter_count;
+ /* dont clear epi successfully, it cause app coredump */
+ if (ep != SHMEM_ADDR_SHTOL(epi->ep))
+ {
+ NSPOL_LOGERR
+ ("ep_conn use by multi ep]ep_conn=%p,ep=%p,ring_hd=%p,epi=%p,epInfo=%p,epInfo->fd=%d,epi->ep=%p",
+ ep_conn, ep, ring_hd, epi, epInfo, epInfo->fd,
+ SHMEM_ADDR_SHTOL(epi->ep));
+ continue;
+ }
+
+ nstack_dfx_state_update((u64) epInfo->rlfd, epInfo->rmidx,
+ DMM_APP_EPOLL_WAIT_GET_TICK, NULL);
+
+ if (!EP_HLIST_NODE_LINKED(&epi->rdllink))
+ {
+ ep_hlist_add_tail(&ep->rdlist, &epi->rdllink);
+ }
+
+ };
+
+ dmm_spin_unlock((dmm_spinlock_t *) (&ep->lock));
+ dmm_spin_unlock((dmm_spinlock_t *) (&ep->sem));
+
+ rdlist_check:
+
+ if (EP_HLIST_EMPTY(&ep->rdlist))
+ {
+ NSSOC_LOGDBG("ep->rdlist is Empty, epfd=%d", ep->epfd);
+ return 0;
+ }
+
+ dmm_spin_lock_with_pid((dmm_spinlock_t *) (&ep->sem)); /*do not need return value */
+ if (EP_HLIST_EMPTY(&ep->rdlist))
+ goto out;
+
+ dmm_spin_lock_with_pid((dmm_spinlock_t *) (&ep->lock)); /*do not need return value */
+
+ struct ep_hlist_node *epRdHead =
+ (struct ep_hlist_node *) SHMEM_ADDR_SHTOL(ep->rdlist.head);
+ if (!epRdHead)
+ {
+ return 0;
+ }
+ node = (struct ep_hlist_node *) SHMEM_ADDR_SHTOL(epRdHead->next);
+
+ while (node)
+ {
+
+ epi = ep_hlist_entry(node, struct epitem, rdllink);
+
+ node = (struct ep_hlist_node *) SHMEM_ADDR_SHTOL(node->next);
+ nsep_epollInfo_t *epInfo =
+ (nsep_epollInfo_t *) SHMEM_ADDR_SHTOL(epi->private_data);
+ epInfo = (nsep_epollInfo_t *) SHMEM_ADDR_SHTOL(epi->private_data);
+
+ nstack_ep_get_evt(epInfo, epi);
+
+ tmp_revents = epi->revents;
+
+ /* app epoll_wait return 24 event, when the fd is in establish state */
+
+ while (!__sync_bool_compare_and_swap(&epi->revents, tmp_revents, 0))
+ { /* daemon-stack don't have lock for err hup rdhup event, so here must ensure that daemon-stack don't modify it */
+ tmp_revents = epi->revents;
+ };
+
+ if (tmp_revents)
+ {
+ events[evt].events = tmp_revents;
+ events[evt].data = epi->event.data;
+ NSSOC_LOGDBG("Add event]epfd=%d,fd=%d,events=%u", ep->epfd,
+ epi->fd, events[evt].events);
+ evt++;
+ nstack_dfx_state_update((u64) epInfo->rlfd, epInfo->rmidx,
+ DMM_APP_EPOLL_WAIT_EVENT,
+ (void *) (u64) tmp_revents);
+ }
+
+ if (0 == tmp_revents || epi->event.events & EPOLLET)
+ {
+ NSSOC_LOGDBG("Del epi->rdllink,epfd=%d,fd=%d", ep->epfd, epi->fd);
+ ep_hlist_del(&ep->rdlist, &epi->rdllink);
+ }
+
+ if (tmp_revents & (EPOLLERR | EPOLLHUP | EPOLLRDHUP))
+ {
+ NSSOC_LOGINF("epfd=%d,fd=%d,epi=%p,revent=%u", ep->epfd, epi->fd,
+ epi, tmp_revents);
+ }
+
+ if (evt >= maxevents)
+ break;
+ }
+ dmm_spin_unlock((dmm_spinlock_t *) (&ep->lock));
+ out:
+ dmm_spin_unlock((dmm_spinlock_t *) (&ep->sem));
+
+ NSSOC_LOGDBG("Return epfd=%d,fd=%d,EP_HLIST_EMPTY(&ep->rdlist)=%d",
+ ep->epfd, epi ? epi->fd : -1, EP_HLIST_EMPTY(&ep->rdlist));
+
+ return evt;
+}
+
+/*no need to check return value*/
+
+void nsep_remove_epfd(nsep_epollInfo_t * pinfo)
+{
+ pid_t pid = get_sys_pid();
+ struct list_node *prenode = NULL;
+ struct list_node *nextnode = NULL;
+ struct list_node **node_arry = NULL;
+ int lenth = NSTACK_MAX_EPOLL_INFO_NUM * sizeof(struct list_node *);
+ struct epitem *epi = NULL;
+ struct epitem *tepi = NULL;
+ struct eventpoll *ep = NULL;
+ u32_t i = 0;
+ u32_t icnt = 0;
+
+ if (!pinfo)
+ {
+ return;
+ }
+ /*malloc a block memory to store epitem node, do not use list for maybe free item */
+ /*malloc() & free() can be used */
+ node_arry = (struct list_node **) malloc(lenth);
+ if (!node_arry)
+ {
+ NSSOC_LOGERR("remove fd from ep malloc mem fail]fd=%d,ep=%p",
+ pinfo->fd, pinfo->ep);
+ return;
+ }
+ /*add return value check */
+ int retVal = memset_s(node_arry, lenth, 0, lenth);
+ if (EOK != retVal)
+ {
+ NSSOC_LOGERR("memset_s failed]retVal=%d", retVal);
+ free(node_arry); /*free() can be used */
+ return;
+ }
+
+ dmm_spin_lock_with_pid((dmm_spinlock_t *) (&pinfo->epiLock)); /*do not need return value */
+ /*list head must be not null */
+ prenode = (struct list_node *) SHMEM_ADDR_SHTOL(pinfo->epiList.head);
+ nextnode = (struct list_node *) SHMEM_ADDR_SHTOL(prenode->next);
+ icnt = 0;
+
+ /*find all node that pid is belong to itself */
+ while (nextnode)
+ {
+ if (++i > NSTACK_MAX_EPOLL_INFO_NUM)
+ {
+ /*record the exception log */
+ NSSOC_LOGERR("error maybe happen]free pinfo=%p", pinfo);
+ break;
+ }
+
+ epi = ep_list_entry(nextnode, struct epitem, fllink);
+ if (pid == epi->pid)
+ {
+ prenode->next = nextnode->next;
+ nextnode->next = NULL;
+ /*put into release list */
+ node_arry[icnt] = nextnode;
+ icnt++;
+ /* only can clear ring for epi that del */
+ (void) nstack_epoll_event_dequeue(epi, 0);
+ }
+ else
+ {
+ prenode = nextnode;
+ }
+ nextnode = (struct list_node *) SHMEM_ADDR_SHTOL(prenode->next);
+ }
+
+ dmm_spin_unlock((dmm_spinlock_t *) (&pinfo->epiLock));
+
+ /*free all epitem */
+ for (i = 0; i < icnt; i++)
+ {
+
+ epi = ep_list_entry(node_arry[i], struct epitem, fllink);
+ ep = (struct eventpoll *) SHMEM_ADDR_SHTOL(epi->ep);
+ if (ep)
+ {
+ dmm_spin_lock_with_pid((dmm_spinlock_t *) (&ep->sem));
+ /* Here don't use epi you find before, use fd and ep to find the epi again.that is multithread safe */
+ tepi = nsep_find_ep(ep, pinfo->fd);
+ /*record the exception log */
+ if (epi != tepi)
+ {
+ NSSOC_LOGERR("remove fd:%d epi:%p tepi:%p erro maybe happen",
+ pinfo->fd, epi, tepi);
+ }
+ /*if tepi is null, epi maybe free by nsep_close_epfd, so no need to free again */
+ if (tepi)
+ {
+#ifdef KERNEL_FD_SUPPORT
+ nsfw_base_epoll_ctl(ep->epfd, EPOLL_CTL_DEL, tepi->fd, NULL); /*do not need return value */
+#endif
+ nsep_epctl_triggle(tepi, pinfo, nstack_ep_triggle_del);
+ dmm_spin_lock_with_pid((dmm_spinlock_t *) (&ep->lock)); /*do not need return value */
+ (void) nstack_ep_unlink(ep, tepi);
+ dmm_spin_unlock((dmm_spinlock_t *) (&ep->lock));
+
+ nsep_free_epitem(epi);
+ }
+ dmm_spin_unlock((dmm_spinlock_t *) (&ep->sem));
+ }
+ }
+
+ nsep_epctl_triggle(NULL, pinfo, nstack_ep_triggle_inform_app);
+ /*malloc() & free() can be used */
+ free(node_arry);
+ return;
+}
+
+void nsep_close_epfd(struct eventpoll *ep)
+{
+
+ if (!ep)
+ return;
+
+ struct epitem *epi = NULL;
+ struct ep_rb_node *node = NULL;
+
+ dmm_spin_lock_with_pid((dmm_spinlock_t *) (&ep->sem)); /*do not need return value */
+ while ((node = ep_rb_first(&ep->rbr)))
+ {
+
+ epi = ep_rb_entry(node, struct epitem, rbn);
+
+ int ret = nsep_epctl_del(ep, epi);
+
+ /* Avoid dead loop */
+ if (ret)
+ {
+ NSSOC_LOGERR
+ ("nstack epctl del fail, will break to avoid dead loop]ep->fd=%d,epi->fd=%d",
+ ep->epfd, epi->fd);
+ break;
+ }
+ }
+ dmm_spin_unlock((dmm_spinlock_t *) (&ep->sem));
+ nsep_free_eventpoll(ep); /*do not need return value */
+}
+
+/*no need to check null pointer*/
+static inline int nsp_epoll_close_kernel_fd(int sock,
+ nsep_epollInfo_t * epInfo)
+{
+ NSSOC_LOGINF("fd=%d,type=%d", sock, epInfo->fdtype);
+ int ret = 0;
+ nsep_remove_epfd(epInfo);
+
+ u32_t pid = get_sys_pid();
+ dmm_spin_lock_with_pid((dmm_spinlock_t *) (&epInfo->freeLock)); /*do not need return value */
+ int left_count = nsep_del_last_pid(&epInfo->pidinfo, pid);
+ dmm_spin_unlock((dmm_spinlock_t *) (&epInfo->freeLock));
+ if (-1 == left_count)
+ {
+ NSSOC_LOGERR("pid not exist]fd=%d,type=%d,pid=%u", sock,
+ epInfo->fdtype, pid);
+ }
+
+ if (0 == left_count)
+ {
+ ret = nsep_free_epinfo(epInfo);
+ NSSOC_LOGINF("epinfo removed]fd=%d,type=%d", sock, epInfo->fdtype);
+ }
+
+ return ret;
+}
+
+/*no need to check null pointer*/
+static inline int nsp_epoll_close_spl_fd(int sock, nsep_epollInfo_t * epInfo)
+{
+ NSSOC_LOGINF("fd=%d,type=%d", sock, epInfo->fdtype);
+ nsep_remove_epfd(epInfo); /*no need to check null pointer */
+ return 0;
+}
+
+/*no need to check null pointer*/
+static inline int nsp_epoll_close_ep_fd(int sock, nsep_epollInfo_t * epInfo)
+{
+ struct eventpoll *ep = SHMEM_ADDR_SHTOL(epInfo->ep);
+ struct spl_conn_pool *ep_conn = SHMEM_ADDR_SHTOL(epInfo->ep_conn);
+ u32_t pid = get_sys_pid();
+ NSSOC_LOGINF("fd:%d is epoll fd ep:%p]", sock, ep);
+ dmm_spin_lock_with_pid((dmm_spinlock_t *) (&epInfo->freeLock));
+ int left_count = nsep_del_last_pid(&epInfo->pidinfo, pid);
+ dmm_spin_unlock((dmm_spinlock_t *) (&epInfo->freeLock));
+ if (0 == left_count)
+ {
+ epInfo->ep = NULL;
+ epInfo->ep_conn = NULL;
+ nsep_close_epfd(ep);
+ /* must close ep fistly before free ep_conn, becasue if close ep_conn firstly, then this ep_conn will alloc by other epfd,
+ this time, now daemon-stack possiblely will report event using this ep_conn */
+ (void) nsep_free_ep_spl_conn_ring(ep_conn);
+ nsep_free_epinfo(epInfo);
+ }
+ return 0;
+}
+
+/*no need to check null pointer*/
+int nsep_epoll_close(int sock)
+{
+ int ret = 0;
+ nsep_epollInfo_t *epInfo = nsep_get_info_by_sock(sock);
+ if (!epInfo)
+ {
+ NSSOC_LOGDBG("epollsock close sock:%d is not exist", sock);
+ return 0;
+ }
+
+ nsep_set_info_sock_map(sock, NULL);
+
+ if (NSTACK_EPOL_FD == epInfo->fdtype)
+ {
+ return nsp_epoll_close_ep_fd(sock, epInfo);
+ }
+
+ if (epInfo->rmidx == nstack_get_linux_mid())
+ {
+ ret = nsp_epoll_close_kernel_fd(sock, epInfo);
+ }
+ else
+ {
+ ret = nsp_epoll_close_spl_fd(sock, epInfo);
+ }
+
+ return ret;
+}
+
+/* epinfo add pid */
+void nsep_fork(u32_t ppid)
+{
+ u32 cpid = get_sys_pid();
+ nsep_epollManager_t *manager = nsep_get_manager();
+ if (NULL == manager->infoSockMap)
+ {
+ NSSOC_LOGERR("infoSockMap is NULL]ppid=%u,cpid=%u", ppid, cpid);
+ return;
+ }
+
+ nsep_epollInfo_t *epinfo = NULL;
+ int pos;
+ for (pos = 0; (u32_t) pos < NSTACK_KERNEL_FD_MAX; pos++)
+ {
+ epinfo = manager->infoSockMap[pos];
+ if (epinfo)
+ {
+ if (nsep_add_pid(&epinfo->pidinfo, cpid) != 0)
+ {
+ NSSOC_LOGERR("epinfo add pid failed]fd=%d,ppid=%u.cpid=%u",
+ pos, ppid, cpid);
+ }
+ else
+ {
+ NSSOC_LOGDBG("epinfo add pid ok]fd=%d,ppid=%u.cpid=%u", pos,
+ ppid, cpid);
+ }
+ }
+ }
+}
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif /* __cplusplus */
diff --git a/src/nSocket/nstack/event/epoll/nstack_eventpoll.c b/src/nSocket/nstack/event/epoll/nstack_eventpoll.c
deleted file mode 100644
index a8b3757..0000000
--- a/src/nSocket/nstack/event/epoll/nstack_eventpoll.c
+++ /dev/null
@@ -1,1215 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "nstack_eventpoll.h"
-#include "nstack_log.h"
-#include "nsfw_recycle_api.h"
-#include "nstack_securec.h"
-#include "nstack_module.h"
-#include "nstack_sockops.h"
-#include "nsfw_mem_api.h"
-#include "nstack_fd_mng.h"
-#include "nstack.h"
-#include "nstack_dmm_adpt.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C"{
-/* *INDENT-ON* */
-#endif /* __cplusplus */
-
-#define NSTACK_EP_TRIGGLE(epFD, proFD, modInx, triggle_ops, event, pdata, ret) \
- if (nstack_extern_deal(modInx).ep_ctl != NULL) \
- { \
- ret = nstack_extern_deal(modInx).ep_ctl((epFD), (proFD), (triggle_ops), (event), pdata); \
- }
-
-#define nstack_ep_getEvt(epFD, profd, modInx, events, ret) \
- if (nstack_extern_deal(modInx).ep_getevt != NULL)\
- { \
- ret |= nstack_extern_deal(modInx).ep_getevt((epFD), (profd), (events)); \
- }
-
-#define NSEP_IS_SOCK_VALID(_sock) ((_sock) >= 0 && (u32_t)(_sock) < NSTACK_KERNEL_FD_MAX)
-
-/*add event to rdlist if event have come in*/
-void
-nsep_ctl_event_add (struct epitem *epi, struct eventpoll *ep,
- int triggle_ops, unsigned int events)
-{
- switch (triggle_ops)
- {
- case nstack_ep_triggle_add:
- if (events & epi->event.events)
- {
- sys_arch_lock_with_pid (&ep->lock);
-
- if (!EP_HLIST_NODE_LINKED (&epi->rdllink))
- {
- ep_hlist_add_tail (&ep->rdlist, &epi->rdllink);
- }
-
- sys_sem_s_signal (&ep->lock);
- sem_post (&ep->waitSem);
- }
-
- break;
-
- case nstack_ep_triggle_mod:
- sys_arch_lock_with_pid (&ep->lock);
-
- if (events & epi->event.events)
- {
- if (!EP_HLIST_NODE_LINKED (&epi->rdllink))
- {
- ep_hlist_add_tail (&ep->rdlist, &epi->rdllink);
- sem_post (&ep->waitSem);
- }
- }
- else
- {
- if (EP_HLIST_NODE_LINKED (&epi->rdllink)
- && (epi->event.events & EPOLLET))
- {
- ep_hlist_del (&ep->rdlist, &epi->rdllink);
- }
- }
-
- sys_sem_s_signal (&ep->lock);
- break;
- default:
- break;
- }
-
- return;
-}
-
-/*
- * Triggle epoll events of stack
- * ep - eventpoll instance
- * fdInf - file descriptor of stack
- * triggle_ops - why triggle
- */
-NSTACK_STATIC void
-nsep_epctl_triggle (struct epitem *epi, nsep_epollInfo_t * info,
- int triggle_ops)
-{
- int modInx;
- int protoFd = -1;
- int epfd = 0;
- int ret = 0;
- struct eventpoll *ep = NULL;
- nsep_epollInfo_t *epInfo = NULL;
-
- ep = ADDR_SHTOL (epi->ep);
- epfd = ep->epfd;
- epInfo = nsep_get_infoBySock (epfd);
-
- NSSOC_LOGINF ("info=%p,info->rmidx=%d,triggle_ops=%d", info, info->rmidx,
- triggle_ops);
-
- /* Now need to triggle userspace network stack events after add operation */
- if (info->rmidx >= 0)
- {
- /* fix overflow type codex issue */
- if ((info->rmidx >= NSEP_SMOD_MAX)
- || (info->rmidx >= NSTACK_MAX_MODULE_NUM))
- {
- return;
- }
-
- NSTACK_EP_TRIGGLE (epInfo->protoFD[info->rmidx], info->rlfd,
- info->rmidx, triggle_ops, &(epi->event), info, ret);
-
- if ((ret >= 0)
- && ((nstack_ep_triggle_add == triggle_ops)
- || (nstack_ep_triggle_mod == triggle_ops)))
- {
- epi->revents = ret;
- nsep_ctl_event_add (epi, ep, triggle_ops, epi->revents);
- info->epaddflag |= (1 << info->rmidx);
- }
- NSSOC_LOGINF ("info=%p,module=%s,protoFd=%d,triggle_ops=%d, ret:%d",
- info, nstack_get_module_name_by_idx (info->rmidx),
- info->rlfd, triggle_ops, ret);
- }
- else
- {
- nstack_each_modInx (modInx)
- {
- protoFd = info->protoFD[modInx];
-
- if (protoFd < 0)
- {
- continue;
- }
- NSTACK_EP_TRIGGLE (epInfo->protoFD[modInx], protoFd, modInx,
- triggle_ops, &(epi->event), info, ret);
- if ((ret >= 0)
- && ((nstack_ep_triggle_add == triggle_ops)
- || (nstack_ep_triggle_mod == triggle_ops)))
- {
- epi->revents |= ret;
- nsep_ctl_event_add (epi, ep, triggle_ops, epi->revents);
- info->epaddflag |= (1 << modInx);
- }
- NSSOC_LOGINF ("info=%p,module=%s,protoFd=%d,triggle_ops=%d, ret:%d",
- info, nstack_get_module_name_by_idx (modInx), protoFd,
- triggle_ops, ret);
- }
- }
- return;
-}
-
-NSTACK_STATIC void
-nsep_rbtree_insert (struct eventpoll *ep, struct epitem *epi)
-{
- struct ep_rb_node **p = &ep->rbr.rb_node, *parent = NULL;
- struct epitem *epic;
- u32_t loopCnt = 0;
-
- while (*p)
- {
- ++loopCnt;
- if (loopCnt > NSTACK_MAX_EPITEM_NUM)
- {
- NSSOC_LOGERR ("Loop out of range!!!!");
- break;
- }
-
- parent = (struct ep_rb_node *) ADDR_SHTOL (*p);
- epic = ep_rb_entry (parent, struct epitem, rbn);
- if (epi->fd > epic->fd)
- {
- p = &(parent->rb_right);
- }
- else
- {
- p = &(parent->rb_left);
- }
- }
-
- ep_rb_link_node (&epi->rbn, parent, p);
- ep_rb_insert_color (&epi->rbn, &ep->rbr);
-}
-
-/*
- * This function is called by epctl_add , it will create one epitem of fd, and insert to eventpoll
- */
-NSTACK_STATIC int
-nsep_insert_node (struct eventpoll *ep, struct epoll_event *event,
- nsep_epollInfo_t * fdInfo)
-{
- struct epitem *epi;
-
- if (nsep_alloc_epitem (&epi))
- {
- NSSOC_LOGERR ("Can't alloc epitem");
- errno = ENOMEM;
- return -1;
- }
-
- EP_HLIST_INIT_NODE (&epi->rdllink);
- EP_HLIST_INIT_NODE (&epi->lkFDllink);
-
- epi->nwait = 0;
- epi->ep = (struct eventpoll *) ADDR_LTOSH_EXT (ep);
- epi->epInfo = (nsep_epollInfo_t *) ADDR_LTOSH_EXT (fdInfo);
- epi->revents = 0;
- epi->ovf_revents = 0;
- epi->event = *event;
- EP_LIST_INIT_NODE (&epi->fllink);
- epi->revents = 0;
- epi->fd = fdInfo->fd;
-
- /* Add the current item to the list of active epoll hook for this file
- This should lock because file descriptor may be called by other eventpoll */
-
- sys_arch_lock_with_pid (&fdInfo->epiLock);
- ep_list_add_tail (&fdInfo->epiList, &epi->fllink);
- epi->private_data = (void *) ADDR_LTOSH_EXT (fdInfo);
- sys_sem_s_signal (&fdInfo->epiLock);
-
- /* Add epitem to eventpoll fd list, don't need lock here because epoll_ctl will lock before calling this function */
- nsep_rbtree_insert (ep, epi);
-
- /* Need to poll the events already stored in stack */
- nsep_epctl_triggle (epi, fdInfo, nstack_ep_triggle_add);
-
- NSSOC_LOGINF ("epfd=%d,ep=%p,fd=%d,epi=%p", ep->epfd, ep, fdInfo->fd, epi);
-
- return 0;
-}
-
-NSTACK_STATIC int
-nsep_isAddValid (int fd)
-{
-
- if (nstack_fix_fd_check ())
- {
- return nstack_fix_fd_check ()(fd, STACK_FD_INVALID_CHECK);
- }
- return 0;
-}
-
-int
-nsep_epctl_add (struct eventpoll *ep, int fd, struct epoll_event *events)
-{
-
- int ret = 0;
-
- NSSOC_LOGINF ("epfd=%d,fd=%d,events=%u", ep->epfd, fd, events->events);
-
- nsep_epollInfo_t *fdInfo = nsep_get_infoBySock (fd);
-
- if (NULL == fdInfo)
- {
- if (0 == nsep_isAddValid (fd))
- {
- NSSOC_LOGERR ("Invalid add check nfd=%d]", fd);
- return -1;
- }
- if (-1 == nsep_alloc_infoWithSock (fd))
- {
- NSSOC_LOGERR ("Can't alloc epInfo for nfd]nfd=%d", fd);
- return -1;
- }
- nsep_set_infoProtoFD (fd, nstack_get_fix_mid (), fd);
- fdInfo = nsep_get_infoBySock (fd);
- }
-
- ret = nsep_insert_node (ep, events, fdInfo);
- if (0 != ret)
- {
- NSSOC_LOGWAR ("insert fail]epfd=%d,fd=%d ", ep->epfd, fdInfo->fd);
- return -1;
- }
-
- return 0;
-}
-
-int
-nsep_epctl_del (struct eventpoll *ep, struct epitem *epi)
-{
- int ret = 0;
-
- nsep_epollInfo_t *epInfo =
- (nsep_epollInfo_t *) ADDR_SHTOL (epi->private_data);
- NSSOC_LOGINF ("epfd=%d,fd=%d,epi=%p", ep->epfd, epi->fd, epi); // modify log format error
-
- nsep_epctl_triggle (epi, epInfo, nstack_ep_triggle_del);
-
- sys_arch_lock_with_pid (&epInfo->epiLock);
- ep_list_del (&epInfo->epiList, &epi->fllink);
-
- sys_sem_s_signal (&epInfo->epiLock);
-
- sys_arch_lock_with_pid (&ep->lock);
- ret = nstack_ep_unlink (ep, epi);
- sys_sem_s_signal (&ep->lock);
- nsep_free_epitem (epi);
-
- return ret;
-}
-
-int
-nsep_epctl_mod (struct eventpoll *ep,
- nsep_epollInfo_t * epInfo,
- struct epitem *epi, struct epoll_event *events)
-{
- if (NULL == epInfo)
- {
- errno = EINVAL;
- NSSOC_LOGWAR ("epfd=%d, intput epInfo is null err", ep->epfd);
- return -1;
- }
-
- NSSOC_LOGINF ("epfd=%d,fd=%d,events=%u", ep->epfd, epInfo->fd,
- events->events);
-
- sys_arch_lock_with_pid (&ep->lock);
- epi->event = *events; /* kernel tells me that I need to modify epi->event in lock context */
- sys_sem_s_signal (&ep->lock);
-
- nsep_epctl_triggle (epi, epInfo, nstack_ep_triggle_mod);
- return 0;
-}
-
-/*
- * Called by nsep_ep_poll
- * proccess the event in the list
- */
-static int
-nsep_events_proc (struct eventpoll *ep,
- struct ep_node_list *nhead,
- struct epoll_event *events, int maxevents, int *eventflag,
- int num)
-{
- struct ep_hlist_node *node = NULL;
- struct epitem *epi = NULL;
- struct ep_hlist_node *head = nhead->head;
- int evt = 0;
-
- while (head)
- {
- node = head;
- epi = ep_hlist_entry (node, struct epitem, rdllink);
- head = (struct ep_hlist_node *) ADDR_SHTOL (node->next);
- EP_HLIST_INIT_NODE (node);
-
- nsep_epollInfo_t *fdInfo =
- (nsep_epollInfo_t *) ADDR_SHTOL (epi->private_data);
-
- if (fdInfo->rmidx != -1)
- {
- nstack_ep_getEvt (ep->epfd, fdInfo->rlfd, fdInfo->rmidx,
- epi->event.events, (epi->revents));
- }
-
- if (epi->revents)
- {
- /*set the flag that already have event int the rdlist */
- if (eventflag && (fdInfo->rmidx >= 0) && (fdInfo->rmidx < num))
- {
- eventflag[fdInfo->rmidx] = 1;
- }
- events[evt].events = epi->revents;
- events[evt].data = epi->event.data;
- NSSOC_LOGDBG ("Add event]epfd=%d,fd=%d,events=%u", ep->epfd,
- epi->fd, events[evt].events);
- evt++;
- }
-
- if (0 != epi->revents && EPOLLET != (epi->event.events & EPOLLET))
- {
- NSSOC_LOGDBG ("Add epi->rdllink,epfd=%d,fd=%d", ep->epfd, epi->fd);
- ep_hlist_add_tail (&ep->rdlist, &epi->rdllink);
- }
- epi->revents = 0;
-
- if (evt >= maxevents)
- break;
- }
- nhead->head = head;
- if (!head)
- {
- nhead->tail = NULL;
- }
- return evt;
-}
-
-/*
- * Called by epoll_wait
- * Wait until events come or timeout
- */
-int
-nsep_ep_poll (struct eventpoll *ep, struct epoll_event *events, int maxevents,
- int *eventflag, int num)
-{
-
- struct ep_hlist_node *tail = NULL;
- struct ep_hlist_node *head = NULL;
- struct epitem *epi = NULL;
- struct epitem *nepi = NULL;
- struct ep_node_list nhead = { 0 };
- int evt = 0;
- nsep_epollInfo_t *fdInfo = NULL;
-
- if (EP_HLIST_EMPTY (&ep->rdlist))
- {
- NSSOC_LOGDBG ("ep->rdlist is Empty, epfd=%d", ep->epfd);
- return 0;
- }
-
- sys_arch_lock_with_pid (&ep->sem);
-
- if (EP_HLIST_EMPTY (&ep->rdlist))
- {
- goto out;
- }
-
- sys_arch_lock_with_pid (&ep->lock);
- head = (struct ep_hlist_node *) ADDR_SHTOL (ep->rdlist.head);
- if (!head)
- {
- sys_sem_s_signal (&ep->lock);
- goto out;
- }
- nhead.head = (struct ep_hlist_node *) ADDR_SHTOL (head->next);
- nhead.tail = (struct ep_hlist_node *) ADDR_SHTOL (ep->rdlist.tail);
- /*unlink from ep->rdlist */
- EP_HLIST_INIT (&(ep->rdlist));
- ep->ovflist = NULL;
- sys_sem_s_signal (&ep->lock);
-
- /*get event list */
- evt = nsep_events_proc (ep, &nhead, events, maxevents, eventflag, num);
-
- sys_arch_lock_with_pid (&ep->lock);
- /*put rest epitem back to the rdlist */
- if (nhead.head)
- {
- tail = (struct ep_hlist_node *) ADDR_SHTOL (ep->rdlist.tail);
- tail->next = (struct ep_hlist_node *) ADDR_LTOSH (nhead.head);
- nhead.head->pprev = (struct ep_hlist_node **) ADDR_LTOSH (&tail->next);
- ep->rdlist.tail = (struct ep_hlist_node *) ADDR_LTOSH (nhead.tail);
- }
- /*put the epitem in ep->ovflist to rdlist */
- for (nepi = (struct epitem *) ADDR_SHTOL (ep->ovflist);
- (epi = nepi) != NULL;
- nepi = (struct epitem *) ADDR_SHTOL (epi->next), epi->next =
- NSEP_EP_UNACTIVE_PTR)
- {
- epi->revents |= epi->ovf_revents;
- /*set the flag that already have event int the rdlist */
- fdInfo = (nsep_epollInfo_t *) ADDR_SHTOL (epi->private_data);
- if (eventflag && fdInfo && (fdInfo->rmidx >= 0)
- && (fdInfo->rmidx < num))
- {
- eventflag[fdInfo->rmidx] = 1;
- }
- epi->ovf_revents = 0;
- if (!EP_HLIST_NODE_LINKED (&epi->rdllink))
- {
- ep_hlist_add_tail (&ep->rdlist, &epi->rdllink);
- }
- }
- ep->ovflist = NSEP_EP_UNACTIVE_PTR;
- sys_sem_s_signal (&ep->lock);
-out:
- sys_sem_s_signal (&ep->sem);
- NSSOC_LOGDBG ("Return epfd=%d,evt=%d,EP_HLIST_EMPTY(&ep->rdlist)=%d",
- ep->epfd, evt, EP_HLIST_EMPTY (&ep->rdlist));
- return evt;
-}
-
-#define FREE_LIST_SIZE 128
-#ifdef FREE_LIST_SIZE
-struct free_list
-{
- struct free_list *next;
- struct list_node *node[FREE_LIST_SIZE];
-};
-#endif
-
-void
-nsep_remove_epfd (nsep_epollInfo_t * pinfo)
-{
- pid_t pid = get_sys_pid ();
- struct list_node *prenode = NULL;
- struct list_node *nextnode = NULL;
-#ifdef FREE_LIST_SIZE
- struct free_list flist;
- struct free_list *fcurr = &flist;
-#else
- struct list_node **node_arry = NULL;
- int length = NSTACK_MAX_EPOLL_INFO_NUM * sizeof (struct list_node *);
-#endif
- struct epitem *epi = NULL;
- struct epitem *tepi = NULL;
- struct eventpoll *ep = NULL;
- u32_t i = 0;
- u32_t icnt = 0;
-
- if (!pinfo)
- {
- return;
- }
- /*malloc a block memory to store epitem node, do not use list for maybe free item */
-#ifdef FREE_LIST_SIZE
- flist.next = 0;
-#else
- node_arry = (struct list_node **) malloc (length);
- if (!node_arry)
- {
- NSSOC_LOGERR ("remove fd from ep malloc mem fail]fd=%d,ep=%p",
- pinfo->fd, pinfo->ep);
- return;
- }
-
- int retVal = MEMSET_S (node_arry, length, 0, length);
- if (EOK != retVal)
- {
- NSSOC_LOGERR ("MEMSET_S failed]retVal=%d", retVal);
- free (node_arry);
- return;
- }
-#endif
- sys_arch_lock_with_pid (&pinfo->epiLock);
- /*list head must be not null */
- prenode = (struct list_node *) ADDR_SHTOL (pinfo->epiList.head);
- nextnode = (struct list_node *) ADDR_SHTOL (prenode->next);
- icnt = 0;
-
- /*find all node that pid is belong to itself */
- while (nextnode)
- {
- if (++i > NSTACK_MAX_EPOLL_INFO_NUM)
- {
- /*record the exception log */
- NSSOC_LOGERR ("error maybe happen]free pinfo=%p", pinfo);
- break;
- }
- epi = ep_list_entry (nextnode, struct epitem, fllink);
- if (pid == epi->pid)
- {
- prenode->next = nextnode->next;
- nextnode->next = NULL;
- /*put into release list */
-#ifdef FREE_LIST_SIZE
- if ((icnt % FREE_LIST_SIZE) == 0 && icnt)
- {
- struct free_list *fnext =
- (struct free_list *) malloc (sizeof (struct free_list));
- if (!fnext)
- {
- NSSOC_LOGERR ("Out of memory for freelist]fd=%d icnt=%u",
- pinfo->fd, icnt);
- break;
- }
- fnext->next = NULL;
- fcurr->next = fnext;
- fcurr = fnext;
- }
- fcurr->node[icnt % FREE_LIST_SIZE] = nextnode;
-#else
- node_arry[icnt] = nextnode;
-#endif
- icnt++;
- }
- else
- {
- prenode = nextnode;
- }
- nextnode = (struct list_node *) ADDR_SHTOL (prenode->next);
- }
-
- sys_sem_s_signal (&pinfo->epiLock);
-
- /*free all epitem */
-#ifdef FREE_LIST_SIZE
- fcurr = &flist;
-#endif
- for (i = 0; i < icnt; i++)
- {
-#ifdef FREE_LIST_SIZE
- if ((i % FREE_LIST_SIZE) == 0 && i)
- {
- fcurr = fcurr->next;
- if (fcurr == NULL)
- {
- NSSOC_LOGERR ("freelist invalid NULL, fd=%d icnt=%u i=%u",
- pinfo->fd, icnt, i);
- break;
- }
- }
- epi =
- ep_list_entry (fcurr->node[i % FREE_LIST_SIZE], struct epitem,
- fllink);
-#else
- epi = ep_list_entry (node_arry[i], struct epitem, fllink);
-#endif
- ep = (struct eventpoll *) ADDR_SHTOL (epi->ep);
- if (ep)
- {
- sys_arch_lock_with_pid (&ep->sem);
- /* Here don't use epi you find before, use fd and ep to find the epi again.that is multithread safe */
- tepi = nsep_find_ep (ep, pinfo->fd);
- /*record the exception log */
- if (epi != tepi)
- {
- NSSOC_LOGERR ("remove fd:%d epi:%p tepi:%p erro maybe happen",
- pinfo->fd, epi, tepi);
- }
- /*if tepi is null, epi maybe free by nsep_close_epfd, so no need to free again */
- if (tepi)
- {
- nsep_epctl_triggle (tepi, pinfo, nstack_ep_triggle_del);
- sys_arch_lock_with_pid (&ep->lock);
- (void) nstack_ep_unlink (ep, tepi);
- sys_sem_s_signal (&ep->lock);
-
- nsep_free_epitem (epi);
- }
- sys_sem_s_signal (&ep->sem);
- }
- }
-#ifdef FREE_LIST_SIZE
- for (fcurr = flist.next; fcurr; fcurr = flist.next)
- {
- flist.next = fcurr->next;
- free (fcurr);
- }
-#else
- free (node_arry);
-#endif
- return;
-}
-
-void
-nsep_close_epfd (struct eventpoll *ep)
-{
-
- if (!ep)
- return;
-
- struct epitem *epi = NULL;
- struct ep_rb_node *node = NULL;
-
- sys_arch_lock_with_pid (&ep->sem);
- while ((node = ep_rb_first (&ep->rbr)))
- {
-
- epi = ep_rb_entry (node, struct epitem, rbn);
- int ret = nsep_epctl_del (ep, epi);
-
- if (ret)
- {
- NSSOC_LOGERR
- ("nstack epctl del fail, will break to avoid dead loop]ep->fd=%d,epi->fd=%d",
- ep->epfd, epi->fd);
- break;
- }
- }
- sys_sem_s_signal (&ep->sem);
- nsep_free_eventpoll (ep);
-}
-
-static inline int
-nsp_epoll_close_kernel_fd (int sock, nsep_epollInfo_t * epInfo)
-{
- NSSOC_LOGINF ("fd=%d,type=%d", sock, epInfo->fdtype);
- int ret = 0;
- nsep_remove_epfd (epInfo);
-
- u32_t pid = get_sys_pid ();
- sys_arch_lock_with_pid (&epInfo->freeLock);
- int left_count = nsep_del_last_pid (&epInfo->pidinfo, pid);
- sys_sem_s_signal (&epInfo->freeLock);
- if (-1 == left_count)
- {
- NSSOC_LOGERR ("pid not exist]fd=%d,type=%d,pid=%d", sock,
- epInfo->fdtype, pid);
- }
-
- if (0 == left_count)
- {
- ret = nsep_free_epinfo (epInfo);
- NSSOC_LOGINF ("epinfo removed]fd=%d,type=%d", sock, epInfo->fdtype);
- }
-
- return ret;
-}
-
-static inline int
-nsp_epoll_close_spl_fd (int sock, nsep_epollInfo_t * epInfo)
-{
- NSSOC_LOGINF ("fd=%d,type=%d", sock, epInfo->fdtype);
- nsep_remove_epfd (epInfo);
- return 0;
-}
-
-static inline int
-nsp_epoll_close_ep_fd (int sock, nsep_epollInfo_t * epInfo)
-{
- struct eventpoll *ep = ADDR_SHTOL (epInfo->ep);
- u32_t pid = get_sys_pid ();
- NSSOC_LOGINF ("fd:%d is epoll fd ep:%p]", sock, ep);
- sys_arch_lock_with_pid (&epInfo->freeLock);
- int left_count = nsep_del_last_pid (&epInfo->pidinfo, pid);
- sys_sem_s_signal (&epInfo->freeLock);
- if (0 == left_count)
- {
- epInfo->ep = NULL;
- nsep_close_epfd (ep);
- nsep_free_epinfo (epInfo);
- }
- return 0;
-}
-
-int
-nsep_epoll_close (int sock)
-{
- int ret = 0;
- int modInx = 0;
- int flag = 0;
- nsep_epollInfo_t *epInfo = nsep_get_infoBySock (sock);
- if (!epInfo)
- {
- NSSOC_LOGDBG ("epollsock close sock:%d is not exist", sock);
- return 0;
- }
-
- if (NSTACK_EPOL_FD == epInfo->fdtype)
- {
- ret = nsp_epoll_close_ep_fd (sock, epInfo);
- nsep_set_infoSockMap (sock, NULL);
- return ret;
- }
-
- nsep_set_infoSockMap (sock, NULL);
-
- nstack_each_modInx (modInx)
- {
- if (0 == (epInfo->epaddflag & (1 << modInx)))
- {
- flag = 1;
- }
- }
- /*if no stack reference the epinfo, just free epInfo,
- *else wait until the stack closed completely
- */
- if (0 == flag)
- {
- ret = nsp_epoll_close_kernel_fd (sock, epInfo);
- }
- else
- {
- ret = nsp_epoll_close_spl_fd (sock, epInfo);
- }
- return ret;
-}
-
-void
-nsep_set_infoSockMap (int sock, nsep_epollInfo_t * info)
-{
- nsep_epollManager_t *manager = nsep_getManager ();
- if (NULL == manager->infoSockMap)
- return;
-
- if (sock < 0 || (u32_t) sock >= NSTACK_KERNEL_FD_MAX)
- return;
-
- manager->infoSockMap[sock] = info;
-}
-
-nsep_epollInfo_t *
-nsep_get_infoBySock (int sock)
-{
- nsep_epollManager_t *manager = nsep_getManager ();
- if ((NULL == manager) || (NULL == manager->infoSockMap))
- return NULL;
-
- if (sock < 0 || (u32_t) sock >= NSTACK_KERNEL_FD_MAX)
- return NULL;
-
- return manager->infoSockMap[sock];
-}
-
-int
-nsep_alloc_infoWithSock (int nfd)
-{
-
- nsep_epollInfo_t *epInfo = NULL;
-
- if (!NSEP_IS_SOCK_VALID (nfd))
- {
- return -1;
- }
-
- if (-1 == nsep_alloc_epinfo (&epInfo))
- {
- NSSOC_LOGERR ("Alloc share info fail,[return]");
- return -1;
- }
-
- epInfo->fd = nfd;
-
- nsep_set_infoSockMap (nfd, epInfo);
-
- return 0;
-}
-
-void
-nsep_set_infoProtoFD (int fd, int modInx, int protoFD)
-{
- nsep_epollInfo_t *epInfo = nsep_get_infoBySock (fd);
-
- if (NULL == epInfo)
- return;
-
- if (modInx < 0 || modInx >= NSTACK_MAX_MODULE_NUM)
- return;
-
- epInfo->protoFD[modInx] = protoFD;
-}
-
-int
-nsep_get_infoProtoFD (int fd, int modInx)
-{
- nsep_epollInfo_t *epInfo = nsep_get_infoBySock (fd);
-
- if (NULL == epInfo)
- return -1;
-
- return epInfo->protoFD[modInx];
-}
-
-void
-nsep_set_infomdix (int fd, int rmidx)
-{
- nsep_epollInfo_t *epInfo = nsep_get_infoBySock (fd);
-
- if (NULL == epInfo)
- return;
-
- epInfo->rmidx = rmidx;
-}
-
-int
-nsep_get_infoMidx (int fd)
-{
- nsep_epollInfo_t *epInfo = nsep_get_infoBySock (fd);
-
- if (NULL == epInfo)
- return -1;
-
- return epInfo->rmidx;
-}
-
-void
-nsep_set_infoRlfd (int fd, int rlfd)
-{
- nsep_epollInfo_t *epInfo = nsep_get_infoBySock (fd);
-
- if (NULL == epInfo)
- return;
-
- epInfo->rlfd = rlfd;
-}
-
-int
-nsep_get_infoRlfd (int fd)
-{
- nsep_epollInfo_t *epInfo = nsep_get_infoBySock (fd);
-
- if (NULL == epInfo)
- return -1;
-
- return epInfo->rlfd;
-}
-
-void
-nsep_set_infoSleepTime (int fd, u32 sleepTime)
-{
- nsep_epollInfo_t *epInfo = nsep_get_infoBySock (fd);
-
- if (NULL == epInfo)
- return;
-
- epInfo->sleepTime = sleepTime;
-}
-
-int
-nsep_get_infoSleepTime (int fd)
-{
- nsep_epollInfo_t *epInfo = nsep_get_infoBySock (fd);
-
- if (NULL == epInfo)
- return -1;
-
- return epInfo->sleepTime;
-}
-
-void
-nsep_set_infoEp (int fd, struct eventpoll *ep)
-{
- nsep_epollInfo_t *epInfo = nsep_get_infoBySock (fd);
-
- if (NULL == epInfo)
- return;
-
- epInfo->ep = (struct eventpoll *) ADDR_LTOSH (ep);
- epInfo->fdtype = NSTACK_EPOL_FD;
-}
-
-struct eventpoll *
-nsep_get_infoEp (int fd)
-{
- nsep_epollInfo_t *epInfo = nsep_get_infoBySock (fd);
-
- if (NULL == epInfo)
- return NULL;
-
- return (struct eventpoll *) ADDR_SHTOL (epInfo->ep);
-}
-
-int
-nsep_free_infoWithSock (int nfd)
-{
- if ((u32_t) nfd >= NSTACK_KERNEL_FD_MAX || nfd < 0)
- return -1;
-
- nsep_epollInfo_t *info = nsep_get_infoBySock (nfd);
-
- if (NULL == info)
- return 0;
-
- nsep_set_infoSockMap (nfd, NULL);
-
- NSSOC_LOGDBG ("nsep_free_infoWithSock info:%p, nfd:%d", info, nfd);
- /* If this not just used by linux, it should be freed in stack-x */
- if (-1 == nsep_free_epinfo (info))
- {
- NSSOC_LOGERR ("Error to free ep info");
- return -1;
- }
- return 0;
-}
-
-/**
- * @Function nsep_init_infoSockMap
- * @Description initial map of epoll info and socket
- * @param none
- * @return 0 on success, -1 on error
- */
-int
-nsep_init_infoSockMap ()
-{
- nsep_epollManager_t *manager = nsep_getManager ();
- nsep_epollInfo_t **map =
- (nsep_epollInfo_t **) malloc (NSTACK_KERNEL_FD_MAX *
- sizeof (nsep_epollInfo_t *));
-
- if (!map)
- {
- NSSOC_LOGERR ("malloc epInfoPool fail");
- return -1;
- }
-
- u32_t iindex;
- for (iindex = 0; iindex < NSTACK_KERNEL_FD_MAX; iindex++)
- {
- map[iindex] = NULL;
- }
-
- manager->infoSockMap = map;
-
- return 0;
-}
-
-NSTACK_STATIC mzone_handle
-nsep_ring_lookup (char *name)
-{
- if (NULL == name)
- {
- NSSOC_LOGERR ("param error]name=%p", name);
- return NULL;
- }
-
- nsfw_mem_name mem_name;
- if (EOK != STRCPY_S (mem_name.aname, sizeof (mem_name.aname), name))
- {
- NSSOC_LOGERR ("Error to lookup ring by name, strcpy fail]name=%s",
- name);
- return NULL;
- }
- mem_name.enowner = NSFW_PROC_MAIN;
- mem_name.entype = NSFW_SHMEM;
-
- return nsfw_mem_ring_lookup (&mem_name);
-}
-
-NSTACK_STATIC mzone_handle
-nsep_attach_shmem (char *name)
-{
- if (NULL == name)
- {
- NSSOC_LOGERR ("param error]name=%p", name);
- return NULL;
- }
-
- nsfw_mem_name mem_name;
- int retVal = STRCPY_S (mem_name.aname, sizeof (mem_name.aname), name);
- if (EOK != retVal)
- {
- NSSOC_LOGERR ("STRCPY_S failed]");
- return NULL;
- }
- mem_name.enowner = NSFW_PROC_MAIN;
- mem_name.entype = NSFW_SHMEM;
-
- return nsfw_mem_zone_lookup (&mem_name);
-}
-
-NSTACK_STATIC int
-nsep_attach_infoMem ()
-{
- mzone_handle hdl = nsep_attach_shmem (MP_NSTACK_EPOLL_INFO_NAME);
- if (NULL == hdl)
- return -1;
-
- nsep_epollManager_t *manager = nsep_getManager ();
- manager->infoPool.pool = (nsep_epollInfo_t *) hdl;
-
- hdl = nsep_ring_lookup (MP_NSTACK_EPINFO_RING_NAME);
- if (NULL == hdl)
- {
- NSSOC_LOGERR ("Fail to lock up epoll info ring]name=%s",
- MP_NSTACK_EPINFO_RING_NAME);
- return -1;
- }
-
- manager->infoPool.ring = hdl;
-
- return 0;
-}
-
-NSTACK_STATIC int
-nsep_attach_epItemMem ()
-{
- mzone_handle hdl = nsep_attach_shmem (MP_NSTACK_EPITEM_POOL);
- if (NULL == hdl)
- return -1;
-
- nsep_epollManager_t *manager = nsep_getManager ();
- manager->epitemPool.pool = (struct epitem *) hdl;
-
- hdl = nsep_ring_lookup (MP_NSTACK_EPITEM_RING_NAME);
- if (NULL == hdl)
- {
- NSSOC_LOGERR ("Fail to lock up epoll info ring]name=%s",
- MP_NSTACK_EPITEM_RING_NAME);
- return -1;
- }
-
- manager->epitemPool.ring = hdl;
-
- return 0;
-}
-
-NSTACK_STATIC int
-nsep_attach_eventpollMem ()
-{
- mzone_handle hdl = nsep_attach_shmem (MP_NSTACK_EVENTPOLL_POOL);
- if (NULL == hdl)
- return -1;
-
- nsep_epollManager_t *manager = nsep_getManager ();
- manager->epollPool.pool = (struct eventpoll *) hdl;
-
- hdl = nsep_ring_lookup (MP_NSTACK_EVENTPOOL_RING_NAME);
- if (NULL == hdl)
- {
- NSSOC_LOGERR ("Fail to lock up epoll info ring]name=%s",
- MP_NSTACK_EVENTPOOL_RING_NAME);
- return -1;
- }
-
- manager->epollPool.ring = hdl;
-
- return 0;
-}
-
-/* epinfo add pid in parent */
-void
-nsep_fork_parent_proc (u32_t ppid, u32_t cpid)
-{
- nsep_epollManager_t *manager = nsep_getManager ();
- if (NULL == manager->infoSockMap)
- {
- NSSOC_LOGERR ("infoSockMap is NULL]ppid=%d,cpid=%d", ppid, cpid);
- return;
- }
-
- nstack_fd_Inf *fdInf = NULL;
- nsep_epollInfo_t *epinfo = NULL;
- int pos;
- for (pos = 0; (u32_t) pos < NSTACK_KERNEL_FD_MAX; pos++)
- {
- epinfo = manager->infoSockMap[pos];
- if (epinfo)
- {
- fdInf = nstack_getValidInf (pos);
- if (fdInf)
- {
- if (((u32_t) (fdInf->type)) & SOCK_CLOEXEC)
- {
- NSSOC_LOGINF ("fd is SOCK_CLOEXEC]fd=%d,ppid=%d.cpid=%d",
- pos, ppid, cpid);
- continue;
- }
- }
-
- if (nsep_add_pid (&epinfo->pidinfo, cpid) != 0)
- {
- NSSOC_LOGERR ("epinfo add pid failed]fd=%d,ppid=%d.cpid=%d",
- pos, ppid, cpid);
- }
- else
- {
- NSSOC_LOGDBG ("epinfo add pid ok]fd=%d,ppid=%d.cpid=%d", pos,
- ppid, cpid);
- }
- }
- }
-}
-
-/* check is pid exist in child,if no,detach epinfo*/
-void
-nsep_fork_child_proc (u32_t ppid)
-{
- nsep_epollManager_t *manager = nsep_getManager ();
- if (NULL == manager->infoSockMap)
- {
- NSSOC_LOGERR ("epinfi sockmap not be create");
- return;
- }
-
- u32_t cpid = get_sys_pid ();
- nsep_epollInfo_t *epinfo = NULL;
- int pos;
- for (pos = 0; (u32_t) pos < NSTACK_KERNEL_FD_MAX; pos++)
- {
- epinfo = manager->infoSockMap[pos];
- if (epinfo)
- {
- if (!nsep_is_pid_exist (&epinfo->pidinfo, cpid))
- {
- NSSOC_LOGINF
- ("unuse epinfo,happen in SOCK_CLOEXEC,!FD_OPEN,parent coredump]fd=%d,epinfo=%p,ppid=%d,cpid=%d",
- pos, epinfo, ppid, cpid);
- nsep_set_infoSockMap (pos, NULL);
- }
- }
- }
-}
-
-int
-nsep_attach_memory ()
-{
- typedef int (*nsep_attachMemFunc_t) (void);
- nsep_attachMemFunc_t attachFuncs[] = { nsep_attach_infoMem,
- nsep_attach_epItemMem,
- nsep_attach_eventpollMem
- };
-
- int i = 0;
- for (i = 0;
- i < (int) (sizeof (attachFuncs) / sizeof (nsep_attachMemFunc_t)); i++)
- {
- if (-1 == attachFuncs[i] ())
- return -1;
- }
-
- return 0;
-}
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif /* __cplusplus */
diff --git a/src/nSocket/nstack/event/select/nstack_select.c b/src/nSocket/nstack/event/select/nstack_select.c
index f61b326..b9db0d7 100644
--- a/src/nSocket/nstack/event/select/nstack_select.c
+++ b/src/nSocket/nstack/event/select/nstack_select.c
@@ -20,220 +20,231 @@
#include "nstack_select.h"
#include "nstack_log.h"
#include "nsfw_base_linux_api.h"
-
+#include "nstack.h"
+#include "nstack_dmm_dfx.h"
/*==============================================*
* constants or macros define *
*----------------------------------------------*/
#ifdef NSTACK_SELECT_MODULE
+#define SELECT_FREE_FD_BITS(read_set, write_set, exp_set) do{\
+ select_free((read_set)->fds_bits); \
+ select_free((write_set)->fds_bits); \
+ select_free((exp_set)->fds_bits); \
+}while(0)
/*==============================================*
* project-wide global variables *
*----------------------------------------------*/
-extern void *nstack_select_thread (void *arg);
+extern void *nstack_select_thread(void *arg);
+pthread_t g_select_thread_id;
/*************select module***************************/
struct select_module_info g_select_module = {
- .inited = FALSE,
+ .inited = FALSE,
};
-/*==============================================*
- * routines' or functions' implementations *
- *----------------------------------------------*/
-/*****************************************************************************
-* Prototype : get_select_module
-* Description : get_select_module
-* Input : void
-* Output : None
-* Return Value : struct select_module_info *
-* Calls :
-* Called By :
-*****************************************************************************/
-struct select_module_info *
-get_select_module (void)
+struct select_module_info *get_select_module(void)
{
- return &g_select_module;
+ return &g_select_module;
}
/*split comm seclet entry to child mod select*/
-/*****************************************************************************
-* Prototype : select_cb_split_by_mod
-* Description : select_cb_split_by_module
-* Input : i32 nfds
-* fd_set *readfd
-* fd_set *writefd
-* fd_set *exceptfd
-* struct select_entry *entry
-* Output : None
-* Return Value : i32
-* Calls :
-* Called By :
-*****************************************************************************/
-i32
-select_cb_split_by_mod (i32 nfds,
- fd_set * readfd,
- fd_set * writefd,
- fd_set * exceptfd, struct select_entry * entry)
+/*no need to check null pointer*/
+
+i32 select_cb_split_by_mod(i32 nfds,
+ fd_set * readfd,
+ fd_set * writefd,
+ fd_set * exceptfd, struct select_entry * entry)
{
- i32 inx;
- i32 i;
- i32 fd;
+ i32 inx;
+ i32 i;
+ i32 fd;
- for (i = 0; i < nfds; i++)
+ for (i = 0; i < nfds; i++)
{
-
- /*not bound to any stack */
- for (inx = 0; inx < get_mode_num (); inx++)
+ /*not bound to any stack */
+ for (inx = 0; inx < nstack_get_module_num(); inx++)
{
- if (!((readfd && FD_ISSET (i, readfd)) ||
- (writefd && FD_ISSET (i, writefd)) ||
- (exceptfd && FD_ISSET (i, exceptfd))))
+ if (!((readfd && FD_ISSET(i, readfd)) ||
+ (writefd && FD_ISSET(i, writefd)) ||
+ (exceptfd && FD_ISSET(i, exceptfd))))
{
- continue;
+ continue;
}
- fd = select_get_modfd (i, inx);
- /*not create by nstack */
- if ((fd < 0) || (select_get_modindex (i) < 0))
+ fd = select_get_modfd(i, inx);
+ /*not create by nstack */
+ if ((fd < 0) || (select_get_modindex(i) < 0))
{
-
- if (inx != get_mode_linux_index ())
+ if (inx != nstack_get_linux_mid())
{
- continue;
+ continue;
}
- fd = i;
- nssct_create (fd, fd, inx);
+ fd = i;
+ nssct_create(fd, fd, inx); /*do not need return value */
}
- else
+ else
{
- if (select_get_modindex (i) != inx)
- continue;
+ if (select_get_modindex(i) != inx)
+ {
+ continue;
+ }
}
- NSSOC_LOGDBG ("fd is available i= %d fd = %d index = %d\n", i, fd,
- inx);
- if ((readfd) && (FD_ISSET (i, readfd)))
+
+ NSSOC_LOGDBG("fd is valiable i= %d fd = %d index = %d\n", i, fd,
+ inx);
+ if ((readfd) && (FD_ISSET(i, readfd)))
{
- NSTACK_FD_SET (fd, &(entry->cb[inx].nstack_readset));
- if (entry->cb[inx].count <= fd)
- entry->cb[inx].count = fd + 1;
+ if (inx == nstack_get_linux_mid())
+ {
+ FD_SET(fd, &(entry->cb[inx].readset));
+ }
+ else
+ {
+ NSTACK_FD_SET(fd, &(entry->cb[inx].nstack_readset));
+ }
+ if (entry->cb[inx].count <= fd)
+ {
+ entry->cb[inx].count = fd + 1;
+ }
}
- if ((writefd) && (FD_ISSET (i, writefd)))
+ if ((writefd) && (FD_ISSET(i, writefd)))
{
- NSTACK_FD_SET (fd, &(entry->cb[inx].nstack_writeset));
- if (entry->cb[inx].count <= fd)
- entry->cb[inx].count = fd + 1;
+ if (inx == nstack_get_linux_mid())
+ {
+ FD_SET(fd, &(entry->cb[inx].writeset));
+ }
+ else
+ {
+ NSTACK_FD_SET(fd, &(entry->cb[inx].nstack_writeset));
+ }
+
+ if (entry->cb[inx].count <= fd)
+ {
+ entry->cb[inx].count = fd + 1;
+ }
}
- if ((exceptfd) && (FD_ISSET (i, exceptfd)))
+ if ((exceptfd) && (FD_ISSET(i, exceptfd)))
{
- NSTACK_FD_SET (fd, &(entry->cb[inx].nstack_exceptset));
- if (entry->cb[inx].count <= fd)
- entry->cb[inx].count = fd + 1;
+ if (inx == nstack_get_linux_mid())
+ {
+ FD_SET(fd, &(entry->cb[inx].exceptset));
+ }
+ else
+ {
+ NSTACK_FD_SET(fd, &(entry->cb[inx].nstack_exceptset));
+ }
+
+ if (entry->cb[inx].count <= fd)
+ {
+ entry->cb[inx].count = fd + 1;
+ }
}
}
}
- for (inx = 0; inx < get_mode_num (); inx++)
+ for (inx = 0; inx < nstack_get_module_num(); inx++)
{
- if (entry->cb[inx].count > 0)
+ if (entry->cb[inx].count > 0)
{
- entry->info.set_num++;
- entry->info.index = inx;
+ entry->info.set_num++;
+ entry->info.index = inx;
}
}
- return TRUE;
+ return TRUE;
}
/*****************************************************************************
* Prototype : select_add_cb
-* Description : add cb to global list
+* Description : add cb to gloab list
* Input : struct select_entry *entry
* Output : None
* Return Value : i32
* Calls :
* Called By :
*****************************************************************************/
-i32
-select_add_cb (struct select_entry * entry)
+i32 select_add_cb(struct select_entry * entry)
{
- if ((!entry))
+ if ((!entry))
{
- return FALSE;
+ return FALSE;
}
- select_spin_lock (&g_select_module.lock);
+ select_spin_lock(&g_select_module.lock);
- if (!g_select_module.entry_head)
+ if (!g_select_module.entry_head)
{
- g_select_module.entry_head = entry;
- g_select_module.entry_tail = entry;
- entry->next = NULL;
- entry->prev = NULL;
+ g_select_module.entry_head = entry;
+ g_select_module.entry_tail = entry;
+ entry->next = NULL;
+ entry->prev = NULL;
}
- else
+ else
{
- g_select_module.entry_tail->next = entry;
- entry->prev = g_select_module.entry_tail;
- g_select_module.entry_tail = entry;
- entry->next = NULL;
+ g_select_module.entry_tail->next = entry;
+ entry->prev = g_select_module.entry_tail;
+ g_select_module.entry_tail = entry;
+ entry->next = NULL;
}
- select_spin_unlock (&g_select_module.lock);
- select_sem_post (&g_select_module.sem);
- return TRUE;
+ select_spin_unlock(&g_select_module.lock);
+ select_sem_post(&g_select_module.sem); /*do not need return value */
+ return TRUE;
}
/*****************************************************************************
* Prototype : select_rm_cb
-* Description : rm the cb from global list
+* Description : rm the cb from gloab list
* Input : struct select_entry *entry
* Output : None
* Return Value : i32
* Calls :
* Called By :
*****************************************************************************/
-i32
-select_rm_cb (struct select_entry * entry)
+i32 select_rm_cb(struct select_entry * entry)
{
- if (!entry)
+ if (!entry)
{
- return FALSE;
+ return FALSE;
}
- select_spin_lock (&g_select_module.lock);
+ select_spin_lock(&g_select_module.lock);
- if (g_select_module.entry_head == entry)
+ if (g_select_module.entry_head == entry)
{
- g_select_module.entry_head = entry->next;
+ g_select_module.entry_head = entry->next;
}
- else if (entry->prev)
+ else if (entry->prev)
{
- entry->prev->next = entry->next;
+ entry->prev->next = entry->next;
}
- if (g_select_module.entry_tail == entry)
+ if (g_select_module.entry_tail == entry)
{
- g_select_module.entry_tail = entry->prev;
+ g_select_module.entry_tail = entry->prev;
}
- else if (entry->next)
+ else if (entry->next)
{
- entry->next->prev = entry->prev;
+ entry->next->prev = entry->prev;
}
- entry->next = NULL;
- entry->prev = NULL;
+ entry->next = NULL;
+ entry->prev = NULL;
- select_spin_unlock (&g_select_module.lock);
- return TRUE;
+ select_spin_unlock(&g_select_module.lock);
+ return TRUE;
}
-/*get fd set from entry*/
+/*get fd set from entrys*/
+/*no need to check null pointer*/
/*****************************************************************************
* Prototype : select_thread_get_fdset
-* Description : get module listening fd form global list
+* Description : get module listening fd form gloab list
* Input : nstack_fd_set *readfd
* nstack_fd_set *writefd
* nstack_fd_set *exceptfd
@@ -244,55 +255,118 @@ select_rm_cb (struct select_entry * entry)
* Calls :
* Called By :
*****************************************************************************/
-i32
-select_thread_get_fdset (nstack_fd_set * readfd,
- nstack_fd_set * writefd,
- nstack_fd_set * exceptfd,
- struct select_module_info * module, i32 inx)
+i32 select_thread_get_fdset(nstack_fd_set * readfd,
+ nstack_fd_set * writefd,
+ nstack_fd_set * exceptfd,
+ struct select_module_info * module, i32 inx)
{
- struct select_entry *tmp;
- i32 nfds = 0;
- int retVal;
+ struct select_entry *tmp;
+ i32 nfds = 0;
+ int retVal;
- if (!module)
+ if (!module)
{
- return FALSE;
+ return FALSE;
}
- retVal = NSTACK_FD_ZERO (readfd);
- retVal |= NSTACK_FD_ZERO (writefd);
- retVal |= NSTACK_FD_ZERO (exceptfd);
- if (EOK != retVal)
+ u32 fd_set_size =
+ sizeof(unsigned char) * ((NSTACK_SELECT_MAX_FD + 7) / 8);
+
+ /*add return value check */
+ retVal = NSTACK_FD_ZERO(readfd, fd_set_size);
+ retVal |= NSTACK_FD_ZERO(writefd, fd_set_size);
+ retVal |= NSTACK_FD_ZERO(exceptfd, fd_set_size);
+ if (EOK != retVal)
{
- NSSOC_LOGERR ("NSTACK_FD_ZERO MEMSET_S failed]ret=%d", retVal);
- return FALSE;
+ NSSOC_LOGERR("NSTACK_FD_ZERO memset_s failed]ret=%d", retVal);
+ return FALSE;
}
- select_spin_lock (&module->lock);
- for (tmp = module->entry_head; NULL != tmp; tmp = tmp->next)
+ select_spin_lock(&module->lock);
+ for (tmp = module->entry_head; NULL != tmp; tmp = tmp->next)
{
- if (tmp->cb[inx].count <= 0)
+ if (tmp->cb[inx].count <= 0)
{
- continue;
+ continue;
}
- NSTACK_FD_OR (readfd, &tmp->cb[inx].nstack_readset);
- NSTACK_FD_OR (writefd, &tmp->cb[inx].nstack_writeset);
- NSTACK_FD_OR (exceptfd, &tmp->cb[inx].nstack_exceptset);
- if (nfds < tmp->cb[inx].count)
+ NSTACK_FD_OR(readfd, &tmp->cb[inx].nstack_readset);
+ NSTACK_FD_OR(writefd, &tmp->cb[inx].nstack_writeset);
+ NSTACK_FD_OR(exceptfd, &tmp->cb[inx].nstack_exceptset);
+ if (nfds < tmp->cb[inx].count)
{
- nfds = tmp->cb[inx].count;
+ nfds = tmp->cb[inx].count;
}
}
- select_spin_unlock (&module->lock);
+ select_spin_unlock(&module->lock);
- return nfds;
+ return nfds;
+}
+
+/*no need to check null pointer*/
+
+i32 select_thread_get_fdset_linux(fd_set * readfd,
+ fd_set * writefd,
+ fd_set * exceptfd,
+ struct select_module_info * module, i32 inx)
+{
+ struct select_entry *tmp;
+ i32 nfds = 0;
+ int i;
+
+ if (!module)
+ {
+ return 0;
+ }
+
+ FD_ZERO(readfd);
+ FD_ZERO(writefd);
+ FD_ZERO(exceptfd);
+
+ select_spin_lock(&module->lock);
+
+ for (tmp = module->entry_head; NULL != tmp; tmp = tmp->next)
+ {
+ if (tmp->cb[inx].count <= 0)
+ {
+ continue;
+ }
+
+ /*need to diff linux and daemon-stack */
+ for (i = 0; i < __FD_SETSIZE; i++)
+ {
+ if (FD_ISSET(i, &tmp->cb[inx].readset))
+ {
+ FD_SET(i, readfd);
+ }
+
+ if (FD_ISSET(i, &tmp->cb[inx].writeset))
+ {
+ FD_SET(i, writefd);
+ }
+
+ if (FD_ISSET(i, &tmp->cb[inx].exceptset))
+ {
+ FD_SET(i, exceptfd);
+ }
+ }
+ /*need to diff linux and daemon-stack */
+
+ if (nfds < tmp->cb[inx].count)
+ {
+ nfds = tmp->cb[inx].count;
+ }
+ }
+
+ select_spin_unlock(&module->lock);
+
+ return nfds;
}
/*****************************************************************************
* Prototype : select_thread_set_fdset
-* Description : set ready event to global list
+* Description : set ready event to gloab list
* Input : i32 nfds
* nstack_fd_set *readfd
* nstack_fd_set *writefd
@@ -305,186 +379,402 @@ select_thread_get_fdset (nstack_fd_set * readfd,
* Calls :
* Called By :
*****************************************************************************/
-i32
-select_thread_set_fdset (i32 nfds,
- nstack_fd_set * readfd,
- nstack_fd_set * writefd,
- nstack_fd_set * exceptfd,
- struct select_module_info * module, i32 inx, i32 err)
+i32 select_thread_set_fdset(i32 nfds,
+ nstack_fd_set * readfd,
+ nstack_fd_set * writefd,
+ nstack_fd_set * exceptfd,
+ struct select_module_info * module,
+ i32 inx, i32 err)
{
- struct select_entry *tmp;
+ struct select_entry *tmp;
- if (!module)
+ if (!module)
{
- return FALSE;
+ return FALSE;
}
- select_spin_lock (&module->lock);
- for (tmp = module->entry_head; NULL != tmp; tmp = tmp->next)
+ select_spin_lock(&module->lock);
+ for (tmp = module->entry_head; NULL != tmp; tmp = tmp->next)
{
- if (tmp->cb[inx].count <= 0)
+ if (tmp->cb[inx].count <= 0)
{
- continue;
+ continue;
}
- if (nfds < 0)
+ if (nfds < 0)
{
- tmp->ready.readyset = nfds;
- tmp->ready.select_errno = err;
- continue;
+ tmp->ready.readyset = nfds;
+ tmp->ready.select_errno = err;
+ continue;
}
- NSSOC_LOGDBG ("readyset=%d,index=%d", tmp->ready.readyset, inx);
- entry_module_fdset (tmp, nfds, readfd, writefd, exceptfd, inx);
+ NSSOC_LOGDBG("readyset=%d,index=%d", tmp->ready.readyset, inx);
+ entry_module_fdset(tmp, nfds, readfd, writefd, exceptfd, inx);
}
- select_spin_unlock (&module->lock);
- return TRUE;
+ select_spin_unlock(&module->lock);
+ return TRUE;
}
+NSTACK_STATIC inline void entry_mod_fdset_linux(int fd, int idx, int inx,
+ struct select_entry *entry,
+ fd_set * readfd,
+ fd_set * writefd,
+ fd_set * exceptfd)
+{
+ if (FD_ISSET(idx, readfd) && FD_ISSET(idx, &entry->cb[inx].readset))
+ {
+ FD_SET(fd, &entry->ready.readset);
+ entry->ready.count++;
+ NSSOC_LOGDBG("readyset is %d", entry->ready.readyset);
+ }
+
+ if (FD_ISSET(idx, writefd) && FD_ISSET(idx, &entry->cb[inx].writeset))
+ {
+ FD_SET(fd, &entry->ready.writeset);
+ entry->ready.count++;
+ NSSOC_LOGDBG("writeset is %d", entry->ready.readyset);
+ }
+
+ if (FD_ISSET(idx, exceptfd) && FD_ISSET(idx, &entry->cb[inx].exceptset))
+ {
+ FD_SET(fd, &entry->ready.exceptset);
+ entry->ready.count++;
+ NSSOC_LOGDBG("exceptset is %d", entry->ready.readyset);
+ }
+}
+
+NSTACK_STATIC inline void entry_module_fdset_linux(struct select_entry
+ *entry, i32 fd_size,
+ fd_set * readfd,
+ fd_set * writefd,
+ fd_set * exceptfd, i32 inx)
+{
+ i32 i;
+ i32 fd;
+
+ for (i = 0; i < fd_size; i++)
+ {
+ fd = select_get_commfd(i, inx);
+ if (fd < 0)
+ {
+ continue;
+ }
+
+ entry_mod_fdset_linux(fd, i, inx, entry, readfd, writefd, exceptfd);
+ }
+}
+
+i32 select_thread_set_fdset_linux(i32 nfds,
+ fd_set * readfd,
+ fd_set * writefd,
+ fd_set * exceptfd,
+ struct select_module_info *module,
+ i32 inx, i32 err)
+{
+
+ struct select_entry *tmp;
+
+ if (!module)
+ {
+ return FALSE;
+ }
+
+ select_spin_lock(&module->lock);
+ for (tmp = module->entry_head; NULL != tmp; tmp = tmp->next)
+ {
+ if (tmp->cb[inx].count <= 0)
+ {
+ continue;
+ }
+
+ if (nfds < 0)
+ {
+ tmp->ready.readyset = nfds;
+ tmp->ready.select_errno = err;
+ continue;
+ }
+ NSSOC_LOGDBG("readyset=%d,index=%d", tmp->ready.readyset, inx);
+ entry_module_fdset_linux(tmp, nfds, readfd, writefd, exceptfd, inx);
+ }
+ select_spin_unlock(&module->lock);
+ return TRUE;
+
+}
+
+/*no need to check null pointer*/
/*****************************************************************************
* Prototype : select_event_post
-* Description : when event ready post sem to awake nstack_select
+* Description : when event ready post sem to awaik nstack_select
* Input : struct select_module_info *module
* Output : None
* Return Value : void
* Calls :
* Called By :
*****************************************************************************/
-void
-select_event_post (struct select_module_info *module)
+void select_event_post(struct select_module_info *module)
{
- struct select_entry *tmp;
- int inx;
- select_spin_lock (&module->lock);
- for (tmp = module->entry_head; NULL != tmp; tmp = tmp->next)
+ struct select_entry *tmp;
+ int inx;
+ select_spin_lock(&module->lock);
+ for (tmp = module->entry_head; NULL != tmp; tmp = tmp->next)
{
- if ((tmp->ready.readyset != 0))
+ if ((tmp->ready.readyset != 0))
{
- for (inx = 0; inx < get_mode_num (); inx++)
+ for (inx = 0; inx < nstack_get_module_num(); inx++)
{
- tmp->cb[inx].count = 0;
+ tmp->cb[inx].count = 0;
}
- NSSOC_LOGDBG ("readyset=%d", tmp->ready.readyset);
- select_sem_post (&tmp->sem);
+ NSSOC_LOGDBG("readyset=%d", tmp->ready.readyset);
+ select_sem_post(&tmp->sem); /*do not need return value */
}
}
- select_spin_unlock (&module->lock);
+ select_spin_unlock(&module->lock);
}
+/*no need to check null pointer*/
+
/*set select_event function*/
-/*****************************************************************************
-* Prototype : select_module_init
-* Description : init select module
-* Input : None
-* Output : None
-* Return Value : i32
-* Calls :
-* Called By :
-*****************************************************************************/
-i32
-select_module_init ()
+i32 select_module_init()
{
- i32 i;
- pthread_t select_thread_id;
- i32 retval;
+ i32 i;
+ i32 retval;
- if (fdmapping_init () < 0)
+ if (fdmapping_init() < 0)
{
- goto ERR_RET;
+ goto ERR_RET;
}
- g_select_module.default_mod = get_mode_linux_index ();
- g_select_module.default_fun = nsfw_base_select;
+ g_select_module.default_mod = nstack_get_linux_mid();
+ g_select_module.default_fun = nsfw_base_select;
- /*regist select fun */
- for (i = 0; i < get_mode_num (); i++)
+ /*regist select fun */
+ for (i = 0; i < nstack_get_module_num(); i++)
{
- g_select_module.get_select_fun_nonblock[i] =
- nstack_module_ops (i)->pfselect;
+ g_select_module.get_select_fun_nonblock[i] =
+ nstack_module_ops(i)->pfselect;
}
- select_sem_init (&g_select_module.sem, 0, 0);
- select_spin_lock_init (&g_select_module.lock);
+ select_sem_init(&g_select_module.sem, 0, 0); /*do not need return value */
+ select_spin_lock_init(&g_select_module.lock);
- if (pthread_create (&select_thread_id, NULL, nstack_select_thread, NULL))
+ if (pthread_create(&g_select_thread_id, NULL, nstack_select_thread, NULL))
{
- goto ERR_RET;
+ goto ERR_RET;
}
- retval = pthread_setname_np (select_thread_id, "nstack_select");
- if (retval)
+ retval = pthread_setname_np(g_select_thread_id, "nstack_select");
+ if (retval)
{
- /*set thread name failed */
+ /*set thread name failed */
}
- g_select_module.inited = TRUE;
- g_select_module.entry_head = g_select_module.entry_tail = NULL;
- return TRUE;
+ g_select_module.inited = TRUE;
+ g_select_module.entry_head = g_select_module.entry_tail = NULL;
+ return TRUE;
-ERR_RET:
+ ERR_RET:
- return FALSE;
+ return FALSE;
}
-/*****************************************************************************
-* Prototype : entry_module_fdset
-* Description : set event
-* Input : struct select_entry *entry
-* i32 fd_size
-* nstack_fd_set *readfd
-* nstack_fd_set *writefd
-* nstack_fd_set *exceptfd
-* i32 inx
-* Output : None
-* Return Value : void
-* Calls :
-* Called By :
-*****************************************************************************/
-void
-entry_module_fdset (struct select_entry *entry,
- i32 fd_size,
- nstack_fd_set * readfd,
- nstack_fd_set * writefd,
- nstack_fd_set * exceptfd, i32 inx)
+NSTACK_STATIC inline void entry_mod_fdset_nstack(int fd, int idx, int inx,
+ struct select_entry *entry,
+ nstack_fd_set * readfd,
+ nstack_fd_set * writefd,
+ nstack_fd_set * exceptfd)
{
- i32 i;
- i32 fd;
+ if (NSTACK_FD_ISSET(idx, readfd)
+ && NSTACK_FD_ISSET(idx, &entry->cb[inx].nstack_readset))
+ {
+ FD_SET(fd, &entry->ready.readset);
+ entry->ready.count++;
+ NSSOC_LOGDBG("readyset is %d", entry->ready.readyset);
+ }
- for (i = 0; i < fd_size; i++)
+ if (NSTACK_FD_ISSET(idx, writefd)
+ && NSTACK_FD_ISSET(idx, &entry->cb[inx].nstack_writeset))
{
- fd = select_get_commfd (i, inx);
- if (fd < 0)
- {
- continue;
- }
- if (NSTACK_FD_ISSET (i, readfd)
- && NSTACK_FD_ISSET (i, &entry->cb[inx].nstack_readset))
- {
- FD_SET (fd, &entry->ready.readset);
- entry->ready.readyset++;
- NSSOC_LOGDBG ("readyset is %d", entry->ready.readyset);
- }
+ FD_SET(fd, &entry->ready.writeset);
+ entry->ready.count++;
+ NSSOC_LOGDBG("writeset is %d", entry->ready.readyset);
+ }
- if (NSTACK_FD_ISSET (i, writefd)
- && NSTACK_FD_ISSET (i, &entry->cb[inx].nstack_writeset))
- {
- FD_SET (fd, &entry->ready.writeset);
- entry->ready.readyset++;
- NSSOC_LOGDBG ("writeset is %d", entry->ready.readyset);
- }
+ if (NSTACK_FD_ISSET(idx, exceptfd)
+ && NSTACK_FD_ISSET(idx, &entry->cb[inx].nstack_exceptset))
+ {
+ FD_SET(fd, &entry->ready.exceptset);
+ entry->ready.count++;
+ NSSOC_LOGDBG("exceptset is %d", entry->ready.readyset);
+ }
+}
- if (NSTACK_FD_ISSET (i, exceptfd)
- && NSTACK_FD_ISSET (i, &entry->cb[inx].nstack_exceptset))
+/*no need to check null pointer*/
+void entry_module_fdset(struct select_entry *entry,
+ i32 fd_size,
+ nstack_fd_set * readfd,
+ nstack_fd_set * writefd,
+ nstack_fd_set * exceptfd, i32 inx)
+{
+ i32 i;
+ i32 fd;
+
+ for (i = 0; i < fd_size; i++)
+ {
+ fd = select_get_commfd(i, inx);
+ if (fd < 0)
{
- FD_SET (fd, &entry->ready.exceptset);
- entry->ready.readyset++;
- NSSOC_LOGDBG ("exceptset is %d", entry->ready.readyset);
+ continue;
}
+
+ entry_mod_fdset_nstack(fd, i, inx, entry, readfd, writefd, exceptfd);
}
+}
+NSTACK_STATIC inline int nstack_fd_copy(nstack_fd_set * psrc,
+ nstack_fd_set * pdst, u32 size)
+{
+ return memcpy_s(pdst->fds_bits, size, psrc->fds_bits, size);
+}
+
+NSTACK_STATIC inline int alloc_and_init_fd_set(nstack_fd_set * readfd,
+ nstack_fd_set * writefd,
+ nstack_fd_set * exceptfd,
+ struct select_cb_p *select_cb)
+{
+ int ret = 0;
+ u32 fds_bits_size =
+ sizeof(unsigned char) * ((NSTACK_SELECT_MAX_FD + 7) >> 3);
+
+ readfd->fds_bits = select_fd_set_bits_alloc();
+ writefd->fds_bits = select_fd_set_bits_alloc();
+ exceptfd->fds_bits = select_fd_set_bits_alloc();
+ if (!readfd->fds_bits || !writefd->fds_bits || !exceptfd->fds_bits)
+ {
+ return -1;
+ }
+
+ ret |=
+ nstack_fd_copy(&(select_cb->nstack_readset), readfd, fds_bits_size);
+ ret |=
+ nstack_fd_copy(&(select_cb->nstack_writeset), writefd, fds_bits_size);
+ ret |=
+ nstack_fd_copy(&(select_cb->nstack_exceptset), exceptfd,
+ fds_bits_size);
+ if (EOK != ret)
+ {
+ return -1;
+ }
+
+ return 0;
+}
+
+NSTACK_STATIC inline i32 select_scan_linux(struct select_entry * entry,
+ int inx)
+{
+ i32 fd_size;
+ i32 ready;
+ fd_set readfd;
+ fd_set writefd;
+ fd_set exceptfd;
+ struct timeval timeout;
+
+ fd_size = entry->cb[inx].count;
+ if (!g_select_module.get_select_fun_nonblock[inx] || (fd_size <= 0))
+ {
+ return TRUE;
+ }
+
+ readfd = (entry->cb[inx].readset);
+ writefd = (entry->cb[inx].writeset);
+ exceptfd = (entry->cb[inx].exceptset);
+
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 0;
+
+ ready =
+ g_select_module.get_select_fun_nonblock[inx] (fd_size, &readfd,
+ &writefd, &exceptfd,
+ &timeout);
+ if (ready > 0)
+ {
+ entry_module_fdset_linux(entry, fd_size, &readfd, &writefd,
+ &exceptfd, inx);
+ }
+ else if (ready < 0)
+ {
+ entry->ready.count = ready;
+ entry->ready.select_errno = errno;
+ NSSOC_LOGERR("select failed index = %d", inx);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+NSTACK_STATIC inline i32 select_scan_nstack(struct select_entry * entry,
+ int inx)
+{
+ i32 fd_size;
+ i32 ready;
+ i32 ret = TRUE;
+ nstack_fd_set *readfd = NULL;
+ nstack_fd_set *writefd = NULL;
+ nstack_fd_set *exceptfd = NULL;
+ struct timeval timeout;
+
+ fd_size = entry->cb[inx].count;
+ if (!g_select_module.get_select_fun_nonblock[inx] || (fd_size <= 0))
+ {
+ return TRUE;
+ }
+
+ readfd = select_alloc(sizeof(nstack_fd_set));
+ writefd = select_alloc(sizeof(nstack_fd_set));
+ exceptfd = select_alloc(sizeof(nstack_fd_set));
+
+ if (!readfd || !writefd || !exceptfd)
+ {
+ NSSOC_LOGERR("malloc fd sets failed");
+ FREE_SELECT_FD_SET(readfd, writefd, exceptfd);
+ return FALSE;
+ }
+
+ if (alloc_and_init_fd_set(readfd, writefd, exceptfd, &(entry->cb[inx])))
+ {
+ NSSOC_LOGERR("malloc fd bits failed");
+ goto return_over;
+ ret = FALSE;
+ }
+
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 0;
+
+ ready =
+ g_select_module.get_select_fun_nonblock[inx] (fd_size,
+ (fd_set *) readfd,
+ (fd_set *) writefd,
+ (fd_set *) exceptfd,
+ &timeout);
+ if (ready > 0)
+ {
+ entry_module_fdset(entry, fd_size, readfd, writefd, exceptfd, inx);
+ }
+ else if (ready < 0)
+ {
+ entry->ready.count = ready;
+ entry->ready.select_errno = errno;
+ NSSOC_LOGERR("select failed index = %d", inx);
+ goto return_over;
+ ret = FALSE;
+ }
+
+ return_over:
+ SELECT_FREE_FD_BITS(readfd, writefd, exceptfd);
+ FREE_SELECT_FD_SET(readfd, writefd, exceptfd);
+ return ret;
}
/*****************************************************************************
@@ -496,100 +786,37 @@ entry_module_fdset (struct select_entry *entry,
* Calls :
* Called By :
*****************************************************************************/
-i32
-select_scan (struct select_entry *entry)
+i32 select_scan(struct select_entry * entry)
{
- i32 inx;
- i32 fd_size;
- i32 ready;
- nstack_fd_set *readfd;
- nstack_fd_set *writefd;
- nstack_fd_set *exceptfd;
- struct timeval timeout;
-
- readfd = malloc (sizeof (nstack_fd_set));
- writefd = malloc (sizeof (nstack_fd_set));
- exceptfd = malloc (sizeof (nstack_fd_set));
- if ((!readfd) || (!writefd) || (!exceptfd))
- {
- NSPOL_LOGERR ("malloc nstack_fd_set fail");
- FREE_FD_SET (readfd, writefd, exceptfd);
- return -1;
- }
- for (inx = 0; inx < get_mode_num (); inx++)
- {
-
- *readfd = entry->cb[inx].nstack_readset;
- *writefd = entry->cb[inx].nstack_writeset;
- *exceptfd = entry->cb[inx].nstack_exceptset;
- fd_size = entry->cb[inx].count;
- timeout.tv_sec = 0;
- timeout.tv_usec = 0;
- if ((g_select_module.get_select_fun_nonblock[inx]) && (fd_size > 0))
+ i32 inx;
+ int ret = 0;
+
+ for (inx = 0; inx < nstack_get_module_num(); inx++)
+ {
+ if (inx == nstack_get_linux_mid())
{
- ready =
- g_select_module.get_select_fun_nonblock[inx] (fd_size,
- (fd_set *) readfd,
- (fd_set *) writefd,
- (fd_set *) exceptfd,
- &timeout);
+ ret = select_scan_linux(entry, inx);
}
- else
+ else
{
- continue;
+ ret = select_scan_nstack(entry, inx);
}
- if (ready > 0)
+ if (!ret)
{
- entry_module_fdset (entry, fd_size, readfd, writefd, exceptfd, inx);
+ return FALSE;
}
- else if (ready < 0)
- {
- entry->ready.readyset = ready;
- entry->ready.select_errno = errno;
- NSSOC_LOGERR ("select failed index = %d", inx);
- FREE_FD_SET (readfd, writefd, exceptfd);
- return FALSE;
- }
-
}
- FREE_FD_SET (readfd, writefd, exceptfd);
- return TRUE;
-}
-/*****************************************************************************
-* Prototype : lint_lock
-* Description : avoid lint error
-* Input : None
-* Output : None
-* Return Value : static inline void
-* Calls :
-* Called By :
-*****************************************************************************/
-static inline void
-lint_lock ()
-{
- return;
+ return TRUE;
}
-/*****************************************************************************
-* Prototype : lint_unlock
-* Description : avoid lint error
-* Input : None
-* Output : None
-* Return Value : static inline void
-* Calls :
-* Called By :
-*****************************************************************************/
-static inline void
-lint_unlock ()
-{
- return;
-}
+/*no need to check null pointer*/
+/*try to get event form all modules */
/*****************************************************************************
* Prototype : nstack_select_thread
-* Description : if global list not null scaning all modules ,need to think
+* Description : if gloab list not null scaning all modules ,need to think
about block mod
* Input : void *arg
* Output : None
@@ -597,100 +824,145 @@ lint_unlock ()
* Calls :
* Called By :
*****************************************************************************/
-void *
-nstack_select_thread (void *arg)
-{
-
-#define SELECT_SLEEP_TIME 100 //us
- i32 inx;
- nstack_fd_set *readfd;
- nstack_fd_set *writefd;
- nstack_fd_set *exceptfd;
- i32 fd_size;
- i32 ready;
- i32 sleep_time = SELECT_SLEEP_TIME;
- struct timeval timeout;
+void *nstack_select_thread(void *arg)
+{
- lint_lock ();
+#define SELECT_SLEEP_TIME 800 //us
+
+ i32 inx;
+ nstack_fd_set *readfd;
+ nstack_fd_set *writefd;
+ nstack_fd_set *exceptfd;
+ fd_set rdfd;
+ fd_set wtfd;
+ fd_set expfd;
+ i32 fd_size;
+ i32 ready;
+ i32 sleep_time = SELECT_SLEEP_TIME;
+ struct timeval timeout;
+ int selet_errno;
+
+ readfd = select_alloc(sizeof(nstack_fd_set));
+ writefd = select_alloc(sizeof(nstack_fd_set));
+ exceptfd = select_alloc(sizeof(nstack_fd_set));
+ if ((!readfd) || (!writefd) || (!exceptfd))
+ {
+ NSPOL_LOGERR("malloc nstack_fd_set fail");
+ FREE_SELECT_FD_SET(readfd, writefd, exceptfd);
+ return NULL;
+ }
- readfd = malloc (sizeof (nstack_fd_set));
- writefd = malloc (sizeof (nstack_fd_set));
- exceptfd = malloc (sizeof (nstack_fd_set));
- if ((!readfd) || (!writefd) || (!exceptfd))
+ readfd->fds_bits = select_fd_set_bits_alloc();
+ writefd->fds_bits = select_fd_set_bits_alloc();
+ exceptfd->fds_bits = select_fd_set_bits_alloc();
+ if ((!readfd->fds_bits) || (!writefd->fds_bits) || (!exceptfd->fds_bits))
{
- NSPOL_LOGERR ("malloc nstack_fd_set fail");
- FREE_FD_SET (readfd, writefd, exceptfd);
- lint_unlock ();
- return NULL;
+ NSPOL_LOGERR("malloc fd_bits for nstack_fd_set fail");
+
+ SELECT_FREE_FD_BITS(readfd, writefd, exceptfd);
+ FREE_SELECT_FD_SET(readfd, writefd, exceptfd);
+ return NULL;
}
- /*used nonblock need add block mod later */
+ /*used nonblock need add block mod later */
- for (;;)
+ for (;;)
{
- /*wait app calling select no cong cpu */
- if (!g_select_module.entry_head)
+ /*wait app calling select no cong cpu */
+ if (!g_select_module.entry_head)
{
- select_sem_wait (&g_select_module.sem);
+ select_sem_wait(&g_select_module.sem); /*do not need return value */
}
- for (inx = 0; inx < get_mode_num (); inx++)
+ for (inx = 0; inx < nstack_get_module_num(); inx++)
{
- fd_size =
- select_thread_get_fdset (readfd, writefd, exceptfd,
- &g_select_module, inx);
- if (fd_size <= 0)
+ if (inx == nstack_get_linux_mid())
{
- continue;
- }
+ fd_size =
+ select_thread_get_fdset_linux(&rdfd, &wtfd, &expfd,
+ &g_select_module, inx);
+ if (fd_size <= 0)
+ continue;
+ if (g_select_module.get_select_fun_nonblock[inx])
+ ready =
+ g_select_module.get_select_fun_nonblock[inx] (fd_size,
+ (fd_set
+ *) &
+ rdfd,
+ (fd_set
+ *) &
+ wtfd,
+ (fd_set
+ *) &
+ expfd,
+ &timeout);
+ else
+ continue;
+
+ if (ready > 0)
+
+ select_thread_set_fdset_linux(fd_size, &rdfd,
+ &wtfd, &expfd,
+ &g_select_module, inx, 0);
+ else if (ready < 0)
+ {
- if (g_select_module.get_select_fun_nonblock[inx])
- {
- ready =
- g_select_module.get_select_fun_nonblock[inx] (fd_size,
- (fd_set *)
- readfd,
- (fd_set *)
- writefd,
- (fd_set *)
- exceptfd,
- &timeout);
+ selet_errno = errno;
+ select_thread_set_fdset_linux(fd_size, &rdfd, &wtfd,
+ &expfd, &g_select_module,
+ inx, selet_errno);
+ break;
+ }
}
- else
+ else
{
- continue;
- }
+ fd_size =
+ select_thread_get_fdset(readfd, writefd, exceptfd,
+ &g_select_module, inx);
+ if (fd_size <= 0)
+ continue;
+ if (g_select_module.get_select_fun_nonblock[inx])
+ ready =
+ g_select_module.get_select_fun_nonblock[inx] (fd_size,
+ (fd_set
+ *)
+ readfd,
+ (fd_set
+ *)
+ writefd,
+ (fd_set
+ *)
+ exceptfd,
+ &timeout);
+ else
+ continue;
+
+ if (ready > 0)
+ select_thread_set_fdset(fd_size, readfd, writefd, exceptfd, &g_select_module, inx, 0); /*do not need return value */
+ else if (ready < 0)
+ {
+ selet_errno = errno;
+ select_thread_set_fdset(ready, readfd, writefd, exceptfd, &g_select_module, inx, selet_errno); /*do not need return value */
+ break;
+ }
- if (ready > 0)
- {
- select_thread_set_fdset (fd_size, readfd, writefd, exceptfd,
- &g_select_module, inx, 0);
- }
- else if (ready < 0)
- {
- select_thread_set_fdset (ready, readfd, writefd, exceptfd,
- &g_select_module, inx, errno);
- NSSOC_LOGERR ("module[%d] select failed] ret = %d errno = %d",
- inx, ready, errno);
- lint_unlock ();
- break;
}
}
- select_event_post (&g_select_module);
- timeout.tv_sec = 0;
- timeout.tv_usec = sleep_time;
- lint_unlock ();
- /*use linux select for timer */
- nsfw_base_select (1, NULL, NULL, NULL, &timeout);
+ select_event_post(&g_select_module);
+ timeout.tv_sec = 0;
+ timeout.tv_usec = sleep_time;
+ /*use linux select for timer */
+ nsfw_base_select(1, NULL, NULL, NULL, &timeout);
+ //sys_sleep_ns(0, sleep_time); //g_sem_sleep_time
}
}
/*****************************************************************************
* Prototype : nssct_create
-* Description : create a select record for event fd
+* Description : create a select record for eveny fd
* Input : i32 cfd
* i32 mfd
* i32 inx
@@ -699,15 +971,14 @@ nstack_select_thread (void *arg)
* Calls :
* Called By :
*****************************************************************************/
-void
-nssct_create (i32 cfd, i32 mfd, i32 inx)
+void nssct_create(i32 cfd, i32 mfd, i32 inx)
{
- if (g_select_module.inited != TRUE)
+ if (g_select_module.inited != TRUE)
{
- return;
+ return;
}
- select_set_modfd (cfd, inx, mfd);
- select_set_commfd (mfd, inx, cfd);
+ select_set_modfd(cfd, inx, mfd); /*do not need return value */
+ select_set_commfd(mfd, inx, cfd); /*do not need return value */
}
/*****************************************************************************
@@ -720,17 +991,16 @@ nssct_create (i32 cfd, i32 mfd, i32 inx)
* Calls :
* Called By :
*****************************************************************************/
-void
-nssct_close (i32 cfd, i32 inx)
+void nssct_close(i32 cfd, i32 inx)
{
- if (g_select_module.inited != TRUE)
+ if (g_select_module.inited != TRUE)
{
- return;
+ return;
}
- i32 mfd = select_get_modfd (cfd, inx);
- select_set_modfd (cfd, inx, -1);
- select_set_commfd (mfd, inx, -1);
- select_set_index (cfd, -1);
+ i32 mfd = select_get_modfd(cfd, inx);
+ select_set_modfd(cfd, inx, -1); /*do not need return value */
+ select_set_commfd(mfd, inx, -1); /*do not need return value */
+ select_set_index(cfd, -1); /*do not need return value */
}
/*****************************************************************************
@@ -743,36 +1013,260 @@ nssct_close (i32 cfd, i32 inx)
* Calls :
* Called By :
*****************************************************************************/
-void
-nssct_set_index (i32 fd, i32 inx)
+void nssct_set_index(i32 fd, i32 inx)
+{
+ if (g_select_module.inited != TRUE)
+ {
+ return;
+ }
+ select_set_index(fd, inx); /*do not need return value */
+}
+
+int select_scan_return_from_entry(fd_set * readfds, fd_set * writefds,
+ fd_set * exceptfds,
+ struct select_entry *entry)
+{
+ int ret;
+ if (readfds)
+ {
+ *readfds = entry->ready.readset;
+ }
+ if (writefds)
+ {
+ *writefds = entry->ready.writeset;
+ }
+ if (exceptfds)
+ {
+ *exceptfds = entry->ready.exceptset;
+ }
+
+ ret = entry->ready.readyset;
+ if (ret < 0)
+ {
+ errno = entry->ready.select_errno;
+ }
+ return ret;
+}
+
+void nstack_select_entry_free(struct select_entry *entry)
+{
+ int i;
+
+ if (!entry)
+ return;
+
+ for (i = 0; i < nstack_get_module_num(); i++)
+ {
+
+ SELECT_FREE_FD_BITS(&entry->cb[i].nstack_readset,
+ &entry->cb[i].nstack_writeset,
+ &entry->cb[i].nstack_exceptset);
+ }
+
+ SELECT_FREE_FD_BITS(&entry->ready.nstack_readset,
+ &entry->ready.nstack_writeset,
+ &entry->ready.nstack_exceptset);
+
+}
+
+void nstack_select_entry_alloc(struct select_entry **entry)
{
- if (g_select_module.inited != TRUE)
+ struct select_entry *tmp;
+ int i;
+
+ tmp = select_alloc(sizeof(struct select_entry));
+ if (!tmp)
+ return;
+ for (i = 0; i < nstack_get_module_num(); i++)
+ {
+ tmp->cb[i].nstack_readset.fds_bits = select_fd_set_bits_alloc();
+ tmp->cb[i].nstack_writeset.fds_bits = select_fd_set_bits_alloc();
+ tmp->cb[i].nstack_exceptset.fds_bits = select_fd_set_bits_alloc();
+ if (!tmp->cb[i].nstack_readset.fds_bits ||
+ !tmp->cb[i].nstack_writeset.fds_bits ||
+ !tmp->cb[i].nstack_exceptset.fds_bits)
+ {
+ goto err_return;
+ }
+ }
+
+ tmp->ready.nstack_readset.fds_bits = select_fd_set_bits_alloc();
+ tmp->ready.nstack_writeset.fds_bits = select_fd_set_bits_alloc();
+ tmp->ready.nstack_exceptset.fds_bits = select_fd_set_bits_alloc();
+ if (!tmp->ready.nstack_readset.fds_bits ||
+ !tmp->ready.nstack_writeset.fds_bits ||
+ !tmp->ready.nstack_exceptset.fds_bits)
{
- return;
+ goto err_return;
+ }
+
+ *entry = tmp;
+ return;
+ err_return:
+ nstack_select_entry_free(tmp);
+ *entry = NULL;
+}
+
+void select_fail_stat(i32 nfds,
+ fd_set * readfd, fd_set * writefd, fd_set * exceptfd)
+{
+ i32 i;
+ i32 event_id = 0;
+ nstack_fd_Inf *fdInf = NULL;
+
+ for (i = 0; i < nfds; i++)
+ {
+
+ event_id = 0;
+ if (!((readfd && FD_ISSET(i, readfd)) ||
+ (writefd && FD_ISSET(i, writefd)) ||
+ (exceptfd && FD_ISSET(i, exceptfd))))
+ {
+ continue;
+ }
+
+ fdInf = nstack_get_valid_inf(i);
+ if ((NULL == fdInf) || !fdInf->ops
+ || (fdInf->rmidx != MOD_INDEX_FOR_STACKPOOL))
+ {
+ continue;
+ }
+ if ((readfd) && (FD_ISSET(i, readfd)))
+ {
+ event_id |= EPOLLIN;
+ }
+ if ((writefd) && (FD_ISSET(i, writefd)))
+ {
+ event_id |= EPOLLOUT;
+ }
+ if ((exceptfd) && (FD_ISSET(i, exceptfd)))
+ {
+ event_id |= EPOLLERR;
+ }
+ nstack_dfx_state_update((u64) fdInf->rlfd, fdInf->rmidx,
+ DMM_APP_SELECT_FAIL,
+ (void *) ((u64_t) event_id));
}
- select_set_index (fd, inx);
}
-i32
-select_module_init_child ()
+int nstack_select_processing(int nfds, fd_set * readfds, fd_set * writefds,
+ fd_set * exceptfds, struct timeval *timeout)
{
- pthread_t select_thread_id;
- i32 retval;
+ int ret = -1;
+ struct select_module_info *select_module = get_select_module();
+ struct select_entry *entry = NULL;
- if (pthread_create (&select_thread_id, NULL, nstack_select_thread, NULL))
+ nstack_select_entry_alloc(&entry);
+ if (NULL == entry)
{
- goto ERR_RET;
+ errno = ENOMEM;
+ NSSOC_LOGERR("select entry alloc fail");
+ goto err_return;
}
+ /* need init sem */
+ select_sem_init(&entry->sem, 0, 0); /*do not need return value */
+
+ /* fix dead-code type */
+ /*split select fd to each modules fd and save to entry */
+ (void) select_cb_split_by_mod(nfds, readfds, writefds, exceptfds, entry);
+
+ /*if all fd in default module we just calling it */
+ if (entry->info.set_num <= 1)
+ {
+
+ /*adapte linux */
+ if ((select_module)
+ && (entry->info.index == select_module->default_mod))
+ {
+ if (select_module->default_fun)
+ {
+ ret =
+ select_module->default_fun(nfds, readfds, writefds,
+ exceptfds, timeout);
+ }
+ else
+ {
+ ret =
+ nsfw_base_select(nfds, readfds, writefds, exceptfds,
+ timeout);
+ }
+ goto err_return;
+ }
+ }
+
+ /*cheching if event ready or not */
+ if (FALSE == select_scan(entry))
+ {
+ NSSOC_LOGERR("select scan fail");
+ goto err_return;
+ }
+
+ if (entry->ready.readyset != 0)
+ {
+ goto scan_return;
+ }
+
+ if (TIMEVAL_EQUAL_ZERO(timeout))
+ {
+ goto scan_return;
+ }
+
+ if (FALSE == select_add_cb(entry))
+ {
+ errno = ENOMEM;
+ NSSOC_LOGERR("select entry add fail");
+ goto err_return;
+ }
+
+ if (NULL == timeout)
+ {
+ select_sem_wait(&entry->sem); /*do not need return value */
+ }
+ else
+ {
+ long time_cost = 0;
+ long msec = 0;
+ if (nstack_timeval2msec(timeout, &msec))
+ {
+ nstack_set_errno(EINVAL);
+ goto err_return;
+ }
+ ret = nstack_sem_timedwait(&entry->sem, msec, &time_cost);
+ if (ret < 0)
+ {
+ nstack_set_errno(EINVAL);
+ goto err_return;
+ }
+
+ if (time_cost >= msec)
+ {
+ select_fail_stat(nfds, readfds, writefds, exceptfds);
+ timeout->tv_sec = 0;
+ timeout->tv_usec = 0;
+ }
+ else if (time_cost > 0)
+ {
+ msec = msec - time_cost;
+ timeout->tv_sec = msec / 1000;
+ timeout->tv_usec = (msec % 1000) * 1000;
+ }
+ }
+
+ select_rm_cb(entry); /*do not need return value */
+
+ scan_return:
+ ret = select_scan_return_from_entry(readfds, writefds, exceptfds, entry);
- retval = pthread_setname_np (select_thread_id, "nstack_select_child");
- if (retval)
+ err_return:
+ if (entry)
{
- /*set thread name failed */
+ nstack_select_entry_free(entry);
}
- return TRUE;
+ NSSOC_LOGDBG
+ ("nfds=%d,readfds=%p,writefds=%p,exceptfds=%p,timeout=%p,ret=%d errno=%d",
+ nfds, readfds, writefds, exceptfds, timeout, ret, errno);
-ERR_RET:
- return FALSE;
+ return ret;
}
#endif /* NSTACK_SELECT_MODULE */
diff --git a/src/nSocket/nstack/event/select/select_adapt.c b/src/nSocket/nstack/event/select/select_adapt.c
index a9858e8..f61d7c1 100644
--- a/src/nSocket/nstack/event/select/select_adapt.c
+++ b/src/nSocket/nstack/event/select/select_adapt.c
@@ -26,314 +26,199 @@
/*==============================================*
* project-wide global variables *
*----------------------------------------------*/
-i32 nstack_mod_fd[NSTACK_MAX_MODULE_NUM][NSTACK_SELECT_MAX_FD];
struct select_fd_map_inf g_select_fd_map;
/*==============================================*
* routines' or functions' implementations *
*----------------------------------------------*/
-/*****************************************************************************
-* Prototype : select_alloc
-* Description : select_alloc
-* Input : int size
-* Output : None
-* Return Value : void *
-* Calls :
-* Called By :
-*****************************************************************************/
-void *
-select_alloc (int size)
+void *select_alloc(int size)
{
- char *p;
- if (size <= 0)
+ char *p;
+ if (size <= 0)
{
- return NULL;
+ return NULL;
}
- p = malloc (size);
- if (!p)
+ p = malloc(size);
+ if (!p)
{
- return NULL;
+ return NULL;
}
- if (EOK != MEMSET_S (p, size, 0, size))
+ if (EOK != memset_s(p, size, 0, size))
{
- free (p);
- p = NULL;
+ free(p);
+ p = NULL;
}
- return p;
+ return p;
}
-/*****************************************************************************
-* Prototype : select_free
-* Description : select_free
-* Input : char *p
-* Output : None
-* Return Value : void
-* Calls :
-* Called By :
-*****************************************************************************/
-void
-select_free (char *p)
+/*point is set to NULL because it's freeed */
+void select_free(void *p)
{
- if (p)
+ if (p)
{
- free (p);
- p = NULL;
+ free(p);
+ p = NULL;
}
}
-/*****************************************************************************
-* Prototype : get_select_fdinf
-* Description : get_select_fdinf
-* Input : i32 fd
-* Output : None
-* Return Value : struct select_comm_fd_map *
-* Calls :
-* Called By :
-*****************************************************************************/
-struct select_comm_fd_map *
-get_select_fdinf (i32 fd)
+struct select_comm_fd_map *get_select_fdinf(i32 fd)
{
- if ((fd < 0) || (fd >= NSTACK_SELECT_MAX_FD))
+ if ((fd < 0) || ((u32) fd >= NSTACK_SELECT_MAX_FD))
{
- return NULL;
+ return NULL;
}
- return (&g_select_fd_map.fdinf[fd]);
+ return (&g_select_fd_map.fdinf[fd]);
}
-/*****************************************************************************
-* Prototype : reset_select_fdinf
-* Description : reset_select_fdinf
-* Input : i32 fd
-* Output : None
-* Return Value : void
-* Calls :
-* Called By :
-*****************************************************************************/
-void
-reset_select_fdinf (i32 fd)
+void reset_select_fdinf(i32 fd)
{
- i32 i;
- struct select_comm_fd_map *fdinf = get_select_fdinf (fd);
- if (NULL == fdinf)
+ i32 i;
+ struct select_comm_fd_map *fdinf = get_select_fdinf(fd);
+ /* fdinf is possible is null */
+ if (NULL == fdinf)
{
- return;
+ return;
}
- fdinf->index = -1;
- for (i = 0; i < NSTACK_MAX_MODULE_NUM; i++)
+ fdinf->index = -1;
+ for (i = 0; i < NSTACK_MAX_MODULE_NUM; i++)
{
- fdinf->mod_fd[i] = -1;
+ fdinf->mod_fd[i] = -1;
}
}
-/*****************************************************************************
-* Prototype : select_get_modfd
-* Description : select_get_modfd
-* Input : i32 fd
-* i32 inx
-* Output : None
-* Return Value : i32
-* Calls :
-* Called By :
-*****************************************************************************/
-i32
-select_get_modfd (i32 fd, i32 inx)
+i32 select_get_modfd(i32 fd, i32 inx)
{
- if ((fd < 0) || (fd >= NSTACK_SELECT_MAX_FD))
+ if ((fd < 0) || ((u32) fd >= NSTACK_SELECT_MAX_FD))
{
- return -1;
+ return -1;
}
- if ((inx < 0))
+ if ((inx < 0))
{
- return -1;
+ return -1;
}
- if (!g_select_fd_map.fdinf)
+ if (!g_select_fd_map.fdinf)
{
- return FALSE;
+ return FALSE;
}
- return (g_select_fd_map.fdinf[fd].mod_fd[inx]);
+ return (g_select_fd_map.fdinf[fd].mod_fd[inx]);
}
-/*****************************************************************************
-* Prototype : select_set_modfd
-* Description : select_set_modfd
-* Input : i32 fd
-* i32 inx
-* i32 modfd
-* Output : None
-* Return Value : i32
-* Calls :
-* Called By :
-*****************************************************************************/
-i32
-select_set_modfd (i32 fd, i32 inx, i32 modfd)
+i32 select_set_modfd(i32 fd, i32 inx, i32 modfd)
{
- if ((fd < 0) || (fd >= NSTACK_SELECT_MAX_FD))
+ if ((fd < 0) || ((u32) fd >= NSTACK_SELECT_MAX_FD))
{
- return -1;
+ return -1;
}
- if (!g_select_fd_map.fdinf)
+ if (!g_select_fd_map.fdinf)
{
- return FALSE;
+ return FALSE;
}
- g_select_fd_map.fdinf[fd].mod_fd[inx] = modfd;
+ g_select_fd_map.fdinf[fd].mod_fd[inx] = modfd;
- return TRUE;
+ return TRUE;
}
-/*****************************************************************************
-* Prototype : select_get_modindex
-* Description : select_get_modindex
-* Input : i32 fd
-* Output : None
-* Return Value : i32
-* Calls :
-* Called By :
-*****************************************************************************/
-i32
-select_get_modindex (i32 fd)
+i32 select_get_modindex(i32 fd)
{
- if ((fd < 0) || (fd >= NSTACK_SELECT_MAX_FD))
+ if ((fd < 0) || ((u32) fd >= NSTACK_SELECT_MAX_FD))
{
- return -1;
+ return -1;
}
- return g_select_fd_map.fdinf[fd].index;
+ return g_select_fd_map.fdinf[fd].index;
}
-/*****************************************************************************
-* Prototype : select_get_commfd
-* Description : select_get_commfd
-* Input : i32 modfd
-* i32 inx
-* Output : None
-* Return Value : i32
-* Calls :
-* Called By :
-*****************************************************************************/
-i32
-select_get_commfd (i32 modfd, i32 inx)
+i32 select_get_commfd(i32 modfd, i32 inx)
{
- if ((modfd < 0) || (modfd >= NSTACK_SELECT_MAX_FD))
+ if ((modfd < 0) || ((u32) modfd >= NSTACK_SELECT_MAX_FD))
{
- return -1;
+ return -1;
}
- return g_select_fd_map.modinf[inx].comm_fd[modfd];
+ return g_select_fd_map.modinf[inx].comm_fd[modfd];
}
-/*****************************************************************************
-* Prototype : select_set_commfd
-* Description : select_set_commfd
-* Input : i32 modfd
-* i32 inx
-* i32 fd
-* Output : None
-* Return Value : i32
-* Calls :
-* Called By :
-*****************************************************************************/
-i32
-select_set_commfd (i32 modfd, i32 inx, i32 fd)
+i32 select_set_commfd(i32 modfd, i32 inx, i32 fd)
{
- if ((modfd < 0) || (modfd >= NSTACK_SELECT_MAX_FD))
+ if ((modfd < 0) || ((u32) modfd >= NSTACK_SELECT_MAX_FD))
{
- return -1;
+ return -1;
}
- if (!g_select_fd_map.modinf[inx].comm_fd)
+ if (!g_select_fd_map.modinf[inx].comm_fd)
{
- return FALSE;
+ return FALSE;
}
- g_select_fd_map.modinf[inx].comm_fd[modfd] = fd;
+ g_select_fd_map.modinf[inx].comm_fd[modfd] = fd;
- return TRUE;
+ return TRUE;
}
-/*****************************************************************************
-* Prototype : select_set_index
-* Description : select_set_index
-* Input : i32 fd
-* i32 inx
-* Output : None
-* Return Value : i32
-* Calls :
-* Called By :
-*****************************************************************************/
-i32
-select_set_index (i32 fd, i32 inx)
+i32 select_set_index(i32 fd, i32 inx)
{
- if ((fd < 0) || (fd >= NSTACK_SELECT_MAX_FD))
+ if ((fd < 0) || ((u32) fd >= NSTACK_SELECT_MAX_FD))
{
- return -1;
+ return -1;
}
- if (!g_select_fd_map.fdinf)
+ if (!g_select_fd_map.fdinf)
{
- return FALSE;
+ return FALSE;
}
- g_select_fd_map.fdinf[fd].index = inx;
- return TRUE;
+ g_select_fd_map.fdinf[fd].index = inx;
+ return TRUE;
}
-/*****************************************************************************
-* Prototype : fdmapping_init
-* Description : fdmapping_init
-* Input : void
-* Output : None
-* Return Value : i32
-* Calls :
-* Called By :
-*****************************************************************************/
-i32
-fdmapping_init (void)
+i32 fdmapping_init(void)
{
- int ret = FALSE;
- int i, inx;
+ int ret = FALSE;
+ int i, inx;
- g_select_fd_map.fdinf =
- (struct select_comm_fd_map *)
- select_alloc (sizeof (struct select_comm_fd_map) * NSTACK_SELECT_MAX_FD);
- if (NULL == g_select_fd_map.fdinf)
+ g_select_fd_map.fdinf =
+ (struct select_comm_fd_map *)
+ select_alloc(sizeof(struct select_comm_fd_map) *
+ NSTACK_SELECT_MAX_FD);
+ if (NULL == g_select_fd_map.fdinf)
{
- goto err_return;
+ goto err_return;
}
- for (i = 0; i < get_mode_num (); i++)
+ for (i = 0; i < nstack_get_module_num(); i++)
{
- g_select_fd_map.modinf[i].comm_fd =
- (i32 *) select_alloc (sizeof (i32) * NSTACK_SELECT_MAX_FD);
- if (NULL == g_select_fd_map.modinf[i].comm_fd)
+ g_select_fd_map.modinf[i].comm_fd =
+ (i32 *) select_alloc(sizeof(i32) * NSTACK_SELECT_MAX_FD);
+ if (NULL == g_select_fd_map.modinf[i].comm_fd)
{
- goto err_return;
+ goto err_return;
}
}
- for (i = 0; i < NSTACK_SELECT_MAX_FD; i++)
+ u32 fd_idx = 0;
+ for (fd_idx = 0; fd_idx < NSTACK_SELECT_MAX_FD; fd_idx++)
{
- reset_select_fdinf (i);
+ reset_select_fdinf(fd_idx);
}
- for (inx = 0; inx < get_mode_num (); inx++)
+ for (inx = 0; inx < nstack_get_module_num(); inx++)
{
- for (i = 0; i < NSTACK_SELECT_MAX_FD; i++)
+ for (fd_idx = 0; fd_idx < NSTACK_SELECT_MAX_FD; fd_idx++)
{
- select_set_commfd (i, inx, -1);
-
+ select_set_commfd(fd_idx, inx, -1);
}
}
- ret = TRUE;
- return ret;
-err_return:
+ ret = TRUE;
+ return ret;
+ err_return:
- select_free ((char *) g_select_fd_map.fdinf);
- for (i = 0; i < get_mode_num (); i++)
+ select_free((char *) g_select_fd_map.fdinf);
+ for (i = 0; i < nstack_get_module_num(); i++)
{
- select_free ((char *) g_select_fd_map.modinf[i].comm_fd);
+ select_free((char *) g_select_fd_map.modinf[i].comm_fd);
}
- return ret;
+ return ret;
}
diff --git a/src/nSocket/nstack/nstack.c b/src/nSocket/nstack/nstack.c
index 9d6a2ba..444f9fc 100644
--- a/src/nSocket/nstack/nstack.c
+++ b/src/nSocket/nstack/nstack.c
@@ -20,773 +20,889 @@
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
-#include "common_mem_buf.h"
-#include "common_mem_api.h"
+#include <dlfcn.h>
#include "nstack_eventpoll.h"
#include "nstack_socket.h"
#include "nstack_securec.h"
-#include "nsfw_init.h"
+#include "nsfw_init_api.h"
#include "nstack_share_res.h"
#include "nsfw_mgr_com_api.h"
#include "nsfw_ps_mem_api.h"
-#include "nsfw_fd_timer_api.h"
#include "nsfw_ps_api.h"
#include "nsfw_recycle_api.h"
+#include "nsfw_maintain_api.h"
#include "nstack_fd_mng.h"
+#include "nstack_sem.h"
+#include "nsfw_maintain_api.h"
+#include "nstack_module.h"
+#include "nsfw_mem_api.h"
+#include "dmm_rwlock.h"
+#include "nsfw_base_linux_api.h"
+#include "nstack_dmm_dfx.h"
#include "nstack_info_parse.h"
-#include "nstack_dmm_adpt.h"
#include "nstack_rd.h"
-#include "nstack_module.h"
-#include "nstack_select.h"
-#include "common_func.h"
-#define NSTACK_EVENT_MEN_MAXLEN (sizeof(struct eventpoll_pool) + NSTACK_MAX_EPOLL_NUM * sizeof(struct eventpoll_entry))
-#define NSTACK_EPITEM_MEN_MAXLEN (sizeof(struct epitem_pool) + NSTACK_MAX_EPITEM_NUM *sizeof(struct epitem_entry))
-/* *INDENT-OFF* */
+int nstack_dmm_dfx_init(nstack_proc_ops * ops);
nStack_info_t g_nStackInfo = {
- .hasInited = NSTACK_MODULE_INIT,
- .fwInited = NSTACK_MODULE_INIT,
- .moduleload = NSTACK_MODULE_INIT,
- .load_mutex = PTHREAD_MUTEX_INITIALIZER,
- .lk_sockPoll = NULL,
- .pid = 0,
- .fork_lock = {0},
- .ikernelfdmax = NSTACK_MAX_SOCK_NUM,
- };
-
-/*if this flag was set, maybe all socket interface called during initializing*/
-__thread int g_tloadflag = 0;
-
-extern u8 app_mode;
-
-/*check init stack*/
-#define NSTACK_INIT_STATE_CHECK_RET(state) do {\
- if ((state) == NSTACK_MODULE_SUCCESS) \
- { \
- return 0; \
- } \
- if ((state) == NSTACK_MODULE_FAIL) \
- { \
- return -1; \
- } \
-}while(0);
-
-
-
-int
-nstack_timeval2msec (struct timeval *pTime, u64_t * msec)
+ .hasInited = NSTACK_MODULE_INIT,
+ .fwInited = NSTACK_MODULE_INIT,
+ .init_mutex = PTHREAD_MUTEX_INITIALIZER,
+ .lk_sockPool = NULL,
+#ifndef KERNEL_FD_SUPPORT
+ .fdhead = 0,
+ .fdlock = {0},
+#endif
+ .pid = 0,
+ .fork_lock = {0},
+ .ikernelfdmax = NSTACK_MAX_SOCK_NUM,
+};
+
+int nstack_timeval2msec(struct timeval *pTime, long *msec)
{
- if (pTime->tv_sec < 0 || pTime->tv_usec < 0)
+ if (pTime->tv_sec < 0 || pTime->tv_usec < 0)
{
- NSSOC_LOGERR ("time->tv_sec is negative");
- return -1;
+ NSSOC_LOGERR("time->tv_sec is nagative");
+ return -1;
}
- if (NSTACK_MAX_U64_NUM / 1000 < (u64_t) pTime->tv_sec)
+ if (NSTACK_MAX_U64_NUM / 1000 < (u64_t) pTime->tv_sec)
{
- NSSOC_LOGERR ("tout.tv_sec is too large]tout.tv_sec=%lu",
- pTime->tv_sec);
- return -1;
+ NSSOC_LOGERR("tout.tv_sec is too large]tout.tv_sec=%ld",
+ pTime->tv_sec);
+ return -1;
}
- u64_t sec2msec = 1000 * pTime->tv_sec;
- u64_t usec2msec = (u64_t) pTime->tv_usec / 1000;
+ long sec2msec = 1000 * pTime->tv_sec;
+ long usec2msec = pTime->tv_usec / 1000;
- if (NSTACK_MAX_U64_NUM - sec2msec < usec2msec)
+ if (NSTACK_MAX_U64_NUM - sec2msec < usec2msec)
{
- NSSOC_LOGERR
- ("nsec2msec plus sec2usec is too large]usec2msec=%lu,usec2msec=%lu",
- usec2msec, sec2msec);
- return -1;
+ NSSOC_LOGERR
+ ("nsec2msec plus sec2usec is too large]usec2msec=%lu,usec2msec=%lu",
+ usec2msec, sec2msec);
+ return -1;
}
- *msec = sec2msec + usec2msec;
- return 0;
+ *msec = sec2msec + usec2msec;
+ return 0;
}
-int
-nstack_current_time2msec (u64_t * msec)
+int nstack_current_time2msec(long *msec)
{
- struct timespec tout;
- if (unlikely (0 != clock_gettime (CLOCK_MONOTONIC, &tout)))
+ struct timespec tout;
+ if (unlikely(0 != clock_gettime(CLOCK_MONOTONIC, &tout)))
{
- NSSOC_LOGERR ("Failed to get time, errno = %d", errno);
+ NSSOC_LOGERR("Failed to get time, errno=%d", errno);
}
- if (NSTACK_MAX_U64_NUM / 1000 < (u64_t) tout.tv_sec)
+ if (NSTACK_MAX_U64_NUM / 1000 < (u64_t) tout.tv_sec)
{
- NSSOC_LOGERR ("tout.tv_sec is too large]tout.tv_sec=%lu", tout.tv_sec);
- return -1;
+ NSSOC_LOGERR("tout.tv_sec is too large]tout.tv_sec=%ld", tout.tv_sec);
+ return -1;
}
- u64_t sec2msec = 1000 * tout.tv_sec;
- u64_t nsec2msec = (u64_t) tout.tv_nsec / 1000000;
+ long sec2msec = 1000 * tout.tv_sec;
+ long nsec2msec = tout.tv_nsec / 1000000;
- if (NSTACK_MAX_U64_NUM - sec2msec < nsec2msec)
+ if (NSTACK_MAX_U64_NUM - sec2msec < nsec2msec)
{
- NSSOC_LOGERR
- ("nsec2msec plus sec2usec is too large]nsec2msec=%lu,usec2msec=%lu",
- nsec2msec, sec2msec);
- return -1;
+ NSSOC_LOGERR
+ ("nsec2msec plus sec2usec is too large]nsec2msec=%lu,usec2msec=%lu",
+ nsec2msec, sec2msec);
+ return -1;
}
- *msec = sec2msec + nsec2msec;
+ *msec = sec2msec + nsec2msec;
- return 0;
+ return 0;
}
-
-int
-nstack_sem_timedwait (sem_t * pSem, u64_t abs_timeout /*ms */ )
+/*epoll and select shouldnot get affected by system time change*/
+int nstack_sem_timedwait(sem_t * pSem, long abs_timeout /*ms */ ,
+ long *mcost)
{
- int retVal;
+ int retVal;
- u64_t starttime, endtime;
+ /* clock_gettime() get second variable is long, so here should use long */
+ long starttime, endtime;
#define FAST_SLEEP_TIME 10000
#define SLOW_SLEEP_TIME 500000
#define FAST_RETRY_COUNT 100
- unsigned int retry_count = 0;
+ unsigned int retry_count = 0;
- if (nstack_current_time2msec (&starttime))
+ if (abs_timeout < 0 || nstack_current_time2msec(&starttime))
{
- errno = ETIMEDOUT;
- return -1;
+ NSSOC_LOGERR("times out");
+ errno = ETIMEDOUT;
+ return -1;
}
- while (1)
+ while (1)
{
- retVal = sem_trywait (pSem);
+ retVal = sem_trywait(pSem);
- if (nstack_current_time2msec (&endtime))
- {
- errno = ETIMEDOUT;
- return -1;
- }
+ if (nstack_current_time2msec(&endtime))
+ {
+ errno = ETIMEDOUT;
+ return -1;
+ }
- /*when get event we return the time cost */
- if (retVal == 0)
- {
- return (endtime - starttime);
- }
- /*when time out it return 0 */
- if (endtime < starttime || (endtime - starttime) > abs_timeout)
- {
- errno = ETIMEDOUT;
- return abs_timeout;
+ /*when get event we return the time cost */
+ if (retVal == 0)
+ {
+ *mcost = (endtime - starttime);
+ return 0;
+ }
+ /*when time out it return 0 */
+ if (endtime < starttime || (endtime - starttime) > abs_timeout)
+ {
+ errno = ETIMEDOUT;
+ *mcost = abs_timeout;
+ return 0;
+ }
+
+ /*app calling setsockopt to set time */
+ if (retry_count < FAST_RETRY_COUNT)
+ {
+ sys_sleep_ns(0, FAST_SLEEP_TIME);
+ retry_count++;
+ }
+ else
+ {
+ sys_sleep_ns(0, SLOW_SLEEP_TIME);
+ }
}
- /* app calling setsockopt to set time */
- if (retry_count < FAST_RETRY_COUNT)
+}
+
+NSTACK_STATIC inline char *get_ver_head(char *version)
+{
+ const char *split = " ";
+ char *tmp = NULL;
+ char *next_pos = NULL;
+
+ tmp = strtok_s(version, split, &next_pos);
+#ifndef SYSTEMC_LIB
+ if (NULL == tmp || NULL == next_pos)
+#else
+ if (NULL == tmp)
+#endif
{
- sys_sleep_ns (0, FAST_SLEEP_TIME);
- retry_count++;
+ return NULL;
}
- else
+
+ // version
+ tmp = strtok_s(next_pos, split, &next_pos);
+ if (NULL == tmp)
{
- sys_sleep_ns (0, SLOW_SLEEP_TIME);
- }
+ return NULL;
}
+ return tmp;
}
-/*epoll and select shouldnot get affected by system time change*/
-int
-nstack_epoll_sem_timedwait (sem_t * pSem, u64_t abs_timeout /*ms */ ,
- long wait_time /*us */ )
+NSTACK_STATIC int match_version(char *nstack_ver, char *my_ver)
{
- int retVal;
-
- /* clock_gettime() get second variable is long, so here should use long */
- u64_t starttime, endtime;
-
-#define FAST_SLEEP_TIME 10000
-#define SLOW_SLEEP_TIME 500000
-#define FAST_RETRY_COUNT 100
- unsigned int retry_count = 0;
-
- if (nstack_current_time2msec (&starttime))
+ if ((NULL == nstack_ver || 0 == nstack_ver[0]) ||
+ (NULL == my_ver || 0 == my_ver[0]))
{
- errno = ETIMEDOUT;
- return -1;
+ NSSOC_LOGERR("invalid input]");
+ return 0;
}
- while (1)
- {
- retVal = sem_trywait (pSem);
+ char *nstack_ver_head = NULL;
+ char *my_ver_head = NULL;
- if (retVal == 0)
+ char nstack_version[NSTACK_VERSION_LEN] = { 0 };
+ char my_version[NSTACK_VERSION_LEN] = { 0 };
+
+ // !!!strtok_s will modify the original string, so use use temp for parameter
+ /*use strcpy_s instead of memcpy_s to avoid invalid memory visit */
+ if (EOK != strcpy_s(nstack_version, sizeof(nstack_version), nstack_ver))
{
- return retVal;
+ return 0;
}
- if (nstack_current_time2msec (&endtime))
+ nstack_ver_head = get_ver_head(nstack_version);
+ if (NULL == nstack_ver_head)
{
- errno = ETIMEDOUT;
- return -1;
+ return 0;
}
- if (endtime < starttime || (endtime - starttime) > abs_timeout)
+ /*use strcpy_s instead of memcpy_s to avoid invalid memory visit */
+ if (EOK != strcpy_s(my_version, sizeof(my_version), my_ver))
{
- errno = ETIMEDOUT;
- return -1;
+ return 0;
}
- /*app calling setsockopt to set time */
- if (wait_time > 0)
+ my_ver_head = get_ver_head(my_version);
+ if (NULL == my_ver_head)
{
- long wait_sec;
- long wait_nsec;
- wait_sec = wait_time / 1000000;
- wait_nsec = 1000 * (wait_time % 1000000);
- sys_sleep_ns (wait_sec, wait_nsec); //g_sem_sleep_time
+ return 0;
}
- else if (retry_count < FAST_RETRY_COUNT)
+
+ /* Out-of-Bounds Read (FORTIFY.Out-of-Bounds_Read) */
+ if (strlen(my_ver_head) != strlen(nstack_ver_head))
{
- sys_sleep_ns (0, FAST_SLEEP_TIME);
- retry_count++;
+ /*should return 0 when failed */
+ return 0;
}
- else
+
+ if (0 != strncmp(nstack_ver_head, my_ver_head, strlen(nstack_ver_head))) /* Out-of-Bounds Read (FORTIFY.Out-of-Bounds_Read) */
{
- sys_sleep_ns (0, SLOW_SLEEP_TIME);
- }
+ return 0;
}
+ return 1;
}
-NSTACK_STATIC inline char *
-get_ver_head (char *version)
+NSTACK_STATIC inline void set_unmatch_version(char *version,
+ unmatch_ver_info_t *
+ app_ver_info)
{
- const char *split = " ";
- char *tmp = NULL;
- char *next_pos = NULL;
-
- tmp = STRTOK_S (version, split, &next_pos);
- if (NULL == tmp || NULL == next_pos)
+ int i = 0;
+ if (version == NULL || app_ver_info == NULL)
{
- return NULL;
+ return;
}
- // version
- tmp = STRTOK_S (next_pos, split, &next_pos);
- if (NULL == tmp)
+ for (; i < MAX_UNMATCH_VER_CNT; i++)
{
- return NULL;
+ if (app_ver_info[i].unmatch_count != 0)
+ {
+ if (0 ==
+ strncmp(version, app_ver_info[i].lib_version,
+ NSTACK_VERSION_LEN - 1))
+ {
+ app_ver_info[i].unmatch_count++;
+ return;
+ }
+ }
+ else
+ {
+ /* (1) use some fixed value but no effect (e506) (2) it don't contain any extra commas (e505) */
+ if (__sync_bool_compare_and_swap
+ (&app_ver_info[i].unmatch_count, 0, 1))
+ {
+ // use strncpy_s to instead the complex logic
+ //if version is too long, truncate it to ensure the copy success. so set 'count' to NSTACK_VERSION_LEN-1
+ int retval = strncpy_s(app_ver_info[i].lib_version,
+ NSTACK_VERSION_LEN, version,
+ NSTACK_VERSION_LEN - 1);
+ if (EOK != retval)
+ {
+ NSSOC_LOGERR("strncpy_s failed]ret=%d", retval);
+ return;
+ }
+
+ get_current_time(app_ver_info[i].first_time_stamp,
+ LOG_TIME_STAMP_LEN);
+ return;
+ }
+ }
}
-
- return tmp;
}
-NSTACK_STATIC int
-match_version (char *nstack_ver, char *my_ver)
+NSTACK_STATIC inline int check_main_version()
{
- if ((NULL == nstack_ver || 0 == nstack_ver[0]) ||
- (NULL == my_ver || 0 == my_ver[0]))
+ char my_version[NSTACK_VERSION_LEN] = { 0 };
+ nsfw_mem_name stname =
+ { NSFW_SHMEM, NSFW_PROC_MAIN, {NSTACK_VERSION_SHM} };
+ g_nStackInfo.nstack_version = nsfw_mem_zone_lookup(&stname);
+
+ if (NULL == g_nStackInfo.nstack_version)
{
- NSSOC_LOGERR ("invalid input]");
- return 0;
+ NSSOC_LOGERR("can not get nstack version.");
+ return 0;
}
+ /* copy string should use strcpy_s */
+ if (EOK != strcpy_s(my_version, sizeof(my_version), NSTACK_VERSION))
+ {
+ NSSOC_LOGERR("strcpy_s failed");
+ return 0;
+ }
- if (0 != strncmp (nstack_ver, my_ver, 5))
+ if (match_version(g_nStackInfo.nstack_version, my_version))
{
- return 0;
+ return 1;
}
- return 1;
+ NSSOC_LOGERR("version not match]my version=%s, daemon-stack_version=%s",
+ my_version, g_nStackInfo.nstack_version);
+
+ /* record unmatched app version in snapshot- */
+ char *unmatch_app_version =
+ g_nStackInfo.nstack_version + NSTACK_VERSION_LEN;
+
+ set_unmatch_version(my_version,
+ (unmatch_ver_info_t *) unmatch_app_version);
+
+ return 0;
}
-NSTACK_STATIC inline void
-set_unmatch_version (char *version, unmatch_ver_info_t * app_ver_info)
+int nstack_init_shmem()
{
- int i = 0;
- if (version == NULL || app_ver_info == NULL)
- {
- return;
- }
+ int deploytype = nstack_get_deploy_type();
- for (; i < MAX_UNMATCH_VER_CNT; i++)
- {
- if (app_ver_info[i].unmatch_count != 0)
+ if ((deploytype != NSTACK_MODEL_TYPE1)
+ && (deploytype != NSTACK_MODEL_TYPE_SIMPLE_STACK))
{
- if (0 ==
- strncmp (version, app_ver_info[i].lib_version,
- NSTACK_VERSION_LEN - 1))
+ if (nstack_attach_share_res() != 0)
+ {
+ return -1;
+ }
+
+ if (-1 == nsep_attach_memory())
+ {
+ return -1;
+ }
+
+ if (-1 == ns_sync_sem_module_init(1, 0))
{
- app_ver_info[i].unmatch_count++;
- return;
+ return -1;
}
}
- else
+ else
{
- if (__sync_bool_compare_and_swap (&app_ver_info[i].unmatch_count, 0, 1))
+ if (nstack_init_share_res() != 0)
{
- int retval =
- STRNCPY_S (app_ver_info[i].lib_version, NSTACK_VERSION_LEN,
- version, NSTACK_VERSION_LEN - 1);
- if (EOK != retval)
+ return -1;
+ }
+
+ if (-1 == nsep_create_memory())
{
- NSSOC_LOGERR ("STRNCPY_S failed]ret=%d", retval);
- return;
+ return -1;
}
- get_current_time (app_ver_info[i].first_time_stamp,
- LOG_TIME_STAMP_LEN);
- return;
+ if (-1 == ns_sync_sem_module_init(0, 0))
+ {
+ return -1;
}
}
- }
+
+ return 0;
}
-NSTACK_STATIC inline void
-check_main_version ()
+/**
+ * This should be called only once
+ */
+NSTACK_STATIC int nstack_init_mem(void)
{
- char my_version[NSTACK_VERSION_LEN] = { 0 };
- nsfw_mem_name stname = { NSFW_SHMEM, NSFW_PROC_MAIN, {NSTACK_VERSION_SHM} };
- g_nStackInfo.nstack_version = nsfw_mem_zone_lookup (&stname);
+ int ret = ns_fail;
+ int deploytype = nstack_get_deploy_type();
- if (NULL == g_nStackInfo.nstack_version)
+ /* record unmatched app version- */
+ /* check lib version match - */
+ if ((!check_main_version()) && (deploytype != NSTACK_MODEL_TYPE1)
+ && (deploytype != NSTACK_MODEL_TYPE_SIMPLE_STACK))
{
- NSSOC_LOGERR ("can not get nstack version.");
- return;
+ NSSOC_LOGERR("check version failed");
+ return ns_fail;
}
- if (EOK != STRCPY_S (my_version, sizeof (my_version), NSTACK_VERSION))
+ ret = nstack_init_shmem();
+ if (ns_success != ret)
{
- NSSOC_LOGERR ("STRCPY_S failed");
- return;
+ NSSOC_LOGERR("nstack init shmem fail");
+ return ns_fail;
}
- if (match_version (g_nStackInfo.nstack_version, my_version))
+ if (nstack_stack_module_init())
{
- return;
+ NSSOC_LOGERR("module init failed!");
+ goto INIT_NOT_DONE;
}
- NSSOC_LOGERR ("version not match]my version=%s, nStackMain_version=%s",
- my_version, g_nStackInfo.nstack_version);
-
- /* record unmatched app version in snapshot */
- char *unmatch_app_version =
- g_nStackInfo.nstack_version + NSTACK_VERSION_LEN;
-
- set_unmatch_version (my_version,
- (unmatch_ver_info_t *) unmatch_app_version);
-}
-
-int
-nstack_init_shmem ()
-{
-
- int deploytype = nstack_get_deploy_type ();
-
- if (deploytype != NSTACK_MODEL_TYPE1 && deploytype != NSTACK_MODEL_TYPE_SIMPLE_STACK )
+ if (ns_success != nstack_rd_sys())
{
- if (-1 == nsep_attach_memory ())
- {
- return -1;
+ NSSOC_LOGERR("nstack rd sys fail");
+ return ns_fail;
}
- if (nstack_attach_share_res () != 0)
+ /*init select mod */
+ if (FALSE == select_module_init())
{
- return -1;
- }
+ goto INIT_NOT_DONE;
}
- else
- {
- if (nsep_create_memory () != 0)
+ if (nstack_dmm_dfx_init(nstack_fd_deal))
{
- return -1;
+ goto INIT_NOT_DONE;
}
- if (nstack_init_share_res () != 0)
+ ret = ns_success;
+ /* The memory of the g_nStackInfo.lk_sockPool was not released in the exception */
+ return ret;
+ INIT_NOT_DONE:
+ ret = ns_fail;
+ return ret;
+
+}
+
+void nstack_fork_fd_local_lock_info(nstack_fd_local_lock_info_t * local_lock)
+{
+ if (local_lock->fd_ref.counter > 1) /* after fork, if fd ref > 1, need set it to 1 */
{
- return -1;
- }
+ local_lock->fd_ref.counter = 1;
}
- return 0;
+ dmm_spin_init(&local_lock->close_lock);
}
+void nstack_reset_fd_local_lock_info(nstack_fd_local_lock_info_t * local_lock)
+{
+ atomic_set(&local_lock->fd_ref, 0);
+ dmm_spin_init(&local_lock->close_lock);
+ local_lock->fd_status = FD_CLOSE;
+}
-/**
- * This should be called only once
- */
-NSTACK_STATIC int
-nstack_init_mem (void)
+dmm_rwlock_t *get_fork_lock()
+{
+ return &g_nStackInfo.fork_lock;
+}
+
+NSTACK_STATIC int nstack_init_fd_local_info()
{
- int ret = ns_fail;
- int deploytype = nstack_get_deploy_type ();
- /* record unmatched app version*/
- /* check lib version match - Begin */
- if (deploytype != NSTACK_MODEL_TYPE1 && deploytype != NSTACK_MODEL_TYPE_SIMPLE_STACK )
+ int iindex = 0;
+ int ret;
+ nstack_fd_Inf *fdInf;
+
+ g_nStackInfo.lk_sockPool = (nstack_fd_Inf *) malloc(NSTACK_KERNEL_FD_MAX * sizeof(nstack_fd_Inf)); /*malloc can be used */
+ if (!g_nStackInfo.lk_sockPool)
{
- check_main_version ();
+ NSSOC_LOGERR("malloc nstack_fd_lock_info failed");
+ return ns_fail;
}
-
- ret = nstack_init_shmem ();
- if (ns_success != ret)
+ ret =
+ memset_s(g_nStackInfo.lk_sockPool,
+ NSTACK_KERNEL_FD_MAX * sizeof(nstack_fd_Inf), 0,
+ NSTACK_KERNEL_FD_MAX * sizeof(nstack_fd_Inf));
+ if (EOK != ret)
{
- NSSOC_LOGERR ("nstack init shmem fail");
- return ns_fail;
+ NSSOC_LOGERR("memset error");
+ free(g_nStackInfo.lk_sockPool); /*free can be used */
+ g_nStackInfo.lk_sockPool = NULL;
+ return ns_fail;
}
- /*rd info sys*/
- ret = nstack_rd_sys();
- if (ns_success != ret)
- {
- NSSOC_LOGERR("nstack rd sys fail");
- return ns_fail;
- }
-
- (void)nstack_stack_module_init();
+ for (iindex = 0; iindex < (int) NSTACK_KERNEL_FD_MAX; iindex++)
+ {
+ fdInf = &g_nStackInfo.lk_sockPool[iindex];
+ nstack_reset_fd_inf(fdInf);
+#ifndef KERNEL_FD_SUPPORT
+ fdInf->fd = iindex;
+ if (iindex == NSTACK_KERNEL_FD_MAX - 1)
+ {
+ fdInf->nxtfd = -1;
+ }
+ else
+ {
+ fdInf->nxtfd = iindex + 1;
+ }
+#endif
+ }
- /*init select mod*/
- if(FALSE == select_module_init()){
- return ns_fail;
- }
- return ns_success;
- /* The memory of the g_nStackInfo.lk_sockPoll was not released in the exception*/
-}
+#ifndef KERNEL_FD_SUPPORT
+ g_nStackInfo.fdhead = 0;
+ dmm_spin_init((dmm_spinlock_t *) & g_nStackInfo.fdlock);
+#endif
-void
-nstack_fork_fd_local_lock_info (nstack_fd_local_lock_info_t * local_lock)
-{
- if (local_lock->fd_ref.counter > 1) /* after fork, if fd ref > 1, need set it to 1 */
+ if (-1 ==
+ nsep_init_info_sock_map(NSTACK_KERNEL_FD_MAX, NSTACK_MAX_MODULE_NUM))
{
- local_lock->fd_ref.counter = 1;
+ NSSOC_LOGERR("malloc epInfoPool fail");
+ if (g_nStackInfo.lk_sockPool)
+ {
+ free(g_nStackInfo.lk_sockPool);
+ g_nStackInfo.lk_sockPool = NULL;
+ }
+ return ns_fail;
}
- common_mem_spinlock_init (&local_lock->close_lock);
-}
-void
-nstack_reset_fd_local_lock_info (nstack_fd_local_lock_info_t * local_lock)
-{
- atomic_set (&local_lock->fd_ref, 0);
- common_mem_spinlock_init (&local_lock->close_lock);
- local_lock->fd_status = FD_CLOSE;
+ return ns_success;
}
-common_mem_rwlock_t *
-get_fork_lock ()
-{
- return &g_nStackInfo.fork_lock;
-}
+/*=========== get share config for app =============*/
-NSTACK_STATIC int
-nstack_init_fd_local_info ()
+NSTACK_STATIC inline int get_share_config()
{
- int iindex = 0;
- nstack_fd_Inf *fdInf;
+ static nsfw_mem_name g_cfg_mem_info =
+ { NSFW_SHMEM, NSFW_PROC_MAIN, NSTACK_SHARE_CONFIG };
+ int deploytype = nstack_get_deploy_type();
- g_nStackInfo.lk_sockPoll = (nstack_fd_Inf *) malloc (NSTACK_KERNEL_FD_MAX * sizeof (nstack_fd_Inf));
- if (!g_nStackInfo.lk_sockPoll)
+ if ((deploytype == NSTACK_MODEL_TYPE1)
+ || (deploytype == NSTACK_MODEL_TYPE_SIMPLE_STACK))
{
- NSSOC_LOGERR ("malloc nstack_fd_lock_info failed");
- return ns_fail;
+ get_default_base_cfg(1);
+ return 0;
}
- for (iindex = 0; iindex < (int) NSTACK_KERNEL_FD_MAX; iindex++)
+ mzone_handle base_cfg_mem = nsfw_mem_zone_lookup(&g_cfg_mem_info);
+ if (NULL == base_cfg_mem)
{
- fdInf = &g_nStackInfo.lk_sockPoll[iindex];
- nstack_reset_fdInf (fdInf);
+ NSSOC_LOGERR("get config share mem failed.");
+ return -1;
}
- if (-1 == nsep_init_infoSockMap ())
- {
- NSSOC_LOGERR ("malloc epInfoPool fail");
- if (g_nStackInfo.lk_sockPoll)
+ if (get_share_cfg_from_mem(base_cfg_mem) < 0)
{
- free (g_nStackInfo.lk_sockPoll);
- g_nStackInfo.lk_sockPoll = NULL;
- }
- return ns_fail;
+ NSSOC_LOGERR("get share config failed.");
+ return -1;
}
- return ns_success;
+ NSSOC_LOGDBG("get share config success.");
+ return 0;
}
-
-
/*design ensures that g_ksInfo is not write accessed at the same time.
-only read is done simultaneously with no chance of other thread writing it.
-so no protection needed.*/
-int
-nstack_stack_init (void)
-{ // Just need to create shared memory
- int ret;
+ only read is done simultaneously with no chance of other thread writing it.
+ so no protection needed.*/
+int nstack_stack_init(void)
+{
+ // Just need to create shared memory
+ int ret;
- ret = nstack_init_fd_local_info ();
- if (ret != ns_success)
+ /* log add start. */
+ ret = nstack_init_fd_local_info();
+ if (ret != ns_success)
{
- goto INIT_DONE;
+ goto INIT_DONE;
}
- if (ns_fail == nstack_init_mem ())
+ if (ns_fail == nstack_init_mem())
{
- ret = ns_fail;
- goto INIT_DONE;
+ ret = ns_fail;
+ goto INIT_DONE;
}
- if (SYS_HOST_INITIAL_PID == get_sys_pid ())
+ if (SYS_HOST_INITIAL_PID == get_sys_pid())
{
- ret = ns_fail;
- goto INIT_DONE;
+ ret = ns_fail;
+ goto INIT_DONE;
}
- ret = ns_success;
+ ret = ns_success;
+
+#ifdef KERNEL_FD_SUPPORT
+ nsep_get_manager()->checkEpollFD = nsfw_base_epoll_create(1);
+#endif
-INIT_DONE:
+ INIT_DONE:
- if (ns_success == ret)
+ if (ns_success == ret)
{
- NSSOC_LOGDBG ("success");
+ NSSOC_LOGDBG("success");
}
- else
+ else
{
- NSSOC_LOGERR ("fail");
+ NSSOC_LOGERR("fail");
}
- return ret;
+ return ret;
}
-int
-nstack_for_epoll_init ()
+int nstack_for_epoll_init()
{
- NSSOC_LOGINF ("fork] init begin..");
- if (g_nStackInfo.pid != 0 && g_nStackInfo.pid != getpid ())
+ NSSOC_LOGINF("fork] init begin..");
+ if (g_nStackInfo.pid != 0 && g_nStackInfo.pid != getpid())
{
- NSSOC_LOGINF ("fork]g_nStackInfo.pid=%u,getpid=%d", g_nStackInfo.pid,
- getpid ());
+ NSSOC_LOGINF("fork]g_nStackInfo.pid=%u,getpid=%d", g_nStackInfo.pid,
+ getpid());
- nstack_stack_module_init_child();
+ nstack_register_module_forchild();
}
- return 0;
+ return 0;
}
-
-
-void
-signal_handler_app (int s)
+void signal_handler_app(int s)
{
- NSPOL_LOGERR ("Received signal exiting.]s=%d", s);
- if (SIGHUP != s && SIGTERM != s)
+ NSPOL_LOGERR("Received signal exiting.]s=%d", s);
+ if (SIGHUP != s && SIGTERM != s)
{
- nstack_segment_error (s);
+ nstack_segment_error(s);
}
}
-void
-register_signal_handler_app ()
+void register_signal_handler_app()
{
- /* handle function should comply secure coding standard
- here mask signal that will use in sigwait() */
- sigset_t waitset, oset;
- if (0 != sigemptyset (&waitset))
+ /* signal handle function should comply secure coding standard
+ here mask signal that will use in sigwait() */
+ sigset_t waitset, oset;
+ if (0 != sigemptyset(&waitset))
{
- NSPOL_LOGERR ("sigemptyset failed");
+ NSPOL_LOGERR("sigemptyset failed");
}
- if (0 != sigaddset (&waitset, SIGRTMIN)) /* for timer */
+ if (0 != sigaddset(&waitset, SIGRTMIN)) /* for timer */
{
- NSPOL_LOGERR ("sigaddset failed");
+ NSPOL_LOGERR("sigaddset failed");
}
- if (0 != sigaddset (&waitset, SIGRTMIN + 2))
+ if (0 != sigaddset(&waitset, SIGRTMIN + 2))
{
- NSPOL_LOGERR ("sigaddset failed");
+ NSPOL_LOGERR("sigaddset failed");
}
- if (0 != pthread_sigmask (SIG_BLOCK, &waitset, &oset))
+ if (0 != pthread_sigmask(SIG_BLOCK, &waitset, &oset))
{
- NSPOL_LOGERR ("pthread_sigmask failed");
+ NSPOL_LOGERR("pthread_sigmask failed");
}
-
- struct sigaction s;
- s.sa_handler = signal_handler_app;
- if (0 != sigemptyset (&s.sa_mask))
+ struct sigaction s;
+ s.sa_handler = signal_handler_app;
+ if (0 != sigemptyset(&s.sa_mask))
{
- NSPOL_LOGERR ("sigemptyset failed.");
+ NSPOL_LOGERR("sigemptyset failed.");
}
- s.sa_flags = (int) SA_RESETHAND;
+ s.sa_flags = (int) SA_RESETHAND;
- /* register sig handler for more signals */
- if (sigaction (SIGINT, &s, NULL) != 0)
+ /*register sig handler for more signals [start] */
+ if (sigaction(SIGINT, &s, NULL) != 0)
{
- NSPOL_LOGERR ("Could not register SIGINT signal handler.");
+ NSPOL_LOGERR("Could not register SIGINT signal handler.");
}
- if (sigaction (SIGSEGV, &s, NULL) != 0)
+ if (sigaction(SIGSEGV, &s, NULL) != 0)
{
- NSPOL_LOGERR ("Could not register SIGSEGV signal handler.");
+ NSPOL_LOGERR("Could not register SIGSEGV signal handler.");
}
- if (sigaction (SIGPIPE, &s, NULL) != 0)
+ if (sigaction(SIGPIPE, &s, NULL) != 0)
{
- NSPOL_LOGERR ("Could not register SIGPIPE signal handler.");
+ NSPOL_LOGERR("Could not register SIGPIPE signal handler.");
}
- if (sigaction (SIGFPE, &s, NULL) != 0)
+ if (sigaction(SIGFPE, &s, NULL) != 0)
{
- NSPOL_LOGERR ("Could not register SIGFPE signal handler.");
+ NSPOL_LOGERR("Could not register SIGFPE signal handler.");
}
- if (sigaction (SIGABRT, &s, NULL) != 0)
+ if (sigaction(SIGABRT, &s, NULL) != 0)
{
- NSPOL_LOGERR ("Could not register SIGABRT signal handler.");
+ NSPOL_LOGERR("Could not register SIGABRT signal handler.");
}
- if (sigaction (SIGBUS, &s, NULL) != 0)
+ if (sigaction(SIGBUS, &s, NULL) != 0)
{
- NSPOL_LOGERR ("Could not register SIGBUS signal handler.");
+ NSPOL_LOGERR("Could not register SIGBUS signal handler.");
}
- /* register sig handler for more signals */
-
+ /*register sig handler for more signals [end] */
}
-int nstack_stack_module_load()
+/*app send its version info to daemon-stack*/
+/* when an app init finish, register its version to daemon-stack, daemon-stack will record it */
+void nstack_app_touch(void)
{
- /*check whether already inited*/
- NSTACK_INIT_STATE_CHECK_RET(g_nStackInfo.moduleload);
-
- /*lock for fork*/
- common_mem_rwlock_read_lock(get_fork_lock());
-
- if (pthread_mutex_lock(&g_nStackInfo.load_mutex)){
- NSSOC_LOGERR("nstack mutex lock fail");
- common_mem_rwlock_read_unlock(get_fork_lock());
- return -1;
+ int i;
+ for (i = 0; i < NSTACK_MAX_MODULE_NUM; i++)
+ {
+ if (nstack_fd_deal[i].app_touch)
+ {
+ nstack_fd_deal[i].app_touch();
+ }
}
+}
- NSTACK_INIT_STATE_CHECK_RET(g_nStackInfo.moduleload);
-
- NSTACK_THREAD_LOAD_SET();
-
+int nstack_stack_module_load()
+{
if (0 != nstack_module_parse())
{
- NSSOC_LOGERR("nstack stack module parse fail");
+ NSSOC_LOGERR("parse module config failed!");
goto LOAD_FAIL;
}
-
if (0 != nstack_register_module())
{
- NSSOC_LOGERR("nstack stack module parse fail");
+ NSSOC_LOGERR("register modules failed, fallback to default one");
goto LOAD_FAIL;
}
-
- NSTACK_THREAD_LOAD_UNSET();
- g_nStackInfo.moduleload = NSTACK_MODULE_SUCCESS;
- common_mem_rwlock_read_unlock(get_fork_lock());
- pthread_mutex_unlock(&g_nStackInfo.load_mutex);
return 0;
-LOAD_FAIL:
- g_nStackInfo.moduleload = NSTACK_MODULE_FAIL;
- NSTACK_THREAD_LOAD_UNSET();
- common_mem_rwlock_read_unlock(get_fork_lock());
- pthread_mutex_unlock(&g_nStackInfo.load_mutex);
+ LOAD_FAIL:
return -1;
}
-int
-nstack_app_init (void *ppara)
+int nstack_app_init(void *ppara)
{
- NSSOC_LOGINF("nstack app init begin");
+ NSSOC_LOGINF("nstack app init begin");
+
+ if (get_share_config() < 0)
+ {
+ NSSOC_LOGERR("get share config failed");
+ return ns_fail;
+ }
+
+ if (g_nStackInfo.pid != 0 && g_nStackInfo.pid != getpid())
+ {
+ NSSOC_LOGINF("fork]g_nStackInfo.pid=%u,getpid=%d", g_nStackInfo.pid,
+ getpid());
+ nstack_register_module_forchild();
+ }
+#ifdef KERNEL_FD_SUPPORT
+ long sysfdmax = 0;
+ sysfdmax = sysconf(_SC_OPEN_MAX);
+ NSSOC_LOGINF("sys max open files:%ld", sysfdmax);
+ if (sysfdmax > 0)
+ {
+ g_nStackInfo.ikernelfdmax =
+ (uint32_t) ((sysfdmax <=
+ ((NSTACK_MAX_SOCK_NUM / 8) *
+ 60)) ? sysfdmax : ((NSTACK_MAX_SOCK_NUM / 8) * 60));
+ }
+ else
+ {
+ NSSOC_LOGERR("get sys max open file fail");
+ g_nStackInfo.ikernelfdmax = NSTACK_MAX_SOCK_NUM;
+ }
+#endif
+ NSSOC_LOGINF("final max fd:%u", g_nStackInfo.ikernelfdmax);
- g_nStackInfo.ikernelfdmax = nstack_get_maxfd_id(nstack_get_fix_mid());
+ nstack_set_maxfd_id(nstack_get_linux_mid(), g_nStackInfo.ikernelfdmax);
- NSSOC_LOGINF("final max fd:%d", g_nStackInfo.ikernelfdmax);
+ g_nStackInfo.pid = getpid();
- g_nStackInfo.pid = getpid ();
+ /*if init already, just return success, if init fail before, just return err */
+ if (NSTACK_MODULE_INIT != g_nStackInfo.hasInited)
+ {
+ NSSOC_LOGINF("nstack app already init state:%d",
+ g_nStackInfo.hasInited);
+ return (NSTACK_MODULE_SUCCESS ==
+ g_nStackInfo.hasInited ? ns_success : ns_fail);
+ }
- /*if init already, just return success, if init fail before, just return err */
- if (NSTACK_MODULE_INIT != g_nStackInfo.hasInited)
+ if (0 != nstack_stack_init())
{
- NSSOC_LOGINF ("nstack app already init state:%d",
- g_nStackInfo.hasInited);
- return (NSTACK_MODULE_SUCCESS ==
- g_nStackInfo.hasInited ? ns_success : ns_fail);
+ NSSOC_LOGERR("nstack stack init failed");
+ g_nStackInfo.hasInited = NSTACK_MODULE_FAIL;
+ return ns_fail;
}
- if (0 != nstack_stack_init ())
+ nstack_app_touch(); /*app send its version info to daemon-stack */
+
+ g_nStackInfo.hasInited = NSTACK_MODULE_SUCCESS;
+ NSSOC_LOGINF("nstack app init success end");
+ return ns_success;
+}
+
+int mem_adpt_init(void *handle, nsfw_mem_attr * mem_ops,
+ nsfw_ring_ops * ring_ops)
+{
+ int i = 0;
+ nsfw_ring_ops *temp_ring_ops;
+
+ mem_ops[NSFW_SHMEM].stmemop = dlsym(handle, "g_shmem_ops");
+ mem_ops[NSFW_NSHMEM].stmemop = dlsym(handle, "g_nshmem_ops");
+ temp_ring_ops = dlsym(handle, "g_ring_ops_arry_spl");
+
+ for (i = 0; i < NSFW_MEM_TYPEMAX * NSFW_MPOOL_TYPEMAX; i++)
{
- NSSOC_LOGERR ("nstack stack init failed");
- g_nStackInfo.hasInited = NSTACK_MODULE_FAIL;
- return ns_fail;
+ ring_ops[i] = *temp_ring_ops;
+ temp_ring_ops++;
}
- g_nStackInfo.hasInited = NSTACK_MODULE_SUCCESS;
- NSSOC_LOGINF ("nstack app init success end");
- return ns_success;
+ NSFW_LOGINF("get shmem and nshmem and ring_ops ops var success.");
+
+ return 0;
}
/*nsocket call framework init fun*/
-int
-nstack_fw_init ()
+int nstack_fw_init()
+{
+ int ret = ns_fail;
+
+ if (NSTACK_MODULE_SUCCESS == g_nStackInfo.fwInited)
+ {
+ return ns_success;
+ }
+ if (NSTACK_MODULE_INIT == g_nStackInfo.fwInited)
+ {
+ g_nStackInfo.fwInited = NSTACK_MODULE_INITING;
+ nstack_log_init_app();
+ if (0 != nstack_stack_module_load())
+ {
+ NSSOC_LOGERR("nstack stack module load failed!");
+ g_nStackInfo.fwInited = NSTACK_MODULE_FAIL;
+ return -1;
+ }
+
+ dmm_read_lock(get_fork_lock());
+ updata_sys_pid();
+ u8 proc_type = NSFW_PROC_APP;
+ nsfw_mem_para stinfo = { 0 };
+ stinfo.iargsnum = 0;
+ stinfo.pargs = NULL;
+ stinfo.enflag = (fw_poc_type) proc_type;
+
+ nstack_framework_set_module_param(NSFW_MEM_MGR_MODULE,
+ (void *) &stinfo);
+ nstack_framework_set_module_param(NSFW_MGR_COM_MODULE,
+ (void *) ((long long) proc_type));
+ nstack_framework_set_module_param(NSFW_PS_MODULE,
+ (void *) ((long long) proc_type));
+ nstack_framework_set_module_param(NSFW_PS_MEM_MODULE,
+ (void *) ((long long) proc_type));
+ nstack_framework_set_module_param(NSFW_RECYCLE_MODULE,
+ (void *) ((long long) proc_type));
+
+ ret = nstack_framework_init();
+
+ if (ns_success == ret)
+ {
+ g_nStackInfo.fwInited = NSTACK_MODULE_SUCCESS;
+ }
+ else
+ {
+ g_nStackInfo.fwInited = NSTACK_MODULE_FAIL;
+ }
+ dmm_read_unlock(get_fork_lock());
+ }
+ return ret;
+}
+
+nstack_fd_local_lock_info_t *get_fd_local_lock_info(int fd)
{
+ if (!g_nStackInfo.lk_sockPool)
+ {
+ return NULL;
+ }
+
+ if (fd >= 0 && fd < (int) NSTACK_KERNEL_FD_MAX)
+ {
+ return &(g_nStackInfo.lk_sockPool[fd].local_lock);
+ }
- int ret = ns_fail;
-
- if (NSTACK_MODULE_SUCCESS == g_nStackInfo.fwInited)
- {
- return ns_success;
- }
-
- if (NSTACK_MODULE_INIT == g_nStackInfo.fwInited)
- {
- g_nStackInfo.fwInited = NSTACK_MODULE_INITING;
- nstack_log_init_app();
-
- if (0 != nstack_stack_module_load())
- {
- NSSOC_LOGERR("nstack stack module load fail");
- g_nStackInfo.fwInited = NSTACK_MODULE_FAIL;
- return -1;
- }
-
- common_mem_rwlock_read_lock (get_fork_lock ());
- update_sys_pid ();
- u8 proc_type = NSFW_PROC_APP;
- nsfw_mem_para stinfo = { 0 };
-
- int deploytype = nstack_get_deploy_type();
-
- if (deploytype == NSTACK_MODEL_TYPE1)
- {
- proc_type = NSFW_PROC_MAIN;
- }else if (deploytype == NSTACK_MODEL_TYPE_SIMPLE_STACK)
- {
- proc_type = NSFW_PROC_MAIN;
- app_mode=1;
- }
-
- stinfo.iargsnum = 0;
- stinfo.pargs = NULL;
- stinfo.enflag = (fw_poc_type)proc_type;
- nstack_framework_setModuleParam(NSFW_MEM_MGR_MODULE, (void*)&stinfo);
- nstack_framework_setModuleParam(NSFW_MGR_COM_MODULE, (void*) ((long long)proc_type));
- nstack_framework_setModuleParam(NSFW_TIMER_MODULE, (void*) ((long long)proc_type));
- nstack_framework_setModuleParam(NSFW_PS_MODULE, (void*) ((long long)proc_type));
- nstack_framework_setModuleParam(NSFW_PS_MEM_MODULE, (void*) ((long long)proc_type));
- nstack_framework_setModuleParam(NSFW_RECYCLE_MODULE, (void*) ((long long)proc_type));
- NSTACK_THREAD_LOAD_SET();
- ret = nstack_framework_init();
-
- if (ns_success == ret)
- {
- g_nStackInfo.fwInited = NSTACK_MODULE_SUCCESS;
- }
- else
- {
- g_nStackInfo.fwInited = NSTACK_MODULE_FAIL;
- }
- NSTACK_THREAD_LOAD_UNSET();
- common_mem_rwlock_read_unlock(get_fork_lock());
- }
-
- return ret;
+ return NULL;
}
-nstack_fd_local_lock_info_t *
-get_fd_local_lock_info (int fd)
+int nstack_dmm_dfx_init(nstack_proc_ops * ops)
{
- if (!g_nStackInfo.lk_sockPoll)
+ int i;
+ int ret;
+ nstack_dmm_stack_ops_t dfx_ops[NSTACK_MAX_MODULE_NUM];
+
+ if (!ops)
+ return ns_fail;
+
+ dmm_fd_dfx_pool = (nstack_fd_dfx_t *) malloc(NSTACK_KERNEL_FD_MAX * sizeof(nstack_fd_dfx_t)); /*malloc can be used */
+ if (!dmm_fd_dfx_pool)
+ {
+ NSSOC_LOGERR("malloc fd_dfx_pool failed");
+ free(g_nStackInfo.lk_sockPool);
+ g_nStackInfo.lk_sockPool = NULL;
+ return ns_fail;
+
+ }
+ else
{
- return NULL;
+ ret =
+ memset_s(dmm_fd_dfx_pool,
+ NSTACK_KERNEL_FD_MAX * sizeof(nstack_fd_dfx_t), 0,
+ NSTACK_KERNEL_FD_MAX * sizeof(nstack_fd_dfx_t));
+ if (EOK != ret)
+ {
+ NSSOC_LOGERR("memset failed");
+ free(g_nStackInfo.lk_sockPool);
+ g_nStackInfo.lk_sockPool = NULL;
+ free(dmm_fd_dfx_pool);
+ dmm_fd_dfx_pool = NULL;
+ return ns_fail;
+ }
}
- if (fd >= 0 && fd < (int) NSTACK_KERNEL_FD_MAX)
+ for (i = 0; i < NSTACK_MAX_MODULE_NUM; i++)
{
- return &(g_nStackInfo.lk_sockPoll[fd].local_lock);
+ dfx_ops[i].get_stack_tick = ops[i].get_stack_tick;
+ dfx_ops[i].update_dfx_data = ops[i].update_dfx_data;
+ dfx_ops[i].type = 0;
}
- return NULL;
+ return nstack_dfx_init_ops(dfx_ops);
}
diff --git a/src/nSocket/nstack/nstack.h b/src/nSocket/nstack/nstack.h
index 1ec88f0..d167899 100644
--- a/src/nSocket/nstack/nstack.h
+++ b/src/nSocket/nstack/nstack.h
@@ -28,9 +28,8 @@
#include "nstack_module.h"
#include "nstack_fd_mng.h"
-#include "nstack_types.h"
+#include "types.h"
#include "nstack_eventpoll.h"
-#include "common_mem_api.h"
#include "nstack_select.h"
#include <stdio.h>
@@ -38,11 +37,9 @@
#include <string.h>
#include <unistd.h>
#include "nstack_atomic.h"
-#include "common_mem_spinlock.h"
-#include "generic/common_mem_rwlock.h"
-
#include "nsfw_mem_api.h"
#include "nsfw_recycle_api.h"
+#include "dmm_rwlock.h"
#ifdef __cplusplus
/* *INDENT-OFF* */
@@ -52,32 +49,53 @@ extern "C"{
#define NSTACK_PIDINFO "hw_nstack_pidinfo"
+typedef struct _dict_
+{
+ int n;
+ ssize_t size;
+ char **key;
+ char **val;
+ unsigned *hash;
+} dict;
+/* release sockets when app exit */
+typedef struct
+{
+ uint32_t hostpid;
+ uint32_t pid;
+ uint64_t pidns;
+ atomic_t socketCount;
+} __attribute__ ((__packed__)) nStackPidInfo_t;
+
typedef enum
{
- NSTACK_MODULE_INIT,
- NSTACK_MODULE_INITING,
- NSTACK_MODULE_SUCCESS,
- NSTACK_MODULE_FAIL
+ NSTACK_MODULE_INIT,
+ NSTACK_MODULE_INITING,
+ NSTACK_MODULE_SUCCESS,
+ NSTACK_MODULE_FAIL
} nstack_module_state;
typedef struct
{
- nstack_module_state hasInited; /*nsocket inside init status */
- nstack_module_state fwInited; /*framework init status */
- nstack_module_state moduleload; /*framework init status */
- char pad1[2];
-
- pthread_mutex_t load_mutex;
- /* if a nstack_fd_Inf contains a valid linux kernel proFD, it will be allocated from this poll.
- * Total size of the poll is NSTACK_MAX_SOCK_NUM, index range is [0, NSTACK_MAX_SOCK_NUM).
- */
- nstack_fd_Inf *lk_sockPoll;
-
- common_mem_rwlock_t fork_lock; /* to ensure that there is no fd to create and close when fork */
- uint32_t pid;
- char *nstack_version;
- int checkEpollFD;
- uint32_t ikernelfdmax;
+ nstack_module_state hasInited; /*nsocket inside init status */
+ nstack_module_state fwInited; /*framework init status */
+ char pad1[2];
+
+ pthread_mutex_t init_mutex;
+ /* if a nstack_fd_Inf contains a valid linux kernel proFD, it will be allocated from this poll.
+ * Total size of the poll is NSTACK_MAX_SOCK_NUM, index range is [0, NSTACK_MAX_SOCK_NUM).
+ */
+ nstack_fd_Inf *lk_sockPool;
+
+#ifndef KERNEL_FD_SUPPORT
+ int fdhead;
+ dmm_spinlock_t fdlock;
+#endif
+
+ dmm_rwlock_t fork_lock; /* to ensure that there is no fd to create and close when fork. */
+ uint32_t pid;
+ char *nstack_version;
+ int checkEpollFD;
+ uint32_t ikernelfdmax;
} __attribute__ ((__packed__)) nStack_info_t;
#define ENV_NSTACK_RD_CFG_PATH "NSTACK_RD_CFG_PATH"
@@ -85,33 +103,25 @@ typedef struct
#define nstack_set_errno(no) errno = (no)
extern nStack_info_t g_nStackInfo;
-extern __thread int g_tloadflag;
#define NSTACK_KERNEL_FD_MAX (g_nStackInfo.ikernelfdmax)
-#define NSTACK_THREAD_LOAD_SET() (g_tloadflag = 1)
-#define NSTACK_THREAD_LOAD_UNSET() (g_tloadflag = 0)
-#define NSTACK_THREAD_LOADING() (g_tloadflag == 1)
#define nstack_each_protoFDSt(modInx, fdInf, st) \
- for ((modInx) = 0; ((modInx) < nstack_get_modNum() && ((st) = nstack_get_protoFdSt((fdInf), modInx))); (modInx)++)
-
-extern int nstack_timeval2msec (struct timeval *pTime, u64_t * msec);
-extern int nstack_current_time2msec (u64_t * msec);
-extern int nstack_sem_timedwait (sem_t * pSem, u64_t abs_timeout /*ms */ );
-extern int nstack_epoll_sem_timedwait (sem_t * pSem,
- u64_t abs_timeout /*ms */ ,
- long wait_time /*us */ );
-extern int nstack_app_init (void *ppara);
-extern int nstack_fw_init ();
-
-nstack_fd_local_lock_info_t *get_fd_local_lock_info (int fd);
-void nstack_fork_fd_local_lock_info (nstack_fd_local_lock_info_t *
+ for ((modInx) = 0; ((modInx) < nstack_get_module_num() && ((st) = nstack_get_proto_fd_st((fdInf), modInx))); (modInx)++)
+
+extern int nstack_timeval2msec(struct timeval *pTime, long *msec);
+extern int nstack_current_time2msec(long *msec);
+extern int nstack_sem_timedwait(sem_t * pSem, long abs_timeout /*ms */ ,
+ long *mcost);
+extern int nstack_app_init(void *ppara);
+extern int nstack_fw_init();
+
+nstack_fd_local_lock_info_t *get_fd_local_lock_info(int fd);
+void nstack_fork_fd_local_lock_info(nstack_fd_local_lock_info_t * local_lock);
+void nstack_reset_fd_local_lock_info(nstack_fd_local_lock_info_t *
local_lock);
-void nstack_reset_fd_local_lock_info (nstack_fd_local_lock_info_t *
- local_lock);
-common_mem_rwlock_t *get_fork_lock ();
-int nstack_for_epoll_init ();
-int nstack_stack_module_load ();
+dmm_rwlock_t *get_fork_lock();
+int nstack_for_epoll_init();
#ifdef __cplusplus
/* *INDENT-OFF* */
diff --git a/src/nSocket/nstack/nstack_fd_mng.c b/src/nSocket/nstack/nstack_fd_mng.c
index 86e045d..81d3818 100644
--- a/src/nSocket/nstack/nstack_fd_mng.c
+++ b/src/nSocket/nstack/nstack_fd_mng.c
@@ -25,216 +25,340 @@
#include "nstack_fd_mng.h"
#include "nstack_socket.h"
#include "nstack_securec.h"
-#include "nstack_sockops.h"
+#include "nsfw_base_linux_api.h"
+#include "nstack_dmm_dfx.h"
+
+static inline void nstack_reset_fd_dfx(int fd)
+{
+ if (dmm_fd_dfx_pool && fd >= 0 && (u32_t) fd < NSTACK_KERNEL_FD_MAX)
+ {
+ if (memset_s
+ (&dmm_fd_dfx_pool[fd], sizeof(nstack_fd_dfx_t), 0,
+ sizeof(nstack_fd_dfx_t)))
+ {
+ NSSOC_LOGERR("memset failed");
+ }
+ }
+ return;
+}
/* test_epollCtl_004_001_trial : both 32bit and 64bit members of 'ops' and 'conn'
need to reset, otherwise it will be invalid address in 32bit APP case */
-void
-nstack_reset_fdInf (nstack_fd_Inf * fdInf)
+/*no need to check null pointer here*/
+void nstack_reset_fd_inf(nstack_fd_Inf * fdInf)
{
- int loop;
-
- fdInf->isBound = NSTACK_FD_NOBIND;
- fdInf->rlfd = -1;
- fdInf->rmidx = -1;
- fdInf->nxtfd = -1;
- fdInf->fd = -1;
- fdInf->attr = 0;
- fdInf->ops = 0; /*operations of the fd, for save space we user opIdx here */
- fdInf->type = 0; /*the fd type like SOCK_STREAM|SOCK_NONBLOCK ... */
+ int loop;
+ fdInf->isBound = NSTACK_FD_NOBIND;
+ fdInf->rlfd = -1;
+ fdInf->rmidx = -1;
+#ifdef KERNEL_FD_SUPPORT
+ fdInf->nxtfd = -1;
+ fdInf->fd = -1;
+#else
+ fdInf->stat = NSTACK_FD_DISCARD;
+#endif
+ fdInf->attr = 0;
+ fdInf->ops = 0; /*opers of the fd, for save space we user opIdx here */
+ fdInf->type = 0; /*the fd type like SOCK_STREAM|SOCK_NONBLOCK ... */
- NSTACK_SET_FD_BLOCKING (fdInf);
- for (loop = 0; loop < NSTACK_MAX_MODULE_NUM; loop++)
+ NSTACK_SET_FD_BLOKING(fdInf);
+ for (loop = 0; loop < NSTACK_MAX_MODULE_NUM; loop++)
{
- fdInf->protoFD[loop].fd = -1;
- fdInf->protoFD[loop].errCode = 0;
- fdInf->protoFD[loop].pad = 0;
- fdInf->protoFD[loop].liststate = NSTACK_NO_LISTENING;
+ fdInf->protoFD[loop].fd = -1;
+ fdInf->protoFD[loop].errCode = 0;
+ fdInf->protoFD[loop].pad = 0;
+ fdInf->protoFD[loop].liststate = NSTACK_NO_LISENING;
}
- nstack_reset_fd_local_lock_info (&(fdInf->local_lock));
- return;
+ nstack_reset_fd_local_lock_info(&(fdInf->local_lock));
+ return;
}
-nstack_fd_Inf *
-nstack_fd2inf (int fd)
+nstack_fd_Inf *nstack_fd2inf(int fd)
{
- /*if nstack init not finished, just return null */
- if (NSTACK_MODULE_SUCCESS != g_nStackInfo.fwInited)
+ /*if nstack init not finished, just return null */
+ if (NSTACK_MODULE_SUCCESS != g_nStackInfo.fwInited)
{
- return NULL;
+ return NULL;
}
- if (nstack_is_nstack_sk (fd) && g_nStackInfo.lk_sockPoll)
+ if (nstack_is_nstack_sk(fd) && g_nStackInfo.lk_sockPool)
{
- return &(g_nStackInfo.lk_sockPoll[fd]);
+ return &(g_nStackInfo.lk_sockPool[fd]);
}
- return NULL;
+ return NULL;
}
-void
-nstack_set_protoFd (nstack_fd_Inf * fdInf, int modInx, int protofd)
+/*no need to check null pointer here*/
+void nstack_set_proto_fd(nstack_fd_Inf * fdInf, int modInx, int protofd)
{
- if (protofd < nstack_get_minfd_id (modInx)
- || protofd > nstack_get_maxfd_id (modInx))
+ if (protofd < nstack_get_minfd_id(modInx)
+ || protofd > nstack_get_maxfd_id(modInx))
{
- NSSOC_LOGERR ("module:%d protofd invalid] protofd=%d", modInx, protofd);
- return;
+ NSSOC_LOGDBG("module:%d protofd invalid] protofd=%d", modInx,
+ protofd);
+ return;
}
- nstack_get_protoFd (fdInf, modInx) = protofd;
+ nstack_get_proto_fd(fdInf, modInx) = protofd;
- nsep_set_infoProtoFD (fdInf->fd, modInx, protofd);
+ nsep_set_info_proto_fd(fdInf->fd, modInx, protofd);
- nssct_create (fdInf->fd, protofd, modInx);
- return;
+ nssct_create(fdInf->fd, protofd, modInx); /*do not need return value */
+ return;
}
/* pass app info to struct netconn */
-void
-nstack_set_app_info (nstack_fd_Inf * fdInf, int modInx)
+void nstack_set_app_info(nstack_fd_Inf * fdInf, int modInx)
{
- return;
+ if (nstack_fd_deal[modInx].set_app_info)
+ {
+ struct nsfw_app_info appinfo;
+
+ appinfo.hostpid = get_sys_pid();
+ appinfo.pid = getpid();
+ appinfo.ppid = getppid();
+ appinfo.tid = (int) syscall(SYS_gettid);
+ appinfo.nsocket_fd = fdInf->fd;
+ appinfo.sbr_fd = nstack_get_proto_fd(fdInf, modInx);
+
+ nstack_fd_deal[modInx].set_app_info(appinfo.sbr_fd,
+ (void *) &appinfo);
+ }
+
+ return;
}
-nstack_fd_Inf *
-nstack_lk_fd_alloc_with_kernel (int nfd)
+#ifdef KERNEL_FD_SUPPORT
+
+/* release sockets when app exit */
+nstack_fd_Inf *nstack_lk_fd_alloc_with_kernel(int nfd)
{
- nstack_fd_Inf *retInf = NULL;
+ nstack_fd_Inf *retInf = NULL;
- if ((nfd < 0) || (nfd >= (int) NSTACK_KERNEL_FD_MAX)
- || (!g_nStackInfo.lk_sockPoll))
+ if ((nfd < 0) || (nfd >= (int) NSTACK_KERNEL_FD_MAX)
+ || (!g_nStackInfo.lk_sockPool))
{
- NSSOC_LOGERR
- ("nfd < 0 or nfd>= NSTACK_KERNEL_FD_MAX, parameter not valid");
- return NULL;
+ NSSOC_LOGERR
+ ("nfd < 0 or nfd>= NSTACK_KERNEL_FD_MAX, parameter not valid");
+ return NULL;
}
- retInf = &g_nStackInfo.lk_sockPoll[nfd];
+ retInf = &g_nStackInfo.lk_sockPool[nfd];
- if (FD_OPEN == retInf->local_lock.fd_status)
+ if (FD_OPEN == retInf->local_lock.fd_status)
{
- NSSOC_LOGERR ("nstack_lk_fd_alloc_with_kernel fd:%d already create",
- nfd);
+ NSSOC_LOGERR("nstack_lk_fd_alloc_with_kernel fd:%d already create",
+ nfd);
}
- retInf->fd = nfd;
- if (-1 == nsep_alloc_infoWithSock (nfd))
+ retInf->fd = nfd;
+ if (-1 == nsep_alloc_info_with_sock(nfd))
{
- NSSOC_LOGERR ("Can't alloc epInfo for nfd=%d]", nfd);
- nstack_reset_fdInf (retInf);
- return NULL;
+ NSSOC_LOGERR("Can't alloc epInfo for nfd=%d]", nfd);
+ nstack_reset_fd_inf(retInf);
+ nstack_reset_fd_dfx(nfd);
+ return NULL;
}
- nstack_set_protoFd (retInf, g_nstack_modules.fix_mid, nfd);
- NSSOC_LOGDBG ("nfd=%d,retInf_fd=%d", nfd, retInf->fd);
- return retInf;
+ nstack_set_proto_fd(retInf, nstack_get_linux_mid(), nfd);
+ NSSOC_LOGDBG("nfd=%d,retInf_fd=%d", nfd, retInf->fd);
+ return retInf;
}
-
-int
-nstack_fd_free_with_kernel (nstack_fd_Inf * fdInf)
+#else
+nstack_fd_Inf *nstack_fd_alloc(void)
{
- int closeRet = 0;
- ns_int32 fd;
-
- if (!fdInf)
+ int tfd;
+ int LoopCount = 0;
+ if (!g_nStackInfo.lk_sockPool)
{
- NSSOC_LOGERR ("fdInf is NULL");
- return 0;
+ return NULL;
}
- fd = fdInf->protoFD[nstack_get_fix_mid ()].fd;
- nstack_reset_fdInf (fdInf);
- if (fd >= 0 && fd < (int) NSTACK_KERNEL_FD_MAX)
+ /*begin using SpinLock instead CAS, to avoid ABA problem */
+ dmm_spin_lock_with_pid((dmm_spinlock_t *) & g_nStackInfo.fdlock);
+ /* [Add memory alloc state] */
+ do
{
- NSTACK_CAL_FUN (nstack_fix_mid_ops (), close, (fd), closeRet);
- NSSOC_LOGINF ("close]fd=%d,ret=%d", fd, closeRet);
+ /* loop count should not be more than NSTACK_MAX_NON_LK_SOCK_NUM */
+ if (LoopCount > NSTACK_MAX_SOCK_NUM)
+ {
+ dmm_spin_unlock((dmm_spinlock_t *) (&g_nStackInfo.fdlock));
+ NSSOC_LOGERR("some err happen in alloc one fdInf");
+ return NULL;
+ }
+
+ /* add tfd rang check */
+ if (0 > (tfd = g_nStackInfo.fdhead) || tfd >= NSTACK_MAX_SOCK_NUM)
+ {
+ dmm_spin_unlock((dmm_spinlock_t *) (&g_nStackInfo.fdlock));
+ NSSOC_LOGERR("fdinfo was empty");
+ return NULL;
+ }
+ g_nStackInfo.fdhead = g_nStackInfo.lk_sockPool[tfd].nxtfd;
+ if (NSTACK_FD_DISCARD == g_nStackInfo.lk_sockPool[tfd].stat)
+ {
+ g_nStackInfo.lk_sockPool[tfd].stat = NSTACK_FD_INUSING;
+ break;
+ }
+ else
+ {
+ NSSOC_LOGWAR("Alloc one fdInf with stat %d [not correct]",
+ g_nStackInfo.lk_sockPool[tfd].stat);
+
+ }
+ LoopCount++;
}
- return closeRet;
+ while (1);
+ /* [Add memory alloc state] */
+ dmm_spin_unlock((dmm_spinlock_t *) (&g_nStackInfo.fdlock));
+ /*end using SpinLock instead CAS, to avoid ABA problem */
+
+ return &g_nStackInfo.lk_sockPool[tfd];
}
-void
-nstack_fork_init_parent (pid_t ppid)
+void nstack_fd_free(nstack_fd_Inf * fdInf)
{
- int fd;
- nstack_fd_Inf *fdInf = NULL;
- for (fd = 0; fd < (int) NSTACK_KERNEL_FD_MAX; fd++)
+ int nfd;
+
+ nfd = fdInf->fd;
+
+ if (nfd < NSTACK_MAX_SOCK_NUM && nfd > -1)
{
- fdInf = nstack_getValidInf (fd);
- if ((NULL != fdInf) && (!((u32_t) (fdInf->type) & SOCK_CLOEXEC)))
+ dmm_spin_lock_with_pid((dmm_spinlock_t *) & g_nStackInfo.fdlock);
+ if (NSTACK_FD_INUSING != fdInf->stat)
{
- int i;
- nstack_each_modInx (i)
- {
- if ((nstack_extern_deal (i).fork_parent_fd)
- && (fdInf->protoFD[i].fd >= 0))
- {
- nstack_extern_deal (i).fork_parent_fd (fdInf->protoFD[i].fd,
- ppid);
- }
- }
+ NSSOC_LOGERR("fdInf not alloced yet!");
+ dmm_spin_unlock((dmm_spinlock_t *) (&g_nStackInfo.fdlock));
+ return;
}
+ nstack_reset_fd_inf(fdInf);
+ nstack_reset_fd_dfx(nfd);
+ g_nStackInfo.lk_sockPool[nfd].nxtfd = g_nStackInfo.fdhead;
+ g_nStackInfo.fdhead = nfd;
+ dmm_spin_unlock((dmm_spinlock_t *) (&g_nStackInfo.fdlock));
}
+ return;
}
-void
-nstack_fork_init_child (pid_t ppid)
+nstack_fd_Inf *nstack_lk_fd_alloc_without_kernel()
{
- pid_t cpid = update_sys_pid ();
- NSSOC_LOGDBG ("parent_pid=%d, child_pid=%d", ppid, cpid);
+ nstack_fd_Inf *retInf = NULL;
+
+ retInf = nstack_fd_alloc();
+ if (!retInf)
+ {
+ NSSOC_LOGERR("nstack_lk_fd_alloc_without_kernel fail");
+ return NULL;
+ }
+
+ if (FD_OPEN == retInf->local_lock.fd_status)
+ {
+ NSSOC_LOGWAR
+ ("nstack_lk_fd_alloc_without_kernel fd:%d already create",
+ retInf->fd);
- nsfw_mgr_clr_fd_lock ();
- if (FALSE == nsfw_recycle_fork_init ())
+ }
+
+ if (-1 == nsep_alloc_info_with_sock(retInf->fd))
{
- NSFW_LOGERR ("init rec zone failed!]ppid=%d,cpid=%d", ppid, cpid);
+ NSSOC_LOGERR("Can't alloc epInfo for nfd=%d]", retInf->fd);
+ nstack_reset_fd_inf(retInf);
+ nstack_reset_fd_dfx(retInf->fd);
+ return NULL;
}
- int i;
- nstack_each_modInx (i)
- {
- if (nstack_extern_deal (i).fork_init_child)
- {
- nstack_extern_deal (i).fork_init_child (ppid, cpid);
- }
- }
+ NSSOC_LOGDBG("retInf->fd=%d", retInf->fd);
+ return retInf;
+}
+#endif
+
+/* should release resource for kernel */
+static int nstack_close_kernel_socket(int fd)
+{
+ return nsfw_base_close(fd);
+}
+
+int nstack_fd_free_with_kernel(nstack_fd_Inf * fdInf)
+{
+ int closeRet = 0;
+ ns_int32 fd;
+
+ if (!fdInf)
+ {
+ NSSOC_LOGERR("fdInf is NULL");
+ return 0;
+ }
+ fd = fdInf->protoFD[nstack_get_linux_mid()].fd;
+ nstack_reset_fd_dfx(fd);
+ nstack_reset_fd_inf(fdInf);
- int pos;
- nstack_fd_Inf *fdInf = NULL;
+ if (fd >= 0 && fd < (int) NSTACK_KERNEL_FD_MAX)
+ {
+ closeRet = nstack_close_kernel_socket(fd);
+ NSSOC_LOGINF("close]fd=%d,ret=%d", fd, closeRet);
+ }
+ return closeRet;
+}
- for (pos = 0; pos < (int) NSTACK_KERNEL_FD_MAX; pos++)
+void nstack_fork_fd(pid_t ppid)
+{
+ int i;
+ int fd;
+ nstack_fd_Inf *fdInf = NULL;
+ pid_t cpid = get_sys_pid();
+ for (fd = 0; fd < (int) NSTACK_KERNEL_FD_MAX; fd++)
{
- fdInf = nstack_getValidInf (pos);
- if (fdInf)
+ fdInf = nstack_get_valid_inf(fd);
+ if (fdInf)
{
- if (!((u32_t) (fdInf->type) & SOCK_CLOEXEC))
+ if (!((u32_t) (fdInf->type) & SOCK_CLOEXEC))
{
- nstack_fork_fd_local_lock_info (&fdInf->local_lock);
-
- nstack_each_modInx (i)
- {
- if ((nstack_extern_deal (i).fork_child_fd)
- && (fdInf->protoFD[i].fd >= 0))
- {
- nstack_extern_deal (i).fork_child_fd (fdInf->
- protoFD[i].fd, ppid,
- cpid);
- }
- }
+ nstack_fork_fd_local_lock_info(&fdInf->local_lock);
+ nstack_each_mod_inx(i)
+ {
+ if ((nstack_fd_deal[i].fork_fd)
+ && (fdInf->protoFD[i].fd >= 0))
+ {
+ nstack_fd_deal[i].fork_fd(fdInf->protoFD[i].fd, ppid,
+ cpid);
+ }
+ }
}
- else
+ else
{
- nstack_reset_fd_local_lock_info (&fdInf->local_lock);
- nsep_set_infoSockMap (pos, NULL);
- nstack_each_modInx (i)
- {
- if ((nstack_extern_deal (i).fork_free_fd)
- && (fdInf->protoFD[i].fd >= 0))
- {
- nstack_extern_deal (i).fork_free_fd (fdInf->protoFD[i].fd,
- ppid, cpid);
- }
- }
+ nstack_reset_fd_local_lock_info(&fdInf->local_lock);
+ nsep_set_info_sock_map(fd, NULL);
+ nstack_each_mod_inx(i)
+ {
+ if ((nstack_fd_deal[i].fork_free_fd)
+ && (fdInf->protoFD[i].fd >= 0))
+ {
+ nstack_fd_deal[i].fork_free_fd(fdInf->protoFD[i].fd);
+ }
+ }
}
}
}
}
+
+void nstack_fork_init_child(pid_t ppid)
+{
+ pid_t cpid = updata_sys_pid();
+ NSSOC_LOGDBG("parent_pid=%d, child_pid=%d", ppid, cpid);
+
+ nsfw_mgr_clr_fd_lock();
+ if (FALSE == nsfw_recycle_fork_init())
+ {
+ NSFW_LOGERR("init rec zone failed!]ppid=%d,cpid=%d", ppid, cpid);
+ }
+
+ int i;
+ nstack_each_mod_inx(i)
+ {
+ if (nstack_fd_deal[i].fork_init_child)
+ {
+ nstack_fd_deal[i].fork_init_child(ppid, cpid);
+ }
+ }
+}
diff --git a/src/nSocket/nstack/nstack_fd_mng.h b/src/nSocket/nstack/nstack_fd_mng.h
index cb25e8e..fcf7ed4 100644
--- a/src/nSocket/nstack/nstack_fd_mng.h
+++ b/src/nSocket/nstack/nstack_fd_mng.h
@@ -18,15 +18,17 @@
#define __NSTACK_FD_MNG_H__
#include <semaphore.h>
+#ifndef SPL_INSTANCE_H
#include "nstack_atomic.h"
+#endif
#include "types.h"
#include "nstack_module.h"
-#include "nstack_types.h"
-#include "nstack_eventpoll.h"
-#include "common_mem_spinlock.h"
-#include "common_mem_api.h"
-#include "common_func.h"
+
+#include "pid_common.h"
+#include "nsfw_maintain_api.h"
+#include "dmm_spinlock.h"
+#include "nstack_rd_priv.h"
#ifdef __cplusplus
/* *INDENT-OFF* */
@@ -34,12 +36,14 @@ extern "C" {
/* *INDENT-ON* */
#endif
+#define KERNEL_FD_SUPPORT 1
+
#define NSTACK_FDT_BLOCK_NOFFSET 10
#define NSTACK_FDT_CONVERT_FLAG 0x40000000 /* flag set means nstack socket */
-#define NSTACK_MAX_SOCK_NUM 8192
+#define NSTACK_MAX_SOCK_NUM MAX_SOCKET_NUM
-#define NSTACK_MAX_PID 65536 /* release sockets when app exit */
+#define NSTACK_MAX_PID 65536 /* release sockets when app exit Add */
#ifndef AF_INET
#define AF_INET 2
@@ -50,28 +54,37 @@ extern "C" {
/* setsockopt level type*/
enum
{
- NSTACK_SOCKOPT = 0xff02
+ NSTACK_SOCKOPT = 0xff02
};
/*setsockopt optname type*/
enum
{
- NSTACK_SEM_SLEEP = 0X001
+ NSTACK_SEM_SLEEP = 0X001,
+ MPTCP_SET_PRIO = 0X002,
+ NSTACK_RD_MODE = 0X003,
+};
+
+enum
+{
+ NSTACK_RD_OPT_KERNEL = 0,
+ NSTACK_RD_OPT_STACKPOOL = 1,
+ NSTACK_RD_OPT_MAX = 2,
};
#endif
#define nstack_is_nstack_sk(fd) ((fd) >= 0 && ((fd) < (int)NSTACK_KERNEL_FD_MAX))
typedef enum __nstack_fd_Stat
{
- NSTACK_FD_INUSING,
- NSTACK_FD_DISCARD
+ NSTACK_FD_INUSING,
+ NSTACK_FD_DISCARD
} nstack_fd_stat;
#define NSTACK_BIND_SUCCESS 0
#define NSTACK_LISTEN_SUCCESS 0
#define NSTACK_LISTEN_FAIL 1
#define NSTACK_BIND_FAIL 1
-#define NSTACK_LISTENING 1
-#define NSTACK_NO_LISTENING 0
+#define NSTACK_LISENING 1
+#define NSTACK_NO_LISENING 0
#define NSTACK_FD_INIT (0)
#define NSTACK_FD_OPEN (1)
@@ -80,81 +93,94 @@ typedef enum __nstack_fd_Stat
#define NSTACK_FD_NOBIND (0)
#define NSTACK_FD_BIND (1)
-/* release sockets when app exit */
-
typedef struct
{
- ns_int32 fd;
- ns_int32 errCode;
- union
- {
- struct result
+ ns_int32 fd;
+ ns_int32 errCode;
+ union
{
- ns_int32 brslt:8;
- ns_int32 lrslt:8;
- ns_int32 resrv:16;
- } rslt;
- ns_int32 pad;
- };
- ns_int32 liststate;
+ struct reslt
+ {
+ ns_int32 brslt:8;
+ ns_int32 lrslt:8;
+ ns_int32 resrv:16;
+ } rslt;
+ ns_int32 pad;
+ };
+ ns_int32 liststate;
} __attribute__ ((__packed__)) nstack_protoFD_t;
-#define NSTACK_FD_ATTR_NONBLOCKING 0x00000001
+#define NSTACK_FD_ATTR_NONBLOKING 0x00000001
#define NSTACK_FD_ATTR_EPOLL_SOCKET 0x00000002
#define NSTACK_FD_ATTR_LISTEN_SOCKET 0x00000004
-#define NSTACK_IS_FD_NONBLOCKING(inf) ((inf)->attr & NSTACK_FD_ATTR_NONBLOCKING)
-#define NSTACK_SET_FD_NONBLOCKING(inf) ((inf)->attr |= NSTACK_FD_ATTR_NONBLOCKING)
-#define NSTACK_SET_FD_BLOCKING(inf) ((inf)->attr &= (~NSTACK_FD_ATTR_NONBLOCKING))
+#define NSTACK_IS_FD_NONBLOKING(inf) ((inf)->attr & NSTACK_FD_ATTR_NONBLOKING)
+#define NSTACK_SET_FD_NONBLOKING(inf) ((inf)->attr |= NSTACK_FD_ATTR_NONBLOKING)
+#define NSTACK_SET_FD_BLOKING(inf) ((inf)->attr &= (~NSTACK_FD_ATTR_NONBLOKING))
#define NSTACK_IS_FD_EPOLL_SOCKET(inf) ((inf)->attr & NSTACK_FD_ATTR_EPOLL_SOCKET)
#define NSTACK_SET_FD_EPOLL_SOCKET(inf) ((inf)->attr |= NSTACK_FD_ATTR_EPOLL_SOCKET)
#define NSTACK_IS_FD_LISTEN_SOCKET(inf) ((inf)->attr & NSTACK_FD_ATTR_LISTEN_SOCKET)
#define NSTACK_SET_FD_LISTEN_SOCKET(inf) ((inf)->attr |= NSTACK_FD_ATTR_LISTEN_SOCKET)
+#define NSTACK_SET_FD_ATTR(inf, _attr) ((inf)->attr |= (_attr))
+#define NSTACK_IS_FD_ATTR(inf, _attr) ((inf)->attr &= (_attr))
+
typedef struct
{
- atomic_t fd_ref;
- common_mem_spinlock_t close_lock;
- volatile int fd_status;
+ atomic_t fd_ref;
+ dmm_spinlock_t close_lock;
+ volatile int fd_status;
} nstack_fd_local_lock_info_t;
+
/*
fd_ref:the number of times the fd is used, when it is 0, should release fd resource
close_lock:lock for close and epoll
fd_status:when created, it is FD_OPEN;after close, it is FD_CLOSING;after release_fd,
it is FD_CLOSE.
-- Begin */
+*/
typedef enum
{
- FD_CLOSE,
- FD_OPEN,
- FD_CLOSING
+ FD_CLOSE,
+ FD_OPEN,
+ FD_CLOSING
} FD_STATUS;
typedef enum
{
- NSTACK_STATE_CLOSE,
- NSTACK_STATE_OPEN,
- NSTACK_STATE_MAX
+ NSTACK_STATE_CLOSE,
+ NSTACK_STATE_OPEN,
+ NSTACK_STATE_MAX
} nstack_fdstate;
+
typedef struct __nstack_fd_Inf
{
- ns_int32 rlfd; /*the protocl stack returned fd */
- ns_int32 rmidx;
- ns_int32 nxtfd;
- nstack_socket_ops *ops; /*opers of the fd, for save space we user opIdx here */
- ns_int32 type; /*the fd type like SOCK_STREAM|SOCK_NONBLOCK ... */
- ns_int32 stat;
- ns_int32 fd;
- ns_uint32 attr; /* attribute like non-blocking, listen socket , epoll socket.... */
-
- nstack_protoFD_t protoFD[NSTACK_MAX_MODULE_NUM]; // where is protocol fd stores, index is module type
- nstack_fd_local_lock_info_t local_lock;
- /* if has bound to an addr */
- u8_t isBound; /*0:no call bind, 1: call bind */
- char last_reserve[2]; //reserve for update
+ ns_int32 rlfd; /*the protocl stack returned fd */
+ ns_int32 rmidx;
+ ns_int32 nxtfd;
+ nstack_socket_ops *ops; /*opers of the fd, for save space we user opIdx here */
+ ns_int32 type; /*the fd type like SOCK_STREAM|SOCK_NONBLOCK ... */
+ ns_int32 stat;
+ ns_int32 fd;
+ ns_uint32 attr; /* attribute like non-blocking, listen socket , epoll socket.... */
+ ns_int32 rd_opt; /* select stacks by setsockopt */
+
+ nstack_protoFD_t protoFD[NSTACK_MAX_MODULE_NUM]; // where is protocol fd stores, index is module type
+ nstack_fd_local_lock_info_t local_lock;
+ /* if has bound to an addr */
+ u8_t isBound; /*0:no call bind, 1: call bind */
+ rd_data_item rd_item; // associated matched rd item
+ char last_reserve[2]; //reserve for update
} nstack_fd_Inf;
+// TODO: DFX function
+/*
+typedef struct __ns_udp_route_info{
+ struct sockaddr_in iaddr;
+ int selectmod;
+}ns_udp_route_Inf;
+*/
+
#define nstack_set_router_protocol(_fdInf, _proto) \
(_fdInf)->rmidx = (_proto); \
nsep_set_infomdix((_fdInf)->fd, (_proto));\
@@ -162,26 +188,25 @@ typedef struct __nstack_fd_Inf
#define nstack_set_routed_fd(_fdInf, _protoFD) \
(_fdInf)->rlfd = (_protoFD); \
- nsep_set_infoRlfd((_fdInf)->fd, (_protoFD));\
+ nsep_set_info_rlfd((_fdInf)->fd, (_protoFD));\
-nstack_fd_Inf *nstack_fd2inf (int fd);
+nstack_fd_Inf *nstack_fd2inf(int fd);
-void nstack_reset_fdInf (nstack_fd_Inf * fdInf);
+void nstack_reset_fd_inf(nstack_fd_Inf * fdInf);
-static inline nstack_fd_Inf *
-nstack_getValidInf (int fd)
+static inline nstack_fd_Inf *nstack_get_valid_inf(int fd)
{
- nstack_fd_Inf *retInf = NULL;
- retInf = nstack_fd2inf (fd);
- if (NULL == retInf || FD_OPEN != retInf->local_lock.fd_status)
+ nstack_fd_Inf *retInf = NULL;
+ retInf = nstack_fd2inf(fd);
+ if (NULL == retInf || FD_OPEN != retInf->local_lock.fd_status)
{
- return NULL;
+ return NULL;
}
- return retInf;
+ return retInf;
}
-#define nstack_get_protoFd(fdInf, modInx) ((fdInf)->protoFD[modInx].fd)
+#define nstack_get_proto_fd(fdInf, modInx) ((fdInf)->protoFD[modInx].fd)
#define nstack_set_bind_ret(fdInf, modInx, ret) ((fdInf)->protoFD[modInx].rslt.brslt = ret)
#define nstack_set_listen_ret(fdInf, modInx, ret) ((fdInf)->protoFD[modInx].rslt.lrslt = ret)
#define nstack_set_ret(fdInf, modInx, ret) ((fdInf)->protoFD[modInx].pad = ret)
@@ -189,17 +214,17 @@ nstack_getValidInf (int fd)
#define nstack_get_listen_state(fdInf, modInx) ((fdInf)->protoFD[modInx].liststate)
#define nstack_get_listen_ret(fdInf, modInx) ((fdInf)->protoFD[modInx].rslt.lrslt)
#define nstack_get_bind_ret(fdInf, modInx) ((fdInf)->protoFD[modInx].rslt.brslt)
-#define nstack_get_protoFdSt(fdInf, modInx) (&(fdInf)->protoFD[modInx])
-void nstack_set_protoFd (nstack_fd_Inf * fdInf, int modInx, int protofd);
-void nstack_set_app_info (nstack_fd_Inf * fdInf, int modInx);
-
-int nstack_fd_free_with_kernel (nstack_fd_Inf * fdInf);
-int nstack_fd_free_without_kernel (nstack_fd_Inf * fdInf, int ref);
-extern nstack_fd_Inf *nstack_lk_fd_alloc_with_kernel (int nfd); //alloc a nstack socket that include kernel fd
-extern void nstack_fd_free (nstack_fd_Inf * fdInf);
-
-void nstack_fork_init_child (pid_t ppid);
-void nstack_fork_init_parent (pid_t ppid);
+#define nstack_get_proto_fd_st(fdInf, modInx) (&(fdInf)->protoFD[modInx])
+void nstack_set_proto_fd(nstack_fd_Inf * fdInf, int modInx, int protofd);
+void nstack_set_app_info(nstack_fd_Inf * fdInf, int modInx);
+int nstack_fd_free_with_kernel(nstack_fd_Inf * fdInf);
+int nstack_fd_free_without_kernel(nstack_fd_Inf * fdInf, int ref);
+extern nstack_fd_Inf *nstack_lk_fd_alloc_with_kernel(int nfd); //alloc a nstack socket that include kernel fd
+extern nstack_fd_Inf *nstack_lk_fd_alloc_without_kernel();
+extern void nstack_fd_free(nstack_fd_Inf * fdInf);
+
+void nstack_fork_init_child(pid_t ppid);
+void nstack_fork_fd(pid_t ppid);
#ifdef __cplusplus
/* *INDENT-OFF* */
diff --git a/src/nSocket/nstack/nstack_info_parse.c b/src/nSocket/nstack/nstack_info_parse.c
index 8b2d62f..2f74cf6 100644
--- a/src/nSocket/nstack/nstack_info_parse.c
+++ b/src/nSocket/nstack/nstack_info_parse.c
@@ -28,6 +28,8 @@
#include "json.h"
#include "nsfw_base_linux_api.h"
#include "nstack_info_parse.h"
+#include "nstack_rd_api.h"
+#include "nstack_rd_priv.h"
/*get string value*/
#define NSTACK_JSON_PARSE_STRING(obj, name, lent, result, index) do { \
@@ -41,7 +43,7 @@
NSSOC_LOGERR("can't get value from %s index:%d", name, (index)); \
goto RETURN_ERROR; \
} \
- (void)STRNCPY_S((result), (lent), temp_value1, (lent)); \
+ (void)strncpy_s((result), (lent), temp_value1, (lent)-1); \
} \
else \
{ \
@@ -66,7 +68,7 @@
} \
else \
{ \
- if (strcmp(name, "deploytype") == 0 || strcmp(name, "stackid") == 0) \
+ if (strcmp(name, "deploytype") == 0 || strcmp(name, "stackid") == 0) \
{ \
NSSOC_LOGERR("can't get obj from %s index:%d", name, (index)); \
} \
@@ -77,449 +79,561 @@
} \
} while ( 0 );
-/*parse module cfg*/
-int
-nstack_parse_module_cfg_json (char *param)
+/* load default config */
+static int load_default_module()
{
- struct json_object *obj = json_tokener_parse (param);
- struct json_object *module_list_obj = NULL;
- struct json_object *module_obj = NULL;
- struct json_object *temp_obj = NULL;
- const char *default_name = NULL;
- const char *temp_value = NULL;
- int module_num = 0;
- int ret = NSTACK_RETURN_FAIL;
- int index = 0;
- int icnt = 0;
- int ret_val;
+ if (EOK !=
+ strcpy_s(g_nstack_module_desc[0].modName, NSTACK_MODULE_NAME_MAX,
+ RD_KERNEL_NAME))
+ {
+ NSSOC_LOGERR("strcpy_s failed!");
+ return NSTACK_RETURN_FAIL;
+ }
+ if (EOK !=
+ strcpy_s(g_nstack_module_desc[0].register_fn_name,
+ NSTACK_MODULE_NAME_MAX, "kernel_stack_register"))
+ {
+ NSSOC_LOGERR("strcpy_s failed!");
+ return NSTACK_RETURN_FAIL;
+ }
+ if (EOK !=
+ strcpy_s(g_nstack_module_desc[0].libPath, NSTACK_MODULE_NAME_MAX,
+ "./"))
+ {
+ NSSOC_LOGERR("strcpy_s failed!");
+ return NSTACK_RETURN_FAIL;
+ }
+ g_nstack_module_desc[0].deploytype = NSTACK_MODEL_TYPE1;
+ g_nstack_module_desc[0].libtype = NSTACK_LIB_LOAD_STATIC;
+ g_nstack_module_desc[0].default_stack = 1;
+ g_nstack_module_desc[0].priority = 0;
+ g_nstack_module_desc[0].maxfdid = 8191;
+ g_nstack_module_desc[0].minfdid = 0;
+ g_nstack_module_desc[0].modInx = 0;
+
+ if (EOK !=
+ strcpy_s(g_nstack_module_desc[1].modName, NSTACK_MODULE_NAME_MAX,
+ "stackpool"))
+ {
+ NSSOC_LOGERR("strcpy_s failed!");
+ return NSTACK_RETURN_FAIL;
+ }
+ if (EOK !=
+ strcpy_s(g_nstack_module_desc[1].register_fn_name,
+ NSTACK_MODULE_NAME_MAX, "nstack_stack_register"))
+ {
+ NSSOC_LOGERR("strcpy_s failed!");
+ return NSTACK_RETURN_FAIL;
+ }
+ if (EOK !=
+ strcpy_s(g_nstack_module_desc[1].libPath, NSTACK_MODULE_NAME_MAX,
+ "libnstack.so"))
+ {
+ NSSOC_LOGERR("strcpy_s failed!");
+ return NSTACK_RETURN_FAIL;
+ }
+ g_nstack_module_desc[1].deploytype = NSTACK_MODEL_TYPE3;
+ g_nstack_module_desc[1].libtype = NSTACK_LIB_LOAD_DYN;
+ g_nstack_module_desc[1].default_stack = 0;
+ g_nstack_module_desc[1].priority = 0;
+ g_nstack_module_desc[1].maxfdid = 8192;
+ g_nstack_module_desc[1].minfdid = 0;
+ g_nstack_module_desc[1].modInx = 1;
+
+ g_module_num = 2;
+ return NSTACK_RETURN_OK;
+}
- if (!obj)
+/*parse module cfg*/
+static int parse_module_cfg(char *param)
+{
+ struct json_object *obj = json_tokener_parse(param);
+ struct json_object *module_list_obj = NULL;
+ struct json_object *module_obj = NULL;
+ struct json_object *temp_obj = NULL;
+ const char *default_name = NULL;
+ const char *temp_value = NULL;
+ int module_num = 0;
+ int ret = NSTACK_RETURN_FAIL;
+ int index = 0; /* local variable:index */
+ int icnt = 0;
+
+ if (!obj)
{
- NSSOC_LOGERR ("json parse fail");
- return NSTACK_RETURN_FAIL;
+ NSSOC_LOGERR("json parse fail");
+ return NSTACK_RETURN_FAIL;
}
- (void) MEMSET_S (&g_nstack_module_desc[0], sizeof (g_nstack_module_desc), 0,
- sizeof (g_nstack_module_desc));
+ (void) memset_s(&g_nstack_module_desc[0], sizeof(g_nstack_module_desc),
+ 0, sizeof(g_nstack_module_desc));
- (void) json_object_object_get_ex (obj, "default_stack_name", &temp_obj);
- if (!temp_obj)
+ (void) json_object_object_get_ex(obj, "default_stack_name", &temp_obj);
+ if (!temp_obj)
{
- NSSOC_LOGERR ("can't get module_list");
- goto RETURN_ERROR;
+ NSSOC_LOGERR("can't get module_list");
+ goto RETURN_ERROR;
}
- default_name = json_object_get_string (temp_obj);
+ default_name = json_object_get_string(temp_obj);
- (void) json_object_object_get_ex (obj, "module_list", &module_list_obj);
- if (!module_list_obj)
+ (void) json_object_object_get_ex(obj, "module_list", &module_list_obj);
+ if (!module_list_obj)
{
- NSSOC_LOGERR ("can't get module_list");
- goto RETURN_ERROR;
+ NSSOC_LOGERR("can't get module_list");
+ goto RETURN_ERROR;
}
- module_num = json_object_array_length (module_list_obj);
- if ((module_num <= 0) || (module_num >= NSTACK_MAX_MODULE_NUM))
+ module_num = json_object_array_length(module_list_obj);
+ if ((module_num <= 0) || (module_num >= NSTACK_MAX_MODULE_NUM))
{
- NSSOC_LOGERR ("get module number:%d fail", module_num);
- goto RETURN_ERROR;
+ NSSOC_LOGERR("get module number:%d fail", module_num);
+ goto RETURN_ERROR;
}
- for (index = 0; index < module_num; index++)
+ for (index = 0; index < module_num; index++)
{
- module_obj = json_object_array_get_idx (module_list_obj, index);
- if (module_obj)
+ module_obj = json_object_array_get_idx(module_list_obj, index);
+ if (module_obj)
{
- NSTACK_JSON_PARSE_STRING (module_obj, "stack_name", MODULE_NAME_MAX,
- &(g_nstack_module_desc[icnt].modName[0]),
- index);
- STRCPY_S (&(g_nstack_module_desc[icnt].register_fn_name[0]),
- sizeof (&
- (g_nstack_module_desc[icnt].register_fn_name[0])),
- &(g_nstack_module_desc[icnt].modName[0]));
- ret_val =
- STRCAT_S (&(g_nstack_module_desc[icnt].register_fn_name[0]),
- sizeof (&
- (g_nstack_module_desc[icnt].register_fn_name
- [0])), "_stack_register");
- if (EOK != ret_val)
+ NSTACK_JSON_PARSE_STRING(module_obj, "stack_name",
+ NSTACK_MODULE_NAME_MAX,
+ &(g_nstack_module_desc[icnt].modName
+ [0]), index);
+ NSTACK_JSON_PARSE_STRING(module_obj, "function_name",
+ NSTACK_MODULE_NAME_MAX,
+ &(g_nstack_module_desc
+ [icnt].register_fn_name[0]), index);
+ NSTACK_JSON_PARSE_STRING(module_obj, "libname",
+ NSTACK_MODULE_NAME_MAX,
+ &(g_nstack_module_desc[icnt].libPath
+ [0]), index);
+
+ (void) json_object_object_get_ex(module_obj, "loadtype",
+ &temp_obj);
+ if (temp_obj)
{
- NSFW_LOGERR ("register_fn_name STRCAT_S failed]ret_val=%d",
- ret_val);
- return -1;
- }
- NSTACK_JSON_PARSE_STRING (module_obj, "libname", MODULE_NAME_MAX,
- &(g_nstack_module_desc[icnt].libPath[0]),
- index);
-
- (void) json_object_object_get_ex (module_obj, "loadtype",
- &temp_obj);
- if (temp_obj)
- {
- temp_value = json_object_get_string (temp_obj);
- if (strcmp (temp_value, "static") == 0)
+ temp_value = json_object_get_string(temp_obj);
+ if (temp_value && (strcmp(temp_value, "static") == 0))
{
- g_nstack_module_desc[icnt].libtype = NSTACK_LIB_LOAD_STATIC;
+ g_nstack_module_desc[icnt].libtype =
+ NSTACK_LIB_LOAD_STATIC;
}
- else
+ else
{
- g_nstack_module_desc[icnt].libtype = NSTACK_LIB_LOAD_DYN;
+ g_nstack_module_desc[icnt].libtype = NSTACK_LIB_LOAD_DYN;
}
}
- else
+ else
{
- if (strcmp (g_nstack_module_desc[icnt].modName, "kernel") == 0)
+ if (strcmp
+ (g_nstack_module_desc[icnt].modName, RD_KERNEL_NAME) == 0)
{
- g_nstack_module_desc[icnt].libtype = NSTACK_LIB_LOAD_STATIC;
+ g_nstack_module_desc[icnt].libtype =
+ NSTACK_LIB_LOAD_STATIC;
}
- else
+ else
{
- g_nstack_module_desc[icnt].libtype = NSTACK_LIB_LOAD_DYN;
+ g_nstack_module_desc[icnt].libtype = NSTACK_LIB_LOAD_DYN;
}
- NSSOC_LOGWAR ("can't get the value of loadtype for module:%s",
- g_nstack_module_desc[icnt].modName);
+ NSSOC_LOGWAR("can't get the value of loadtype for module:%s",
+ g_nstack_module_desc[icnt].modName);
}
- NSSBR_LOGINF ("load type of %d has been chosen",
- g_nstack_module_desc[icnt].libtype);
- NSTACK_JSON_PARSE_INT (module_obj, "deploytype", MODULE_NAME_MAX,
- g_nstack_module_desc[icnt].deploytype,
- index);
- NSTACK_JSON_PARSE_INT (module_obj, "maxfd", MODULE_NAME_MAX,
- g_nstack_module_desc[icnt].maxfdid, index);
- if (g_nstack_module_desc[icnt].maxfdid == 0)
+ NSTACK_JSON_PARSE_INT(module_obj, "deploytype",
+ NSTACK_MODULE_NAME_MAX,
+ g_nstack_module_desc[icnt].deploytype,
+ index);
+ g_nstack_module_desc[icnt].maxfdid = 8191;
+ NSTACK_JSON_PARSE_INT(module_obj, "maxfd",
+ NSTACK_MODULE_NAME_MAX,
+ g_nstack_module_desc[icnt].maxfdid, index);
+ g_nstack_module_desc[icnt].minfdid = 0;
+ NSTACK_JSON_PARSE_INT(module_obj, "minfd",
+ NSTACK_MODULE_NAME_MAX,
+ g_nstack_module_desc[icnt].minfdid, index);
+ NSTACK_JSON_PARSE_INT(module_obj, "priorty",
+ NSTACK_MODULE_NAME_MAX,
+ g_nstack_module_desc[icnt].priority, index);
+ NSTACK_JSON_PARSE_INT(module_obj, "stackid",
+ NSTACK_MODULE_NAME_MAX,
+ g_nstack_module_desc[icnt].modInx, index);
+ if (icnt != g_nstack_module_desc[icnt].modInx)
{
- g_nstack_module_desc[icnt].maxfdid = 1024;
+ NSSOC_LOGERR
+ ("stackid mismatch, expected:%d, actually given:%d", icnt,
+ g_nstack_module_desc[icnt].modInx);
+ goto RETURN_ERROR;
}
- NSTACK_JSON_PARSE_INT (module_obj, "minfd", MODULE_NAME_MAX,
- g_nstack_module_desc[icnt].minfdid, index);
- NSTACK_JSON_PARSE_INT (module_obj, "priorty", MODULE_NAME_MAX,
- g_nstack_module_desc[icnt].priority, index);
- NSTACK_JSON_PARSE_INT (module_obj, "stackid", MODULE_NAME_MAX,
- g_nstack_module_desc[icnt].modInx, index);
- if (0 == strcmp (g_nstack_module_desc[icnt].modName, default_name))
+ if (0 == strcmp(g_nstack_module_desc[icnt].modName, default_name))
{
- g_nstack_module_desc[icnt].default_stack = 1;
+ g_nstack_module_desc[icnt].default_stack = 1;
}
- icnt++;
- g_module_num = icnt;
+ icnt++;
+ g_module_num = icnt;
}
}
- ret = NSTACK_RETURN_OK;
+ ret = NSTACK_RETURN_OK;
-RETURN_ERROR:
- json_object_put (obj);
- return ret;
+ RETURN_ERROR:
+ json_object_put(obj);
+ return ret;
}
-/*parse module cfg*/
-int
-nstack_parse_rd_cfg_json (char *param, rd_route_data ** data, int *num)
+static int rd_do_parse(struct json_object *obj, const char *name, void *table)
{
- struct json_object *obj = json_tokener_parse (param);
- struct json_object *ip_list_obj = NULL;
- struct json_object *proto_list_obj = NULL;
- struct json_object *module_obj = NULL;
- struct json_object *temp_obj = NULL;
- rd_route_data *rdtemp = NULL;
- rd_route_data *rddata = NULL;
- const char *sub = NULL;
- const char *temp_value = NULL;
- int ip_list_num = 0;
- int proto_list_num = 0;
- int totalnum = 0;
- int tlen = 0;
- int index = 0;
- int icnt = 0;
- char ipadd[32] = { 0 };
-
- if (!obj)
+ struct json_object *ip = NULL;
+ struct json_object *proto = NULL;
+ struct json_object *type = NULL;
+ struct json_object *temp = NULL;
+ struct json_object *o = NULL;
+ int index = 0; /* local variable:index */
+ int ip_list_num = 0, type_list_num = 0, proto_list_num = 0;
+ const char *ip_addr;
+ char *sub = NULL;
+ char addr[32];
+
+ rd_ip_data ip_data;
+ rd_type_data type_data;
+ rd_proto_data proto_data;
+
+ (void) json_object_object_get_ex(obj, "ip_route", &ip);
+ (void) json_object_object_get_ex(obj, "protocol_route", &proto);
+ (void) json_object_object_get_ex(obj, "type_route", &type);
+ if (!ip && !proto && !type)
{
- NSSOC_LOGERR ("json parse fail");
- return NSTACK_RETURN_FAIL;
+ NSSOC_LOGERR("Error: no rd policies found!");
+ return -1;
}
- (void) json_object_object_get_ex (obj, "ip_route", &ip_list_obj);
- if (!ip_list_obj)
+ if (ip)
+ {
+ ip_list_num = json_object_array_length(ip);
+ }
+ if (type)
{
- NSSOC_LOGERR ("can't get module_list");
- goto RETURN_ERROR;
+ type_list_num = json_object_array_length(type);
}
- (void) json_object_object_get_ex (obj, "prot_route", &proto_list_obj);
- if (!proto_list_obj)
+ if (proto)
{
- NSSOC_LOGERR ("can't get module_list");
- goto RETURN_ERROR;
+ proto_list_num = json_object_array_length(proto);
}
- ip_list_num = json_object_array_length (ip_list_obj);
- proto_list_num = json_object_array_length (proto_list_obj);
- totalnum = ip_list_num + proto_list_num;
- if (totalnum > NSTACK_RD_MAX)
+ for (index = 0; index < ip_list_num; index++)
{
- NSSOC_LOGERR ("rd num is too more, and return fail");
- goto RETURN_ERROR;
+ temp = json_object_array_get_idx(ip, index);
+ if (temp)
+ {
+ ip_addr = json_object_get_string(temp);
+ if (!ip_addr)
+ {
+ NSSOC_LOGERR("cannot get ip address at index:%d", index);
+ return -1;
+ }
+ sub = strstr(ip_addr, "/");
+ if (!sub)
+ {
+ NSSOC_LOGERR("cannot get masklen from %s", ip_addr);
+ return -1;
+ }
+ if (EOK != memset_s(addr, sizeof(addr), 0, sizeof(addr)))
+ {
+ NSSOC_LOGERR("memset_s failed!");
+ return -1;
+ }
+ if (EOK !=
+ strncpy_s(addr, sizeof(addr), ip_addr,
+ (size_t) (sub - ip_addr)))
+ {
+ NSSOC_LOGERR("strncpy_s failed!");
+ return -1;
+ }
+ ip_data.addr = inet_addr(addr);
+ ip_data.masklen = atoi(sub + 1); /* not deprecated */
+ ip_data.resev[0] = 0;
+ ip_data.resev[1] = 0;
+ nstack_rd_ip_node_insert(name, &ip_data, table);
+ }
}
- tlen = sizeof (rd_route_data) * totalnum;
- rdtemp = (rd_route_data *) malloc (tlen);
- if (!rdtemp)
+
+ for (index = 0; index < type_list_num; index++)
{
- NSSOC_LOGERR ("malloc mem fail");
- goto RETURN_ERROR;
+ temp = json_object_array_get_idx(type, index);
+ if (temp)
+ {
+ (void) json_object_object_get_ex(temp, "value", &o);
+ if (!o)
+ {
+ NSSOC_LOGERR("no value specified of type_route index:%d",
+ index);
+ return -1;
+ }
+ type_data.value = json_object_get_int(o);
+ o = NULL;
+ (void) json_object_object_get_ex(temp, "attr", &o);
+ if (!o)
+ {
+ NSSOC_LOGERR("no attr specified of type_route index:%d",
+ index);
+ return -1;
+ }
+ type_data.attr = json_object_get_int(o);
+ type_data.reserved[0] = 0;
+ type_data.reserved[1] = 0;
+ type_data.reserved[2] = 0;
+ type_data.reserved[3] = 0;
+ nstack_rd_type_node_insert(name, &type_data, table);
+ o = NULL;
+ }
}
- MEMSET_S (rdtemp, tlen, 0, tlen);
- for (index = 0; index < ip_list_num; index++)
+
+ for (index = 0; index < proto_list_num; index++)
{
- module_obj = json_object_array_get_idx (ip_list_obj, index);
- if (module_obj)
+ temp = json_object_array_get_idx(proto, index);
+ if (temp)
{
- rddata = rdtemp + icnt;
- rddata->type = RD_DATA_TYPE_IP;
- (void) json_object_object_get_ex (module_obj, "stack_name",
- &temp_obj);
- if (temp_obj)
+ (void) json_object_object_get_ex(temp, "value", &o);
+ if (!o)
{
- temp_value = json_object_get_string (temp_obj);
- if (!temp_value)
- {
- NSSOC_LOGERR ("can't get value from subnet index:%d",
- index);
- goto RETURN_ERROR;
- }
- (void) STRNCPY_S (rddata->stack_name, RD_PLANE_NAMELEN,
- temp_value, RD_PLANE_NAMELEN);
+ NSSOC_LOGERR("no value specified of protocol_route index:%d",
+ index);
+ return -1;
}
- (void) json_object_object_get_ex (module_obj, "subnet", &temp_obj);
- if (temp_obj)
+ proto_data.value = json_object_get_int(o);
+ o = NULL;
+ (void) json_object_object_get_ex(temp, "attr", &o);
+ if (!o)
{
- temp_value = json_object_get_string (temp_obj);
- if (!temp_value)
- {
- NSSOC_LOGERR ("can't get value from subnet index:%d",
- index);
- goto RETURN_ERROR;
- }
- sub = strstr (temp_value, "/");
- if (!sub)
- {
- NSSOC_LOGERR ("can't get maskklen from %s", temp_value);
- goto RETURN_ERROR;
- }
- (void) MEMSET_S (ipadd, sizeof (ipadd), 0, sizeof (ipadd));
- (void) STRNCPY_S (ipadd, sizeof (ipadd), temp_value,
- (size_t) (sub - temp_value));
- rddata->ipdata.masklen = atoi (sub + 1);
- rddata->ipdata.addr = ntohl (inet_addr (ipadd));
- icnt++;
+ NSSOC_LOGERR("no attr specified of protocol_route index:%d",
+ index);
+ return -1;
}
+ proto_data.attr = json_object_get_int(o);
+ nstack_rd_proto_node_insert(name, &proto_data, table);
+ o = NULL;
}
}
- for (index = 0; index < proto_list_num; index++)
+ return 0;
+}
+
+/*parse rd cfg*/
+static int parse_rd_cfg(char *param, const char *name, void *table)
+{
+ struct json_object *obj = json_tokener_parse(param);
+ struct json_object *module_obj = NULL;
+ struct json_object *temp_obj = NULL;
+ struct json_object *modules = NULL;
+ const char *module_name;
+ int total = 0;
+ int i = 0;
+
+ if ((!name) || (!obj))
+ {
+ NSSOC_LOGERR("json parse fail");
+ return NSTACK_RETURN_FAIL;
+ }
+
+ (void) json_object_object_get_ex(obj, "modules", &modules);
+ if (!modules)
{
- module_obj = json_object_array_get_idx (proto_list_obj, index);
- if (module_obj)
+ NSSOC_LOGERR("can't get modules");
+ goto RETURN_ERROR;
+ }
+
+ total = json_object_array_length(modules);
+ if (total > NSTACK_MAX_MODULE_NUM)
+ {
+ NSSOC_LOGERR("too many modules specified!");
+ goto RETURN_ERROR;
+ }
+ for (i = 0; i < total; i++)
+ {
+ module_obj = json_object_array_get_idx(modules, i);
+ if (module_obj)
{
- rddata = rdtemp + icnt;
- rddata->type = RD_DATA_TYPE_PROTO;
- (void) json_object_object_get_ex (module_obj, "stack_name",
- &temp_obj);
- if (temp_obj)
+ (void) json_object_object_get_ex(module_obj, "name", &temp_obj);
+ if (temp_obj)
{
- temp_value = json_object_get_string (temp_obj);
- if (!temp_value)
+ module_name = json_object_get_string(temp_obj);
+ if (!module_name)
{
- NSSOC_LOGERR ("can't get value from proto index:%d", index);
- goto RETURN_ERROR;
+ NSSOC_LOGERR("cannot get module name at index:%d", i);
+ goto RETURN_ERROR;
}
- (void) STRNCPY_S (rddata->stack_name, RD_PLANE_NAMELEN,
- temp_value, RD_PLANE_NAMELEN);
- }
- (void) json_object_object_get_ex (module_obj, "proto_type",
- &temp_obj);
- if (temp_obj)
- {
- temp_value = json_object_get_string (temp_obj);
- if (!temp_value)
+ if (strcmp(module_name, name) == 0) // this is what we are looking for
{
- NSSOC_LOGERR ("can't get value from proto index:%d", index);
- goto RETURN_ERROR;
+ if (rd_do_parse(module_obj, module_name, table))
+ {
+ NSSOC_LOGERR("parse failed at index:%d", i);
+ goto RETURN_ERROR;
+ }
+ break;
}
- rddata->proto_type = atoi (temp_value);
- icnt++;
}
}
}
- *data = rdtemp;
- *num = icnt;
- json_object_put (obj);
- return NSTACK_RETURN_OK;
-RETURN_ERROR:
- json_object_put (obj);
- if (rdtemp)
- {
- free (rdtemp);
- }
- return -1;
+ json_object_put(obj);
+ return NSTACK_RETURN_OK;
+ RETURN_ERROR:
+ json_object_put(obj);
+ return -1;
}
/*read json file, and return a buf, if return success, the caller need to free **buf*/
-int
-nstack_json_file_read (char *filename, char **buf)
+static int read_json_file(char *filename, char **buf)
{
- char *cfg_buf = NULL;
- int fp = 0;
- off_t file_len = 0;
- off_t buff_len = 0;
- int ret = NSTACK_RETURN_FAIL;
+ char *cfg_buf = NULL;
+ int fp = 0;
+ off_t file_len = 0;
+ off_t buff_len = 0;
+ int ret = NSTACK_RETURN_FAIL;
- if ((!filename) || (!buf))
+ if ((!filename) || (!buf))
{
- return NSTACK_RETURN_FAIL;
+ return NSTACK_RETURN_FAIL;
}
- fp = open (filename, O_RDONLY);
- if (fp < 0)
+ fp = open(filename, O_RDONLY);
+ if (fp < 0)
{
- NSSOC_LOGERR ("open %s fail, error:%d!", filename, errno);
- ret = NSTACK_RETURN_FAIL;
- goto RETURN_RELEASE;
+ NSSOC_LOGERR("open %s fail, error:%d!", filename, errno);
+ ret = NSTACK_RETURN_FAIL;
+ goto RETURN_RELEASE;
}
- file_len = lseek (fp, 0, SEEK_END);
- if (file_len <= 0)
+ file_len = lseek(fp, 0, SEEK_END);
+ if (file_len <= 0)
{
- NSSOC_LOGERR ("failed to get file len]file name=%s", filename);
- ret = NSTACK_RETURN_FAIL;
- goto RETURN_RELEASE;
+ NSSOC_LOGERR("failed to get file len]file name=%s", filename);
+ ret = NSTACK_RETURN_FAIL;
+ goto RETURN_RELEASE;
}
- if (file_len > NSTACK_CFG_FILELEN_MAX)
+ if (file_len > NSTACK_CFG_FILELEN_MAX)
{
- NSSOC_LOGERR
- ("file len is too big]file len=%d, max len=%d, file name=%s",
- file_len, NSTACK_CFG_FILELEN_MAX, filename);
- ret = NSTACK_RETURN_FAIL;
- goto RETURN_RELEASE;
+ NSSOC_LOGERR
+ ("file len is too big]file len=%ld, max len=%d, file name=%s",
+ file_len, NSTACK_CFG_FILELEN_MAX, filename);
+ ret = NSTACK_RETURN_FAIL;
+ goto RETURN_RELEASE;
}
- ret = lseek (fp, 0, SEEK_SET);
- if (ret < 0)
+ ret = lseek(fp, 0, SEEK_SET);
+ if (ret < 0)
{
- NSSOC_LOGERR ("seek to start failed]file name=%s", filename);
- ret = NSTACK_RETURN_FAIL;
- goto RETURN_RELEASE;
+ NSSOC_LOGERR("seek to start failed]file name=%s", filename);
+ ret = NSTACK_RETURN_FAIL;
+ goto RETURN_RELEASE;
}
- buff_len = file_len + 1;
- cfg_buf = (char *) malloc (buff_len);
- if (!cfg_buf)
+ buff_len = file_len + 1;
+ cfg_buf = (char *) malloc(buff_len);
+ if (!cfg_buf)
{
- NSSOC_LOGERR ("malloc buff failed]buff_len=%d", buff_len);
- ret = NSTACK_RETURN_FAIL;
- goto RETURN_RELEASE;
+ NSSOC_LOGERR("malloc buff failed]buff_len=%ld", buff_len);
+ ret = NSTACK_RETURN_FAIL;
+ goto RETURN_RELEASE;
}
- ret = MEMSET_S (cfg_buf, buff_len, 0, buff_len);
- if (NSTACK_RETURN_OK != ret)
+ ret = memset_s(cfg_buf, buff_len, 0, buff_len);
+ if (NSTACK_RETURN_OK != ret)
{
- NSSOC_LOGERR ("MEMSET_S failed]ret=%d.", ret);
- ret = NSTACK_RETURN_FAIL;
- goto RETURN_RELEASE;
+ NSSOC_LOGERR("memset_s failed]ret=%d.", ret);
+ ret = NSTACK_RETURN_FAIL;
+ goto RETURN_RELEASE;
}
- ret = nsfw_base_read (fp, cfg_buf, buff_len - 1);
- if (ret <= 0)
+ ret = nsfw_base_read(fp, cfg_buf, buff_len - 1);
+ if (ret <= 0)
{
- NSSOC_LOGERR ("read failed]ret=%d, errno:%d", ret, errno);
- ret = NSTACK_RETURN_FAIL;
- goto RETURN_RELEASE;
+ NSSOC_LOGERR("read failed]ret=%d, errno:%d", ret, errno);
+ ret = NSTACK_RETURN_FAIL;
+ goto RETURN_RELEASE;
}
- *buf = cfg_buf;
- nsfw_base_close (fp);
- return NSTACK_RETURN_OK;
-RETURN_RELEASE:
- if (fp >= 0)
+ *buf = cfg_buf;
+ nsfw_base_close(fp);
+ return NSTACK_RETURN_OK;
+ RETURN_RELEASE:
+ if (fp >= 0)
{
- nsfw_base_close (fp);
+ nsfw_base_close(fp);
}
- if (cfg_buf)
+ if (cfg_buf)
{
- free (cfg_buf);
+ free(cfg_buf);
}
- return ret;
+ return ret;
}
/*parse module cfg file*/
-int
-nstack_module_parse ()
+int nstack_module_parse()
{
- char *modulecfg = NULL;
- char *tmp_config_path = NULL;
- char *cfg_buf = NULL;
- int ret = NSTACK_RETURN_FAIL;
+ char *modulecfg = NULL;
+ char *tmp_config_path = NULL;
+ char *cfg_buf = NULL;
+ int ret = NSTACK_RETURN_FAIL;
- modulecfg = getenv (NSTACK_MOD_CFG_FILE);
+ modulecfg = getenv(NSTACK_MOD_CFG_FILE);
- if (modulecfg)
+ if (modulecfg)
{
- tmp_config_path = realpath (modulecfg, NULL);
+ tmp_config_path = realpath(modulecfg, NULL);
}
- else
+ else
{
- tmp_config_path = realpath (DEFALT_MODULE_CFG_FILE, NULL);
+ tmp_config_path = realpath(DEFALT_MODULE_CFG_FILE, NULL);
}
- if (!tmp_config_path)
+ if (!tmp_config_path)
{
- NSSOC_LOGERR ("nstack module file:%s get real path fail!",
- modulecfg ? modulecfg : DEFALT_MODULE_CFG_FILE);
- return NSTACK_RETURN_FAIL;
+ NSSOC_LOGWAR
+ ("nstack module file:%s get real path failed! Load default instead.",
+ modulecfg ? modulecfg : DEFALT_MODULE_CFG_FILE);
+ return load_default_module();
}
- ret = nstack_json_file_read (tmp_config_path, &cfg_buf);
- if (NSTACK_RETURN_OK == ret)
+ ret = read_json_file(tmp_config_path, &cfg_buf);
+ if (NSTACK_RETURN_OK == ret)
{
- ret = nstack_parse_module_cfg_json (cfg_buf);
- free (cfg_buf);
+ ret = parse_module_cfg(cfg_buf);
+ free(cfg_buf);
}
- free (tmp_config_path);
- return ret;
+ free(tmp_config_path);
+ return ret;
}
-int
-nstack_stack_rd_parse (rd_route_data ** data, int *num)
+int nstack_rd_parse(const char *name, void *table)
{
- char *modulecfg = NULL;
- char *tmp_config_path = NULL;
- char *cfg_buf = NULL;
- int ret = NSTACK_RETURN_FAIL;
+ char *modulecfg = NULL;
+ char *tmp_config_path = NULL;
+ char *cfg_buf = NULL;
+ int ret = NSTACK_RETURN_FAIL;
- modulecfg = getenv (NSTACK_MOD_CFG_RD);
+ modulecfg = getenv(NSTACK_MOD_CFG_RD);
- if (modulecfg)
+ if (modulecfg)
{
- tmp_config_path = realpath (modulecfg, NULL);
+ tmp_config_path = realpath(modulecfg, NULL);
}
- else
+ else
{
- tmp_config_path = realpath (DEFALT_RD_CFG_FILE, NULL);
+ tmp_config_path = realpath(DEFALT_RD_CFG_FILE, NULL);
}
- if (!tmp_config_path)
+ if (!tmp_config_path)
{
- NSSOC_LOGERR ("nstack rd file:%s get real path fail!",
- modulecfg ? modulecfg : DEFALT_MODULE_CFG_FILE);
- return NSTACK_RETURN_FAIL;
+ NSSOC_LOGWAR("nstack rd file:%s get real path failed!",
+ modulecfg ? modulecfg : DEFALT_MODULE_CFG_FILE);
+ return NSTACK_RETURN_FAIL;
}
- ret = nstack_json_file_read (tmp_config_path, &cfg_buf);
- if (NSTACK_RETURN_OK == ret)
+ ret = read_json_file(tmp_config_path, &cfg_buf);
+ if (NSTACK_RETURN_OK == ret)
{
- ret = nstack_parse_rd_cfg_json (cfg_buf, data, num);
- free (cfg_buf);
+ ret = parse_rd_cfg(cfg_buf, name, table);
+ free(cfg_buf);
}
- free (tmp_config_path);
- return ret;
+ free(tmp_config_path);
+ return ret;
}
diff --git a/src/nSocket/nstack/nstack_info_parse.h b/src/nSocket/nstack/nstack_info_parse.h
index 8b508b3..5211dd0 100644
--- a/src/nSocket/nstack/nstack_info_parse.h
+++ b/src/nSocket/nstack/nstack_info_parse.h
@@ -34,8 +34,6 @@
#include "nstack_module.h"
#include "nstack_log.h"
#include "nstack_securec.h"
-#include "nstack_rd.h"
-#include "nstack_rd_data.h"
#define DEFALT_MODULE_CFG_FILE "./module_config.json"
#define DEFALT_RD_CFG_FILE "./rd_config.json"
@@ -50,7 +48,6 @@
extern nstack_module_keys g_nstack_module_desc[NSTACK_MAX_MODULE_NUM];
extern ns_uint32 g_module_num;
-extern int nstack_module_parse ();
-extern int nstack_stack_rd_parse (rd_route_data ** data, int *num);
+extern int nstack_module_parse();
#endif
diff --git a/src/nSocket/nstack/nstack_module.c b/src/nSocket/nstack/nstack_module.c
index 9566ab8..fdfea06 100644
--- a/src/nSocket/nstack/nstack_module.c
+++ b/src/nSocket/nstack/nstack_module.c
@@ -29,13 +29,13 @@
#include <arpa/inet.h>
#include <errno.h>
#include "nstack_module.h"
-#include "common_mem_buf.h"
#include "nstack_log.h"
+#include "nstack_select.h"
#include "nstack_securec.h"
-#include "nstack_dmm_api.h"
-#include "nstack_dmm_adpt.h"
-#include "nstack_rd_init.h"
+#include "nstack_rd.h"
+#include "nstack_epoll_api.h"
#include "nstack_info_parse.h"
+#include "nsfw_mem_api.h"
/* *INDENT-OFF* */
nstack_module_info g_nstack_modules = {
@@ -45,243 +45,336 @@ nstack_module_info g_nstack_modules = {
.defMod = NULL,
};
-/* *INDENT-ON* */
nstack_module_keys g_nstack_module_desc[NSTACK_MAX_MODULE_NUM];
-
ns_uint32 g_module_num = 0;
+nstack_proc_ops nstack_fd_deal[NSTACK_MAX_MODULE_NUM];
+/* *INDENT-ON* */
+
+extern rd_route_table *g_rd_table_handle[NSTACK_MAX_MODULE_NUM];
-int
-nstack_get_deploy_type ()
+int nstack_get_deploy_type()
{
- int icnt = 0;
- int type = 0;
- for (icnt = 0; icnt < g_module_num; icnt++)
+ int icnt = 0;
+ int type = 0;
+ for (icnt = 0; icnt < g_module_num; icnt++)
{
- if (g_nstack_module_desc[icnt].deploytype > type)
+ if (g_nstack_module_desc[icnt].deploytype > type)
{
- type = g_nstack_module_desc[icnt].deploytype;
+ type = g_nstack_module_desc[icnt].deploytype;
}
}
- return type;
+ return type;
}
NSTACK_STATIC inline int
-nstack_register_one_module (nstack_module_keys * pKeys)
+nstack_register_one_module_forchild(nstack_module_keys * pKeys)
{
+ nstack_module *pmod = NULL;
+ nstack_stack_register_fn stack_register_fn = NULL;
+ nstack_event_ops val = { 0 };
+ int ret = 0;
- nstack_module *pmod = NULL;
- nstack_stack_register_fn stack_register_fn = NULL;
- nstack_event_cb val = { 0 };
- int retVal;
- int ret = 0;
-
- if (pKeys->modInx >= NSTACK_MAX_MODULE_NUM)
+ if (pKeys->modInx >= NSTACK_MAX_MODULE_NUM)
{
- NSSOC_LOGERR ("modeindex is overload]index=%d", pKeys->modInx);
- ret = -1;
- goto err_return;
+ NSSOC_LOGERR
+ ("pKeys->modInx is too large]pKeys->modName=%s,pKeys->modInx=%d",
+ pKeys->modName, pKeys->modInx);
+ return -1;
}
- pmod = nstack_get_module (pKeys->modInx);
-
- retVal =
- STRNCPY_S (pmod->modulename, NSTACK_PLUGIN_NAME_LEN, pKeys->modName,
- NSTACK_PLUGIN_NAME_LEN);
- if (EOK != retVal)
+ pmod = nstack_get_module(pKeys->modInx);
+ /*There are some unsafe function ,need to be replace with safe function */
+ ret =
+ strncpy_s(pmod->modulename, NSTACK_MODULE_NAME_MAX, pKeys->modName,
+ NSTACK_MODULE_NAME_MAX - 1);
+ if (EOK != ret)
{
- NSSOC_LOGERR ("STRNCPY_S failed]ret=%d", retVal);
- ret = -1;
- goto err_return;
+ NSSOC_LOGERR("strncpy_s failed]ret=%d", ret);
+ return -1;
}
+ pmod->modulename[NSTACK_MODULE_NAME_MAX - 1] = '\0';
+ pmod->priority = pKeys->priority;
+ pmod->modInx = pKeys->modInx;
+ pmod->maxfdid = pKeys->maxfdid;
+ pmod->minfdid = pKeys->minfdid;
- pmod->modulename[NSTACK_PLUGIN_NAME_LEN - 1] = '\0';
- pmod->priority = pKeys->priority;
- pmod->modInx = pKeys->modInx;
- pmod->maxfdid = pKeys->maxfdid;
- pmod->minfdid = pKeys->minfdid;
- pmod->ep_free_ref = pKeys->ep_free_ref;
-
- if (pKeys->libtype == NSTACK_LIB_LOAD_DYN)
+ if (pKeys->libtype == NSTACK_LIB_LOAD_DYN)
{
- pmod->handle = dlopen (pKeys->libPath, RTLD_LAZY);
- if (!pmod->handle)
+ pmod->handle = dlopen(pKeys->libPath, RTLD_LAZY);
+ if (!pmod->handle)
{
- /*optimize dlopen err print */
- NSSOC_LOGERR ("dlopen lib=%s of module=%s failed, err_string=%s",
- pKeys->libPath, pKeys->modName, dlerror ());
- ret = -1;
- goto err_return;
+ NSSOC_LOGERR
+ ("dlopen failed, lib=%s of module=%s, error string=%s",
+ pKeys->libPath, pKeys->modName, dlerror());
+ return -1;
}
}
- else
+ else
{
- pmod->handle = RTLD_DEFAULT;
+ pmod->handle = RTLD_DEFAULT;
}
- stack_register_fn = dlsym (pmod->handle, pKeys->register_fn_name);
- if (!stack_register_fn)
+ stack_register_fn = dlsym(pmod->handle, pKeys->register_fn_name);
+ if (!stack_register_fn)
{
- /* optimize dlopen err print */
- NSSOC_LOGERR ("register function not found]err_string=%s", dlerror ());
- if (pmod->handle)
+ /* optimize dlopen err print Begin */
+ NSSOC_LOGERR("register function not found]err_string=%s", dlerror());
+ /* optimize dlopen err print End */
+ if (pmod->handle && RTLD_NEXT != pmod->handle)
{
- dlclose (pmod->handle);
- pmod->handle = NULL;
+ dlclose(pmod->handle);
+ pmod->handle = NULL;
}
- ret = -1;
- goto err_return;
+ return -1;
}
- val.handle = pmod->handle;
- val.type = pKeys->modInx;
- val.event_cb = nstack_event_callback;
- if (stack_register_fn (&pmod->mops, &val))
+ val.handle = pmod->handle;
+ val.type = pKeys->modInx;
+ val.event_cb = nstack_epoll_event_enqueue;
+ if (stack_register_fn(&pmod->ops, &val, &nstack_fd_deal[pmod->modInx]))
{
- NSSOC_LOGERR ("register function failed");
- if (pmod->handle)
+ NSSOC_LOGERR("register function failed");
+ if (pmod->handle && RTLD_NEXT != pmod->handle)
{
- dlclose (pmod->handle);
- pmod->handle = NULL;
+ dlclose(pmod->handle);
+ pmod->handle = NULL;
}
- ret = -1;
- goto err_return;
+ return -1;
}
- /* malloc length need protect
- malloc parameter type is size_t */
- if (((pmod->maxfdid + 1) < 1)
- || (SIZE_MAX / sizeof (ns_int32) < (pmod->maxfdid + 1)))
+ return 0;
+}
+
+void nstack_register_module_forchild(void)
+{
+ ns_uint32 idx;
+ for (idx = 0; idx < g_module_num; idx++)
{
- NSSOC_LOGERR ("malloc size is wrong]maxfdid=%d", pmod->maxfdid);
- if (pmod->handle)
+ if (0 !=
+ nstack_register_one_module_forchild(&g_nstack_module_desc[idx]))
{
- dlclose (pmod->handle);
- pmod->handle = NULL;
+ NSSOC_LOGERR
+ ("can't register module]modInx=%d,modName=%s,libPath=%s",
+ g_nstack_module_desc[idx].modInx,
+ g_nstack_module_desc[idx].modName,
+ g_nstack_module_desc[idx].libPath);
+ return;
}
- ret = -1;
- goto err_return;
}
-
-err_return:
- return ret;
}
-/*nstack_register_module can't concurrent*/
-int
-nstack_register_module ()
+int nstack_register_one_module(nstack_module_keys * pKeys)
{
- unsigned int idx = 0;
- nstack_stack_info *pstacks = NULL;
- int ret = 0;
-
- nstack_get_route_data rd_fun[] = {
- nstack_stack_rd_parse,
- };
+ nstack_module *pmod = NULL;
+ nstack_stack_register_fn stack_register_fn = NULL;
+ nstack_event_ops val = { 0 };
+ int ret = 0;
- pstacks =
- (nstack_stack_info *) malloc (sizeof (nstack_stack_info) * g_module_num);
- if (!pstacks)
+ if (pKeys->modInx >= NSTACK_MAX_MODULE_NUM)
{
- NSSOC_LOGERR ("malloc failed]");
- return ns_fail;
+ NSSOC_LOGERR("modeindex overflows]index=%d", pKeys->modInx);
+ ret = -1;
+ goto err_return;
}
- ret =
- MEMSET_S (pstacks, sizeof (nstack_stack_info) * g_module_num, 0,
- sizeof (nstack_stack_info) * g_module_num);
- if (EOK != ret)
+
+ pmod = nstack_get_module(pKeys->modInx);
+
+ /*There are some unsafe function ,need to be replace with safe function */
+ ret =
+ strncpy_s(pmod->modulename, NSTACK_MODULE_NAME_MAX, pKeys->modName,
+ NSTACK_MODULE_NAME_MAX - 1);
+ if (EOK != ret)
{
- NSSOC_LOGERR ("MEMSET_S failed]ret=%d", ret);
- free (pstacks);
- return ns_fail;
+ NSSOC_LOGERR("strncpy_s failed]ret=%d", ret);
+ ret = -1;
+ goto err_return;
}
- for (idx = 0; idx < g_module_num; idx++)
+ pmod->modulename[NSTACK_MODULE_NAME_MAX - 1] = '\0';
+ pmod->priority = pKeys->priority;
+ pmod->modInx = pKeys->modInx;
+ pmod->maxfdid = pKeys->maxfdid;
+ pmod->minfdid = pKeys->minfdid;
+
+ if (pKeys->libtype == NSTACK_LIB_LOAD_DYN)
{
- if (0 != nstack_register_one_module (&g_nstack_module_desc[idx]))
+ pmod->handle = dlopen(pKeys->libPath, RTLD_LAZY);
+ if (!pmod->handle)
{
- NSSOC_LOGERR
- ("can't register module]modInx=%d,modName=%s,libPath=%s",
- g_nstack_module_desc[idx].modInx,
- g_nstack_module_desc[idx].modName,
- g_nstack_module_desc[idx].libPath);
- free (pstacks);
- return ns_fail;
+ NSSOC_LOGERR
+ ("dlopen failed, lib=%s of module=%s, error string=%s",
+ pKeys->libPath, pKeys->modName, dlerror());
+ ret = -1;
+ goto err_return;
}
- ret =
- STRCPY_S (pstacks[idx].name, STACK_NAME_MAX,
- g_nstack_module_desc[idx].modName);
- if (EOK != ret)
+ }
+ else
+ {
+ pmod->handle = RTLD_DEFAULT;
+ }
+
+ stack_register_fn = dlsym(pmod->handle, pKeys->register_fn_name);
+ if (!stack_register_fn)
+ {
+ /* optimize dlopen err print Begin */
+ NSSOC_LOGERR("register function not found]err_string=%s", dlerror());
+ /* optimize dlopen err print End */
+ if (pmod->handle)
{
- NSSOC_LOGERR ("STRCPY_S fail]idx=%d,modName=%s,ret=%d", idx,
- g_nstack_module_desc[idx].modName, ret);
- free (pstacks);
- return ns_fail;
+ dlclose(pmod->handle);
+ pmod->handle = NULL;
}
- pstacks[idx].priority = g_nstack_module_desc[idx].priority;
- pstacks[idx].stack_id = g_nstack_module_desc[idx].modInx;
- if (g_nstack_module_desc[idx].default_stack == 1)
+ ret = -1;
+ goto err_return;
+ }
+ val.handle = pmod->handle;
+ val.type = pKeys->modInx;
+ val.event_cb = nstack_epoll_event_enqueue;
+ if (stack_register_fn(&pmod->ops, &val, &nstack_fd_deal[pmod->modInx]))
+ {
+ NSSOC_LOGERR("register function failed, module=%s", pKeys->modName);
+ if (pmod->handle)
{
- g_nstack_modules.defMod =
- &g_nstack_modules.modules[g_nstack_module_desc[idx].modInx];
- g_nstack_modules.fix_mid = g_nstack_module_desc[idx].modInx;
+ dlclose(pmod->handle);
+ pmod->handle = NULL;
}
+ ret = -1;
+ goto err_return;
}
- if (g_nstack_modules.fix_mid < 0)
+ /* malloc length need protect
+ malloc parameter type is size_t */
+
+ if (((pmod->maxfdid + 1) < 1)
+ || (SIZE_MAX / sizeof(ns_int32) < (pmod->maxfdid + 1)))
{
- free (pstacks);
- NSSOC_LOGERR ("nstack fix mid is unknown and return fail");
- return ns_fail;
+ NSSOC_LOGERR("malloc size is wrong]maxfdid=%d", pmod->maxfdid);
+ if (pmod->handle)
+ {
+ dlclose(pmod->handle);
+ pmod->handle = NULL;
+ }
+ ret = -1;
+ goto err_return;
}
- g_nstack_modules.modNum = g_module_num;
- /*rd module init */
- if (ns_success !=
- nstack_rd_init (pstacks, idx, rd_fun,
- sizeof (rd_fun) / sizeof (nstack_get_route_data)))
+ if (nstack_fd_deal[pmod->modInx].module_init_pre)
{
- free (pstacks);
- NSSOC_LOGERR ("nstack rd init fail");
- return ns_fail;
+ ret = nstack_fd_deal[pmod->modInx].module_init_pre((void *)
+ g_nsfw_mem_ops,
+ (void *)
+ g_ring_ops_arry,
+ NSFW_MEM_TYPEMAX,
+ NSFW_MPOOL_TYPEMAX);
}
- free (pstacks);
- return ns_success;
+
+ err_return:
+ return ret;
}
-int
-nstack_stack_module_init ()
+/*nstack_register_module can't concurrent*/
+int nstack_register_module()
{
- ns_uint32 idx;
- for (idx = 0; idx < g_module_num; idx++)
+ unsigned int idx = 0;
+ nstack_rd_stack_info *pstacks = NULL;
+ int ret = 0;
+
+ pstacks =
+ (nstack_rd_stack_info *) malloc(sizeof(nstack_rd_stack_info) *
+ g_module_num);
+ if (!pstacks)
{
- if (g_nstack_modules.modules[idx].mops.extern_ops.module_init)
+ NSSOC_LOGERR("malloc failed]");
+ return ns_fail;
+ }
+ /*There are some unsafe function ,need to be replace with safe function */
+ ret =
+ memset_s(&nstack_fd_deal[0], sizeof(nstack_fd_deal), 0,
+ sizeof(nstack_fd_deal));
+ ret |=
+ memset_s(pstacks, sizeof(nstack_rd_stack_info) * g_module_num, 0,
+ sizeof(nstack_rd_stack_info) * g_module_num);
+ if (EOK != ret)
+ {
+ NSSOC_LOGERR("memset_s failed]ret=%d", ret);
+ free(pstacks); /*free() can be used */
+ return ns_fail;
+ }
+
+ for (idx = 0; idx < g_module_num; idx++)
+ {
+ if (0 != nstack_register_one_module(&g_nstack_module_desc[idx]))
{
- if (0 !=
- g_nstack_modules.modules[idx].mops.extern_ops.module_init ())
- {
- NSSOC_LOGERR ("nstack[%s] modx:%d init fail",
- g_nstack_modules.modules[idx].modulename, idx);
- }
+ NSSOC_LOGERR
+ ("can't register module]modInx=%d,modName=%s,libPath=%s",
+ g_nstack_module_desc[idx].modInx,
+ g_nstack_module_desc[idx].modName,
+ g_nstack_module_desc[idx].libPath);
+ free(pstacks); /*free() can be used */
+ return ns_fail;
}
+ ret =
+ strcpy_s(pstacks[idx].name, STACK_NAME_MAX,
+ g_nstack_module_desc[idx].modName);
+ if (EOK != ret)
+ {
+ NSSOC_LOGERR("strcpy_s fail]idx=%u,modName=%s,ret=%d", idx,
+ g_nstack_module_desc[idx].modName, ret);
+ free(pstacks); /*free() can be used */
+ return ns_fail;
+ }
+
+ pstacks[idx].priority = g_nstack_module_desc[idx].priority;
+ pstacks[idx].stack_id = g_nstack_module_desc[idx].modInx;
+ if (g_nstack_module_desc[idx].default_stack == 1)
+ {
+ g_nstack_modules.defMod =
+ &g_nstack_modules.modules[g_nstack_module_desc[idx].modInx];
+ g_nstack_modules.fix_mid = g_nstack_module_desc[idx].modInx;
+ }
+ if (strcmp(g_nstack_module_desc[idx].modName, RD_KERNEL_NAME) == 0)
+ {
+ g_nstack_modules.linuxmid = idx;
+ }
+ }
+
+ if (g_nstack_modules.fix_mid < 0)
+ {
+ free(pstacks);
+ NSSOC_LOGERR("nstack fix mid still unknown!");
+ return ns_fail;
+ }
+ g_nstack_modules.modNum = g_module_num;
+
+ /*rd module init */
+ if (ns_success != nstack_rd_init(pstacks, idx))
+ {
+ free(pstacks); /*free() can be used */
+ NSSOC_LOGERR("nstack rd init fail");
+ return ns_fail;
}
- return 0;
+ free(pstacks); /*free() can be used */
+ return ns_success;
}
-int
-nstack_stack_module_init_child ()
+int nstack_stack_module_init()
{
- ns_uint32 idx;
- for (idx = 0; idx < g_module_num; idx++)
+ int icnt;
+ for (icnt = 0; icnt < g_module_num; icnt++)
{
- if (g_nstack_modules.modules[idx].mops.extern_ops.module_init_child)
+ if (nstack_fd_deal[icnt].module_init)
{
- if (0 !=
- g_nstack_modules.modules[idx].mops.
- extern_ops.module_init_child ())
+ if (nstack_fd_deal[icnt].module_init())
{
- NSSOC_LOGERR ("nstack[%s] modx:%d init child fail",
- g_nstack_modules.modules[idx].modulename, idx);
+ NSSOC_LOGERR("stack:%s init failed!",
+ g_nstack_modules.modules[icnt].modulename);
+ return -1;
}
}
+ if (nstack_fd_deal[icnt].get_ip_shmem)
+ {
+ g_rd_table_handle[icnt] =
+ (rd_route_table *) nstack_fd_deal[icnt].get_ip_shmem();
+ }
}
- return 0;
+ return 0;
}
diff --git a/src/nSocket/nstack/nstack_module.h b/src/nSocket/nstack/nstack_module.h
index 40a2ef8..1520cf1 100644
--- a/src/nSocket/nstack/nstack_module.h
+++ b/src/nSocket/nstack/nstack_module.h
@@ -17,12 +17,14 @@
#ifndef __NSTACK_MODULE_H__
#define __NSTACK_MODULE_H__
+#ifndef SPL_INSTANCE_H
#include <poll.h>
+#endif
#include <sys/socket.h>
#include <sys/epoll.h>
-#include "nstack_types.h"
-#include "nstack_dmm_api.h"
#include "types.h"
+#include "nstack_callback_ops.h"
+#include "nsfw_common_defs.h"
#ifdef __cplusplus
/* *INDENT-OFF* */
@@ -30,60 +32,56 @@ extern "C"{
/* *INDENT-ON* */
#endif
-#define NSTACK_LIB_LOAD_DYN 0
-#define NSTACK_LIB_LOAD_STATIC 1
-
-#define NSTACK_PLUGIN_NAME_LEN 64
-
-#define NSTACK_MAX_MODULE_NUM 8
-#define NSTACK_PRO_MODULE 1
-
-#define NSTACK_EP_FREE_NEED_REF 1 /*when epoll information free, need to wait that stack would not notify event */
-#define NSTACK_EP_FREE_NONEED_REF 0
-
-#define MODULE_NAME_MAX 128
+#define MOD_INDEX_FOR_STACKPOOL 1
typedef struct __NSTACK_MODULE_KEYS
{
- ns_char modName[MODULE_NAME_MAX]; /*stack name */
- ns_char register_fn_name[MODULE_NAME_MAX]; /*stack register fun name */
- ns_char libPath[MODULE_NAME_MAX]; /*if libtype is dynamic, it is the path of lib */
- ns_char deploytype; /*delpoly model type: model type1, model type2, model type3 */
- ns_char libtype; /*dynamic lib or static lib */
- ns_char ep_free_ref; /*when epoll information free,
- *need to wait that stack would not notify event
- */
- ns_char default_stack; /*whether is default stack:when don't know how to choose stack,
- *just use default stack
- */
- ns_int32 priority;
- ns_int32 maxfdid; //the max fd id
- ns_int32 minfdid; //the min fd id
- ns_int32 modInx; // This is alloced by nStack , not from configuration
+ ns_char modName[NSTACK_MODULE_NAME_MAX]; // stack name
+ ns_char register_fn_name[NSTACK_MODULE_NAME_MAX]; // stack register function symbol
+ ns_char libPath[NSTACK_MODULE_NAME_MAX]; // if libtype is dynamic, it is the path of lib
+ ns_char deploytype; // deploy type: type1, type2, type3, and etc
+ ns_char libtype; // dynamic or static
+ ns_char default_stack; // whether it is the default one
+ ns_int32 priority;
+ ns_int32 maxfdid; //the max fd id
+ ns_int32 minfdid; //the min fd id
+ ns_int32 modInx; // This is alloced by nStack , not from configuration
} nstack_module_keys;
typedef struct __NSTACK_MODULE
{
- char modulename[NSTACK_PLUGIN_NAME_LEN];
- ns_int32 priority;
- void *handle;
- nstack_proc_cb mops;
- ns_int32 ep_free_ref; //ep information need free with ref
- ns_int32 modInx; // The index of module
- ns_int32 maxfdid; //the max fd id
- ns_int32 minfdid; //the min fd id
+ char modulename[NSTACK_MODULE_NAME_MAX];
+ ns_int32 priority;
+ void *handle;
+ nstack_socket_ops ops;
+ ns_int32 modInx; // The index of module
+ ns_int32 maxfdid; //the max fd id
+ ns_int32 minfdid; //the min fd id
} nstack_module;
typedef struct
{
- ns_int32 modNum; // Number of modules registered
- ns_int32 fix_mid;
- nstack_module *defMod; // The default module
- nstack_module modules[NSTACK_MAX_MODULE_NUM];
+ ns_int32 modNum; // Number of modules registed
+ ns_int32 fix_mid;
+ ns_int32 linuxmid;
+ nstack_module *defMod; // The default module
+ nstack_module modules[NSTACK_MAX_MODULE_NUM];
} nstack_module_info;
+typedef enum
+{
+ NSTACK_MODEL_TYPE1 = 1, /*nSocket and stack belong to the same process */
+ NSTACK_MODEL_TYPE2 = 2, /*nSocket and stack belong to different processes,
+ *and nStack don't take care the communication between stack and stack adpt
+ */
+ NSTACK_MODEL_TYPE3 = 3, /*nSocket and stack belong to different processes, and sbr was supplied to communicate whit stack */
+ NSTACK_MODEL_TYPE_SIMPLE_STACK = 4, /* like TYPE1, DMM will NOT provide SBR or pipeline mode, just allocate 32M, and use dpdk file
+ * prefix to support multiple running app under DMM */
+ NSTACK_MODEL_INVALID,
+} nstack_model_deploy_type;
+
/*register module according the modulecfg file*/
-extern ns_int nstack_register_module ();
+extern ns_int nstack_register_module();
/*****************************************************************
Parameters : ops never be null; nstack api calls it;
@@ -91,48 +89,39 @@ Return : 0,not match; 1, match
Description :
*****************************************************************/
extern nstack_module_info g_nstack_modules;
+extern nstack_proc_ops nstack_fd_deal[NSTACK_MAX_MODULE_NUM];
extern nstack_module_keys g_nstack_module_desc[];
+extern ns_uint32 g_module_num;
#define nstack_defmod_name() (g_nstack_modules.defMod->modulename)
#define nstack_default_module() (g_nstack_modules.defMod)
-#define nstack_defMod_inx() (g_nstack_modules.defMod->modInx)
+#define nstack_defmod_inx() (g_nstack_modules.fix_mid)
#define nstack_get_module(inx) (&g_nstack_modules.modules[(inx)])
-#define nstack_get_modNum() (g_nstack_modules.modNum)
+#define nstack_get_module_num() (g_nstack_modules.modNum)
#define nstack_get_module_name_by_idx(inx) (g_nstack_modules.modules[inx].modulename)
-#define nstack_def_ops() (&g_nstack_modules.defMod->mops.socket_ops)
-#define nstack_module_ops(modInx) (&g_nstack_modules.modules[(modInx)].mops.socket_ops)
+#define nstack_def_ops() (&g_nstack_modules.defMod->ops)
+#define nstack_get_linux_mid() (g_nstack_modules.linuxmid)
+#define nstack_module_ops(modInx) (&g_nstack_modules.modules[(modInx)].ops)
#define nstack_get_maxfd_id(modInx) (g_nstack_modules.modules[modInx].maxfdid)
#define nstack_get_minfd_id(modInx) (g_nstack_modules.modules[modInx].minfdid)
-#define nstack_get_descmaxfd_id(modInx) (g_nstack_module_desc[modInx].maxfdid)
-#define nstack_epinfo_free_flag(modInx) (g_nstack_modules.modules[(modInx)].ep_free_ref == NSTACK_EP_FREE_NEED_REF)
-
-#define nstack_extern_deal(modInx) (g_nstack_modules.modules[(modInx)].mops.extern_ops)
+#define nstack_set_maxfd_id(modInx, maxfd) (g_nstack_module_desc[modInx].maxfdid = maxfd)
-#define nstack_defMod_profd(fdInf) ((fdInf)->protoFD[g_nstack_modules.defMod->modInx].fd)
-#define nstack_inf_modProfd(fdInf, pMod) ((fdInf)->protoFD[(pMod)->modInx].fd)
+#define nstack_def_mod_profd(fdInf) ((fdInf)->protoFD[g_nstack_modules.defMod->modInx].fd)
+#define nstack_inf_mod_profd(fdInf, pMod) ((fdInf)->protoFD[(pMod)->modInx].fd)
-#define nstack_get_fix_mid() (g_nstack_modules.fix_mid)
-#define nstack_fix_mid_ops() (&(g_nstack_modules.modules[g_nstack_modules.fix_mid].mops.socket_ops))
-#define nstack_fix_stack_name() (g_nstack_modules.modules[g_nstack_modules.fix_mid].modulename)
+#define nstack_each_mod_ops(modInx, ops) \
+ for ((modInx) = 0; ((modInx) < nstack_get_module_num() && ((ops) = nstack_module_ops(modInx))); (modInx)++)
-#define nstack_fix_fd_check() ((g_nstack_modules.fix_mid >= 0) && (g_nstack_modules.fix_mid < NSTACK_MAX_MODULE_NUM) \
- ? g_nstack_modules.modules[g_nstack_modules.fix_mid].mops.extern_ops.stack_fd_check \
- : NULL)
-
-#define nstack_each_modOps(modInx, ops) \
- for ((modInx) = 0; ((modInx) < nstack_get_modNum() && ((ops) = nstack_module_ops(modInx))); (modInx)++)
-
-#define nstack_each_modInx(modInx) \
- for ((modInx) = 0; ((modInx) < nstack_get_modNum()); (modInx)++)
+#define nstack_each_mod_inx(modInx) \
+ for ((modInx) = 0; ((modInx) < nstack_get_module_num()); (modInx)++)
#define nstack_each_module(modInx, pMod) \
- for ((modInx) = 0; ((modInx) < nstack_get_modNum() && (pMod = nstack_get_module((modInx)))); (modInx)++)
-
-int nstack_stack_module_init ();
-int nstack_stack_module_init_child ();
+ for ((modInx) = 0; ((modInx) < nstack_get_module_num() && (pMod = nstack_get_module((modInx)))); (modInx)++)
-int nstack_get_deploy_type ();
+void nstack_register_module_forchild(void);
+int nstack_get_deploy_type();
+int nstack_stack_module_init();
#ifdef __cplusplus
/* *INDENT-OFF* */
diff --git a/src/nSocket/nstack/nstack_nsocket_construct.c b/src/nSocket/nstack/nstack_nsocket_construct.c
index 0b447b7..bf60066 100644
--- a/src/nSocket/nstack/nstack_nsocket_construct.c
+++ b/src/nSocket/nstack/nstack_nsocket_construct.c
@@ -14,30 +14,20 @@
* limitations under the License.
*/
-#include "nsfw_init.h"
+#include "nsfw_init_api.h"
#include "nsfw_mem_api.h"
#include "nsfw_mgr_com_api.h"
#include "nsfw_recycle_api.h"
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C"{
-/* *INDENT-ON* */
-#endif /* __cplusplus */
-
#define NSACK_NSOCKET_MODULE "nSocket"
-extern int nstack_app_init (void *ppara);
-/* *INDENT-OFF* */
-NSFW_MODULE_NAME (NSACK_NSOCKET_MODULE)
-NSFW_MODULE_PRIORITY (7)
-NSFW_MODULE_DEPENDS (NSFW_MGR_COM_MODULE)
-NSFW_MODULE_DEPENDS (NSFW_MEM_MGR_MODULE)
-NSFW_MODULE_DEPENDS (NSFW_RECYCLE_MODULE)
-NSFW_MODULE_INIT (nstack_app_init)
-/* *INDENT-ON* */
-#ifdef __cplusplus
+extern int nstack_app_init(void *ppara);
+
/* *INDENT-OFF* */
-}
+NSFW_MODULE_NAME(NSACK_NSOCKET_MODULE)
+NSFW_MODULE_PRIORITY(7)
+NSFW_MODULE_DEPENDS(NSFW_MGR_COM_MODULE)
+NSFW_MODULE_DEPENDS(NSFW_MEM_MGR_MODULE)
+NSFW_MODULE_DEPENDS(NSFW_RECYCLE_MODULE)
+NSFW_MODULE_INIT(nstack_app_init)
/* *INDENT-ON* */
-#endif /* __cplusplus */
diff --git a/src/nSocket/nstack/nstack_socket.c b/src/nSocket/nstack/nstack_socket.c
index 210e29d..a69747d 100644
--- a/src/nSocket/nstack/nstack_socket.c
+++ b/src/nSocket/nstack/nstack_socket.c
@@ -31,12 +31,11 @@
#include "nstack.h"
#include "nstack_socket.h"
#include "nstack_fd_mng.h"
-#include "nstack_dmm_api.h"
+#include "nstack_callback_ops.h"
#include "nstack_sockops.h"
#include "nstack_module.h"
-#include "common_mem_spinlock.h"
#include "nstack_securec.h"
-#include "nsfw_init.h"
+#include "nsfw_init_api.h"
#include "nsfw_recycle_api.h"
#include "nsfw_base_linux_api.h"
#include "nstack_rd_data.h"
@@ -44,8 +43,17 @@
#include "select_adapt.h"
#include "nstack_select.h"
#include "nstack_share_res.h"
+#include "nsfw_ps_api.h"
+#include "nstack_ip_addr.h"
+#include "nsfw_mem_api.h"
+#include "dmm_spinlock.h"
+#include "dmm_rwlock.h"
+#include "nstack_dmm_dfx.h"
+#include <stdlib.h>
+#include <unistd.h>
+
#ifndef F_SETFL
-#define F_SETFL 4
+#define F_SETFL 4
#endif
#define NSTACK_LOOP_IP 0x100007f
@@ -60,8 +68,12 @@
extern __typeof (name) aliasname __attribute__ ((alias (#name)));
#undef NSTACK_MK_DECL
#define NSTACK_MK_DECL(ret, fn, args) strong_alias(nstack_##fn, fn)
-#include <declare_syscalls.h>
+#include <declare_syscalls.h.tmpl>
#endif
+__thread unsigned int g_addrinfo_flag = 0;
+
+extern void nsep_notify_fd_epoll_wait_fail(struct eventpoll *ep);
+extern void custom_close_status(int fd, int status);
#define NSTACK_FUN_CHECK_RET(fdops, mod, fun) \
if (!(fdops) || !(fdops)->pf##fun) \
@@ -71,34 +83,40 @@
return -1; \
}
-#define NSTACK_DOMAIN_CHECK_RET(domainVal, fn, para) { \
- if ((domainVal != AF_INET) \
- && (domainVal != PF_INET)) \
- { \
- int _ret_ = 0; \
- if (nstack_fix_fd_check() && nstack_fix_fd_check()(-1, STACK_FD_FUNCALL_CHECK)) \
+#define NSTACK_DOMAIN_CHECK_RETURN(domainVal, fn, para) { \
+ if (domainVal != AF_INET && domainVal != PF_INET && \
+ domainVal != AF_INET6 && domainVal != PF_INET6) \
{ \
- NSTACK_CAL_FUN(nstack_fix_mid_ops(), fn, para, _ret_); \
+ int _ret_ = nsfw_base_socket para ; \
+ return _ret_; \
} \
- return _ret_; \
- } \
+ }
+
+#define NSTACK_ADDRINFO_CHECK_RETURN(flag, fn, para){\
+ if (1 == flag) \
+ {\
+ NSSOC_LOGINF("linux getaddrinfo [call]");\
+ return nsfw_base_##fn para ; \
+ }\
+}
+
+NSTACK_STATIC inline int support_kernel_fd()
+{
+#ifdef KERNEL_FD_SUPPORT
+ return 1;
+#else
+ return 0;
+#endif
}
-#define NSTACK_FD_LINUX_CHECK(fdVal, fn, fdInf, para) { \
- if (!(fdInf = nstack_getValidInf(fdVal))) \
+/* fork will close all fd(dont create by nstack) in continure,
+ which cause lots of log, here remove the log output */
+#define NSTACK_FD_LINUX_CHECK_RETURN(fdVal, fn, fdInf, para) { \
+ if (!(fdInf = nstack_get_valid_inf(fdVal))) \
{ \
- if (NSTACK_THREAD_LOADING()) \
- { \
- return nsfw_base_##fn para;\
- } \
- if (0 == nstack_stack_module_load()) \
- { \
- if (nstack_fix_fd_check() && nstack_fix_fd_check()(fdVal, STACK_FD_FUNCALL_CHECK)) \
- { \
- int _ret_ = 0; \
- NSTACK_CAL_FUN(nstack_fix_mid_ops(), fn, para, _ret_); \
- return _ret_; \
- } \
+ if ((support_kernel_fd()) && (fdVal != nsep_get_manager()->checkEpollFD)) \
+ { \
+ return nsfw_base_##fn para; \
} \
nstack_set_errno(ENOSYS); \
return -1; \
@@ -107,1540 +125,1913 @@
#define NSTACK_SELECT_LINUX_CHECK() (get_select_module()->inited)
-/* Supports multi-threaded and multi-process */
-NSTACK_STATIC inline void
-set_fd_status (int fd, FD_STATUS status)
+/* Support multi-threaded and multi-process */
+NSTACK_STATIC inline void set_fd_status(int fd, FD_STATUS status)
{
- nstack_fd_local_lock_info_t *local_lock = get_fd_local_lock_info (fd);
- if (local_lock)
+ nstack_fd_local_lock_info_t *local_lock = get_fd_local_lock_info(fd);
+ if (local_lock)
{
- if (FD_OPEN == status)
+ if (FD_OPEN == status)
{
- atomic_inc (&local_lock->fd_ref);
+ atomic_inc(&local_lock->fd_ref);
}
- local_lock->fd_status = status;
+ local_lock->fd_status = (int) status;
}
}
-void
-set_fd_status_lock_fork (int fd, FD_STATUS status)
+#define LOCK_SEND(fd, fd_inf, local_lock) \
+ u64_t tmp_in; /* use tmp_in to avoid statistic mistake from the lock acquiring */ \
+ NSTACK_GET_SYS_TICK(&tmp_in);\
+ INC_FD_REF_RETURN(fd, fd_inf, local_lock) \
+ NSTACK_FD_DFX_LAST_SEND_TICK_IN(fd, tmp_in)
+
+static inline void UNLOCK_SEND(int fd, nstack_fd_Inf * fdInf,
+ nstack_fd_local_lock_info_t * local_lock)
{
- common_mem_rwlock_read_lock (get_fork_lock ());
- set_fd_status (fd, status);
- common_mem_rwlock_read_unlock (get_fork_lock ());
+ u64_t tmp_out;
+ NSTACK_GET_SYS_TICK(&tmp_out);
+ NSTACK_FD_DFX_LAST_SEND_TICK_OUT(fd, tmp_out);
+ nstack_fd_dfx_update_dfx_data(fd, fdInf->rlfd, fdInf->rmidx,
+ DMM_STAT_LONGEST_SEND_COST, NULL);
+ if ((NULL != local_lock) && atomic_dec(&local_lock->fd_ref) == 0)
+ {
+ release_fd(fd, local_lock);
+ }
}
-/*****************************************************************
-Parameters : domain
- type
- protocol
-Return :
-Description : create a nstack fd for application
-*****************************************************************/
-int
-nstack_socket (int domain, int itype, int protocol)
+#define LOCK_RECV(fd, fd_inf, local_lock) \
+ u64_t tmp_in; /* use tmp_in to avoid statistic mistake from the lock acquiring */ \
+ NSTACK_GET_SYS_TICK(&tmp_in);\
+ LOCK_BASE_WITHOUT_KERNEL(fd, fd_inf, local_lock) \
+ NSTACK_FD_DFX_LAST_RECV_TICK_IN(fd, tmp_in)
+
+static inline void UNLOCK_RECV(int fd, nstack_fd_Inf * fdInf,
+ nstack_fd_local_lock_info_t * local_lock)
{
- int ret = -1; //tmp ret of a Single proctol mode.
- int modInx;
- nstack_socket_ops *ops;
- int ret_fd = -1;
- int protoFD[NSTACK_MAX_MODULE_NUM];
- int selectmod = -1;
-
- /*check whether module init finish or not */
- NSTACK_INIT_CHECK_RET (socket, domain, itype, protocol);
-
- NSSOC_LOGINF ("(domain=%d, type=%d, protocol=%d) [Caller]", domain, itype,
- protocol);
-
- /*if domain don't equal AF_INET , just call linux */
- NSTACK_DOMAIN_CHECK_RET (domain, socket, (domain, itype, protocol));
-
- nstack_each_modInx (modInx)
- {
- protoFD[modInx] = -1;
- }
-
- /*create the fix socket first, and check it wether ok */
- NSTACK_CAL_FUN (nstack_fix_mid_ops (), socket, (domain, itype, protocol),
- ret_fd);
- if (!nstack_is_nstack_sk (ret_fd))
- {
- if (ret_fd >= 0)
- {
- NSTACK_CAL_FUN (nstack_fix_mid_ops (), close, (ret_fd), ret);
- nstack_set_errno (EMFILE);
- }
- NSSOC_LOGERR
- ("[nstack_linux]domain=%d,type=%d protocol=%d linux fd=%d is too big and return fail [return]",
- domain, itype, protocol, ret_fd);
- return ns_fail;
- }
-
- protoFD[nstack_get_fix_mid ()] = ret_fd;
-
- nstack_fd_local_lock_info_t *lock_info = get_fd_local_lock_info (ret_fd);
- LOCK_FOR_EP (lock_info);
- /*create socket by calling select module or all module */
- nstack_each_modOps (modInx, ops)
- {
- if (modInx == nstack_get_fix_mid ())
- {
- continue;
- }
- /*if no module selected then create all or just create selected stack */
- if ((selectmod == -1) || (modInx == selectmod))
- {
- NSTACK_CAL_FUN (ops, socket, (domain, itype, protocol), ret);
- protoFD[modInx] = ret;
- NSSOC_LOGINF ("Create socket of]modName=%s:%d",
- nstack_get_module_name_by_idx (modInx),
- protoFD[modInx]);
- if ((modInx == selectmod) && (-1 == ret))
- {
- goto SOCKET_ERR;
- }
- }
- }
-
- /* alloc nstack fd info */
- nstack_fd_Inf *fdInf = nstack_lk_fd_alloc_with_kernel (ret_fd);
- if (NULL == fdInf)
- {
- /*if alloc failed */
- nstack_set_errno (EMFILE);
- NSSOC_LOGERR ("have no available nstack_fd_Inf [return]");
- goto SOCKET_ERR;
- }
-
- /*save the fd into fdinfo */
- fdInf->type = itype;
- nstack_each_modInx (modInx)
- {
- if (-1 != protoFD[modInx])
- {
- nstack_set_ret (fdInf, modInx, 0);
- nstack_set_protoFd (fdInf, modInx, protoFD[modInx]);
- nstack_set_app_info (fdInf, modInx);
- }
- }
- set_fd_status_lock_fork (ret_fd, FD_OPEN);
-
- /*if some stack was choose, just set the chose stack */
- if (-1 != selectmod)
- {
- fdInf->ops = nstack_module_ops (selectmod);
- nstack_set_router_protocol (fdInf, selectmod);
- nstack_set_routed_fd (fdInf, protoFD[selectmod]);
- }
- NSSOC_LOGINF ("create fix stack[%s] fd=%d,fdInf->fd=%d,ret=%d [return]",
- nstack_fix_stack_name (), ret_fd, fdInf->fd, ret_fd);
- UNLOCK_FOR_EP (lock_info);
- return ret_fd;
-
-SOCKET_ERR:
- nstack_each_modOps (modInx, ops)
- {
- if (-1 != protoFD[modInx])
- {
- NSTACK_CAL_FUN (ops, close, (protoFD[modInx]), ret);
- }
- }
- UNLOCK_FOR_EP (lock_info);
- return -1;
+ u64_t tmp_out;
+ NSTACK_GET_SYS_TICK(&tmp_out);
+ NSTACK_FD_DFX_LAST_RECV_TICK_OUT(fd, tmp_out);
+ nstack_fd_dfx_update_dfx_data(fd, fdInf->rlfd, fdInf->rmidx,
+ DMM_STAT_LONGEST_RECV_COST, NULL);
+ /*do not need return value */ UNLOCK_BASE(fd, fdInf, local_lock);
}
-/*****************************************************************
-Parameters : fd
- addr
- len
-Return :
-Description : the code of bind&listen are same, if there are another same api we should extract
-*****************************************************************/
-int
-nstack_bind (int fd, const struct sockaddr *addr, socklen_t addrlen)
+#define NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_SEND(fdVal, fun, inf, err, local_lock) \
+ /*do not need return value*/NSTACK_EPOLL_FD_CHECK_RET_UNLOCK(fdVal, fun, inf, err, local_lock, UNLOCK_SEND)
+
+#define NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_RECV(fdVal, fun, inf, err, local_lock) \
+ /*do not need return value*/NSTACK_EPOLL_FD_CHECK_RET_UNLOCK(fdVal, fun, inf, err, local_lock, UNLOCK_RECV)
+
+void set_fd_status_lock_fork(int fd, FD_STATUS status)
{
- nstack_fd_Inf *fdInf;
- int retval = ns_fail;
- int tem = -1;
- int modIdx = 0;
- int tfd;
- int selectmod = -1;
- struct sockaddr_in *iaddr = NULL;
- nstack_rd_key rdkey = { 0 };
+ dmm_read_lock(get_fork_lock());
+ set_fd_status(fd, status);
+ dmm_read_unlock(get_fork_lock());
+}
- NSTACK_INIT_CHECK_RET (bind, fd, addr, addrlen);
+/* Implemet aggregation packets send/receive. */
- NSSOC_LOGINF ("(sockfd=%d, addr=%p, addrlen=%u) [Caller]", fd, addr,
- addrlen);
+int nstack_create_kernel_socket()
+{
+ return nsfw_base_socket(AF_UNIX, SOCK_DGRAM, 0);
+}
- if (fd < 0)
- {
- nstack_set_errno (EBADF);
- NSSOC_LOGERR ("invalid input]fd=%d,addr=%p,len=0x%x [return]", fd, addr,
- addrlen);
- return -1;
- }
- if ((NULL == addr) || (addrlen < 2))
+int nstack_socket_create_index(int domain, int itype, int protocol,
+ rd_data_item * matched_item)
+{
+ int ret_fd;
+ if (nstack_rd_match_pre(domain, itype, protocol, matched_item) == -1)
{
- nstack_set_errno (EINVAL);
- NSSOC_LOGERR ("invalid input]fd=%d,addr=%p,len=0x%x [return]", fd, addr,
- addrlen);
- return -1;
+ return nsfw_base_socket(domain, itype, protocol);
}
- iaddr = (struct sockaddr_in *) addr;
- if ((addrlen >= sizeof (struct sockaddr_in))
- && ((addr->sa_family) == AF_INET))
+ //NSTACK_CAL_FUN(nstack_module_ops(matched_item.stack_id), socket, (domain, itype, protocol), ret_fd);
+ ret_fd = nstack_create_kernel_socket();
+
+ return ret_fd;
+}
+
+int nstack_socket(int domain, int itype, int protocol)
+{
+ int ret = -1; //tmp ret of a Single proctol mode.
+ int modInx;
+ nstack_socket_ops *ops;
+ int ret_fd = -1;
+ int protoFD[NSTACK_MAX_MODULE_NUM];
+ rd_data_item matched_item = {
+ .stack_id = -1
+ };
+
+ /*check whether module init finish or not */
+ NSTACK_INIT_CHECK_RET(socket, domain, itype, protocol);
+
+ NSSOC_LOGINF("(domain=%d, type=%d, protocol=%d) [Caller]", domain, itype,
+ protocol);
+
+#ifndef KERNEL_FD_SUPPORT
+ if (domain != AF_INET && domain != PF_INET && domain != AF_INET6)
{
- NSSOC_LOGINF ("fd=%d,addr=%s,port=%d", fd, inet_ntoa (iaddr->sin_addr),
- ntohs (iaddr->sin_port));
+ NSSOC_LOGERR("don't support the specified address family.]domain=%d",
+ domain);
+ nstack_set_errno(EAFNOSUPPORT);
+ return ns_fail;
}
- else
+
+ if (protocol < 0)
{
- NSSOC_LOGINF ("addrlen = %d ,fd=%d", (int) addrlen, fd);
+ nstack_set_errno(EINVAL);
+ return ns_fail;
}
+#endif
- NSTACK_FD_LINUX_CHECK (fd, bind, fdInf, (fd, addr, addrlen));
+ /*if domain don't equal AF_INET , just call linux */
+ NSTACK_DOMAIN_CHECK_RETURN(domain, socket, (domain, itype, protocol));
- nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
- LOCK_COMMON (fd, fdInf, local_lock);
+ /* if the socket is called by getaddrinfo, just call linux */
+ NSTACK_ADDRINFO_CHECK_RETURN(g_addrinfo_flag, socket,
+ (domain, itype, protocol));
- NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_COMMON (fd, bind, fdInf, ENOTSOCK,
- local_lock);
+ nstack_each_mod_inx(modInx)
+ {
+ protoFD[modInx] = -1;
+ }
- /*bind repeat, first time success, other return fail */
- if (fdInf->isBound)
+#ifdef KERNEL_FD_SUPPORT
+ /*firstly create linux fd, if create fail or fd is too big just return fail */
+ ret_fd =
+ nstack_socket_create_index(domain, itype, protocol, &matched_item);
+ if (-1 == ret_fd)
{
- nstack_set_errno (EINVAL);
- NSPOL_LOGERR ("error, already bind]fd=%d", fd);
- UNLOCK_COMMON (fd, local_lock);
- return -1;
+ NSSOC_LOGERR
+ ("[nstack_linux]domain=%d,type=%d protocol=%d create fail errno:%d [return]",
+ domain, itype, protocol, errno);
+ return ns_fail;
}
- /*just support af_inet and pf_inet */
- if (iaddr->sin_family != AF_INET && iaddr->sin_family != PF_INET)
+ /*linux fd is to big, return fail */
+ if (!nstack_is_nstack_sk(ret_fd))
{
- nstack_set_errno (EAFNOSUPPORT);
- NSSOC_LOGERR ("not surport]fd=%d,domain=%d,[return]", fd,
- iaddr->sin_family);
- UNLOCK_COMMON (fd, local_lock);
- return -1;
+ if (ret_fd >= 0)
+ {
+ nsfw_base_close(ret_fd); /*donot need return value */
+ }
+ nstack_set_errno(EMFILE);
+ NSSOC_LOGERR
+ ("[nstack_linux]domain=%d,type=%d protocol=%d linux fd=%d is too big and return fail [return]",
+ domain, itype, protocol, ret_fd);
+ return ns_fail;
}
- /* need check addrlen's validity, will visite iaddr->sin_addr.s_addr following code
- for visite iaddr->sin_addr.s_addr is 8 byte */
- if (addrlen < 8)
+ nstack_fd_local_lock_info_t *lock_info = get_fd_local_lock_info(ret_fd);
+ LOCK_FOR_EP(lock_info);
+
+ protoFD[nstack_get_linux_mid()] = ret_fd; // Set kernel fd here.
+#endif
+
+ /*create socket by calling every module */
+ nstack_each_mod_ops(modInx, ops)
{
- nstack_set_errno (EINVAL);
- NSPOL_LOGERR ("addrlen<sizeof(struct sockaddr_in)]addrlen=%u", addrlen);
- UNLOCK_COMMON (fd, local_lock);
- return -1;
+#ifdef KERNEL_FD_SUPPORT
+ if (modInx == nstack_get_linux_mid())
+ continue;
+#endif
+ NSTACK_CAL_FUN(ops, socket, (domain, itype, protocol), ret);
+ protoFD[modInx] = ret;
+ NSSOC_LOGINF("Create socket of]modName=%s:%d",
+ nstack_get_module_name_by_idx(modInx), protoFD[modInx]);
}
- /* for custom socket, choose stack after creating socket. */
- if (fdInf->ops)
+ /* alloc nstack fd info */
+#ifdef KERNEL_FD_SUPPORT
+ nstack_fd_Inf *fdInf = nstack_lk_fd_alloc_with_kernel(ret_fd);
+#else
+ nstack_fd_Inf *fdInf = nstack_lk_fd_alloc_without_kernel();
+#endif
+ if (NULL == fdInf)
{
- NSTACK_CAL_FUN (fdInf->ops, bind, (fdInf->rlfd, addr, addrlen), tem);
- if (ns_success == tem)
+ /*if alloc failed */
+ nstack_each_mod_ops(modInx, ops)
{
- retval = ns_success;
- nstack_set_bind_ret (fdInf, fdInf->rmidx, NSTACK_BIND_SUCCESS);
- }
- else
- {
- nstack_set_bind_ret (fdInf, fdInf->rmidx, NSTACK_BIND_FAIL);
+ if (-1 != protoFD[modInx])
+ {
+ NSTACK_CAL_FUN(ops, close, (protoFD[modInx]), ret);
+ }
}
- goto bind_over;
+
+ nstack_set_errno(EMFILE);
+ NSSOC_LOGERR("have no available nstack_fd_Inf [return]");
+#ifdef KERNEL_FD_SUPPORT
+ UNLOCK_FOR_EP(lock_info);
+#endif
+ return -1;
}
+#ifndef KERNEL_FD_SUPPORT
+ nstack_fd_local_lock_info_t *lock_info =
+ get_fd_local_lock_info(fdInf->fd);
+ LOCK_FOR_EP(lock_info);
+#endif
+ fdInf->type = itype;
+ fdInf->rd_opt = -1;
+ fdInf->rd_item.stack_id = -1;
- /*loop ip call linux */
- rdkey.type = RD_DATA_TYPE_IP;
- rdkey.ip_addr = iaddr->sin_addr.s_addr;
- retval = nstack_rd_get_stackid (&rdkey, &selectmod);
- if ((ns_success != retval) && (-1 != selectmod))
+ if (matched_item.stack_id != -1)
{
- NSSOC_LOGWAR ("fd Can't select any module for]fd=%d,IP==%s", fd,
- inet_ntoa ((iaddr->sin_addr)));
- selectmod = -1;
+ if (EOK !=
+ memcpy_s(&fdInf->rd_item, sizeof(rd_data_item), &matched_item,
+ sizeof(rd_data_item)))
+ {
+ NSSOC_LOGERR("memcpy_s failed!");
+ nstack_set_errno(EMFILE);
+ return -1;
+ }
}
- else
+ nstack_each_mod_inx(modInx)
{
- NSSOC_LOGINF ("fd addr Select module]fd=%d,addr=%s,module=%s",
- fd, inet_ntoa (iaddr->sin_addr),
- nstack_get_module_name_by_idx (selectmod));
- }
+#ifndef KERNEL_FD_SUPPORT
+ //if (modInx == nstack_get_linux_mid())
+ //continue;
+#endif
+ nstack_set_ret(fdInf, modInx, 0);
+ nstack_set_proto_fd(fdInf, modInx, protoFD[modInx]);
+ nstack_set_app_info(fdInf, modInx);
+ }
+
+#ifdef KERNEL_FD_SUPPORT
+ NSSOC_LOGINF("createfd=%d,fdInf->fd=%d,ret=%d [return]", ret_fd,
+ fdInf->fd, ret_fd);
+ set_fd_status_lock_fork(ret_fd, FD_OPEN);
+#else
+ NSSOC_LOGINF("fdInf->fd=%d,ret=%d [return]", fdInf->fd, fdInf->fd);
+ set_fd_status_lock_fork(fdInf->fd, FD_OPEN);
+ ret_fd = fdInf->fd;
+#endif
- if (selectmod == -1)
+#ifdef KERNEL_FD_SUPPORT
+ if (matched_item.stack_id != -1)
{
- rdkey.type = RD_DATA_TYPE_PROTO;
- rdkey.proto_type = fdInf->type;
- retval = nstack_rd_get_stackid (&rdkey, &selectmod);
- if ((0 != retval) || (selectmod < 0)
- || (selectmod >= nstack_get_modNum ()))
- {
- NSSOC_LOGWAR
- ("fd Can't select any module for]fd=%d,IP==%s using proto route",
- fd, inet_ntoa ((iaddr->sin_addr)));
- selectmod = -1;
- }
- else
+ switch (matched_item.type)
{
- NSSOC_LOGINF ("Bind socket of]select modName=%s",
- nstack_get_module_name_by_idx (selectmod));
+ case RD_DATA_TYPE_TYPE:
+ {
+ NSTACK_SET_FD_ATTR(fdInf, matched_item.type_data.attr);
+ break;
+ }
+ case RD_DATA_TYPE_PROTO:
+ {
+ NSTACK_SET_FD_ATTR(fdInf, matched_item.proto_data.attr);
+ break;
+ }
+ default:
+ break;
}
+ fdInf->ops = nstack_module_ops(matched_item.stack_id);
+ nstack_set_router_protocol(fdInf, matched_item.stack_id);
+ nstack_set_routed_fd(fdInf, protoFD[matched_item.stack_id]);
}
+#endif
- retval = -1;
- nstack_each_modInx (modIdx)
- {
- tfd = nstack_get_protoFd (fdInf, modIdx);
- if ((-1 == tfd) || (selectmod != modIdx)) // for INADDR_ANY, need try to bind on both stack-x and linux
- {
- /*tfd is -1, but is the select module */
- if (selectmod == modIdx)
- {
- retval = -1;
- nstack_set_errno (ENOSYS);
- NSSOC_LOGDBG
- ("fd tfd=-1, but is the select module]fd=%d,tfd=-1,modIdx=%d",
- fd, modIdx);
- }
- nstack_set_bind_ret (fdInf, modIdx, NSTACK_BIND_FAIL);
- continue;
- }
-
- NSTACK_CAL_FUN (nstack_module_ops (modIdx), bind, (tfd, addr, addrlen),
- tem);
+ UNLOCK_FOR_EP(lock_info);
+ return ret_fd;
+}
- if (ns_success == tem)
- {
- fdInf->ops = nstack_module_ops (modIdx);
- nstack_set_router_protocol (fdInf, modIdx);
- nstack_set_routed_fd (fdInf, tfd);
- retval = ns_success;
- nstack_set_bind_ret (fdInf, modIdx, NSTACK_BIND_SUCCESS);
- }
- else
- {
- NSSOC_LOGWAR ("bind fail]module=%s,fd=%d",
- nstack_get_module_name_by_idx (modIdx), tfd);
- nstack_set_bind_ret (fdInf, modIdx, NSTACK_BIND_FAIL);
- }
- }
+int nstack_get_stackid_by_name(char *stackname, int *stackid)
+{
+ int modIdx = 0;
- if (-1 == selectmod)
+ nstack_each_mod_inx(modIdx)
{
- nstack_set_errno (EINVAL);
- NSSOC_LOGERR ("failed for no module selected]fd=%d", fd);
+ /* params are not NULL */
+ if (strcmp(nstack_get_module_name_by_idx(modIdx), stackname) == 0)
+ {
+ *stackid = modIdx;
+ return ns_success;
+ }
}
+ return ns_fail;
+}
-bind_over:
- if (ns_success == retval)
+int nstack_get_stackid_by_opt(nstack_fd_Inf * fdInf, int *stackid)
+{
+ *stackid = (int) fdInf->rd_opt;
+ switch (fdInf->rd_opt)
{
- fdInf->isBound = 1;
+ case NSTACK_RD_OPT_KERNEL:
+ *stackid = nstack_get_linux_mid();
+ return ns_success;
+
+ case NSTACK_RD_OPT_STACKPOOL:
+ return nstack_get_stackid_by_name(RD_STACKPOOL_NAME, stackid);
+
+ default:
+ return ns_fail;
}
- NSSOC_LOGINF ("appfd=%d,prot_fd=%d,rmidx=%d, retVal=%d [return]", fd,
- fdInf->rlfd, fdInf->rmidx, retval);
- UNLOCK_COMMON (fd, local_lock);
- return retval;
}
-int
-nstack_listen (int fd, int backlog)
+int nstack_socket_get_stackid(nstack_fd_Inf * fdInf,
+ const struct sockaddr *addr, socklen_t addrlen)
{
- nstack_fd_Inf *fdInf;
- int retval = -1;
- int tem = -1;
- int modIdx = 0;
- int tfd;
- int func_called = 0;
-
- NSTACK_INIT_CHECK_RET (listen, fd, backlog);
-
- NSSOC_LOGINF ("(sockfd=%d, backlog=%d) [Caller]", fd, backlog);
- if (fd < 0)
- {
- nstack_set_errno (EBADF);
- NSSOC_LOGERR ("invalid input]fd=%d,backlog=%d [return]", fd, backlog);
- return -1;
- }
-
- NSTACK_FD_LINUX_CHECK (fd, listen, fdInf, (fd, backlog));
-
- nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
- LOCK_COMMON (fd, fdInf, local_lock);
- NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_COMMON (fd, listen, fdInf, ENOTSOCK,
- local_lock);
-
- /*listen:use all mode we support */
- nstack_each_modInx (modIdx)
- {
- tfd = nstack_get_protoFd (fdInf, modIdx);
-
- if ((-1 == tfd)
- || (NSTACK_BIND_FAIL == nstack_get_bind_ret (fdInf, modIdx)))
- {
- continue;
- }
-
- func_called = 1;
- NSTACK_CAL_FUN (nstack_module_ops (modIdx), listen, (tfd, backlog), tem);
- if (ns_success == tem)
- {
- nstack_set_listen_state (fdInf, modIdx, NSTACK_LISTENING);
- NSTACK_SET_FD_LISTEN_SOCKET (fdInf);
- retval = ns_success;
- nstack_set_listen_ret (fdInf, modIdx, NSTACK_LISTEN_SUCCESS);
- }
+
+ nstack_rd_key rdkey = { 0 };
+
+ if (fdInf->rd_opt != -1)
+ {
+ return nstack_get_stackid_by_opt(fdInf, &fdInf->rd_item.stack_id);
+ }
+
+ if (addr->sa_family == AF_INET)
+ {
+ rdkey.type = RD_DATA_TYPE_IP;
+ rdkey.ip_addr = ((struct sockaddr_in *) addr)->sin_addr.s_addr;
+ }
+ else if (addr->sa_family == AF_INET6)
+ {
+ rdkey.type = RD_DATA_TYPE_IP6;
+ rdkey.in6_addr = ((struct sockaddr_in6 *) addr)->sin6_addr;
+ }
else
- {
- NSSOC_LOGWAR ("listen fail]fd=%d,module=%s,tfd=%d", fd,
- nstack_get_module_name_by_idx (modIdx), tfd);
- nstack_set_listen_ret (fdInf, modIdx, NSTACK_LISTEN_FAIL);
- nstack_set_listen_state (fdInf, modIdx, NSTACK_NO_LISTENING);
- }
- }
+ {
+ rdkey.type = RD_DATA_TYPE_MAX;
+ }
- if (0 == func_called)
+ if (rdkey.type == RD_DATA_TYPE_MAX)
{
- retval = -1;
- nstack_set_errno (ENOSYS);
- NSSOC_LOGERR ("listen fail for no module called]fd=%d", fd);
+ fdInf->rd_item.stack_id = nstack_get_linux_mid();
+ return ns_success;
}
- NSSOC_LOGINF ("fd=%d,ret=%d [return]", fd, retval);
- UNLOCK_COMMON (fd, local_lock);
- return retval;
+ return nstack_rd_get_stackid(&rdkey, &fdInf->rd_item);
}
-int
-nstack_accept (int fd, struct sockaddr *addr, socklen_t * addr_len)
+int nstack_bind(int fd, const struct sockaddr *addr, socklen_t addrlen)
{
- nstack_fd_Inf *apstfdInf = NULL;
- int tfd = -1;
- int accfd = -1;
- int fix_fd;
- int ret_fd = -1;
- nstack_fd_Inf *accInf;
- int ret = -1;
+ nstack_fd_Inf *fdInf;
+ int retval = ns_fail;
+ int tem = -1;
+ int modIdx = 0;
+ int tfd;
+ nstack_rd_key rdkey = { 0 };
- NSTACK_INIT_CHECK_RET (accept, fd, addr, addr_len);
+ NSTACK_INIT_CHECK_RET(bind, fd, addr, addrlen);
- NSSOC_LOGINF ("(sockfd=%d, addr=%p, addrlen=%p) [Caller]", fd, addr,
- addr_len);
- if (fd < 0)
+ NSSOC_LOGINF("(sockfd=%d, addr=%p, addrlen=%u) [Caller]", fd, addr,
+ addrlen);
+
+ if (fd < 0)
{
- nstack_set_errno (EBADF);
- NSSOC_LOGERR ("fd is invalid]fd=%d [return]", fd);
- return -1;
+ nstack_set_errno(EBADF);
+ NSSOC_LOGERR("invalid input]fd=%d,addr=%p,len=0x%x [return]", fd,
+ addr, addrlen);
+ return -1;
+ }
+ if ((NULL == addr) || (addrlen < 2))
+ {
+ nstack_set_errno(EINVAL);
+ NSSOC_LOGERR("invalid input]fd=%d,addr=%p,len=0x%x [return]", fd,
+ addr, addrlen);
+ return -1;
}
- NSTACK_FD_LINUX_CHECK (fd, accept, apstfdInf, (fd, addr, addr_len));
- nstack_fd_local_lock_info_t *local_lock = &apstfdInf->local_lock;
- LOCK_ACCEPT (fd, apstfdInf, local_lock);
- NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_ACCEPT (fd, accept, apstfdInf, ENOTSOCK,
- local_lock);
+ /*avoid access to iaddr memory */
+ /*miss the condition about sockaddr_un,and get wrong value */
+ if ((addrlen >= sizeof(struct sockaddr_in))
+ && ((addr->sa_family) == AF_INET))
+ {
+ struct sockaddr_in *iaddr = (struct sockaddr_in *) addr;
+ NSSOC_LOGINF("fd=%d,addr=*.*.%u.%u,port=%d", fd,
+ FUZZY_IP_VAR(&iaddr->sin_addr), ntohs(iaddr->sin_port));
+ }
+ else if ((addrlen >= sizeof(struct sockaddr_in6))
+ && ((addr->sa_family) == AF_INET6))
+ {
+ struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *) addr;
+ NSSOC_LOGINF("fd=%d,addr=%s,port=%u", fd,
+ inet6_ntoa(&addr6->sin6_addr), htons(addr6->sin6_port));
+ }
+ else
+ {
+ NSSOC_LOGINF("addrlen = %d ,fd=%d", (int) addrlen, fd);
+ }
- if (addr)
+ NSTACK_FD_LINUX_CHECK_RETURN(fd, bind, fdInf, (fd, addr, addrlen));
+
+ nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
+ LOCK_COMMON(fd, fdInf, local_lock);
+
+ NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_COMMON(fd, bind, fdInf, ENOTSOCK,
+ local_lock);
+
+ /*bind repeat, first time success, other return fail */
+ if (fdInf->isBound)
{
- if ((!addr_len) || (*addr_len == NSTACK_MAX_U32_NUM))
- {
- nstack_set_errno (EINVAL);
- NSSOC_LOGERR ("addr_len input error [return]");
- UNLOCK_ACCEPT (fd, local_lock);
- return -1;
- }
+ nstack_set_errno(EINVAL);
+ NSPOL_LOGERR("error, alread bind]fd=%d", fd);
+ UNLOCK_COMMON(fd, fdInf, local_lock);
+ return -1;
}
- /*if no module select or listen / bind fail, just return fail */
- if ((!apstfdInf->ops)
- || (NSTACK_LISTEN_FAIL ==
- nstack_get_listen_ret (apstfdInf, apstfdInf->rmidx))
- || (NSTACK_BIND_FAIL ==
- nstack_get_bind_ret (apstfdInf, apstfdInf->rmidx)))
+ /*just support af_inet and pf_inet */
+ if (addr->sa_family != AF_INET && addr->sa_family != PF_INET
+ && addr->sa_family != AF_INET6)
{
- nstack_set_errno (EINVAL);
- NSSOC_LOGERR
- ("nstack accept fd=%d no module select, or bind/listen fail [return]",
- fd);
- UNLOCK_ACCEPT (fd, local_lock);
- return -1;
+ nstack_set_errno(EAFNOSUPPORT);
+ NSSOC_LOGERR("not surport]fd=%d,domain=%d,[return]", fd,
+ addr->sa_family);
+ UNLOCK_COMMON(fd, fdInf, local_lock);
+ return -1;
}
- tfd = nstack_get_protoFd (apstfdInf, apstfdInf->rmidx);
- NSTACK_CAL_FUN (nstack_module_ops (apstfdInf->rmidx), accept,
- (tfd, addr, addr_len), accfd);
- NSSOC_LOGINF ("nstack fd=%d:%d accept fd=%d from module=%s", fd, tfd, accfd,
- nstack_get_module_name_by_idx (apstfdInf->rmidx));
- if (-1 == accfd)
+
+ /* need check addrlen's validity, will visite iaddr->sin_addr.s_addr following code
+ for visite iaddr->sin_addr.s_addr is 8 byte */
+ if (addrlen < 8)
{
- if (errno != EAGAIN)
+ nstack_set_errno(EINVAL);
+ NSPOL_LOGERR("addrlen<sizeof(struct sockaddr_in)]addrlen=%u",
+ addrlen);
+ UNLOCK_COMMON(fd, fdInf, local_lock);
+ return -1;
+ }
+
+ /* for custom socket, choose stack after creating socket. */
+ if (fdInf->ops)
+ {
+ NSTACK_CAL_FUN(fdInf->ops, bind, (fdInf->rlfd, addr, addrlen), tem);
+ if (ns_success == tem)
+ {
+ retval = ns_success;
+ nstack_set_bind_ret(fdInf, fdInf->rmidx, NSTACK_BIND_SUCCESS);
+ }
+ else
{
- NSSOC_LOGERR ("appfd=%d,module=%s,ret=%d,errno=%d [return]", fd,
- nstack_get_module_name_by_idx (apstfdInf->rmidx),
- accfd, errno);
+ nstack_set_bind_ret(fdInf, fdInf->rmidx, NSTACK_BIND_FAIL);
}
- UNLOCK_ACCEPT (fd, local_lock);
- return -1;
+ goto bind_over;
}
- // If it is not from kernel, need to create one kernel socket
- if (apstfdInf->rmidx != nstack_get_fix_mid ())
+ if (fdInf->rd_opt != -1)
{
- /*err num is same with linux */
- fix_fd = nstack_extern_deal (nstack_get_fix_mid ()).stack_alloc_fd ();
- if (fix_fd < 0)
+ retval = nstack_get_stackid_by_opt(fdInf, &fdInf->rd_item.stack_id);
+ if (ns_success != retval)
+ {
+ NSSOC_LOGWAR
+ ("fd Can't select any module by opt for]fd=%d,opt=%d", fd,
+ fdInf->rd_opt);
+ fdInf->rd_item.stack_id = -1;
+ }
+ else
{
- NSSOC_LOGERR
- ("nstack accept fd=%d return fd=%d kernelFD fd create fail [return]",
- fd, accfd);
- NSTACK_CAL_FUN (nstack_module_ops (apstfdInf->rmidx), close,
- (accfd), ret);
- UNLOCK_ACCEPT (fd, local_lock);
- return -1;
+ NSSOC_LOGINF("fd opt Select module]fd=%d,opt=%d,module=%s",
+ fd, fdInf->rd_opt,
+ nstack_get_module_name_by_idx(fdInf->
+ rd_item.stack_id));
}
}
- else
+ else
{
- fix_fd = accfd;
+ if (addr->sa_family == AF_INET)
+ {
+ struct sockaddr_in *iaddr = (struct sockaddr_in *) addr;
+ /*loop ip call linux */
+ if (NSTACK_LOOP_IP == iaddr->sin_addr.s_addr)
+ {
+ fdInf->rd_item.stack_id = nstack_get_linux_mid();
+ }
+ /*any ip call defaul mod */
+ else if (NSTACK_ANY_IP == iaddr->sin_addr.s_addr)
+ {
+ fdInf->rd_item.stack_id = nstack_defmod_inx();
+ }
+ else
+ {
+ rdkey.type = RD_DATA_TYPE_IP;
+ rdkey.ip_addr = iaddr->sin_addr.s_addr;
+ retval = nstack_rd_get_stackid(&rdkey, &fdInf->rd_item);
+ if (ns_success != retval)
+ {
+ NSSOC_LOGWAR
+ ("fd Can't select any module for]fd=%d,IP=*.*.%u.%u",
+ fd, FUZZY_IP_VAR(&iaddr->sin_addr));
+ }
+ else
+ {
+ NSSOC_LOGINF
+ ("fd addr Select module]fd=%d,addr=*.*.%u.%u,module=%s",
+ fd, FUZZY_IP_VAR(&iaddr->sin_addr),
+ nstack_get_module_name_by_idx(fdInf->
+ rd_item.stack_id));
+ }
+ }
+ }
+ else if (addr->sa_family == AF_INET6)
+ {
+ struct in6_addr *in6 = &((struct sockaddr_in6 *) addr)->sin6_addr;
+
+ /*loop ip call linux */
+ if (IN6_IS_ADDR_LOOPBACK(in6))
+ {
+ fdInf->rd_item.stack_id = nstack_get_linux_mid();
+ }
+ /*any ip call defaul mod */
+ else if (IN6_IS_ADDR_UNSPECIFIED(in6))
+ {
+ fdInf->rd_item.stack_id = nstack_get_linux_mid();
+ }
+ else
+ {
+ rdkey.type = RD_DATA_TYPE_IP6;
+ rdkey.in6_addr = *in6;
+ retval = nstack_rd_get_stackid(&rdkey, &fdInf->rd_item);
+ if (ns_success != retval)
+ {
+ NSSOC_LOGWAR
+ ("fd Can't select any module for]fd=%d,IP==%s", fd,
+ inet6_ntoa(in6));
+ }
+ else
+ {
+ NSSOC_LOGINF
+ ("fd addr Select module]fd=%d,addr=%s,module=%s", fd,
+ inet6_ntoa(in6),
+ nstack_get_module_name_by_idx(fdInf->
+ rd_item.stack_id));
+ }
+ }
+ }
+ else
+ {
+ fdInf->rd_item.stack_id = nstack_get_linux_mid();
+ }
}
- if (fix_fd >= (int) NSTACK_KERNEL_FD_MAX)
+ retval = -1;
+ nstack_each_mod_inx(modIdx)
{
- /* nstack not support kernel fd >= NSTACK_MAX_SOCK_NUM.
- * close it and nstack_accept() return failed
- */
- NSSOC_LOGERR ("kernelFD fd too big, close it. kernelFD=%d [return]",
- accfd);
- NSTACK_CAL_FUN (nstack_module_ops (apstfdInf->rmidx), close, (accfd),
- ret);
- if (apstfdInf->rmidx != nstack_get_fix_mid ())
+ tfd = nstack_get_proto_fd(fdInf, modIdx);
+ if ((-1 == tfd) || (fdInf->rd_item.stack_id != modIdx)) // for INADDR_ANY, need try to bind on both lwip and linux
+ {
+ /*tfd is -1, but is the select module */
+ if (fdInf->rd_item.stack_id == modIdx)
+ {
+ retval = -1;
+ nstack_set_errno(ENOSYS);
+ NSSOC_LOGDBG
+ ("fd tfd=-1, but is the select module]fd=%d,tfd=-1,modIdx=%d",
+ fd, modIdx);
+ }
+ nstack_set_bind_ret(fdInf, modIdx, NSTACK_BIND_FAIL);
+ continue;
+ }
+
+ NSTACK_CAL_FUN(nstack_module_ops(modIdx), bind,
+ (tfd, addr, addrlen), tem);
+
+ if (ns_success == tem)
+ {
+ fdInf->ops = nstack_module_ops(modIdx);
+ nstack_set_router_protocol(fdInf, modIdx); /*do not need return value */
+ nstack_set_routed_fd(fdInf, tfd); /*do not need return value */
+ retval = ns_success;
+ nstack_set_bind_ret(fdInf, modIdx, NSTACK_BIND_SUCCESS);
+ }
+ else
{
- NSTACK_CAL_FUN (nstack_fix_mid_ops (), close, (fix_fd), ret);
+ NSSOC_LOGWAR("bind fail]module=%s,fd=%d",
+ nstack_get_module_name_by_idx(modIdx), tfd);
+ nstack_set_bind_ret(fdInf, modIdx, NSTACK_BIND_FAIL);
}
- nstack_set_errno (EMFILE);
- UNLOCK_ACCEPT (fd, local_lock);
- return -1;
}
- nstack_fd_local_lock_info_t *lock_info = get_fd_local_lock_info (fix_fd);
- LOCK_FOR_EP (lock_info);
+ if (-1 == fdInf->rd_item.stack_id)
+ {
+ nstack_set_errno(EINVAL);
+ NSSOC_LOGERR("failed for no module selected]fd=%d", fd);
+ }
- accInf = nstack_lk_fd_alloc_with_kernel (fix_fd);
- ret_fd = fix_fd;
+ bind_over:
+ if (ns_success == retval)
+ {
+ fdInf->isBound = 1;
+ }
+ NSSOC_LOGINF("appfd=%d,prot_fd=%d,rmidx=%d, retVal=%d [return]", fd,
+ fdInf->rlfd, fdInf->rmidx, retval);
+ UNLOCK_COMMON(fd, fdInf, local_lock);
+ return retval;
+}
- if (NULL == accInf)
+int nstack_listen(int fd, int backlog)
+{
+ nstack_fd_Inf *fdInf;
+ int retval = -1;
+ int tem = -1;
+ int modIdx = 0;
+ int tfd;
+ int func_called = 0;
+
+ NSTACK_INIT_CHECK_RET(listen, fd, backlog);
+
+ NSSOC_LOGINF("(sockfd=%d, backlog=%d) [Caller]", fd, backlog);
+ if (fd < 0)
{
- NSSOC_LOGERR ("Can't alloc nstack fdInf [return]");
- NSTACK_CAL_FUN (nstack_module_ops (apstfdInf->rmidx), close, (accfd),
- ret);
- if (apstfdInf->rmidx != nstack_get_fix_mid ())
+ nstack_set_errno(EBADF);
+ NSSOC_LOGERR("invalid input]fd=%d,backlog=%d [return]", fd, backlog);
+ return -1;
+ }
+
+ NSTACK_FD_LINUX_CHECK_RETURN(fd, listen, fdInf, (fd, backlog));
+
+ nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
+ LOCK_COMMON(fd, fdInf, local_lock);
+
+ NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_COMMON(fd, listen, fdInf, ENOTSOCK,
+ local_lock);
+
+ /*listen:use all mode we support */
+ nstack_each_mod_inx(modIdx)
+ {
+ tfd = nstack_get_proto_fd(fdInf, modIdx);
+
+ if ((-1 == tfd)
+ || (NSTACK_BIND_FAIL == nstack_get_bind_ret(fdInf, modIdx)))
{
- NSTACK_CAL_FUN (nstack_fix_mid_ops (), close, (fix_fd), ret);
+ continue;
}
- UNLOCK_FOR_EP (lock_info);
- nstack_set_errno (EMFILE);
- UNLOCK_ACCEPT (fd, local_lock);
- return -1;
+ func_called = 1;
+ NSTACK_CAL_FUN(nstack_module_ops(modIdx), listen, (tfd, backlog),
+ tem);
+ if (ns_success == tem)
+ {
+ nstack_set_listen_state(fdInf, modIdx, NSTACK_LISENING);
+ NSTACK_SET_FD_LISTEN_SOCKET(fdInf);
+ retval = ns_success;
+ nstack_set_listen_ret(fdInf, modIdx, NSTACK_LISTEN_SUCCESS);
+ }
+ else
+ {
+ NSSOC_LOGWAR("listen fail]fd=%d,module=%s,tfd=%d", fd,
+ nstack_get_module_name_by_idx(modIdx), tfd);
+ nstack_set_listen_ret(fdInf, modIdx, NSTACK_LISTEN_FAIL);
+ nstack_set_listen_state(fdInf, modIdx, NSTACK_NO_LISENING);
+ }
}
- nstack_set_routed_fd (accInf, accfd);
- accInf->ops = nstack_module_ops (apstfdInf->rmidx);
- /*do not include SOCK_CLOEXEC SOCK_NONBLOCK */
- accInf->type =
- apstfdInf->type & (~((ns_int32) SOCK_CLOEXEC | (ns_int32) SOCK_NONBLOCK));
- nstack_set_router_protocol (accInf, apstfdInf->rmidx);
- nstack_set_protoFd (accInf, apstfdInf->rmidx, accfd);
- nstack_set_app_info (accInf, apstfdInf->rmidx);
- /* Set the linux kernel fd also in accInf for kernel module (0) */
- if (apstfdInf->rmidx != nstack_get_fix_mid ())
+ if (0 == func_called)
{
- nstack_set_protoFd (accInf, nstack_get_fix_mid (), fix_fd);
+ retval = -1;
+ nstack_set_errno(ENOSYS);
+ NSSOC_LOGERR("listen fail for no module called]fd=%d", fd);
}
- NSSOC_LOGINF ("listenfd=%d,acceptfd=%d,module=%s(rlfd=%d),ret=%d [return]",
- fd, ret_fd, nstack_get_module_name_by_idx (apstfdInf->rmidx),
- accfd, ret_fd);
- set_fd_status_lock_fork (ret_fd, FD_OPEN);
- UNLOCK_FOR_EP (lock_info);
- UNLOCK_ACCEPT (fd, local_lock);
- return ret_fd;
+ NSSOC_LOGINF("fd=%d,ret=%d [return]", fd, retval);
+ UNLOCK_COMMON(fd, fdInf, local_lock);
+ return retval;
}
-int
-nstack_accept4 (int fd, struct sockaddr *addr,
- socklen_t * addr_len, int flags)
+int nstack_accept(int fd, struct sockaddr *addr, socklen_t * addr_len)
{
- nstack_fd_Inf *pstfdInf = NULL;
- int tfd = -1;
- int accfd = -1;
- int fix_fd = -1;
- int ret_fd = -1;
- int ret = -1;
- nstack_fd_Inf *accInf;
+ nstack_fd_Inf *apstfdInf = NULL;
+ int tfd = -1;
+ int accfd = -1;
+#ifdef KERNEL_FD_SUPPORT
+ int kernelFD;
+#endif
+ int ret_fd = -1;
+ nstack_fd_Inf *accInf;
+ int ret = -1;
- NSTACK_INIT_CHECK_RET (accept4, fd, addr, addr_len, flags);
+ NSTACK_INIT_CHECK_RET(accept, fd, addr, addr_len);
- NSSOC_LOGINF ("(sockfd=%d, addr=%p, addrlen=%p, flags=%d) [Caller]", fd,
- addr, addr_len, flags);
- if (fd < 0)
+ NSSOC_LOGINF("(sockfd=%d, addr=%p, addrlen=%p) [Caller]", fd, addr,
+ addr_len);
+ if (fd < 0)
{
- nstack_set_errno (EBADF);
- NSSOC_LOGERR ("nstack accept4,fd=%d invalid [return]", fd);
- return -1;
+ nstack_set_errno(EBADF);
+ NSSOC_LOGERR("fd is invalid]fd=%d [return]", fd);
+ return -1;
}
- NSTACK_FD_LINUX_CHECK (fd, accept4, pstfdInf, (fd, addr, addr_len, flags));
+ NSTACK_FD_LINUX_CHECK_RETURN(fd, accept, apstfdInf, (fd, addr, addr_len));
- nstack_fd_local_lock_info_t *local_lock = &pstfdInf->local_lock;
- LOCK_ACCEPT (fd, pstfdInf, local_lock);
- NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_ACCEPT (fd, accept4, pstfdInf, ENOTSOCK,
- local_lock);
+ nstack_fd_local_lock_info_t *local_lock = &apstfdInf->local_lock;
+ LOCK_ACCEPT(fd, apstfdInf, local_lock);
- if (addr)
+ NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_ACCEPT(fd, accept, apstfdInf, ENOTSOCK,
+ local_lock);
+
+ if (addr)
{
- if ((!addr_len) || (*addr_len == NSTACK_MAX_U32_NUM))
+ if ((!addr_len) || (*addr_len == NSTACK_MAX_U32_NUM))
{
- nstack_set_errno (EINVAL);
- NSSOC_LOGERR ("nstack accept4 addr_len input error [return]");
- UNLOCK_ACCEPT (fd, local_lock);
- return -1;
+ nstack_set_errno(EINVAL);
+ NSSOC_LOGERR("addr_len inpurt error [return]");
+ UNLOCK_ACCEPT(fd, apstfdInf, local_lock);
+ return -1;
}
}
- /*if no module select or listen / bind fail, just return fail */
- if ((!pstfdInf->ops)
- || (NSTACK_LISTEN_FAIL ==
- nstack_get_listen_ret (pstfdInf, pstfdInf->rmidx))
- || (NSTACK_BIND_FAIL ==
- nstack_get_bind_ret (pstfdInf, pstfdInf->rmidx)))
+ /*if no module select or listen / bind fail, just return fail */
+ if ((!apstfdInf->ops)
+ || (NSTACK_LISTEN_FAIL ==
+ nstack_get_listen_ret(apstfdInf, apstfdInf->rmidx))
+ || (NSTACK_BIND_FAIL ==
+ nstack_get_bind_ret(apstfdInf, apstfdInf->rmidx)))
+ {
+ nstack_set_errno(EINVAL);
+ NSSOC_LOGERR
+ ("nstack accept fd=%d no mudle select, or bind/listen fail [return]",
+ fd);
+ UNLOCK_ACCEPT(fd, apstfdInf, local_lock);
+ return -1;
+ }
+ tfd = nstack_get_proto_fd(apstfdInf, apstfdInf->rmidx);
+ NSTACK_CAL_FUN(nstack_module_ops(apstfdInf->rmidx), accept,
+ (tfd, addr, addr_len), accfd);
+ NSSOC_LOGINF("nstack fd=%d:%d accept fd=%d from module=%s", fd, tfd,
+ accfd, nstack_get_module_name_by_idx(apstfdInf->rmidx));
+ if (-1 == accfd)
+ {
+ if (errno != EAGAIN)
+ {
+ NSSOC_LOGERR("appfd=%d,module=%s,ret=%d,errno=%d [return]", fd,
+ nstack_get_module_name_by_idx(apstfdInf->rmidx),
+ accfd, errno);
+ }
+ UNLOCK_ACCEPT(fd, apstfdInf, local_lock);
+ return -1;
+ }
+
+#ifdef KERNEL_FD_SUPPORT
+ // If it is not from kernel, need to create one kernel socket
+ if (apstfdInf->rmidx != nstack_get_linux_mid())
+ {
+ /*err num is same with linux */
+ kernelFD = nstack_create_kernel_socket();
+ if (kernelFD < 0)
+ {
+ NSSOC_LOGERR
+ ("nstack accept fd=%d return fd=%d kernelFD fd create fail [return]",
+ fd, accfd);
+ NSTACK_CAL_FUN(nstack_module_ops(apstfdInf->rmidx), close,
+ (accfd), ret);
+ UNLOCK_ACCEPT(fd, apstfdInf, local_lock);
+ return -1;
+ }
+ }
+ else
{
- nstack_set_errno (EINVAL);
- NSSOC_LOGERR
- ("nstack accept4 fd:%d no module select, or bind/listen fail [return]",
- fd);
- UNLOCK_ACCEPT (fd, local_lock);
- return -1;
+ kernelFD = accfd;
}
- tfd = nstack_get_protoFd (pstfdInf, pstfdInf->rmidx);
- NSTACK_CAL_FUN (nstack_module_ops (pstfdInf->rmidx), accept4,
- (tfd, addr, addr_len, flags), accfd);
- if (-1 == accfd)
+ if (kernelFD >= (int) NSTACK_KERNEL_FD_MAX)
{
- if (errno != EAGAIN)
+ /* nstack not support kernel fd >= NSTACK_MAX_SOCK_NUM.
+ * close it and nstack_accept() return failed
+ */
+ NSSOC_LOGERR("kernelFD fd too big, close it. kernelFD=%d [return]",
+ accfd);
+
+ NSTACK_CAL_FUN(nstack_module_ops(apstfdInf->rmidx), close, (accfd),
+ ret);
+ if (apstfdInf->rmidx != nstack_get_linux_mid())
{
- NSSOC_LOGERR ("appfd=%d,module=%s,ret=%d,errno=%d [return]", fd,
- nstack_get_module_name_by_idx (pstfdInf->rmidx),
- accfd, errno);
+
+ NSTACK_CAL_FUN(nstack_module_ops(nstack_get_linux_mid()),
+ close, (kernelFD), ret);
}
- UNLOCK_ACCEPT (fd, local_lock);
- return -1;
+ nstack_set_errno(EMFILE);
+ UNLOCK_ACCEPT(fd, apstfdInf, local_lock);
+ return -1;
}
- // If it is not from kernel, need to create one kernel socket
- if (pstfdInf->rmidx != nstack_get_fix_mid ())
+ nstack_fd_local_lock_info_t *lock_info = get_fd_local_lock_info(kernelFD);
+ LOCK_FOR_EP(lock_info);
+
+ accInf = nstack_lk_fd_alloc_with_kernel(kernelFD);
+ ret_fd = kernelFD;
+#else
+ accInf = nstack_lk_fd_alloc_without_kernel();
+#endif
+
+ if (NULL == accInf)
{
- fix_fd = nstack_extern_deal (nstack_get_fix_mid ()).stack_alloc_fd ();
+ NSSOC_LOGERR("Can't alloc nstack fdInf [return]");
+
+ NSTACK_CAL_FUN(nstack_module_ops(apstfdInf->rmidx), close, (accfd),
+ ret);
+#ifdef KERNEL_FD_SUPPORT
+ if (apstfdInf->rmidx != nstack_get_linux_mid())
+ {
+
+ NSTACK_CAL_FUN(nstack_module_ops(nstack_get_linux_mid()),
+ close, (kernelFD), ret);
+ }
+ UNLOCK_FOR_EP(lock_info);
+#endif
+ nstack_set_errno(EMFILE);
+ UNLOCK_ACCEPT(fd, apstfdInf, local_lock);
+
+ return -1;
+ }
+
+#ifndef KERNEL_FD_SUPPORT
+ nstack_fd_local_lock_info_t *lock_info =
+ get_fd_local_lock_info(accInf->fd);
+ ret_fd = accInf->fd;
+ LOCK_FOR_EP(lock_info);
+#endif
+
+ nstack_set_routed_fd(accInf, accfd); /*do not need return value */
+ accInf->ops = nstack_module_ops(apstfdInf->rmidx);
+ /*donot include SOCK_CLOEXEC SOCK_NONBLOCK */
+ accInf->type =
+ apstfdInf->type &
+ (~((ns_int32) SOCK_CLOEXEC | (ns_int32) SOCK_NONBLOCK));
+ nstack_set_router_protocol(accInf, apstfdInf->rmidx); /*do not need return value */
+ nstack_set_proto_fd(accInf, apstfdInf->rmidx, accfd);
+ nstack_set_app_info(accInf, apstfdInf->rmidx);
+ /* Set the linux kernel fd also in accInf for kernel module (0) */
+#ifdef KERNEL_FD_SUPPORT
+ if (apstfdInf->rmidx != nstack_get_linux_mid())
+ {
+ nstack_set_proto_fd(accInf, nstack_get_linux_mid(), kernelFD);
}
- else
+#endif
+ NSSOC_LOGINF
+ ("listenfd=%d,acceptfd=%d,module=%s(rlfd=%d),ret=%d [return]", fd,
+ ret_fd, nstack_get_module_name_by_idx(apstfdInf->rmidx), accfd,
+ ret_fd);
+
+ set_fd_status_lock_fork(ret_fd, FD_OPEN);
+ UNLOCK_FOR_EP(lock_info);
+ UNLOCK_ACCEPT(fd, apstfdInf, local_lock);
+ return ret_fd;
+}
+
+int nstack_accept4(int fd, struct sockaddr *addr,
+ socklen_t * addr_len, int flags)
+{
+ nstack_fd_Inf *pstfdInf = NULL;
+ int tfd = -1;
+ int accfd = -1;
+#ifdef KERNEL_FD_SUPPORT
+ int kernelFD = -1;
+#endif
+ int ret_fd = -1;
+ int ret = -1;
+ nstack_fd_Inf *accInf;
+
+ NSTACK_INIT_CHECK_RET(accept4, fd, addr, addr_len, flags);
+
+ NSSOC_LOGINF("(sockfd=%d, addr=%p, addrlen=%p, flags=%d) [Caller]", fd,
+ addr, addr_len, flags);
+ if (fd < 0)
{
- fix_fd = accfd;
+ nstack_set_errno(EBADF);
+ NSSOC_LOGERR("nstack accept4,fd=%d invalid [return]", fd);
+ return -1;
}
+ NSTACK_FD_LINUX_CHECK_RETURN(fd, accept4, pstfdInf,
+ (fd, addr, addr_len, flags));
+
+ nstack_fd_local_lock_info_t *local_lock = &pstfdInf->local_lock;
+ LOCK_ACCEPT(fd, pstfdInf, local_lock);
+
+ NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_ACCEPT(fd, accept4, pstfdInf, ENOTSOCK,
+ local_lock);
- if (!nstack_is_nstack_sk (fix_fd))
+ if (addr)
{
- /* nstack not support kernel fd >= NSTACK_MAX_SOCK_NUM.
- * close it and nstack_accept() return failed
- */
- NSSOC_LOGERR
- ("nstack accept4 fd=%d kernelFD fd too big, close it. kernelFD=%d [return]",
- fd, fix_fd);
- if (fix_fd >= 0)
+ if ((!addr_len) || (*addr_len == NSTACK_MAX_U32_NUM))
{
- NSTACK_CAL_FUN (nstack_module_ops (pstfdInf->rmidx), close, (accfd),
- ret);
+ nstack_set_errno(EINVAL);
+ NSSOC_LOGERR("nstack accept4 addr_len inpurt error [return]");
+ UNLOCK_ACCEPT(fd, pstfdInf, local_lock);
+ return -1;
}
+ }
- if (pstfdInf->rmidx != nstack_get_fix_mid ())
+ /*if no module select or listen / bind fail, just return fail */
+ if ((!pstfdInf->ops)
+ || (NSTACK_LISTEN_FAIL ==
+ nstack_get_listen_ret(pstfdInf, pstfdInf->rmidx))
+ || (NSTACK_BIND_FAIL ==
+ nstack_get_bind_ret(pstfdInf, pstfdInf->rmidx)))
+ {
+ nstack_set_errno(EINVAL);
+ NSSOC_LOGERR
+ ("nstack accept4 fd:%d no mudle select, or bind/listen fail [return]",
+ fd);
+ UNLOCK_ACCEPT(fd, pstfdInf, local_lock);
+ return -1;
+ }
+
+ tfd = nstack_get_proto_fd(pstfdInf, pstfdInf->rmidx);
+ NSTACK_CAL_FUN(nstack_module_ops(pstfdInf->rmidx), accept4,
+ (tfd, addr, addr_len, flags), accfd);
+ if (-1 == accfd)
+ {
+ if (errno != EAGAIN)
{
- NSTACK_CAL_FUN (nstack_module_ops (nstack_get_fix_mid ()), close,
- (fix_fd), ret);
+ NSSOC_LOGERR("appfd=%d,module=%s,ret=%d,errno=%d [return]", fd,
+ nstack_get_module_name_by_idx(pstfdInf->rmidx),
+ accfd, errno);
}
- nstack_set_errno (EMFILE);
- UNLOCK_ACCEPT (fd, local_lock);
- return -1;
+ UNLOCK_ACCEPT(fd, pstfdInf, local_lock);
+ return -1;
}
- nstack_fd_local_lock_info_t *lock_info = get_fd_local_lock_info (fix_fd);
- LOCK_FOR_EP (lock_info);
- accInf = nstack_lk_fd_alloc_with_kernel (fix_fd);
- ret_fd = fix_fd;
+#ifdef KERNEL_FD_SUPPORT
+ // If it is not from kernel, need to create one kernel socket
+ if (pstfdInf->rmidx != nstack_get_linux_mid())
+ kernelFD = nstack_create_kernel_socket();
+ else
+ kernelFD = accfd;
- if (NULL == accInf)
+ if (!nstack_is_nstack_sk(kernelFD))
{
- NSTACK_CAL_FUN (nstack_module_ops (pstfdInf->rmidx), close, (accfd),
- ret);
- if (pstfdInf->rmidx != nstack_get_fix_mid ())
+ /* nstack not support kernel fd >= NSTACK_MAX_SOCK_NUM.
+ * close it and nstack_accept() return failed
+ */
+ NSSOC_LOGERR
+ ("nstack accept4 fd=%d kernelFD fd too big, close it. kernelFD=%d [return]",
+ fd, kernelFD);
+
+ if (kernelFD >= 0)
+ NSTACK_CAL_FUN(nstack_module_ops(pstfdInf->rmidx), close,
+ (accfd), ret);
+
+ if (pstfdInf->rmidx != nstack_get_linux_mid())
{
- NSTACK_CAL_FUN (nstack_module_ops (nstack_get_fix_mid ()), close,
- (fix_fd), ret);
+
+ NSTACK_CAL_FUN(nstack_module_ops(nstack_get_linux_mid()),
+ close, (kernelFD), ret);
}
- UNLOCK_FOR_EP (lock_info);
- NSSOC_LOGERR ("nstack accept fd alloc is NULL [return]");
- UNLOCK_ACCEPT (fd, local_lock);
- return -1;
+ nstack_set_errno(EMFILE);
+ UNLOCK_ACCEPT(fd, pstfdInf, local_lock);
+ return -1;
}
- nstack_set_routed_fd (accInf, accfd);
- accInf->ops = nstack_module_ops (pstfdInf->rmidx);
- accInf->type =
- (pstfdInf->type & (~((ns_int32) SOCK_CLOEXEC | (ns_int32) SOCK_NONBLOCK)))
- | (ns_int32) flags;
- nstack_set_router_protocol (accInf, pstfdInf->rmidx);
- nstack_set_protoFd (accInf, pstfdInf->rmidx, accfd);
- nstack_set_app_info (accInf, pstfdInf->rmidx);
- /* Set the linux kernel fd also in accInf for kernel module (0) */
- if (pstfdInf->rmidx != nstack_get_fix_mid ())
+ nstack_fd_local_lock_info_t *lock_info = get_fd_local_lock_info(kernelFD);
+ LOCK_FOR_EP(lock_info);
+ accInf = nstack_lk_fd_alloc_with_kernel(kernelFD);
+ ret_fd = kernelFD;
+#else
+ accInf = nstack_lk_fd_alloc_without_kernel();
+#endif
+
+ if (NULL == accInf)
{
- nstack_set_protoFd (accInf, nstack_get_fix_mid (), fix_fd);
+
+ NSTACK_CAL_FUN(nstack_module_ops(pstfdInf->rmidx), close, (accfd),
+ ret);
+#ifdef KERNEL_FD_SUPPORT
+ if (pstfdInf->rmidx != nstack_get_linux_mid())
+ {
+
+ NSTACK_CAL_FUN(nstack_module_ops(nstack_get_linux_mid()),
+ close, (kernelFD), ret);
+ }
+ UNLOCK_FOR_EP(lock_info);
+#endif
+ NSSOC_LOGERR("nstack accept fd alloc is NULL [return]");
+ UNLOCK_ACCEPT(fd, pstfdInf, local_lock);
+ return -1;
}
- NSSOC_LOGINF
- ("listenfd=%d,acceptfd=%d,accInf->fd=%d,module=%s(rlfd:%d),ret=%d [return]",
- fd, ret_fd, accInf->fd, nstack_get_module_name_by_idx (pstfdInf->rmidx),
- accfd, ret_fd);
- set_fd_status_lock_fork (ret_fd, FD_OPEN);
- UNLOCK_FOR_EP (lock_info);
- UNLOCK_ACCEPT (fd, local_lock);
- return ret_fd;
+
+#ifndef KERNEL_FD_SUPPORT
+ nstack_fd_local_lock_info_t *lock_info =
+ get_fd_local_lock_info(accInf->fd);
+ ret_fd = accInf->fd;
+ LOCK_FOR_EP(lock_info);
+#endif
+
+ nstack_set_routed_fd(accInf, accfd); /*do not need return value */
+ accInf->ops = nstack_module_ops(pstfdInf->rmidx);
+ accInf->type =
+ (pstfdInf->type &
+ (~((ns_int32) SOCK_CLOEXEC | (ns_int32) SOCK_NONBLOCK))) | (ns_int32)
+ flags;
+ nstack_set_router_protocol(accInf, pstfdInf->rmidx); /*do not need return value */
+ nstack_set_proto_fd(accInf, pstfdInf->rmidx, accfd);
+ nstack_set_app_info(accInf, pstfdInf->rmidx);
+#ifdef KERNEL_FD_SUPPORT
+ /* Set the linux kernel fd also in accInf for kernel module (0) */
+ if (pstfdInf->rmidx != nstack_get_linux_mid())
+ {
+ nstack_set_proto_fd(accInf, nstack_get_linux_mid(), kernelFD);
+ }
+#endif
+ NSSOC_LOGINF
+ ("listenfd=%d,acceptfd=%d,accInf->fd=%d,module=%s(rlfd:%d),ret=%d [return]",
+ fd, ret_fd, accInf->fd,
+ nstack_get_module_name_by_idx(pstfdInf->rmidx), accfd, ret_fd);
+ set_fd_status_lock_fork(ret_fd, FD_OPEN);
+ UNLOCK_FOR_EP(lock_info);
+ UNLOCK_ACCEPT(fd, pstfdInf, local_lock);
+ return ret_fd;
}
-/*****************************************************************
-Parameters : fd
- addr
- len
-Return :
-Description : use the rd select rlfd or default rlfd to Establish connection. the unused fd should closed
-*****************************************************************/
-int
-nstack_connect (int fd, const struct sockaddr *addr, socklen_t addrlen)
+int nstack_connect(int fd, const struct sockaddr *addr, socklen_t addrlen)
{
- int retval = -1;
- nstack_fd_Inf *fdInf;
- struct sockaddr_in *iaddr = NULL;
- iaddr = (struct sockaddr_in *) addr;
- int selectmod = -1;
- nstack_rd_key rdkey = { 0 };
+ int retval = -1;
+ nstack_fd_Inf *fdInf;
+ struct sockaddr_in *iaddr = (struct sockaddr_in *) addr;
- NSTACK_INIT_CHECK_RET (connect, fd, addr, addrlen);
+ NSTACK_INIT_CHECK_RET(connect, fd, addr, addrlen);
- NSSOC_LOGINF ("(sockfd=%d, addr=%p, addrlen=%u) [Caller]", fd, addr,
- addrlen);
+ NSSOC_LOGINF("(sockfd=%d, addr=%p, addrlen=%u) [Caller]", fd, addr,
+ addrlen);
- if (fd < 0)
+ if (fd < 0)
{
- nstack_set_errno (EBADF);
- NSSOC_LOGERR
- ("nstack connect, fd=%d invalid input: addr=%p,len=0x%x [return]", fd,
- addr, addrlen);
- return -1;
+ nstack_set_errno(EBADF);
+ NSSOC_LOGERR
+ ("nstack connect, fd=%d invalid input: addr=%p,len=0x%x [return]",
+ fd, addr, addrlen);
+ return -1;
}
- if ((NULL == addr) || (addrlen < 2))
+ if ((NULL == addr) || (addrlen < 2))
{
- nstack_set_errno (EINVAL);
- NSSOC_LOGERR
- ("nstack connect, fd=%d invalid input: addr=%p,len=0x%x [return]", fd,
- addr, addrlen);
- return -1;
+ nstack_set_errno(EINVAL);
+ NSSOC_LOGERR
+ ("nstack connect, fd=%d invalid input: addr=%p,len=0x%x [return]",
+ fd, addr, addrlen);
+ return -1;
}
- if ((addrlen >= sizeof (struct sockaddr_in))
- && ((addr->sa_family) == AF_INET))
+ /* avoid access to iaddr memory */
+ /* miss the condition about sockaddr_un,and get wrong value */
+ if ((addrlen >= sizeof(struct sockaddr_in))
+ && ((addr->sa_family) == AF_INET))
{
- NSSOC_LOGINF ("fd=%d,addr=%s,port=%d", fd, inet_ntoa (iaddr->sin_addr),
- ntohs (iaddr->sin_port));
+ NSSOC_LOGINF("fd=%d,addr=*.*.%u.%u,port=%d", fd,
+ FUZZY_IP_VAR(&iaddr->sin_addr), ntohs(iaddr->sin_port));
}
- else
+ else if ((addrlen >= sizeof(struct sockaddr_in6))
+ && ((addr->sa_family) == AF_INET6))
{
- NSSOC_LOGINF ("addrlen = %d ,fd=%d", (int) addrlen, fd);
+ struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *) addr;
+ NSSOC_LOGINF("fd=%d,addr=%s,port=%u", fd,
+ inet6_ntoa(&addr6->sin6_addr), htons(addr6->sin6_port));
+ }
+ else
+ {
+ NSSOC_LOGINF("addrlen = %d ,fd=%d", (int) addrlen, fd);
}
- /* need check addrlen's validity, will visite iaddr->sin_addr.s_addr following code,for visite iaddr->sin_addr.s_addr is 8 byte */
- if (addrlen < 8)
+ /* need check addrlen's validity, will visite iaddr->sin_addr.s_addr following code,for visite iaddr->sin_addr.s_addr is 8 byte */
+ if (addrlen < 8)
{
- nstack_set_errno (EINVAL);
- NSSOC_LOGERR
- ("nstack connect, fd=%d invalid addrlen input: addr=%p,len=0x%x [return]",
- fd, addr, addrlen);
- return -1;
+ nstack_set_errno(EINVAL);
+ NSSOC_LOGERR
+ ("nstack connect, fd=%d invalid addrlen input: addr=%p,len=0x%x [return]",
+ fd, addr, addrlen);
+ return -1;
}
- if (NSTACK_ANY_IP == iaddr->sin_addr.s_addr)
+ if (addr->sa_family == AF_INET)
{
- nstack_set_errno (ECONNREFUSED);
- NSSOC_LOGERR
- ("nstack connect, fd=%d invalid input: 0==addr_in->sin_addr.s_addr [return]",
- fd);
- return -1;
+ if (addrlen < sizeof(struct sockaddr_in))
+ {
+ /* sa family is always AF_INET */
+ NSSOC_LOGERR
+ ("nstack connect, fd=%d family=AF_INET invalid size: %d [return]",
+ fd, addrlen);
+ nstack_set_errno(EINVAL);
+ return -1;
+ }
+ if (NSTACK_ANY_IP == iaddr->sin_addr.s_addr) /*no need to check null pointer */
+ {
+ nstack_set_errno(ECONNREFUSED);
+ NSSOC_LOGERR
+ ("nstack connect, fd=%d invalid input: 0==addr_in->sin_addr.s_addr [return]",
+ fd);
+ return -1;
+ }
+ else if (NSTACK_MAX_U32_NUM == iaddr->sin_addr.s_addr) /*no need to check null pointer */
+ {
+ nstack_set_errno(ENETUNREACH);
+ NSSOC_LOGERR
+ ("nstack connect, fd=%d invalid input: 0xffffffff==addr_in->sin_addr.s_addr [return]",
+ fd);
+ return -1;
+ }
}
- else if (NSTACK_MAX_U32_NUM == iaddr->sin_addr.s_addr)
+ else if (addr->sa_family == AF_INET6)
{
- nstack_set_errno (ENETUNREACH);
- NSSOC_LOGERR
- ("nstack connect, fd=%d invalid input: 0xffffffff==addr_in->sin_addr.s_addr [return]",
- fd);
- return -1;
+ if (addrlen < sizeof(struct sockaddr_in6))
+ {
+ NSSOC_LOGERR
+ ("nstack connect, fd=%d family=AF_INET6 invalid size: %d [return]",
+ fd, addrlen);
+ nstack_set_errno(EINVAL);
+ return -1;
+ }
+
+ if (IN6_IS_ADDR_UNSPECIFIED
+ (&((const struct sockaddr_in6 *) addr)->sin6_addr))
+ {
+ nstack_set_errno(ECONNREFUSED);
+ NSSOC_LOGERR
+ ("nstack connect, fd=%d invalid input: 0==addr_in->sin6_addr [return]",
+ fd);
+ return -1;
+ }
}
- NSTACK_FD_LINUX_CHECK (fd, connect, fdInf, (fd, addr, addrlen));
- nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
- LOCK_CONNECT (fd, fdInf, local_lock);
- NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_CONNECT (fd, connect, fdInf, ENOTSOCK,
- local_lock);
+ NSTACK_FD_LINUX_CHECK_RETURN(fd, connect, fdInf, (fd, addr, addrlen));
+
+ nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
+ LOCK_CONNECT(fd, fdInf, local_lock);
- /*if no module select, according to dest ip */
- if (!fdInf->ops)
+ NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_CONNECT(fd, connect, fdInf, ENOTSOCK, local_lock); /*do not need return value */
+
+ /*if no module select, according to dest ip */
+ if (!fdInf->ops)
{
- rdkey.type = RD_DATA_TYPE_IP;
- rdkey.ip_addr = iaddr->sin_addr.s_addr;
- retval = nstack_rd_get_stackid (&rdkey, &selectmod);
- if ((0 != retval) || (selectmod == -1))
+ retval = nstack_socket_get_stackid(fdInf, addr, addrlen);
+ if (ns_success == retval && fdInf->rd_item.stack_id != -1)
{
- rdkey.type = RD_DATA_TYPE_PROTO;
- rdkey.proto_type = fdInf->type;
- retval = nstack_rd_get_stackid (&rdkey, &selectmod);
- if ((0 != retval) || (selectmod < 0)
- || (selectmod >= nstack_get_modNum ()))
- {
- NSSOC_LOGINF ("fd=%d addr=%s Select module=%s",
- fd, inet_ntoa (iaddr->sin_addr),
- nstack_get_module_name_by_idx (selectmod));
- selectmod = -1;
- }
- else
- {
- NSSOC_LOGINF ("Connect socket of]select modName=%s",
- nstack_get_module_name_by_idx (selectmod));
- }
+ NSSOC_LOGINF("fd=%d addr=%s Select module=%s, rd_opt=%d", fd,
+ inet_ntoa_x(addr),
+ nstack_get_module_name_by_idx(fdInf->
+ rd_item.stack_id),
+ fdInf->rd_opt);
+ /*in case of that multi-thread connect. if route was chosed by one thread, the other just use the first one */
+ fdInf->rmidx = fdInf->rd_item.stack_id;
+ fdInf->ops = nstack_module_ops(fdInf->rd_item.stack_id);
+ nstack_set_routed_fd(fdInf, nstack_get_proto_fd(fdInf, fdInf->rd_item.stack_id)); /*do not need return value */
+ nstack_set_router_protocol(fdInf, fdInf->rd_item.stack_id); /*do not need return value */
}
- if (ns_success == retval && selectmod >= 0)
+ else
{
- NSSOC_LOGINF ("fd=%d addr=%s Select module=%s",
- fd, inet_ntoa (iaddr->sin_addr),
- nstack_get_module_name_by_idx (selectmod));
- /*in case of that multi-thread connect. if route was chosen by one thread, the other just use the first one */
- fdInf->rmidx = selectmod;
- fdInf->ops = nstack_module_ops (selectmod);
- nstack_set_routed_fd (fdInf, nstack_get_protoFd (fdInf, selectmod));
- nstack_set_router_protocol (fdInf, selectmod);
+ NSSOC_LOGERR
+ ("fd=%d Callback select module=%d rd_opt=%d, ret=0x%x", fd,
+ fdInf->rd_item.stack_id, fdInf->rd_opt, retval);
+ nstack_set_errno(ENETUNREACH);
+ UNLOCK_CONNECT(fd, fdInf, local_lock);
+ return -1;
}
- else
- {
- NSSOC_LOGERR ("fd=%d Callback select module=%d ret=0x%x", fd,
- selectmod, retval);
- nstack_set_errno (ENETUNREACH);
- UNLOCK_CONNECT (fd, local_lock);
- return -1;
- }
- NSSOC_LOGINF ("fd=%d addr=%s Select module=%s",
- fd, inet_ntoa (iaddr->sin_addr),
- nstack_get_module_name_by_idx (selectmod));
}
- NSTACK_CAL_FUN (fdInf->ops, connect, (fdInf->rlfd, addr, addrlen), retval);
- if (-1 == retval && errno != EINPROGRESS)
+ NSTACK_CAL_FUN(fdInf->ops, connect, (fdInf->rlfd, addr, addrlen), retval);
+ if (-1 == retval && errno != EINPROGRESS)
{
- NSSOC_LOGERR ("appfd=%d,module=%s,proto_fd=%d,ret=%d,errno=%d [return]",
- fd, nstack_get_module_name_by_idx (fdInf->rmidx),
- fdInf->rlfd, retval, errno);
+ NSSOC_LOGERR
+ ("appfd=%d,module=%s,proto_fd=%d,ret=%d,errno=%d [return]", fd,
+ nstack_get_module_name_by_idx(fdInf->rmidx), fdInf->rlfd,
+ retval, errno);
}
- else
+ else
{
- NSSOC_LOGINF ("appfd=%d,module=%s,proto_fd=%d,ret=%d,errno=%d [return]",
- fd, nstack_get_module_name_by_idx (fdInf->rmidx),
- fdInf->rlfd, retval, errno);
+ NSSOC_LOGINF
+ ("appfd=%d,module=%s,proto_fd=%d,ret=%d,errno=%d [return]", fd,
+ nstack_get_module_name_by_idx(fdInf->rmidx), fdInf->rlfd,
+ retval, errno);
}
- UNLOCK_CONNECT (fd, local_lock);
- return retval;
+ UNLOCK_CONNECT(fd, fdInf, local_lock);
+ return retval;
}
-int
-nstack_shutdown (int fd, int how)
+int nstack_shutdown(int fd, int how)
{
- nstack_fd_Inf *fdInf = NULL;
- int retval = -1;
- int tfd;
+ nstack_fd_Inf *fdInf = NULL;
+ int retval = -1;
+ int tfd;
- if (fd < 0)
+ if (fd < 0)
{
- nstack_set_errno (EBADF);
- NSSOC_LOGERR ("fd=%d invalid input [return]", fd);
- return -1;
+ nstack_set_errno(EBADF);
+ NSSOC_LOGERR("fd=%d invalid input [return]", fd);
+ return -1;
}
- NSTACK_INIT_CHECK_RET (shutdown, fd, how);
+ NSTACK_INIT_CHECK_RET(shutdown, fd, how);
- NSSOC_LOGINF ("(fd=%d, how=%d) [Caller]", fd, how);
+ /* begin fork will close all fd(dont create by nstack) in continure,
+ which cause lots of log, here remove the log output */
+ NSSOC_LOGINF("(fd=%d, how=%d) [Caller]", fd, how);
- NSTACK_FD_LINUX_CHECK (fd, shutdown, fdInf, (fd, how));
+ NSTACK_FD_LINUX_CHECK_RETURN(fd, shutdown, fdInf, (fd, how));
- nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
- LOCK_COMMON (fd, fdInf, local_lock);
- NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_COMMON (fd, shutdown, fdInf, ENOTSOCK,
- local_lock);
+ nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
+ LOCK_COMMON(fd, fdInf, local_lock);
- if (!fdInf->ops || -1 == fdInf->rlfd)
+ NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_COMMON(fd, shutdown, fdInf, ENOTSOCK,
+ local_lock);
+
+ if (!fdInf->ops || -1 == fdInf->rlfd)
+ {
+ NSSOC_LOGWAR("fd=%d,how=%d, shutdown fail [return]", fd, how);
+ nstack_set_errno(ENOTCONN);
+ UNLOCK_COMMON(fd, fdInf, local_lock);
+ return -1;
+ }
+ tfd = fdInf->rlfd;
+ NSTACK_CAL_FUN(fdInf->ops, shutdown, (tfd, how), retval);
+ if ((-1 == retval) && (fdInf->rmidx != nstack_get_linux_mid()))
+ {
+ NSSOC_LOGWAR("fd=%d,ret=%d [return]", fd, retval);
+ }
+ else
{
- NSSOC_LOGWAR ("fd=%d,how=%d, shutdown fail [return]", fd, how);
- nstack_set_errno (ENOTCONN);
- UNLOCK_COMMON (fd, local_lock);
- return -1;
+ NSSOC_LOGINF("fd=%d,ret=%d [return]", fd, retval);
}
- tfd = fdInf->rlfd;
- NSTACK_CAL_FUN (fdInf->ops, shutdown, (tfd, how), retval);
- NSSOC_LOGINF ("fd=%d,ret=%d [return]", fd, retval);
- UNLOCK_COMMON (fd, local_lock);
- return retval;
+ UNLOCK_COMMON(fd, fdInf, local_lock);
+ return retval;
}
-int
-release_fd (int fd, nstack_fd_local_lock_info_t * local_lock)
+int release_fd(int fd, nstack_fd_local_lock_info_t * local_lock)
{
- nstack_fd_Inf *fdInf = NULL;
- nstack_module *pMod = NULL;
- int retval = 0;
- int curRet = -1;
- int modInx, tfd;
+ nstack_fd_Inf *fdInf = NULL;
+ nstack_module *pMod = NULL;
+#ifdef KERNEL_FD_SUPPORT
+ int retval = -1;
+#else
+ int retval = 0;
+#endif
+ int curRet = -1;
+ int modInx, tfd;
- if (!local_lock)
+ if (!local_lock)
{
- return -1;
+ return -1;
}
- LOCK_CLOSE (local_lock);
+ LOCK_CLOSE(local_lock);
- /* if fd is used by others, just pass, delay close it */
- if (local_lock->fd_status != FD_CLOSING || local_lock->fd_ref.counter > 0)
+ /* if fd is used by others, just pass, delay close it */
+ if (local_lock->fd_status != FD_CLOSING || local_lock->fd_ref.counter > 0)
{
- UNLOCK_CLOSE (local_lock);
- return 0;
+ UNLOCK_CLOSE(local_lock);
+ return 0;
}
- local_lock->fd_status = FD_CLOSE;
+ local_lock->fd_status = FD_CLOSE;
- fdInf = nstack_fd2inf (fd);
- if (NULL == fdInf)
+ fdInf = nstack_fd2inf(fd);
+ if (NULL == fdInf)
{
- nstack_set_errno (EINVAL);
- NSSOC_LOGERR ("pstfdInf is NULL");
- UNLOCK_CLOSE (local_lock);
- return -1;
+ nstack_set_errno(EINVAL);
+ NSSOC_LOGERR("pstfdInf is NULL");
+ UNLOCK_CLOSE(local_lock);
+ return -1;
}
- (void) nsep_epoll_close (fd);
+ (void) nsep_epoll_close(fd);
+
+ nstack_each_module(modInx, pMod)
+ {
+ tfd = nstack_get_proto_fd(fdInf, modInx);
- nstack_each_module (modInx, pMod)
- {
- tfd = nstack_get_protoFd (fdInf, modInx);
+ /* add tfd rang check */
+ if (nstack_get_minfd_id(modInx) > tfd
+ || tfd > nstack_get_maxfd_id(modInx))
+ {
+ continue;
+ }
- if (nstack_get_minfd_id (modInx) > tfd
- || tfd > nstack_get_maxfd_id (modInx))
- {
- continue;
- }
+ NSSOC_LOGINF("fd=%d,module=%s,tfd=%d", fd,
+ nstack_get_module_name_by_idx(modInx), tfd);
- NSSOC_LOGINF ("fd=%d,module=%s,tfd=%d", fd,
- nstack_get_module_name_by_idx (modInx), tfd);
+#ifdef KERNEL_FD_SUPPORT
+ if (0 ==
+ strcmp(RD_KERNEL_NAME, nstack_get_module_name_by_idx(modInx)))
+ {
+ if (!(tfd >= 3 && tfd < (int) NSTACK_KERNEL_FD_MAX))
+ {
+ NSSOC_LOGERR("tfd is out of scope]tfd=%d", tfd);
+ /* should release lock in this error branch */
+ UNLOCK_CLOSE(local_lock);
+ return -1;
+ }
- if (0 ==
- strcmp (nstack_fix_stack_name (),
- nstack_get_module_name_by_idx (modInx)))
- {
- continue;
- }
+ /* should release resource for kernel */
+ continue;
+ }
+#endif
- nssct_close (fd, modInx);
- NSTACK_CAL_FUN ((&pMod->mops.socket_ops), close, (tfd), curRet);
+ nssct_close(fd, modInx); /*do not need return value */
+ NSTACK_CAL_FUN((&pMod->ops), close, (tfd), curRet);
- if (-1 == curRet)
- {
- NSSOC_LOGERR ("failed]module=%s,tfd=%d,errno=%d",
- nstack_get_module_name_by_idx (modInx), tfd, errno);
- }
+ if (-1 == curRet)
+ {
+ NSSOC_LOGERR("failed]module=%s,tfd=%d,errno=%d",
+ nstack_get_module_name_by_idx(modInx), tfd, errno);
+ }
- retval &= curRet;
- }
- retval &= nstack_fd_free_with_kernel (fdInf);
- if (-1 == retval)
+#ifdef KERNEL_FD_SUPPORT
+ retval &= curRet;
+#else
+ retval |= curRet;
+#endif
+ }
+#ifdef KERNEL_FD_SUPPORT
+ retval &= nstack_fd_free_with_kernel(fdInf);
+ if (-1 == retval)
{
- NSSOC_LOGWAR ("fd=%d,ret=%d [return]", fd, retval);
+ NSSOC_LOGWAR("fd=%d,ret=%d [return]", fd, retval);
}
- else
+ else
{
- NSSOC_LOGINF ("fd=%d,ret=%d [return]", fd, retval);
+ NSSOC_LOGINF("fd=%d,ret=%d [return]", fd, retval);
}
+#else
+ nstack_fd_free(fdInf);
+#endif
- UNLOCK_CLOSE (local_lock);
- return retval;
+ UNLOCK_CLOSE(local_lock);
+ return retval;
}
/*not support fork now, to support fork the module must provide gfdt & refer cnt
while fork the frame use callback fun to add refer*/
-int
-nstack_close (int fd)
+/*vars are used in macro*/
+int nstack_close(int fd)
{
- nstack_fd_Inf *fdInf;
- int ret = -1;
+ nstack_fd_Inf *fdInf;
+ int modInx = 0;
+ int ret = -1;
- NSTACK_INIT_CHECK_RET (close, fd);
+ NSTACK_INIT_CHECK_RET(close, fd);
- /*linux fd check */
- if (!(fdInf = nstack_getValidInf (fd)))
+#ifdef KERNEL_FD_SUPPORT
+ /*linux fd check */
+ if (!(fdInf = nstack_get_valid_inf(fd)))
{
- if (NSTACK_THREAD_LOADING ())
- {
- return nsfw_base_close (fd);
- }
- if (0 != nstack_stack_module_load ())
+ if (fd != nsep_get_manager()->checkEpollFD)
{
- return -1;
- }
- if (nstack_fix_fd_check ()
- && nstack_fix_fd_check ()(fd, STACK_FD_FUNCALL_CHECK))
- {
- /*free epoll resoure */
- nsep_epoll_close (fd);
- nssct_close (fd, nstack_get_fix_mid ());
+ /*free epoll resouce */
+ nsep_epoll_close(fd); /*do not need return value */
+ nssct_close(fd, nstack_get_linux_mid()); /*do not need return value */
- NSTACK_CAL_FUN (nstack_fix_mid_ops (), close, (fd), ret);
- return ret;
+ return nsfw_base_close(fd);
}
- nstack_set_errno (ENOSYS);
- return -1;
+ nstack_set_errno(ENOSYS);
+ return -1;
}
+#else
+ NSTACK_FD_LINUX_CHECK_RETURN(fd, close, fdInf, (fd));
+#endif
- NSSOC_LOGINF ("Caller]fd=%d", fd);
+ NSSOC_LOGINF("Caller]fd=%d", fd);
- nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
- LOCK_CLOSE (local_lock);
- if (local_lock->fd_status != FD_OPEN)
+ nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
+ LOCK_CLOSE(local_lock);
+ if (local_lock->fd_status != FD_OPEN)
{
- NSSOC_LOGERR ("return]fd_status=%d,fd=%d", local_lock->fd_status, fd);
- nstack_set_errno (EBADF);
- UNLOCK_CLOSE (local_lock);
- return -1;
+ NSSOC_LOGERR("return]fd_status=%d,fd=%d", local_lock->fd_status, fd);
+ nstack_set_errno(EBADF);
+ UNLOCK_CLOSE(local_lock);
+ return -1;
}
- set_fd_status_lock_fork (fd, FD_CLOSING);
+ set_fd_status_lock_fork(fd, FD_CLOSING);
- UNLOCK_CLOSE (local_lock);
- ret =
- (atomic_dec (&local_lock->fd_ref) > 0 ? 0 : release_fd (fd, local_lock));
+ /* add fdInf->rlfd and fdInf->ops's validity check,avoid
+ print error log in normal scenario */
+ if (NSTACK_IS_FD_ATTR(fdInf, fdInf->rd_item.type_data.attr)
+ && (-1 != fdInf->rlfd) && fdInf->ops)
+ {
+ nstack_each_mod_inx(modInx)
+ {
+ if (nstack_fd_deal[modInx].set_close_stat)
+ {
+ nstack_fd_deal[modInx].set_close_stat(fdInf->rlfd,
+ FD_CLOSING);
+ }
+ }
+ }
- if (-1 == ret)
+ UNLOCK_CLOSE(local_lock);
+ ret =
+ (atomic_dec(&local_lock->fd_ref) >
+ 0 ? 0 : release_fd(fd, local_lock));
+
+ if (-1 == ret)
{
- NSSOC_LOGWAR ("return]fd=%d,retVal=%d", fd, ret);
+ NSSOC_LOGWAR("return]fd=%d,retVal=%d", fd, ret);
}
- else
+ else
{
- NSSOC_LOGINF ("return]fd=%d,retVal=%d", fd, ret);
+ NSSOC_LOGINF("return]fd=%d,retVal=%d", fd, ret);
}
- return ret;
+ return ret;
}
-ssize_t
-nstack_send (int fd, const void *buf, size_t len, int flags)
+ssize_t nstack_send(int fd, const void *buf, size_t len, int flags)
{
- nstack_fd_Inf *fdInf = NULL;
- int size = -1;
+ nstack_fd_Inf *fdInf = NULL;
+ ssize_t size = -1;
- NSTACK_INIT_CHECK_RET (send, fd, buf, len, flags);
+ NSTACK_INIT_CHECK_RET(send, fd, buf, len, flags);
- NS_LOG_CTRL (LOG_CTRL_SEND, NSOCKET, "NSSOC", NSLOG_DBG,
- "(sockfd=%d, buf=%p, len=%zu, flags=%d) [Caller]", fd, buf,
- len, flags);
+ NS_LOG_CTRL(LOG_CTRL_SEND, NSOCKET, "SOC", NSLOG_DBG,
+ "sockfd=%d,buf=%p,len=%zu,flags=%d[Caller]", fd, buf, len,
+ flags);
- NSTACK_FD_LINUX_CHECK (fd, send, fdInf, (fd, buf, len, flags));
+ NSTACK_FD_LINUX_CHECK_RETURN(fd, send, fdInf, (fd, buf, len, flags));
- nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
- LOCK_SEND (fd, fdInf, local_lock);
- NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_SEND (fd, send, fdInf, ENOTSOCK,
- local_lock);
+ nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
+ LOCK_SEND(fd, fdInf, local_lock);
- if ((!fdInf->ops) || (-1 == fdInf->rlfd))
+ NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_SEND(fd, send, fdInf, ENOTSOCK,
+ local_lock);
+
+ if ((!fdInf->ops) || (-1 == fdInf->rlfd))
{
- NSSOC_LOGINF ("fd Fail: Not select any module yet!]fd=%d [return]", fd);
- nstack_set_errno (ENOTCONN);
- UNLOCK_SEND (fd, local_lock);
- return -1;
+ NSSOC_LOGINF("fd Fail: Not select any module yet]fd=%d[return]", fd);
+ nstack_set_errno(ENOTCONN);
+ UNLOCK_SEND(fd, fdInf, local_lock);
+ return -1;
}
- NSTACK_CAL_FUN (fdInf->ops, send, (fdInf->rlfd, buf, len, flags), size);
-
- NSSOC_LOGDBG ("fd=%d,ret=%d [Return]", fd, size);
+ nstack_fd_dfx_update_dfx_data(fd, fdInf->rlfd, fdInf->rmidx,
+ DMM_STAT_LONGEST_SEND_INTERVAL, NULL);
+ NSTACK_CAL_FUN(fdInf->ops, send, (fdInf->rlfd, buf, len, flags), size);
- UNLOCK_SEND (fd, local_lock);
- return size;
+ NSSOC_LOGDBG("fd=%d,ret=%zd[Return]", fd, size);
+ UNLOCK_SEND(fd, fdInf, local_lock);
+ return size;
}
-ssize_t
-nstack_recv (int fd, void *buf, size_t len, int flags)
+ssize_t nstack_recv(int fd, void *buf, size_t len, int flags)
{
- nstack_fd_Inf *fdInf = NULL;
- int size = -1;
+ nstack_fd_Inf *fdInf = NULL;
+ ssize_t size = -1;
- NSTACK_INIT_CHECK_RET (recv, fd, buf, len, flags);
+ NSTACK_INIT_CHECK_RET(recv, fd, buf, len, flags);
- NS_LOG_CTRL (LOG_CTRL_RECV, NSOCKET, "NSSOC", NSLOG_DBG,
- "(sockfd=%d, buf=%p, len=%zu, flags=%d) [Caller]", fd, buf,
- len, flags);
+ NS_LOG_CTRL(LOG_CTRL_RECV, NSOCKET, "SOC", NSLOG_DBG,
+ "sockfd=%d,buf=%p,len=%zu,flags=%d[Caller]", fd, buf, len,
+ flags);
- NSTACK_FD_LINUX_CHECK (fd, recv, fdInf, (fd, buf, len, flags));
+ NSTACK_FD_LINUX_CHECK_RETURN(fd, recv, fdInf, (fd, buf, len, flags));
- nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
- LOCK_RECV (fd, fdInf, local_lock);
- NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_RECV (fd, recv, fdInf, ENOTSOCK,
- local_lock);
+ nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
+ LOCK_RECV(fd, fdInf, local_lock);
- if ((!fdInf->ops) || (-1 == fdInf->rlfd))
+ NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_RECV(fd, recv, fdInf, ENOTSOCK,
+ local_lock);
+
+ if ((!fdInf->ops) || (-1 == fdInf->rlfd))
{
- NSSOC_LOGINF ("Not select any module yet!]fd=%d [Return]", fd);
- nstack_set_errno (ENOTCONN);
- UNLOCK_RECV (fd, local_lock);
- return -1;
+ NSSOC_LOGINF("Not select any module yet]fd=%d[Return]", fd);
+ nstack_set_errno(ENOTCONN);
+ UNLOCK_RECV(fd, fdInf, local_lock);
+ return -1;
}
- NSTACK_CAL_FUN (fdInf->ops, recv, (fdInf->rlfd, buf, len, flags), size);
+ nstack_fd_dfx_update_dfx_data(fd, fdInf->rlfd, fdInf->rmidx,
+ DMM_STAT_LONGEST_RECV_INTERVAL, NULL);
+ NSTACK_CAL_FUN(fdInf->ops, recv, (fdInf->rlfd, buf, len, flags), size);
- NSSOC_LOGDBG ("fd=%d,ret=%d [Return]", fd, size);
+ NSSOC_LOGDBG("fd=%d,ret=%zd[Return]", fd, size);
- UNLOCK_RECV (fd, local_lock);
- return size;
+ UNLOCK_RECV(fd, fdInf, local_lock);
+ return size;
}
-ssize_t
-nstack_write (int fd, const void *buf, size_t count)
+ssize_t nstack_write(int fd, const void *buf, size_t count)
{
- nstack_fd_Inf *fdInf = NULL;
- int size = -1;
+ nstack_fd_Inf *fdInf = NULL;
+ ssize_t size = -1;
- NSTACK_INIT_CHECK_RET (write, fd, buf, count);
+ NSTACK_INIT_CHECK_RET(write, fd, buf, count);
- NSTACK_FD_LINUX_CHECK (fd, write, fdInf, (fd, buf, count));
+ NSTACK_FD_LINUX_CHECK_RETURN(fd, write, fdInf, (fd, buf, count));
+ NS_LOG_CTRL(LOG_CTRL_WRITE, NSOCKET, "SOC", NSLOG_DBG,
+ "fd=%d,buf=%p,count=%zu[Caller]", fd, buf, count);
- NS_LOG_CTRL (LOG_CTRL_WRITE, NSOCKET, "NSSOC", NSLOG_DBG,
- "(fd=%d, buf=%p, count=%zu) [Caller]", fd, buf, count);
+ nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
+ LOCK_SEND(fd, fdInf, local_lock);
- nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
- LOCK_SEND (fd, fdInf, local_lock);
- NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_SEND (fd, write, fdInf, EINVAL,
- local_lock);
+ NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_SEND(fd, write, fdInf, EINVAL,
+ local_lock);
- if ((!fdInf->ops) || (-1 == fdInf->rlfd))
+ if ((!fdInf->ops) || (-1 == fdInf->rlfd))
{
- NSSOC_LOGINF ("Not select any module yet!]fd=%d [Return]", fd);
- nstack_set_errno (ENOTCONN);
- UNLOCK_SEND (fd, local_lock);
- return -1;
+ NSSOC_LOGINF("Not select any module yet]fd=%d[Return]", fd);
+ nstack_set_errno(ENOTCONN);
+ UNLOCK_SEND(fd, fdInf, local_lock);
+ return -1;
}
- NSTACK_CAL_FUN (fdInf->ops, write, (fdInf->rlfd, buf, count), size);
+ nstack_fd_dfx_update_dfx_data(fd, fdInf->rlfd, fdInf->rmidx,
+ DMM_STAT_LONGEST_SEND_INTERVAL, NULL);
+ NSTACK_CAL_FUN(fdInf->ops, write, (fdInf->rlfd, buf, count), size);
- NSSOC_LOGDBG ("fd=%d,ret=%d [Return]", fd, size);
+ NSSOC_LOGDBG("fd=%d,ret=%zd[Return]", fd, size);
- UNLOCK_SEND (fd, local_lock);
- return size;
+ UNLOCK_SEND(fd, fdInf, local_lock);
+ return size;
}
-ssize_t
-nstack_read (int fd, void *buf, size_t count)
+ssize_t nstack_read(int fd, void *buf, size_t count)
{
- nstack_fd_Inf *fdInf = NULL;
- int size = -1;
+ nstack_fd_Inf *fdInf = NULL;
+ ssize_t size = -1;
+
+ NSTACK_INIT_CHECK_RET(read, fd, buf, count);
- NSTACK_INIT_CHECK_RET (read, fd, buf, count);
+ NS_LOG_CTRL(LOG_CTRL_READ, NSOCKET, "SOC", NSLOG_DBG,
+ "fd=%d,buf=%p,count=%zu[Caller]", fd, buf, count);
- NS_LOG_CTRL (LOG_CTRL_READ, NSOCKET, "NSSOC", NSLOG_DBG,
- "(fd=%d, buf=%p, count=%zu) [Caller]", fd, buf, count);
+ NSTACK_FD_LINUX_CHECK_RETURN(fd, read, fdInf, (fd, buf, count));
- NSTACK_FD_LINUX_CHECK (fd, read, fdInf, (fd, buf, count));
+ nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
+ LOCK_RECV(fd, fdInf, local_lock);
- nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
- LOCK_RECV (fd, fdInf, local_lock);
- NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_RECV (fd, read, fdInf, EINVAL, local_lock);
+ NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_RECV(fd, read, fdInf, EINVAL,
+ local_lock);
- if ((!fdInf->ops) || (-1 == fdInf->rlfd))
+ if ((!fdInf->ops) || (-1 == fdInf->rlfd))
{
- NSSOC_LOGINF ("Not select any module yet!]fd=%d [Return]", fd);
- nstack_set_errno (ENOTCONN);
- UNLOCK_RECV (fd, local_lock);
- return -1;
+ NSSOC_LOGINF("Not select any module yet]fd=%d[Return]", fd);
+ nstack_set_errno(ENOTCONN);
+ UNLOCK_RECV(fd, fdInf, local_lock);
+ return -1;
}
- NSTACK_CAL_FUN (fdInf->ops, read, (fdInf->rlfd, buf, count), size);
+ nstack_fd_dfx_update_dfx_data(fd, fdInf->rlfd, fdInf->rmidx,
+ DMM_STAT_LONGEST_RECV_INTERVAL, NULL);
+ NSTACK_CAL_FUN(fdInf->ops, read, (fdInf->rlfd, buf, count), size);
- NSSOC_LOGDBG ("fd=%d,ret=%d [Return]", fd, size);
+ NSSOC_LOGDBG("fd=%d,ret=%zd[Return]", fd, size);
- UNLOCK_RECV (fd, local_lock);
- return size;
+ UNLOCK_RECV(fd, fdInf, local_lock);
+ return size;
}
-ssize_t
-nstack_writev (int fd, const struct iovec * iov, int iovcnt)
+ssize_t nstack_writev(int fd, const struct iovec * iov, int iovcnt)
{
- nstack_fd_Inf *fdInf = NULL;
- int size = -1;
+ nstack_fd_Inf *fdInf = NULL;
+ ssize_t size = -1;
- NSTACK_INIT_CHECK_RET (writev, fd, iov, iovcnt);
+ NSTACK_INIT_CHECK_RET(writev, fd, iov, iovcnt);
- NS_LOG_CTRL (LOG_CTRL_WRITEV, NSOCKET, "NSSOC", NSLOG_DBG,
- "(fd=%d, iov=%p, count=%d) [Caller]", fd, iov, iovcnt);
+ NS_LOG_CTRL(LOG_CTRL_WRITEV, NSOCKET, "SOC", NSLOG_DBG,
+ "fd=%d,iov=%p,count=%d[Caller]", fd, iov, iovcnt);
- NSTACK_FD_LINUX_CHECK (fd, writev, fdInf, (fd, iov, iovcnt));
+ NSTACK_FD_LINUX_CHECK_RETURN(fd, writev, fdInf, (fd, iov, iovcnt));
- nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
- LOCK_SEND (fd, fdInf, local_lock);
- NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_SEND (fd, writev, fdInf, EINVAL,
- local_lock);
+ nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
+ LOCK_SEND(fd, fdInf, local_lock);
- if ((!fdInf->ops) || (-1 == fdInf->rlfd))
+ NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_SEND(fd, writev, fdInf, EINVAL,
+ local_lock);
+
+ if ((!fdInf->ops) || (-1 == fdInf->rlfd))
{
- NSSOC_LOGERR ("Not select any module yet!]fd=%d [Return]", fd);
- nstack_set_errno (ENOTCONN);
- UNLOCK_SEND (fd, local_lock);
- return -1;
+ NSSOC_LOGERR("Not select any module yet]fd=%d[Return]", fd);
+ nstack_set_errno(ENOTCONN);
+ UNLOCK_SEND(fd, fdInf, local_lock);
+ return -1;
}
- NSTACK_CAL_FUN (fdInf->ops, writev, (fdInf->rlfd, iov, iovcnt), size);
+ nstack_fd_dfx_update_dfx_data(fd, fdInf->rlfd, fdInf->rmidx,
+ DMM_STAT_LONGEST_SEND_INTERVAL, NULL);
+ NSTACK_CAL_FUN(fdInf->ops, writev, (fdInf->rlfd, iov, iovcnt), size);
- NSSOC_LOGDBG ("fd=%d,ret=%d [Return]", fd, size);
+ NSSOC_LOGDBG("fd=%d,ret=%zd[Return]", fd, size);
- UNLOCK_SEND (fd, local_lock);
- return size;
+ UNLOCK_SEND(fd, fdInf, local_lock);
+ return size;
}
-ssize_t
-nstack_readv (int fd, const struct iovec * iov, int iovcnt)
+ssize_t nstack_readv(int fd, const struct iovec * iov, int iovcnt)
{
- nstack_fd_Inf *fdInf = NULL;
- int size = -1;
+ nstack_fd_Inf *fdInf = NULL;
+ ssize_t size = -1;
+
+ NSTACK_INIT_CHECK_RET(readv, fd, iov, iovcnt);
- NSTACK_INIT_CHECK_RET (readv, fd, iov, iovcnt);
+ NS_LOG_CTRL(LOG_CTRL_READV, NSOCKET, "SOC", NSLOG_DBG,
+ "fd=%d,iov=%p,count=%d[Caller]", fd, iov, iovcnt);
- NS_LOG_CTRL (LOG_CTRL_READV, NSOCKET, "NSSOC", NSLOG_DBG,
- "(fd=%d, iov=%p, count=%d) [Caller]", fd, iov, iovcnt);
+ NSTACK_FD_LINUX_CHECK_RETURN(fd, readv, fdInf, (fd, iov, iovcnt));
- NSTACK_FD_LINUX_CHECK (fd, readv, fdInf, (fd, iov, iovcnt));
+ nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
+ LOCK_RECV(fd, fdInf, local_lock);
- nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
- LOCK_RECV (fd, fdInf, local_lock);
- NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_RECV (fd, readv, fdInf, EINVAL,
- local_lock);
+ NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_RECV(fd, readv, fdInf, EINVAL,
+ local_lock);
- if ((!fdInf->ops) || (-1 == fdInf->rlfd))
+ if ((!fdInf->ops) || (-1 == fdInf->rlfd))
{
- NSSOC_LOGERR ("Not select any module yet!]fd=%d [Return]", fd);
- nstack_set_errno (ENOTCONN);
- UNLOCK_RECV (fd, local_lock);
- return -1;
+ NSSOC_LOGERR("Not select any module yet]fd=%d [Return]", fd);
+ nstack_set_errno(ENOTCONN);
+ UNLOCK_RECV(fd, fdInf, local_lock);
+ return -1;
}
- NSTACK_CAL_FUN (fdInf->ops, readv, (fdInf->rlfd, iov, iovcnt), size);
+ nstack_fd_dfx_update_dfx_data(fd, fdInf->rlfd, fdInf->rmidx,
+ DMM_STAT_LONGEST_RECV_INTERVAL, NULL);
+ NSTACK_CAL_FUN(fdInf->ops, readv, (fdInf->rlfd, iov, iovcnt), size);
- NSSOC_LOGDBG ("fd=%d,ret=%d [Return]", fd, size);
+ NSSOC_LOGDBG("fd=%d,ret=%zd[Return]", fd, size);
- UNLOCK_RECV (fd, local_lock);
- return size;
+ UNLOCK_RECV(fd, fdInf, local_lock);
+ return size;
}
/*we assumed that the connect allready called, if not call, we must try many sok*/
-ssize_t
-nstack_sendto (int fd, const void *buf, size_t len, int flags,
- const struct sockaddr * dest_addr, socklen_t addrlen)
+ssize_t nstack_sendto(int fd, const void *buf, size_t len, int flags,
+ const struct sockaddr * dest_addr, socklen_t addrlen)
{
- nstack_fd_Inf *fdInf = NULL;
- int size = -1;
- struct sockaddr_in *iaddr = NULL;
- int selectmod = -1;
- int retval = 0;
- nstack_rd_key rdkey = { 0 };
+ nstack_fd_Inf *fdInf = NULL;
+ ssize_t size = -1;
+ int retval = 0;
- NSTACK_INIT_CHECK_RET (sendto, fd, buf, len, flags, dest_addr, addrlen);
+ ns_udp_route_Inf udp_route_info;
- NSSOC_LOGDBG
- ("(sockfd=%d, buf=%p, len=%zu, flags=%d, dest_addr=%p, addrlen=%u) [Caller]",
- fd, buf, len, flags, dest_addr, addrlen);
+ NSTACK_INIT_CHECK_RET(sendto, fd, buf, len, flags, dest_addr, addrlen);
- NSTACK_FD_LINUX_CHECK (fd, sendto, fdInf,
- (fd, buf, len, flags, dest_addr, addrlen));
+ NSSOC_LOGDBG
+ ("sockfd=%d, buf=%p,len=%zu,flags=%d,dest_addr=%p,addrlen=%u[Caller]",
+ fd, buf, len, flags, dest_addr, addrlen);
- nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
- LOCK_SEND (fd, fdInf, local_lock);
- NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_SEND (fd, sendto, fdInf, ENOTSOCK,
- local_lock);
+ NSTACK_FD_LINUX_CHECK_RETURN(fd, sendto, fdInf,
+ (fd, buf, len, flags, dest_addr, addrlen));
- if (fdInf->ops)
+ nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
+ LOCK_SEND(fd, fdInf, local_lock);
+
+ NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_SEND(fd, sendto, fdInf, ENOTSOCK,
+ local_lock);
+
+ if (fdInf->ops)
{
- NSTACK_CAL_FUN (fdInf->ops, sendto,
- (fdInf->rlfd, buf, len, flags, dest_addr, addrlen),
- size);
+ nstack_fd_dfx_update_dfx_data(fd, fdInf->rlfd, fdInf->rmidx,
+ DMM_STAT_LONGEST_SEND_INTERVAL, NULL);
+ NSTACK_CAL_FUN(fdInf->ops, sendto,
+ (fdInf->rlfd, buf, len, flags, dest_addr, addrlen),
+ size);
- NSSOC_LOGDBG
- ("fdInf->ops:fd=%d buf=%p,len=%zu,size=%d,addr=%p [Return]", fd, buf,
- len, size, dest_addr);
- UNLOCK_SEND (fd, local_lock);
- return size;
+ NSSOC_LOGDBG
+ ("fdInf->ops]fd=%d buf=%p,len=%zu,size=%zd,addr=%p[Return]", fd,
+ buf, len, size, dest_addr);
+ UNLOCK_SEND(fd, fdInf, local_lock);
+ return size;
}
- /*invalid ip, just return */
- /*validity check for addrlen: for visite iaddr->sin_addr.s_addr is 8 byte */
- if ((NULL == dest_addr) || (addrlen < 8))
+ /*invalid ip, just return */
+ /* add validity check for addrlen: for visite iaddr->sin_addr.s_addr is 8 byte */
+ if ((NULL == dest_addr) || (addrlen < 8))
{
- nstack_set_errno (EINVAL);
- NSSOC_LOGERR ("invalid input]fd=%d,buf=%p,len=%zu,addr=%p [Return]", fd,
- buf, len, dest_addr);
- UNLOCK_SEND (fd, local_lock);
- return -1;
+ nstack_set_errno(EINVAL);
+ NSSOC_LOGERR("invalid input]fd=%d,buf=%p,len=%zu,addr=%p[Return]",
+ fd, buf, len, dest_addr);
+ UNLOCK_SEND(fd, fdInf, local_lock);
+ return -1;
}
- iaddr = (struct sockaddr_in *) dest_addr;
- rdkey.type = RD_DATA_TYPE_IP;
- rdkey.ip_addr = iaddr->sin_addr.s_addr;
- retval = nstack_rd_get_stackid (&rdkey, &selectmod);
- if ((0 != retval) || (selectmod == -1))
- {
- rdkey.type = RD_DATA_TYPE_PROTO;
- rdkey.proto_type = fdInf->type;
- retval = nstack_rd_get_stackid (&rdkey, &selectmod);
- if ((0 != retval) || (selectmod < 0)
- || (selectmod >= nstack_get_modNum ()))
- {
- NSSOC_LOGINF ("fd=%d addr=%s Select module=%s",
- fd, inet_ntoa (iaddr->sin_addr),
- nstack_get_module_name_by_idx (selectmod));
- selectmod = -1;
- }
- else
- {
- NSSOC_LOGINF ("sendto socket of]select modName=%s",
- nstack_get_module_name_by_idx (selectmod));
- }
- }
- if ((ns_success == retval) && (selectmod >= 0))
+ retval = nstack_socket_get_stackid(fdInf, dest_addr, addrlen);
+
+ if ((ns_success == retval) && (fdInf->rd_item.stack_id != -1))
{
- NSSOC_LOGINF ("fd=%d,addr=%s,select_module=%s",
- fd, inet_ntoa (iaddr->sin_addr),
- nstack_get_module_name_by_idx (selectmod));
- fdInf->rmidx = selectmod;
- nstack_set_routed_fd (fdInf, nstack_get_protoFd (fdInf, selectmod));
- nstack_set_router_protocol (fdInf, selectmod);
- fdInf->ops = nstack_module_ops (selectmod);
+ NSSOC_LOGINF("fd=%d,addr=%s,select_module=%s, rd_opt=%d", fd,
+ inet_ntoa_x(dest_addr),
+ nstack_get_module_name_by_idx(fdInf->rd_item.stack_id),
+ fdInf->rd_opt);
+ fdInf->rmidx = fdInf->rd_item.stack_id;
+ nstack_set_routed_fd(fdInf,
+ nstack_get_proto_fd(fdInf,
+ fdInf->rd_item.stack_id));
+ nstack_set_router_protocol(fdInf, fdInf->rd_item.stack_id);
+ fdInf->ops = nstack_module_ops(fdInf->rd_item.stack_id);
+
+ udp_route_info.iaddr = *(struct sockaddr_in *) dest_addr;
+ udp_route_info.selectmod = fdInf->rd_item.stack_id;
+ nstack_fd_dfx_update_dfx_data(fd, fdInf->rlfd, fdInf->rmidx,
+ DMM_STAT_ROUTE_INFO, &udp_route_info);
+
}
- else
+ else
{
- NSSOC_LOGERR ("fd=%d Callback select module=%d,ret=0x%x", fd, selectmod,
- retval);
- nstack_set_errno (ENETUNREACH);
- UNLOCK_SEND (fd, local_lock);
- return -1;
+ NSSOC_LOGERR("fd=%d Callback select module=%d, rd_opt=%d, ret=0x%x",
+ fd, fdInf->rd_item.stack_id, fdInf->rd_opt, retval);
+ nstack_set_errno(ENETUNREACH);
+ UNLOCK_SEND(fd, fdInf, local_lock);
+ return -1;
}
- NSSOC_LOGDBG ("fd=%d,addr=%s,select_module=%s",
- fd, inet_ntoa (iaddr->sin_addr),
- nstack_get_module_name_by_idx (selectmod));
+ NSSOC_LOGDBG("fd=%d,addr=%s,select_module=%s,rd_opt=%d", fd,
+ inet_ntoa_x(dest_addr),
+ nstack_get_module_name_by_idx(fdInf->rd_item.stack_id),
+ fdInf->rd_opt);
- NSTACK_CAL_FUN (fdInf->ops, sendto,
- (fdInf->rlfd, buf, len, flags, dest_addr, addrlen), size);
+ nstack_fd_dfx_update_dfx_data(fd, fdInf->rlfd, fdInf->rmidx,
+ DMM_STAT_LONGEST_SEND_INTERVAL, NULL);
+ NSTACK_CAL_FUN(fdInf->ops, sendto,
+ (fdInf->rlfd, buf, len, flags, dest_addr, addrlen), size);
- NSSOC_LOGDBG ("fd=%d,module=%s,ret=%d [Return]", fd,
- nstack_get_module_name_by_idx (fdInf->rmidx), size);
+ NSSOC_LOGDBG("fd=%d,module=%s,ret=%d[Return]", fd,
+ nstack_get_module_name_by_idx(fdInf->rmidx), size);
- UNLOCK_SEND (fd, local_lock);
- return size;
+ UNLOCK_SEND(fd, fdInf, local_lock);
+ return size;
}
-ssize_t
-nstack_sendmsg (int fd, const struct msghdr * msg, int flags)
+ssize_t nstack_sendmsg(int fd, const struct msghdr * msg, int flags)
{
- nstack_fd_Inf *fdInf = NULL;
- int size = -1;
- struct sockaddr_in *iaddr = NULL;
- int selectmod = -1;
- int retval = 0;
- nstack_rd_key rdkey = { 0 };
+ nstack_fd_Inf *fdInf = NULL;
+ ssize_t size = -1;
+ struct sockaddr *addr = NULL;
+ int retval = 0;
- NSTACK_INIT_CHECK_RET (sendmsg, fd, msg, flags);
+ NSTACK_INIT_CHECK_RET(sendmsg, fd, msg, flags);
- NS_LOG_CTRL (LOG_CTRL_SENDMSG, NSOCKET, "NSSOC", NSLOG_DBG,
- "(sockfd=%d, msg=%p, flags=%d) [Caller]", fd, msg, flags);
+ NS_LOG_CTRL(LOG_CTRL_SENDMSG, NSOCKET, "SOC", NSLOG_DBG,
+ "sockfd=%d,msg=%p,flags=%d[Caller]", fd, msg, flags);
- if (NULL == msg)
+ if (NULL == msg)
{
- nstack_set_errno (EINVAL);
- NSSOC_LOGERR ("invalid input]fd=%d,msg=%p [Return]", fd, msg);
- return -1;
+ nstack_set_errno(EINVAL);
+ NSSOC_LOGERR("invalid input]fd=%d,msg=%p[Return]", fd, msg);
+ return -1;
}
- NSTACK_FD_LINUX_CHECK (fd, sendmsg, fdInf, (fd, msg, flags));
+ NSTACK_FD_LINUX_CHECK_RETURN(fd, sendmsg, fdInf, (fd, msg, flags));
- nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
- LOCK_SEND (fd, fdInf, local_lock);
- NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_SEND (fd, sendmsg, fdInf, ENOTSOCK,
- local_lock);
+ nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
+ LOCK_SEND(fd, fdInf, local_lock);
- /*if some module select, just connect */
- if (fdInf->ops)
- {
- NSTACK_CAL_FUN (fdInf->ops, sendmsg, (fdInf->rlfd, msg, flags), size);
- NSSOC_LOGDBG ("]fd=%d,size=%d msg=%p [Return]", fd, size, msg);
- UNLOCK_SEND (fd, local_lock);
- return size;
- }
+ NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_SEND(fd, sendmsg, fdInf, ENOTSOCK,
+ local_lock);
- iaddr = (struct sockaddr_in *) msg->msg_name;
- /* validity check for msg->msg_namelen,for visite iaddr->sin_addr.s_addr is 8 byte */
- if ((NULL == iaddr) || (msg->msg_namelen < 8))
+ /*if some module select, just connect */
+ if (fdInf->ops)
{
- NSSOC_LOGINF ("fd addr is null and select linux module]fd=%d", fd);
- fdInf->ops = nstack_module_ops (nstack_get_fix_mid ());
- nstack_set_routed_fd (fdInf,
- nstack_get_protoFd (fdInf,
- nstack_get_fix_mid ()));
- nstack_set_router_protocol (fdInf, nstack_get_fix_mid ());
+ nstack_fd_dfx_update_dfx_data(fd, fdInf->rlfd, fdInf->rmidx,
+ DMM_STAT_LONGEST_SEND_INTERVAL, NULL);
+ NSTACK_CAL_FUN(fdInf->ops, sendmsg, (fdInf->rlfd, msg, flags), size);
+
+ NSSOC_LOGDBG("]fd=%d,size=%zd msg=%p[Return]", fd, size, msg);
+ UNLOCK_SEND(fd, fdInf, local_lock);
+ return size;
}
- else
+
+ /* add validity check for msg->msg_namelen,for visite iaddr->sin_addr.s_addr is 8 byte */
+ addr = (struct sockaddr *) msg->msg_name;
+ if ((fdInf->rd_opt != -1) || ((NULL != addr) && (msg->msg_namelen >= 8)))
{
- rdkey.type = RD_DATA_TYPE_IP;
- rdkey.ip_addr = iaddr->sin_addr.s_addr;
- retval = nstack_rd_get_stackid (&rdkey, &selectmod);
- if ((0 != retval) || (selectmod == -1))
+ retval = nstack_socket_get_stackid(fdInf, addr, msg->msg_namelen);
+ if (ns_success == retval && fdInf->rd_item.stack_id != -1)
{
- rdkey.type = RD_DATA_TYPE_PROTO;
- rdkey.proto_type = fdInf->type;
- retval = nstack_rd_get_stackid (&rdkey, &selectmod);
- if ((0 != retval) || (selectmod < 0)
- || (selectmod >= nstack_get_modNum ()))
+ if (NULL != addr)
{
- NSSOC_LOGINF ("fd=%d addr=%s Select module=%s",
- fd, inet_ntoa (iaddr->sin_addr),
- nstack_get_module_name_by_idx (selectmod));
- selectmod = -1;
+ NSSOC_LOGINF("fd=%d,addr=%s,select_module=%s, rd_opt=%d", fd,
+ inet_ntoa_x(addr),
+ nstack_get_module_name_by_idx(fdInf->
+ rd_item.stack_id),
+ fdInf->rd_opt);
}
- else
+ else
{
- NSSOC_LOGINF ("Connect socket of]select modName=%s",
- nstack_get_module_name_by_idx (selectmod));
+ NSSOC_LOGINF("fd=%d,select_module=%s, rd_opt=%d", fd,
+ nstack_get_module_name_by_idx(fdInf->
+ rd_item.stack_id),
+ fdInf->rd_opt);
}
+
+ fdInf->rmidx = fdInf->rd_item.stack_id;
+ nstack_set_routed_fd(fdInf,
+ nstack_get_proto_fd(fdInf,
+ fdInf->
+ rd_item.stack_id));
+ nstack_set_router_protocol(fdInf, fdInf->rd_item.stack_id);
+ fdInf->ops = nstack_module_ops(fdInf->rd_item.stack_id);
}
- if (ns_success == retval)
- {
- NSSOC_LOGINF ("fd=%d,addr=%s,select_module=%s",
- fd, inet_ntoa (iaddr->sin_addr),
- nstack_get_module_name_by_idx (selectmod));
- fdInf->rmidx = selectmod;
- nstack_set_routed_fd (fdInf, nstack_get_protoFd (fdInf, selectmod));
- nstack_set_router_protocol (fdInf, selectmod);
- fdInf->ops = nstack_module_ops (selectmod);
- }
- else
+ else
{
- NSSOC_LOGERR ("fd=%d Callback select_module=%d,ret=0x%x", fd,
- selectmod, retval);
- nstack_set_errno (ENETUNREACH);
- UNLOCK_SEND (fd, local_lock);
- return -1;
+ NSSOC_LOGERR
+ ("fd=%d Callback select_module=%d, rd_opt=%d, ret=0x%x", fd,
+ fdInf->rd_item.stack_id, fdInf->rd_opt, retval);
+ nstack_set_errno(ENETUNREACH);
+ UNLOCK_SEND(fd, fdInf, local_lock);
+ return -1;
}
- NSSOC_LOGDBG ("fd=%d,addr=%s,select_module=%s",
- fd, inet_ntoa (iaddr->sin_addr),
- nstack_get_module_name_by_idx (selectmod));
+ NSSOC_LOGDBG("fd=%d,select_module=%s", fd,
+ nstack_get_module_name_by_idx(fdInf->rd_item.stack_id));
}
+ else
+ {
+ NSSOC_LOGINF("fd addr is null and select linux module]fd=%d", fd);
+ fdInf->ops = nstack_module_ops(nstack_get_linux_mid());
+ nstack_set_routed_fd(fdInf,
+ nstack_get_proto_fd(fdInf,
+ nstack_get_linux_mid()));
+ nstack_set_router_protocol(fdInf, nstack_get_linux_mid());
+ }
+ nstack_fd_dfx_update_dfx_data(fd, fdInf->rlfd, fdInf->rmidx,
+ DMM_STAT_LONGEST_SEND_INTERVAL, NULL);
+ NSTACK_CAL_FUN(fdInf->ops, sendmsg, (fdInf->rlfd, msg, flags), size);
- NSTACK_CAL_FUN (fdInf->ops, sendmsg, (fdInf->rlfd, msg, flags), size);
-
- NSSOC_LOGDBG ("fd=%d,module=%s,ret=%d [Return]", fd,
- nstack_get_module_name_by_idx (fdInf->rmidx), size);
+ NSSOC_LOGDBG("fd=%d,module=%s,ret=%d[Return]", fd,
+ nstack_get_module_name_by_idx(fdInf->rmidx), size);
- UNLOCK_SEND (fd, local_lock);
- return size;
+ UNLOCK_SEND(fd, fdInf, local_lock);
+ return size;
}
/*we assumed that the connect allready called, if not call, we must try many sok*/
-ssize_t
-nstack_recvfrom (int fd, void *buf, size_t len, int flags,
- struct sockaddr * src_addr, socklen_t * addrlen)
+ssize_t nstack_recvfrom(int fd, void *buf, size_t len, int flags,
+ struct sockaddr * src_addr, socklen_t * addrlen)
{
- nstack_fd_Inf *fdInf = NULL;
- int size = -1;
+ nstack_fd_Inf *fdInf = NULL;
+ ssize_t size = -1;
- NSTACK_INIT_CHECK_RET (recvfrom, fd, buf, len, flags, src_addr, addrlen);
+ NSTACK_INIT_CHECK_RET(recvfrom, fd, buf, len, flags, src_addr, addrlen);
- NSSOC_LOGDBG
- ("(sockfd=%d, buf=%p, len=%zu, flags=%d, src_addr=%p, addrlen=%p) [Caller]",
- fd, buf, len, flags, src_addr, addrlen);
+ NSSOC_LOGDBG
+ ("sockfd=%d,buf=%p,len=%zu,flags=%d,src_addr=%p,addrlen=%p[Caller]",
+ fd, buf, len, flags, src_addr, addrlen);
- if (NULL == buf)
+ if (NULL == buf)
{
- nstack_set_errno (EFAULT);
- NSSOC_LOGERR ("invalid input]fd=%d,buf=%p [Return]", fd, buf);
- return -1;
+ nstack_set_errno(EFAULT);
+ NSSOC_LOGERR("invalid input]fd=%d,buf=%p[Return]", fd, buf);
+ return -1;
}
- NSTACK_FD_LINUX_CHECK (fd, recvfrom, fdInf,
- (fd, buf, len, flags, src_addr, addrlen));
+ NSTACK_FD_LINUX_CHECK_RETURN(fd, recvfrom, fdInf,
+ (fd, buf, len, flags, src_addr, addrlen));
+
+ nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
+ LOCK_RECV(fd, fdInf, local_lock);
- nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
- LOCK_RECV (fd, fdInf, local_lock);
- NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_RECV (fd, recvfrom, fdInf, ENOTSOCK,
- local_lock);
+ NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_RECV(fd, recvfrom, fdInf, ENOTSOCK,
+ local_lock);
- if ((!fdInf->ops) || (-1 == fdInf->rlfd))
+ if ((!fdInf->ops) || (-1 == fdInf->rlfd))
{
- NSSOC_LOGINF ("Not select any module yet!]fd=%d [Return]", fd);
- nstack_set_errno (ENOTCONN);
- UNLOCK_RECV (fd, local_lock);
- return -1;
+ NSSOC_LOGINF("Not select any module yet]fd=%d[Return]", fd);
+ nstack_set_errno(ENOTCONN);
+ UNLOCK_RECV(fd, fdInf, local_lock);
+ return -1;
}
- NSTACK_CAL_FUN (fdInf->ops, recvfrom,
- (fdInf->rlfd, buf, len, flags, src_addr, addrlen), size);
+ nstack_fd_dfx_update_dfx_data(fd, fdInf->rlfd, fdInf->rmidx,
+ DMM_STAT_LONGEST_RECV_INTERVAL, NULL);
+ NSTACK_CAL_FUN(fdInf->ops, recvfrom,
+ (fdInf->rlfd, buf, len, flags, src_addr, addrlen), size);
- NSSOC_LOGDBG ("fd=%d,retVal=%d [Return]", fd, size);
+ NSSOC_LOGDBG("fd=%d,retVal=%zd[Return]", fd, size);
- UNLOCK_RECV (fd, local_lock);
- return size;
+ UNLOCK_RECV(fd, fdInf, local_lock);
+ return size;
}
-ssize_t
-nstack_recvmsg (int fd, struct msghdr * msg, int flags)
+ssize_t nstack_recvmsg(int fd, struct msghdr * msg, int flags)
{
- nstack_fd_Inf *fdInf = NULL;
- int size = -1;
+ nstack_fd_Inf *fdInf = NULL;
+ ssize_t size = -1;
- NSTACK_INIT_CHECK_RET (recvmsg, fd, msg, flags);
+ NSTACK_INIT_CHECK_RET(recvmsg, fd, msg, flags);
+ NS_LOG_CTRL(LOG_CTRL_RECVMSG, NSOCKET, "SOC", NSLOG_DBG,
+ "sockfd=%d,msg=%p,flags=%d[Caller]", fd, msg, flags);
- NS_LOG_CTRL (LOG_CTRL_RECVMSG, NSOCKET, "NSSOC", NSLOG_DBG,
- "(sockfd=%d, msg=%p, flags=%d) [Caller]", fd, msg, flags);
+ NSTACK_FD_LINUX_CHECK_RETURN(fd, recvmsg, fdInf, (fd, msg, flags));
- NSTACK_FD_LINUX_CHECK (fd, recvmsg, fdInf, (fd, msg, flags));
+ nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
+ LOCK_RECV(fd, fdInf, local_lock);
- nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
- LOCK_RECV (fd, fdInf, local_lock);
- NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_RECV (fd, recvmsg, fdInf, ENOTSOCK,
- local_lock);
+ NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_RECV(fd, recvmsg, fdInf, ENOTSOCK,
+ local_lock);
- if ((-1 == fdInf->rlfd) || (NULL == fdInf->ops))
+ if ((-1 == fdInf->rlfd) || (NULL == fdInf->ops))
{
- NSSOC_LOGERR ("Not select any module yet!]fd=%d [Return]", fd);
- nstack_set_errno (ENOTCONN);
- UNLOCK_RECV (fd, local_lock);
- return -1;
+ NSSOC_LOGERR("Not select any module yet]fd=%d[Return]", fd);
+ nstack_set_errno(ENOTCONN);
+ UNLOCK_RECV(fd, fdInf, local_lock);
+ return -1;
}
- NSTACK_CAL_FUN (fdInf->ops, recvmsg, (fdInf->rlfd, msg, flags), size);
+ nstack_fd_dfx_update_dfx_data(fd, fdInf->rlfd, fdInf->rmidx,
+ DMM_STAT_LONGEST_RECV_INTERVAL, NULL);
+ NSTACK_CAL_FUN(fdInf->ops, recvmsg, (fdInf->rlfd, msg, flags), size);
+
+ NSSOC_LOGDBG("fd=%d,ret=%zd[Return]", fd, size);
+
+ UNLOCK_RECV(fd, fdInf, local_lock);
+ return size;
+}
+
+/*****************************************************************
+Parameters : fd
+ addr
+ len
+Return :
+Description : use hostname to get ip or use ip to get hostname
+*****************************************************************/
+int nstack_getaddrinfo(const char *name, const char *service,
+ const struct addrinfo *hints, struct addrinfo **res)
+{
+ int ret = 0;
- NSSOC_LOGDBG ("fd=%d,ret=%d [Return]", fd, size);
+ g_addrinfo_flag = 1;
+ ret = nsfw_base_getaddrinfo(name, service, hints, res);
+ g_addrinfo_flag = 0;
- UNLOCK_RECV (fd, local_lock);
- return size;
+ return ret;
}
/*****************************************************************
@@ -1650,68 +2041,68 @@ Parameters : fd
Return :
Description : all module fd bind to same addr, so just use first rlfd to get bind addr.
*****************************************************************/
-int
-nstack_getsockname (int fd, struct sockaddr *addr, socklen_t * addrlen)
+int nstack_getsockname(int fd, struct sockaddr *addr, socklen_t * addrlen)
{
- nstack_fd_Inf *fdInf = NULL;
- int tfd = -1;
- int ret = -1;
+ nstack_fd_Inf *fdInf = NULL;
+ int tfd = -1;
+ int ret = -1;
- NSTACK_INIT_CHECK_RET (getsockname, fd, addr, addrlen);
+ NSTACK_INIT_CHECK_RET(getsockname, fd, addr, addrlen);
- NS_LOG_CTRL (LOG_CTRL_GETSOCKNAME, NSOCKET, "NSSOC", NSLOG_INF,
- "(fd=%d, addr=%p, addrlen=%p) [Caller]", fd, addr, addrlen);
+ NS_LOG_CTRL(LOG_CTRL_GETSOCKNAME, NSOCKET, "SOC", NSLOG_INF,
+ "fd=%d,addr=%p,addrlen=%p[Caller]", fd, addr, addrlen);
- if (fd < 0)
+ if (fd < 0)
{
- nstack_set_errno (EBADF);
- NSSOC_LOGERR ("invalid input]fd=%d. [return]", fd);
- return -1;
+ nstack_set_errno(EBADF);
+ NSSOC_LOGERR("invalid input]fd=%d[return]", fd);
+ return -1;
}
- NSTACK_FD_LINUX_CHECK (fd, getsockname, fdInf, (fd, addr, addrlen));
+ NSTACK_FD_LINUX_CHECK_RETURN(fd, getsockname, fdInf, (fd, addr, addrlen));
- nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
- LOCK_COMMON (fd, fdInf, local_lock);
+ nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
+ LOCK_COMMON(fd, fdInf, local_lock);
- if ((NULL != fdInf->ops) && (fdInf->rlfd != -1))
+ if ((NULL != fdInf->ops) && (fdInf->rlfd != -1))
{
- tfd = fdInf->rlfd;
- NSTACK_CAL_FUN (fdInf->ops, getsockname, (tfd, addr, addrlen), ret);
- NSSOC_LOGINF ("fd=%d,module=%s,tfd=%d [return]", fd,
- nstack_get_module_name_by_idx (fdInf->rmidx), tfd);
- if (-1 == ret)
+ tfd = fdInf->rlfd;
+ NSTACK_CAL_FUN(fdInf->ops, getsockname, (tfd, addr, addrlen), ret);
+ NSSOC_LOGINF("fd=%d,module=%s,tfd=%d[return]", fd,
+ nstack_get_module_name_by_idx(fdInf->rmidx), tfd);
+ if ((-1 == ret) && (fdInf->rmidx != nstack_get_linux_mid()))
{
- NSSOC_LOGERR ("rmidx=%d,fd=%d return fail [return]", fdInf->rmidx,
- tfd);
+ NSSOC_LOGERR("rmidx=%d,fd=%d return fail[return]", fdInf->rmidx,
+ tfd);
}
- UNLOCK_COMMON (fd, local_lock);
- return ret;
+ UNLOCK_COMMON(fd, fdInf, local_lock);
+ return ret;
}
- if (NULL != g_nstack_modules.defMod)
+ if (NULL != g_nstack_modules.defMod)
{
- tfd = nstack_get_protoFd (fdInf, nstack_defMod_inx ());
- if (tfd >= 0)
+ tfd = nstack_get_proto_fd(fdInf, nstack_defmod_inx());
+ if (tfd >= 0)
{
- nstack_socket_ops *ops = nstack_def_ops ();
- NSTACK_CAL_FUN (ops, getsockname, (tfd, addr, addrlen), ret);
- NSSOC_LOGINF ("fd=%d,module=%s,tfd=%d [return]", fd,
- nstack_defmod_name (), tfd);
- if (-1 == ret)
+ nstack_socket_ops *ops = nstack_def_ops();
+ NSTACK_CAL_FUN(ops, getsockname, (tfd, addr, addrlen), ret);
+ NSSOC_LOGINF("fd=%d,module=%s,tfd=%d[return]", fd,
+ nstack_defmod_name(), tfd);
+ if ((-1 == ret)
+ && (nstack_defmod_inx() != nstack_get_linux_mid()))
{
- NSSOC_LOGERR ("return fail]module=%d,fd=%d [return]",
- nstack_defMod_inx (), tfd);
+ NSSOC_LOGERR("return fail]mudle=%d,fd=%d[return]",
+ nstack_defmod_inx(), tfd);
}
- UNLOCK_COMMON (fd, local_lock);
- return ret;
+ UNLOCK_COMMON(fd, fdInf, local_lock);
+ return ret;
}
}
- nstack_set_errno (ENOTSOCK);
- NSSOC_LOGINF ("fd=%d,ret=%d [Return]", fd, ret);
- UNLOCK_COMMON (fd, local_lock);
- return ret;
+ nstack_set_errno(ENOTSOCK);
+ NSSOC_LOGINF("fd=%d,ret=%d [Return]", fd, ret);
+ UNLOCK_COMMON(fd, fdInf, local_lock);
+ return ret;
}
@@ -1720,1148 +2111,1065 @@ Parameters : fd
addr
len
Return :
-Description : getpeername only used by the fd who already Establish connection, so use first rlfd.
+Description : getpeername only used by the fd who already Estblsh connection, so use first rlfd.
*****************************************************************/
-int
-nstack_getpeername (int fd, struct sockaddr *addr, socklen_t * addrlen)
+int nstack_getpeername(int fd, struct sockaddr *addr, socklen_t * addrlen)
{
- nstack_fd_Inf *fdInf;
- int tfd;
- int ret = -1;
+ nstack_fd_Inf *fdInf;
+ int tfd;
+ int ret = -1;
- NSTACK_INIT_CHECK_RET (getpeername, fd, addr, addrlen);
+ NSTACK_INIT_CHECK_RET(getpeername, fd, addr, addrlen);
- NS_LOG_CTRL (LOG_CTRL_GETPEERNAME, NSOCKET, "NSSOC", NSLOG_INF,
- "(fd=%d, addr=%p, addrlen=%p) [Caller]", fd, addr, addrlen);
+ NS_LOG_CTRL(LOG_CTRL_GETPEERNAME, NSOCKET, "SOC", NSLOG_INF,
+ "fd=%d,addr=%p,addrlen=%p[Caller]", fd, addr, addrlen);
- if (fd < 0)
+ if (fd < 0)
{
- nstack_set_errno (EBADF);
- NSSOC_LOGERR ("invalid input, fd=%d. [return]", fd);
- return -1;
+ nstack_set_errno(EBADF);
+ NSSOC_LOGERR("invalid input,fd=%d[return]", fd);
+ return -1;
}
- NSTACK_FD_LINUX_CHECK (fd, getpeername, fdInf, (fd, addr, addrlen));
+ NSTACK_FD_LINUX_CHECK_RETURN(fd, getpeername, fdInf, (fd, addr, addrlen));
- nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
- LOCK_COMMON (fd, fdInf, local_lock);
+ nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
+ LOCK_COMMON(fd, fdInf, local_lock);
- /*?????????,????????????? */
- if (fdInf->ops)
+ if (fdInf->ops)
{
- tfd = fdInf->rlfd;
- NSTACK_CAL_FUN (fdInf->ops, getpeername, (tfd, addr, addrlen), ret);
- NSSOC_LOGINF ("fd=%d,module=%s,rlfd=%d,ret=%d [return]",
- fd, nstack_get_module_name_by_idx (fdInf->rmidx),
- fdInf->rlfd, ret);
- if (-1 == ret)
+ tfd = fdInf->rlfd;
+ NSTACK_CAL_FUN(fdInf->ops, getpeername, (tfd, addr, addrlen), ret);
+ NSSOC_LOGINF("fd=%d,module=%s,rlfd=%d,ret=%d[return]",
+ fd, nstack_get_module_name_by_idx(fdInf->rmidx),
+ fdInf->rlfd, ret);
+ if ((-1 == ret) && (fdInf->rmidx != nstack_get_linux_mid()))
{
- NSSOC_LOGERR ("return fail]module=%d,fd=%d [return]", fdInf->rmidx,
- tfd);
+ NSSOC_LOGERR("return fail]mudle=%d,fd=%d[return]", fdInf->rmidx,
+ tfd);
}
- UNLOCK_COMMON (fd, local_lock);
- return ret;
+ UNLOCK_COMMON(fd, fdInf, local_lock);
+ return ret;
}
- if (NULL != g_nstack_modules.defMod)
+ if (NULL != g_nstack_modules.defMod)
{
- tfd = nstack_get_protoFd (fdInf, nstack_defMod_inx ());
- if (tfd >= 0)
+ tfd = nstack_get_proto_fd(fdInf, nstack_defmod_inx());
+ if (tfd >= 0)
{
- nstack_socket_ops *ops = nstack_def_ops ();
- NSTACK_CAL_FUN (ops, getpeername, (tfd, addr, addrlen), ret);
- NSSOC_LOGINF ("fd=%d,module=%s,tfd=%d [return]", fd,
- nstack_defmod_name (), tfd);
- if (-1 == ret)
+ nstack_socket_ops *ops = nstack_def_ops();
+ NSTACK_CAL_FUN(ops, getpeername, (tfd, addr, addrlen), ret);
+ NSSOC_LOGINF("fd=%d,module=%s,tfd=%d[return]", fd,
+ nstack_defmod_name(), tfd);
+ if ((-1 == ret)
+ && (nstack_defmod_inx() != nstack_get_linux_mid()))
{
- NSSOC_LOGERR ("return fail] module=%d,fd=%d [return]",
- nstack_defMod_inx (), tfd);
+ NSSOC_LOGERR("return fail] mudle=%d,fd=%d[return]",
+ nstack_defmod_inx(), tfd);
}
- UNLOCK_COMMON (fd, local_lock);
- return ret;
+ UNLOCK_COMMON(fd, fdInf, local_lock);
+ return ret;
}
}
- nstack_set_errno (ENOTSOCK);
- NSSOC_LOGINF ("fd=%d,ret=%d [Return]", fd, ret);
- UNLOCK_COMMON (fd, local_lock);
- return ret;
+ nstack_set_errno(ENOTSOCK);
+ NSSOC_LOGINF("fd=%d,ret=%d[Return]", fd, ret);
+ UNLOCK_COMMON(fd, fdInf, local_lock);
+ return ret;
}
-int
-nstack_option_set (nstack_fd_Inf * fdInf, int optname, const void *optval,
- socklen_t optlen)
+int nstack_option_set(nstack_fd_Inf * fdInf, int optname, const void *optval,
+ socklen_t optlen)
{
+ ns_int32 rd_opt;
#define SLEEP_MAX 10000000
- if ((!optval) || (optlen < sizeof (u32_t)))
+ if ((!optval) || (optlen < sizeof(u32_t)))
{
- NSSOC_LOGINF ("rong parmeter optname]=%d", optname);
- nstack_set_errno (EINVAL);
- return -1;
+ NSSOC_LOGINF("rong parmeter optname]=%d", optname);
+ nstack_set_errno(EINVAL);
+ return -1;
}
- switch (optname)
+ switch (optname)
{
- case NSTACK_SEM_SLEEP:
- if ((*(u32_t *) optval) > SLEEP_MAX)
- {
- NSSOC_LOGWAR ("time overflow]epfd=%d", fdInf->fd);
- nstack_set_errno (EINVAL);
- return -1;
- }
-
- nsep_set_infoSleepTime (fdInf->fd, *(u32_t *) optval);
- NSSOC_LOGINF ("set sem wait option] g_sem_sleep_time=%ld",
- *(u32_t *) optval);
- break;
+ case NSTACK_SEM_SLEEP:
+ if ((*(u32_t *) optval) > SLEEP_MAX)
+ {
+ NSSOC_LOGWAR("time overflow]epfd=%d", fdInf->fd);
+ nstack_set_errno(EINVAL);
+ return -1;
+ }
- default:
- NSSOC_LOGINF ("rong parmeter optname]=%d", optname);
- nstack_set_errno (ENOPROTOOPT);
- return -1;
- }
- return 0;
+ nsep_set_info_sleep_time(fdInf->fd, *(u32_t *) optval); /*no need to check null pointer */
+ NSSOC_LOGINF("set sem wait option] g_sem_sleep_time=%u",
+ *(u32_t *) optval);
+ break;
+ case NSTACK_RD_MODE:
+ rd_opt = *(ns_int32 *) optval;
+ if (rd_opt < -1 || rd_opt >= nstack_get_module_num())
+ {
+ NSSOC_LOGWAR("invail rd mode fd=%d, mode=%d", fdInf->fd,
+ rd_opt);
+ nstack_set_errno(EINVAL);
+ return -1;
+ }
+ fdInf->rd_opt = rd_opt;
+ NSSOC_LOGINF("set rd mode] mode=%d", rd_opt);
+ break;
+ default:
+ NSSOC_LOGINF("rong parmeter optname]=%d", optname);
+ nstack_set_errno(ENOPROTOOPT);
+ return -1;
+ }
+ return 0;
}
-int
-nstack_option_get (nstack_fd_Inf * fdInf, int optname, const void *optval,
- socklen_t * optlen)
+int nstack_option_get(nstack_fd_Inf * fdInf, int optname, const void *optval,
+ socklen_t * optlen)
{
- if ((!optval) || (!optlen) || (optlen && (*optlen < sizeof (u32_t))))
+ if ((!optval) || (!optlen) || (*optlen < sizeof(u32_t)))
{
- NSSOC_LOGINF ("rong parmeter optname]=%d", optname);
- nstack_set_errno (EINVAL);
- return -1;
+ NSSOC_LOGINF("rong parmeter optname]=%d", optname);
+ nstack_set_errno(EINVAL);
+ return -1;
}
- switch (optname)
+ switch (optname)
{
- case NSTACK_SEM_SLEEP:
- *(long *) optval = nsep_get_infoSleepTime (fdInf->fd);
- NSSOC_LOGINF ("get sem wait option] g_sem_sleep_time=%ld",
- *(long *) optval);
- break;
-
- default:
- NSSOC_LOGINF ("rong parmeter optname]=%d", optname);
- nstack_set_errno (ENOPROTOOPT);
- return -1;
+ case NSTACK_SEM_SLEEP:
+ *(long *) optval = nsep_get_info_sleep_time(fdInf->fd); /*no need to check null pointer */
+ NSSOC_LOGINF("get sem wait option] g_sem_sleep_time=%ld",
+ *(long *) optval);
+ break;
+ case NSTACK_RD_MODE:
+ *(ns_int32 *) optval = fdInf->rd_opt;
+ NSSOC_LOGINF("get rd mode] mode=%d", *(ns_int32 *) optval);
+ break;
+ default:
+ NSSOC_LOGINF("rong parmeter optname]=%d", optname);
+ nstack_set_errno(ENOPROTOOPT);
+ return -1;
}
- return 0;
+ return 0;
}
/* just use first rlfd to getsockopt, this may not what app really want.*/
-/* Currently, if getsockopt is successfull either in kernel or stack-x, the below API returns SUCCESS */
-int
-nstack_getsockopt (int fd, int level, int optname, void *optval,
- socklen_t * optlen)
+/* Currently, if getsockopt is successfull either in kernel or lwip, the below API returns SUCCESS */
+int nstack_getsockopt(int fd, int level, int optname, void *optval,
+ socklen_t * optlen)
{
- nstack_fd_Inf *fdInf;
- int tfd;
- int ret = -1;
- nstack_socket_ops *ops;
+ nstack_fd_Inf *fdInf;
+ int tfd;
+ int ret = -1;
+ nstack_socket_ops *ops;
- NSTACK_INIT_CHECK_RET (getsockopt, fd, level, optname, optval, optlen);
+ NSTACK_INIT_CHECK_RET(getsockopt, fd, level, optname, optval, optlen);
- NS_LOG_CTRL (LOG_CTRL_GETSOCKOPT, NSOCKET, "NSSOC", NSLOG_INF,
- "(fd=%d, level=%d, optname=%d, optval=%p, optlen=%p) [Caller]",
- fd, level, optname, optval, optlen);
+ NS_LOG_CTRL(LOG_CTRL_GETSOCKOPT, NSOCKET, "SOC", NSLOG_INF,
+ "fd=%d,level=%d,optname=%d,optval=%p,optlen=%p[Caller]",
+ fd, level, optname, optval, optlen);
- if (fd < 0)
+ if (fd < 0)
{
- nstack_set_errno (EBADF);
- NSSOC_LOGERR ("invalid input]fd=%d [return]", fd);
- return -1;
+ nstack_set_errno(EBADF);
+ NSSOC_LOGERR("invalid input]fd=%d[return]", fd);
+ return -1;
}
- NSTACK_FD_LINUX_CHECK (fd, getsockopt, fdInf,
- (fd, level, optname, optval, optlen));
+ NSTACK_FD_LINUX_CHECK_RETURN(fd, getsockopt, fdInf,
+ (fd, level, optname, optval, optlen));
- nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
- LOCK_COMMON (fd, fdInf, local_lock);
+ nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
+ LOCK_COMMON(fd, fdInf, local_lock);
- if ((NSTACK_SOCKOPT == level) && NSTACK_IS_FD_EPOLL_SOCKET (fdInf))
+ if ((NSTACK_SOCKOPT == level) &&
+ (NSTACK_IS_FD_EPOLL_SOCKET(fdInf) || NSTACK_RD_MODE == optname))
{
- ret = nstack_option_get (fdInf, optname, optval, optlen);
- UNLOCK_COMMON (fd, local_lock);
- return ret;
+ ret = nstack_option_get(fdInf, optname, optval, optlen);
+ UNLOCK_COMMON(fd, fdInf, local_lock);
+ return ret;
}
- if (fdInf->ops)
+ if (fdInf->ops)
{
- tfd = fdInf->rlfd;
- NSTACK_CAL_FUN (fdInf->ops, getsockopt,
- (tfd, level, optname, optval, optlen), ret);
- NSSOC_LOGINF
- ("fd=%d,module=%s,tfd=%d,level=%d,optname=%d,ret=%d [return]", fd,
- nstack_get_module_name_by_idx (fdInf->rmidx), tfd, level, optname,
- ret);
- if (-1 == ret)
+ tfd = fdInf->rlfd;
+ NSTACK_CAL_FUN(fdInf->ops, getsockopt,
+ (tfd, level, optname, optval, optlen), ret);
+ NSSOC_LOGINF
+ ("fd=%d,module=%s,tfd=%d,level=%d,optname=%d,ret=%d[return]", fd,
+ nstack_get_module_name_by_idx(fdInf->rmidx), tfd, level,
+ optname, ret);
+ if ((-1 == ret) && (fdInf->rmidx != nstack_get_linux_mid()))
{
- NSSOC_LOGERR ("return fail]module=%d,fd=%d [return]", fdInf->rmidx,
- tfd);
+ NSSOC_LOGERR("return fail]mudle=%d,fd=%d[return]", fdInf->rmidx,
+ tfd);
}
- UNLOCK_COMMON (fd, local_lock);
- return ret;
+ UNLOCK_COMMON(fd, fdInf, local_lock);
+ return ret;
}
- if (NULL != g_nstack_modules.defMod)
+ if (NULL != g_nstack_modules.defMod)
{
- tfd = nstack_get_protoFd (fdInf, nstack_defMod_inx ());
- if (tfd >= 0)
+ tfd = nstack_get_proto_fd(fdInf, nstack_defmod_inx());
+ if (tfd >= 0)
{
- ops = nstack_def_ops ();
- NSTACK_CAL_FUN (ops, getsockopt,
- (tfd, level, optname, optval, optlen), ret);
- NSSOC_LOGINF
- ("fd=%d,module=%s:%d,level=%d,optname=%d,ret=%d [return]", fd,
- nstack_defmod_name (), tfd, level, optname, ret);
- if (-1 == ret)
+ ops = nstack_def_ops();
+ NSTACK_CAL_FUN(ops, getsockopt,
+ (tfd, level, optname, optval, optlen), ret);
+ NSSOC_LOGINF
+ ("fd=%d,module=%s:%d,level=%d,optname=%d,ret=%d[return]", fd,
+ nstack_defmod_name(), tfd, level, optname, ret);
+ if ((-1 == ret)
+ && (nstack_defmod_inx() != nstack_get_linux_mid()))
{
- NSSOC_LOGERR ("return fail]module=%d,fd=%d [return]",
- nstack_defMod_inx (), tfd);
+ NSSOC_LOGERR("return fail]mudle=%d,fd=%d[return]",
+ nstack_defmod_inx(), tfd);
}
- UNLOCK_COMMON (fd, local_lock);
- return ret;
+ UNLOCK_COMMON(fd, fdInf, local_lock);
+ return ret;
}
}
- nstack_set_errno (ENOTSOCK);
- NSSOC_LOGINF ("fd=%d,ret=%d [Return]", fd, ret);
- UNLOCK_COMMON (fd, local_lock);
- return ret;
+ nstack_set_errno(ENOTSOCK);
+ NSSOC_LOGINF("fd=%d,ret=%d [Return]", fd, ret);
+ UNLOCK_COMMON(fd, fdInf, local_lock);
+ return ret;
}
-/* all rlfd need setsockopt, set opt failed still can Establish connection. so we not care suc/fail */
-/* Currently, if setsockopt is successfull either in kernel or stack-x, the below API returns SUCCESS */
-int
-nstack_setsockopt (int fd, int level, int optname, const void *optval,
- socklen_t optlen)
+/* all rlfd need setsockopt, set opt failed still can Estblsh connection. so we not care suc/fail */
+/* Currently, if setsockopt is successfull either in kernel or lwip, the below API returns SUCCESS */
+int nstack_setsockopt(int fd, int level, int optname, const void *optval,
+ socklen_t optlen)
{
- nstack_fd_Inf *fdInf;
- int ret = -1;
- nstack_socket_ops *ops;
- int itfd;
- int modInx = 0;
- int curRet = -1;
- int lerror = 0;
- int flag = 0;
-
- NSTACK_INIT_CHECK_RET (setsockopt, fd, level, optname, optval, optlen);
-
- NSSOC_LOGINF
- ("(fd=%d, level=%d, optname=%d, optval=%p, optlen=%u) [Caller]", fd,
- level, optname, optval, optlen);
-
- if (fd < 0)
- {
- nstack_set_errno (EBADF);
- NSSOC_LOGERR ("invalid input]fd=%d [return]", fd);
- return -1;
- }
-
- NSTACK_FD_LINUX_CHECK (fd, setsockopt, fdInf,
- (fd, level, optname, optval, optlen));
-
- nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
- LOCK_COMMON (fd, fdInf, local_lock);
-
- if ((NSTACK_SOCKOPT == level) && NSTACK_IS_FD_EPOLL_SOCKET (fdInf))
- {
- ret = nstack_option_set (fdInf, optname, optval, optlen);
- UNLOCK_COMMON (fd, local_lock);
- return ret;
- }
-
- if (fdInf->ops)
- {
- itfd = fdInf->rlfd;
- NSTACK_CAL_FUN (fdInf->ops, setsockopt,
- (itfd, level, optname, optval, optlen), ret);
- NSSOC_LOGINF
- ("fd=%d,module=%s,tfd=%d,level=%d,optname=%d,ret=%d [return]", fd,
- nstack_get_module_name_by_idx (fdInf->rmidx), itfd, level, optname,
- ret);
- if (-1 == ret)
- {
- NSSOC_LOGERR ("return fail]module=%d,fd=%d [return]", fdInf->rmidx,
- itfd);
- }
- UNLOCK_COMMON (fd, local_lock);
- return ret;
- }
- nstack_each_modOps (modInx, ops)
- {
- itfd = nstack_get_protoFd (fdInf, modInx);
- if (-1 == itfd)
- {
- continue;
- }
- flag = 1;
- NSTACK_CAL_FUN (ops, setsockopt, (itfd, level, optname, optval, optlen),
- curRet);
- NSSOC_LOGDBG ("fd=%d,module=%s,tfd=%d,level=%d,optname=%d,ret=%d", fd,
- nstack_get_module_name_by_idx (modInx), itfd, level,
- optname, curRet);
- if (modInx == nstack_get_fix_mid ())
- {
- ret = curRet;
- /* errno is thread safe, but stack-x is not, so save it first */
- lerror = errno;
- }
- }
- /* errno is thread safe, but stack-x is not, so save it first begin */
- /*if all fd of stack is -1, the input fd maybe invalid */
- if (0 == flag)
- {
- nstack_set_errno (EBADF);
- }
- /*if linux return fail, and error is none zero, just reset it again */
- if ((lerror != 0) && (ns_success != ret))
- {
- nstack_set_errno (lerror);
- }
- /* errno is thread safe, but stack-x is not, so save it first end */
- NSSOC_LOGINF ("fd=%d,ret=%d [Return]", fd, ret);
- UNLOCK_COMMON (fd, local_lock);
- return ret;
+ nstack_fd_Inf *fdInf;
+ int ret = -1;
+ nstack_socket_ops *ops;
+ int itfd;
+ int modInx = 0;
+ int curRet = -1;
+ int lerror = 0;
+ int flag = 0;
+
+ NSTACK_INIT_CHECK_RET(setsockopt, fd, level, optname, optval, optlen);
+
+ NSSOC_LOGINF("fd=%d,level=%d,optname=%d,optval=%p,optlen=%u[Caller]",
+ fd, level, optname, optval, optlen);
+
+ if (fd < 0)
+ {
+ nstack_set_errno(EBADF);
+ NSSOC_LOGERR("invalid input]fd=%d[return]", fd);
+ return -1;
+ }
+
+ NSTACK_FD_LINUX_CHECK_RETURN(fd, setsockopt, fdInf,
+ (fd, level, optname, optval, optlen));
+
+ nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
+ LOCK_COMMON(fd, fdInf, local_lock);
+
+ if ((NSTACK_SOCKOPT == level) &&
+ (NSTACK_IS_FD_EPOLL_SOCKET(fdInf) || NSTACK_RD_MODE == optname))
+ {
+ ret = nstack_option_set(fdInf, optname, optval, optlen);
+ UNLOCK_COMMON(fd, fdInf, local_lock);
+ return ret;
+ }
+
+ if (fdInf->ops)
+ {
+ itfd = fdInf->rlfd;
+ NSTACK_CAL_FUN(fdInf->ops, setsockopt,
+ (itfd, level, optname, optval, optlen), ret);
+ NSSOC_LOGINF
+ ("fd=%d,module=%s,tfd=%d,level=%d,optname=%d,ret=%d[return]", fd,
+ nstack_get_module_name_by_idx(fdInf->rmidx), itfd, level,
+ optname, ret);
+ if ((-1 == ret) && (fdInf->rmidx != nstack_get_linux_mid()))
+ {
+ NSSOC_LOGERR("return fail]mudle=%d,fd=%d[return]", fdInf->rmidx,
+ itfd);
+ }
+ UNLOCK_COMMON(fd, fdInf, local_lock);
+ return ret;
+ }
+ nstack_each_mod_ops(modInx, ops)
+ {
+ itfd = nstack_get_proto_fd(fdInf, modInx);
+ if (-1 == itfd)
+ {
+ continue;
+ }
+ flag = 1;
+ NSTACK_CAL_FUN(ops, setsockopt,
+ (itfd, level, optname, optval, optlen), curRet);
+ NSSOC_LOGDBG("fd=%d,module=%s,tfd=%d,level=%d,optname=%d,ret=%d", fd,
+ nstack_get_module_name_by_idx(modInx), itfd, level,
+ optname, curRet);
+ if (modInx == nstack_get_linux_mid())
+ {
+ ret = curRet;
+ /*errno is thread safe, but stackpool is not, so save it first */
+ lerror = errno;
+ }
+ }
+ /* errno is thread safe, but stackpool is not, so save it first */
+ /*if all fd of stack is -1, the input fd maybe invalid */
+ if (0 == flag)
+ {
+ nstack_set_errno(EBADF);
+ }
+ /*if linux return fail, and error is none zero, just reset it again */
+ if ((lerror != 0) && (ns_success != ret))
+ {
+ nstack_set_errno(lerror);
+ }
+ /*errno is thread safe, but stackpool is not, so save it first */
+ NSSOC_LOGINF("fd=%d,ret=%d[Return]", fd, ret);
+ UNLOCK_COMMON(fd, fdInf, local_lock);
+ return ret;
}
-int
-nstack_ioctl (int fd, unsigned long request, unsigned long argp)
+int nstack_ioctl(int fd, unsigned long request, unsigned long argp)
{
- nstack_fd_Inf *fdInf;
- int ret = -1;
- nstack_socket_ops *ops;
- int tfd;
- int modInx = 0;
- int curRet = -1;
- int lerror = 0;
- int flag = 0;
+ nstack_fd_Inf *fdInf;
+ int ret = -1;
+ nstack_socket_ops *ops;
+ int tfd;
+ int modInx = 0;
+ int curRet = -1;
+ int lerror = 0;
+ int flag = 0;
- NSTACK_INIT_CHECK_RET (ioctl, fd, request, argp);
+ NSTACK_INIT_CHECK_RET(ioctl, fd, request, argp);
- NSSOC_LOGINF ("(fd=%d, request=%lu) [Caller]", fd, request);
- if (fd < 0)
+ NSSOC_LOGINF("fd=%d,request=%lu[Caller]", fd, request);
+ if (fd < 0)
{
- nstack_set_errno (EBADF);
- NSSOC_LOGERR ("invalid input]fd=%d [return]", fd);
- return -1;
+ nstack_set_errno(EBADF);
+ NSSOC_LOGERR("invalid input]fd=%d[return]", fd);
+ return -1;
}
- NSTACK_FD_LINUX_CHECK (fd, ioctl, fdInf, (fd, request, argp));
+ NSTACK_FD_LINUX_CHECK_RETURN(fd, ioctl, fdInf, (fd, request, argp));
- nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
+ nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
- LOCK_COMMON (fd, fdInf, local_lock);
- if (fdInf->ops)
+ LOCK_COMMON(fd, fdInf, local_lock);
+ if (fdInf->ops)
{
- tfd = fdInf->rlfd;
- NSTACK_CAL_FUN (fdInf->ops, ioctl, (tfd, request, argp), ret);
- NSSOC_LOGINF ("fd=%d,module=%s,rlfd=%d,argp=0x%x,ret=%d [return]",
- fd, nstack_get_module_name_by_idx (fdInf->rmidx),
- fdInf->rlfd, argp, ret);
- if (-1 == ret)
+ tfd = fdInf->rlfd;
+ NSTACK_CAL_FUN(fdInf->ops, ioctl, (tfd, request, argp), ret);
+ NSSOC_LOGINF("fd=%d,module=%s,rlfd=%d,argp=0x%x,ret=%d[return]",
+ fd, nstack_get_module_name_by_idx(fdInf->rmidx),
+ fdInf->rlfd, argp, ret);
+ if ((-1 == ret) && (fdInf->rmidx != nstack_get_linux_mid()))
{
- NSSOC_LOGERR ("return fail]module=%d,fd=%d [return]", fdInf->rmidx,
- tfd);
+ NSSOC_LOGERR("return fail]mudle=%d,fd=%d[return]", fdInf->rmidx,
+ tfd);
}
- UNLOCK_COMMON (fd, local_lock);
- return ret;
+ UNLOCK_COMMON(fd, fdInf, local_lock);
+ return ret;
}
- nstack_each_modOps (modInx, ops)
- {
- tfd = nstack_get_protoFd (fdInf, modInx);
- if (-1 == tfd)
- {
- continue;
- }
- flag = 1;
+ nstack_each_mod_ops(modInx, ops)
+ {
+ tfd = nstack_get_proto_fd(fdInf, modInx);
+ if (-1 == tfd)
+ {
+ continue;
+ }
+ flag = 1;
- NSTACK_CAL_FUN (ops, ioctl, (tfd, request, argp), curRet);
- NSSOC_LOGINF ("fd=%d,module=%s,tfd=%d,argp=0x%x,ret=%d ",
- fd, nstack_get_module_name_by_idx (modInx), tfd, argp,
- curRet);
- if (modInx == nstack_get_fix_mid ())
- {
- ret = curRet;
- /* errno is thread safe, but stack-x is not, so save it first */
- lerror = errno;
- }
- }
- /* errno is thread safe, but stack-x is not, so save it first */
- if (0 == flag)
+ NSTACK_CAL_FUN(ops, ioctl, (tfd, request, argp), curRet);
+ NSSOC_LOGINF("fd=%d,module=%s,tfd=%d,argp=0x%x,ret=%d ",
+ fd, nstack_get_module_name_by_idx(modInx), tfd, argp,
+ curRet);
+ if (modInx == nstack_get_linux_mid())
+ {
+ ret = curRet;
+ /*errno is thread safe, but stackpool is not, so save it first */
+ lerror = errno;
+ }
+ }
+ /*errno is thread safe, but stackpool is not, so save it first */
+ if (0 == flag)
{
- nstack_set_errno (EBADF);
+ nstack_set_errno(EBADF);
}
- if ((0 != lerror) && (ns_success != ret))
+ if ((0 != lerror) && (ns_success != ret))
{
- nstack_set_errno (lerror);
+ nstack_set_errno(lerror);
}
+ /*errno is thread safe, but stackpool is not, so save it first */
- NSSOC_LOGINF ("fd=%d,ret=%d [return]", fd, ret);
+ NSSOC_LOGINF("fd=%d,ret=%d[return]", fd, ret);
- UNLOCK_COMMON (fd, local_lock);
- return ret;
+ UNLOCK_COMMON(fd, fdInf, local_lock);
+ return ret;
}
-int
-nstack_fcntl (int fd, int cmd, unsigned long argp)
+int nstack_fcntl(int fd, int cmd, unsigned long argp)
{
- nstack_fd_Inf *fdInf;
- nstack_socket_ops *ops = NULL;
- int ret = -1;
- int noProOpt = 0;
- int tfd;
- int modInx = 0;
- int curRet = -1;
- int lerror = 0;
- int flag = 0;
+ nstack_fd_Inf *fdInf;
+ nstack_socket_ops *ops = NULL;
+ int ret = -1;
+ int noProOpt = 0;
+ int tfd;
+ int modInx = 0;
+ int curRet = -1;
+ int lerror = 0;
+ int flag = 0;
- NSTACK_INIT_CHECK_RET (fcntl, fd, cmd, argp);
+ NSTACK_INIT_CHECK_RET(fcntl, fd, cmd, argp);
- NSSOC_LOGINF ("(fd=%d, cmd=%d) [Caller]", fd, cmd);
- if (fd < 0)
+ NSSOC_LOGINF("fd=%d,cmd=%d[Caller]", fd, cmd);
+ if (fd < 0)
{
- nstack_set_errno (EBADF);
- NSSOC_LOGERR ("invalid input]fd=%d [return]", fd);
- return -1;
+ nstack_set_errno(EBADF);
+ NSSOC_LOGERR("invalid input]fd=%d[return]", fd);
+ return -1;
}
- NSTACK_FD_LINUX_CHECK (fd, fcntl, fdInf, (fd, cmd, argp));
+ NSTACK_FD_LINUX_CHECK_RETURN(fd, fcntl, fdInf, (fd, cmd, argp));
- nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
- LOCK_COMMON (fd, fdInf, local_lock);
+ nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
+ LOCK_COMMON(fd, fdInf, local_lock);
- /*have already bind */
- if (fdInf->ops)
+ /*have already bind */
+ if (fdInf->ops)
{
- tfd = fdInf->rlfd;
- NSTACK_CAL_FUN (fdInf->ops, fcntl, (tfd, cmd, argp), ret);
- NSSOC_LOGINF ("fd=%d,cmd=%d,mod=%s,tfd=%d,argp=0x%x,ret=%d",
- fd, cmd, nstack_get_module_name_by_idx (fdInf->rmidx),
- tfd, argp, ret);
- if (-1 == ret)
+ tfd = fdInf->rlfd;
+ NSTACK_CAL_FUN(fdInf->ops, fcntl, (tfd, cmd, argp), ret);
+ NSSOC_LOGINF("fd=%d,cmd=%d,mod=%s,tfd=%d,argp=0x%x,ret=%d",
+ fd, cmd, nstack_get_module_name_by_idx(fdInf->rmidx),
+ tfd, argp, ret);
+ if ((-1 == ret) && (fdInf->rmidx != nstack_get_linux_mid()))
{
- NSSOC_LOGERR ("return fail]module=%d,fd=%d", fdInf->rmidx, tfd);
+ NSSOC_LOGERR("return fail]mudle=%d,fd=%d", fdInf->rmidx, tfd);
}
}
- else
+ else
{
- /*set cmd call all module, and return just linux */
- if (F_SETFL == cmd)
+ /*set cmd call all module, and return just linux */
+ if (F_SETFL == cmd)
{
- nstack_each_modOps (modInx, ops)
- {
- tfd = nstack_get_protoFd (fdInf, modInx);
- if (-1 == tfd)
- {
- continue;
- }
- flag = 1;
- noProOpt = 0;
- NSTACK_CAL_FUN (ops, fcntl, (tfd, cmd, argp), curRet);
- NSSOC_LOGINF ("fd=%d,module=%s,tfd=%d,argp=0x%x,ret=%d ",
- fd, nstack_get_module_name_by_idx (modInx), tfd,
- argp, curRet);
- if (modInx == nstack_get_fix_mid ())
- {
- ret = curRet;
- lerror = errno;
- }
- }
- /* errno is thread safe, but stack-x is not, so save it first */
- if (0 == flag)
+ nstack_each_mod_ops(modInx, ops)
+ {
+ tfd = nstack_get_proto_fd(fdInf, modInx);
+ if (-1 == tfd)
+ {
+ continue;
+ }
+ flag = 1;
+ noProOpt = 0;
+ NSTACK_CAL_FUN(ops, fcntl, (tfd, cmd, argp), curRet);
+ NSSOC_LOGINF("fd=%d,module=%s,tfd=%d,argp=0x%x,ret=%d ",
+ fd, nstack_get_module_name_by_idx(modInx), tfd,
+ argp, curRet);
+ if (modInx == nstack_get_linux_mid())
+ {
+ ret = curRet;
+ lerror = errno;
+ }
+ }
+ /*errno is thread safe, but stackpool is not, so save it first */
+ if (0 == flag)
{
- nstack_set_errno (EBADF);
+ nstack_set_errno(EBADF);
}
- if ((0 != lerror) && (ns_success != ret))
+ if ((0 != lerror) && (ns_success != ret))
{
- nstack_set_errno (lerror);
+ nstack_set_errno(lerror);
}
+ /*errno is thread safe, but stackpool is not, so save it first */
} /*other cmd call default */
- else if (g_nstack_modules.defMod)
+ else if (g_nstack_modules.defMod)
{
- tfd = nstack_get_protoFd (fdInf, g_nstack_modules.defMod->modInx);
- if (tfd >= 0)
+ tfd = nstack_get_proto_fd(fdInf, g_nstack_modules.defMod->modInx);
+ if (tfd >= 0)
{
- ops = nstack_def_ops ();
- NSTACK_CAL_FUN (ops, fcntl, (tfd, cmd, argp), ret);
- NSSOC_LOGINF ("fd=%d,cmd=%d,mod=%s,tfd=%d,argp=0x%x,ret=%d",
- fd, cmd, g_nstack_modules.defMod->modulename, tfd,
- argp, ret);
- if (-1 == ret)
+ ops = nstack_def_ops();
+ NSTACK_CAL_FUN(ops, fcntl, (tfd, cmd, argp), ret);
+ NSSOC_LOGINF("fd=%d,cmd=%d,mod=%s,tfd=%d,argp=0x%x,ret=%d",
+ fd, cmd, g_nstack_modules.defMod->modulename,
+ tfd, argp, ret);
+ if ((-1 == ret) && (fdInf->rmidx != nstack_get_linux_mid()))
{
- NSSOC_LOGERR ("return fail]module=%d,fd=%d",
- g_nstack_modules.defMod->modInx, tfd);
+ NSSOC_LOGERR("return fail]mudle=%d,fd=%d",
+ g_nstack_modules.defMod->modInx, tfd);
}
}
- else
+ else
{
- noProOpt = 1;
+ noProOpt = 1;
}
}
- else
+ else
{
- noProOpt = 1;
+ noProOpt = 1;
}
}
- if (noProOpt)
+ if (noProOpt)
{
- nstack_set_errno (EBADF);
- NSSOC_LOGINF ("fd=%d,ret=%d", fd, ret);
+ nstack_set_errno(EBADF);
+ NSSOC_LOGINF("fd=%d,ret=%d", fd, ret);
}
- NSSOC_LOGINF ("fd=%d,cmd=%d,ret=%d [return]", fd, cmd, ret);
- UNLOCK_COMMON (fd, local_lock);
- return ret;
+ NSSOC_LOGINF("fd=%d,cmd=%d,ret=%d[return]", fd, cmd, ret);
+ UNLOCK_COMMON(fd, fdInf, local_lock);
+ return ret;
}
-/*****************************************************************************
-* Prototype : nstack_select
-* Description : nstack_select
-* Input : int nfds
-* fd_set *readfds
-* fd_set *writefds
-* fd_set *exceptfds
-* struct timeval *timeout
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*****************************************************************************/
-int
-nstack_select (int nfds, fd_set * readfds, fd_set * writefds,
- fd_set * exceptfds, struct timeval *timeout)
+int nstack_select(int nfds, fd_set * readfds, fd_set * writefds,
+ fd_set * exceptfds, struct timeval *timeout)
{
- int ret = -1;
-
- struct select_entry *entry = NULL;
- struct select_module_info *select_module = get_select_module ();
- u64_t msec;
+ struct select_module_info *select_module = get_select_module();
- int i;
+ NSTACK_INIT_CHECK_RET(select, nfds, readfds, writefds, exceptfds,
+ timeout);
- NSTACK_INIT_CHECK_RET (select, nfds, readfds, writefds, exceptfds, timeout);
-
- if ((nfds > __FD_SETSIZE) || (nfds < 0)
- || ((timeout) && ((timeout->tv_sec < 0) || (timeout->tv_usec < 0))))
+ if (NFDS_NOT_VALID(nfds) || TIMEVAL_NOT_VALID(timeout))
{
- NSSOC_LOGERR ("paremeter of nfds or timeout are no correct.]nfds = %d \
- sec = %ld usec = %ld", nfds, timeout->tv_sec, timeout->tv_usec);
- errno = EINVAL;
- return -1;
+ NSSOC_LOGERR("paremeter of nfds or timeout are no correct]nfds=%d \
+ sec=%ld usec=%ld", nfds, timeout->tv_sec, timeout->tv_usec);
+ errno = EINVAL;
+ return -1;
}
- for (i = 0; i < nfds; i++)
- {
- if ((readfds) && (FD_ISSET (i, readfds)))
- {
- NSSOC_LOGDBG ("input readfd set %d", i);
- }
+ print_select_dbg(nfds, readfds, writefds, exceptfds);
- if ((writefds) && (FD_ISSET (i, writefds)))
- {
- NSSOC_LOGDBG ("input writefd set %d", i);
- }
- if ((exceptfds) && (FD_ISSET (i, exceptfds)))
- {
- NSSOC_LOGDBG ("input exceptfds set %d", i);
- }
- }
-
- /*check the module had regist or not */
- if (TRUE != NSTACK_SELECT_LINUX_CHECK ())
+ /*check the module had regist or not */
+ if (TRUE != NSTACK_SELECT_LINUX_CHECK())
{
- return nsfw_base_select (nfds, readfds, writefds, exceptfds, timeout);
+ return nsfw_base_select(nfds, readfds, writefds, exceptfds, timeout);
}
- /*nstack select not support timer function and not check nfds so calling default select */
- if ((nfds <= 0)
- || ((NULL == readfds) && (NULL == writefds) && (NULL == exceptfds)))
+ /*nstack select not support timer function and not check nfds so calling dufault select */
+ if (is_select_used_as_timer(nfds, readfds, writefds, exceptfds))
{
- if ((select_module) && (select_module->default_fun))
+ if ((select_module) && (select_module->default_fun))
{
- return select_module->default_fun (nfds, readfds, writefds,
- exceptfds, timeout);
+ return select_module->default_fun(nfds, readfds, writefds,
+ exceptfds, timeout);
}
- else
+ else
{
- return nsfw_base_select (nfds, readfds, writefds, exceptfds,
- timeout);
+ return nsfw_base_select(nfds, readfds, writefds, exceptfds,
+ timeout);
}
}
- entry = (struct select_entry *) select_alloc (sizeof (struct select_entry));
- if (NULL == entry)
- {
- errno = ENOMEM;
- NSSOC_LOGERR ("select entry alloc failed");
- goto err_return;
- }
+ return nstack_select_processing(nfds, readfds, writefds, exceptfds,
+ timeout);
- /* fix dead-code type Codex issue */
- /*split select fd to each modules fd and save to entry */
- (void) select_cb_split_by_mod (nfds, readfds, writefds, exceptfds, entry);
+}
- /*if all fd in default module we just calling it */
- if (entry->info.set_num <= 1)
- {
+/* epfd?fd maybe is from kernel or stackpool,should take care */
+int nstack_epoll_ctl(int epfd, int op, int fd, struct epoll_event *event)
+{
+ int ret = ns_fail;
+ struct eventpoll *ep = NULL;
+ nstack_fd_Inf *epInf;
+ struct epoll_event ep_event = { 0 };
+ struct epitem *epi = NULL;
- /*adapte linux */
- if ((select_module)
- && (entry->info.index == select_module->default_mod))
- {
- if (select_module->default_fun)
- {
- ret =
- select_module->default_fun (nfds, readfds, writefds,
- exceptfds, timeout);
- }
- else
- {
- ret =
- nsfw_base_select (nfds, readfds, writefds, exceptfds,
- timeout);
- }
- goto err_return;
- }
+ NSTACK_INIT_CHECK_RET(epoll_ctl, epfd, op, fd, event);
+
+ NSSOC_LOGINF("epfd=%d,op=%d,fd=%d,event=%p[Caller]", epfd, op, fd, event);
+ if (event)
+ {
+ NSSOC_LOGINF("event->data.fd=%d,event->events=%u", event->data.fd,
+ event->events);
}
- /*checking if event ready or not */
- if (FALSE == select_scan (entry))
+ NSTACK_FD_LINUX_CHECK_RETURN(epfd, epoll_ctl, epInf,
+ (epfd, op, fd, event));
+
+ nstack_fd_local_lock_info_t *epoll_local_lock = &epInf->local_lock;
+ LOCK_EPOLL(epfd, epInf, epoll_local_lock);
+ nstack_fd_local_lock_info_t *local_lock = get_fd_local_lock_info(fd);
+ LOCK_EPOLL_CTRL_RETURN(fd, local_lock, epfd, epoll_local_lock);
+
+ if (!NSTACK_IS_FD_EPOLL_SOCKET(epInf) || fd == epfd) /* `man epoll_ctl` tells me to do this check :) */
{
- NSSOC_LOGERR ("select scan failed");
- goto err_return;
+ NSSOC_LOGWAR("epfd=%d is not a epoll fd[return]", epfd);
+ errno = EINVAL;
+ goto err_return;
}
- if (entry->ready.readyset != 0)
+ if (!nstack_is_nstack_sk(fd))
{
- goto scan_return;
+ NSSOC_LOGWAR("epfd=%d ,fd %d is not a supported [return]", epfd, fd);
+ errno = EBADF;
+ goto err_return;
}
- if ((timeout) && (timeout->tv_sec == 0) && (timeout->tv_usec == 0))
+ nsep_epollInfo_t *epInfo = nsep_get_info_by_sock(epfd);
+ if (NULL == epInfo)
{
- goto scan_return;
+ NSSOC_LOGWAR("epInfo of epfd=%d is NULL[return]", epfd);
+ errno = EINVAL;
+ goto err_return;
}
- if (FALSE == select_add_cb (entry))
+ ep = SHMEM_ADDR_SHTOL(epInfo->ep);
+ if (NULL == ep)
{
- errno = ENOMEM;
- NSSOC_LOGERR ("select entry add failed");
- goto err_return;
+ NSSOC_LOGWAR("ep of epfd=%d is NULL[return]", epfd);
+ errno = EINVAL;
+ goto err_return;
}
- if (NULL == timeout)
+ if (NULL != event)
{
- select_sem_wait (&entry->sem);
+ ep_event.data = event->data;
+ ep_event.events = event->events;
}
- else
+ else
{
- u64_t time_cost;
- if (nstack_timeval2msec (timeout, &msec))
+ if (op != EPOLL_CTL_DEL)
{
- nstack_set_errno (EINVAL);
- goto err_return;
- }
- time_cost = nstack_sem_timedwait (&entry->sem, msec);
- if (time_cost >= msec)
- {
- timeout->tv_sec = 0;
- timeout->tv_usec = 0;
- }
- else if (time_cost > 0)
- {
- msec = msec - time_cost;
- timeout->tv_sec = msec / 1000;
- timeout->tv_usec = (msec % 1000) * 1000;
+ NSSOC_LOGWAR("events epfd=%d is NULL[return]", epfd);
+ errno = EFAULT;
+ goto err_return;
}
}
- select_rm_cb (entry);
+ dmm_spin_lock_with_pid((dmm_spinlock_t *) (&ep->sem)); /*do not need return value */
-scan_return:
- if (readfds)
+ epi = nsep_find_ep(ep, fd);
+ switch (op)
{
- *readfds = entry->ready.readset;
- }
- if (writefds)
- {
- *writefds = entry->ready.writeset;
- }
- if (exceptfds)
- {
- *exceptfds = entry->ready.exceptset;
- }
+ case EPOLL_CTL_ADD:
+ if (!epi)
+ {
- ret = entry->ready.readyset;
- if (ret < 0)
- {
- errno = entry->ready.select_errno;
- }
+ ep_event.events |= (EPOLLERR | EPOLLHUP); // Check `man epoll_ctl` if you don't understand , smile :)
-err_return:
- if (entry)
- {
- select_free ((char *) entry);
- }
- NSSOC_LOGDBG
- ("(nfds=%d,readfds=%p,writefds=%p,exceptfds=%p,timeout=%p),ret=%d errno = %d",
- nfds, readfds, writefds, exceptfds, timeout, ret, errno);
- return ret;
-}
+ dmm_read_lock(get_fork_lock()); /* to ensure that there is no fd to create and close when fork. */
+ ret = nsep_epctl_add(ep, epInfo, fd, &ep_event);
+ dmm_read_unlock(get_fork_lock());
+ }
+ else
+ {
+ NSSOC_LOGWAR("fd already in eventpoll");
+ errno = EEXIST;
+ ret = -1;
+ }
+ break;
+ case EPOLL_CTL_DEL:
+ if (epi)
+ {
+ dmm_read_lock(get_fork_lock());
+ ret = nsep_epctl_del(ep, epi);
+ dmm_read_unlock(get_fork_lock());
+ }
+ else
+ {
+ NSSOC_LOGWAR("fd not registed before");
+ errno = ENOENT;
+ ret = -1;
+ }
+ break;
+ case EPOLL_CTL_MOD:
+ if (epi)
+ {
-/* epfd?fd maybe is from kernel or stack-x,should take care */
-int
-nstack_epoll_ctl (int epfd, int op, int fd, struct epoll_event *event)
-{
- int ret = ns_fail;
- struct eventpoll *ep = NULL;
- nstack_fd_Inf *epInf;
- struct epoll_event ep_event = { 0 };
- struct epitem *epi = NULL;
+ ep_event.events |= (EPOLLERR | EPOLLHUP); // Look up ?
- NSTACK_INIT_CHECK_RET (epoll_ctl, epfd, op, fd, event);
+ ret =
+ nsep_epctl_mod(ep, nsep_get_info_by_sock(fd), epi,
+ &ep_event);
+ }
+ else
+ {
+ NSSOC_LOGWAR("fd not registed before");
+ errno = ENOENT;
+ ret = -1;
+ }
+ break;
+ default:
+ NSSOC_LOGERR("epfd=%d,fd=%d,opt=%d not supported", epfd, fd, op);
+ errno = EINVAL;
+ ret = -1;
+ }
- NSSOC_LOGINF ("(epfd=%d, op=%d, fd=%d, event=%p) [Caller]", epfd, op, fd,
- event);
- if (event)
- NSSOC_LOGINF ("event->data.fd=%d,event->events=%u", event->data.fd,
- event->events);
+ dmm_spin_unlock((dmm_spinlock_t *) (&ep->sem));
+ NSSOC_LOGINF("epfd=%d,op=%d,fd=%d,ret=%d[return]", epfd, op, fd, ret);
- NSTACK_FD_LINUX_CHECK (epfd, epoll_ctl, epInf, (epfd, op, fd, event));
+ err_return:
+ UNLOCK_EPOLL_CTRL(fd, local_lock);
+ UNLOCK_EPOLL(epfd, epoll_local_lock);
+ return ret;
+}
- nstack_fd_local_lock_info_t *epoll_local_lock = &epInf->local_lock;
- LOCK_EPOLL (epfd, epInf, epoll_local_lock);
- nstack_fd_local_lock_info_t *local_lock = get_fd_local_lock_info (fd);
- LOCK_EPOLL_CTRL (fd, local_lock, epfd, epoll_local_lock);
+int nstack_epoll_create(int size)
+{
+ nstack_fd_Inf *fdInf = NULL;
+ struct eventpoll *ep = NULL;
+ struct spl_conn_pool *ep_conn = NULL;
+ int epfd = -1;
- if (!NSTACK_IS_FD_EPOLL_SOCKET (epInf) || fd == epfd) /* `man epoll_ctl` tells me to do this check :) */
- {
- NSSOC_LOGWAR ("epfd=%d is not a epoll fd [return]", epfd);
- errno = EINVAL;
- goto err_return;
- }
+ NSTACK_INIT_CHECK_RET(epoll_create, size);
+ NSSOC_LOGINF("size=%d[Caller]", size);
- if (!nstack_is_nstack_sk (fd))
+ if (size <= 0)
{
- NSSOC_LOGWAR ("epfd=%d ,fd %d is not a supported [return]", epfd, fd);
- errno = EBADF;
- goto err_return;
+ errno = EINVAL;
+ NSSOC_LOGERR("invalid input,param]size=%d[return]", size);
+ return -1;
}
+#ifdef KERNEL_FD_SUPPORT
+ epfd = nsfw_base_epoll_create(size);
- nsep_epollInfo_t *epInfo = nsep_get_infoBySock (epfd);
- if (NULL == epInfo)
+ if (!nstack_is_nstack_sk(epfd))
{
- NSSOC_LOGWAR ("epInfo of epfd=%d is NULL [return]", epfd);
- errno = EINVAL;
- goto err_return;
+ nsfw_base_close(epfd); /*do not need return value */
+ NSSOC_LOGERR("kernel fd alloced is too larger]kernel_fd=%d[return]",
+ epfd);
+ errno = EMFILE;
+ return -1;
}
- ep = ADDR_SHTOL (epInfo->ep);
- if (NULL == ep)
+ nstack_fd_local_lock_info_t *lock_info = get_fd_local_lock_info(epfd);
+ LOCK_FOR_EP(lock_info);
+ fdInf = nstack_lk_fd_alloc_with_kernel(epfd);
+#else
+ fdInf = nstack_lk_fd_alloc_without_kernel();
+#endif
+ if (NULL == fdInf)
{
- NSSOC_LOGWAR ("ep of epfd=%d is NULL [return]", epfd);
- errno = EINVAL;
- goto err_return;
+ NSSOC_LOGERR("create fdInf fail[return]");
+ errno = ENOMEM;
+#ifdef KERNEL_FD_SUPPORT
+ nsfw_base_close(epfd); /*do not need return value */
+ UNLOCK_FOR_EP(lock_info);
+#endif
+ return -1;
}
- if (NULL != event)
- {
- ep_event.data = event->data;
- ep_event.events = event->events;
- }
- else
- {
- if (op != EPOLL_CTL_DEL)
- {
- NSSOC_LOGWAR ("events epfd=%d is NULL [return]", epfd);
- errno = EFAULT;
- goto err_return;
- }
- }
+#ifndef KERNEL_FD_SUPPORT
+ epfd = fdInf->fd;
+ nstack_fd_local_lock_info_t *lock_info = get_fd_local_lock_info(epfd);
+ LOCK_FOR_EP(lock_info);
+#endif
- sys_arch_lock_with_pid (&ep->sem);
+ /* here can't check return value, because if daemon-stack is old version, then here will fail, it is normal scenario */
+ (void) nsep_alloc_ep_spl_conn_ring(&ep_conn);
- epi = nsep_find_ep (ep, fd);
- switch (op)
+ int pesudoEpIdx = nsep_alloc_eventpoll(&ep);
+ if (pesudoEpIdx < 0)
{
- case EPOLL_CTL_ADD:
- if (!epi)
- {
- ep_event.events |= (EPOLLERR | EPOLLHUP); // Check `man epoll_ctl` if you don't understand , smile :)
- common_mem_rwlock_read_lock (get_fork_lock ()); /* to ensure that there is no fd to create and close when fork. added by tongshaojun t00391048 */
- ret = nsep_epctl_add (ep, fd, &ep_event);
- common_mem_rwlock_read_unlock (get_fork_lock ());
- }
- else
- {
- NSSOC_LOGWAR ("fd already in eventpoll");
- errno = EEXIST;
- ret = -1;
- }
- break;
- case EPOLL_CTL_DEL:
- if (epi)
- {
- common_mem_rwlock_read_lock (get_fork_lock ());
- ret = nsep_epctl_del (ep, epi);
- common_mem_rwlock_read_unlock (get_fork_lock ());
- }
- else
- {
- NSSOC_LOGWAR ("fd not registered before");
- errno = ENOENT;
- ret = -1;
- }
- break;
- case EPOLL_CTL_MOD:
- if (epi)
- {
- ep_event.events |= (EPOLLERR | EPOLLHUP); // Look up ?
- ret = nsep_epctl_mod (ep, nsep_get_infoBySock (fd), epi, &ep_event);
- }
- else
- {
- NSSOC_LOGWAR ("fd not registered before");
- errno = ENOENT;
- ret = -1;
- }
- break;
- default:
- NSSOC_LOGERR ("epfd=%d,fd=%d,opt=%d not supported", epfd, fd, op);
- errno = EINVAL;
- ret = -1;
+ nsep_free_info_with_sock(epfd); /*do not need return value */
+ NSSOC_LOGERR("Alloc eventpoll fail[return]");
+#ifdef KERNEL_FD_SUPPORT
+ nstack_fd_free_with_kernel(fdInf); /*do not need return value */
+#else
+ nstack_fd_free(fdInf);
+#endif
+ (void) nsep_free_ep_spl_conn_ring(ep_conn);
+ errno = ENOMEM;
+ UNLOCK_FOR_EP(lock_info);
+ return -1;
}
- sys_sem_s_signal (&ep->sem);
- NSSOC_LOGINF ("epfd=%d,op=%d,fd=%d,ret=%d [return]", epfd, op, fd, ret);
+ ep->epfd = epfd;
+ nsep_set_info_ep_resource(epfd, ep, ep_conn);
+ NSTACK_SET_FD_EPOLL_SOCKET(fdInf);
-err_return:
- UNLOCK_EPOLL_CTRL (fd, local_lock);
- UNLOCK_EPOLL (epfd, epoll_local_lock);
- return ret;
+ NSSOC_LOGINF("fd=%d[return]", epfd);
+ set_fd_status_lock_fork(epfd, FD_OPEN);
+ UNLOCK_FOR_EP(lock_info);
+ return epfd;
}
-int
-nstack_epoll_create (int size)
+int nstack_epoll_wait(int epfd, struct epoll_event *events, int maxevents,
+ int timeout)
{
- nstack_fd_Inf *fdInf = NULL;
- struct eventpoll *ep = NULL;
- int epfd = -1;
- int modInx = 0;
- int tfd = 0;
- nstack_socket_ops *ops;
- int ret = 0;
+ nstack_fd_Inf *fdInf = NULL;
+ nsep_epollInfo_t *epInfo = NULL;
+ struct eventpoll *ep = NULL;
+ struct spl_conn_pool *ep_conn = NULL;
+ int evt = 0;
+ int ret = 0;
+ int evt_ns = 0;
- NSTACK_INIT_CHECK_RET (epoll_create, size);
+ NSTACK_INIT_CHECK_RET(epoll_wait, epfd, events, maxevents, timeout);
- NSSOC_LOGINF ("(size=%d) [Caller]", size);
+ NSTACK_FD_LINUX_CHECK_RETURN(epfd, epoll_wait, fdInf,
+ (epfd, events, maxevents, timeout));
- if (size <= 0)
+ nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
+ LOCK_EPOLL(epfd, fdInf, local_lock);
+
+ if (!NSTACK_IS_FD_EPOLL_SOCKET(fdInf))
{
- nstack_set_errno (EINVAL);
- NSSOC_LOGERR ("invalid input,param]size=%d [return]", size);
- return -1;
+ NSSOC_LOGWAR("epfd=%d is not a epoll fd", epfd);
+ errno = EINVAL;
+ UNLOCK_EPOLL(epfd, local_lock);
+ return -1;
}
- /*create a epfd */
- if (nstack_fix_mid_ops ()->pfepoll_create)
+ /* should check input paramter's validity */
+ if (NULL == events)
{
- epfd = nstack_fix_mid_ops ()->pfepoll_create (size);
+ NSSOC_LOGWAR("events is NULL");
+ errno = EINVAL;
+ UNLOCK_EPOLL(epfd, local_lock);
+ return -1;
}
- else
+
+ epInfo = nsep_get_info_by_sock(epfd);
+ if (NULL == epInfo)
{
- /*if not surport epfd create, just alloc a fd */
- if (nstack_extern_deal (nstack_get_fix_mid ()).stack_alloc_fd)
- {
- epfd = nstack_extern_deal (nstack_get_fix_mid ()).stack_alloc_fd ();
- }
- else
- {
- nstack_set_errno (ENOSYS);
- NSSOC_LOGERR ("not surport epoll create]size=%d [return]", size);
- return -1;
- }
+ NSSOC_LOGWAR("epInfo is NULL]epinfo=%p,epfd=%d", epInfo, epfd);
+ errno = EINVAL;
+ UNLOCK_EPOLL(epfd, local_lock);
+ return -1;
}
- if (!nstack_is_nstack_sk (epfd))
+
+ ep = SHMEM_ADDR_SHTOL(epInfo->ep);
+ if (NULL == ep)
{
- if (epfd >= 0)
- {
- NSTACK_CAL_FUN (nstack_fix_mid_ops (), close, (epfd), ret);
- }
- NSSOC_LOGERR ("kernel fd alloced is too larger]kernel_fd=%d [return]",
- epfd);
- nstack_set_errno (EMFILE);
- return -1;
+ NSSOC_LOGWAR("fdInf->ep is NULL]epinfo=%p,epfd=%d", epInfo, epfd);
+ errno = EINVAL;
+ UNLOCK_EPOLL(epfd, local_lock);
+ return -1;
}
- nstack_fd_local_lock_info_t *lock_info = get_fd_local_lock_info (epfd);
- LOCK_FOR_EP (lock_info);
- fdInf = nstack_lk_fd_alloc_with_kernel (epfd);
- if (NULL == fdInf)
+ if (maxevents <= 0)
{
- NSSOC_LOGERR ("create fdInf fail [return]");
- nstack_set_errno (ENOMEM);
- NSTACK_CAL_FUN (nstack_fix_mid_ops (), close, (epfd), ret);
- UNLOCK_FOR_EP (lock_info);
- return -1;
+ NSSOC_LOGWAR("maxevent less than zero]maxevents=%d", maxevents);
+ errno = EINVAL;
+ UNLOCK_EPOLL(epfd, local_lock);
+ return -1;
}
- if (nsep_alloc_eventpoll (&ep))
+ NSTACK_GET_SYS_TICK(&ep->epoll_wait_tick);
+ ep->epoll_wait_pending = 1;
+ /* only if this ep is forked before, then set to 1 */
+ if (epInfo->pidinfo.pid_used_size > 1)
{
- nsep_free_infoWithSock (epfd);
- NSSOC_LOGERR ("Alloc eventpoll fail [return]");
- nstack_fd_free_with_kernel (fdInf);
- nstack_set_errno (ENOMEM);
- UNLOCK_FOR_EP (lock_info);
- return -1;
+ ep->epoll_fork_flag = 1;
}
- ep->epfd = epfd;
- nsep_set_infoEp (epfd, ep);
- NSTACK_SET_FD_EPOLL_SOCKET (fdInf);
-
- /*if stack supply ep_create interface, just call create */
- nstack_each_modOps (modInx, ops)
- {
-
- if (modInx == nstack_get_fix_mid ())
- {
- nstack_set_protoFd (fdInf, modInx, epfd);
- continue;
- }
- if (ops->pfepoll_create)
- {
- tfd = ops->pfepoll_create (size);
- nstack_set_protoFd (fdInf, modInx, tfd);
- }
- }
-
- NSSOC_LOGINF ("fd=%d [return]", epfd);
- set_fd_status_lock_fork (epfd, FD_OPEN);
- UNLOCK_FOR_EP (lock_info);
- return epfd;
-}
-
-void
-nstack_epoll_prewait_proc (int epfd, int *eventflag, int num)
-{
- int modInx = 0;
- nsep_epollInfo_t *epInfo = NULL;
- epInfo = nsep_get_infoBySock (epfd);
- if (!epInfo)
- {
- return;
- }
- nstack_each_modInx (modInx)
- {
- if (nstack_extern_deal (modInx).ep_prewait_proc)
- {
- if (epInfo->protoFD[modInx] < 0)
- {
- continue;
- }
- /*if already report event, maybe next time to do this proc */
- if ((eventflag) && (modInx < num) && (eventflag[modInx] != 0))
- {
- continue;
- }
- nstack_extern_deal (modInx).ep_prewait_proc (epInfo->protoFD[modInx]);
- }
- }
- return;
-}
+ /* step1: get kernel epoll events and add them to epInfo */
+#ifdef KERNEL_FD_SUPPORT
+ NSTACK_CAL_FUN(nstack_module_ops(nstack_get_linux_mid()), epoll_wait,
+ (epfd, events, maxevents, 0), ret);
+ if (ret > 0)
+ {
+ /* here we should refill event.data from epi,which is revised by nstack_epoll_ctl */
+ int i = 0;
+ nsep_epollInfo_t *fd_epinfo = NULL;
+ struct list_node *fd_epi_head = NULL;
+ struct list_node *node = NULL;
+ struct epitem *epi = NULL;
+ struct eventpoll *epfd_ep = NULL;
-int
-nstack_epoll_wait (int epfd, struct epoll_event *events, int maxevents,
- int timeout)
-{
- nstack_fd_Inf *fdInf = NULL;
- nsep_epollInfo_t *epInfo = NULL;
- struct eventpoll *ep = NULL;
- int eventflag[NSEP_SMOD_MAX];
- int evt = 0;
- int ret = 0;
+ for (i = 0; i < ret; i++)
+ {
+ fd_epinfo = nsep_get_info_by_sock(events[i].data.fd);
+ if (!fd_epinfo)
+ {
+ NSSOC_LOGERR("get null epInfo err]protoFD=%d",
+ events[i].data.fd);
+ continue;
+ }
- NSTACK_INIT_CHECK_RET (epoll_wait, epfd, events, maxevents, timeout);
+ dmm_spin_lock_with_pid((dmm_spinlock_t *) (&fd_epinfo->epiLock)); /*do not need return value */
+ fd_epi_head =
+ (struct list_node *) SHMEM_ADDR_SHTOL(fd_epinfo->
+ epiList.head);
+ node = (struct list_node *) SHMEM_ADDR_SHTOL(fd_epi_head->next);
+ while (node)
+ {
- NSTACK_FD_LINUX_CHECK (epfd, epoll_wait, fdInf,
- (epfd, events, maxevents, timeout));
+ epi =
+ (struct epitem *) ep_list_entry(node, struct epitem,
+ fllink);
+ epfd_ep = (struct eventpoll *) SHMEM_ADDR_SHTOL(epi->ep);
- nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
- LOCK_EPOLL (epfd, fdInf, local_lock);
+ if (epfd_ep->epfd == epfd)
+ {
+ NSSOC_LOGDBG("Kernel got one event]i=%d,fd=%d,events=%u",
+ evt, events[i].data.fd, events[i].events);
+ events[evt].events = events[i].events;
+ events[evt].data = epi->event.data;
+ evt++;
+ break;
+ }
- if (!NSTACK_IS_FD_EPOLL_SOCKET (fdInf))
- {
- NSSOC_LOGWAR ("epfd=%d is not a epoll fd, return -1", epfd);
- errno = EINVAL;
- UNLOCK_EPOLL (epfd, local_lock);
- return -1;
+ node = (struct list_node *) SHMEM_ADDR_SHTOL(node->next);
+ }
+ if (!node)
+ {
+ NSSOC_LOGINF("fd was not added to this epfd]fd=%d, epfd=%d",
+ events[i].data.fd, epfd);
+ }
+ dmm_spin_unlock((dmm_spinlock_t *) (&fd_epinfo->epiLock));
+ }
+ /* end refill event.data */
}
+#endif
+ /* step2: get events from epInfo(nstack's events).
+ 1)If have events, just return.
+ 2)If no event,wait and record new events. */
- /* check input paramter's validity */
- if (NULL == events)
+ ep_conn = SHMEM_ADDR_SHTOL(epInfo->ep_conn);
+ evt_ns = nsep_ep_poll(ep, &events[evt], (maxevents - evt), ep_conn);
+ if (evt_ns > 0)
{
- NSSOC_LOGWAR ("events is NULL, return -1 ");
- errno = EINVAL;
- UNLOCK_EPOLL (epfd, local_lock);
- return -1;
+ evt += evt_ns;
}
-
- epInfo = nsep_get_infoBySock (epfd);
- if (NULL == epInfo)
+ if (evt)
{
- NSSOC_LOGWAR ("epInfo is NULL]epinfo=%p,epfd=%d", epInfo, epfd);
- errno = EINVAL;
- UNLOCK_EPOLL (epfd, local_lock);
- return -1;
+ NSSOC_LOGDBG("Got event]epfd=%d,maxevents=%d,ret=%d", epfd,
+ maxevents, evt);
+ goto out;
}
- ep = ADDR_SHTOL (epInfo->ep);
- if (NULL == ep)
- {
- NSSOC_LOGWAR ("fdInf->ep is NULL, return -1,epinfo=%p,epfd=%d", epInfo,
- epfd);
- errno = EINVAL;
- UNLOCK_EPOLL (epfd, local_lock);
- return -1;
- }
+#ifdef KERNEL_FD_SUPPORT
+ /* step3: if no event, add epfd to g_ksInfo.epfd epoll list and ks_ep_thread will record the new kernel epoll events to epinf */
+ struct epoll_event ep_event;
+ ep_event.data.fd = epfd;
+
+ ep_event.events = EPOLLIN | EPOLLET;
- if (maxevents <= 0)
+ /* Here we don't check return value, because epfd maybe already in ks_ep_thread */
+ NSTACK_CAL_FUN(nstack_module_ops(nstack_get_linux_mid()), epoll_ctl,
+ (0, EPOLL_CTL_ADD, epfd, &ep_event), ret);
+#endif
+
+ do
{
- NSSOC_LOGWAR ("maxevent less than zero maxevents=%d, return -1 ",
- maxevents);
- errno = EINVAL;
- UNLOCK_EPOLL (epfd, local_lock);
- return -1;
+ /*ns_sync_sem_timedwait need to deal timeout == 0 timeout < 0 timeout > 0 */
+ ret =
+ g_ns_sync_ops.ns_sync_sem_timedwait(&ep->waitSem, timeout,
+ epInfo->sleepTime);
+ if (ret)
+ {
+ nsep_notify_fd_epoll_wait_fail(ep);
+ break;
+ }
+ evt = nsep_ep_poll(ep, events, maxevents, ep_conn);
+ if (evt)
+ {
+ NSSOC_LOGDBG("Got event]epfd=%d,maxevents=%d,ret=%d", epfd,
+ maxevents, evt);
+ break;
+ }
}
+ while (1);
+
+ /* step5: del epfd from g_ksInfo.epfd epoll list to make sure epoll_wait duration is the same as app */
+#ifdef KERNEL_FD_SUPPORT
+
+ NSTACK_CAL_FUN(nstack_module_ops(nstack_get_linux_mid()), epoll_ctl,
+ (0, EPOLL_CTL_DEL, epfd, &ep_event), ret);
+#endif
+
+ out:
+ UNLOCK_EPOLL(epfd, local_lock);
+ ep->epoll_wait_pending = 0;
+ return evt;
+}
+
+pid_t nstack_fork(void)
+{
+ pid_t pid;
+ pid_t ppid = sys_get_hostpid_from_file(getpid());
- /**
- * For linux epoll
- * Case 1: event is already there, means ks_ep_thread already reported, and epfd not in epoll.
- * Case 2: event is not there, so we need to add epfd to ks_ep_thread
- * Update : only try to add epfd to ks_ep_thread once, avoid ks_ep_thread reporting the same event again after app has got the event!
- */
- MEMSET_S (&eventflag[0], sizeof (eventflag), 0, sizeof (eventflag));
- evt = nsep_ep_poll (ep, events, maxevents, &eventflag[0], NSEP_SMOD_MAX);
- if (evt)
+ NSTACK_INIT_CHECK_RET(fork);
+
+ if (ppid >= NSFW_MAX_PID || ppid <= 0)
{
- NSSOC_LOGDBG ("Got event]epfd=%d,maxevents=%d,ret=%d", epfd, maxevents,
- evt);
- nstack_epoll_prewait_proc (epfd, &eventflag[0], NSEP_SMOD_MAX);
- goto out;
+ NSSOC_LOGERR("ppid over MAX_PID or not over 0]ppid=%d", ppid);
+ return -1;
}
- nstack_epoll_prewait_proc (epfd, NULL, 0);
- do
+ dmm_write_lock(get_fork_lock());
+ if (NSTACK_MODULE_SUCCESS == g_nStackInfo.fwInited)
{
- if (0 == timeout)
- {
- goto out;
- }
- else if (timeout < 0)
+ fork_parent_start(ppid);
+ pid = nsfw_base_fork();
+ if (pid == 0)
{
- ret = sem_wait (&ep->waitSem);
- /* when sem_wait return -1, epoll_wait should also return sem_wait's return value and errno */
- if (ret < 0)
- {
- /* Change sem_wait EINTR log to WAR level */
- if (errno == EINTR)
- {
- NSSOC_LOGWAR ("sem_wait return -1]errno=%d", errno);
- }
- else
- {
- NSSOC_LOGERR ("sem_wait return -1]errno=%d", errno);
- }
+ fork_child_start(ppid);
- evt = ret;
- goto out;
- }
+ /* when fork, the child process need
+ relese the lock in glog */
+ nstack_log_lock_release();
+ nstack_fork_init_child(ppid);
+ (void) nstack_for_epoll_init();
+ nstack_fork_fd(ppid);
+ nsep_fork(ppid);
+ fork_child_done(ppid);
}
- else
+ else if (pid > 0)
{
- ret =
- nstack_epoll_sem_timedwait (&ep->waitSem, (u64_t) timeout,
- epInfo->sleepTime);
+ fork_wait_child_done(ppid);
}
-
- if (ret)
+ else
{
- goto out;
+ fork_parent_failed(ppid);
}
-
- evt = nsep_ep_poll (ep, events, maxevents, NULL, 0);
- if (evt)
+ }
+ else
+ {
+ pid = nsfw_base_fork();
+ if (pid == 0)
{
- NSSOC_LOGDBG ("Got event]epfd=%d,maxevents=%d,ret=%d", epfd,
- maxevents, evt);
- goto out;
+ updata_sys_pid();
}
+ NSSOC_LOGERR("g_nStackInfo has not initialized]ppid=%d, pid=%d",
+ ppid, pid);
}
- while (1);
-out:
- UNLOCK_EPOLL (epfd, local_lock);
- return evt;
+ dmm_write_unlock(get_fork_lock());
+ return pid;
}
-pid_t
-nstack_fork (void)
+int nstack_custom_peak(int fd)
{
- pid_t pid;
- pid_t parent_pid = sys_get_hostpid_from_file (getpid ());
-
- NSTACK_INIT_CHECK_RET (fork);
+ nstack_fd_Inf *fdInf = NULL;
+ int ret = 0;
+ int modInx = 0;
- common_mem_rwlock_write_lock (get_fork_lock ());
- if (NSTACK_MODULE_SUCCESS == g_nStackInfo.fwInited)
+ fdInf = nstack_get_valid_inf(fd);
+ if (NULL == fdInf)
{
- nstack_fork_init_parent (parent_pid);
- dmm_spinlock_lock_with_pid (nstack_get_fork_share_lock (), parent_pid);
- pid = nsfw_base_fork ();
- if (pid == 0)
- {
- /* when fork, the child process need relese the lock in glog */
- nstack_log_lock_release ();
- nstack_fork_init_child (parent_pid);
- (void) nstack_for_epoll_init ();
- dmm_spinlock_lock_with_pid (nstack_get_fork_share_lock (),
- get_sys_pid ());
- nsep_fork_child_proc (parent_pid);
+ nstack_set_errno(EINVAL);
+ NSSOC_LOGERR("invalid fd]fd=%d", fd);
+ return -1;
+ }
- (void) select_module_init_child ();
- common_mem_spinlock_unlock (nstack_get_fork_share_lock ());
- }
- else if (pid > 0)
- {
- pid_t child_pid = get_hostpid_from_file (pid);
- nsep_fork_parent_proc (parent_pid, child_pid);
- common_mem_spinlock_unlock (nstack_get_fork_share_lock ());
- sys_sleep_ns (0, 10000000); /* wait child add pid for netconn */
- }
- else
- {
- NSSOC_LOGERR ("fork failed]parent_pid=%d", parent_pid);
- common_mem_spinlock_unlock (nstack_get_fork_share_lock ());
- }
+ nstack_fd_local_lock_info_t *local_lock = &fdInf->local_lock;
+ LOCK_RECV(fd, fdInf, local_lock);
+
+ if (!NSTACK_IS_FD_ATTR(fdInf, fdInf->rd_item.type_data.attr))
+ {
+ nstack_set_errno(EBADFD);
+ NSSOC_LOGERR("fd is not custom socket]fd=%d", fd);
+ UNLOCK_RECV(fd, fdInf, local_lock);
+ return -1;
}
- else
+
+ nstack_fd_dfx_update_dfx_data(fd, fdInf->rlfd, fdInf->rmidx,
+ DMM_STAT_LONGEST_RECV_INTERVAL, NULL);
+ nstack_each_mod_inx(modInx)
{
- pid = nsfw_base_fork ();
- if (pid == 0)
+ if (nstack_fd_deal[modInx].peak)
{
- update_sys_pid ();
+ ret = nstack_fd_deal[modInx].peak(fdInf->rlfd);
}
- NSSOC_LOGERR ("g_nStackInfo has not initialized]parent_pid=%d, pid=%d",
- parent_pid, pid);
+ NSSOC_LOGDBG("Peak packet size]fd=%d,ret=%d", fd, ret);
}
+ UNLOCK_RECV(fd, fdInf, local_lock);
- common_mem_rwlock_write_unlock (get_fork_lock ());
- return pid;
+ return ret;
}
diff --git a/src/nSocket/nstack/nstack_socket.h b/src/nSocket/nstack/nstack_socket.h
index 3bb7843..f63fb6c 100644
--- a/src/nSocket/nstack/nstack_socket.h
+++ b/src/nSocket/nstack/nstack_socket.h
@@ -19,94 +19,73 @@
#include <sys/socket.h>
#include <poll.h>
#include <sys/epoll.h>
+#include <netdb.h>
+#include "dmm_spinlock.h"
+#include "nstack_fd_mng.h"
#undef NSTACK_MK_DECL
#define NSTACK_MK_DECL(ret, fn, args) extern ret nstack_##fn args
-#include "declare_syscalls.h"
+#include "declare_syscalls.h.tmpl"
-int release_fd (int fd, nstack_fd_local_lock_info_t * local_lock);
-int nstack_posix_api_init ();
-int nstack_close (int fd);
-int nstack_socket (int domain, int itype, int protocol);
+int release_fd(int fd, nstack_fd_local_lock_info_t * local_lock);
+int nstack_posix_api_init();
+int nstack_close(int fd);
+int nstack_socket(int domain, int itype, int protocol);
#define NSTACK_EPOLL_FD_CHECK_RET_UNLOCK(fdVal, fun, inf, err, local_lock, unlock) \
if ((NULL == inf) || ((inf)->attr & NSTACK_FD_ATTR_EPOLL_SOCKET)) \
{ \
nstack_set_errno(err); \
NSSOC_LOGERR("nstack [%s] call, fd=0x%x is epoll fd return fail errno=%d [return]", #fun, fdVal, err); \
- unlock(fdVal, local_lock);\
+ unlock(fdVal, inf, local_lock);\
return -1;\
}
#define NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_COMMON(fdVal, fun, inf, err, local_lock) \
- NSTACK_EPOLL_FD_CHECK_RET_UNLOCK(fdVal, fun, inf, err, local_lock, UNLOCK_COMMON)
-
-#define LOCK_RECV(fd, fd_inf, local_lock)\
- LOCK_BASE_WITHOUT_KERNEL(fd, fd_inf, local_lock)
-
-#define UNLOCK_RECV(fd, local_lock) \
- UNLOCK_BASE(fd, local_lock)
-
-#define NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_RECV(fdVal, fun, inf, err, local_lock) \
- NSTACK_EPOLL_FD_CHECK_RET_UNLOCK(fdVal, fun, inf, err, local_lock, UNLOCK_RECV)
-
-#define LOCK_SEND(fd, fd_inf, local_lock) \
- INC_FD_REF(fd, fd_inf, local_lock)
-
-static inline void
-UNLOCK_SEND (int fd, nstack_fd_local_lock_info_t * local_lock)
-{
- if ((NULL != local_lock) && atomic_dec (&local_lock->fd_ref) == 0)
- {
- release_fd (fd, local_lock);
- }
-}
-
-#define NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_SEND(fdVal, fun, inf, err, local_lock) \
- NSTACK_EPOLL_FD_CHECK_RET_UNLOCK(fdVal, fun, inf, err, local_lock, UNLOCK_SEND)
+ /*do not need return value*/NSTACK_EPOLL_FD_CHECK_RET_UNLOCK(fdVal, fun, inf, err, local_lock, UNLOCK_COMMON)
#define LOCK_CONNECT(fd, fd_inf, local_lock) \
- LOCK_BASE(fd, fd_inf, local_lock)
+ LOCK_BASE(fd, fd_inf, local_lock)
-#define UNLOCK_CONNECT(fd, local_lock) \
- UNLOCK_BASE(fd, local_lock)
+#define UNLOCK_CONNECT(fd, fd_inf, local_lock) \
+ /*do not need return value*/UNLOCK_BASE(fd, fd_inf, local_lock)
#define NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_CONNECT(fdVal, fun, inf, err, local_lock) \
NSTACK_EPOLL_FD_CHECK_RET_UNLOCK(fdVal, fun, inf, err, local_lock, UNLOCK_CONNECT)
#define LOCK_ACCEPT(fd, fd_inf, local_lock) \
- LOCK_BASE(fd, fd_inf, local_lock)
+ LOCK_BASE(fd, fd_inf, local_lock)
-#define UNLOCK_ACCEPT(fd, local_lock) \
- UNLOCK_BASE(fd, local_lock)
+#define UNLOCK_ACCEPT(fd, fd_inf, local_lock) \
+ /*do not need return value*/UNLOCK_BASE(fd, fd_inf, local_lock)
#define NSTACK_EPOLL_FD_CHECK_RET_UNLOCK_ACCEPT(fdVal, fun, inf, err, local_lock) \
- NSTACK_EPOLL_FD_CHECK_RET_UNLOCK(fdVal, fun, inf, err, local_lock, UNLOCK_ACCEPT)
+ /*do not need return value*/NSTACK_EPOLL_FD_CHECK_RET_UNLOCK(fdVal, fun, inf, err, local_lock, UNLOCK_ACCEPT)
-#define LOCK_EPOLL(fd, fd_inf, local_lock) INC_FD_REF(fd, fd_inf, local_lock)
+#define LOCK_EPOLL(fd, fd_inf, local_lock) INC_FD_REF_RETURN(fd, fd_inf, local_lock)
-static inline void
-UNLOCK_EPOLL (int fd, nstack_fd_local_lock_info_t * local_lock)
+static inline void UNLOCK_EPOLL(int fd,
+ nstack_fd_local_lock_info_t * local_lock)
{
- if ((NULL != local_lock) && atomic_dec (&local_lock->fd_ref) == 0)
+ if ((NULL != local_lock) && atomic_dec(&local_lock->fd_ref) == 0)
{
- release_fd (fd, local_lock);
+ release_fd(fd, local_lock);
}
}
-#define LOCK_EPOLL_CTRL(fd_val, local_lock, epoll_fd, epoll_local_lock){\
+#define LOCK_EPOLL_CTRL_RETURN(fd_val, local_lock, epoll_fd, epoll_local_lock){\
if (local_lock)\
{\
atomic_inc(&local_lock->fd_ref);\
- common_mem_spinlock_lock(&local_lock->close_lock);\
- nstack_fd_Inf* fd_inf = nstack_getValidInf(fd_val);\
+ dmm_spin_lock(&local_lock->close_lock);\
+ nstack_fd_Inf* fd_inf = nstack_get_valid_inf(fd_val);\
if (fd_inf)\
{\
if (local_lock->fd_status != FD_OPEN)\
{\
NSSOC_LOGWAR("fd %d is not open [return]", fd_val);\
nstack_set_errno(EBADF);\
- common_mem_spinlock_unlock(&local_lock->close_lock);\
+ dmm_spin_unlock(&local_lock->close_lock);\
if(atomic_dec(&local_lock->fd_ref)==0){ \
release_fd(fd_val, local_lock);\
}\
@@ -117,29 +96,29 @@ UNLOCK_EPOLL (int fd, nstack_fd_local_lock_info_t * local_lock)
}\
}
-static inline void
-UNLOCK_EPOLL_CTRL (int fd, nstack_fd_local_lock_info_t * local_lock)
+static inline void UNLOCK_EPOLL_CTRL(int fd,
+ nstack_fd_local_lock_info_t * local_lock)
{
- if (local_lock)
+ if (local_lock)
{
- common_mem_spinlock_unlock (&local_lock->close_lock);
- if (atomic_dec (&local_lock->fd_ref) == 0)
+ dmm_spin_unlock(&local_lock->close_lock);
+ if (atomic_dec(&local_lock->fd_ref) == 0)
{
- release_fd (fd, local_lock);
+ release_fd(fd, local_lock);
}
}
}
-#define INC_FD_REF(fd, fd_inf, local_lock){ \
+#define INC_FD_REF_RETURN(fd, fd_inf, local_lock){ \
if (local_lock)\
{\
atomic_inc(&local_lock->fd_ref);\
if (local_lock->fd_status != FD_OPEN)\
{\
nstack_set_errno(EBADF);\
- NSSOC_LOGERR("nstack call, fd_status=%d [return]", local_lock->fd_status); \
+ NSSOC_LOGERR("nstack call, nfd = %d, fd_status=%d [return]",fd, local_lock->fd_status); \
if(atomic_dec(&local_lock->fd_ref) == 0){ \
- release_fd(fd, local_lock);\
+ release_fd(fd, local_lock);\
}\
return -1;\
}\
@@ -147,42 +126,41 @@ UNLOCK_EPOLL_CTRL (int fd, nstack_fd_local_lock_info_t * local_lock)
}
#define LOCK_BASE(fd, fd_inf, local_lock){\
- INC_FD_REF(fd, fd_inf, local_lock);\
+ INC_FD_REF_RETURN(fd, fd_inf, local_lock);\
}
/* if is kernel fd, don't need to lock */
#define LOCK_BASE_WITHOUT_KERNEL(fd, fd_inf, local_lock){\
- INC_FD_REF(fd, fd_inf, local_lock);\
+ INC_FD_REF_RETURN(fd, fd_inf, local_lock);\
}
-static inline void
-UNLOCK_BASE (int fd, nstack_fd_local_lock_info_t * local_lock)
+static inline void UNLOCK_BASE(int fd, nstack_fd_Inf * inf,
+ nstack_fd_local_lock_info_t * local_lock)
{
- if ((NULL != local_lock) && (atomic_dec (&local_lock->fd_ref) == 0))
+ if ((NULL != local_lock) && (atomic_dec(&local_lock->fd_ref) == 0))
{
- release_fd (fd, local_lock);
+ release_fd(fd, local_lock);
}
}
#define LOCK_COMMON(fd, fd_inf, local_lock) \
LOCK_BASE(fd, fd_inf, local_lock)
-#define UNLOCK_COMMON(fd, local_lock) \
- UNLOCK_BASE(fd, local_lock)
+#define UNLOCK_COMMON(fd, fd_inf, local_lock) \
+ /*do not need return value*/UNLOCK_BASE(fd, fd_inf, local_lock)
#define LOCK_CLOSE(local_lock){\
if (local_lock)\
{\
- common_mem_spinlock_lock(&local_lock->close_lock);\
+ dmm_spin_lock(&local_lock->close_lock);\
}\
}
-static inline void
-UNLOCK_CLOSE (nstack_fd_local_lock_info_t * local_lock)
+static inline void UNLOCK_CLOSE(nstack_fd_local_lock_info_t * local_lock)
{
- if (local_lock)
+ if (local_lock)
{
- common_mem_spinlock_unlock (&local_lock->close_lock);
+ dmm_spin_unlock(&local_lock->close_lock);
}
}
@@ -197,7 +175,7 @@ UNLOCK_CLOSE (nstack_fd_local_lock_info_t * local_lock)
return nsfw_base_##fun(args); \
} \
if (nstack_fw_init()) { \
- NSSOC_LOGERR("nstack %s call, but initial not finished yet [return]", #fun); \
+ NSSOC_LOGERR("nstack %s call, but initial not finished yet, errno %d [return]", #fun,get_fw_init_err()); \
nstack_set_errno(ENOSYS); \
return -1; \
} \
@@ -205,4 +183,6 @@ UNLOCK_CLOSE (nstack_fd_local_lock_info_t * local_lock)
#define NSTACK_MODULE_ERROR_SET(Index)
+extern int nstack_create_kernel_socket();
+
#endif /* __NSTACK_SOCKET_H__ */
diff --git a/src/nSocket/nstack_rd/nstack_rd.c b/src/nSocket/nstack_rd/nstack_rd.c
index 650f165..0c7d127 100644
--- a/src/nSocket/nstack_rd/nstack_rd.c
+++ b/src/nSocket/nstack_rd/nstack_rd.c
@@ -15,58 +15,72 @@
*/
#include <stdlib.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
#include "nstack_rd.h"
-#include "nstack_rd_init.h"
#include "nstack_rd_priv.h"
#include "nstack_rd_ip.h"
+#include "nstack_rd_ip6.h"
+#include "nstack_rd_type.h"
#include "nstack_rd_proto.h"
#include "nstack_log.h"
-#include "nstack_info_parse.h"
#include "nstack_securec.h"
+#include <arpa/inet.h>
-typedef struct __rd_data_defaut_ip
-{
- char ip[RD_IP_STR_MAX_LEN];
- char stackname[RD_PLANE_NAMELEN];
- int masklent;
-} rd_data_defaut_ip;
+extern rd_route_table *g_rd_table_handle[];
-typedef struct __rd_data_defaut_protocol
-{
- unsigned int proto_type;
- char stackname[RD_PLANE_NAMELEN];
-} rd_data_defaut_protocol;
+rd_local_data *g_rd_local_data = NULL;
rd_data_proc g_rd_cpy[RD_DATA_TYPE_MAX] = {
- {
- nstack_rd_ipdata_cpy,
- nstack_rd_ip_item_insert,
- nstack_rd_ip_item_age,
- nstack_rd_ip_item_find,
- nstack_rd_ip_spec,
- nstack_rd_ip_default,
- },
- {
- nstack_rd_proto_cpy,
- nstack_rd_proto_item_insert,
- nstack_rd_proto_item_age,
- nstack_rd_proto_item_find,
- nstack_rd_proto_spec,
- nstack_rd_proto_default,
- },
+ {
+ nstack_rd_ip_data_cpy,
+ nstack_rd_ip_item_insert,
+ nstack_rd_ip_item_age,
+ nstack_rd_ip_item_clean,
+ nstack_rd_ip_item_find,
+ nstack_rd_ip_spec,
+ },
+ {
+ nstack_rd_ip6_data_cpy,
+ nstack_rd_ip6_item_insert,
+ nstack_rd_ip6_item_age,
+ nstack_rd_ip6_item_clean,
+ nstack_rd_ip6_item_find,
+ nstack_rd_ip6_spec,
+ },
+ {
+ nstack_rd_type_data_cpy,
+ nstack_rd_type_item_insert,
+ nstack_rd_type_item_age,
+ nstack_rd_type_item_clean,
+ nstack_rd_type_item_find,
+ nstack_rd_type_spec,
+ },
+ {
+ nstack_rd_proto_data_cpy,
+ nstack_rd_proto_item_insert,
+ nstack_rd_proto_item_age,
+ nstack_rd_proto_item_clean,
+ nstack_rd_proto_item_find,
+ nstack_rd_proto_spec,
+ }
};
-rd_data_defaut_ip g_default_ip_config[] = {
- {{"127.0.0.1"}, {RD_KERNEL}, 32},
- {{"0.0.0.0"}, {RD_KERNEL}, 32},
-};
+int nstack_choose_highest_prio()
+{
+ int i;
+ int ret = 0;
+ int highest = 0x7FFFFFFF;
+ nstack_rd_stack_info *stack_info = g_rd_local_data->pstack_info;
-rd_data_defaut_protocol g_default_protcol[] = {
- {0xf001, {RD_LWIP}},
-};
+ for (i = 0; i < NSTACK_NUM; i++)
+ {
+ if (stack_info[i].priority < highest)
+ {
+ highest = stack_info[i].priority;
+ ret = i;
+ }
+ }
+ return ret;
+}
/*****************************************************************************
* Prototype : nstack_rd_get_stackid
@@ -78,256 +92,414 @@ rd_data_defaut_protocol g_default_protcol[] = {
* Calls :
* Called By :
*****************************************************************************/
-int
-nstack_rd_get_stackid (nstack_rd_key * pkey, int *stackid)
+int nstack_rd_get_stackid(nstack_rd_key * pkey, rd_data_item * item)
{
- int type = 0;
- int ret = NSTACK_RD_SUCCESS;
- rd_data_item item;
- if ((!pkey) || (!stackid) || (pkey->type >= RD_DATA_TYPE_MAX))
+ int accumulate = 0;
+ int icnt = 0;
+ int type = 0;
+ int ret = NSTACK_RD_SUCCESS;
+ int rdtbl_ver = 0;
+ if ((!pkey) || (!item) || (pkey->type >= RD_DATA_TYPE_MAX))
{
- NSSOC_LOGERR ("input get stackid fail]addr=%p,stackid=%p,addr->type=%d",
- pkey, stackid, !pkey ? RD_DATA_TYPE_MAX : pkey->type);
- return NSTACK_RD_FAIL;
+ NSSOC_LOGERR("input get stackid fail]addr=%p,item=%p,addr->type=%d",
+ pkey, item, !pkey ? RD_DATA_TYPE_MAX : pkey->type);
+ return NSTACK_RD_FAIL;
}
- int retVal = MEMSET_S (&item, sizeof (item), 0, sizeof (item));
- if (EOK != retVal)
+ /*add return value check */
+ int retVal =
+ memset_s(item, sizeof(rd_data_item), 0, sizeof(rd_data_item));
+ if (EOK != retVal)
{
- NSSOC_LOGERR ("MEMSET_S failed]retVal=%d", retVal);
- return NSTACK_RD_FAIL;
+ NSSOC_LOGERR("memset_s failed]retVal=%d", retVal);
+ return NSTACK_RD_FAIL;
}
- type = pkey->type;
+ item->stack_id = -1;
+ type = pkey->type;
- /*specfic key find, for ip example: stack-x was chose if the key is multicast ip */
- if (g_rd_cpy[type].rd_item_spec)
+ /*specfic key find, for ip example: stackpool was chose if the key is multicast ip */
+ if (g_rd_cpy[type].rd_item_spec)
{
- ret = g_rd_cpy[type].rd_item_spec ((void *) pkey);
- if (ret >= 0)
+ ret = g_rd_cpy[type].rd_item_spec((void *) pkey);
+ if (ret >= 0)
{
- *stackid = ret;
- return NSTACK_RD_SUCCESS;
+ item->stack_id = ret;
+ return NSTACK_RD_SUCCESS;
}
}
- /*search the list */
- ret =
- g_rd_cpy[type].rd_item_find (NSTACK_RD_LIST (type), (void *) pkey, &item);
- if (NSTACK_RD_SUCCESS == ret)
+ /*check ver */
+ for (icnt = 0; icnt < NSTACK_NUM; icnt++)
{
- NSSOC_LOGDBG ("item type=%d stackid=%d was found", pkey->type,
- item.stack_id);
- *stackid = item.stack_id;
- return NSTACK_RD_SUCCESS;
+ retVal =
+ g_rd_local_data->rdtbl_ver_get_fun(&rdtbl_ver,
+ g_rd_table_handle[icnt]);
+ if (retVal)
+ {
+ NSSOC_LOGWAR("stackid=%d get rd table ver failed!",
+ g_rd_local_data->pstack_info->stack_id);
+ if (++accumulate < NSTACK_NUM)
+ {
+ continue;
+ }
+ NSSOC_LOGERR("rd table ver get failed");
+ return NSTACK_RD_FAIL;
+ }
+ if (g_rd_local_data->rdlocal_ver[icnt] != rdtbl_ver)
+ {
+ NSSOC_LOGINF
+ ("RD table ver unmatch]new rd tlbver:%d,local rd tblver:%d,resync now",
+ rdtbl_ver, g_rd_local_data->rdlocal_ver[icnt]);
+ ret = nstack_rd_sys();
+ if (ret != NSTACK_RD_SUCCESS)
+ {
+ item->stack_id = nstack_choose_highest_prio();
+ NSSOC_LOGERR
+ ("sync RD INF failed, choose highest priority stack, stackid=%d",
+ item->stack_id);
+ return NSTACK_RD_SUCCESS;
+ }
+ }
}
- if (g_rd_cpy[type].rd_item_default)
+
+ /*search the list */
+ ret =
+ g_rd_cpy[type].rd_item_find(NSTACK_RD_LIST(type), (void *) pkey,
+ item);
+ if (NSTACK_RD_SUCCESS == ret)
{
- *stackid = g_rd_cpy[type].rd_item_default ((void *) pkey);
+ NSSOC_LOGDBG("item type=%d stackid=%d was found", pkey->type,
+ item->stack_id);
+ return NSTACK_RD_SUCCESS;
}
- else
+ item->stack_id = nstack_choose_highest_prio();
+ NSSOC_LOGINF
+ ("item type=%d was not found, choose highest priority stack by default, stackid=%d",
+ pkey->type, item->stack_id);
+ return NSTACK_RD_SUCCESS;
+}
+
+static char *nstack_rd_parse_ip(char *pos, unsigned int *ip)
+{
+ char buf[16];
+ char *p;
+ int len, ret;
+
+ if (!pos)
+ return NULL;
+
+ p = strchr(pos, '/');
+ if (!p)
+ return NULL;
+
+ len = p - pos;
+ if (len >= 16)
+ return NULL;
+
+ ret = memcpy_s(buf, sizeof(buf), pos, len);
+ if (EOK != ret)
{
- *stackid = -1;
+ return NULL;
}
- NSSOC_LOGINF ("item type=%d was not found, return default=%d", pkey->type,
- *stackid);
- return NSTACK_RD_SUCCESS;
+
+ buf[len] = 0;
+
+ ret = inet_pton(AF_INET, buf, ip);
+ if (ret == 1)
+ return p + 1;
+
+ return NULL;
+
}
-/*****************************************************************************
-* Prototype : nstack_rd_sys_default
-* Description : sys default rd info,
-* Input : None
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-******************************************************************************/
-void
-nstack_rd_sys_default ()
+static char *nstack_rd_parse_ip6(char *pos, unsigned int ip[4])
+{
+ char buf[46];
+ char *p;
+ int len, ret;
+
+ p = strchr(pos, '/');
+ if (!p)
+ return NULL;
+
+ len = p - pos;
+ if (len >= 46)
+ return NULL;
+
+ (void) memcpy_s(buf, sizeof(buf), pos, len);
+ buf[len] = 0;
+
+ ret = inet_pton(AF_INET6, buf, ip);
+ if (ret == 1)
+ return p + 1;
+
+ return NULL;
+}
+
+static char *nstack_rd_parse_stackid(char *pos, int *stack_id)
{
- rd_data_item item;
- rd_data_defaut_ip *pdata = NULL;
- rd_data_defaut_protocol *pprotodata = NULL;
- int icnt = 0, iindex = 0;
- int stack_num = 0;
+ size_t n = 0;
+ int i;
- stack_num = g_rd_local_data->stack_num;
+ while (pos[n] != ':' && pos[n] != 0)
+ n++;
+ if (n == 0 || n >= RD_PLANE_NAMELEN)
+ return NULL;
- /*get the ip default route */
- for (icnt = 0;
- icnt < sizeof (g_default_ip_config) / sizeof (rd_data_defaut_ip);
- icnt++)
+ for (i = 0; i < g_rd_local_data->stack_num; ++i)
{
- pdata = &g_default_ip_config[icnt];
- for (iindex = 0; iindex < stack_num; iindex++)
+ /* params are not NULL */
+ if (0 == strncmp(pos, g_rd_local_data->pstack_info[i].name, n))
{
- if (0 ==
- strcmp (g_rd_local_data->pstack_info[iindex].name,
- pdata->stackname))
- {
- item.stack_id = g_rd_local_data->pstack_info[iindex].stack_id;
- break;
- }
+ *stack_id = g_rd_local_data->pstack_info[i].stack_id;
+ return pos + n;
}
- if (iindex >= stack_num)
+ }
+
+ return NULL;
+}
+
+static void nstack_rd_sys_load_default()
+{
+ char *env, *pos;
+
+ env = getenv("NSTACK_RD"); /*this func can be used */
+
+ if (!env || !env[0])
+ return;
+
+ pos = env;
+ while (*pos)
+ {
+ rd_data_item item;
+ char *pos6 = pos;
+
+ pos = nstack_rd_parse_ip(pos, &item.ipdata.addr);
+ if (pos)
{
- NSSOC_LOGINF
- ("default stack name:%s was not fount, ip:%s msklen:%d was dropped",
- pdata->stackname, pdata->ip, pdata->masklent);
- continue;
+ item.type = RD_DATA_TYPE_IP;
+ item.agetime = NSTACK_RD_AGETIME_MAX;
+ item.ipdata.resev[0] = 0;
+ item.ipdata.resev[1] = 0;
+ item.ipdata.masklen = (unsigned int) strtoul(pos, &pos, 10);
+ if (item.ipdata.masklen > 32 || *pos++ != '=')
+ {
+ NSSOC_LOGERR("nstack rd sys config error '%s'", env);
+ return;
+ }
}
- item.type = RD_DATA_TYPE_IP;
- item.ipdata.addr = ntohl (inet_addr (pdata->ip));
- item.ipdata.masklen = pdata->masklent;
- item.ipdata.resev[0] = 0;
- item.ipdata.resev[1] = 0;
- item.agetime = NSTACK_RD_AGETIME_MAX;
- /*insert to the list */
- g_rd_cpy[RD_DATA_TYPE_IP].rd_item_inset (NSTACK_RD_LIST
- (RD_DATA_TYPE_IP), &item);
- }
-
- /*get the protocol default route */
- (void) MEMSET_S (&item, sizeof (item), 0, sizeof (item));
- for (icnt = 0;
- icnt < sizeof (g_default_protcol) / sizeof (rd_data_defaut_protocol);
- icnt++)
- {
- pprotodata = &g_default_protcol[icnt];
- for (iindex = 0; iindex < stack_num; iindex++)
+ else if (NULL !=
+ (pos = nstack_rd_parse_ip6(pos6, item.ip6data.addr.addr32)))
{
- if (0 ==
- strcmp (g_rd_local_data->pstack_info[iindex].name,
- pprotodata->stackname))
+ item.type = RD_DATA_TYPE_IP6;
+ item.agetime = NSTACK_RD_AGETIME_MAX;
+ item.ip6data.masklen = (unsigned int) strtoul(pos, &pos, 10);
+ if (item.ip6data.masklen > 128 || *pos++ != '=')
{
- item.stack_id = g_rd_local_data->pstack_info[iindex].stack_id;
- break;
+ NSSOC_LOGERR("nstack rd sys config error '%s'", env);
+ return;
}
}
- if (iindex >= stack_num)
+ else
{
- NSSOC_LOGINF
- ("default stack name:%s was not fount, protocoltype:%d was dropped",
- pprotodata->stackname, pprotodata->proto_type);
- continue;
+ NSSOC_LOGERR("nstack rd sys config error '%s'", env);
+ return;
}
- item.type = RD_DATA_TYPE_PROTO;
- item.proto_type = pprotodata->proto_type;
- /*insert to the list */
- g_rd_cpy[RD_DATA_TYPE_PROTO].rd_item_inset (NSTACK_RD_LIST
- (RD_DATA_TYPE_PROTO),
+
+ pos = nstack_rd_parse_stackid(pos, &item.stack_id);
+ if (!pos)
+ {
+ NSSOC_LOGERR("nstack rd sys config error '%s'", env);
+ return;
+ }
+
+ (void) g_rd_cpy[item.type].rd_item_insert(NSTACK_RD_LIST(item.type),
&item);
- }
- return;
-}
-/*****************************************************************************
-* Prototype : nstack_rd_save
-* Description : save the rd data
-* Input : None
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*****************************************************************************/
-void
-nstack_rd_save (rd_route_data * rd_data, int num)
-{
- int icnt = 0;
- int iindex = 0;
- int stack_num = 0;
- rd_data_item item;
- rd_data_type type = RD_DATA_TYPE_MAX;
+ if (item.type == RD_DATA_TYPE_IP6)
+ {
+ char buf[46];
+ NSSOC_LOGINF("insert one RD %d=%s/%u", item.stack_id,
+ inet_ntop(AF_INET6, &item.ip6data.addr, buf,
+ sizeof(buf)), item.ip6data.masklen);
+ }
+ else
+ {
+ NSSOC_LOGINF("insert one RD %d:%u.%u.%u.%u/%u", item.stack_id,
+ item.ipdata.addr >> 24,
+ (item.ipdata.addr >> 16) & 255,
+ (item.ipdata.addr >> 8) & 255,
+ item.ipdata.addr & 255, item.ipdata.masklen);
+ }
- int retVal = MEMSET_S (&item, sizeof (item), 0, sizeof (item));
- if (EOK != retVal)
- {
- NSSOC_LOGERR ("MEMSET_S failed]retVal=%d", retVal);
- return;
+ if (*pos == ':')
+ pos++;
}
+}
- stack_num = g_rd_local_data->stack_num;
-
- for (iindex = 0; iindex < num; iindex++)
+static void nstack_rd_sys_clean()
+{
+ int type;
+ for (type = 0; type < RD_DATA_TYPE_MAX; type++)
{
- if (rd_data[iindex].type >= RD_DATA_TYPE_MAX)
+ if (!hlist_empty(&(NSTACK_RD_LIST(type)->headlist)))
{
- NSSOC_LOGERR ("rd data type=%d unkown", rd_data[iindex].type);
- continue;
+ g_rd_cpy[type].rd_item_clean(NSTACK_RD_LIST(type));
}
+ }
+}
- type = rd_data[iindex].type;
+static int nstack_rd_ip_get(rd_route_data ** data, int *num, int *ver,
+ rd_route_table * handle)
+{
+ rd_route_data *pdata = NULL;
+ rd_route_node *pnode = NULL;
+ size_t size = 0;
+ int icnt = 0;
+ int idex = 0;
+ int ret;
+ int rdver = 0;
- if (NSTACK_RD_SUCCESS ==
- g_rd_cpy[type].rd_item_cpy ((void *) &item,
- (void *) &rd_data[iindex]))
+ if (!handle || !data || !num || !ver)
+ {
+ NSSOC_LOGERR("nstack rd mng not inited or input err");
+ return -1;
+ }
+ dmm_spin_lock_with_pid(&handle->rd_lock);
+ size = sizeof(rd_route_data) * handle->size;
+ pdata = (rd_route_data *) malloc(size);
+ if (!pdata)
+ {
+ dmm_spin_unlock(&handle->rd_lock);
+ NSSOC_LOGERR("rd route data malloc fail");
+ return -1;
+ }
+ ret = memset_s(pdata, size, 0, size);
+ if (EOK != ret)
+ {
+ dmm_spin_unlock(&handle->rd_lock);
+ NSSOC_LOGERR("memset_s failed]ret=%d", ret);
+ free(pdata);
+ return -1;
+ }
+ for (icnt = 0; icnt < handle->size; icnt++)
+ {
+ pnode = &(handle->node[icnt]);
+ if (RD_NODE_USING == pnode->flag)
{
- item.agetime = NSTACK_RD_AGETIME_MAX;
- for (icnt = 0; icnt < stack_num; icnt++)
- {
- if (0 ==
- strcmp (g_rd_local_data->pstack_info[icnt].name,
- rd_data[iindex].stack_name))
- {
- item.stack_id = g_rd_local_data->pstack_info[icnt].stack_id;
- break;
- }
- }
- if (icnt >= stack_num)
- {
- NSSOC_LOGINF
- ("plane name:%s was not fount, protocoltype:%d was dropped",
- rd_data[iindex].stack_name);
- continue;
- }
- /*insert to the list */
- g_rd_cpy[type].rd_item_inset (NSTACK_RD_LIST (type), &item);
- continue;
+ pdata[idex] = pnode->data;
+ idex++;
}
+ }
+ rdver = handle->rdtbl_ver;
+ dmm_spin_unlock(&handle->rd_lock);
+ /*if no data fetched , just return fail */
+ if (idex == 0)
+ {
+ free(pdata);
+ return -1;
+ }
+ *data = pdata;
+ *num = idex;
+ *ver = rdver;
+ return 0;
+}
- NSSOC_LOGERR ("rd data type=%d cpy fail", rd_data[iindex].type);
+static int nstack_rd_tblver_get(int *ver, rd_route_table * handle)
+{
+ if (!handle || !ver)
+ {
+ NSSOC_LOGERR("nstack rd mng not inited or input err");
+ return -1;
}
- return;
+ *ver = handle->rdtbl_ver;
+ return 0;
}
-/*****************************************************************************
-* Prototype : nstack_rd_data_get
-* Description : rd data get,
-* Input : None
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*****************************************************************************/
-int
-nstack_rd_data_get (nstack_get_route_data pfun)
+int nstack_rd_init(nstack_rd_stack_info * pstack, int num)
{
- rd_route_data *rd_data = NULL;
- int iret = NSTACK_RD_FAIL;
- int inum = 0;
+ int icnt = 0;
+ nstack_rd_stack_info *ptemstack = NULL;
+ int *rd_ver = NULL;
- /*get rd config */
- if (pfun && (NSTACK_RD_SUCCESS == pfun (&rd_data, &inum)))
+ if (!pstack)
{
- if (inum > 0)
- {
- nstack_rd_save (rd_data, inum);
- iret = NSTACK_RD_SUCCESS;
- }
- else
- {
- NSSOC_LOGDBG ("no rd data got");
- }
- if (rd_data)
- {
- free (rd_data);
- rd_data = NULL;
- }
+ NSSOC_LOGERR("input err pstack:%p", pstack);
+ return NSTACK_RD_FAIL;
+ }
+ g_rd_local_data = (rd_local_data *) malloc(sizeof(rd_local_data));
+ if (!g_rd_local_data)
+ {
+ NSSOC_LOGERR("g_rd_local_data alloc fail");
+ return NSTACK_RD_FAIL;
+ }
+
+ /*add return value check */
+ if (EOK !=
+ memset_s((void *) g_rd_local_data, sizeof(rd_local_data), 0,
+ sizeof(rd_local_data)))
+ {
+ NSSOC_LOGERR("memset_s fail");
+ goto ERR;
+ }
+
+ g_rd_local_data->sys_fun = nstack_rd_ip_get;
+ g_rd_local_data->rdtbl_ver_get_fun = nstack_rd_tblver_get;
+
+ ptemstack =
+ (nstack_rd_stack_info *) malloc(sizeof(nstack_rd_stack_info) * num);
+ if (!ptemstack)
+ {
+ NSSOC_LOGERR("rd stack info malloc fail");
+ goto ERR;
+ }
+
+ if (EOK !=
+ memcpy_s(ptemstack, sizeof(nstack_rd_stack_info) * num, pstack,
+ sizeof(nstack_rd_stack_info) * num))
+ {
+ NSSOC_LOGERR("memcpy_s failed!");
+ goto ERR;
+ }
+
+ g_rd_local_data->pstack_info = ptemstack;
+ g_rd_local_data->stack_num = num;
+
+ rd_ver = (int *) malloc(sizeof(int) * NSTACK_NUM); /*this function is necessary */
+ if (!rd_ver)
+ {
+ NSSOC_LOGERR("rd_ver alloc failed!");
+ goto ERR;
+ }
+ if (EOK !=
+ memset_s((void *) rd_ver, sizeof(int) * NSTACK_NUM, 0,
+ sizeof(int) * NSTACK_NUM))
+ {
+ NSSOC_LOGERR("memset_s failed!");
+ goto ERR;
+ }
+ g_rd_local_data->rdlocal_ver = rd_ver;
+
+ for (icnt = 0; icnt < RD_DATA_TYPE_MAX; icnt++)
+ {
+ INIT_HLIST_HEAD(&(g_rd_local_data->route_list[icnt].headlist));
}
- else
+ return NSTACK_RD_SUCCESS;
+
+ ERR:
+ if (g_rd_local_data)
+ {
+ free(g_rd_local_data);
+ g_rd_local_data = NULL;
+ }
+ if (ptemstack)
{
- NSSOC_LOGERR ("nstack rd sys rd info fail");
+ free(ptemstack);
}
- return iret;
+ if (rd_ver)
+ {
+ free(rd_ver); /*this function is necessary */
+ }
+ return NSTACK_RD_FAIL;
}
/*****************************************************************************
@@ -339,33 +511,92 @@ nstack_rd_data_get (nstack_get_route_data pfun)
* Calls :
* Called By :
*****************************************************************************/
-int
-nstack_rd_sys ()
+int nstack_rd_sys()
{
- int iret = NSTACK_RD_FAIL;
- int icnt = 0;
- if (!g_rd_local_data)
+ rd_route_data *rd_data = NULL;
+ nstack_rd_stack_info *prdstack = NULL;
+ int icnt = 0;
+ int inum = 0;
+ int iver = 0;
+ int iret = 0;
+ int iindex = 0;
+ rd_data_item item;
+ rd_data_type type = RD_DATA_TYPE_MAX;
+
+ if (!g_rd_local_data)
{
- NSSOC_LOGERR ("rd have not been inited");
- return NSTACK_RD_FAIL;
+ NSSOC_LOGERR("rd have not been inited");
+ return NSTACK_RD_FAIL;
}
+ /*add return value check */
+ int retVal = memset_s(&item, sizeof(item), 0, sizeof(item));
+ if (EOK != retVal)
+ {
+ NSSOC_LOGERR("memset_s failed]retVal=%d", retVal);
+ return NSTACK_RD_FAIL;
+ }
+ nstack_rd_sys_clean();
- /*insert default rd info */
- nstack_rd_sys_default ();
+ nstack_rd_sys_load_default();
- /*get from config file */
- for (icnt = 0; icnt < g_rd_local_data->fun_num; icnt++)
+ prdstack = g_rd_local_data->pstack_info;
+ for (icnt = 0; icnt < NSTACK_NUM; icnt++)
{
- if (NSTACK_RD_SUCCESS ==
- nstack_rd_data_get (g_rd_local_data->sys_fun[icnt]))
+ if (!g_rd_table_handle[icnt])
{
- iret = NSTACK_RD_SUCCESS;
+ continue;
}
- }
+ /*get from rd table */
+ iret =
+ g_rd_local_data->sys_fun(&rd_data, &inum, &iver,
+ g_rd_table_handle[icnt]);
+ if (NSTACK_RD_SUCCESS != iret)
+ {
+ NSSOC_LOGERR("nstack rd sys rd info stack fail] stack=%s",
+ prdstack[icnt].name);
+ return NSTACK_RD_FAIL;
+ }
+ NSSOC_LOGINF
+ ("nstack rd sync sucess] stack=%s, rdtable ver:%d, rdtable size:%d",
+ prdstack[icnt].name, iver, inum);
- /*age after sys */
- nstack_rd_age ();
- return iret;
+ g_rd_local_data->rdlocal_ver[icnt] = iver;
+ if (inum <= 0)
+ {
+ NSSOC_LOGDBG("no rd data got");
+ if (rd_data)
+ {
+ free(rd_data); /*this function is necessary */
+ rd_data = NULL;
+ }
+ continue;
+ }
+ for (iindex = 0; iindex < inum; iindex++)
+ {
+ if (rd_data[iindex].type >= RD_DATA_TYPE_MAX)
+ {
+ NSSOC_LOGERR("rd data type=%d unkown", rd_data[iindex].type);
+ continue;
+ }
+ type = rd_data[iindex].type;
+ if (NSTACK_RD_SUCCESS ==
+ g_rd_cpy[type].rd_item_copy((void *) &item,
+ (void *) &rd_data[iindex]))
+ {
+ item.agetime = NSTACK_RD_AGETIME_MAX;
+ item.stack_id = prdstack[icnt].stack_id;
+ /*insert to the list */
+ g_rd_cpy[type].rd_item_insert(NSTACK_RD_LIST(type), &item); /*do not need return value */
+ continue;
+ }
+ NSSOC_LOGERR("rd data type=%d cpy fail", rd_data[iindex].type);
+ }
+ free(rd_data); /*this function is necessary */
+ rd_data = NULL;
+ }
+ /*age after sys */
+ nstack_rd_age(); /*do not need return value */
+ return NSTACK_RD_SUCCESS;
}
/*****************************************************************************
@@ -378,13 +609,42 @@ nstack_rd_sys ()
* Calls :
* Called By :
*****************************************************************************/
-int
-nstack_rd_age ()
+int nstack_rd_age()
{
- int icnt = 0;
- for (icnt = 0; icnt < RD_DATA_TYPE_MAX; icnt++)
+ int icnt = 0;
+ for (icnt = 0; icnt < RD_DATA_TYPE_MAX; icnt++)
{
- (void) g_rd_cpy[icnt].rd_item_age (NSTACK_RD_LIST (icnt));
+ if (g_rd_cpy[icnt].rd_item_age)
+ (void) g_rd_cpy[icnt].rd_item_age(NSTACK_RD_LIST(icnt));
}
- return NSTACK_RD_SUCCESS;
+ return NSTACK_RD_SUCCESS;
+}
+
+int nstack_rd_match_pre(int domain, int type, int protocol,
+ rd_data_item * item)
+{
+ int ret = -1;
+ nstack_rd_key key = { 0 };
+
+ key.type = RD_DATA_TYPE_TYPE;
+ key.socket_type = type;
+ ret =
+ g_rd_cpy[key.type].rd_item_find(NSTACK_RD_LIST(key.type),
+ (void *) &key, (void *) item);
+ if (ret == NSTACK_RD_SUCCESS)
+ {
+ return item->stack_id;
+ }
+
+ key.type = RD_DATA_TYPE_PROTO;
+ key.proto = protocol;
+ ret =
+ g_rd_cpy[key.type].rd_item_find(NSTACK_RD_LIST(key.type),
+ (void *) &key, (void *) item);
+ if (ret == NSTACK_RD_SUCCESS)
+ {
+ return item->stack_id;
+ }
+
+ return -1;
}
diff --git a/src/nSocket/nstack_rd/nstack_rd_init.c b/src/nSocket/nstack_rd/nstack_rd_init.c
deleted file mode 100644
index 09186ae..0000000
--- a/src/nSocket/nstack_rd/nstack_rd_init.c
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include <stdlib.h>
-#include "nstack_rd.h"
-#include "nstack_rd_data.h"
-#include "nstack_rd_init.h"
-#include "nstack_rd_priv.h"
-#include "nstack_log.h"
-#include "nstack_securec.h"
-
-#define NSTACK_RD_ERR_CHECK_GOTO(ret, desc, lab) \
-if (NSTACK_RD_SUCCESS != (ret))\
-{ \
- NSSOC_LOGERR("%s fail, return:%d", desc, ret); \
- goto lab; \
-}
-
-#define NSTACK_RD_POINT_CHECK_GOTO(ptr, desc, lab) \
-if (!ptr)\
-{ \
- NSSOC_LOGERR("%s fail", desc); \
- goto lab; \
-}
-
-rd_local_data *g_rd_local_data = NULL;
-
-/*****************************************************************************
-* Prototype : nstack_rd_init
-* Description : nstack rd init
-* Input : nstack_stack_info *pstack
-* int num
-* nstack_get_route_data pfun
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-* pstack : 1. priority 0: when router not fund, the first will be chose
-* 2. if have many same 0 priority, fist input will be chose,
-* 3. if none 0 priority, the last input will be choose
-*****************************************************************************/
-int
-nstack_rd_init (nstack_stack_info * pstack, int num,
- nstack_get_route_data * pfun, int fun_num)
-{
- int icnt = 0;
- int hindex = 0;
- int tindex = num - 1;
- int iindex = 0;
- int ret = NSTACK_RD_SUCCESS;
- nstack_rd_stack_info *ptemstack = NULL;
-
- if ((!pstack) || (!pfun))
- {
- NSSOC_LOGERR ("input err pstack:%p, pfun:%p", pstack, pfun);
- return NSTACK_RD_FAIL;
- }
- g_rd_local_data = (rd_local_data *) malloc (sizeof (rd_local_data));
- if (!g_rd_local_data)
- {
- NSSOC_LOGERR ("g_rd_local_data alloc fail");
- return NSTACK_RD_FAIL;
- }
-
- if (EOK !=
- MEMSET_S ((void *) g_rd_local_data, sizeof (rd_local_data), 0,
- sizeof (rd_local_data)))
- {
- NSSOC_LOGERR ("MEMSET_S fail");
- goto ERR;
- }
- for (icnt = 0; icnt < fun_num; icnt++)
- {
- g_rd_local_data->sys_fun[icnt] = pfun[icnt];
- }
- g_rd_local_data->fun_num = fun_num;
- ptemstack =
- (nstack_rd_stack_info *) malloc (sizeof (nstack_rd_stack_info) * num);
- NSTACK_RD_POINT_CHECK_GOTO (ptemstack, "rd stack info malloc fail", ERR);
-
- /*save stack info in priority order */
- for (icnt = 0; icnt < num; icnt++)
- {
- if (0 == pstack[icnt].priority)
- {
- iindex = hindex;
- hindex++;
- }
- else
- {
- iindex = tindex;
- tindex--;
- }
-
- /* modify destMax from RD_PLANE_NAMELEN to STACK_NAME_MAX */
- ret =
- STRCPY_S (ptemstack[iindex].name, STACK_NAME_MAX, pstack[icnt].name);
- if (ret != EOK)
- {
- NSSOC_LOGERR ("STRCPY_S failed");
- goto ERR;
- }
-
- ptemstack[iindex].priority = pstack[icnt].priority;
- ptemstack[iindex].stack_id = pstack[icnt].stack_id;
- NSSOC_LOGDBG
- ("nstack rd init]stackname=%s,priority=%d,stackid=%d was added",
- ptemstack[iindex].name,
- ptemstack[iindex].priority, ptemstack[iindex].stack_id);
- }
-
- g_rd_local_data->pstack_info = ptemstack;
- g_rd_local_data->stack_num = num;
-
- for (icnt = 0; icnt < RD_DATA_TYPE_MAX; icnt++)
- {
- INIT_HLIST_HEAD (&(g_rd_local_data->route_list[icnt].headlist));
- }
- return NSTACK_RD_SUCCESS;
-
-ERR:
- if (g_rd_local_data)
- {
- free (g_rd_local_data);
- g_rd_local_data = NULL;
- }
- if (ptemstack)
- {
- free (ptemstack);
- }
- return NSTACK_RD_FAIL;
-}
-
-/*****************************************************************************
-* Prototype : nstack_get_stackid_byname
-* Description : get stack ip by stack name
-* Input : char *name
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*****************************************************************************/
-int
-nstack_get_stackid_byname (char *name)
-{
- int stacknum = g_rd_local_data->stack_num;
- int iindex = 0;
- nstack_rd_stack_info *pstack = NULL;
- for (iindex = 0; iindex < stacknum; iindex++)
- {
- pstack = &(g_rd_local_data->pstack_info[iindex]);
- if (0 == strcmp (pstack->name, name))
- {
- return pstack->stack_id;
- }
- }
- return -1;
-}
diff --git a/src/nSocket/nstack_rd/nstack_rd_ip.c b/src/nSocket/nstack_rd/nstack_rd_ip.c
index 82035d1..d769720 100644
--- a/src/nSocket/nstack_rd/nstack_rd_ip.c
+++ b/src/nSocket/nstack_rd/nstack_rd_ip.c
@@ -18,157 +18,158 @@
#include <arpa/inet.h>
#include "nstack_rd_data.h"
#include "nstack_rd.h"
-#include "nstack_rd_init.h"
#include "nstack_rd_priv.h"
#include "nstack_rd_ip.h"
#include "nstack_log.h"
#include "nstack_securec.h"
+/* Optimize log */
#include "nstack_ip_addr.h"
-#define NSTACK_IP_MLSTACKID RD_LWIP
-
#define PP_HTONL(x) ((((x) & 0xff) << 24) | \
(((x) & 0xff00) << 8) | \
(((x) & 0xff0000UL) >> 8) | \
(((x) & 0xff000000UL) >> 24))
-#define rd_ismulticast(addr)(((unsigned int)(addr) & 0xf0000000UL) == 0xe0000000UL)
+#define rd_ismulticast(addr)(((ntohl(addr)) & 0xf0000000UL) == 0xe0000000UL)
int g_multi_stackid = -1;
/*copy rd data*/
-int
-nstack_rd_ipdata_cpy (void *destdata, void *srcdata)
+int nstack_rd_ip_data_cpy(void *destdata, void *srcdata)
{
- rd_data_item *pitem = (rd_data_item *) destdata;
- rd_route_data *pdata = (rd_route_data *) srcdata;
-
- pitem->type = pdata->type;
- pitem->ipdata.addr = pdata->ipdata.addr;
- pitem->ipdata.masklen = pdata->ipdata.masklen;
- pitem->ipdata.resev[0] = pdata->ipdata.resev[0];
- pitem->ipdata.resev[1] = pdata->ipdata.resev[1];
- return NSTACK_RD_SUCCESS;
+ rd_data_item *pitem = (rd_data_item *) destdata;
+ rd_route_data *pdata = (rd_route_data *) srcdata;
+
+ pitem->type = pdata->type;
+ pitem->ipdata.addr = pdata->ipdata.addr;
+ pitem->ipdata.masklen = pdata->ipdata.masklen;
+ pitem->ipdata.resev[0] = pdata->ipdata.resev[0];
+ pitem->ipdata.resev[1] = pdata->ipdata.resev[1];
+ return NSTACK_RD_SUCCESS;
}
/*
* Add an ip segment to the list and sort it in descending order of ip mask length
* If the list already exists in the same list of ip side, then stack_id update
- *ip is local byteorder
+ *ip is network byte order
*/
-int
-nstack_rd_ip_item_insert (nstack_rd_list * hlist, void *rditem)
+/*vars are used in macro*/
+int nstack_rd_ip_item_insert(nstack_rd_list * hlist, void *rditem)
{
- nstack_rd_node *pdatanode = NULL;
- nstack_rd_node *tempdata = NULL;
- struct hlist_node *tempnode = NULL;
- struct hlist_node *tem = NULL;
-
- unsigned int tempip_addr = 0;
- unsigned int tempip_masklen = 0;
- rd_data_item *pitem = (rd_data_item *) rditem;
- unsigned int ip_addr = pitem->ipdata.addr;
- unsigned int ip_masklen = pitem->ipdata.masklen;
- unsigned int ip_maskv = MASK_V (ip_addr, ip_masklen);
-
- ip_masklen = pitem->ipdata.masklen;
- NSSOC_LOGDBG ("stackid:%d, ipaddr:%u.%u.%u.%u masklen:0x%x was inserted",
- pitem->stack_id, ip4_addr4_16 (&pitem->ipdata.addr),
- ip4_addr3_16 (&pitem->ipdata.addr),
- ip4_addr2_16 (&pitem->ipdata.addr),
- ip4_addr1_16 (&pitem->ipdata.addr), pitem->ipdata.masklen);
-
- pdatanode = (nstack_rd_node *) malloc (sizeof (nstack_rd_node));
- if (!pdatanode)
+ nstack_rd_node *pdatanode = NULL;
+ nstack_rd_node *tempdata = NULL;
+ struct hlist_node *tempnode = NULL;
+ struct hlist_node *tem = NULL;
+ unsigned int ip_addr = 0;
+ unsigned int ip_masklen = 0;
+ unsigned int ip_maskv = 0;
+ unsigned int tempip_addr = 0;
+ unsigned int tempip_masklen = 0;
+ rd_data_item *pitem = (rd_data_item *) rditem;
+
+ ip_masklen = pitem->ipdata.masklen;
+ ip_addr = pitem->ipdata.addr;
+ ip_maskv = MASK_V(ip_addr, ip_masklen);
+
+ /* Optimize log */
+ NSSOC_LOGDBG("stackid:%d, ipaddr:*.*.%u.%u masklen:0x%x was inserted",
+ pitem->stack_id, FUZZY_IP_VAR(&pitem->ipdata.addr),
+ pitem->ipdata.masklen);
+
+ pdatanode = (nstack_rd_node *) malloc(sizeof(nstack_rd_node)); /*this function is necessary */
+ if (!pdatanode)
{
- NSSOC_LOGERR ("nstack rd item malloc fail");
- return NSTACK_RD_FAIL;
+ NSSOC_LOGERR("nstack rd item malloc fail");
+ return NSTACK_RD_FAIL;
}
- int retVal =
- MEMSET_S (pdatanode, sizeof (nstack_rd_node), 0, sizeof (nstack_rd_node));
- if (EOK != retVal)
+ /* add return value check */
+ int retVal = memset_s(pdatanode, sizeof(nstack_rd_node), 0,
+ sizeof(nstack_rd_node));
+ if (EOK != retVal)
{
- NSSOC_LOGERR ("MEMSET_S failed]retVal=%d", retVal);
- free (pdatanode);
- return NSTACK_RD_FAIL;
+ NSSOC_LOGERR("memset_s failed]retVal=%d", retVal);
+ free(pdatanode); /*this function is necessary */
+ return NSTACK_RD_FAIL;
}
- INIT_HLIST_NODE (&pdatanode->rdnode);
- NSTACK_RD_IP_ITEM_COPY (&(pdatanode->item), pitem);
+ INIT_HLIST_NODE(&pdatanode->rdnode);
+ NSTACK_RD_IP_ITEM_COPY(&(pdatanode->item), pitem);
- if (hlist_empty (&(hlist->headlist)))
+ if (hlist_empty(&(hlist->headlist)))
{
- hlist_add_head (&(pdatanode->rdnode), &(hlist->headlist));
- return NSTACK_RD_SUCCESS;
+ hlist_add_head(&(pdatanode->rdnode), &(hlist->headlist));
+
+ return NSTACK_RD_SUCCESS;
+
}
- hlist_for_each_entry (tempdata, tempnode, &(hlist->headlist), rdnode)
- {
- tem = tempnode;
- tempip_addr = tempdata->item.ipdata.addr;
- tempip_masklen = tempdata->item.ipdata.masklen;
- if (ip_masklen < tempip_masklen)
- {
- continue;
- }
-
- /*if already exist, just return success */
- if (ip_maskv == MASK_V (tempip_addr, tempip_masklen))
- {
- NSSOC_LOGDBG
- ("insert ip:%u.%u.%u.%u, mask:0x%x, stack_id:%d, exist orgid:%d",
- ip4_addr4_16 (&pitem->ipdata.addr),
- ip4_addr3_16 (&pitem->ipdata.addr),
- ip4_addr2_16 (&pitem->ipdata.addr),
- ip4_addr1_16 (&pitem->ipdata.addr), pitem->ipdata.masklen,
- pitem->stack_id, tempdata->item.stack_id);
-
- tempdata->item.stack_id = pitem->stack_id;
- tempdata->item.agetime = NSTACK_RD_AGETIME_MAX;
- free (pdatanode);
+
+ hlist_for_each_entry(tempdata, tempnode, &(hlist->headlist), rdnode)
+ {
+ tem = tempnode;
+ tempip_addr = tempdata->item.ipdata.addr;
+ tempip_masklen = tempdata->item.ipdata.masklen;
+ if (ip_masklen < tempip_masklen)
+ {
+ continue;
+ }
+
+ /*if already exist, just return success */
+ if (ip_maskv == MASK_V(tempip_addr, tempip_masklen))
+ {
+ /* Optimize log */
+ NSSOC_LOGDBG
+ ("insert ip=*.*.%u.%u, mask=0x%x, stack_id=%d, exist orgid=%d",
+ FUZZY_IP_VAR(&pitem->ipdata.addr), pitem->ipdata.masklen,
+ pitem->stack_id, tempdata->item.stack_id);
+ /* Optimize log */
+
+ tempdata->item.stack_id = pitem->stack_id;
+ tempdata->item.agetime = NSTACK_RD_AGETIME_MAX;
+ free(pdatanode); /*this function is necessary */
+ return NSTACK_RD_SUCCESS;
+ }
+ hlist_add_before(&(pdatanode->rdnode), tempnode);
+
return NSTACK_RD_SUCCESS;
- }
- hlist_add_before (&(pdatanode->rdnode), tempnode);
+
+ }
+ hlist_add_after(tem, &(pdatanode->rdnode));
+
return NSTACK_RD_SUCCESS;
- }
- hlist_add_after (tem, &(pdatanode->rdnode));
- return NSTACK_RD_SUCCESS;
+
}
/*
*find stackid by ip
- *input ip must netorder
+ *input ip must be network order
*/
-int
-nstack_rd_ip_item_find (nstack_rd_list * hlist, void *rdkey, void *outitem)
+int nstack_rd_ip_item_find(nstack_rd_list * hlist, void *rdkey, void *outitem)
{
- struct hlist_node *tempnode = NULL;
- nstack_rd_node *tempdata = NULL;
- unsigned int tempip_addr = 0;
- unsigned int tempip_masklen = 0;
- nstack_rd_key *key = (nstack_rd_key *) rdkey;
- rd_data_item *pitem = (rd_data_item *) outitem;
- unsigned int ip_addr = 0;
- /*need to convert to local order */
- ip_addr = ntohl (key->ip_addr);
-
- hlist_for_each_entry (tempdata, tempnode, &(hlist->headlist), rdnode)
- {
- tempip_addr = tempdata->item.ipdata.addr;
- tempip_masklen = tempdata->item.ipdata.masklen;
- /*if already exist, just return success */
- if (MASK_V (ip_addr, tempip_masklen) ==
- MASK_V (tempip_addr, tempip_masklen))
- {
- NSTACK_RD_IP_ITEM_COPY (pitem, &(tempdata->item));
- return NSTACK_RD_SUCCESS;
- }
- }
+ struct hlist_node *tempnode = NULL;
+ nstack_rd_node *tempdata = NULL;
+ unsigned int tempip_addr = 0;
+ unsigned int tempip_masklen = 0;
+ nstack_rd_key *key = (nstack_rd_key *) rdkey;
+ rd_data_item *pitem = (rd_data_item *) outitem;
+ unsigned int ip_addr = key->ip_addr;
- NSSOC_LOGDBG ("ip=%u.%u.%u.%u item not found", ip4_addr4_16 (&ip_addr),
- ip4_addr3_16 (&ip_addr),
- ip4_addr2_16 (&ip_addr), ip4_addr1_16 (&ip_addr));
+ hlist_for_each_entry(tempdata, tempnode, &(hlist->headlist), rdnode)
+ {
+ tempip_addr = tempdata->item.ipdata.addr;
+ tempip_masklen = tempdata->item.ipdata.masklen;
+ /*if already exist, just return success */
+ if (MASK_V(ip_addr, tempip_masklen) ==
+ MASK_V(tempip_addr, tempip_masklen))
+ {
+ NSTACK_RD_IP_ITEM_COPY(pitem, &(tempdata->item));
+ return NSTACK_RD_SUCCESS;
+ }
+ }
- return NSTACK_RD_FAIL;
+ /* Optimize log */
+ NSSOC_LOGDBG("ip=*.*.%u.%u item not found", FUZZY_IP_VAR(&ip_addr));
+
+ return NSTACK_RD_FAIL;
}
/*****************************************************************************
@@ -180,86 +181,130 @@ nstack_rd_ip_item_find (nstack_rd_list * hlist, void *rdkey, void *outitem)
* Calls :
* Called By :
*****************************************************************************/
-int
-nstack_rd_ip_item_age (nstack_rd_list * hlist)
+int nstack_rd_ip_item_age(nstack_rd_list * hlist)
+{
+ struct hlist_node *tempnode = NULL;
+ nstack_rd_node *tempdata = NULL;
+ nstack_rd_node *prevdata = NULL;
+ struct hlist_node *prevnode = NULL;
+ NSSOC_LOGINF("nstack rd ip age begin");
+ hlist_for_each_entry(tempdata, tempnode, &(hlist->headlist), rdnode)
+ {
+ /*if agetime equal 0, remove it */
+ if (tempdata->item.agetime <= 0)
+ {
+ if (prevdata)
+ {
+ /* Optimize log */
+ NSSOC_LOGDBG
+ ("stackid=%d, addrip=*.*.%u.%u, masklen=0x%x was aged",
+ tempdata->item.stack_id,
+ FUZZY_IP_VAR(&tempdata->item.ipdata.addr),
+ tempdata->item.ipdata.masklen);
+
+ hlist_del_init(prevnode);
+ free(prevdata); /*this function is necessary */
+ }
+ prevdata = tempdata;
+ prevnode = tempnode;
+ }
+ else
+ {
+ tempdata->item.agetime--;
+ }
+ }
+ if (prevdata)
+ {
+ if (tempdata)
+ {
+ /* Optimize log */
+ NSSOC_LOGDBG
+ ("stackid:%d, addrip:*.*.%u.%u, masklen:0x%x was last aged",
+ tempdata->item.stack_id,
+ FUZZY_IP_VAR(&tempdata->item.ipdata.addr),
+ tempdata->item.ipdata.masklen);
+ }
+ hlist_del_init(prevnode);
+ free(prevdata); /*this function is necessary */
+ }
+ NSSOC_LOGINF("nstack rd ip age end");
+ return NSTACK_RD_SUCCESS;
+}
+
+void nstack_rd_ip_item_clean(nstack_rd_list * hlist)
{
- struct hlist_node *tempnode = NULL;
- nstack_rd_node *tempdata = NULL;
- nstack_rd_node *prevdata = NULL;
- struct hlist_node *prevnode = NULL;
- NSSOC_LOGINF ("nstack rd ip age begin");
- hlist_for_each_entry (tempdata, tempnode, &(hlist->headlist), rdnode)
- {
- /*if agetime equal 0, remove it */
- if (tempdata->item.agetime <= 0)
- {
+ struct hlist_node *tempnode = NULL;
+ nstack_rd_node *tempdata = NULL;
+ nstack_rd_node *prevdata = NULL;
+ struct hlist_node *prevnode = NULL;
+ NSSOC_LOGINF("nstack rd ip item clean begin");
+ hlist_for_each_entry(tempdata, tempnode, &(hlist->headlist), rdnode)
+ {
if (prevdata)
- {
+ {
NSSOC_LOGDBG
- ("stackid:%d, addrip:%u.%u.%u.%u, masklen:0x%x was aged",
- tempdata->item.stack_id,
- ip4_addr4_16 (&tempdata->item.ipdata.addr),
- ip4_addr3_16 (&tempdata->item.ipdata.addr),
- ip4_addr2_16 (&tempdata->item.ipdata.addr),
- ip4_addr1_16 (&tempdata->item.ipdata.addr),
- tempdata->item.ipdata.masklen);
-
- hlist_del_init (prevnode);
- free (prevdata);
- }
+ ("stackid=%d, addrip=*.*.%u.%u, masklen=0x%x was aged",
+ tempdata->item.stack_id,
+ FUZZY_IP_VAR(&tempdata->item.ipdata.addr),
+ tempdata->item.ipdata.masklen);
+
+ hlist_del_init(prevnode);
+ free(prevdata); /*this function is necessary */
+ }
+
prevdata = tempdata;
prevnode = tempnode;
- }
- else
- {
- tempdata->item.agetime--;
- }
- }
- if (prevdata)
+ }
+ if (prevdata)
{
- if (tempdata)
+ if (tempdata)
{
- NSSOC_LOGDBG
- ("stackid:%d, addrip:%u.%u.%u.%u, masklen:0x%x was last aged",
- tempdata->item.stack_id,
- ip4_addr4_16 (&tempdata->item.ipdata.addr),
- ip4_addr3_16 (&tempdata->item.ipdata.addr),
- ip4_addr2_16 (&tempdata->item.ipdata.addr),
- ip4_addr1_16 (&tempdata->item.ipdata.addr),
- tempdata->item.ipdata.masklen);
+ NSSOC_LOGDBG
+ ("stackid:%d, addrip:*.*.%u.%u, masklen:0x%x was last aged",
+ tempdata->item.stack_id,
+ FUZZY_IP_VAR(&tempdata->item.ipdata.addr),
+ tempdata->item.ipdata.masklen);
}
- hlist_del_init (prevnode);
- free (prevdata);
+ hlist_del_init(prevnode);
+ free(prevdata); /*this function is necessary */
}
- NSSOC_LOGINF ("nstack rd ip age end");
- return NSTACK_RD_SUCCESS;
+ NSSOC_LOGINF("nstack rd ip item clean end");
+}
+
+static int nstack_get_stackid_byname(char *name)
+{
+ int stacknum = g_rd_local_data->stack_num;
+ int iindex = 0;
+ nstack_rd_stack_info *pstack = NULL;
+ for (iindex = 0; iindex < stacknum; iindex++)
+ {
+ pstack = &(g_rd_local_data->pstack_info[iindex]);
+ if (0 == strcmp(pstack->name, name))
+ {
+ return pstack->stack_id;
+ }
+ }
+ return -1;
}
/*
*find stackid by spec ip(multicast ip)
- *input ip must netorder
+ *input ip must be network order
*/
-int
-nstack_rd_ip_spec (void *rdkey)
+int nstack_rd_ip_spec(void *rdkey)
{
- nstack_rd_key *key = (nstack_rd_key *) rdkey;
- unsigned int ip_addr = 0;
+ nstack_rd_key *key = (nstack_rd_key *) rdkey;
+ unsigned int ip_addr = 0;
- ip_addr = ntohl (key->ip_addr);
+ ip_addr = (key->ip_addr);
- if (rd_ismulticast (ip_addr))
+ if (rd_ismulticast(ip_addr))
{
- if (-1 == g_multi_stackid)
+ if (-1 == g_multi_stackid)
{
- g_multi_stackid = nstack_get_stackid_byname (NSTACK_IP_MLSTACKID);
+ g_multi_stackid = nstack_get_stackid_byname(RD_STACKPOOL_NAME);
}
- return g_multi_stackid;
+ return g_multi_stackid;
}
- return -1;
-}
-
-int
-nstack_rd_ip_default (void *rdkey)
-{
- return NSTACK_GET_STACK (0);
+ return -1;
}
diff --git a/src/nSocket/nstack_rd/nstack_rd_ip.h b/src/nSocket/nstack_rd/nstack_rd_ip.h
index d64956d..b3abee3 100644
--- a/src/nSocket/nstack_rd/nstack_rd_ip.h
+++ b/src/nSocket/nstack_rd/nstack_rd_ip.h
@@ -17,6 +17,8 @@
#ifndef __NSTACK_RD_IP_H
#define __NSTACK_RD_IP_H
+#include "nstack_rd_priv.h"
+
#define NSTACK_RD_IP_ITEM_COPY(destitem, srcitem){ \
(destitem)->agetime = (srcitem)->agetime; \
(destitem)->stack_id = (srcitem)->stack_id; \
@@ -27,12 +29,12 @@
(destitem)->ipdata.resev[1] = (srcitem)->ipdata.resev[1]; \
}
-int nstack_rd_ipdata_cpy (void *destdata, void *srcdata);
-int nstack_rd_ip_item_insert (nstack_rd_list * hlist, void *rditem);
-int nstack_rd_ip_item_find (nstack_rd_list * hlist, void *rdkey,
- void *outitem);
-int nstack_rd_ip_item_age (nstack_rd_list * hlist);
-int nstack_rd_ip_spec (void *rdkey);
-int nstack_rd_ip_default (void *rdkey);
+int nstack_rd_ip_data_cpy(void *destdata, void *srcdata);
+int nstack_rd_ip_item_insert(nstack_rd_list * hlist, void *rditem);
+int nstack_rd_ip_item_find(nstack_rd_list * hlist, void *rdkey,
+ void *outitem);
+int nstack_rd_ip_item_age(nstack_rd_list * hlist);
+void nstack_rd_ip_item_clean(nstack_rd_list * hlist);
+int nstack_rd_ip_spec(void *rdkey);
#endif
diff --git a/src/nSocket/nstack_rd/nstack_rd_ip6.c b/src/nSocket/nstack_rd/nstack_rd_ip6.c
new file mode 100644
index 0000000..dde201d
--- /dev/null
+++ b/src/nSocket/nstack_rd/nstack_rd_ip6.c
@@ -0,0 +1,261 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#include <stdlib.h>
+#include <arpa/inet.h>
+#include "nstack_rd_data.h"
+#include "nstack_rd.h"
+#include "nstack_rd_priv.h"
+#include "nstack_rd_ip6.h"
+#include "nstack_log.h"
+#include "nstack_securec.h"
+#include "nstack_ip_addr.h"
+
+inline static const char *ip6_ntoa(const ip6_addr_t * addr)
+{
+#define IP6_NTOA_NUM (1 << 3)
+#define IP6_NTOA_LEN 46
+ static __thread char ip6_ntoa_buf[IP6_NTOA_NUM][IP6_NTOA_LEN];
+ static __thread unsigned int ip6_ntoa_index = 0;
+
+ char *buf = ip6_ntoa_buf[(ip6_ntoa_index++) & (IP6_NTOA_NUM - 1)];
+ return inet_ntop(AF_INET, addr, buf, IP6_NTOA_LEN);
+}
+
+int nstack_rd_ip6_data_cpy(void *destdata, void *srcdata)
+{
+ rd_data_item *pitem = (rd_data_item *) destdata;
+ rd_route_data *pdata = (rd_route_data *) srcdata;
+
+ pitem->type = pdata->type;
+ pitem->ip6data = pdata->ip6data;
+ return NSTACK_RD_SUCCESS;
+}
+
+/*
+ * Add an ip segment to the list and sort it in descending order of ip mask length
+ * If the list already exists in the same list of ip side, then stack_id update
+ * ip is network byte order
+ */
+/*vars are used in macro*/
+int nstack_rd_ip6_item_insert(nstack_rd_list * hlist, void *rditem)
+{
+ nstack_rd_node *pdatanode = NULL;
+ nstack_rd_node *tempdata = NULL;
+ struct hlist_node *tempnode = NULL;
+ struct hlist_node *tem = NULL;
+ rd_data_item *pitem = (rd_data_item *) rditem;
+ char buf[52];
+
+ NSSOC_LOGDBG("stackid:%d, ip6addr:%s masklen:0x%x was inserted",
+ pitem->stack_id, inet_ntop(AF_INET6, &pitem->ip6data.addr,
+ buf, sizeof(buf)),
+ pitem->ip6data.masklen);
+
+ pdatanode = (nstack_rd_node *) malloc(sizeof(nstack_rd_node)); /*this function is necessary */
+ if (!pdatanode)
+ {
+ NSSOC_LOGERR("nstack rd item malloc fail");
+ return NSTACK_RD_FAIL;
+ }
+
+ int retVal = memset_s(pdatanode, sizeof(nstack_rd_node), 0,
+ sizeof(nstack_rd_node));
+ if (EOK != retVal)
+ {
+ NSSOC_LOGERR("memset_s failed]retVal=%d", retVal);
+ free(pdatanode); /*this function is necessary */
+ return NSTACK_RD_FAIL;
+ }
+
+ INIT_HLIST_NODE(&pdatanode->rdnode);
+ pdatanode->item = *pitem;
+
+ if (hlist_empty(&(hlist->headlist)))
+ {
+ hlist_add_head(&(pdatanode->rdnode), &(hlist->headlist));
+
+ return NSTACK_RD_SUCCESS;
+
+ }
+
+ hlist_for_each_entry(tempdata, tempnode, &(hlist->headlist), rdnode)
+ {
+ tem = tempnode;
+ if (pitem->ip6data.masklen < tempdata->item.ip6data.masklen)
+ {
+ continue;
+ }
+
+ /*if already exist, just return success */
+ if (pitem->ip6data.masklen == tempdata->item.ip6data.masklen &&
+ ip6_addr_match(&pitem->ip6data.addr,
+ &tempdata->item.ip6data.addr,
+ pitem->ip6data.masklen))
+ {
+ NSSOC_LOGDBG
+ ("insert ip6:%s, mask:0x%x, stack_id:%d, exist orgid:%d",
+ inet_ntop(AF_INET6, &pitem->ip6data.addr, buf,
+ sizeof(buf)), pitem->ip6data.masklen,
+ pitem->stack_id, tempdata->item.stack_id);
+
+ tempdata->item.stack_id = pitem->stack_id;
+ tempdata->item.agetime = NSTACK_RD_AGETIME_MAX;
+ free(pdatanode); /*this function is necessary */
+ return NSTACK_RD_SUCCESS;
+ }
+ hlist_add_before(&(pdatanode->rdnode), tempnode);
+
+ return NSTACK_RD_SUCCESS;
+
+ }
+ hlist_add_after(tem, &(pdatanode->rdnode));
+
+ return NSTACK_RD_SUCCESS;
+
+}
+
+int nstack_rd_ip6_item_age(nstack_rd_list * hlist)
+{
+ struct hlist_node *tempnode = NULL;
+ nstack_rd_node *tempdata = NULL;
+ nstack_rd_node *prevdata = NULL;
+ struct hlist_node *prevnode = NULL;
+ char buf[46];
+
+ NSSOC_LOGINF("nstack rd ip age begin");
+ hlist_for_each_entry(tempdata, tempnode, &(hlist->headlist), rdnode)
+ {
+ /*if agetime equal 0, remove it */
+ if (tempdata->item.agetime <= 0)
+ {
+ if (prevdata)
+ {
+ NSSOC_LOGDBG("stackid:%d, addrip6:%s, masklen:0x%x was aged",
+ tempdata->item.stack_id,
+ inet_ntop(AF_INET6,
+ &tempdata->item.ip6data.addr, buf,
+ sizeof(buf)),
+ tempdata->item.ip6data.masklen);
+
+ hlist_del_init(prevnode);
+ free(prevdata); /*this function is necessary */
+ }
+ prevdata = tempdata;
+ prevnode = tempnode;
+ }
+ else
+ {
+ tempdata->item.agetime--;
+ }
+ }
+ if (prevdata)
+ {
+ if (tempdata)
+ {
+ NSSOC_LOGDBG
+ ("stackid:%d, addrip6:%s, masklen:0x%x was last aged",
+ tempdata->item.stack_id, inet_ntop(AF_INET6,
+ &tempdata->item.
+ ip6data.addr, buf,
+ sizeof(buf)),
+ tempdata->item.ip6data.masklen);
+ }
+ hlist_del_init(prevnode);
+ free(prevdata); /*this function is necessary */
+ }
+
+ NSSOC_LOGINF("nstack rd ip age end");
+ return NSTACK_RD_SUCCESS;
+}
+
+void nstack_rd_ip6_item_clean(nstack_rd_list * hlist)
+{
+ struct hlist_node *tempnode = NULL;
+ nstack_rd_node *tempdata = NULL;
+ nstack_rd_node *prevdata = NULL;
+ struct hlist_node *prevnode = NULL;
+ char buf[46];
+
+ NSSOC_LOGINF("nstack rd ip clean begin");
+ hlist_for_each_entry(tempdata, tempnode, &(hlist->headlist), rdnode)
+ {
+ if (prevdata)
+ {
+ NSSOC_LOGDBG("stackid:%d, addrip6:%s, masklen:0x%x was aged",
+ tempdata->item.stack_id,
+ inet_ntop(AF_INET6, &tempdata->item.ip6data.addr,
+ buf, sizeof(buf)),
+ tempdata->item.ip6data.masklen);
+
+ hlist_del_init(prevnode);
+ free(prevdata); /*this function is necessary */
+ }
+
+ prevdata = tempdata;
+ prevnode = tempnode;
+ }
+ if (prevdata)
+ {
+ if (tempdata)
+ {
+ NSSOC_LOGDBG
+ ("stackid:%d, addrip6:%s, masklen:0x%x was last aged",
+ tempdata->item.stack_id, inet_ntop(AF_INET6,
+ &tempdata->item.
+ ip6data.addr, buf,
+ sizeof(buf)),
+ tempdata->item.ip6data.masklen);
+ }
+ hlist_del_init(prevnode);
+ free(prevdata); /*this function is necessary */
+ }
+
+ NSSOC_LOGINF("nstack rd ip clean end");
+}
+
+int nstack_rd_ip6_item_find(nstack_rd_list * hlist, void *rdkey,
+ void *outitem)
+{
+ struct hlist_node *tempnode = NULL;
+ nstack_rd_node *tempdata = NULL;
+ nstack_rd_key *key = (nstack_rd_key *) rdkey;
+ char buf[46];
+
+ hlist_for_each_entry(tempdata, tempnode, &(hlist->headlist), rdnode)
+ {
+ rd_data_item *tempitem = &tempdata->item;
+
+ /*if already exist, just return success */
+ if (ip6_addr_match
+ ((struct ip6_addr *) &key->in6_addr, &tempitem->ip6data.addr,
+ tempitem->ip6data.masklen))
+ {
+ *(rd_data_item *) outitem = *tempitem;
+ return NSTACK_RD_SUCCESS;
+ }
+ }
+
+ NSSOC_LOGDBG("ip6=%s item not found",
+ inet_ntop(AF_INET6, &key->in6_addr, buf, sizeof(buf)));
+
+ return NSTACK_RD_FAIL;
+}
+
+int nstack_rd_ip6_spec(void *rdkey)
+{
+ return -1;
+}
diff --git a/src/framework/common/base/include/common/common_mem_common.h b/src/nSocket/nstack_rd/nstack_rd_ip6.h
index 1e4cf56..2934bb3 100644
--- a/src/framework/common/base/include/common/common_mem_common.h
+++ b/src/nSocket/nstack_rd/nstack_rd_ip6.h
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-#ifndef _COMMON_MEM_COMMON_H_
-#define _COMMON_MEM_COMMON_H_
+#define __NSTACK_RD_IP6_H
-#ifdef HAL_LIB
-#else
-#include "rte_common.h"
-#endif
-
-#endif
+int nstack_rd_ip6_data_cpy(void *destdata, void *srcdata);
+int nstack_rd_ip6_item_insert(nstack_rd_list * hlist, void *rditem);
+int nstack_rd_ip6_item_find(nstack_rd_list * hlist, void *rdkey,
+ void *outitem);
+int nstack_rd_ip6_item_age(nstack_rd_list * hlist);
+void nstack_rd_ip6_item_clean(nstack_rd_list * hlist);
+int nstack_rd_ip6_spec(void *rdkey);
diff --git a/src/nSocket/nstack_rd/nstack_rd_proto.c b/src/nSocket/nstack_rd/nstack_rd_proto.c
index 81246c0..e1c58e2 100644
--- a/src/nSocket/nstack_rd/nstack_rd_proto.c
+++ b/src/nSocket/nstack_rd/nstack_rd_proto.c
@@ -18,107 +18,111 @@
#include <arpa/inet.h>
#include "nstack_rd_data.h"
#include "nstack_rd.h"
-#include "nstack_rd_init.h"
#include "nstack_rd_priv.h"
#include "nstack_rd_proto.h"
#include "nstack_log.h"
#include "nstack_securec.h"
-#include "common_mem_common.h"
/*copy rd data*/
-int
-nstack_rd_proto_cpy (void *destdata, void *srcdata)
+int nstack_rd_proto_data_cpy(void *destdata, void *srcdata)
{
- rd_data_item *pitem = (rd_data_item *) destdata;
- rd_route_data *pdata = (rd_route_data *) srcdata;
- pitem->type = pdata->type;
- pitem->proto_type = pdata->proto_type;
- return NSTACK_RD_SUCCESS;
+ rd_data_item *pitem = (rd_data_item *) destdata;
+ rd_route_data *pdata = (rd_route_data *) srcdata;
+
+ pitem->type = pdata->type;
+ pitem->proto_data.value = pdata->proto_data.value;
+ pitem->proto_data.attr = pdata->proto_data.attr;
+ return NSTACK_RD_SUCCESS;
}
/*
* Add an ip segment to the list and sort it in descending order of ip mask length
* If the list already exists in the same list of ip side, then stack_id update
- *ip is local byteorder
+ *ip is network byte order
*/
-int
-nstack_rd_proto_item_insert (nstack_rd_list * hlist, void *rditem)
+/*vars are used in macro*/
+int nstack_rd_proto_item_insert(nstack_rd_list * hlist, void *rditem)
{
- nstack_rd_node *pdatanode = NULL;
- nstack_rd_node *tempdata = NULL;
- struct hlist_node *tempnode = NULL;
- rd_data_item *pitem = (rd_data_item *) rditem;
+ nstack_rd_node *pdatanode = NULL;
+ nstack_rd_node *tempdata = NULL;
+ struct hlist_node *tempnode = NULL;
+ rd_data_item *pitem = (rd_data_item *) rditem;
- NSSOC_LOGDBG ("stackid:%d, protocol type:%d was inserted", pitem->stack_id,
- pitem->proto_type);
+ NSSOC_LOGDBG("stackid:%d, proto value:%u proto attr:%u was inserted",
+ pitem->stack_id, pitem->proto_data.value,
+ pitem->proto_data.attr);
- pdatanode = (nstack_rd_node *) malloc (sizeof (nstack_rd_node));
- if (!pdatanode)
+ pdatanode = (nstack_rd_node *) malloc(sizeof(nstack_rd_node)); /*this function is necessary */
+ if (!pdatanode)
{
- NSSOC_LOGERR ("nstack rd item malloc fail");
- return NSTACK_RD_FAIL;
+ NSSOC_LOGERR("nstack rd item malloc fail");
+ return NSTACK_RD_FAIL;
}
- int retVal =
- MEMSET_S (pdatanode, sizeof (nstack_rd_node), 0, sizeof (nstack_rd_node));
- if (EOK != retVal)
+ /* add return value check */
+ int retVal = memset_s(pdatanode, sizeof(nstack_rd_node), 0,
+ sizeof(nstack_rd_node));
+ if (EOK != retVal)
{
- NSSOC_LOGERR ("MEMSET_S failed]retVal=%d", retVal);
- free (pdatanode);
- return NSTACK_RD_FAIL;
+ NSSOC_LOGERR("memset_s failed]retVal=%d", retVal);
+ free(pdatanode); /*this function is necessary */
+ return NSTACK_RD_FAIL;
}
- INIT_HLIST_NODE (&pdatanode->rdnode);
- NSTACK_RD_PROTO_ITEM_COPY (&(pdatanode->item), pitem);
- if (hlist_empty (&(hlist->headlist)))
+ INIT_HLIST_NODE(&pdatanode->rdnode);
+ NSTACK_RD_PROTO_ITEM_COPY(&(pdatanode->item), pitem);
+
+ if (hlist_empty(&(hlist->headlist)))
{
- hlist_add_head (&(pdatanode->rdnode), &(hlist->headlist));
+ hlist_add_head(&(pdatanode->rdnode), &(hlist->headlist));
- return NSTACK_RD_SUCCESS;
+ return NSTACK_RD_SUCCESS;
}
- hlist_for_each_entry (tempdata, tempnode, &(hlist->headlist), rdnode)
- {
- if (tempdata->item.proto_type == pitem->proto_type)
-
- {
- tempdata->item.stack_id = pitem->stack_id;
- tempdata->item.agetime = NSTACK_RD_AGETIME_MAX;
- free (pdatanode);
- return NSTACK_RD_SUCCESS;
- }
- }
- hlist_add_head (&(pdatanode->rdnode), &(hlist->headlist));
+ hlist_for_each_entry(tempdata, tempnode, &(hlist->headlist), rdnode)
+ {
+ if (tempdata->item.proto_data.value == pitem->proto_data.value)
+ {
+ NSSOC_LOGDBG
+ ("find duplicate node, proto value:%u, old stack_id:%d, new stack_id:%d",
+ pitem->proto_data.value, tempdata->item.stack_id,
+ pitem->stack_id);
+ tempdata->item.stack_id = pitem->stack_id;
+ tempdata->item.agetime = NSTACK_RD_AGETIME_MAX;
+ free(pdatanode); /*this function is necessary */
+ return NSTACK_RD_SUCCESS;
+ }
+ }
+ hlist_add_head(&(pdatanode->rdnode), &(hlist->headlist));
- return NSTACK_RD_SUCCESS;
+ return NSTACK_RD_SUCCESS;
}
/*
*find stackid by ip
- *input ip must netorder
+ *input ip must be network order
*/
-int
-nstack_rd_proto_item_find (nstack_rd_list * hlist, void *rdkey, void *outitem)
+int nstack_rd_proto_item_find(nstack_rd_list * hlist, void *rdkey,
+ void *outitem)
{
- struct hlist_node *tempnode = NULL;
- nstack_rd_node *tempdata = NULL;
- nstack_rd_key *key = (nstack_rd_key *) rdkey;
- rd_data_item *pitem = (rd_data_item *) outitem;
- hlist_for_each_entry (tempdata, tempnode, &(hlist->headlist), rdnode)
- {
-
- /*if already exist, just return success */
- if (tempdata->item.proto_type == key->proto_type)
-
- {
- NSTACK_RD_PROTO_ITEM_COPY (pitem, &(tempdata->item));
- return NSTACK_RD_SUCCESS;
- }
- }
+ struct hlist_node *tempnode = NULL;
+ nstack_rd_node *tempdata = NULL;
+ nstack_rd_key *key = (nstack_rd_key *) rdkey;
+ rd_data_item *pitem = (rd_data_item *) outitem;
- NSSOC_LOGDBG ("protocol type item not found", key->proto_type);
+ hlist_for_each_entry(tempdata, tempnode, &(hlist->headlist), rdnode)
+ {
+ if (tempdata->item.proto_data.value == key->proto)
+ {
+ NSTACK_RD_PROTO_ITEM_COPY(pitem, &(tempdata->item));
+ return NSTACK_RD_SUCCESS;
+ }
+ }
- return NSTACK_RD_FAIL;
+ /* Optimize log */
+ NSSOC_LOGDBG("proto:%u item not found", key->proto);
+
+ return NSTACK_RD_FAIL;
}
/*****************************************************************************
@@ -130,61 +134,92 @@ nstack_rd_proto_item_find (nstack_rd_list * hlist, void *rdkey, void *outitem)
* Calls :
* Called By :
*****************************************************************************/
-int
-nstack_rd_proto_item_age (nstack_rd_list * hlist)
+int nstack_rd_proto_item_age(nstack_rd_list * hlist)
{
- struct hlist_node *tempnode = NULL;
- nstack_rd_node *tempdata = NULL;
- nstack_rd_node *prevdata = NULL;
- struct hlist_node *prevnode = NULL;
- NSSOC_LOGINF ("nstack rd ip age begin");
- hlist_for_each_entry (tempdata, tempnode, &(hlist->headlist), rdnode)
- {
- /*if agetime equal 0, remove it */
- if (tempdata->item.agetime <= 0)
- {
+ struct hlist_node *tempnode = NULL;
+ nstack_rd_node *tempdata = NULL;
+ nstack_rd_node *prevdata = NULL;
+ struct hlist_node *prevnode = NULL;
+ NSSOC_LOGINF("nstack rd proto age begin");
+ hlist_for_each_entry(tempdata, tempnode, &(hlist->headlist), rdnode)
+ {
+ /*if agetime equal 0, remove it */
+ if (tempdata->item.agetime <= 0)
+ {
+ if (prevdata)
+ {
+ /* Optimize log */
+ NSSOC_LOGDBG("stackid=%d, proto:%u was aged",
+ tempdata->item.stack_id,
+ tempdata->item.proto_data.value);
+
+ hlist_del_init(prevnode);
+ free(prevdata); /*this function is necessary */
+ }
+ prevdata = tempdata;
+ prevnode = tempnode;
+ }
+ else
+ {
+ tempdata->item.agetime--;
+ }
+ }
+ if (prevdata)
+ {
+ if (tempdata)
+ {
+ /* Optimize log */
+ NSSOC_LOGDBG("stackid:%d, proto:%u was last aged",
+ tempdata->item.stack_id,
+ tempdata->item.proto_data.value);
+ }
+ hlist_del_init(prevnode);
+ free(prevdata); /*this function is necessary */
+ }
+ NSSOC_LOGINF("nstack rd proto age end");
+ return NSTACK_RD_SUCCESS;
+}
+
+void nstack_rd_proto_item_clean(nstack_rd_list * hlist)
+{
+ struct hlist_node *tempnode = NULL;
+ nstack_rd_node *tempdata = NULL;
+ nstack_rd_node *prevdata = NULL;
+ struct hlist_node *prevnode = NULL;
+ NSSOC_LOGINF("nstack rd proto item clean begin");
+ hlist_for_each_entry(tempdata, tempnode, &(hlist->headlist), rdnode)
+ {
if (prevdata)
- {
- NSSOC_LOGDBG ("stackid:%d, protocol type was aged",
- tempdata->item.stack_id, tempdata->item.proto_type);
+ {
+ NSSOC_LOGDBG("stackid=%d, proto:%u was cleaned",
+ tempdata->item.stack_id,
+ tempdata->item.proto_data.value);
+ hlist_del_init(prevnode);
+ free(prevdata); /*this function is necessary */
+ }
- hlist_del_init (prevnode);
- free (prevdata);
- }
prevdata = tempdata;
prevnode = tempnode;
- }
- else
- {
- tempdata->item.agetime--;
- }
- }
- if (prevdata)
+ }
+ if (prevdata)
{
- if (tempdata)
+ if (tempdata)
{
- NSSOC_LOGDBG ("stackid:%d, protocol type was aged",
- tempdata->item.stack_id, tempdata->item.proto_type);
+ NSSOC_LOGDBG("stackid=%d, proto:%u was last cleaned",
+ tempdata->item.stack_id,
+ tempdata->item.proto_data.value);
}
- hlist_del_init (prevnode);
- free (prevdata);
+ hlist_del_init(prevnode);
+ free(prevdata); /*this function is necessary */
}
- NSSOC_LOGINF ("nstack rd ip age end");
- return NSTACK_RD_SUCCESS;
+ NSSOC_LOGINF("nstack rd proto item clean end");
}
/*
*find stackid by spec ip(multicast ip)
- *input ip must netorder
+ *input ip must be network order
*/
-int
-nstack_rd_proto_spec (void *rdkey)
-{
- return -1;
-}
-
-int
-nstack_rd_proto_default (void *rdkey)
+int nstack_rd_proto_spec(void *rdkey)
{
- return -1;
+ return -1;
}
diff --git a/src/nSocket/nstack_rd/nstack_rd_proto.h b/src/nSocket/nstack_rd/nstack_rd_proto.h
index f3b0311..e8a573e 100644
--- a/src/nSocket/nstack_rd/nstack_rd_proto.h
+++ b/src/nSocket/nstack_rd/nstack_rd_proto.h
@@ -16,20 +16,23 @@
#ifndef __NSTACK_RD_PROTO_H
#define __NSTACK_RD_PROTO_H
-/* *INDENT-OFF* */
+
+#include "nstack_rd_priv.h"
+
#define NSTACK_RD_PROTO_ITEM_COPY(destitem, srcitem){ \
(destitem)->agetime = (srcitem)->agetime; \
(destitem)->stack_id = (srcitem)->stack_id; \
(destitem)->type = (srcitem)->type; \
- (destitem)->proto_type = (srcitem)->proto_type; \
+ (destitem)->proto_data.value = (srcitem)->proto_data.value; \
+ (destitem)->proto_data.attr = (srcitem)->proto_data.attr; \
}
-/* *INDENT-ON* */
-int nstack_rd_proto_cpy (void *destdata, void *srcdata);
-int nstack_rd_proto_item_insert (nstack_rd_list * hlist, void *rditem);
-int nstack_rd_proto_item_find (nstack_rd_list * hlist, void *rdkey,
- void *outitem);
-int nstack_rd_proto_item_age (nstack_rd_list * hlist);
-int nstack_rd_proto_spec (void *rdkey);
-int nstack_rd_proto_default (void *rdkey);
-#endif /* */
+int nstack_rd_proto_data_cpy(void *destdata, void *srcdata);
+int nstack_rd_proto_item_insert(nstack_rd_list * hlist, void *rditem);
+int nstack_rd_proto_item_find(nstack_rd_list * hlist, void *rdkey,
+ void *outitem);
+int nstack_rd_proto_item_age(nstack_rd_list * hlist);
+void nstack_rd_proto_item_clean(nstack_rd_list * hlist);
+int nstack_rd_proto_spec(void *rdkey);
+
+#endif
diff --git a/src/nSocket/nstack_rd/nstack_rd_type.c b/src/nSocket/nstack_rd/nstack_rd_type.c
new file mode 100644
index 0000000..c5f440e
--- /dev/null
+++ b/src/nSocket/nstack_rd/nstack_rd_type.c
@@ -0,0 +1,229 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#include <stdlib.h>
+#include <arpa/inet.h>
+#include "nstack_rd_data.h"
+#include "nstack_rd.h"
+#include "nstack_rd_priv.h"
+#include "nstack_rd_type.h"
+#include "nstack_log.h"
+#include "nstack_securec.h"
+
+/*copy rd data*/
+int nstack_rd_type_data_cpy(void *destdata, void *srcdata)
+{
+ rd_data_item *pitem = (rd_data_item *) destdata;
+ rd_route_data *pdata = (rd_route_data *) srcdata;
+
+ pitem->type = pdata->type;
+ pitem->type_data.value = pdata->type_data.value;
+ pitem->type_data.attr = pdata->type_data.attr;
+ pitem->type_data.reserved[0] = pdata->type_data.reserved[0];
+ pitem->type_data.reserved[1] = pdata->type_data.reserved[1];
+ pitem->type_data.reserved[2] = pdata->type_data.reserved[2];
+ pitem->type_data.reserved[3] = pdata->type_data.reserved[3];
+ return NSTACK_RD_SUCCESS;
+}
+
+/*
+ * Add an ip segment to the list and sort it in descending order of ip mask length
+ * If the list already exists in the same list of ip side, then stack_id update
+ *ip is network byte order
+ */
+/*vars are used in macro*/
+int nstack_rd_type_item_insert(nstack_rd_list * hlist, void *rditem)
+{
+ nstack_rd_node *pdatanode = NULL;
+ nstack_rd_node *tempdata = NULL;
+ struct hlist_node *tempnode = NULL;
+ rd_data_item *pitem = (rd_data_item *) rditem;
+
+ NSSOC_LOGDBG("stackid:%d, type value:%u type attr:%u was inserted",
+ pitem->stack_id, pitem->type_data.value,
+ pitem->type_data.attr);
+
+ pdatanode = (nstack_rd_node *) malloc(sizeof(nstack_rd_node)); /*this function is necessary */
+ if (!pdatanode)
+ {
+ NSSOC_LOGERR("nstack rd item malloc fail");
+ return NSTACK_RD_FAIL;
+ }
+ /* add return value check */
+ int retVal = memset_s(pdatanode, sizeof(nstack_rd_node), 0,
+ sizeof(nstack_rd_node));
+ if (EOK != retVal)
+ {
+ NSSOC_LOGERR("memset_s failed]retVal=%d", retVal);
+ free(pdatanode); /*this function is necessary */
+ return NSTACK_RD_FAIL;
+ }
+ INIT_HLIST_NODE(&pdatanode->rdnode);
+ NSTACK_RD_TYPE_ITEM_COPY(&(pdatanode->item), pitem);
+
+ if (hlist_empty(&(hlist->headlist)))
+ {
+ hlist_add_head(&(pdatanode->rdnode), &(hlist->headlist));
+
+ return NSTACK_RD_SUCCESS;
+
+ }
+
+ hlist_for_each_entry(tempdata, tempnode, &(hlist->headlist), rdnode)
+ {
+ if (tempdata->item.type_data.value == pitem->type_data.value)
+ {
+ NSSOC_LOGDBG
+ ("find duplicate node, type value:%u, old stack_id:%d, new stack_id:%d",
+ pitem->type_data.value, tempdata->item.stack_id,
+ pitem->stack_id);
+ tempdata->item.stack_id = pitem->stack_id;
+ tempdata->item.agetime = NSTACK_RD_AGETIME_MAX;
+ free(pdatanode); /*this function is necessary */
+ return NSTACK_RD_SUCCESS;
+ }
+ }
+ hlist_add_head(&(pdatanode->rdnode), &(hlist->headlist));
+
+ return NSTACK_RD_SUCCESS;
+
+}
+
+/*
+ *find stackid by ip
+ *input ip must be network order
+ */
+int nstack_rd_type_item_find(nstack_rd_list * hlist, void *rdkey,
+ void *outitem)
+{
+ struct hlist_node *tempnode = NULL;
+ nstack_rd_node *tempdata = NULL;
+ nstack_rd_key *key = (nstack_rd_key *) rdkey;
+ rd_data_item *pitem = (rd_data_item *) outitem;
+
+ hlist_for_each_entry(tempdata, tempnode, &(hlist->headlist), rdnode)
+ {
+ if (tempdata->item.type_data.value == key->socket_type)
+ {
+ NSTACK_RD_TYPE_ITEM_COPY(pitem, &(tempdata->item));
+ return NSTACK_RD_SUCCESS;
+ }
+ }
+
+ /* Optimize log */
+ NSSOC_LOGDBG("socket type:%u item not found", key->socket_type);
+
+ return NSTACK_RD_FAIL;
+}
+
+/*****************************************************************************
+* Prototype : nstack_rd_ip_item_age
+* Description : delete the ip item that have not been add again for one time
+* Input : nstack_rd_list *hlist
+* Output : None
+* Return Value : int
+* Calls :
+* Called By :
+*****************************************************************************/
+int nstack_rd_type_item_age(nstack_rd_list * hlist)
+{
+ struct hlist_node *tempnode = NULL;
+ nstack_rd_node *tempdata = NULL;
+ nstack_rd_node *prevdata = NULL;
+ struct hlist_node *prevnode = NULL;
+ NSSOC_LOGINF("nstack rd type age begin");
+ hlist_for_each_entry(tempdata, tempnode, &(hlist->headlist), rdnode)
+ {
+ /*if agetime equal 0, remove it */
+ if (tempdata->item.agetime <= 0)
+ {
+ if (prevdata)
+ {
+ /* Optimize log */
+ NSSOC_LOGDBG("stackid=%d, type:%u was aged",
+ tempdata->item.stack_id,
+ tempdata->item.type_data.value);
+
+ hlist_del_init(prevnode);
+ free(prevdata); /*this function is necessary */
+ }
+ prevdata = tempdata;
+ prevnode = tempnode;
+ }
+ else
+ {
+ tempdata->item.agetime--;
+ }
+ }
+ if (prevdata)
+ {
+ if (tempdata)
+ {
+ /* Optimize log */
+ NSSOC_LOGDBG("stackid:%d, type:%u was last aged",
+ tempdata->item.stack_id,
+ tempdata->item.type_data.value);
+ }
+ hlist_del_init(prevnode);
+ free(prevdata); /*this function is necessary */
+ }
+ NSSOC_LOGINF("nstack rd type age end");
+ return NSTACK_RD_SUCCESS;
+}
+
+void nstack_rd_type_item_clean(nstack_rd_list * hlist)
+{
+ struct hlist_node *tempnode = NULL;
+ nstack_rd_node *tempdata = NULL;
+ nstack_rd_node *prevdata = NULL;
+ struct hlist_node *prevnode = NULL;
+ NSSOC_LOGINF("nstack rd type item clean begin");
+ hlist_for_each_entry(tempdata, tempnode, &(hlist->headlist), rdnode)
+ {
+ if (prevdata)
+ {
+ NSSOC_LOGDBG("stackid=%d, type:%u was cleaned",
+ tempdata->item.stack_id,
+ tempdata->item.type_data.value);
+ hlist_del_init(prevnode);
+ free(prevdata); /*this function is necessary */
+ }
+
+ prevdata = tempdata;
+ prevnode = tempnode;
+ }
+ if (prevdata)
+ {
+ if (tempdata)
+ {
+ NSSOC_LOGDBG("stackid=%d, type:%u was last cleaned",
+ tempdata->item.stack_id,
+ tempdata->item.type_data.value);
+ }
+ hlist_del_init(prevnode);
+ free(prevdata); /*this function is necessary */
+ }
+ NSSOC_LOGINF("nstack rd type item clean end");
+}
+
+/*
+ *find stackid by spec ip(multicast ip)
+ *input ip must be network order
+ */
+int nstack_rd_type_spec(void *rdkey)
+{
+ return -1;
+}
diff --git a/src/nSocket/nstack_rd/nstack_rd_type.h b/src/nSocket/nstack_rd/nstack_rd_type.h
new file mode 100644
index 0000000..d50fa87
--- /dev/null
+++ b/src/nSocket/nstack_rd/nstack_rd_type.h
@@ -0,0 +1,42 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#ifndef __NSTACK_RD_TYPE_H
+#define __NSTACK_RD_TYPE_H
+
+#include "nstack_rd_priv.h"
+
+#define NSTACK_RD_TYPE_ITEM_COPY(destitem, srcitem){ \
+ (destitem)->agetime = (srcitem)->agetime; \
+ (destitem)->stack_id = (srcitem)->stack_id; \
+ (destitem)->type = (srcitem)->type; \
+ (destitem)->type_data.value = (srcitem)->type_data.value; \
+ (destitem)->type_data.attr = (srcitem)->type_data.attr; \
+ (destitem)->type_data.reserved[0] = (srcitem)->type_data.reserved[0]; \
+ (destitem)->type_data.reserved[1] = (srcitem)->type_data.reserved[1]; \
+ (destitem)->type_data.reserved[2] = (srcitem)->type_data.reserved[2]; \
+ (destitem)->type_data.reserved[3] = (srcitem)->type_data.reserved[3]; \
+}
+
+int nstack_rd_type_data_cpy(void *destdata, void *srcdata);
+int nstack_rd_type_item_insert(nstack_rd_list * hlist, void *rditem);
+int nstack_rd_type_item_find(nstack_rd_list * hlist, void *rdkey,
+ void *outitem);
+int nstack_rd_type_item_age(nstack_rd_list * hlist);
+void nstack_rd_type_item_clean(nstack_rd_list * hlist);
+int nstack_rd_type_spec(void *rdkey);
+
+#endif
diff --git a/stacks/lwip_stack/CMakeLists.txt b/stacks/lwip_stack/CMakeLists.txt
deleted file mode 100644
index 5a5ca94..0000000
--- a/stacks/lwip_stack/CMakeLists.txt
+++ /dev/null
@@ -1,111 +0,0 @@
-#########################################################################
-#
-# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-# 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.
-#########################################################################
-
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11)
-PROJECT(nStack)
-SET(CMAKE_C_COMPILER "gcc")
-SET(OS_RELEASE "" CACHE STRING "User-specified OS release.")
-SET(EXECUTABLE_PATH ${CMAKE_CURRENT_LIST_DIR}/release/bin)
-SET(LIB_PATH_STATIC ${PROJECT_BINARY_DIR})
-SET(LIB_PATH_SHARED ${CMAKE_CURRENT_LIST_DIR}/release/lib64)
-SET(NSTACKTOOLS_PATH ${CMAKE_CURRENT_LIST_DIR}/release/tools)
-SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIB_PATH_STATIC})
-SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_PATH})
-SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIB_PATH_SHARED})
-
-
-MESSAGE(STATUS "Top dir is: " ${CMAKE_CURRENT_LIST_DIR})
-MESSAGE(STATUS "Static library dir: " ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
-MESSAGE(STATUS "Executable binary dir: " ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
-MESSAGE(STATUS "Shared library dir: " ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
-
-option(WITH_SECUREC_LIB "Option description" OFF)
-option(WITH_HAL_LIB "Option description" OFF)
-
-if(WITH_SECUREC_LIB)
- add_definitions(-DSECUREC_LIB)
-endif()
-
-if(WITH_HAL_LIB)
- add_definitions(-DHAL_LIB)
-endif()
-
-SET(post_compile "${PROJECT_BINARY_DIR}/post_compile.sh")
-FILE(WRITE ${post_compile} "#!/bin/bash\n")
-FILE(APPEND ${post_compile}
-"
-
-ln -sfn ./run_nstack_main.sh ${CMAKE_CURRENT_LIST_DIR}/release/script/run_nstack.sh
-echo post compile process success.
-"
-)
-
-ADD_CUSTOM_TARGET(DPDK ALL COMMAND sh post_compile.sh)
-
-execute_process(
- COMMAND cp -rf ${CMAKE_CURRENT_LIST_DIR}/../../release/include ${CMAKE_CURRENT_LIST_DIR}/src/
- COMMAND cp ${CMAKE_CURRENT_LIST_DIR}/../../release/lib64/libnStackAPI.so ${CMAKE_CURRENT_LIST_DIR}/release/lib64/
- COMMAND cp ${CMAKE_CURRENT_LIST_DIR}/../../release/lib64/libdmm_api.so ${CMAKE_CURRENT_LIST_DIR}/release/lib64/
- COMMAND echo "stacklwip prepare ok"
-)
-execute_process(
- COMMAND sh ${CMAKE_CURRENT_LIST_DIR}/release/lwip_helper_files/download_lwip.sh
-)
-
-ADD_DEFINITIONS(-D_GNU_SOURCE -DNSTACK_GETVER_VERSION="18.10")
-
-SET(JSON_C_SRC ${CMAKE_CURRENT_LIST_DIR}/../../thirdparty/json/json-c-0.12.1)
-INCLUDE(ExternalProject)
-ExternalProject_Add(
- JSON
- SOURCE_DIR ${JSON_C_SRC}
- BUILD_IN_SOURCE 1
- CONFIGURE_COMMAND sh autogen.sh COMMAND sh ./configure --enable-static --with-pic
- BUILD_COMMAND make -j 8
- INSTALL_COMMAND cp -f .libs/libjson-c.a ${LIB_PATH_STATIC}/
-)
-
-SET(SECUREC_SRC ${CMAKE_CURRENT_LIST_DIR}/../SecureC/src)
-SET(SECUREC_SRC_H ${CMAKE_CURRENT_LIST_DIR}/../SecureC/include)
-
-if(WITH_SECUREC_LIB)
-INCLUDE(ExternalProject)
-ExternalProject_Add(
- SECUREC
- SOURCE_DIR ${SECUREC_SRC}
- BUILD_IN_SOURCE 1
- CONFIGURE_COMMAND ""
- BUILD_COMMAND COMMAND make -j 8
- INSTALL_COMMAND cp -f ${SECUREC_SRC}/../lib/libsecurec.so ${LIB_PATH_SHARED}/
-)
-endif()
-
-SET(GLOG_SRC ${CMAKE_CURRENT_LIST_DIR}/../../thirdparty/glog/glog-0.3.4)
-INCLUDE(ExternalProject)
-ExternalProject_Add(
- GLOG
- SOURCE_DIR ${GLOG_SRC}
- BUILD_IN_SOURCE 1
- CONFIGURE_COMMAND autoreconf COMMAND sh configure CFLAGS=-fPIC CXXFLAGS=-fPIC
- BUILD_COMMAND COMMAND make -j 8
- INSTALL_COMMAND cp -f ${GLOG_SRC}/.libs/libglog.a ${LIB_PATH_STATIC}/
-)
-
-ADD_SUBDIRECTORY(src)
-ADD_SUBDIRECTORY(lwip_src)
-ADD_SUBDIRECTORY(lwip_src/socket)
-ADD_SUBDIRECTORY(tools)
-#ADD_SUBDIRECTORY(thirdparty/rsrdma)
diff --git a/stacks/lwip_stack/configure/module_config.json b/stacks/lwip_stack/configure/module_config.json
deleted file mode 100644
index c9c872b..0000000
--- a/stacks/lwip_stack/configure/module_config.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "default_stack_name": "kernel",
- "module_list": [
- {
- "stack_name": "kernel",
- "libname": "./",
- "deploytype": "1",
- "stackid": "0",
- },
- {
- "stack_name": "lwip",
- "libname": "liblwip_dpdk.so",
- "deploytype": "3",
- "stackid": "1",
- },
- ]
-}
diff --git a/stacks/lwip_stack/configure/nStackConfig.json b/stacks/lwip_stack/configure/nStackConfig.json
deleted file mode 100644
index 3cc54c5..0000000
--- a/stacks/lwip_stack/configure/nStackConfig.json
+++ /dev/null
@@ -1,32 +0,0 @@
-{
-"cfg_seg_socket": [
-{
- "socket_num": 8192,
- "arp_stale_time": 300,
- "arp_bc_retrans_num": 5
-}
-],
-"cfg_seg_log": [
-{
- "run_log_size": 50,
- "run_log_count": 10,
- "mon_log_size": 10,
- "mon_log_count": 10
-}
-],
-"cfg_seg_thread_pri": [
-{
- "comment":"0:SCHED_OTHER, 1:SCHED_FIFO, 2:SCHED_RR",
- "sched_policy": 0,
- "thread_pri": 0
-}
-],
-"cfg_seg_path": [
-{
- "stackpool_log_path": "/var/log/nStack",
- "master_log_path": "/var/log/nStack",
- "nstack_log_path": "/var/log/nStack",
- "dpdk_log_path": "/var/log/nstack-dpdk"
-}
-]
-}
diff --git a/stacks/lwip_stack/configure/rd_config.json b/stacks/lwip_stack/configure/rd_config.json
deleted file mode 100644
index 3109bcd..0000000
--- a/stacks/lwip_stack/configure/rd_config.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "ip_route": [
- {
- "subnet": "192.168.1.1/24",
- "stack_name": "lwip",
- },
- {
- "subnet": "192.167.1.1/24",
- "stack_name": "kernel",
- },
- {
- "subnet": "192.166.1.1/24",
- "stack_name": "kernel",
- }
- ],
- "prot_route": [
- {
- "proto_type": "1",
- "stack_name": "lwip",
- },
- {
- "proto_type": "2",
- "stack_name": "kernel",
- }
- ],
-}
diff --git a/stacks/lwip_stack/doc/README.md b/stacks/lwip_stack/doc/README.md
deleted file mode 100644
index a76b18a..0000000
--- a/stacks/lwip_stack/doc/README.md
+++ /dev/null
@@ -1,125 +0,0 @@
-# 1. What is lwIP
-lwIP is a light-weight implementation of the TCP/IP protocol suite.
-lwIP is freely available (under a BSD-style license) in C source
-code format and can be downloaded from the development homepage.
-The focus of the lwIP TCP/IP implementation is to reduce the RAM
-usage while still having a full scale TCP.
-
-# 2. How to use lwIP
-
-## How to integrate lwIP into DMM
-The file CMakeList.txt defined the compiling process, including downloading
-the lwip 2.7.0 code and pushing the helper files into it, or modify
-lwip files.
-
-Currently lwip will not be build as separate lib, instead it'll be part
-of the excutable namely "nStackMain".
-lwip Stack will run in pipeline mode. Application will run in one process
-and lwip will run as "nStackMain" process. Below picture depicts
-a birds eye view of lwip in DMM pipeline mode.
-![Lwip in DMM framework](dmm_lwip.png)
-
-## Compile
-```sh
- #cd dmm/build && cmake ..
- #make
- #cd ../stacks/lwip_stack/build && cmake ..
- #make
-```
-
-## Test
-- Steps 1: update some environment variables
-```sh
- #export LD_LIBRARY_PATH=${dmm}/stacks/lwip_stack/release/lib64/
- #export LD_PRELOAD=${dmm}/release/lib64/libnStackAPI.so
- #export NSTACK_MOD_CFG_FILE=${dmm}/stacks/lwip_stack/configure/module_config.json
- #export NSTACK_MOD_CFG_RD=${dmm}/stacks/lwip_stack/configure/rd_config.json
- #export NSTACK_LOG_ON=DBG (optional enable debug)
-```
-- Steps 2: Modify rd_config.json(located at dmm/stacks/lwip_stack/configure/)
-```sh
- #vim rd_config.json
- Eg. set "subnet": "192.168.21.1/24"
-```
-Note:
- Means dmm chose lwip_stack if subnet matches 192.168.21.*
-
-- Steps 3: Run nStackMain(lwip stack))
-```sh
- #cp ${dmm}/stacks/lwip_stack/release/configure/ip_data.json ${dmm}/stacks/lwip_stack/release/bin/
- #cp ${dmm}/stacks/lwip_stack/release/configure/network_data_tonStack.json ${dmm}/stacks/lwip_stack/release/bin/
-
-```
-Modify ip_data.json
-```
-Change ref_nic => to interface name which you want to use
-Change ip_cidr => ip address you want to use.
-```
-Modify network network_data_tonStack.json
-```
-Change ref_nic => to interface name which you want to use
-Change subnet => Subnet (ip_cidr belongs to this subnet)
-Change gateway, range-start, range-end, dst, gw accordingly. This information will be used by DMM to configure network.
-```
-Run the process:
-```
- #cd ${dmm}/stacks/lwip_stack/release
- #./start_nstack.sh
-```
-
-If you want to run it with vhost-user, you can run the start_nstack.sh with parameters as follow.
-```
- #./start_nstack.sh --vdev virtio_user,mac=fa:16:3e:5f:b3:08,path=/tmp/unix/sock1.sock,queues=8,queue_size=1024 --no-pci
-```
-
-- Steps 4: Communication test between machine A(as server) with machine B
- (as client)
-
-##### Run in machine A
-```sh
- #./dmm/release/bin/vs_epoll -p 20000 -d 192.168.21.180 -a 10000 -s 192.168.21.181 -l 1000 -t 500000 -i 0 -f 1 -r 20000 -n 1 -w 10 -u 50000 -e 10 -x 1
-```
-Note:
- Means the current machine would be server, and it's
-destination address is 192.168.21.180 (client address),
-source address is 192.168.21.181(server address)
-
-##### Run in machine B
-```
- #./dmm/release/bin/vc_common -p 20000 -d 192.168.21.181 -a 10000 -s 192.168.21.180 -l 1000 -t 500000 -i 0 -f 1 -r 20000 -n 1 -w 10 -u 50000 -e 10 -x 1
-```
-Note:
- Means the current machine would be client, and it's
-destination address is 192.168.21.181 (server address),
-source address is 192.168.21.180(client address)
-
-# 3. Document description
-
-(dmm/stacks/lwip_stack/doc)
-
-## CMakeLists.txt
-Control file for Cmake compiling.
-
-## config folder
-##### module_config.json
-- module_config.json is for configuring dmm protocol stack module.
-
-##### rd_config.json
-- rd_config.json is to choose which module is better to go through, if subnet matches, It will go through lwip protocol stack when RD type is nstack-dpdk
-
-## lwip helper files.
-lwip helper files is implmentation and modification of some supportive functions to run lwip with dmm.
-
-## lwip_stack/src folder
-
-- Implmetation of nStackMain process which provides the framework to hold lwip stack.
-
-## lwip_stack/lwip_src
-- Downloaded opensource lwip 2.7.0. code.
-
-# 4. More Information
-https://wiki.fd.io/view/DMM
-https://savannah.nongnu.org/projects/lwip/
-http://lwip.wikia.com/wiki/LwIP_Wiki
-[DMM_DeveloperManual.md](../../doc/DMM_DeveloperManual.md)
-
diff --git a/stacks/lwip_stack/doc/dmm_lwip.png b/stacks/lwip_stack/doc/dmm_lwip.png
deleted file mode 100644
index 403eed3..0000000
--- a/stacks/lwip_stack/doc/dmm_lwip.png
+++ /dev/null
Binary files differ
diff --git a/stacks/lwip_stack/lwip_src/CMakeLists.txt b/stacks/lwip_stack/lwip_src/CMakeLists.txt
deleted file mode 100644
index 4425905..0000000
--- a/stacks/lwip_stack/lwip_src/CMakeLists.txt
+++ /dev/null
@@ -1,98 +0,0 @@
-#########################################################################
-#
-# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-# 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.
-#########################################################################
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g -fPIE -pie -fPIC -m64 -mssse3 -std=gnu89")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -Wshadow -Wfloat-equal -Wformat=2")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector -fstack-protector-all")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-z,relro,-z,now -Wl,--disable-new-dtags")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-z,noexecstack -mcmodel=medium")
-
-ADD_DEFINITIONS(-D_GNU_SOURCE)
-ADD_DEFINITIONS(-DDPDK_MODULE=0)
-if(WITH_HAL_LIB)
-SET(RTP_CONFIG ${CMAKE_CURRENT_LIST_DIR}/../src/include/rtp_config.h)
-else()
- SET(PAL_H_DIRECTORIES "/usr/include/dpdk/")
- SET(RTP_CONFIG ${PROJECT_SOURCE_DIR}/../../src/framework/common/base/include/common/common_sys_config.h)
- INCLUDE_DIRECTORIES(
- ${PAL_H_DIRECTORIES}
- )
-endif()
-SET(COMPLE_CONFIG ${CMAKE_CURRENT_LIST_DIR}/../src/include/compile_config.h)
-SET(MGR_COM ${CMAKE_CURRENT_LIST_DIR}/../src/include/mgr_com.h)
-ADD_DEFINITIONS(-include ${RTP_CONFIG})
-ADD_DEFINITIONS(-include ${COMPLE_CONFIG})
-ADD_DEFINITIONS(-include ${MGR_COM})
-if(WITH_SECUREC_LIB)
-LINK_LIBRARIES(pthread rt securec)
-else()
-LINK_LIBRARIES(pthread rt)
-endif()
-LINK_DIRECTORIES(${LIB_PATH_SHARED} ${LIB_PATH_STATIC})
-INCLUDE_DIRECTORIES(
- ${CMAKE_CURRENT_LIST_DIR}/../../../SecureC/include
- ${CMAKE_CURRENT_LIST_DIR}/../../../thirdparty/json/json-c-0.12.1/
- ${CMAKE_CURRENT_LIST_DIR}/../../../thirdparty/glog/glog-0.3.4/src/
- ${CMAKE_CURRENT_LIST_DIR}/../src/include/
- ${CMAKE_CURRENT_LIST_DIR}/lwip/include/
- ${CMAKE_CURRENT_LIST_DIR}/lwip/include/lwip/
-)
-
-FILE(GLOB API api/*.c)
-FILE(GLOB_RECURSE CORE core/*.c)
-FILE(GLOB INSTANCE instance/*.c)
-FILE(GLOB IPMODULE ip_module/*.c)
-FILE(GLOB NETIF netif/*.c)
-FILE(GLOB RECYCLE recycle/*.c)
-FILE(GLOB_RECURSE MAINTAIN maintain/*.c)
-FILE(GLOB COMMON common/*.c)
-FILE(GLOB_RECURSE LWIPSRC lwip/arch/*.c lwip/core/*.c lwip/netif/*.c)
-FOREACH(item ${LWIPSRC})
- IF(${item} MATCHES "slipif.c")
- LIST(REMOVE_ITEM LWIPSRC ${item})
- ENDIF(${item} MATCHES "slipif.c")
-ENDFOREACH(item)
-
-ADD_LIBRARY(stacklwip STATIC ${API} ${ARCH} ${CORE} ${NETIF} ${NETTOOL} ${IPMODULE} ${COMMON} ${INSTANCE} ${RECYCLE} ${MAINTAIN} ${LWIPSRC})
-ADD_DEPENDENCIES(stacklwip JSON GLOG DPDK)
-TARGET_INCLUDE_DIRECTORIES(
- stacklwip
- BEFORE
- PRIVATE
- common/
- socket/
- include/
- include/util/
- include/log/
- include/ipv4/
- include/ipv4/stackx
- include/stackx/
- include/netif/
- include/nstack/
- include/ip_module/
- lwip/include/lwip/
- lwip/include/lwip/arch/
- lwip/include/lwip/apps/
- lwip/include/lwip/priv/
- lwip/include/lwip/prot/
- lwip/include/netif/
- lwip/include/netif/ppp/
- lwip/include/netif/ppp/polarssl/
- ${CMAKE_CURRENT_LIST_DIR}/../src/sbr/
- ${CMAKE_CURRENT_LIST_DIR}/../src/include/
- ${CMAKE_CURRENT_LIST_DIR}/../src/alarm/
-)
-
diff --git a/stacks/lwip_stack/lwip_src/api/spl_api.c b/stacks/lwip_stack/lwip_src/api/spl_api.c
deleted file mode 100644
index 5c8af7d..0000000
--- a/stacks/lwip_stack/lwip_src/api/spl_api.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "nsfw_init.h"
-//#include "sockets.h"
-//#include <netinet/in.h>
-
-#include "stackx_spl_share.h"
-#include "stackx/spl_api.h"
-//#include "stackx/ip.h"
-#include "sharedmemory.h"
-#include "spl_hal.h"
-#include "hal_api.h"
-#include "alarm_api.h"
-#include "nsfw_mt_config.h"
-#include "nsfw_recycle_api.h"
-#include "nstack_dmm_adpt.h"
-
-/* main entry for stackx */
-int
-spl_main_init (void *args)
-{
- (void) args;
- if (init_by_main_thread () < 0)
- {
- return -1;
- }
-
- return 0;
-}
-
-/* *INDENT-OFF* */
-NSFW_MODULE_NAME ("STACKX_MAIN")
-NSFW_MODULE_PRIORITY (10)
-NSFW_MODULE_DEPENDS (NSFW_ALARM_MODULE)
-NSFW_MODULE_DEPENDS (NSTACK_DMM_MODULE)
-NSFW_MODULE_INIT (spl_main_init)
-/* *INDENT-ON* */
diff --git a/stacks/lwip_stack/lwip_src/api/spl_api_msg.c b/stacks/lwip_stack/lwip_src/api/spl_api_msg.c
deleted file mode 100644
index b7ea24b..0000000
--- a/stacks/lwip_stack/lwip_src/api/spl_api_msg.c
+++ /dev/null
@@ -1,3329 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "nsfw_msg.h"
-#include "spl_opt.h"
-#include "spl_ip_addr.h"
-//#include "stackx_socket.h"
-#include "cpuid.h"
-//#include "sockets.h"
-#include <netinet/in.h>
-#include <errno.h>
-#include <netinet/tcp.h>
-
-#include "stackx_prot_com.h"
-#include "spl_api.h"
-//#include "stackx/ip.h"
-#include "sc_dpdk.h"
-#include "spl_sbr.h"
-//#include "maintain/spl_dfx.h"
-#include "stackx_tx_box.h"
-#include "spl_instance.h"
-#include "spl_sockets.h"
-
-#include "nstack_dmm_adpt.h"
-
-#include "tcp.h"
-#include "udp.h"
-#include "pbuf.h"
-#include "tcp_priv.h"
-#include "init.h"
-#include "timeouts.h"
-
-#include "stackx_pbuf_comm.h"
-#include "spl_netbuf.h"
-#include "spl_hal.h"
-#include "sys_arch.h"
-#include "tcpip.h"
-#include "debug.h"
-#ifdef HAL_LIB
-#else
-#include "rte_memcpy.h"
-#endif
-
-extern struct tcp_pcb *tcp_bound_pcbs;
-extern union tcp_listen_pcbs_t tcp_listen_pcbs;
-extern struct tcp_pcb *tcp_active_pcbs; /* List of all TCP PCBs that are in a
- state in which they accept or send
- data. */
-extern struct tcp_pcb *tcp_tw_pcbs; /* List of all TCP PCBs in TIME-WAIT. */
-extern struct tcp_pcb **const tcp_pcb_lists[NUM_TCP_PCB_LISTS];
-extern stackx_instance *p_def_stack_instance;
-extern u16_t g_offSetArry[SPL_PBUF_MAX_LAYER];
-
-#define TCP_FN_NULL 0
-#define TCP_FN_DEFAULT 1
-#define TCP_FN_STACKX 2
-#define TCP_FN_MAX 3
-
-struct callback_fn tcp_fn[TCP_FN_MAX] = {
- {NULL, NULL, NULL, NULL, NULL, NULL, NULL},
- {NULL, spl_tcp_recv_null, NULL, NULL, NULL, NULL},
- {spl_sent_tcp, spl_recv_tcp, spl_do_connected, spl_poll_tcp, spl_err_tcp,
- NULL, spl_accept_function},
-};
-
-// extern int nstack_get_nstack_fd_snapshot_from_proto_fd(int proto_fd);
-extern void tcp_drop_conn (spl_netconn_t * conn);
-extern void unlink_pcb (struct common_pcb *cpcb);
-extern struct queue *get_msgbox (int tos);
-
-#define SPL_SET_NONBLOCKING_CONNECT(conn, val) \
-do { \
- if (val) \
- { \
- (conn)->flags |= SPL_NETCONN_FLAG_IN_NONBLOCKING_CONNECT; \
- } \
- else \
- { \
- (conn)->flags &= ~SPL_NETCONN_FLAG_IN_NONBLOCKING_CONNECT; \
- } \
- } while (0)
-
-#define SPL_IN_NONBLOCKING_CONNECT(conn) (((conn)->flags & SPL_NETCONN_FLAG_IN_NONBLOCKING_CONNECT) != 0)
-
-extern int tcpip_thread_control;
-
-void
-spl_event_callback (struct spl_netconn *conn, enum spl_netconn_evt evt,
- int postFlag)
-{
- NSPOL_LOGDBG (SOCK_INFO, "Get event]conn=%p,evt=%d,postFlag=%d", conn, evt,
- postFlag);
- /* Get socket */
- if (!conn)
- {
- NSPOL_LOGDBG (SOCK_INFO, "conn=NULL");
- return;
- }
-
- switch (evt)
- {
- case SPL_NETCONN_EVT_RCVPLUS:
- __sync_fetch_and_add (&conn->rcvevent, 1);
- if ((conn->epoll_flag) && (postFlag))
- {
- nstack_event_callback (ADDR_SHTOL (conn->epInfo), EPOLLIN);
- }
- break;
- case SPL_NETCONN_EVT_RCVMINUS: // This will never be reached
- __sync_fetch_and_sub (&conn->rcvevent, 1);
- if ((conn->epoll_flag) && (postFlag))
- {
- nstack_event_callback (ADDR_SHTOL (conn->epInfo), EPOLLIN);
- }
- break;
- case SPL_NETCONN_EVT_SENDPLUS:
- conn->sendevent = 1;
- if ((conn->epoll_flag) && (postFlag))
- {
- nstack_event_callback (ADDR_SHTOL (conn->epInfo), EPOLLOUT);
- }
- break;
- case SPL_NETCONN_EVT_SENDMINUS:
- conn->sendevent = 0;
-
- if ((conn->epoll_flag) && (postFlag))
- {
- nstack_event_callback (ADDR_SHTOL (conn->epInfo), EPOLLOUT);
- }
- break;
- case SPL_NETCONN_EVT_ERROR:
- conn->errevent |= EPOLLERR;
- if ((conn->epoll_flag) && (postFlag))
- {
- nstack_event_callback (ADDR_SHTOL (conn->epInfo), conn->errevent);
- conn->errevent = 0;
- }
- break;
-#if 1
- case SPL_NETCONN_EVT_ACCEPT:
- __sync_fetch_and_add (&conn->rcvevent, 1);
- if ((conn->epoll_flag) && (postFlag))
- {
- nstack_event_callback (ADDR_SHTOL (conn->epInfo), EPOLLIN);
- }
- break;
-
- case SPL_NETCONN_EVT_HUP:
- conn->errevent |= EPOLLHUP;
- if ((conn->epoll_flag) && (postFlag))
- {
- nstack_event_callback (ADDR_SHTOL (conn->epInfo), conn->errevent);
- conn->errevent = 0;
- }
- break;
- case SPL_NETCONN_EVT_RDHUP:
- conn->errevent |= EPOLLRDHUP;
- if ((conn->epoll_flag) && (postFlag))
- {
- nstack_event_callback (ADDR_SHTOL (conn->epInfo), conn->errevent);
- conn->errevent = 0;
- }
- break;
-#endif
-
- default:
- NSTCP_LOGERR ("unknown event]conn=%p,event=%d", conn, evt);
- return;
- }
- return;
-}
-
-u8
-get_shut_op (data_com_msg * m)
-{
- if (m && m->param.module_type == MSG_MODULE_SBR
- && m->param.major_type == SPL_TCPIP_NEW_MSG_API)
- {
- if (m->param.minor_type == SPL_API_DO_CLOSE)
- return ((msg_close *) (m->buffer))->shut;
-
- if (m->param.minor_type == SPL_API_DO_DELCON)
- return ((msg_delete_netconn *) (m->buffer))->shut;
- }
-
- return SPL_NETCONN_SHUT_RDWR;
-}
-
-/*
- Never using head/tail to judge whether need to do enque/deque, just do enque&deque, the return val will tell you ring is full/empty or not
- rtp_perf_ring never provid ring_full/ring_empty function;
- one more thing the rtp_ring_enque/deque result must be checked.
-*/
-err_t
-accept_enqueue (spl_netconn_t * conn, void *p)
-{
- if (conn == NULL)
- {
- NSPOL_LOGERR ("accept_enqueue: invalid input]conn=%p", conn);
- return ERR_VAL;
- }
-
- NSPOL_LOGDBG (NEW_RING_DEBUG, "accept_enqueue]conn=%p,p=%p", conn, p);
- mring_handle ring = conn->recv_ring;
- if (NULL == ring)
- {
- NSPOL_LOGERR ("conn=%p accept new conn=%p enqueue ring addr is null",
- conn, p);
- return ERR_VAL;
- }
-
- err_t retVal = ERR_MEM;
- int enQSucCnt = 0;
- int nTryCnt = 0;
- do
- {
- enQSucCnt = nsfw_mem_ring_enqueue (ring, (void *) p);
- if (1 == enQSucCnt)
- {
- retVal = ERR_OK;
- break;
- }
- else if (0 == enQSucCnt)
- {
- sys_sleep_ns (0, 3000);
- nTryCnt++;
- }
- else
- {
- retVal = ERR_VAL;
- break;
- }
- }
- while (nTryCnt < MAX_TRY_GET_MEMORY_TIMES);
-
- return retVal;
-}
-
-err_t
-accept_dequeue (spl_netconn_t * lconn, void **new_buf,
- u32_t timeout /*miliseconds */ )
-{
- struct timespec starttm;
- struct timespec endtm;
- long timediff;
- long timediff_sec;
- u32_t timeout_sec = timeout / 1000;
-
-#define FAST_SLEEP_TIME 10000
-#define SLOW_SLEEP_TIME 500000
-#define FAST_RETRY_COUNT 100
- unsigned int retry_count = 0;
-
- if (NULL == lconn || NULL == new_buf)
- {
- NSPOL_LOGERR ("accept_dequeue invalid input]conn=%p,newbuf=%p", lconn,
- new_buf);
- return ERR_ARG;
- }
-
- if (timeout != 0)
- {
- /* Handle system time change side-effects */
- if (unlikely (0 != clock_gettime (CLOCK_MONOTONIC, &starttm)))
- {
- //NSPOL_LOGERR("Failed to get time]errno=%d", errno);
- }
- }
-
- mring_handle ring = lconn->recv_ring;
- if (ring == NULL)
- {
- NSPOL_LOGERR ("Get rtp_perf_ring failed]conn=%p", lconn);
- return ERR_ARG;
- }
-
- int nDequeRt;
- int retVal;
- while (1)
- {
- if ((lconn->shut_status) && (-1 != (int) timeout))
- {
- retVal = ERR_VAL;
- break;
- }
-
- nDequeRt = nsfw_mem_ring_dequeue (ring, new_buf);
- if (nDequeRt == 1)
- {
- retVal = ERR_OK;
- break;
- }
- else if (nDequeRt == 0)
- {
- if ((int) timeout == -1)
- {
- retVal = ERR_WOULDBLOCK;
- break;
- }
-
- if (timeout != 0)
- {
- /* Handle system time change side-effects */
- if (unlikely (0 != clock_gettime (CLOCK_MONOTONIC, &endtm)))
- {
- //NSPOL_LOGERR("Failed to get time, errno = %d", errno);
- }
- timediff_sec = endtm.tv_sec - starttm.tv_sec;
- if (timediff_sec >= timeout_sec)
- {
- timediff = endtm.tv_nsec > starttm.tv_nsec ?
- (timediff_sec * 1000) + (endtm.tv_nsec -
- starttm.tv_nsec) /
- USEC_TO_SEC : (timediff_sec * 1000) -
- ((starttm.tv_nsec - endtm.tv_nsec) / USEC_TO_SEC);
-
- /*NOTE: if user configured the timeout as say 0.5 ms, then timediff value
- will be negetive if still 0.5 ms is not elapsed. this is intended and we should
- not typecast to any unsigned type during this below if check */
- if (timediff > (long) timeout)
- {
- retVal = ERR_TIMEOUT;
- break;
- }
- }
- }
-
- /* reduce CPU usage in blocking mode */
- if (retry_count < FAST_RETRY_COUNT)
- {
- sys_sleep_ns (0, FAST_SLEEP_TIME);
- retry_count++;
- }
- else
- {
- sys_sleep_ns (0, SLOW_SLEEP_TIME);
- }
-
- continue;
- }
- else
- {
- retVal = ERR_VAL;
- break;
- }
- }
-
- return retVal;
-}
-
-err_t
-sp_enqueue (struct common_pcb * cpcb, void *p)
-{
- mring_handle ring = NULL;
- spl_netconn_t *conn = NULL;
- int enQueRet = 0;
-
- if (cpcb == NULL || (NULL == (conn = cpcb->conn)))
- {
- NSTCP_LOGERR ("conn NULL!");
- return ERR_VAL;
- }
-
- NSPOL_LOGDBG (NEW_RING_DEBUG, "]conn=%p,buf=%p", cpcb->conn, p);
- ring = conn->recv_ring;
- if (NULL == ring)
- {
- NSPOL_LOGERR ("Get rtp_perf_ring failed]conn=%p.", conn);
- return ERR_CLSD;
- }
-
- /* clear LOOP_SEND_FLAG to indicate that this pbuf has been given to upper layer */
- struct spl_pbuf *tmpbuf = p;
- while (tmpbuf)
- {
- tmpbuf->res_chk.u8Reserve &= ~LOOP_SEND_FLAG;
- tmpbuf = tmpbuf->next;
- }
-
- enQueRet = nsfw_mem_ring_enqueue (ring, p);
- if (1 != enQueRet)
- {
- NS_LOG_CTRL (LOG_CTRL_RECV_QUEUE_FULL, LOGTCP, "NSTCP", NSLOG_WAR,
- "ringvbox_enqueue buf is full]conn=%p.", conn);
-
- return ERR_MEM;
- }
-
- return ERR_OK;
-}
-
-/**
- * Receive callback function for UDP netconns.
- * Posts the packet to conn->recvmbox or deletes it on memory error.
- *
- * @see udp.h (struct udp_pcb.recv) for parameters
- */
-
-static void
-spl_recv_udp (void *arg, struct udp_pcb *pcb, struct pbuf *p,
- const ip_addr_t * ipaddr, u16_t port)
-{
- struct spl_netbuf *buf;
- spl_netconn_t *conn = (spl_netconn_t *) arg;
- struct spl_pbuf *spl_pb = NULL; //??
-
- if (NULL == pcb)
- {
- NSPOL_LOGERR ("recv_udp must have a pcb argument");
- pbuf_free (p);
- return;
- }
-
- if (NULL == arg)
- {
- NSPOL_LOGERR ("recv_udp must have an argument");
- pbuf_free (p);
- return;
- }
- /* //@TODO: malloc and Copy splbuf */
- struct common_pcb *cpcb = (struct common_pcb *) (conn->comm_pcb_data);
-
- u16_t proc_id = spl_get_lcore_id ();
-
- spl_pb = spl_pbuf_alloc_hugepage (SPL_PBUF_TRANSPORT,
- p->tot_len +
- g_offSetArry[SPL_PBUF_TRANSPORT],
- SPL_PBUF_HUGE, proc_id, conn);
-
- if (!spl_pb)
- {
- NSPOL_LOGINF (TCP_DEBUG, "spl_pbuf_alloc_hugepage Failed!!!");
- return;
- }
-
- pbuf_to_splpbuf_copy (spl_pb, p);
- pbuf_free (p);
-
- buf = (struct spl_netbuf *) ((char *) spl_pb + sizeof (struct spl_pbuf));
- buf->p = spl_pb;
- spl_ip_addr_set (&buf->addr, ipaddr);
- buf->port = port;
-
- err_t ret = sp_enqueue (cpcb, (void *) spl_pb);
- if (ret != ERR_OK)
- {
- NSPOL_LOGDBG (UDP_DEBUG, "mbox post failed");
- spl_netbuf_delete (buf);
- return;
- }
- else
- {
- /* Register event with callback */
- NSPOL_LOGDBG (UDP_DEBUG | LWIP_DBG_TRACE,
- "recv a udp packet: and api_event");
- SPL_API_EVENT (cpcb->conn, SPL_NETCONN_EVT_RCVPLUS, 1);
- }
-}
-
-/**
- * Receive callback function for TCP netconns.
- * Posts the packet to conn->recvmbox, but doesn't delete it on errors.
- *
- * @see tcp.h (struct tcp_pcb.recv) for parameters and return value
- */
-
-err_t
-spl_recv_tcp (void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
-{
- struct spl_pbuf *spl_pb = NULL;
- u32_t len;
-
- if (NULL == pcb)
- {
- NSTCP_LOGERR ("recv_tcp must have a pcb argument");
- pbuf_free (p);
- return ERR_ARG;
- }
-
- if (NULL == arg)
- {
- NSTCP_LOGERR ("must have an argument]pcb=%p", pcb);
- pbuf_free (p);
- return ERR_ARG;
- }
-
- spl_netconn_t *conn = (spl_netconn_t *) arg;
-
- /* Unlike for UDP or RAW pcbs, don't check for available space
- using recv_avail since that could break the connection
- (data is already ACKed) */
- /* don't overwrite fatal errors! */
- (void) err;
- if (p == NULL)
- {
- return ERR_OK;
- }
-
- len = p->tot_len;
-
- u16_t proc_id = spl_get_lcore_id ();
-
- spl_pb = spl_pbuf_alloc_hugepage (SPL_PBUF_TRANSPORT,
- p->tot_len +
- g_offSetArry[SPL_PBUF_TRANSPORT],
- SPL_PBUF_HUGE, proc_id, conn);
-
- if (!spl_pb)
- {
- NSPOL_LOGINF (TCP_DEBUG, "spl_pbuf_alloc_hugepage Failed!!!");
- return ERR_MEM;
- }
-
- pbuf_to_splpbuf_copy (spl_pb, p);
- pbuf_free (p);
-
- if (sp_enqueue ((struct common_pcb *) conn->comm_pcb_data, (void *) spl_pb)
- != ERR_OK)
- {
- NSPOL_LOGDBG (TCP_DEBUG, "sp_enqueue!=ERR_OK]conn=%p", conn);
- spl_pbuf_free (spl_pb);
- return ERR_MEM;
- }
-
- SPL_API_EVENT (conn, SPL_NETCONN_EVT_RCVPLUS, 1);
- conn->recv_avail_prod += len;
-
- return ERR_OK;
-}
-
-/**
- * Poll callback function for TCP netconns.
- * Wakes up an application thread that waits for a connection to close
- * or data to be sent. The application thread then takes the
- * appropriate action to go on.
- *
- * Signals the conn->sem.
- * netconn_close waits for conn->sem if closing failed.
- *
- * @see tcp.h (struct tcp_pcb.poll) for parameters and return value
- */
-err_t
-spl_poll_tcp (void *arg, struct tcp_pcb * pcb)
-{
- spl_netconn_t *conn = (spl_netconn_t *) arg;
- struct tcp_pcb *tpcb = NULL;
-
- if (NULL == conn)
- {
- NSPOL_LOGERR ("conn==NULL");
- return ERR_VAL;
- }
-
- if (conn->state == SPL_NETCONN_WRITE)
- {
- (void) do_writemore (conn);
-
- /* do_close_internal, can release th PCB
- and connection CB. so checking NETCONN_FLAG_CHECK_WRITESPACE should not be
- done after do_close_internal. anyway this flag is used with data send.(do_writemore) */
- /* Did a nonblocking write fail before? Then check available write-space. */
- if (conn->flags & SPL_NETCONN_FLAG_CHECK_WRITESPACE)
- {
- tpcb = (struct tcp_pcb *) conn->private_data;
- /* If the queued byte- or pbuf-count drops below the configured low-water limit,
- let select mark this pcb as writable again. */
- if ((tpcb != NULL) && (tcp_sndbuf (tpcb) > TCP_SNDLOWAT) &&
- (tcp_sndqueuelen (tpcb) < TCP_SNDQUEUELOWAT))
- {
- conn->flags &= ~SPL_NETCONN_FLAG_CHECK_WRITESPACE;
- SPL_API_EVENT (conn, SPL_NETCONN_EVT_SENDPLUS, 1);
- }
- }
- }
- else if (conn->state == SPL_NETCONN_CLOSE)
- {
- (void) do_close_internal ((struct common_pcb *) conn->comm_pcb_data, 0);
- }
-
- /* @todo: implement connect timeout here? */
- return ERR_OK;
-}
-
-/**
- * Default receive callback that is called if the user didn't register
- * a recv callback for the pcb.
- */
-err_t
-spl_tcp_recv_null (void *arg, struct tcp_pcb * pcb, struct pbuf * p,
- err_t err)
-{
- LWIP_UNUSED_ARG (arg);
-
- if (p != NULL)
- {
- tcp_recved (pcb, p->tot_len);
- pbuf_free (p);
- }
- else if (err == ERR_OK)
- {
- return tcp_close (pcb);
- }
-
- return ERR_OK;
-}
-
-/**
- * Sent callback function for TCP netconns.
- * Signals the conn->sem and calls API_EVENT.
- * netconn_write waits for conn->sem if send buffer is low.
- *
- * @see tcp.h (struct tcp_pcb.sent) for parameters and return value
- */
-err_t
-spl_sent_tcp (void *arg, struct tcp_pcb * pcb, u16_t len)
-{
- spl_netconn_t *conn = (spl_netconn_t *) arg;
-
- if (NULL == conn)
- {
- NSPOL_LOGERR ("conn==NULL");
- return ERR_VAL;
- }
-
- if (conn->state == SPL_NETCONN_WRITE)
- {
- (void) do_writemore (conn);
- }
- else if (conn->state == SPL_NETCONN_CLOSE)
- {
- (void) do_close_internal ((struct common_pcb *) conn->comm_pcb_data, 0);
- }
-
- /* conn is already checked for NULL above with ASSERT */
- /* If the queued byte- or pbuf-count drops below the configured low-water limit,
- let select mark this pcb as writable again. */
- if (pcb->snd_buf > TCP_SNDLOWAT)
- {
- conn->flags &= ~SPL_NETCONN_FLAG_CHECK_WRITESPACE;
- if (((struct common_pcb *) conn->comm_pcb_data)->model == SOCKET_STACKX)
- SPL_API_EVENT (conn, SPL_NETCONN_EVT_SENDPLUS, 1);
- }
-
- return ERR_OK;
-}
-
-/**
- * Error callback function for TCP netconns.
- * Signals conn->sem, posts to all conn mboxes and calls API_EVENT.
- * The application thread has then to decide what to do.
- *
- * @see tcp.h (struct tcp_pcb.err) for parameters
- */
-void
-spl_err_tcp (void *arg, err_t err)
-{
- spl_netconn_t *conn;
- enum spl_netconn_state old_state;
- data_com_msg *forFree = NULL;
-
- struct common_pcb *cpcb;
-
- NSTCP_LOGINF ("Enter err_tcp.");
-
- conn = (spl_netconn_t *) arg;
- cpcb = (struct common_pcb *) (conn->comm_pcb_data);
-
- old_state = conn->state;
- conn->state = SPL_NETCONN_NONE;
-
- /* Call unlink pcb no matter what */
- unlink_pcb (cpcb);
- if (old_state == SPL_NETCONN_CLOSE)
- {
- /* RST during close: let close return success & dealloc the netconn */
- err = ERR_OK;
- SPL_NETCONN_SET_SAFE_ERR (conn, ERR_OK);
- }
- else
- {
- SPL_NETCONN_SET_SAFE_ERR (conn, err);
- }
-
- NSTCP_LOGWAR ("inform HUP and ERROR event.");
- SPL_API_EVENT (conn, SPL_NETCONN_EVT_RCVPLUS, 0);
- SPL_API_EVENT (conn, SPL_NETCONN_EVT_SENDPLUS, 0);
- SPL_API_EVENT (conn, SPL_NETCONN_EVT_ERROR, 0);
- SPL_API_EVENT (conn, SPL_NETCONN_EVT_HUP, 1);
-
- if ((old_state == SPL_NETCONN_WRITE) || (old_state == SPL_NETCONN_CLOSE)
- || (old_state == SPL_NETCONN_CONNECT))
- {
- int was_nonblocking_connect = spl_netconn_is_nonblocking (conn);
- SPL_SET_NONBLOCKING_CONNECT (conn, 0);
-
- if (!was_nonblocking_connect)
- {
- /* set error return code */
- if (NULL == cpcb->current_msg)
- {
- NSPOL_LOGERR ("conn->current_msg==NULL");
- return;
- }
-
- /* current msg could be connect msg or write_buf_msg */
- SET_MSG_ERR (cpcb->current_msg, err);
- /* signal app to exit */
- if (old_state == SPL_NETCONN_CONNECT
- && !spl_netconn_is_nonblocking (conn))
- {
- SYNC_MSG_ACK (cpcb->current_msg);
- }
-
- /* no matter it's connect msg or write msg, we will no process it any more */
- cpcb->current_msg = NULL;
-
- /* but, if msg is write_buf_msg, then we should release the pbuf in msg */
- if (cpcb->msg_head != NULL)
- {
- /* current_msg should be write_buf_msg */
- msg_write_buf *tmp_msg = cpcb->msg_head;
- while (tmp_msg != NULL)
- {
-
- forFree = MSG_ENTRY (tmp_msg, data_com_msg, buffer);
- spl_pbuf_free (tmp_msg->p);
- tmp_msg = tmp_msg->next;
-
- // free msg
- ASYNC_MSG_FREE (forFree);
- }
- cpcb->current_msg = NULL;
- cpcb->msg_head = cpcb->msg_tail = NULL;
- }
- }
- }
- else
- {
-
- }
-}
-
-/**
- * Setup a tcp_pcb with the correct callback function pointers
- * and their arguments.
- *
- * @param conn the TCP netconn to setup
- */
-NSTACK_STATIC void
-setup_tcp (struct tcp_pcb *pcb, spl_netconn_t * conn)
-{
- struct common_pcb *cpcb = (struct common_pcb *) conn->comm_pcb_data;
-
- /* callback have the same value as cpcb->conn */
- cpcb->conn = conn;
- tcp_arg (pcb, (void *) conn);
- tcp_recv (pcb, tcp_fn[TCP_FN_STACKX].recv_fn);
- tcp_sent (pcb, tcp_fn[TCP_FN_STACKX].sent_fn);
- tcp_poll (pcb, tcp_fn[TCP_FN_STACKX].poll_fn, 4);
- tcp_err (pcb, tcp_fn[TCP_FN_STACKX].err_fn);
-
-}
-
-/**
- * Accept callback function for TCP netconns.
- * Allocates a new netconn and posts that to conn->acceptmbox.
- *
- * @see tcp.h (struct tcp_pcb_listen.accept) for parameters and return value
- */
-err_t
-spl_accept_function (void *arg, struct tcp_pcb *newpcb, err_t err)
-{
- spl_netconn_t *newconn;
- spl_netconn_t *lconn = (spl_netconn_t *) arg; /* listen conneciton */
- struct common_pcb *cpcb = NULL;
-
- NSPOL_LOGDBG (API_MSG_DEBUG, "]state=%s",
- tcp_debug_state_str (newpcb->state));
-
- if (lconn == NULL)
- {
- NSPOL_LOGERR ("accept_function: conn is NULL");
- return ERR_VAL;
- }
-
- /* We have to set the callback here even though
- * the new socket is unknown. conn->socket is marked as -1. */
- newconn = ss_malloc_conn (lconn->conn_pool, SPL_NETCONN_TCP);
- if (newconn == NULL)
- {
- NSPOL_LOGERR ("conn alloc failed");
- return ERR_MEM;
- }
-
- cpcb = alloc_common_pcb (SPL_NETCONN_TCP);
- if (cpcb == NULL)
- {
- return ERR_MEM;
- }
-
- /* used by application to recycle conn */
- newconn->recycle.accept_from = lconn;
- newconn->conn_pool = lconn->conn_pool;
-
- newconn->recv_obj = (i64) & newconn->private_data;
- newconn->private_data = (i64) newpcb;
- newconn->comm_pcb_data = (i64) cpcb;
-
- NSFW_LOGINF ("alloc accept conn]conn=%p,pcb=%p,lconn=%p", newconn, newpcb,
- lconn);
- newconn->shut_status = 0xFFFF;
- newconn->last_err = ERR_OK;
- newconn->CanNotReceive = 0;
- newconn->flags = 0;
-
- newconn->state = SPL_NETCONN_NONE;
- newconn->mss = newpcb->mss;
- newconn->remote_ip.addr = newpcb->remote_ip.addr;
- newconn->remote_port = newpcb->remote_port;
- ss_set_local_ip (newconn, newpcb->local_ip.addr);
- ss_set_local_port (newconn, newpcb->local_port);
-
- setup_tcp (newpcb, newconn);
- newpcb->state = ESTABLISHED;
- update_tcp_state (newconn, ESTABLISHED);
-
- /*Initialize flow control variables */
- newconn->tcp_sndbuf = CONN_TCP_MEM_DEF_LINE;
- newconn->tcp_wmem_alloc_cnt = 0;
- newconn->tcp_wmem_sbr_free_cnt = 0;
- newconn->tcp_wmem_spl_free_cnt = 0;
- newconn->snd_buf = 0;
-
- newconn->bind_thread_index = lconn->bind_thread_index;
- ss_set_msg_box (newconn,
- ss_get_instance_msg_box (newconn->bind_thread_index, 0));
-
- /* no protection: when creating the pcb, the netconn is not yet known
- to the application thread */
- newconn->last_err = err;
-
- NSPOL_LOGDBG (TCP_DEBUG,
- "trypost]newconn=%p, tcp=%p state=%d conn state=%d ", newconn,
- newpcb, newpcb->state, newconn->state);
- if (accept_enqueue (lconn, (void *) newconn) != ERR_OK)
- {
- /* remove all references to this netconn from the pcb */
- NSPOL_LOGERR ("sp_enqueue!=ERR_OK]ring = %p", newconn->recv_ring);
-
- tcp_arg (newpcb, NULL);
- tcp_recv (newpcb, tcp_fn[TCP_FN_NULL].recv_fn);
- tcp_sent (newpcb, tcp_fn[TCP_FN_NULL].sent_fn);
- tcp_poll (newpcb, tcp_fn[TCP_FN_NULL].poll_fn, 0);
- tcp_err (newpcb, tcp_fn[TCP_FN_NULL].err_fn);
- /* drop conn */
- tcp_drop_conn (newconn);
- return ERR_MEM;
- }
-
- SPL_API_EVENT (lconn, SPL_NETCONN_EVT_ACCEPT, 1);
- /* tcp_accepted_with_return_value(newpcb); */
-
- return ERR_OK;
-}
-
-int
-common_pcb_init (struct common_pcb *cpcb)
-{
- // u32 threadnum = p_lwip_instance->rss_queue_id + 1;//0 for app
-
- cpcb->hostpid = get_sys_pid ();
-
- cpcb->socket = 0;
- /* run and close repeatly nstackmain coredum */
- cpcb->close_progress = 0;
- cpcb->model = SOCKET_STACKX;
- cpcb->current_msg = NULL;
- cpcb->msg_head = cpcb->msg_tail = NULL;
- cpcb->write_offset = 0;
-
- cpcb->recv_timeout = cpcb->send_timeout = 0;
-
- cpcb->sk_rcvlowat = 1;
-
- cpcb->l4_tick = 0;
- cpcb->dataSentFlag = 0;
- cpcb->recv_ring_not_empty = 0;
-
- return 0;
-}
-
-int
-common_pcb_reset (struct common_pcb *cpcb)
-{
- cpcb->conn = NULL;
- cpcb->hostpid = 0;
-
- cpcb->socket = 0;
- /* run and close repeatly nstackmain coredum */
- cpcb->close_progress = 0;
- cpcb->model = 0;
- cpcb->current_msg = NULL;
- cpcb->msg_head = cpcb->msg_tail = NULL;
- cpcb->write_offset = 0;
-
- cpcb->recv_timeout = cpcb->send_timeout = 0;
-
- cpcb->sk_rcvlowat = 0;
-
- cpcb->l4_tick = 0;
- cpcb->dataSentFlag = 0;
- cpcb->recv_ring_not_empty = 0;
-
- return 0;
-}
-
-void
-unlink_pcb (struct common_pcb *cpcb)
-{
- if (cpcb && cpcb->conn)
- {
- /* whatever the private data will be reset */
- cpcb->conn->private_data = 0;
- update_tcp_state (cpcb->conn, CLOSED);
- }
- else
- {
- NSPOL_LOGINF (API_MSG_DEBUG, "conn is detached already!");
- }
-}
-
-void
-unlink_recv_ring (spl_netconn_t * conn)
-{
- if (conn)
- conn->recv_ring_valid = 0;
-}
-
-void
-recycle_tmr (void *arg)
-{
- if (arg == NULL)
- {
- NSPOL_LOGERR ("recycle_message is NULL!");
- }
- else
- {
- (void) ss_recycle_conn (arg, do_try_delconn);
- }
-}
-
-/**
- * Create a new pcb of a specific type.
- * Called from do_newconn().
- *
- * @param msg the api_msg_msg describing the connection type
- * @return msg->conn->err, but the return value is currently ignored
- */
-int
-spl_pcb_new (msg_new_netconn * pmsg)
-{
- u16_t thread_index = spl_get_lcore_id ();
- struct common_pcb *cpcb = NULL;
- enum lwip_ip_addr_type iptype = IPADDR_TYPE_V4;
-
- /* Allocate a PCB for this connection */
- switch (SPL_NETCONNTYPE_GROUP (pmsg->type))
- {
- case SPL_NETCONN_UDP:
- {
- struct udp_pcb *u = udp_new_ip_type (iptype);
- if (u == NULL)
- {
- return ERR_MEM;
- }
-
- if (pmsg->type == SPL_NETCONN_UDPNOCHKSUM)
- {
- udp_setflags (u, UDP_FLAGS_NOCHKSUM);
- }
-
- cpcb = (struct common_pcb *) alloc_common_pcb (SPL_NETCONN_UDP);
- if (cpcb == NULL)
- {
- return ERR_MEM;
- }
-
- pmsg->conn->comm_pcb_data = (i64) cpcb;
- pmsg->conn->private_data = (i64) u;
- udp_recv (u, spl_recv_udp, (void *) pmsg->conn);
- break;
- }
-
- case SPL_NETCONN_TCP:
- {
- struct tcp_pcb *t = tcp_new_ip_type (iptype);
- if (t == NULL)
- {
- return ERR_MEM;
- }
-
- cpcb = alloc_common_pcb (SPL_NETCONN_TCP);
- if (cpcb == NULL)
- {
- return ERR_MEM;
- }
-
- pmsg->conn->comm_pcb_data = (i64) cpcb;
- pmsg->conn->private_data = (i64) t;
- setup_tcp (t, pmsg->conn);
- break;
- }
-
- default:
- /* Unsupported netconn type, e.g. protocol disabled */
- NSPOL_LOGERR ("Unsupported netconn type!");
- return ERR_VAL;
- }
-
- /* type and socket value for all type */
- cpcb->socket = pmsg->socket;
- cpcb->conn = pmsg->conn;
- cpcb->bind_thread_index = thread_index;
-
- /* used to find pcb when a msg is received */
- return ERR_OK;
-}
-
-/**
- * Delete rcvmbox and acceptmbox of a netconn and free the left-over data in
- * these mboxes
- *
- * @param conn the netconn to free
- * @bytes_drained bytes drained from recvmbox
- * @accepts_drained pending connections drained from acceptmbox
- */
-int
-netconn_drain (enum spl_netconn_type type, spl_netconn_t * conn)
-{
- int i, n;
- mring_handle ring = NULL;
- void *addr[32] = { 0 };
- int not_empty = 0;
-
- /* This runs in tcpip_thread, so we don't need to lock against rx packets */
- ring = conn->recv_ring;
- do
- {
- /*every times get atmost 32 to release */
- n = nsfw_mem_ring_dequeuev (ring, addr, 32);
- for (i = 0; i < n; i++)
- {
- /* if the con is UDP, buffer type also is struct spl_netbuf,it is same as RAW */
- if ((type == SPL_NETCONN_RAW) || (type == SPL_NETCONN_UDP))
- {
- spl_pbuf_free ((struct spl_pbuf *) addr[i]);
- if (type == SPL_NETCONN_UDP)
- {
- UDP_STATS_INC (udp.drop);
- }
- }
- else
- {
- spl_pbuf_free ((struct spl_pbuf *) addr[i]);
- }
-
- if (not_empty == 0)
- not_empty = 1;
- }
- }
- while (0 != n);
- return not_empty;
-}
-
-/* need free mbuf inside recv ring before free conn */
-void
-free_conn_by_spl (spl_netconn_t * conn)
-{
- struct common_pcb *cpcb = (struct common_pcb *) conn->comm_pcb_data;
-
- free_common_pcb (cpcb);
-
- (void) netconn_drain (conn->type, conn);
- ss_free_conn (conn);
-}
-
-int
-do_close_finished (struct common_pcb *cpcb, u8_t close_finished, u8_t shut,
- err_t err, int OpShutDown)
-{
- struct tcp_pcb *tpcb = (struct tcp_pcb *) cpcb->conn->private_data;
- spl_netconn_t *conn = cpcb->conn;
-
- if (!close_finished)
- {
- /* Closing succeeded */
- /* Closing failed, restore some of the callbacks */
- /* Closing of listen pcb will never fail! */
- if (LISTEN == tpcb->state)
- {
- NSPOL_LOGERR ("Closing a listen pcb may not fail!");
- return ERR_VAL;
- }
-
- tcp_sent (tpcb, tcp_fn[TCP_FN_STACKX].sent_fn);
- tcp_poll (tpcb, tcp_fn[TCP_FN_STACKX].poll_fn, 1);
- tcp_err (tpcb, tcp_fn[TCP_FN_STACKX].err_fn);
- tcp_arg (tpcb, conn);
- /* don't restore recv callback: we don't want to receive any more data */
- }
- else
- {
- /* Closing done (succeeded, non-memory error, nonblocking error or timeout) */
- if (cpcb->current_msg)
- {
- SET_MSG_ERR (cpcb->current_msg, err);
- cpcb->current_msg = NULL;
- }
-
- conn->state = SPL_NETCONN_NONE;
- NSTCP_LOGINF ("release pcb]conn=%p,pcb=%p", conn, tpcb);
- unlink_pcb (cpcb);
- }
-
- return ERR_OK;
-}
-
-NSTACK_STATIC void
-reset_tcp_callback (struct tcp_pcb *tpcb, struct common_pcb *cpcb, u8 shut)
-{
- spl_netconn_t *conn = cpcb->conn;
-
- /* some callbacks have to be reset if tcp_close is not successful */
- if (shut & SPL_NETCONN_SHUT_RD)
- {
- conn->CanNotReceive = 1;
- tcp_recv (tpcb, tcp_fn[TCP_FN_NULL].recv_fn);
- tcp_accept (tpcb, tcp_fn[TCP_FN_NULL].accept_fn);
- }
-
- if (shut & SPL_NETCONN_SHUT_WR)
- {
- tcp_sent (tpcb, tcp_fn[TCP_FN_NULL].sent_fn);
- }
-
- if (shut == SPL_NETCONN_SHUT_RDWR)
- {
- tcp_poll (tpcb, tcp_fn[TCP_FN_NULL].poll_fn, 0);
- tcp_err (tpcb, tcp_fn[TCP_FN_NULL].err_fn);
- }
-}
-
-/**
- * Internal helper function to close a TCP netconn: since this sometimes
- * doesn't work at the first attempt, this function is called from multiple
- * places.
- *
- * @param conn the TCP netconn to close
- */
-err_t
-do_close_internal (struct common_pcb *cpcb, int OpShutDown)
-{
- err_t err;
- u8_t shut, ucclose;
- u8_t close_finished = 0;
-
- if (NULL == cpcb)
- {
- NSTCP_LOGERR ("invalid conn");
- return ERR_ARG;
- }
-
- spl_netconn_t *conn = cpcb->conn;
- if (SPL_NETCONN_TCP != cpcb->type || SPL_NETCONN_CLOSE != conn->state)
- {
- NSTCP_LOGERR ("conn=%p, err_type=%d, error_state=%d",
- conn, cpcb->type, conn->state);
- return ERR_VAL;
- }
-
- struct tcp_pcb *tpcb = (struct tcp_pcb *) (conn->private_data);
-
- if (cpcb->current_msg != NULL)
- shut = get_shut_op (cpcb->current_msg);
- else
- shut = SPL_NETCONN_SHUT_RDWR;
-
- /* shutting down both ends is the same as closing */
- ucclose = (shut == SPL_NETCONN_SHUT_RDWR);
-
- /* Set back some callback pointers */
- if (ucclose)
- {
- conn->CanNotReceive = 1;
- tcp_arg (tpcb, conn);
- }
-
- if (tpcb->state == LISTEN)
- {
- tcp_accept (tpcb, tcp_fn[TCP_FN_NULL].accept_fn);
- }
- else
- {
- reset_tcp_callback (tpcb, cpcb, shut);
- }
-
- /* Try to close the connection */
- if (shut == SPL_NETCONN_SHUT_RDWR && !OpShutDown)
- {
- err = tcp_close (tpcb);
- }
- else
- {
- err =
- tcp_shutdown (tpcb, shut & SPL_NETCONN_SHUT_RD,
- shut & SPL_NETCONN_SHUT_WR);
- }
-
- if (err == ERR_OK)
- {
- close_finished = 1;
- }
- else
- {
- if (err == ERR_MEM)
- {
- /* Blocking close, check the timeout */
- close_finished = 1;
- if (ucclose)
- {
- /* in this case, we want to RST the connection */
- tcp_abort (tpcb);
- err = ERR_OK;
- }
- }
- else
- {
- /* Closing failed for a non-memory error: give up */
- close_finished = 1;
- }
- }
-
- err_t err1 = do_close_finished (cpcb, close_finished,
- shut, err, OpShutDown);
- if (err1 != ERR_OK)
- {
- NSTCP_LOGERR ("return err1]pcb=%p,err1=%d", tpcb, err1);
- return err1;
- }
- return err;
-
- /* If closing didn't succeed, we get called again either
- from poll_tcp or from sent_tcp */
-}
-
-void
-do_try_delconn (void *close_data, u32 delay_sec)
-{
- msg_delete_netconn *dmsg = (msg_delete_netconn *) close_data;
- data_com_msg *m = MSG_ENTRY (dmsg, data_com_msg, buffer);
- struct common_pcb *cpcb = NULL;
-
- spl_netconn_t *conn = dmsg->conn;
-
- /* no receiver in some recycle cases */
- if (0 == m->param.comm_receiver)
- {
- if (NULL == conn)
- {
- NSFW_LOGERR ("release err conn!]pid=%d", dmsg->pid);
- /* need to free pbufs which are attached to msg */
- do_pbuf_free (dmsg->buf);
- return;
- }
-
- cpcb = (struct common_pcb *) conn->comm_pcb_data;
- }
- else
- {
- cpcb = COMM_PRIVATE_PTR (m);
- }
-
- /* no pcb in some recycle cases */
- if (conn->private_data == 0)
- {
- /* though pcb is gone, still need to clean the mbox */
- if (conn != NULL)
- (void) netconn_drain (conn->type, conn);
-
- NSFW_LOGWAR ("release conn pcb null]pcb=%p", m->param.receiver);
- /* need to free pbufs which are attached to msg */
- do_pbuf_free (dmsg->buf);
- return;
- }
-
- if (delay_sec)
- {
- NSFW_LOGWAR ("delay to recycle!]pcb=%p, msg=%d", cpcb, dmsg);
- sys_timeout (delay_sec * 1000, recycle_tmr, dmsg);
- return;
- }
-
- do_delconn (cpcb, dmsg);
-
- /* after the do_delconn, the PCB maybe released, but the conn is ok */
- sys_sem_s_signal (&dmsg->conn->close_completed);
-
- return;
-}
-
-/**
- * Delete the pcb inside a netconn.
- * Called from netconn_delete.
- *
- * @param msg the api_msg_msg pointing to the connection
- */
-void
-do_delconn (struct common_pcb *cpcb, msg_delete_netconn * dmsg)
-{
- spl_netconn_t *conn = cpcb->conn;
- data_com_msg *pmsg = MSG_ENTRY (dmsg, data_com_msg, buffer);
-
- /*if already close, just return */
- /* run and close repeatly nstackmain coredum */
- if (1 == cpcb->close_progress)
- {
- SET_MSG_ERR (pmsg, ERR_OK);
- return;
- }
- cpcb->close_progress = 1;
-
- /* Pbuf free should be done in network stack */
- do_pbuf_free (dmsg->buf);
-
- /* @todo TCP: abort running write/connect? */
- if ((conn->state != SPL_NETCONN_NONE)
- && (conn->state != SPL_NETCONN_LISTEN)
- && (conn->state != SPL_NETCONN_CONNECT))
- {
- /* this only happens for TCP netconns */
- if (SPL_NETCONN_TCP != cpcb->type)
- {
- NSTCP_LOGERR ("msg->conn->type error!]conn=%p,msg->conn->type=%d",
- conn, cpcb->type);
- SET_MSG_ERR (pmsg, ERR_VAL);
- return;
- }
- NSPOL_LOGINF (SOCK_INFO, "conn is not for free state]conn=%p,state=%d",
- conn, conn->state);
-
- //need to release pcb
- if (cpcb->current_msg != NULL && cpcb->msg_tail != NULL)
- {
- NSPOL_LOGINF (SOCK_INFO,
- "conn there is data in conn->current_msg when close the conn]conn=%p,state=%d",
- conn, conn->state);
- (void) do_writemore (cpcb->conn);
- }
- }
-
- /*
- the accpet connections waiting in listen queue will be clear in
- netconn_drain.
- */
- if (conn->state == SPL_NETCONN_LISTEN)
- {
- /* This function does nothing in original code. */
- }
- else
- {
- /* Drain pbuf from non-listen mboxes */
- if (netconn_drain (cpcb->type, conn))
- {
- cpcb->recv_ring_not_empty = 1;
-
- NSPOL_LOGWAR (SOCK_INFO,
- "still some data leave in recv ring when close");
- }
- }
-
- /* conn will be released outside */
-
- switch (SPL_NETCONNTYPE_GROUP (cpcb->type))
- {
-
- case SPL_NETCONN_UDP:
- {
- struct udp_pcb *upcb = (struct udp_pcb *) cpcb->conn->private_data;
- upcb->recv_arg = NULL;
- udp_remove (upcb);
- break;
- }
-
- case SPL_NETCONN_TCP:
- {
- conn->state = SPL_NETCONN_CLOSE;
- dmsg->shut = SPL_NETCONN_SHUT_RDWR;
- cpcb->current_msg = pmsg;
-
- if (ERR_INPROGRESS == do_close_internal (cpcb, 0))
- {
- return;
- }
- }
- default:
- break;
- }
-
- /* tcp netconns don't come here! */
-
-}
-
-/**
- * Bind a pcb contained in a netconn
- * Called from netconn_bind.
- *
- * @param msg the api_msg_msg pointing to the connection and containing
- * the IPaddress and port to bind to
- */
-void
-do_bind (struct common_pcb *cpcb, msg_bind * bmsg)
-{
- spl_netconn_t *conn = cpcb->conn;
- data_com_msg *pmsg = MSG_ENTRY (bmsg, data_com_msg, buffer);
- ip_addr_t stIpaddr;
-
- stIpaddr.addr = bmsg->ipaddr.addr;
-
- if (SPL_ERR_IS_FATAL (conn->last_err)
- && ERR_CANTASSIGNADDR != conn->last_err)
- {
- NSTCP_LOGERR ("bind but conn has err]pcb=%p,conn=%p,err=%d", cpcb, conn,
- conn->last_err);
- SET_MSG_ERR (pmsg, conn->last_err);
- }
- else
- {
- if (!ip_addr_isany (&bmsg->ipaddr)
- && !ip_addr_ismulticast (&bmsg->ipaddr))
- {
- if (!get_netif_by_ip (bmsg->ipaddr.addr)
- && !netif_check_broadcast_addr (&bmsg->ipaddr))
- {
- NSPOL_LOGERR ("ip is not exist]pcb=%p,ip=%u", cpcb,
- bmsg->ipaddr.addr);
- SET_MSG_ERR (pmsg, ERR_CANTASSIGNADDR);
- return;
- }
- }
-
- SET_MSG_ERR (pmsg, ERR_VAL);
- switch (SPL_NETCONNTYPE_GROUP (cpcb->type))
- {
- case SPL_NETCONN_UDP:
- SET_MSG_ERR (pmsg,
- udp_bind ((struct udp_pcb *) (cpcb->
- conn->private_data),
- &stIpaddr, bmsg->port));
-
- /* Set local Ip, willbe used during connect */
- struct udp_pcb *upcb = (struct udp_pcb *) cpcb->conn->private_data;
- ss_set_local_ip (cpcb->conn, upcb->local_ip.addr);
- ss_set_local_port (cpcb->conn, upcb->local_port);
- NSTCP_LOGINF ("updated Ip to spl_netconn_t] %x",
- upcb->local_ip.addr);
-
- NSUDP_LOGINF
- ("udp_bind return]pcb=%p,IP=%u.%u.%u.%u,port=%u,err=%d",
- (struct udp_pcb *) cpcb->conn->private_data,
- &bmsg->ipaddr == NULL ? 0 : ip4_addr1_16 (&stIpaddr),
- &bmsg->ipaddr == NULL ? 0 : ip4_addr2_16 (&stIpaddr),
- &bmsg->ipaddr == NULL ? 0 : ip4_addr3_16 (&stIpaddr),
- &bmsg->ipaddr == NULL ? 0 : ip4_addr4_16 (&stIpaddr), bmsg->port,
- GET_MSG_ERR (pmsg));
- break;
-
- case SPL_NETCONN_TCP:
- SET_MSG_ERR (pmsg,
- tcp_bind ((struct tcp_pcb *) cpcb->conn->private_data,
- &stIpaddr, bmsg->port));
-
- /* Set local Ip, willbe used during connect */
- struct tcp_pcb *tpcb = (struct tcp_pcb *) cpcb->conn->private_data;
- NSTCP_LOGINF ("updated Ip to spl_netconn_t] %x",
- tpcb->local_ip.addr);
- ss_set_local_ip (cpcb->conn, tpcb->local_ip.addr);
- ss_set_local_port (cpcb->conn, tpcb->local_port);
-
- NSTCP_LOGINF
- ("tcp_bind return]pcb=%p,IP=%u.%u.%u.%u,port=%u,err=%d",
- (struct tcp_pcb *) cpcb->conn->private_data,
- &bmsg->ipaddr == NULL ? 0 : ip4_addr1_16 (&stIpaddr),
- &bmsg->ipaddr == NULL ? 0 : ip4_addr2_16 (&stIpaddr),
- &bmsg->ipaddr == NULL ? 0 : ip4_addr3_16 (&stIpaddr),
- &bmsg->ipaddr == NULL ? 0 : ip4_addr4_16 (&stIpaddr), bmsg->port,
- GET_MSG_ERR (pmsg));
- break;
- default:
- break;
- }
- }
-
- conn->last_err = GET_MSG_ERR (pmsg);
- NSPOL_LOGDBG (TESTSOCKET_DEBUG | LWIP_DBG_TRACE, "the msg is doing bind");
- NSTCP_LOGINF ("the msg is doing bind");
-}
-
-/**
- * TCP callback function if a connection (opened by tcp_connect/do_connect) has
- * been established (or reset by the remote host).
- *
- * @see tcp.h (struct tcp_pcb.connected) for parameters and return values
- */
-err_t
-spl_do_connected (void *arg, struct tcp_pcb *pcb, err_t err)
-{
- spl_netconn_t *conn = (spl_netconn_t *) arg;
- struct common_pcb *cpcb = (struct common_pcb *) conn->comm_pcb_data;
- data_com_msg *m = cpcb->current_msg;
- int was_blocking;
-
- if (conn == NULL)
- {
- NSTCP_LOGERR ("conn is NULL!]arg=%p", arg);
- return ERR_ARG;
- }
-
- if (SPL_NETCONN_CONNECT != conn->state)
- {
- NSTCP_LOGERR ("conn->state error!]conn=%p,state=%d", conn, conn->state);
- return ERR_VAL;
- }
-
- if ((NULL == m) && (0 == spl_netconn_is_nonblocking (conn)))
- {
- NSTCP_LOGERR ("conn->current_msg!]conn=%p,current_msg=%p", conn, m);
- return ERR_VAL;
- }
-
- if (m != NULL)
- {
- SET_MSG_ERR (m, err);
- }
-
- if ((cpcb->type == SPL_NETCONN_TCP) && (err == ERR_OK))
- {
- setup_tcp (pcb, conn);
- }
-
- ss_set_local_ip (conn, pcb->local_ip.addr);
- ss_set_local_port (conn, pcb->local_port);
- conn->remote_ip.addr = pcb->remote_ip.addr;
- conn->remote_port = pcb->remote_port;
-
- conn->mss = pcb->mss;
- cpcb->current_msg = NULL;
-
- was_blocking = !SPL_IN_NONBLOCKING_CONNECT (conn);
- SPL_SET_NONBLOCKING_CONNECT (conn, 0);
- conn->state = SPL_NETCONN_NONE;
- SPL_NETCONN_SET_SAFE_ERR (conn, ERR_OK);
-
- update_tcp_state (pcb->callback_arg, ESTABLISHED);
- SPL_API_EVENT (conn, SPL_NETCONN_EVT_SENDPLUS, 1);
-
- if (was_blocking && m != NULL)
- {
- SYNC_MSG_ACK (m);
- }
-
- return ERR_OK;
-}
-
-int
-do_internal_tcp_connect (struct common_pcb *cpcb, struct tcp_pcb *tpcb,
- msg_connect * cmsg)
-{
- spl_netconn_t *conn = cpcb->conn;
- data_com_msg *pmsg = MSG_ENTRY (cmsg, data_com_msg, buffer);
- ip_addr_t ip_addr;
-
- ip_addr.addr = cmsg->ipaddr.addr;
-
- /* Prevent connect while doing any other action. */
- if (conn->state != SPL_NETCONN_NONE)
- {
- if (conn->state == SPL_NETCONN_CONNECT
- || conn->state == SPL_NETCONN_WRITE)
- {
- if (tpcb->state != ESTABLISHED)
- {
- SET_MSG_ERR (pmsg, ERR_ALREADY);
- }
- else
- {
- SET_MSG_ERR (pmsg, ERR_ISCONN);
- }
- }
- else
- {
- SET_MSG_ERR (pmsg, ERR_ISCONN);
- }
-
- NSTCP_LOGINF
- ("tcp_connect]pcb=%p,state=%d,remote_ip=%u.%u.%u.%u,remote_port=%u,local_ip=%u.%u.%u.%u,local_port=%u,err=%d",
- tpcb, conn->state, ip4_addr1_16 (&ip_addr), ip4_addr2_16 (&ip_addr),
- ip4_addr3_16 (&ip_addr), ip4_addr4_16 (&ip_addr), cmsg->port,
- ip4_addr1_16 (&tpcb->local_ip), ip4_addr2_16 (&tpcb->local_ip),
- ip4_addr3_16 (&tpcb->local_ip), ip4_addr4_16 (&tpcb->local_ip),
- tpcb->local_port, GET_MSG_ERR (pmsg));
- }
- else
- {
- setup_tcp (tpcb, conn);
- SET_MSG_ERR (pmsg,
- tcp_connect (tpcb, &ip_addr, cmsg->port,
- tcp_fn[TCP_FN_STACKX].connected_fn));
- conn->mss = tpcb->mss;
- SPL_API_EVENT (conn, NETCONN_EVT_SENDMINUS, 1);
- SPL_API_EVENT (conn, NETCONN_EVT_RCVMINUS, 1);
-
- NSTCP_LOGINF
- ("tcp_connect]pcb=%p,state=%d,remote_ip=%u.%u.%u.%u,remote_port=%u,local_ip=%u.%u.%u.%u,local_port=%u,err=%d",
- tpcb, conn->state, ip4_addr1_16 (&ip_addr), ip4_addr2_16 (&ip_addr),
- ip4_addr3_16 (&ip_addr), ip4_addr4_16 (&ip_addr), cmsg->port,
- ip4_addr1_16 (&tpcb->local_ip), ip4_addr2_16 (&tpcb->local_ip),
- ip4_addr3_16 (&tpcb->local_ip), ip4_addr4_16 (&tpcb->local_ip),
- tpcb->local_port, GET_MSG_ERR (pmsg));
- if (GET_MSG_ERR (pmsg) == ERR_OK)
- {
- int nonblock = spl_netconn_is_nonblocking (conn);
- SPL_SET_NONBLOCKING_CONNECT (conn, nonblock);
- conn->state = SPL_NETCONN_CONNECT;
- if (nonblock)
- {
- SET_MSG_ERR (pmsg, ERR_INPROGRESS);
- }
- else
- {
- cpcb->current_msg = pmsg;
- /* sys_sem_signal() is called from do_connected (or err_tcp()),
- * when the connection is established! */
- return -1;
- }
- }
- }
-
- return 0;
-}
-
-/**
- * Connect a pcb contained inside a netconn
- * Called from netconn_connect.
- *
- * @param msg the api_msg_msg pointing to the connection and containing
- * the IPaddress and port to connect to
- */
-void
-do_connect (struct common_pcb *cpcb, msg_connect * cmsg)
-{
- data_com_msg *pmsg = MSG_ENTRY (cmsg, data_com_msg, buffer);
- ip_addr_t ipaddr;
-
- SET_MSG_ERR (pmsg, ERR_OK);
-
- if (cpcb == NULL)
- {
- /* This may happen when calling netconn_connect() a second time */
- NSTCP_LOGERR ("conn connect but conn has err]msg=%p", pmsg);
- SET_MSG_ERR (pmsg, ERR_CLSD);
- return;
- }
-
- ipaddr.addr = cmsg->ipaddr.addr;
- switch (SPL_NETCONNTYPE_GROUP (cpcb->type))
- {
- case SPL_NETCONN_UDP:
- {
- struct udp_pcb *upcb = (struct udp_pcb *) (cpcb->conn->private_data);
- if (ip_addr_isany (&upcb->local_ip))
- {
- upcb->local_ip.addr = cmsg->local_ip.addr;
- ss_set_local_ip (cpcb->conn, upcb->local_ip.addr);
- }
-
- SET_MSG_ERR (pmsg, udp_connect (upcb, &ipaddr, cmsg->port));
- if (ERR_OK == pmsg->param.err)
- {
- cpcb->conn->remote_ip.addr = cmsg->ipaddr.addr;
- cpcb->conn->remote_port = cmsg->port;
- }
- break;
- }
- case SPL_NETCONN_TCP:
- {
- struct tcp_pcb *tpcb = (struct tcp_pcb *) (cpcb->conn->private_data);
- if (ip_addr_isany (&tpcb->local_ip))
- {
- tpcb->local_ip.addr = cmsg->local_ip.addr;
- ss_set_local_ip (cpcb->conn, tpcb->local_ip.addr);
- }
-
- if (0 != do_internal_tcp_connect (cpcb, tpcb, cmsg))
- {
- return;
- }
-
- }
- break;
- default:
- NSPOL_LOGERR ("Invalid netconn type]type=%d", cpcb->type);
- SET_MSG_ERR (pmsg, ERR_VAL);
- break;
- }
-
- /* For all other protocols, netconn_connect() calls TCPIP_APIMSG(),
- so use TCPIP_APIMSG_ACK() here.
- Do as lwip-2.0.0. set conn->last_error here. */
- SPL_NETCONN_SET_SAFE_ERR (cpcb->conn, GET_MSG_ERR (pmsg));
-}
-
-/* Pbuf free should be done in network stack */
-void
-do_pbuf_free (struct spl_pbuf *buf)
-{
- if (buf)
- {
- struct spl_pbuf *pCur = buf;
- while (buf)
- {
- pCur = buf;
- buf = buf->freeNext;
- spl_pbuf_free (pCur);
- }
- }
-}
-
-/**
- * Set a TCP pcb contained in a netconn into listen mode
- * Called from netconn_listen.
- *
- * @param msg the api_msg_msg pointing to the connection
- */
-void
-do_listen (struct common_pcb *cpcb, msg_listen * lmsg)
-{
- err_t err = ERR_OK;
- spl_netconn_t *conn = cpcb->conn;
- data_com_msg *pmsg = MSG_ENTRY (lmsg, data_com_msg, buffer);
-
- if (SPL_ERR_IS_FATAL (conn->last_err))
- {
- NSTCP_LOGERR ("conn listern but conn has err]conn=%p,err=%d",
- conn, conn->last_err);
- SET_MSG_ERR (pmsg, conn->last_err);
- }
- else
- {
- SET_MSG_ERR (pmsg, ERR_CONN);
-
- if (cpcb->type == SPL_NETCONN_TCP)
- {
- if (conn->state == SPL_NETCONN_NONE)
- {
- struct tcp_pcb *lpcb;
- if (((struct tcp_pcb *) (cpcb->conn->private_data))->state !=
- CLOSED)
- {
- /* connection is not closed, cannot listen */
- SET_MSG_ERR (pmsg, ERR_VAL);;
- }
- else
- {
- u8_t backlog = TCP_DEFAULT_LISTEN_BACKLOG;
-
- lpcb =
- tcp_listen_with_backlog_and_err ((struct tcp_pcb
- *) (cpcb->
- conn->private_data),
- backlog, &err);
- if (lpcb == NULL)
- {
- /* in this case, the old pcb is still allocated */
- SET_MSG_ERR (pmsg, err);
- }
- else
- {
- SET_MSG_ERR (pmsg, ERR_OK);
- /* conn now is put on lpcb */
- conn->state = SPL_NETCONN_LISTEN;
-
- /* NOTE: pmsg->conn->comm_pcb_data == (i64)cpcb; should be already same. */
- conn->private_data = (i64) lpcb;
-
- tcp_arg (lpcb, conn);
- tcp_accept (lpcb, tcp_fn[TCP_FN_STACKX].accept_fn);
-
- SPL_API_EVENT (conn, NETCONN_EVT_SENDMINUS, 1);
- SPL_API_EVENT (conn, NETCONN_EVT_RCVMINUS, 1);
- }
- }
- }
- else if (conn->state == SPL_NETCONN_LISTEN)
- {
- SET_MSG_ERR (pmsg, ERR_OK);
- }
- }
- NSTCP_LOGINF ("listen]conn=%p,pcb=%p,connstate=%d,err=%d",
- conn, cpcb, conn->state, GET_MSG_ERR (pmsg));
-
- }
-
-}
-
-/**
- * Send some data on UDP pcb contained in a netconn
- * Called from do_send
- *
- * @param msg the api_msg_msg pointing to the connection
- */
-void
-spl_udp_send (struct common_pcb *cpcb, msg_send_buf * smsg)
-{
- struct spl_pbuf *p_from = smsg->p;
- spl_netconn_t *conn = cpcb->conn;
- struct udp_pcb *upcb = (struct udp_pcb *) (cpcb->conn->private_data);
- data_com_msg *m = MSG_ENTRY (smsg, data_com_msg, buffer);
- struct pbuf *p_to = NULL;
- err_t err = ERR_OK;
-
- //allocate pbuf and copy spl_pbuf, send , free pbuf and spl_pbuf
- do
- {
- p_to = pbuf_alloc (PBUF_TRANSPORT, p_from->len, PBUF_RAM);
- if (NULL == p_to)
- {
- NSPOL_LOGERR ("pbuf is NULL]conn=%p,pcb=%p", conn, upcb);
- return;
- }
-
- err = splpbuf_to_pbuf_transport_copy (p_to, p_from);
- if (err != ERR_OK)
- {
- SET_MSG_ERR (m, conn->last_err);
- return;
- }
-
- if (ip_addr_isany (&smsg->addr))
- {
- SET_MSG_ERR (m, udp_send (upcb, p_to));
- }
- else
- {
- SET_MSG_ERR (m,
- udp_sendto (upcb, p_to, (ip_addr_t *) & smsg->addr,
- smsg->port));
- }
-
- p_from = (struct spl_pbuf *) ADDR_SHTOL (p_from->next_a);
- }
- while (p_from != NULL);
-
-}
-
-/**
- * Send some data on a RAW or UDP pcb contained in a netconn
- * Called from netconn_send
- *
- * @param msg the api_msg_msg pointing to the connection
- */
-void
-do_send (struct common_pcb *cpcb, msg_send_buf * smsg)
-{
- struct spl_pbuf *p = smsg->p;
- data_com_msg *m = MSG_ENTRY (smsg, data_com_msg, buffer);
- spl_netconn_t *conn = cpcb->conn;
-
- pbuf_set_recycle_flg (p, MBUF_HLD_BY_SPL); /* release buf hold by app on abnormal exit */
-
- if (SPL_ERR_IS_FATAL (conn->last_err))
- {
- SET_MSG_ERR (m, conn->last_err);
- NSPOL_LOGERR ("Invalid param]msg->conn=%p", conn);
- goto err_return;
- }
-
- switch (SPL_NETCONNTYPE_GROUP (cpcb->type))
- {
- case SPL_NETCONN_UDP:
- {
- struct udp_pcb *upcb = (struct udp_pcb *) (cpcb->conn->private_data);
- if (ip_addr_isany (&upcb->local_ip))
- {
- upcb->local_ip.addr = smsg->local_ip.addr;
- ss_set_local_ip (conn, smsg->local_ip.addr);
- }
-
- spl_udp_send (cpcb, smsg);
-
- break;
- }
-
- default:
- SET_MSG_ERR (m, ERR_CONN);
- break;
- }
-
-err_return:
- pbuf_free_safe (smsg->p);
- ASYNC_MSG_FREE (m);
-
- return;
-}
-
-/**
- * Indicate data has been received from a TCP pcb contained in a netconn
- * Called from netconn_recv
- *
- * @param msg the api_msg_msg pointing to the connection
- */
-void
-do_recv (struct common_pcb *cpcb, msg_recv_buf * rmsg)
-{
- data_com_msg *m = MSG_ENTRY (rmsg, data_com_msg, buffer);
- SET_MSG_ERR (m, ERR_OK);
- struct tcp_pcb *tpcb = (struct tcp_pcb *) cpcb->conn->private_data;
-
- if (NULL == tpcb)
- {
- if (rmsg->p)
- {
- NSPOL_LOGDBG (TCP_DEBUG,
- "When pcb was freed: do recv, and free pbuf");
- spl_pbuf_free (rmsg->p);
- rmsg->p = NULL;
- }
-
- return;
- }
-
- if (cpcb->conn->type == SPL_NETCONN_TCP)
- {
- /* Pbuf free should be done in network stack */
- if (rmsg->p)
- {
- NSPOL_LOGDBG (TCP_DEBUG, "do recv, and free pbuf");
- spl_pbuf_free (rmsg->p);
- rmsg->p = NULL;
- }
- tcp_recved (tpcb, rmsg->len * TCP_MSS);
- }
-}
-
-/**
- * See if more data needs to be written from a previous call to netconn_write.
- * Called initially from do_write. If the first call can't send all data
- * (because of low memory or empty send-buffer), this function is called again
- * from sent_tcp() or poll_tcp() to send more data. If all data is sent, the
- * blocking application thread (waiting in netconn_write) is released.
- *
- * @param conn netconn (that is currently in state NETCONN_WRITE) to process
- * @return ERR_OK
- * ERR_MEM if LWIP_TCPIP_CORE_LOCKING=1 and sending hasn't yet finished
- */
-
-/**
- * See if more data needs to be written from a previous call to netconn_write.
- * Called initially from do_write. If the first call can't send all data
- * (because of low memory or empty send-buffer), this function is called again
- * from sent_tcp() or poll_tcp() to send more data. If all data is sent, the
- * blocking application thread (waiting in netconn_write) is released.
- *
- * @param conn netconn (that is currently in state NETCONN_WRITE) to process
- * @return ERR_OK
- * ERR_MEM if LWIP_TCPIP_CORE_LOCKING=1 and sending hasn't yet finished
- */
-err_t
-do_writemore (struct spl_netconn *conn)
-{
- err_t err = ERR_OK;
- u16_t len = 0, available;
- u8_t write_finished = 0;
- struct tcp_pcb *tpcb = (struct tcp_pcb *) conn->private_data;
- common_pcb *cpcb = (struct common_pcb *) conn->comm_pcb_data;
- size_t diff;
- const void *dataptr;
-
- if ((NULL == tpcb) || (NULL == conn) || (SPL_NETCONN_WRITE != conn->state)
- || (NULL == cpcb->current_msg))
- {
- NSPOL_LOGERR ("conn=NULL");
- return ERR_ARG;
- }
-
- msg_write_buf *wmsg = (msg_write_buf *) cpcb->current_msg->buffer;
-start_write:
-
- if (NULL == wmsg->p)
- {
- NSPOL_LOGERR ("wmsg->p is NULL]conn=%p,pcb=%p", conn, tpcb);
- return ERR_VAL;
- }
-
- u8_t apiflags = wmsg->apiflags;
- struct spl_pbuf *current_w_pbuf = wmsg->p;
- current_w_pbuf->res_chk.u8Reserve |= NEED_ACK_FLAG;
- wmsg->p = current_w_pbuf->next;
- current_w_pbuf->next = NULL;
-
- dataptr = (const u8_t *) current_w_pbuf->payload + cpcb->write_offset;
- diff = current_w_pbuf->len - cpcb->write_offset;
-
- if (diff > 0xffffUL)
- {
- len = 0xffff;
- apiflags |= TCP_WRITE_FLAG_MORE;
- }
- else
- {
- len = (u16_t) diff;
- }
-
- available = tcp_sndbuf (tpcb);
- if (!available)
- {
- err = ERR_MEM;
- goto err_mem;
- }
-
- if (available < len)
- {
- /* don't try to write more than sendbuf */
- len = available;
- apiflags |= TCP_WRITE_FLAG_MORE;
- }
-
- err = tcp_write (tpcb, dataptr, len, apiflags);
- if ((err == ERR_OK) || (err == ERR_MEM))
- {
- err_mem:
- if ((tcp_sndbuf (tpcb) <= TCP_SNDLOWAT) ||
- (tcp_sndqueuelen (tpcb) >= TCP_SNDQUEUELOWAT))
- {
- SPL_API_EVENT (conn, NETCONN_EVT_SENDMINUS, 1);
- }
- }
- if (err == ERR_OK)
- {
- cpcb->write_offset += len;
- tcp_output (tpcb);
-
- if (cpcb->write_offset == current_w_pbuf->len)
- {
- cpcb->write_offset = 0;
- spl_pbuf_free (current_w_pbuf);
- if (NULL == wmsg->p)
- {
- /* this message is finished */
- cpcb->write_offset = 0;
- SET_MSG_ERR (cpcb->current_msg, err);
-
- /* go to next msg */
- data_com_msg *forFreemsg = cpcb->current_msg;
- msg_write_buf *msg_head_prev = cpcb->msg_head;
- cpcb->msg_head = cpcb->msg_head->next;
-
- /* no msg remain */
- if (cpcb->msg_head == NULL)
- {
- write_finished = 1;
- if (cpcb->msg_tail != NULL
- && msg_head_prev != cpcb->msg_tail)
- {
- NSPOL_LOGWAR (TCP_DEBUG,
- "err maybe lost one mesg]conn=%p,pcb=%p",
- conn, tpcb);
- }
- cpcb->msg_tail = NULL;
- cpcb->current_msg = NULL;
- conn->state = SPL_NETCONN_NONE;
- }
- else /* go to handle next message */
- {
-
- cpcb->current_msg =
- MSG_ENTRY (cpcb->msg_head, data_com_msg, buffer);
- wmsg = cpcb->msg_head;
- write_finished = 0;
- }
-
- ASYNC_MSG_FREE (forFreemsg);
- }
-
- }
- else
- {
- if (cpcb->write_offset > current_w_pbuf->len)
- {
- NSPOL_LOGERR ("Big trouble write_offset > current_w_pbuf->len");
- }
-
- current_w_pbuf->next = wmsg->p;
- wmsg->p = current_w_pbuf;
- }
- if ((write_finished == 0) && (NULL != wmsg->p))
- {
- goto start_write;
- }
- }
- else if (err == ERR_MEM)
- {
- current_w_pbuf->next = wmsg->p;
- wmsg->p = current_w_pbuf;
- tcp_output (tpcb);
- }
- else
- {
- NSPOL_LOGERR ("]pcb=%p, error when send %d", tpcb, err);
- write_finished = 1;
- cpcb->write_offset = 0;
- current_w_pbuf->next = wmsg->p;
- wmsg->p = current_w_pbuf;
- tcp_abort (tpcb);
- return err;
- }
- NSTCP_LOGINF ("do_writemore finished with err %d", err);
- return ERR_OK;
-}
-
-/**
- * Send some data on a TCP pcb contained in a netconn
- * Called from netconn_write
- *
- * @param msg the api_msg_msg pointing to the connection
- */
-void
-do_write (struct common_pcb *cpcb, msg_write_buf * wmsg)
-{
- struct tcp_pcb *tpcb = (struct tcp_pcb *) cpcb->conn->private_data;
- spl_netconn_t *conn = cpcb->conn;
- data_com_msg *m = MSG_ENTRY (wmsg, data_com_msg, buffer);
-
- pbuf_set_recycle_flg (wmsg->p, MBUF_HLD_BY_SPL); /* release buf hold by app on abnormal exit */
-
- int tcpState = -1;
-
- /* if msg->conn is null, then return */
- if (NULL == conn)
- {
- NSPOL_LOGERR ("Invalid param]msg->conn=%p", conn);
- SET_MSG_ERR (m, ERR_VAL);
- goto err_return;
- }
-
- tcpState = tpcb->state;
-
- if ((SPL_ERR_IS_FATAL (conn->last_err))
- && !((ERR_CLSD == conn->last_err) && (CLOSE_WAIT == tcpState)))
- {
- SET_MSG_ERR (m, conn->last_err);
- }
- else
- {
- if (cpcb->type == SPL_NETCONN_TCP)
- {
- if (cpcb->current_msg != NULL)
- {
- if (NULL == cpcb->msg_head || NULL == cpcb->msg_tail)
- {
- /* if possible only if connect is not finished and it's
- blocking, then the current_msg is connect msg.
- */
- NSPOL_LOGERR ("netconn do_write msg is null]msg_type=%d",
- cpcb->current_msg->param.minor_type);
- goto err_return;
- }
-
- /* only msg_write_buf will be in msg_head-msg_tail queue */
- wmsg->next = NULL;
- cpcb->msg_tail->next = wmsg;
- cpcb->msg_tail = wmsg;
- (void) do_writemore (conn);
- NSTCP_LOGINF ("do_write finished....");
- return;
- }
-
- if (conn->state != SPL_NETCONN_NONE)
- {
- /* netconn is connecting, closing or in blocking write */
- NSPOL_LOGINF (TCP_DEBUG,
- "msg->conn->state != SPL_NETCONN_NONE..netconn is connecting, "
- "closing or in blocking write]conn=%p", conn);
- SET_MSG_ERR (m, ERR_INPROGRESS);
- }
- /* this means we should start to process this message */
- else if (tpcb != NULL)
- {
- conn->state = SPL_NETCONN_WRITE;
-
- /* set all the variables used by do_writemore */
- if (0 != cpcb->write_offset)
- {
- NSPOL_LOGERR ("already writing or closing]conn=%p", conn);
- goto err_return;
- }
-
- if (0 == wmsg->len)
- {
- NSPOL_LOGERR ("msg->msg.w.len=0]conn=%p", conn);
- goto err_return;
- }
-
- /* record the msg will be processed */
- cpcb->current_msg = m;
- if (cpcb->msg_head != NULL || cpcb->msg_tail != NULL)
- {
- NSPOL_LOGERR ("error maybe lost mesg]conn=%p", conn);
- }
- cpcb->msg_head = cpcb->msg_tail = wmsg;
- wmsg->next = NULL;
- cpcb->write_offset = 0;
-
- (void) do_writemore (conn);
-
- if ((conn->snd_buf) > TCP_SNDLOWAT)
- {
- if (cpcb->model == SOCKET_STACKX)
- SPL_API_EVENT (conn, SPL_NETCONN_EVT_SENDPLUS, 1);
- }
- NSTCP_LOGINF ("do_write finished %d", conn->snd_buf);
-
- /* for both cases: if do_writemore was called, don't ACK the APIMSG
- since do_writemore ACKs it! */
- return;
- }
- else
- {
- SET_MSG_ERR (m, ERR_CONN);
- }
- }
- else
- {
- SET_MSG_ERR (m, ERR_VAL);
- }
- }
- NSTCP_LOGINF ("do_write finished");
-
-err_return:
- pbuf_free_safe (wmsg->p);
- ASYNC_MSG_FREE (m);
-
- return;
-}
-
-void
-do_getsockname (struct common_pcb *cpcb, msg_getaddrname * amsg)
-{
- spl_netconn_t *conn;
- struct tcp_pcb *tcp;
- struct udp_pcb *udp;
- struct sockaddr_in *paddr = (struct sockaddr_in *) &amsg->sock_addr;
-
- data_com_msg *m = MSG_ENTRY (amsg, data_com_msg, buffer);
-
- if ((NULL == cpcb) || !(conn = cpcb->conn))
- {
- NSTCP_LOGERR ("failed to get sock");
- paddr->sin_family = 0;
- paddr->sin_port = 0;
- paddr->sin_addr.s_addr = 0;
- SET_MSG_ERR (m, ERR_CONN);
- return;
- }
-
- NS_LOG_CTRL (LOG_CTRL_GETSOCKNAME, LOGTCP, "NSTCP", NSLOG_DBG,
- "cpcb=%p,conn=%p,cmd=%u", cpcb, cpcb->conn, amsg->cmd);
-
- paddr->sin_family = AF_INET;
- SET_MSG_ERR (m, ERR_OK);
-
- if (amsg->cmd == 0)
- {
- if (cpcb->type == SPL_NETCONN_TCP)
- {
- tcp = (struct tcp_pcb *) cpcb->conn->private_data;
- /* add judgement:(NETCONN_LISTEN == conn->state) in following if words */
- /* If connect is not done in TCP then the remote address will not be there so need to update proper error code
- if the application call the getpeername in TCP mode */
- if ((SPL_NETCONN_LISTEN == conn->state)
- || (tcp->remote_ip.addr == 0) || (tcp->remote_port == 0))
- {
- paddr->sin_family = 0;
- paddr->sin_port = 0;
- paddr->sin_addr.s_addr = 0;
- SET_MSG_ERR (m, ERR_CONN);
- }
- else
- {
- paddr->sin_port = spl_htons (tcp->remote_port);
- paddr->sin_addr.s_addr = tcp->remote_ip.addr;
- }
- }
- else if (cpcb->type == SPL_NETCONN_UDP)
- {
- udp = (struct udp_pcb *) cpcb->conn->private_data;
- /* If connect is not done in UDP then the remote address will not be there so need to update proper error code
- if the application call the getpeername in UDP mode
- */
- if ((udp->remote_ip.addr == 0) || (udp->remote_port == 0))
- {
- paddr->sin_family = 0;
- paddr->sin_port = 0;
- paddr->sin_addr.s_addr = 0;
- SET_MSG_ERR (m, ERR_CONN);
- }
- else
- {
- paddr->sin_port = spl_htons (udp->remote_port);
- paddr->sin_addr.s_addr = udp->remote_ip.addr;
- }
- }
- }
- else
- {
- if (cpcb->type == SPL_NETCONN_TCP)
- {
- tcp = (struct tcp_pcb *) cpcb->conn->private_data;
- paddr->sin_port = spl_htons (tcp->local_port);
- paddr->sin_addr.s_addr = tcp->local_ip.addr;
- }
- else if (cpcb->type == SPL_NETCONN_UDP)
- {
- udp = (struct udp_pcb *) cpcb->conn->private_data;
- paddr->sin_port = spl_htons (udp->local_port);
- paddr->sin_addr.s_addr = udp->local_ip.addr;
- }
- }
-}
-
-/**
- * Close a TCP pcb contained in a netconn
- * Called from netconn_close
- *
- * @param msg the api_msg_msg pointing to the connection
- */
-void
-do_close (struct common_pcb *cpcb, msg_close * cmsg)
-{
- spl_netconn_t *conn = cpcb->conn;
- data_com_msg *m = MSG_ENTRY (cmsg, data_com_msg, buffer);
-
- NSTCP_LOGDBG ("msg->conn=%p,state=%d", conn, conn->state);
-
- /* @todo: abort running write/connect? */
- if ((conn->state != SPL_NETCONN_NONE)
- && (conn->state != SPL_NETCONN_LISTEN)
- && (conn->state != SPL_NETCONN_CONNECT))
- {
- if (SPL_NETCONN_TCP != cpcb->type)
- {
- NSTCP_LOGERR ("msg->conn=%p,type=%d", conn, cpcb->type);
- return;
- }
- NSTCP_LOGWAR ("msg->conn=%p,state=%d", conn, conn->state);
- SET_MSG_ERR (m, ERR_INPROGRESS);
- }
- else if (cpcb->type == SPL_NETCONN_TCP) //clear codeDEX warning , CID:24336, cpcb can't be null.
- {
- struct tcp_pcb *tpcb = (struct tcp_pcb *) cpcb->conn->private_data;
-
- if (tpcb == NULL)
- {
- NSTCP_LOGERR ("tpcb null msg->conn=%p,type=%d", conn, cpcb->type);
- return;
- }
- if ((cmsg->shut != SPL_NETCONN_SHUT_RDWR)
- && (conn->state == SPL_NETCONN_LISTEN))
- {
- /* LISTEN doesn't support half shutdown */
- NSTCP_LOGERR
- ("LISTEN doesn't support half shutdown!]conn=%p,pcb=%p,state=%d",
- conn, tpcb, conn->state);
- SET_MSG_ERR (m, ERR_CONN);
- }
- else
- {
- if (cmsg->shut & SPL_NETCONN_SHUT_RD)
- {
- /* Drain and delete mboxes */
- (void) netconn_drain (cpcb->type, conn);
- unlink_recv_ring (conn);
- }
-
- if (((NULL != cpcb->current_msg)
- && (conn->state != SPL_NETCONN_CONNECT))
- || (0 != cpcb->write_offset))
- {
- NSTCP_LOGERR
- ("already writing or closing]conn=%p,pcb=%p,offset=%zu,curmsg=%p",
- conn, tpcb, cpcb->write_offset, cpcb->current_msg);
- SET_MSG_ERR (m, ERR_CONN);
- return;
- }
-
- if (conn->state == SPL_NETCONN_CONNECT)
- {
- if (cpcb->current_msg != NULL
- && cpcb->current_msg->param.minor_type ==
- SPL_API_DO_CONNECT)
- {
- SET_MSG_ERR (m, ERR_RST);
- SYNC_MSG_ACK (cpcb->current_msg);
- }
- else
- {
- NSTCP_LOGINF
- ("already in connecting]conn=%p,cpcb=%p,msg=%p", conn,
- cpcb, cpcb->current_msg);
- }
- /* maybe need to clean cpcb->msg_head */
- }
-
- conn->state = SPL_NETCONN_CLOSE;
- cpcb->current_msg = m;
- (void) do_close_internal (cpcb, 1);
-
- if (SPL_NETCONN_SHUT_RD == cmsg->shut
- || SPL_NETCONN_SHUT_RDWR == cmsg->shut)
- {
- SPL_API_EVENT (conn, SPL_NETCONN_EVT_RCVPLUS, 1);
- }
-
- return;
- }
- }
- else
- {
- SET_MSG_ERR (m, ERR_VAL);
- }
-}
-
-/*trans kerner option to stackx option*/
-int
-ks_to_stk_opt (int opt)
-{
- int stack_opt = opt;
- switch (opt)
- {
- case SO_DEBUG:
- stack_opt = SOF_DEBUG;
- break;
- case SO_ACCEPTCONN:
- stack_opt = SOF_ACCEPTCONN;
- break;
- case SO_BROADCAST:
- stack_opt = SOF_BROADCAST;
- break;
- case SO_KEEPALIVE:
- stack_opt = SOF_KEEPALIVE;
- break;
- case SO_REUSEADDR:
- stack_opt = SOF_REUSEADDR;
- break;
- case SO_DONTROUTE:
- stack_opt = SOF_DONTROUTE;
- break;
- case SO_USELOOPBACK:
- stack_opt = SOF_USELOOPBACK;
- break;
- case SO_OOBINLINE:
- stack_opt = SOF_OOBINLINE;
- break;
- default:
- stack_opt = opt;
- break;
- }
- return stack_opt;
-}
-
-void
-do_get_tcpproto_getsockopt_internal (struct common_pcb *cpcb,
- msg_setgetsockopt * smsg)
-{
- int optname;
- void *optval;
- struct tcp_pcb *tpcb = (struct tcp_pcb *) cpcb->conn->private_data;
- data_com_msg *m = MSG_ENTRY (smsg, data_com_msg, buffer);
-
- optname = smsg->optname;
- optval = &smsg->optval;
-
- switch (optname)
- {
- case SPL_TCP_NODELAY:
- *(int *) optval = tcp_nagle_disabled (tpcb);
- NSPOL_LOGDBG (SOCKETS_DEBUG, "]fd=%d,TCP_NODELAY=%s",
- cpcb->socket, (*(int *) optval) ? "on" : "off");
- break;
-
- case SPL_TCP_KEEPIDLE:
- *(int *) optval = (int) (tpcb->keep_idle / 1000);
- NSPOL_LOGDBG (SOCKETS_DEBUG, "]fd=%d,SPL_TCP_KEEPIDLE=%d",
- cpcb->socket, *(int *) optval);
- break;
- case SPL_TCP_KEEPINTVL:
- *(int *) optval = (int) (tpcb->keep_intvl / 1000);
- NSPOL_LOGDBG (SOCKETS_DEBUG, "]fd=%d,SPL_TCP_KEEPINTVL=%d",
- cpcb->socket, *(int *) optval);
- break;
- case SPL_TCP_KEEPCNT:
- *(int *) optval = (int) tpcb->keep_cnt;
- NSPOL_LOGDBG (SOCKETS_DEBUG, "]fd=%d,SPL_TCP_KEEPCNT=%d",
- cpcb->socket, *(int *) optval);
- break;
- case SPL_TCP_INFO:
- ((struct tcp_info *) optval)->tcpi_total_retrans = (int) tpcb->nrtx;
- ((struct tcp_info *) optval)->tcpi_snd_mss = (int) tpcb->mss;
- ((struct tcp_info *) optval)->tcpi_rtt = (int) tpcb->sa;
- ((struct tcp_info *) optval)->tcpi_snd_cwnd = (int) tpcb->cwnd;
- break;
- default:
- NSPOL_LOGDBG (SOCKETS_DEBUG, "unsupported]optname=%d", optname);
- SET_MSG_ERR (m, EOPNOTSUPP);
- break;
- }
-}
-
-void
-do_get_ipproto_getsockopt_internal (struct common_pcb *cpcb,
- msg_setgetsockopt * smsg)
-{
- int optname;
- u32_t optlen;
- void *optval;
-
- struct ip_pcb *ipcb = (struct ip_pcb *) (cpcb);
- data_com_msg *m = MSG_ENTRY (smsg, data_com_msg, buffer);
-
- optname = smsg->optname;
- optval = &smsg->optval;
- optlen = smsg->optlen;
-
- switch (optname)
- {
- case IP_TTL:
- *(int *) optval = ipcb->ttl;
- NSPOL_LOGDBG (SOCKETS_DEBUG, "]fd=%d,IP_TTL=%d",
- cpcb->socket, *(int *) optval);
- break;
- case IP_TOS:
- smsg->optlen =
- (optlen < sizeof (u32_t)) ? sizeof (u8_t) : sizeof (u32_t);
- if (smsg->optlen == sizeof (u8_t))
- {
- *(u8_t *) optval = ipcb->tos;
- }
- else
- {
- *(u32_t *) optval = (u32_t) ipcb->tos;
- }
- NSPOL_LOGDBG (SOCKETS_DEBUG, "]fd=%d,IP_TOS=%d",
- cpcb->socket, *(int *) optval);
- break;
- default:
- SET_MSG_ERR (m, ERR_VAL);
- NSPOL_LOGDBG (SOCKETS_DEBUG, "unsupported]optname=%d", optname);
- break;
- }
-}
-
-void
-do_get_solsocket_getsockopt_internal (struct common_pcb *cpcb,
- msg_setgetsockopt * smsg)
-{
- int optname;
- void *optval;
- struct tcp_pcb *tpcb = NULL;
- data_com_msg *m = MSG_ENTRY (smsg, data_com_msg, buffer);
- struct tcp_pcb *pcb = (struct tcp_pcb *) cpcb->conn->private_data;
-
- optname = smsg->optname;
- optval = &smsg->optval;
-
- switch (optname)
- {
- /* The option flags */
- case SO_BROADCAST:
- case SO_KEEPALIVE:
- case SO_REUSEADDR:
- *(int *) optval =
- (ip_get_option ((struct ip_pcb *) cpcb, ks_to_stk_opt (optname))) ? 1
- : 0;
- NSPOL_LOGDBG (SOCKETS_DEBUG, "]fd=%d,optname=%d,optval=%s",
- cpcb->socket, optname, (*(int *) optval ? "on" : "off"));
- break;
- case SO_ACCEPTCONN:
- tpcb = (struct tcp_pcb *) cpcb->conn->private_data;
- if ((smsg->optlen < sizeof (int)) || (NULL == tpcb))
- {
- SET_MSG_ERR (m, ERR_VAL);
- NSPOL_LOGDBG (SOCKETS_DEBUG,
- "(SOL_SOCKET, SO_ACCEPTCONN) failed]fd=%d,tcp=%p,optlen=%u",
- cpcb->socket, cpcb, smsg->optlen);
- break;
- }
- if (tpcb->state == LISTEN)
- {
- *(int *) optval = 1;
- }
- else
- {
- *(int *) optval = 0;
- }
- NSPOL_LOGDBG (SOCKETS_DEBUG,
- "(SOL_SOCKET, SO_ACCEPTCONN)]fd=%d,optval=%d",
- cpcb->socket, *(int *) optval);
- break;
- case SO_TYPE:
- switch (cpcb->type)
- {
- case SPL_NETCONN_RAW:
- *(int *) optval = SOCK_RAW;
- break;
- case SPL_NETCONN_TCP:
- *(int *) optval = SOCK_STREAM;
- break;
- case SPL_NETCONN_UDP:
- *(int *) optval = SOCK_DGRAM;
- break;
- default: /* unrecognized socket type */
- *(int *) optval = cpcb->type;
- NSPOL_LOGDBG (SOCKETS_DEBUG,
- "(SOL_SOCKET, SO_TYPE): unrecognized socket type]fd=%d,optval=%d",
- cpcb->socket, *(int *) optval);
- } /* switch (sock->conn->type) */
- NSPOL_LOGDBG (SOCKETS_DEBUG, "(SOL_SOCKET, SO_TYPE)]fd=%d,optval=%d",
- cpcb->socket, *(int *) optval);
- break;
- case SO_RCVTIMEO:
- (*(struct timeval *) optval).tv_sec =
- spl_netconn_get_recvtimeout (cpcb) / 1000;
- (*(struct timeval *) optval).tv_usec =
- (spl_netconn_get_recvtimeout (cpcb) % 1000) * 1000;
- NSPOL_LOGDBG (SOCKETS_DEBUG,
- "stackx_getsockopt(SOL_SOCKET, SO_RCVTIMEO)]fd=%d,sec=%ld,usec=%ld",
- cpcb->socket, (*(struct timeval *) optval).tv_sec,
- (*(struct timeval *) optval).tv_usec);
- break;
- case SO_SNDTIMEO:
- (*(struct timeval *) optval).tv_sec =
- spl_netconn_get_sendtimeout (cpcb) / 1000;
- (*(struct timeval *) optval).tv_usec =
- (spl_netconn_get_sendtimeout (cpcb) % 1000) * 1000;
- NSPOL_LOGDBG (SOCKETS_DEBUG,
- "(SOL_SOCKET, SO_SNDTIMEO)]fd=%dsec=%ld,usec=%ld",
- cpcb->socket, (*(struct timeval *) optval).tv_sec,
- (*(struct timeval *) optval).tv_usec);
- break;
- case SO_SNDBUF:
- {
- u16_t mss = (pcb->mss > TCP_MSS
- || pcb->mss == 0) ? TCP_MSS : pcb->mss;
- *(int *) optval = spl_netconn_get_sendbufsize (cpcb->conn) * mss;
- /*If user has not configured any sendbuffer value then we should return minimum
- promissed for the connection based on the flow control. */
- if (*(int *) optval == 0)
- {
- *(int *) optval = CONN_TCP_MEM_MIN_LINE * mss;
- }
- NSPOL_LOGDBG (SOCKETS_DEBUG,
- "(SOL_SOCKET, SO_SNDBUF)]fd=%d,optval=%d", cpcb->socket,
- *(int *) optval);
- break;
- }
- case SO_NO_CHECK:
- *(int *) optval =
- (udp_flags ((struct udp_pcb *) cpcb->conn->private_data) &
- UDP_FLAGS_NOCHKSUM) ? 1 : 0;
- NSPOL_LOGDBG (SOCKETS_DEBUG, "(SOL_SOCKET, SO_NO_CHECK)fd=%d,optval=%d",
- cpcb->socket, *(int *) optval);
- break;
- case SO_SNDLOWAT:
- *(int *) optval = 1;
- NSPOL_LOGDBG (SOCKETS_DEBUG, "(SOL_SOCKET, SO_SNDLOWAT)fd=%d,optval=%d",
- cpcb->socket, *(int *) optval);
- break;
-
- case SO_RCVLOWAT:
- *(int *) optval = spl_netconn_get_reclowbufsize (cpcb);
- NSPOL_LOGDBG (SOCKETS_DEBUG, "(SOL_SOCKET, SO_RCVLOWAT)fd=%d,optval=%d",
- cpcb->socket, *(int *) optval);
- break;
- case SO_ERROR:
- *(int *) optval = GET_MSG_ERR (m);
- SET_MSG_ERR (m, 0);
- NSPOL_LOGDBG (SOCKETS_DEBUG, "SOL_SOCKET]fd=%d,optval=%d", cpcb->socket,
- *(int *) optval);
- break;
- default:
- SET_MSG_ERR (m, ERR_VAL);
- NSPOL_LOGDBG (SOCKETS_DEBUG, "unsupported opt]optname=%d", optname);
- break;
- }
-}
-
-void
-do_getsockopt_internal (struct common_pcb *cpcb, msg_setgetsockopt * smsg)
-{
- int level;
-
- if (NULL == smsg)
- {
- NSTCP_LOGERR ("arg NULL");
- return;
- }
-
- data_com_msg *m = MSG_ENTRY (smsg, data_com_msg, buffer);
-
- level = smsg->level;
- switch (level)
- {
- /* Level: SOL_SOCKET */
- case SOL_SOCKET:
- do_get_solsocket_getsockopt_internal (cpcb, smsg);
-
- break;
-
- /* Level: IPPROTO_IP */
- case IPPROTO_IP:
- do_get_ipproto_getsockopt_internal (cpcb, smsg);
-
- break;
- /* Level: IPPROTO_TCP */
- case IPPROTO_TCP:
- do_get_tcpproto_getsockopt_internal (cpcb, smsg);
-
- break;
- default:
- SET_MSG_ERR (m, ERR_VAL);
- NSPOL_LOGDBG (SOCKETS_DEBUG, "unsupported level]level=%d", level);
- break;
- } /* switch (level) */
-}
-
-void
-do_tcpsock_setsockopt (spl_netconn_t * conn, msg_setgetsockopt * smsg)
-{
- const void *optval;
- int optname;
- struct common_pcb *cpcb = (struct common_pcb *) conn->comm_pcb_data;
- struct tcp_pcb *tpcb = (struct tcp_pcb *) conn->private_data;
-
- data_com_msg *m = MSG_ENTRY (smsg, data_com_msg, buffer);
-
- optname = smsg->optname;
- optval = &smsg->optval;
-
- switch (optname)
- {
- case SPL_TCP_NODELAY:
- if (*(int *) optval)
- {
- tcp_nagle_disable (tpcb);
- }
- else
- {
- tcp_nagle_enable (tpcb);
- }
-
- NSTCP_LOGDBG ("IPPROTO_TCP, TCP_NODELAY]fd=%d,optval=%s",
- cpcb->socket, (*(int *) optval) ? "on" : "off");
- break;
-
- case SPL_TCP_KEEPIDLE:
- /* CID 52121 (#2 of 3): Other violation (HW_VPP_C_FIND_OPERATORS_2_1_1_3) */
- if ((u32_t) (*(int *) optval) >= INT_MAX / 1000)
- {
- NSTCP_LOGWAR ("optval too big]optval=%u",
- (u32_t) (*(int *) optval));
- *(int *) optval = INT_MAX / 1000;
- }
-
- tpcb->keep_idle = 1000 * (u32_t) (*(int *) optval);
-
- if (tpcb->keep_idle > TCP_KEEPIDLE_DEFAULT)
- {
- NSTCP_LOGWAR
- ("(%d, IPPROTO_TCP, SPL_TCP_KEEPIDLE. value bigger than 7200000UL so setting to default 7200000UL) requested is -> %"
- U32_F " ", cpcb->socket, tpcb->keep_idle);
- tpcb->keep_idle = TCP_KEEPIDLE_DEFAULT;
- }
-
- NSTCP_LOGDBG ("IPPROTO_TCP, SPL_TCP_KEEPIDLE](fd=%d,keep_idle=%" U32_F
- " ", cpcb->socket, tpcb->keep_idle);
-
- /* Not required lwip_slowtmr will take care about timer. */
- break;
- case SPL_TCP_KEEPINTVL:
- /* CID 52121 (#1 of 3): Other violation (HW_VPP_C_FIND_OPERATORS_2_1_1_3) */
- if ((u32_t) (*(int *) optval) >= INT_MAX / 1000)
- {
- NSTCP_LOGWAR ("optval too big]optval=%u",
- (u32_t) (*(int *) optval));
- *(int *) optval = INT_MAX / 1000;
- }
-
- tpcb->keep_intvl = 1000 * (u32_t) (*(int *) optval);
-
- if (tpcb->keep_intvl > TCP_KEEPIDLE_DEFAULT) /*max timer value supported */
- {
- NSTCP_LOGWAR
- ("(%d, IPPROTO_TCP, SPL_TCP_KEEPINTVL. value bigger than 7200000UL so setting to default 7200000UL) requested is -> %"
- U32_F " ", cpcb->socket, tpcb->keep_intvl);
- tpcb->keep_intvl = TCP_KEEPIDLE_DEFAULT;
- }
- NSTCP_LOGDBG ("IPPROTO_TCP, SPL_TCP_KEEPINTVL]fd=%d,keep_intvl=%" U32_F
- " ", cpcb->socket, tpcb->keep_intvl);
- break;
- case SPL_TCP_KEEPCNT:
- tpcb->keep_cnt = (u32_t) (*(int *) optval);
- NSTCP_LOGDBG ("IPPROTO_TCP, SPL_TCP_KEEPCNT]fd=%d,keep_cnt=%" U32_F " ",
- cpcb->socket, tpcb->keep_cnt);
- break;
- default:
- SET_MSG_ERR (m, ERR_VAL);
- NSPOL_LOGDBG (SOCKETS_DEBUG, "unsupported]optname=%d", optname);
- break;
- }
-}
-
-void
-do_ipsock_setsockopt (struct common_pcb *cpcb, msg_setgetsockopt * smsg)
-{
- const void *optval;
- u32_t optlen;
- int optname;
-
- data_com_msg *m = MSG_ENTRY (smsg, data_com_msg, buffer);
-
- struct udp_pcb *upcb = (struct udp_pcb *) cpcb->conn->private_data;
- struct ip_pcb *ipcb = (struct ip_pcb *) upcb;
-
- optname = smsg->optname;
- optval = &smsg->optval;
- optlen = smsg->optlen;
-
- int val = 0;
- int bNotAllowSet = 0;
- switch (optname)
- {
- case IP_TTL:
- ipcb->ttl = (u8_t) (*(int *) optval);
- NSIP_LOGDBG ("IPPROTO_IP,IP_TTL]fd=%d,ttl=%u", cpcb->socket, ipcb->ttl);
- break;
- case IP_TOS:
- bNotAllowSet = (cpcb->dataSentFlag != 0)
- && ((SPL_NETCONN_TCP == cpcb->type)
- || (SPL_NETCONN_UDP == cpcb->type)
- || (SPL_NETCONN_RAW == cpcb->type));
- /*not allow set tos value when sending data */
- if (bNotAllowSet)
- {
- SET_MSG_ERR (m, ERR_VAL);
- break;
- }
-
- if (optlen >= sizeof (u32_t))
- {
- val = (int) (*(const int *) optval);
- }
- else if (optlen >= sizeof (u8_t))
- {
- val = (int) (*(const u8_t *) optval);
- }
-
- if (SPL_NETCONN_TCP == cpcb->type)
- {
- val &= ~INET_ECN_MASK;
- val |= ipcb->tos & INET_ECN_MASK;
- }
- ipcb->tos = (u8_t) (val);
-
- smsg->msg_box = (get_msgbox ((u8_t) val))->llring;
-
- NSIP_LOGDBG ("IPPROTO_IP,IP_TOS]]fd=%d,tos=%u", cpcb->socket,
- ipcb->tos);
- break;
- default:
- SET_MSG_ERR (m, ERR_VAL);
- NSPOL_LOGDBG (SOCKETS_DEBUG, "unsupported]optname=%d", optname);
- break;
- }
-}
-
- /*Made seperate functions to reduce code complexity */
-void
-do_setsockopt_recvtimeout_internal (const void *optval,
- struct common_pcb *cpcb)
-{
- if ((*(struct timeval *) optval).tv_sec < 0)
- {
- spl_netconn_set_recvtimeout (cpcb, 0);
- }
- else
- {
- spl_netconn_set_recvtimeout (cpcb, MAX_WAIT_TIMEOUT);
- if ((*(struct timeval *) optval).tv_sec != 0
- || (*(struct timeval *) optval).tv_usec != 0)
- {
- if ((*(struct timeval *) optval).tv_sec <
- ((MAX_WAIT_TIMEOUT / 1000) - 1))
- {
- spl_netconn_set_recvtimeout (cpcb,
- (*(struct timeval *) optval).tv_sec
- * 1000 +
- (*(struct timeval *)
- optval).tv_usec / 1000);
- }
- }
- }
-
- NSPOL_LOGDBG (SOCKETS_DEBUG,
- "SOL_SOCKET, SO_RCVTIMEO]conn=%p,fd=%d,optval=%d", cpcb,
- cpcb->socket, cpcb->recv_timeout);
-}
-
-void
-do_setsockopt_sndtimeout_internal (const void *optval,
- struct common_pcb *cpcb)
-{
- if ((*(struct timeval *) optval).tv_sec < 0)
- {
- spl_netconn_set_sendtimeout (cpcb, 0);
- }
- else
- {
- spl_netconn_set_sendtimeout (cpcb, MAX_WAIT_TIMEOUT);
- if ((*(struct timeval *) optval).tv_sec != 0
- || (*(struct timeval *) optval).tv_usec != 0)
- {
- if ((*(struct timeval *) optval).tv_sec <
- ((MAX_WAIT_TIMEOUT / 1000) - 1))
- {
- spl_netconn_set_sendtimeout (cpcb,
- (*(struct timeval *) optval).tv_sec
- * 1000 +
- (*(struct timeval *)
- optval).tv_usec / 1000);
- }
- }
- }
-
- NSPOL_LOGDBG (SOCKETS_DEBUG,
- "SOL_SOCKET, SO_SNDTIMEO]conn=%p,fd=%d,optval=%d", cpcb,
- cpcb->socket, cpcb->send_timeout);
-}
-
-#define IS_TCP_PCB(cpcb) (cpcb && (cpcb->conn) && (SPL_NETCONN_TCP == cpcb->conn->type))
-NSTACK_STATIC inline void
-set_opt_sol_socket (struct common_pcb *cpcb, struct tcp_pcb *pcb,
- data_com_msg * m, int level, int optname,
- const void *optval)
-{
- switch (optname)
- {
- /* The option flags */
- case SO_BROADCAST:
-
- /* UNIMPL case SO_DEBUG: */
- /* UNIMPL case SO_DONTROUTE: */
- case SO_KEEPALIVE:
- case SO_REUSEADDR:
-
- if (NULL == pcb)
- {
- NSPOL_LOGERR ("conn->pcb.ip is null");
- break;
- }
-
- if (*(const int *) optval)
- {
- ip_set_option ((struct ip_pcb *) pcb, ks_to_stk_opt (optname));
- }
- else
- {
- ip_reset_option ((struct ip_pcb *) pcb, ks_to_stk_opt (optname));
- }
-
- NSPOL_LOGDBG (SOCKETS_DEBUG, "]conn=%p,fd=%d,optname=0x%x,optval=%s",
- cpcb, cpcb->socket, optname,
- (*(const int *) optval ? "on" : "off"));
-
- /* No use now, since tcp_slowtmr will take care about not sending/sending of keepalive */
- break;
-
- case SO_RCVLOWAT:
- spl_netconn_set_reclowbufsize (cpcb, *(int *) optval);
- NSPOL_LOGDBG (SOCKETS_DEBUG,
- "SOL_SOCKET, SO_RCVLOWAT]conn=%p,fd=%d,optval=%d", cpcb,
- cpcb->socket, cpcb->sk_rcvlowat);
- break;
-
- case SO_RCVTIMEO:
- /*to reduce code complexity */
- do_setsockopt_recvtimeout_internal (optval, cpcb);
- break;
-
- case SO_SNDTIMEO:
- /*to reduce code complexity */
- do_setsockopt_sndtimeout_internal (optval, cpcb);
- break;
-
- case SO_SNDBUF:
- {
- /* udp pcb invalid access will cause coredump */
- if (!IS_TCP_PCB (cpcb))
- {
- NSPOL_LOGDBG (SOCKETS_DEBUG,
- "not support for non tcp socket]optname=%d, level=%d",
- optname, level);
- return;
- }
-
- u16_t mss = (pcb->mss > TCP_MSS
- || pcb->mss == 0) ? TCP_MSS : pcb->mss;
-
- if (*(int *) optval < (int) mss)
- {
- /*set value of one TCP_MSS */
- spl_netconn_set_sendbufsize (cpcb->conn, 1);
- }
- else
- {
- spl_netconn_set_sendbufsize (cpcb->conn,
- (*(int *) optval) / (int) mss);
- }
-
- NSPOL_LOGDBG (SOCKETS_DEBUG,
- "SOL_SOCKET, SO_SNDBUF]conn=%p,fd=%d,optval=%d", cpcb,
- cpcb->socket, cpcb->conn->send_bufsize * mss);
- break;
- }
-
- case SO_NO_CHECK:
- /* How udp is coming here.. ?? @TODO: May be move to someother function.? */
- /* solve segment issue when the PCB is not exist */
- if (NULL == cpcb)
- {
- NSPOL_LOGERR ("conn->pcb.udp is null");
- break;
- }
-
- struct udp_pcb *upcb = (struct udp_pcb *) pcb;
-
- if (*(int *) optval)
- {
- udp_setflags (upcb, udp_flags (upcb) | UDP_FLAGS_NOCHKSUM);
- }
- else
- {
- udp_setflags (upcb, udp_flags (upcb) & ~UDP_FLAGS_NOCHKSUM);
- }
-
- NSPOL_LOGDBG (SOCKETS_DEBUG,
- "SOL_SOCKET, SO_NO_CHECK]conn=%p,fd=%d,optval=0x%x", cpcb,
- cpcb->socket, upcb->flags);
- break;
-
- default:
- SET_MSG_ERR (m, ERR_VAL);
- NSPOL_LOGDBG (SOCKETS_DEBUG, "unsupported]optname=%d", optname);
- break;
- } /* switch (optname) */
-
-}
-
-void
-do_setsockopt_internal (struct common_pcb *cpcb, msg_setgetsockopt * smsg)
-{
- int level, optname;
- const void *optval;
-
- data_com_msg *m = MSG_ENTRY (smsg, data_com_msg, buffer);
- struct tcp_pcb *pcb = (struct tcp_pcb *) cpcb->conn->private_data;
-
- if (NULL == smsg)
- {
- NSTCP_LOGERR ("arg null!");
- return;
- }
-
- level = smsg->level;
- optname = smsg->optname;
- optval = &smsg->optval;
-
- switch (level)
- {
- /* Level: SOL_SOCKET */
- case SOL_SOCKET:
- set_opt_sol_socket (cpcb, pcb, m, SOL_SOCKET, optname, optval);
- break;
-
- /* Level: IPPROTO_IP */
- case IPPROTO_IP:
-
- if (NULL == cpcb)
- {
- NSPOL_LOGERR ("conn->pcb.ip is null");
- break;
- }
-
- do_ipsock_setsockopt (cpcb, smsg);
-
- break;
- /* Level: IPPROTO_TCP */
- case IPPROTO_TCP:
- /* udp pcb invalid access will cause coredump */
- if (!IS_TCP_PCB (cpcb))
- {
- SET_MSG_ERR (m, ERR_VAL);
- NSPOL_LOGDBG (SOCKETS_DEBUG,
- "not support for non tcp socket]optname=%d,level=%d",
- optname, level);
- return;
- }
-
- if (NULL == cpcb)
- {
- NSPOL_LOGERR ("conn->pcb.tcp is null");
- break;
- }
-
- do_tcpsock_setsockopt (cpcb->conn, smsg);
-
- break;
- default:
- SET_MSG_ERR (m, ERR_VAL);
- NSPOL_LOGDBG (SOCKETS_DEBUG, "unsupported]level=%d", level);
- break;
- } /* switch (level) */
-}
-
-/*app send its version info to nStackMain */
-void
-do_app_touch (msg_app_touch * smsg)
-{
- //write app version info to running.log
- NSPOL_LOGINF (SOCKETS_DEBUG, "hostpid=%u,app_version=%s", smsg->hostpid,
- smsg->app_version);
-}
-
-void
-tcp_free_accept_ring (spl_netconn_t * conn)
-{
- err_t de_err = ERR_OK;
- spl_netconn_t *newconn;
- while (1)
- {
- newconn = NULL;
- /* -1 means nonblocking */
- de_err = accept_dequeue (conn, (void **) &newconn, (u32_t) - 1);
- if (de_err == ERR_WOULDBLOCK || newconn == NULL)
- return;
-
- tcp_drop_conn (newconn);
- }
-}
-
-void
-tcp_drop_conn (spl_netconn_t * conn)
-{
- /* usually we should not access pcb by recv_obj, but no choice */
- struct tcp_pcb *pcb = (struct tcp_pcb *) conn->private_data;
-
- /* free conn first, even pcb is NULL */
- free_conn_by_spl (conn);
-
- if (pcb == NULL)
- {
- NSTCP_LOGWAR
- ("a tcp connection in accept queue without pcb!]newconn=%p", conn);
- return;
- }
-
- /* tell peer conneciton is reset */
- NSTCP_LOGWAR ("sending RST in accept waiting queue!]pcb=%p", pcb);
-
- tcp_rst (pcb->snd_nxt, pcb->rcv_nxt, &pcb->local_ip, &pcb->remote_ip,
- pcb->local_port, pcb->remote_port);
-
- tcp_pcb_remove (&tcp_active_pcbs, pcb);
- memp_free (MEMP_TCP_PCB, pcb);
-}
-
-void
-update_tcp_state (spl_netconn_t * conn, enum tcp_state state)
-{
- spl_tcp_state_t spl_state;
-
- if (conn != NULL)
- {
- switch (state)
- {
- case CLOSED:
- spl_state = SPL_CLOSED;
- break;
- case LISTEN:
- spl_state = SPL_LISTEN;
- break;
- case SYN_SENT:
- spl_state = SPL_SYN_SENT;
- break;
- case SYN_RCVD:
- spl_state = SPL_SYN_RCVD;
- break;
- case ESTABLISHED:
- spl_state = SPL_ESTABLISHED;
- break;
- case FIN_WAIT_1:
- spl_state = SPL_FIN_WAIT_1;
- break;
- case FIN_WAIT_2:
- spl_state = SPL_FIN_WAIT_2;
- break;
- case CLOSE_WAIT:
- spl_state = SPL_CLOSE_WAIT;
- break;
- case CLOSING:
- spl_state = SPL_CLOSING;
- break;
- case LAST_ACK:
- spl_state = SPL_LAST_ACK;
- break;
- case TIME_WAIT:
- spl_state = SPL_TIME_WAIT;
- break;
- default:
- spl_state = SPL_CLOSED;
- break;
- }
- if (conn->tcp_state != spl_state)
- {
- conn->tcp_state = spl_state;
- NSTCP_LOGINF ("conn=%p,private_data=%p,state=%d", conn,
- conn->private_data, spl_state);
- }
- }
-}
-
-void
-do_update_pcbstate ()
-{
- struct tcp_pcb *tpcb;
- int i;
- for (i = 0; i < NUM_TCP_PCB_LISTS; i++)
- {
- for (tpcb = *tcp_pcb_lists[i]; tpcb != NULL; tpcb = tpcb->next)
- {
- if (tpcb->callback_arg)
- {
- update_tcp_state ((spl_netconn_t *) tpcb->callback_arg,
- tpcb->state);
- }
- }
- }
-
- return;
-}
-
-void
-init_stackx_lwip ()
-{
- lwip_init ();
- sys_timeouts_init ();
- return;
-}
-
-void
-free_common_pcb (struct common_pcb *cpcb)
-{
- if (res_free (&cpcb->res_chk))
- {
- NSFW_LOGERR ("conn refree!]conn=%p", cpcb->conn);
- return;
- }
-
- common_pcb_reset (cpcb);
-
- mring_handle pool = p_def_stack_instance->cpcb_seg;
- if (nsfw_mem_ring_enqueue (pool, (void *) cpcb) != 1)
- {
- NSSBR_LOGERR ("nsfw_mem_ring_enqueue failed,this can not happen");
- }
- return;
-}
-
-struct common_pcb *
-alloc_common_pcb (enum spl_netconn_type type)
-{
- struct common_pcb *cpcb = NULL;
-
- if (nsfw_mem_ring_dequeue (p_def_stack_instance->cpcb_seg, (void **) &cpcb)
- != 1)
- {
- NSSBR_LOGERR ("malloc conn failed");
- return NULL;
- }
-
- NSFW_LOGINF ("alloc_common_pcb]cpcb=%p", cpcb);
-
- common_pcb_init (cpcb);
- cpcb->type = type;
-
- res_alloc (&cpcb->res_chk);
- return cpcb;
-}
diff --git a/stacks/lwip_stack/lwip_src/api/spl_netbuf.c b/stacks/lwip_stack/lwip_src/api/spl_netbuf.c
deleted file mode 100644
index 9c682fc..0000000
--- a/stacks/lwip_stack/lwip_src/api/spl_netbuf.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * 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. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
- *
- * This file is part of the lwIP TCP/IP stack.
- *
- * Author: Adam Dunkels <adam@sics.se>
- *
- */
-//#include "sc_dpdk.h"
-#include "spl_netbuf.h"
-
-void
-spl_netbuf_delete (struct spl_netbuf *buf)
-{
- if (likely (buf != NULL))
- {
- spl_pbuf_free (PTR_SHTOL (struct spl_pbuf *, buf->p));
- }
-}
diff --git a/stacks/lwip_stack/lwip_src/api/spl_netifapi.c b/stacks/lwip_stack/lwip_src/api/spl_netifapi.c
deleted file mode 100644
index ab1446a..0000000
--- a/stacks/lwip_stack/lwip_src/api/spl_netifapi.c
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "spl_opt.h"
-
-#if STACKX_NETIF_API
-
-#include "nsfw_msg_api.h"
-#include "netifapi.h"
-#include <sys/socket.h>
-//#include <netinet/in.h>
-
-#include "stackx_spl_share.h"
-#include "spl_sbr.h"
-#include "stackx/spl_api.h"
-#include "tcpip.h"
-#include "sc_dpdk.h"
-#include "spl_instance.h"
-#include "spl_hal.h"
-#include "spl_def.h"
-#include <inet.h>
-
-struct netifExt *gNetifExt = NULL;
-
-/**
- * common operation for sbr message.
- *
- * @param msg the api_msg_msg describing the connection type
- */
-int
-do_halmsg (data_com_msg * m)
-{
- NSPOL_LOGDBG (TESTSOCKET_DEBUG | STACKX_DBG_TRACE,
- "the msg is from HAL module, minor(%u)", m->param.minor_type);
- return 0;
-}
-
-static int
-_do_add_netif (data_com_msg * m)
-{
- NSPOL_LOGINF (NETIF_DEBUG, "_do_add_netif\n");
-
- m->param.err = ERR_OK;
- msg_add_netif *_m = (msg_add_netif *) m->buffer;
- _m->function (_m);
- SYNC_MSG_ACK (m);
- return 0;
-}
-
-struct netif *
-find_netif_by_if_name (char *if_name)
-{
-
- struct netifExt *netifEx = gNetifExt;
- struct netif *netif = NULL;
-
- while (netifEx != NULL)
- {
- if (!(strcmp (netifEx->if_name, if_name)))
- {
- for (netif = netif_list; netif != NULL; netif = netif->next)
- {
- if (netifEx->id == netif->num)
- return netif;
- }
-
- }
- netifEx = netifEx->next;
- }
-
- return NULL;
-}
-
-/*@TODO: May be moved to some other file ? Like HAL*/
-struct netif *
-get_netif_by_ip (unsigned int ip)
-{
- struct netif *netif;
-
- if (ip == 0)
- {
- return NULL;
- }
-
- for (netif = netif_list; netif != NULL; netif = netif->next)
- {
- if (ip == netif->ip_addr.addr)
- {
- NSPOL_LOGINF (NETIF_DEBUG, "netif_find: found %x %c %c", ip,
- netif->name[0], netif->name[1]);
- return netif;
- }
- }
- NSPOL_LOGINF (NETIF_DEBUG, "netif_find: Not found %x", ip);
- return NULL;
-}
-
-/*
-@TODO:
-*/
-struct netif *
-netif_check_broadcast_addr (spl_ip_addr_t * addr)
-{
- return NULL;
-}
-
-struct netifExt *
-getNetifExt (u16_t id)
-{
-
- struct netifExt *netifEx;
- netifEx = gNetifExt;
-
- while (netifEx != NULL)
- {
- if (netifEx->id == id)
- {
- return netifEx;
- }
- netifEx = netifEx->next;
- }
-
- return NULL;
-}
-
-int
-netifExt_add (struct netif *netif)
-{
-
- /* If Netif Ext already created for it then just return sucess */
- if (getNetifExt (netif->num))
- return 0;
-
- struct netifExt *netifEx = malloc (sizeof (struct netifExt));
- if (!netifEx)
- {
- return -1;
- }
-
- if (memset (netifEx, 0, sizeof (struct netifExt)) < 0)
- {
- return -1;
- }
-
- NSPOL_LOGINF (NETIF_DEBUG, "netifExt_added \n");
-
- netifEx->id = netif->num;
-
- /* add this netif to the list */
- netifEx->next = gNetifExt;
- gNetifExt = netifEx;
- return 0;
-}
-
-void
-do_netifapi_netif_add (msg_add_netif * pmsg)
-{
- struct netif *netif = NULL;
- ip_addr_t ipaddr;
- ip_addr_t netmask;
- ip_addr_t gw;
-
- data_com_msg *m = MSG_ENTRY (pmsg, data_com_msg, buffer);
- ipaddr.addr = pmsg->ipaddr->addr;
- netmask.addr = pmsg->netmask->addr;
- gw.addr = pmsg->gw->addr;
-
- NSPOL_LOGINF (NETIF_DEBUG, "do_netifapi_netif_add \n");
- netif = netif_add (pmsg->netif,
- &ipaddr,
- &netmask, &gw, pmsg->state, pmsg->init, pmsg->input);
-
- if (NULL == netif)
- {
- SET_MSG_ERR (m, ERR_IF);
- }
- else
- {
-
- SET_MSG_ERR (m, ERR_OK);
- NSPOL_LOGINF (NETIF_DEBUG, "netif created name %c%c%d\n",
- netif->name[0], netif->name[1], netif->num);
- pmsg->voidfunc (pmsg->netif);
- add_disp_netif (pmsg->netif);
- }
-
-}
-
-err_t
-spl_netifapi_netif_add (struct netif *pnetif,
- spl_ip_addr_t * ipaddr,
- spl_ip_addr_t * netmask,
- spl_ip_addr_t * gw,
- void *state,
- netif_init_fn init,
- netif_input_fn input, netifapi_void_fn voidfunc)
-{
- msg_add_netif stmsg;
-
- stmsg.function = do_netifapi_netif_add;
- stmsg.netif = pnetif;
- stmsg.ipaddr = ipaddr;
- stmsg.netmask = netmask;
- stmsg.gw = gw;
- stmsg.state = state;
- stmsg.init = init;
- stmsg.input = input;
- stmsg.voidfunc = voidfunc;
- return tcpip_netif_add (&stmsg);
-}
-
-int
-add_netif_ip (char *netif_name, unsigned int ip, unsigned int mask)
-{
- struct netif *pnetif;
- int retval;
-
- if (get_netif_by_ip (ip))
- {
- NSPOL_LOGERR ("ip is exist]IP=%s", inet_ntoa (ip));
- return -1;
- }
- NSPOL_LOGINF (NETIF_DEBUG, "add_netif_ip] IP=%s", inet_ntoa (ip));
-
- pnetif = find_netif_by_if_name (netif_name);
- if (pnetif == NULL)
- {
- return -1;
- }
-
- pnetif->ip_addr.addr = ip;
- pnetif->netmask.addr = mask;
-
- if (ip)
- {
- retval = etharp_request (pnetif, &pnetif->ip_addr);
-
- if (ERR_OK != retval)
- {
- NSPOL_LOGERR ("etharp_request failed]retval=%d,netif=%p,ip=%u", retval, pnetif, pnetif->ip_addr.addr); //inet_ntoa is not thread-safe, print u32 instead.
- }
- }
-
- NSPOL_LOGINF (NETIF_DEBUG, "add_netif_ip]netif_name=%s,IP=%s,mask=0x%08x",
- netif_name, inet_ntoa (ip), spl_htonl (mask));
- return 0;
-}
-
-/*lint -e438*/
-int
-del_netif_ip (char *netif_name, unsigned int ip)
-{
- struct netif *pnetif;
- //struct netif* vnetif = NULL;
- //struct netif** ref;
-
- pnetif = find_netif_by_if_name (netif_name);
- if (NULL == pnetif)
- {
- return -1;
- }
-
- NSPOL_LOGINF (NETIF_DEBUG, "del_netif_ip] IP=%s", inet_ntoa (ip));
-
- pnetif->ip_addr.addr = 0;
- pnetif->netmask.addr = 0;
- return 0;
-}
-
-REGIST_MSG_MODULE_MAJOR_FUN (MSG_MODULE_HAL, SPL_TCPIP_MSG_NETIFAPI,
- do_halmsg);
-REGIST_MSG_MODULE_MAJOR_MINOR_FUN (MSG_MODULE_HAL, SPL_TCPIP_MSG_NETIFAPI,
- NETIF_DO_ADD, _do_add_netif);
-
-#endif /* STACKX_NETIF_API */
diff --git a/stacks/lwip_stack/lwip_src/api/spl_sbr.c b/stacks/lwip_stack/lwip_src/api/spl_sbr.c
deleted file mode 100644
index 4c1be2f..0000000
--- a/stacks/lwip_stack/lwip_src/api/spl_sbr.c
+++ /dev/null
@@ -1,495 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "stackx_spl_share.h"
-#include "spl_api.h"
-#include "ip.h"
-#include "spl_api_msg.h"
-#include "stackx_spl_msg.h"
-#include "internal_msg.h"
-#include "spl_sbr.h"
-#include "spl_pbuf.h"
-
-/**
- * common operation for sbr message.
- *
- * @param msg the api_msg_msg describing the connection type
- */
-int
-do_sbrmsg (data_com_msg * m)
-{
- return 0;
-}
-
-/**
- * Create a new pcb of a specific type inside a netconn.
- * Called from netconn_new_with_proto_and_callback.
- *
- * @param msg the api_msg_msg describing the connection type
- */
-static int
-_do_newconn (data_com_msg * m)
-{
- m->param.err = ERR_OK;
-
- msg_new_netconn *_m = (msg_new_netconn *) m->buffer;
- m->param.err = spl_pcb_new (_m);
-
- if (ERR_OK != m->param.err)
- {
- NSPOL_LOGERR ("pcb_new err]conn=%p,pid=%u,err=%d", _m->conn,
- m->param.recycle_pid, m->param.err);
- goto ERROR;
- }
-
- NSFW_LOGINF ("alloc pcb]conn=%p,pcb=%p,pid=%u", _m->conn,
- _m->conn->private_data, m->param.recycle_pid);
-
- /* sbr use it to set receiver after new connction */
- m->param.receiver = (i64) & _m->conn->private_data;
- m->param.comm_receiver = (i64) & _m->conn->comm_pcb_data;
- _m->conn->recv_obj = m->param.receiver;
-
- SYNC_MSG_ACK (m);
- return 0;
-
-ERROR:
- SYNC_MSG_ACK (m);
- return 0;
-}
-
-int
-_do_connect (data_com_msg * m)
-{
- m->param.err = ERR_OK;
-
- struct common_pcb *cpcb = COMM_PRIVATE_PTR (m);
- if (cpcb == NULL)
- {
- m->param.err = ERR_CLSD;
- SYNC_MSG_ACK (m);
- return 0;
- }
-
- msg_connect *_m = (msg_connect *) m->buffer;
- do_connect (cpcb, _m);
-
- /**
- * err == ERR_OK only applies for blocking connction, so others mean
- * in progress for nonblocking connection or failed to connect
- * cpcb may be NULL, so don't change the order of the 2 ifs.
- */
- if (m->param.err != ERR_OK || cpcb->type != SPL_NETCONN_TCP)
- SYNC_MSG_ACK (m);
-
- return 0;
-}
-
-/**
- * Close a TCP pcb contained in a netconn
- * Called from netconn_close
- *
- * @param msg the api_msg_msg pointing to the connection
- */
-int
-_do_close (data_com_msg * m)
-{
- m->param.err = ERR_OK;
-
- struct common_pcb *cpcb = COMM_PRIVATE_PTR (m);
- if (cpcb != NULL)
- {
- msg_close *_m = (msg_close *) m->buffer;
- do_close (cpcb, _m);
- }
-
- /* if cpcb == NULL, assuming the close is okay, err = ERR_OK */
- SYNC_MSG_ACK (m);
-
- return 0;
-}
-
-/**
- * Delete the pcb inside a netconn.
- * Called from netconn_delete.
- *
- * @param msg the data_com_msg to handle
- */
-static int
-_do_delconn (data_com_msg * m)
-{
- m->param.err = ERR_OK;
- msg_delete_netconn *_m = (msg_delete_netconn *) m->buffer;
-
- if (0 == (--_m->msg_box_ref))
- {
- /* the aync msg is released inside */
- ss_recycle_conn ((void *) _m, do_try_delconn);
- }
-
- return 0;
-}
-
-/**
- * handle message to send UDP packets.
- *
- * @param msg the data_com_msg to handle
- */
-static int
-_do_send (data_com_msg * m)
-{
- m->param.err = ERR_OK;
-
- struct common_pcb *cpcb = COMM_PRIVATE_PTR (m);
- msg_send_buf *_m = (msg_send_buf *) m->buffer;
- if (cpcb == NULL)
- {
- NS_LOG_CTRL (LOG_CTRL_SEND, STACKX, "NSLWIP", NSLOG_ERR,
- "failed to find target pcb, drop the message]"
- "module=%u, major=%u, minor=%u",
- m->param.module_type,
- m->param.major_type, m->param.minor_type);
-
- spl_pbuf_free (_m->p);
- _m->p = NULL;
- ASYNC_MSG_FREE (m);
- return -1;
- }
-
- do_send (cpcb, _m);
-
- ASYNC_MSG_FREE (m);
-
- return 0;
-}
-
-/**
- * handle message to send TCP packets.
- *
- * @param msg the data_com_msg to handle
- */
-static int
-_do_write (data_com_msg * m)
-{
- m->param.err = ERR_OK;
-
- void *tpcb = TCP_PRIVATE_PTR (m);
- struct common_pcb *cpcb = COMM_PRIVATE_PTR (m);
-
- msg_write_buf *_m = (msg_write_buf *) m->buffer;
- if ((tpcb == NULL) || (cpcb == NULL))
- {
- NS_LOG_CTRL (LOG_CTRL_WRITE, STACKX, "NSLWIP", NSLOG_ERR,
- "failed to find target pcb, drop the message]"
- "module=%u, major=%u, minor=%u",
- m->param.module_type,
- m->param.major_type, m->param.minor_type);
-
- spl_pbuf_free (_m->p);
- _m->p = NULL;
- ASYNC_MSG_FREE (m);
- return -1;
- }
-
- do_write (cpcb, _m);
-
- return 0;
-}
-
-/**
- * handle message to receive.
- *
- * @param msg the data_com_msg to handle
- */
-static int
-_do_recv (data_com_msg * m)
-{
- m->param.err = ERR_OK;
-
- msg_recv_buf *_m = (msg_recv_buf *) m->buffer;
- void *tpcb = TCP_PRIVATE_PTR (m);
- struct common_pcb *cpcb = COMM_PRIVATE_PTR (m);
-
- if ((tpcb == NULL) || (cpcb == NULL))
- {
- NS_LOG_CTRL (LOG_CTRL_RECV, STACKX, "NSLWIP", NSLOG_ERR,
- "failed to find target pcb, drop the message]"
- "module=%u, major=%u, minor=%u",
- m->param.module_type,
- m->param.major_type, m->param.minor_type);
-
- spl_pbuf_free (_m->p);
- _m->p = NULL;
- ASYNC_MSG_FREE (m);
- return -1;
- }
-
- do_recv (cpcb, _m);
- ASYNC_MSG_FREE (m);
- return 0;
-}
-
-/**
- * handle message to bind local address.
- *
- * @param msg the data_com_msg to handle
- */
-static int
-_do_bind (data_com_msg * m)
-{
- m->param.err = ERR_OK;
-
- struct common_pcb *cpcb = COMM_PRIVATE_PTR (m);
- if (cpcb == NULL)
- {
- NSPOL_LOGERR ("failed to find target pcb, drop the message]"
- "module=%u, major=%u, minor=%u",
- m->param.module_type,
- m->param.major_type, m->param.minor_type);
-
- m->param.err = ERR_VAL;
- SYNC_MSG_ACK (m);
- return -1;
- }
-
- msg_bind *_m = (msg_bind *) m->buffer;
- do_bind (cpcb, _m);
-
- SYNC_MSG_ACK (m);
-
- return 0;
-}
-
-/**
- * handle message to listen for new connection.
- *
- * @param msg the data_com_msg to handle
- */
-static int
-_do_listen (data_com_msg * m)
-{
- m->param.err = ERR_OK;
-
- struct common_pcb *cpcb = COMM_PRIVATE_PTR (m);
- if (cpcb == NULL)
- {
- NSPOL_LOGERR ("failed to find target pcb, drop the message]"
- "module=%u, major=%u, minor=%u",
- m->param.module_type,
- m->param.major_type, m->param.minor_type);
-
- m->param.err = ERR_CONN;
- SYNC_MSG_ACK (m);
- return -1;
- }
-
- msg_listen *_m = (msg_listen *) m->buffer;
- do_listen (cpcb, _m);
-
- /* Update since pcb may have been changed */
- //m->param.receiver = (i64)&_m->conn->private_data;
- SYNC_MSG_ACK (m);
- return 0;
-}
-
-/**
- * handle message to set socket option.
- *
- * @param msg the data_com_msg to handle
- */
-static int
-_do_setsockopt (data_com_msg * m)
-{
- m->param.err = ERR_OK;
-
- struct common_pcb *cpcb = COMM_PRIVATE_PTR (m);
- if (cpcb == NULL)
- {
-
- NSPOL_LOGERR ("failed to find target pcb, drop the message]"
- "module=%u, major=%u, minor=%u",
- m->param.module_type,
- m->param.major_type, m->param.minor_type);
-
- m->param.err = ERR_VAL;
- SYNC_MSG_ACK (m);
- return -1;
- }
-
- msg_setgetsockopt *_m = (msg_setgetsockopt *) m->buffer;
- do_setsockopt_internal (cpcb, _m);
-
- SYNC_MSG_ACK (m);
-
- return 0;
-}
-
-/**
- * handle message to get socket option.
- *
- * @param msg the data_com_msg to handle
- */
-static int
-_do_getsockopt (data_com_msg * m)
-{
- m->param.err = ERR_OK;
-
- struct common_pcb *cpcb = COMM_PRIVATE_PTR (m);
- if (cpcb == NULL)
- {
- NSPOL_LOGERR ("failed to find target pcb, drop the message]"
- "module=%u, major=%u, minor=%u",
- m->param.module_type,
- m->param.major_type, m->param.minor_type);
-
- m->param.err = ERR_VAL;
- SYNC_MSG_ACK (m);
- return -1;
- }
-
- msg_setgetsockopt *_m = (msg_setgetsockopt *) m->buffer;
- do_getsockopt_internal (cpcb, _m);
-
- SYNC_MSG_ACK (m);
-
- return 0;
-}
-
-/**
- * handle message to free pbuf which never used afterwards by application.
- *
- * @param msg the data_com_msg to handle
- */
-
-static int
-_do_pbuf_free (data_com_msg * m)
-{
- m->param.err = ERR_OK;
-
- msg_free_buf *_m = (msg_free_buf *) m->buffer;
- do_pbuf_free (_m->buf);
-
- ASYNC_MSG_FREE (m);
-
- return 0;
-}
-
-static int
-_do_getsock_name (data_com_msg * m)
-{
- m->param.err = ERR_OK;
-
- struct common_pcb *cpcb = COMM_PRIVATE_PTR (m);
- if (cpcb == NULL)
- {
- NSPOL_LOGERR ("failed to find target pcb, drop the message]"
- "module=%u, major=%u, minor=%u",
- m->param.module_type,
- m->param.major_type, m->param.minor_type);
-
- m->param.err = ERR_VAL;
- SYNC_MSG_ACK (m);
- return -1;
- }
-
- msg_getaddrname *_m = (msg_getaddrname *) m->buffer;
- do_getsockname (cpcb, _m);
-
- SYNC_MSG_ACK (m);
-
- return 0;
-}
-
-/* app send its version info to nStackMain */
-static int
-_do_app_touch (data_com_msg * m)
-{
- m->param.err = ERR_OK;
-
- msg_app_touch *_m = (msg_app_touch *) m->buffer;
- do_app_touch (_m);
-
- ASYNC_MSG_FREE (m);
- return 0;
-}
-
-/**
- * process message from sbr module, all the processing function
- * is registered when nstack is up.
- *
- * @param msg the api_msg_msg pointing to the connection
- */
-int
-spl_sbr_process (data_com_msg * m)
-{
- if (m == NULL)
- {
- NSPOL_LOGERR ("message is NULL");
- return -1;
- }
-
- return call_msg_fun (m);
-}
-
-int
-spl_unsupport_process (data_com_msg * m)
-{
- NSPOL_LOGINF (TCPIP_DEBUG, "module_type=%u,major_type=%u,minor_type=%u",
- m->param.module_type, m->param.major_type,
- m->param.minor_type);
- if (MSG_SYN_POST == m->param.op_type)
- {
- m->param.err = ERR_EPROTONOSUPPORT;
- SYNC_MSG_ACK (m);
- }
- else
- {
- ASYNC_MSG_FREE (m);
- }
-
- return -1;
-}
-
-REGIST_MSG_UNSUPPORT_FUN (spl_unsupport_process);
-REGIST_MSG_MODULE_MAJOR_FUN (MSG_MODULE_SBR, SPL_TCPIP_NEW_MSG_API,
- do_sbrmsg);
-REGIST_MSG_MODULE_MAJOR_MINOR_FUN (MSG_MODULE_SBR, SPL_TCPIP_NEW_MSG_API,
- SPL_API_DO_NEWCONN, _do_newconn);
-REGIST_MSG_MODULE_MAJOR_MINOR_FUN (MSG_MODULE_SBR, SPL_TCPIP_NEW_MSG_API,
- SPL_API_DO_CONNECT, _do_connect);
-REGIST_MSG_MODULE_MAJOR_MINOR_FUN (MSG_MODULE_SBR, SPL_TCPIP_NEW_MSG_API,
- SPL_API_DO_CLOSE, _do_close);
-REGIST_MSG_MODULE_MAJOR_MINOR_FUN (MSG_MODULE_SBR, SPL_TCPIP_NEW_MSG_API,
- SPL_API_DO_DELCON, _do_delconn);
-REGIST_MSG_MODULE_MAJOR_MINOR_FUN (MSG_MODULE_SBR, SPL_TCPIP_NEW_MSG_API,
- SPL_API_DO_SEND, _do_send);
-REGIST_MSG_MODULE_MAJOR_MINOR_FUN (MSG_MODULE_SBR, SPL_TCPIP_NEW_MSG_API,
- SPL_API_DO_WRITE, _do_write);
-REGIST_MSG_MODULE_MAJOR_MINOR_FUN (MSG_MODULE_SBR, SPL_TCPIP_NEW_MSG_API,
- SPL_API_DO_RECV, _do_recv);
-REGIST_MSG_MODULE_MAJOR_MINOR_FUN (MSG_MODULE_SBR, SPL_TCPIP_NEW_MSG_API,
- SPL_API_DO_BIND, _do_bind);
-REGIST_MSG_MODULE_MAJOR_MINOR_FUN (MSG_MODULE_SBR, SPL_TCPIP_NEW_MSG_API,
- SPL_API_DO_LISTEN, _do_listen);
-REGIST_MSG_MODULE_MAJOR_MINOR_FUN (MSG_MODULE_SBR, SPL_TCPIP_NEW_MSG_API,
- SPL_API_DO_GET_SOCK_OPT, _do_getsockopt);
-REGIST_MSG_MODULE_MAJOR_MINOR_FUN (MSG_MODULE_SBR, SPL_TCPIP_NEW_MSG_API,
- SPL_API_DO_SET_SOCK_OPT, _do_setsockopt);
-REGIST_MSG_MODULE_MAJOR_MINOR_FUN (MSG_MODULE_SBR, SPL_TCPIP_NEW_MSG_API,
- SPL_API_DO_PBUF_FREE, _do_pbuf_free);
-REGIST_MSG_MODULE_MAJOR_MINOR_FUN (MSG_MODULE_SBR, SPL_TCPIP_NEW_MSG_API,
- SPL_API_DO_GETSOCK_NAME, _do_getsock_name);
-REGIST_MSG_MODULE_MAJOR_MINOR_FUN (MSG_MODULE_SBR, SPL_TCPIP_NEW_MSG_API, SPL_API_DO_APP_TOUCH, _do_app_touch); /* app send its version info to nStackMain */
diff --git a/stacks/lwip_stack/lwip_src/api/spl_tcpip.c b/stacks/lwip_stack/lwip_src/api/spl_tcpip.c
deleted file mode 100644
index b0b588a..0000000
--- a/stacks/lwip_stack/lwip_src/api/spl_tcpip.c
+++ /dev/null
@@ -1,1547 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "spl_opt.h"
-#include <pthread.h>
-#include <sched.h>
-#include <signal.h>
-#include "memp.h"
-#include "mem.h"
-#include "spl_pbuf.h"
-//#include "sockets.h"
-//#include <netinet/in.h>
-
-#include "stackx_spl_share.h"
-#include "spl_api.h"
-#include "spl_tcpip.h"
-#include "init.h"
-#include "stackx/internal_msg.h"
-#include "netif/sc_dpdk.h"
-#include "sharedmemory.h"
-#include "stackx_instance.h"
-#include "netif/common.h"
-//#include "nettool/nettool.h"
-#include "nstack_log.h"
-#include "nstack_securec.h"
-#include "spl_hal.h"
-#include "spl_sbr.h"
-#include "spl_tcpip.h"
-
-#include "spl_instance.h"
-#include "nsfw_mem_api.h"
-#include "nsfw_msg_api.h"
-#include "configuration_reader.h"
-
-#include "nsfw_ps_api.h"
-#include "alarm_api.h"
-#include "nstack_share_res.h"
-#include "spl_timers.h"
-
-#include "etharp.h"
-#include "raw.h"
-#include "udp.h"
-#include "tcp.h"
-#include "igmp.h"
-#include "memp.h"
-#include "inet.h"
-#include "sys_arch.h"
-
-#include "sys.h"
-
-#define NSTACK_MAIN_MAX_PARA 32
-#define NSTACK_MAIN_MIN_PARA 1
-
-#define DPDK_DEFAULT_EAL_MEM_SIZE (1024)
-
-#define OPT_EAL_MEM_SIZE "--eal-mem-size="
-
-/********************/
-/* extern variables */
-/********************/
-extern mring_handle spl_get_msg_pool ();
-extern mring_handle spl_get_conn_pool ();
-extern u32 spl_get_conn_num ();
-extern err_t ethernet_input (struct pbuf *p, struct netif *netif);
-
-/* tcpip main thread sleep time, configured by user(nStackMain "-sleep" option) */
-extern int g_tcpip_thread_sleep_time;
-
-/* netif related */
-extern struct stackx_port_info *head_used_port_list;
-
-extern u32_t uStackArgIndex;
-
-extern int g_tcpip_thread_stat;
-
-/********************/
-/* global variables */
-/********************/
-
-/* timer thread id */
-sys_thread_t g_timerThread_id = 0;
-
-/*Add an associative mapping relationship to p_stackx_instance based on lcore_id */
-
-int globalArgc = 0;
-
-/* Set different mem args to PAL and EAL */
-char **gArgv = NULL;
-
-int g_dpdk_argc = 0;
-char **g_dpdk_argv = NULL;
-
-/*The sum of the four queue processing messages does not exceed TASK_BURST*/
-static u32 g_highestMboxNum = 12;
-static u32 g_mediumMboxNum = 8;
-static u32 g_lowestMboxNum = 4;
-static u32 g_primaryMboxNum = 8;
-
-/* [set ip_tos2prio size to IPTOS_TOS_MASK >> 1) + 1] */
-u8_t ip_tos2prio[(IPTOS_TOS_MASK >> 1) + 1] = {
- TC_PRIO_BESTEFFORT,
- ECN_OR_COST (FILLER),
- TC_PRIO_BESTEFFORT,
- ECN_OR_COST (BESTEFFORT),
- TC_PRIO_BULK,
- ECN_OR_COST (BULK),
- TC_PRIO_BULK,
- ECN_OR_COST (BULK),
- TC_PRIO_INTERACTIVE,
- ECN_OR_COST (INTERACTIVE),
- TC_PRIO_INTERACTIVE,
- ECN_OR_COST (INTERACTIVE),
- TC_PRIO_INTERACTIVE_BULK,
- ECN_OR_COST (INTERACTIVE_BULK),
- TC_PRIO_INTERACTIVE_BULK,
- ECN_OR_COST (INTERACTIVE_BULK)
-};
-
-/********************/
-/* extern functions */
-/********************/
-extern err_t ethernetif_init (struct netif *pnetif);
-extern int nstack_stackx_init (int flag);
-extern void tcp_sys_rmem_init ();
-extern void ethernetif_packets_input (struct netif *pstnetif);
-
-/********************************/
-/* function forward declaration */
-/********************************/
-
-static inline u32 priority_sched_mbox (struct stackx_stack *share_memory,
- void **box, u32 n);
-static inline char
-rt_tos2priority (u8_t tos)
-{
- return ip_tos2prio[IPTOS_TOS (tos) >> 1];
-}
-
-u64
-timer_get_threadid ()
-{
- return g_timerThread_id;
-}
-
-#if (DPDK_MODULE != 1)
-NSTACK_STATIC inline void
-do_recv_task (struct disp_netif_list *dnlist, u16 index_task)
-{
- struct netifExt *pnetifExt = NULL;
-
- while (dnlist)
- {
- struct netif *currentNetif = dnlist->netif;
- dnlist = dnlist->next;
-
- pnetifExt = getNetifExt (currentNetif->num);
- if (NULL == pnetifExt)
- return;
-
- if (currentNetif != NULL && pnetifExt->num_packets_recv > index_task)
- {
- ethernetif_packets_input (currentNetif);
- }
- }
-}
-
-static inline int
-is_valid_sleep_time (int sleep_time)
-{
-#define TCP_IP_THREAD_MAX_SLEEP_TIME 500
- if ((sleep_time < 0) || (sleep_time > TCP_IP_THREAD_MAX_SLEEP_TIME))
- {
- return 0;
- }
-
- return 1;
-}
-
-static int
-thread_init ()
-{
- sigset_t mask;
-
- if (0 != sigemptyset (&mask))
- {
- NSTCP_LOGERR ("sigemptyset function call error");
- return -1;
- }
-
- if (0 != sigaddset (&mask, SIGRTMIN))
- {
- NSTCP_LOGERR ("sigaddset function call error");
- return -1;
- }
-
- if ((pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL) != 0)
- || (pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL) != 0))
- {
- NSTCP_LOGERR ("pthread setcancel function call error");
- return -1;
- }
-
- if (pthread_sigmask (SIG_BLOCK, &mask, NULL) != 0)
- {
- NSPOL_LOGERR ("pthread_sigmask function call error");
- return -1;
- }
-
- return 0;
-}
-
-alarm_result
-spl_socket_resource_check_func (void)
-{
-
- mring_handle conn_ring = spl_get_conn_pool ();
- unsigned int rate_use = 0;
- alarm_result ret_alarm;
- u32 ring_size = 0, ring_not_used_count = 0;
- u32 socket_num = spl_get_conn_num ();
-
- ring_size = nsfw_mem_ring_size (conn_ring);
-
- if (0 == socket_num)
- {
- /* assign a valid id, then return */
- ret_alarm.alarm_id_get = ALARM_EVENT_MAX;
- return ret_alarm;
- }
-
- ring_not_used_count = nsfw_mem_ring_using_count (conn_ring);
-
- rate_use = (ring_size - ring_not_used_count) * 100 / socket_num;
-
- ret_alarm.alarm_id_get = ALARM_EVENT_NSTACK_RESOURCE_ALARM;
-
- if (rate_use >= USEAGE_HIGHT)
- {
- ret_alarm.alarm_flag_get = ALARM_PRODUCT;
- ret_alarm.alarm_id_get = ALARM_EVENT_NSTACK_RESOURCE_ALARM;
- NSPOL_LOGWAR (TCPIP_DEBUG,
- "app using too much socket resources,the rate is bigger than 80%");
- }
- else if (rate_use <= USEAGE_LOW)
- {
- ret_alarm.alarm_flag_get = ALARM_CLEAN;
- ret_alarm.alarm_id_get = ALARM_EVENT_NSTACK_RESOURCE_ALARM;
- }
- else
- {
- ret_alarm.alarm_id_get = ALARM_EVENT_MAX;
- }
-
- ret_alarm.alarm_reason_get = ALARM_REASON_SOCKET;
-
- return ret_alarm;
-
-}
-
-alarm_result
-spl_msg_buf_resource_check_func (void)
-{
-
- mring_handle msg_ring = spl_get_msg_pool ();
- unsigned int rate_use = 0;
- alarm_result ret_alarm;
- u32 ring_size = 0, ring_not_used_count = 0;
-
- ring_size = nsfw_mem_ring_size (msg_ring);
-
- if (0 == ring_size)
- {
- /* assign a valid id, then return */
- ret_alarm.alarm_id_get = ALARM_EVENT_MAX;
- return ret_alarm;
- }
-
- ring_not_used_count = nsfw_mem_ring_using_count (msg_ring);
-
- rate_use = (ring_size - ring_not_used_count) * 100 / ring_size;
-
- ret_alarm.alarm_id_get = ALARM_EVENT_NSTACK_RESOURCE_ALARM;
-
- if (rate_use >= USEAGE_HIGHT)
- {
- ret_alarm.alarm_flag_get = ALARM_PRODUCT;
- ret_alarm.alarm_id_get = ALARM_EVENT_NSTACK_RESOURCE_ALARM;
- }
- else if (rate_use <= USEAGE_LOW)
- {
- ret_alarm.alarm_flag_get = ALARM_CLEAN;
- ret_alarm.alarm_id_get = ALARM_EVENT_NSTACK_RESOURCE_ALARM;
- }
- else
- {
- ret_alarm.alarm_id_get = ALARM_EVENT_MAX;
- }
-
- ret_alarm.alarm_reason_get = ALARM_REASON_MSG_BUF;
-
- return ret_alarm;
-
-}
-
-NSTACK_STATIC int
-tcpip_thread_init ()
-{
- if (thread_init () != 0)
- {
- return -1;
- }
-
- if (!is_valid_sleep_time (g_tcpip_thread_sleep_time))
- {
- g_tcpip_thread_sleep_time = 0;
- }
-
- alarm_para tcp_alarm_para;
- tcp_alarm_para.period_alarm.time_length = 5; /* 5 second period */
- tcp_alarm_para.alarm_reason_count = 2; /*both resource */
- tcp_alarm_para.func_alarm_check_period[0] = spl_socket_resource_check_func;
- tcp_alarm_para.alarm_reason_set[0] = ALARM_REASON_SOCKET;
- tcp_alarm_para.func_alarm_check_period[1] = spl_msg_buf_resource_check_func;
- tcp_alarm_para.alarm_reason_set[1] = ALARM_REASON_MSG_BUF;
- (void) ns_reg_alarm (ALARM_EVENT_NSTACK_RESOURCE_ALARM, ALARM_PERIOD_CHECK,
- &tcp_alarm_para);
-
- ns_send_init_alarm (ALARM_EVENT_NSTACK_RESOURCE_ALARM);
-
- printmeminfo ();
- return 0;
-}
-
-sys_mbox_t
-get_primary_box ()
-{
- return &p_def_stack_instance->lstack.primary_mbox;
-}
-
-NSTACK_STATIC inline u16
-tcpip_netif_recv (struct disp_netif_list * nif_list)
-{
-
- u16 num_recv_task = 0, netif_packet_num;
-
- struct netif *tmpnetif = NULL;
- struct netifExt *pnetifExt = NULL;
-
- while (nif_list)
- {
- tmpnetif = nif_list->netif;
-
- netif_packet_num = spl_hal_recv (tmpnetif, 0);
- pnetifExt = getNetifExt (tmpnetif->num);
- if (NULL == pnetifExt)
- return 0;
-
- /* store the packet number in each netif */
- pnetifExt->num_packets_recv = netif_packet_num;
-
- /**
- * num_recv_task is the maximum packets of the netif among
- * all the netifs.
- */
- if (num_recv_task < netif_packet_num)
- {
- num_recv_task = netif_packet_num;
- }
-
- nif_list = nif_list->next;
- }
-
- return num_recv_task;
-}
-
-NSTACK_STATIC inline void
-no_task_in_one_loop ()
-{
-}
-
-#endif
-
-/**
- * Pass a received packet to tcpip_thread for input processing
- *
- * @param p the received packet, p->payload pointing to the Ethernet header or
- * to an IP header (if inp doesn't have NETIF_FLAG_ETHARP or
- * SPL_NETIF_FLAG_ETHERNET flags)
- * @param inp the network interface on which the packet was received
- */
-err_t
-spl_tcpip_input (struct pbuf *p, struct netif *inp)
-{
- err_t ret;
- NSPOL_LOGINF (TCPIP_DEBUG, "PACKET]p=%p,inp=%p", (void *) p, (void *) inp);
- print_pbuf_payload_info (p, false);
-
- /* every netif has been set NETIF_FLAG_ETHARP flag, no need else branch */
- ret = ethernet_input (p, inp);
- return ret;
-}
-
-int
-_do_spl_callback_msg (data_com_msg * m)
-{
- NSPOL_LOGDBG (TCPIP_DEBUG, "tcpip_thread: CALLBACK]msg=%p", (void *) m);
-
- m->param.err = ERR_OK;
-
- msg_internal_callback *callback = (msg_internal_callback *) (m->buffer);
- if (!callback->function)
- {
- NSTCP_LOGERR ("function ptr is null in SPL_TCPIP_MSG_CALLBACK msg");
- ASYNC_MSG_FREE (m);
- return 0;
- }
-
- callback->function (callback->ctx);
- ASYNC_MSG_FREE (m);
-
- return 0;
-}
-
-/*****************************************************************************
-* Prototype : get_msgbox
-* Description : According to the socket tos value to determine which priority queue to send
-* Input : struct stackx_stack *sharedmemory, struct netconn *conn, enum api_msg_type type
-* Output : Queue pointer
-* Return Value : Queue pointer
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-struct queue *
-get_msgbox (int tos)
-{
- struct stackx_stack *sharedmemory = &p_def_stack_instance->lstack;
-
- if ((MSG_PRIO_QUEUE_NUM < 3) || (0 == tos))
- {
- return &sharedmemory->primary_mbox;
- }
-
- char prio = rt_tos2priority ((u8_t) tos);
- if ((TC_PRIO_INTERACTIVE == prio))
- {
- NSPOL_LOGDBG (SOCKETS_DEBUG, "sent to the highest mbox.....");
- return &sharedmemory->priority_mbox[0];
- }
- else if ((TC_PRIO_BESTEFFORT == prio) || (TC_PRIO_INTERACTIVE_BULK == prio))
- {
- NSPOL_LOGDBG (SOCKETS_DEBUG, "sent to the medium mbox.....");
- return &sharedmemory->priority_mbox[1];
- }
- else if ((TC_PRIO_BULK == prio) || (TC_PRIO_FILLER == prio))
- {
- NSPOL_LOGDBG (SOCKETS_DEBUG, "sent to the lowest mbox.....");
- return &sharedmemory->priority_mbox[2];
- }
-
- NSPOL_LOGDBG (SOCKETS_DEBUG, "sent to the primary mbox.....");
- return &sharedmemory->primary_mbox;
-}
-
-/*****************************************************************************
-* Prototype : priority_sched_mbox
-* Description : According to the priority from the message queue to take
-* the message to deal with each cycle to take the total number of messages
-* not exceed to TASK_BURST
-* Input : struct stackx_stack *sharedmemory, struct netconn *conn, enum api_msg_type type
-* Output : Queue pointer
-* Return Value : Queue pointer
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline u32
-priority_sched_mbox (struct stackx_stack *share_memory, void **box, u32 n)
-{
- /* high:primary:medium:low -> 3:2:2:1(total:TASK_BURST) */
- if (unlikely
- ((g_highestMboxNum + g_mediumMboxNum + g_primaryMboxNum +
- g_lowestMboxNum) != n))
- {
- g_mediumMboxNum = n >> 2;
- g_lowestMboxNum = n >> 3;
- g_primaryMboxNum = n >> 2;
- g_highestMboxNum =
- n - g_mediumMboxNum - g_primaryMboxNum - g_lowestMboxNum;
- }
-
- u32 highestMboxNum = g_highestMboxNum;
- u32 primaryMboxNum = g_primaryMboxNum;
- u32 lowestMboxNum = g_lowestMboxNum;
- u32 mediumMboxNum = g_mediumMboxNum;
-
- u32 totalNum = 0;
- u32 num = 0;
- u32 oldLowestNum = 0;
-
- num = nsfw_mem_ring_dequeuev (share_memory->priority_mbox[0].llring,
- (box + totalNum), highestMboxNum);
- if (unlikely (num > highestMboxNum))
- {
- num = highestMboxNum;
- NSTCP_LOGERR
- ("something wrong:num>highestMboxNum]num=%u,highestMboxNum=%u", num,
- highestMboxNum);
- }
-
- totalNum += num;
-
- u32 temp = highestMboxNum - num;
- /* bisect the left number of highest */
- primaryMboxNum += (temp >> 1);
- mediumMboxNum += temp - (temp >> 1);
-
- num = nsfw_mem_ring_dequeuev (share_memory->priority_mbox[1].llring,
- (box + totalNum), mediumMboxNum);
- if (unlikely (num > mediumMboxNum))
- {
- num = mediumMboxNum;
- NSTCP_LOGERR
- ("something wrong.num>mediumMboxNum]num=%u,mediumMboxNum=%u", num,
- mediumMboxNum);
- }
-
- totalNum += num;
- primaryMboxNum += mediumMboxNum - num; //occupy the left number of medium
-
- /* dynamically adjust g_mediumMboxNum and g_highestMboxNum, according to 'num' */
- oldLowestNum = g_mediumMboxNum;
- if (0 == num)
- {
- g_mediumMboxNum = 1;
- }
- else if (num < g_mediumMboxNum)
- {
- g_mediumMboxNum = num;
- }
- else
- {
- g_mediumMboxNum = n >> 2;
- }
-
- g_highestMboxNum += oldLowestNum - g_mediumMboxNum;
-
- num = nsfw_mem_ring_dequeuev (share_memory->primary_mbox.llring,
- (box + totalNum), primaryMboxNum);
- if (unlikely (num > primaryMboxNum))
- {
- num = primaryMboxNum;
- NSTCP_LOGERR
- ("something wrong.num>primaryMboxNum]num=%u,primaryMboxNum=%u", num,
- primaryMboxNum);
- }
-
- totalNum += num;
- lowestMboxNum += primaryMboxNum - num; //occupy the left number of primary
-
- /* dynamically adjust g_primaryMboxNum and g_highestMboxNum, according to 'num' */
- oldLowestNum = g_primaryMboxNum;
- if (0 == num)
- {
- g_primaryMboxNum = 1;
- }
- else if (num < g_primaryMboxNum)
- {
- g_primaryMboxNum = num;
- }
- else
- {
- g_primaryMboxNum = n >> 2;
- }
-
- g_highestMboxNum += oldLowestNum - g_primaryMboxNum;
-
- if (lowestMboxNum > (n - totalNum))
- {
- lowestMboxNum = n - totalNum;
- }
-
- num = nsfw_mem_ring_dequeuev (share_memory->priority_mbox[2].llring,
- (box + totalNum), lowestMboxNum);
- if (unlikely (num > lowestMboxNum))
- {
- num = lowestMboxNum;
- NSTCP_LOGERR
- ("something wrong.num>lowestMboxNum]num=%u,lowestMboxNum=%u", num,
- lowestMboxNum);
- }
-
- totalNum += num;
-
- /* dynamically adjust g_lowestMboxNum and g_highestMboxNum, according to 'num' */
- oldLowestNum = g_lowestMboxNum;
- if (0 == num)
- {
- g_lowestMboxNum = 1;
- }
- else if (num < g_lowestMboxNum)
- {
- g_lowestMboxNum = num;
- }
- else
- {
- g_lowestMboxNum = n >> 3;
- }
-
- g_highestMboxNum += oldLowestNum - g_lowestMboxNum;
-
- return totalNum;
-}
-
-/**
- * call ltt_apimsg in STACKX TIMER THREAD
- *
- * @param h function to be called on timeout
- * @param arg argument to pass to timeout function h
- * @return error code given back by the function that was called
- */
-err_t
-ltt_apimsg (sys_timeout_handler h, void *arg)
-{
- data_com_msg *p_msg_entry;
- sys_mbox_t mbox = get_primary_box ();
- if (sys_mbox_valid (&mbox))
- {
- if (-1 == spl_msg_malloc (&p_msg_entry))
- {
- NSPOL_LOGERR ("ltt_apimsg:spl_msg_malloc failed.");
- return -1;
- }
-
- p_msg_entry->param.module_type = MSG_MODULE_TIMER;
- p_msg_entry->param.major_type = SPL_TCPIP_MSG_TIMER;
- p_msg_entry->param.minor_type = TIMER_MSG_TIMEOUT;
- p_msg_entry->param.op_type = MSG_ASYN_POST;
-
- sys_sem_init (&p_msg_entry->param.op_completed);
-
- msg_timer *tmsg = (msg_timer *) (p_msg_entry->buffer);
- tmsg->act = h;
- tmsg->arg = arg;
-
- if (msg_post (p_msg_entry, mbox->llring) < 0)
- {
- NSPOL_LOGERR
- ("msg post is failed]module_type=%u, major_type=%u, minor_type=%u",
- p_msg_entry->param.module_type, p_msg_entry->param.major_type,
- p_msg_entry->param.minor_type);
- spl_msg_free (p_msg_entry);
- return ERR_VAL;
- }
-
- return ERR_OK;
- }
-
- NSPOL_LOGERR ("mbox is invalid");
- return ERR_VAL;
-}
-
-int
-_do_spl_timer_msg (data_com_msg * m)
-{
- NSPOL_LOGDBG (TESTSOCKET_DEBUG | STACKX_DBG_TRACE,
- "the msg is from TIMER module, minor(%u)",
- m->param.minor_type);
- return 0;
-}
-
-static int
-_do_timeout_handle (data_com_msg * m)
-{
- m->param.err = ERR_OK;
- msg_timer *tmo_msg = (msg_timer *) m->buffer;
- if (!tmo_msg->act)
- {
- NSTCP_LOGERR ("TIMER_MSG_TIMEOUT msg act is NULL");
- ASYNC_MSG_FREE (m);
- return -1;
- }
-
- timeout_phandler (tmo_msg->act, tmo_msg->arg);
- ASYNC_MSG_FREE (m);
- return 0;
-}
-
-static int
-_do_clear_timer (data_com_msg * m)
-{
- NSTCP_LOGDBG ("TIMER_CLEAR API]msg=%p", (void *) m);
-
- msg_timer *handle = (msg_timer *) (m->buffer);
- if (!handle->act)
- {
- NSTCP_LOGERR ("function ptr is null in TIMER_MSG_CLEAR msg");
- SET_MSG_ERR (m, ERR_VAL);
- return 0;
- }
-
- //stackxTcpPcbClearTimer((struct tcp_pcb *)handle->act, (unsigned long)handle->arg);
- spl_msg_free (m);
-
- return 0;
-}
-
-err_t
-ltt_clearTmrmsg (void *pcb, void *arg)
-{
- data_com_msg *p_msg_entry;
- sys_mbox_t mbox = get_primary_box ();
- if (sys_mbox_valid (&mbox))
- {
- if (-1 == spl_msg_malloc (&p_msg_entry) || (NULL == p_msg_entry))
- {
- NSPOL_LOGERR ("ltt_clearTmrmsg:spl_msg_malloc failed.");
- return -1;
- }
-
- p_msg_entry->param.module_type = MSG_MODULE_TIMER;
- p_msg_entry->param.major_type = SPL_TCPIP_MSG_TIMER;
- p_msg_entry->param.minor_type = TIMER_MSG_CLEAR;
- p_msg_entry->param.op_type = MSG_ASYN_POST;
- p_msg_entry->param.receiver = 0;
- sys_sem_init (&p_msg_entry->param.op_completed);
-
- msg_timer *tmo = (msg_timer *) (p_msg_entry->buffer);
- tmo->act = pcb;
- tmo->arg = arg;
-
- if (msg_post (p_msg_entry, mbox->llring) < 0)
- {
- NSPOL_LOGERR
- ("msg post is failed]module_type=%u, major_type=%u, minor_type=%u",
- p_msg_entry->param.module_type, p_msg_entry->param.major_type,
- p_msg_entry->param.minor_type);
- spl_msg_free (p_msg_entry);
- return ERR_VAL;
- }
-
- return ERR_OK;
- }
-
- NSPOL_LOGERR ("mbox is invalid");
- return ERR_VAL;
-}
-
-#if STACKX_NETIF_API
-err_t
-tcpip_netif_post (data_com_msg * m)
-{
- err_t err = ERR_OK;
- sys_mbox_t mbox = get_primary_box ();
-
- if (NULL == mbox || !sys_mbox_valid (&mbox))
- {
- NSPOL_LOGERR ("mbox not initialed well");
- err = ERR_MEM;
- goto err_exit;
- }
-
- if (NULL == mbox->llring)
- {
- int tryCount = 0;
-#define TCP_NETIF_WAITINIT_MAX_COUNT 10
- NSPOL_LOGWAR (TCPIP_DEBUG, "mbox->llring not initialed yet...");
- sys_sleep_ns (0, 100000000);
- while (!mbox->llring && (++tryCount < TCP_NETIF_WAITINIT_MAX_COUNT))
- {
- NSPOL_LOGWAR (TCPIP_DEBUG, "mbox->llring not initialed yet...");
- sys_sleep_ns (0, 100000000);
- }
-
- if (NULL == mbox->llring)
- {
- NSPOL_LOGERR ("failed to get a valid mbox->llring");
- err = ERR_MEM;
- goto err_exit;
- }
- }
-
- NSPOL_LOGINF (TCPIP_DEBUG, "post tcpip_netif_msg...");
-
- if (msg_post_with_lock_rel (m, mbox->llring) < 0)
- {
- err = ERR_VAL;
- }
- else
- {
- err = m->param.err;
- }
-
-err_exit:
- /* it's a sync message */
- spl_msg_free (m);
- return err;
-}
-
-/**
- * Much like tcpip_apimsg, but calls the lower part of a netifapi_*
- * function.
- *
- * @param netifapimsg a struct containing the function to call and its parameters
- * @return error code given back by the function that was called
- */
-err_t
-tcpip_netif_add (msg_add_netif * tmp)
-{
- data_com_msg *p_msg_entry = NULL;
- msg_add_netif *nmsg = NULL;
-
- if (spl_msg_malloc (&p_msg_entry) == -1)
- {
- NSPOL_LOGERR ("tcpip_netifapi:spl_msg_malloc failed.");
- return ERR_MEM;
- }
-
- p_msg_entry->param.module_type = MSG_MODULE_HAL;
- p_msg_entry->param.major_type = SPL_TCPIP_MSG_NETIFAPI;
- p_msg_entry->param.minor_type = NETIF_DO_ADD;
- p_msg_entry->param.op_type = MSG_SYN_POST;
- p_msg_entry->param.receiver = 0;
- sys_sem_init (&p_msg_entry->param.op_completed);
-
- nmsg = (msg_add_netif *) p_msg_entry->buffer;
- nmsg->function = tmp->function;
- nmsg->netif = tmp->netif;
- nmsg->ipaddr = tmp->ipaddr;
- nmsg->netmask = tmp->netmask;
- nmsg->gw = tmp->gw;
- nmsg->state = tmp->state;
- nmsg->init = tmp->init;
- nmsg->input = tmp->input;
- nmsg->voidfunc = tmp->voidfunc;
-
- return tcpip_netif_post (p_msg_entry);
-}
-
-#endif /* STACKX_NETIF_API */
-
-/* Added for congestion control, maybe not used end */
-
-extern err_t init_ptimer (void);
-extern struct cfg_item_info g_cfg_item_info[CFG_SEG_MAX][MAX_CFG_ITEM];
-
-/*=========== set share config for nStackMain =============*/
-static inline mzone_handle
-create_mem_zone (nsfw_mem_zone * zone_info)
-{
- return nsfw_mem_zone_create (zone_info);
-}
-
-static inline int
-set_zone_info (nsfw_mem_zone * zone_info, nsfw_mem_name * name_info, u32 len)
-{
- if (EOK !=
- MEMCPY_S (&(zone_info->stname), sizeof (nsfw_mem_name), name_info,
- sizeof (nsfw_mem_name)))
- {
- NSPOL_DUMP_LOGERR ("create pool failed, MEMCPY_S failed.");
- return -1;
- }
-
- zone_info->length = len;
- zone_info->isocket_id = NSFW_SOCKET_ANY;
-
- return 0;
-}
-
-int
-set_share_config ()
-{
- static nsfw_mem_name g_cfg_mem_info =
- { NSFW_SHMEM, NSFW_PROC_MAIN, NSTACK_SHARE_CONFIG };
-
- nsfw_mem_zone zone_info;
- if (set_zone_info (&zone_info, &g_cfg_mem_info, get_cfg_share_mem_size ()) <
- 0)
- {
- return -1;
- }
-
- mzone_handle base_cfg_mem = create_mem_zone (&zone_info);
- if (NULL == base_cfg_mem)
- {
- NSPOL_LOGERR ("get config share mem failed.");
- return -1;
- }
-
- if (set_share_cfg_to_mem (base_cfg_mem) < 0)
- {
- NSPOL_LOGERR ("set share config failed.");
- return -1;
- }
-
- return 0;
-}
-
-int
-init_by_tcpip_thread ()
-{
- if (spl_init_app_res () != 0)
- {
- NSPOL_LOGERR ("spl_init_app_res failed");
- return -1;
- }
-
- if (init_instance () != 0)
- {
- return -1;
- }
- if (tcpip_thread_init () != 0)
- {
- NSTCP_LOGERR ("tcpip_thread_init failed!");
- return -1;
- }
-
- init_stackx_lwip ();
-
- return 0;
-}
-
-void
-spl_tcpip_thread (void *arg)
-{
- g_tcpip_thread_stat = 1;
-
- if (init_by_tcpip_thread () != 0)
- {
- return;
- }
-
- struct stackx_stack *share_memory = &p_def_stack_instance->lstack;
- struct disp_netif_list **iflist = &p_def_stack_instance->netif_list;
-
- u32 run_count = 0;
- u16 task_loop;
- u16 num_recv_task = 0, num_send_timer_task = 0;
- u16 index_task = 0;
- //int tcpip_thread_sleep_interval = g_tcpip_thread_sleep_time * 1000;
- void *task_queue[TASK_BURST];
- data_com_msg *msg;
-
- while (1)
- {
- /* try to receive packet from hal layer */
- num_recv_task = tcpip_netif_recv (*iflist);
-
- /* try to receive message from sbr layer */
- num_send_timer_task = priority_sched_mbox (share_memory,
- task_queue, TASK_BURST);
-
- if (num_recv_task)
- {
- NSPOL_LOGINF (TCPIP_DEBUG, "num_recv_task %d", num_recv_task);
- }
-
- /* Statistics the total number of messages */
-
- /* Separate statistics on socket api messages */
- /* handle the request from upper layer and lower layer one by one */
- task_loop = (num_send_timer_task > num_recv_task ?
- num_send_timer_task : num_recv_task);
- if (task_loop == 0)
- {
- no_task_in_one_loop ();
-
- if (run_count++ > 20)
- {
- //sys_sleep_ns (0, tcpip_thread_sleep_interval);
- }
- continue;
- }
-
- run_count = 0;
- index_task = 0;
-
- /* at least one task to be handled */
- while (task_loop > index_task)
- {
- /* handle one packet from hal layer (for multi-nic case, do it for each) */
- if (num_recv_task > index_task)
- {
- do_recv_task (*iflist, index_task);
- }
-
- /* handle one message from sbr layer */
- if (num_send_timer_task > index_task)
- {
- msg = (data_com_msg *) (task_queue[index_task]);
-
- spl_process (msg);
- }
-
- do_update_pcbstate ();
-
- index_task++;
- }
- }
-}
-
-int
-create_tcpip_thread ()
-{
- int ret;
- u64 arg = 0;
-
- /* main tcpip thread */
- char thread_name[32] = TCPIP_THREAD_NAME;
-
- sys_thread_t thread = sys_thread_new (thread_name, spl_tcpip_thread,
- (void *) arg,
- TCPIP_THREAD_STACKSIZE,
- g_cfg_item_info[CFG_SEG_PRI]
- [CFG_SEG_THREAD_PRI_PRI].value);
-
- cpu_set_t cpuset;
- CPU_ZERO (&cpuset); /*lint !e534 */
- CPU_SET (g_nstack_bind_cpu, &cpuset); /*lint !e522 */
- ret = pthread_setaffinity_np (thread, sizeof (cpuset), &cpuset);
- if (ret != 0)
- {
- NSPOL_LOGERR ("pthread_setaffinity_np failed]thread_name=%s,ret=%d",
- TCPIP_THREAD_NAME, ret);
- }
-
- return 0;
-}
-
-int
-create_timer_thread ()
-{
-#if 1
- if (init_ptimer () != ERR_OK)
- {
- NSPOL_LOGERR ("init_ptimer failed");
- return -1;
- }
-
- sys_thread_t thread_timer =
- sys_thread_new (PTIMER_THREAD_NAME, ptimer_thread, NULL,
- TCPIP_THREAD_STACKSIZE, 0);
- cpu_set_t cpuset_timer;
- CPU_ZERO (&cpuset_timer);
- CPU_SET (1, &cpuset_timer);
- int ret = pthread_setaffinity_np (thread_timer, sizeof (cpuset_timer),
- &cpuset_timer);
- if (ret != 0)
- {
- NSPOL_LOGERR ("TCP init Timer Trhead Failed!");
- }
-
- g_timerThread_id = thread_timer;
-#endif
- return 0;
-}
-
-int
-init_ip_module_reader ()
-{
- output_api api = { 0 };
- api.post_to = post_ip_module_msg;
- api.add_netif_ip = add_netif_ip;
- api.del_netif_ip = del_netif_ip;
- regist_output_api (&api);
-
- if (init_configuration_reader () < 0)
- {
- NSPOL_LOGERR ("init_configuration_reader failed");
- return -1;
- }
-
- return 0;
-}
-
-extern int init_unmatch_version (void);
-extern int init_stackx_global_tick (void);
-
-int
-init_by_main_thread ()
-{
- NSPOL_LOGINF (TCPIP_DEBUG, "init_by_main_thread start version 1.4");
-
- uStackArgIndex++;
- if (spl_hal_init (g_dpdk_argc, (char **) g_dpdk_argv) < 0)
- {
- NSPOL_LOGERR ("spl_hal_init failed");
- return -1;
- }
- NSPOL_LOGINF (TCPIP_DEBUG, "stage 1");
-
- if (init_unmatch_version () != 0)
- {
- return -1;
- }
-
- NSPOL_LOGINF (TCPIP_DEBUG, "stage 2");
- if (init_stackx_global_tick () != 0)
- {
- return -1;
- }
- NSPOL_LOGINF (TCPIP_DEBUG, "stage 3");
-
- if (spl_init_group_array () != 0)
- {
- NSPOL_LOGERR ("spl_init_group_array failed");
- return -1;
- }
- NSPOL_LOGINF (TCPIP_DEBUG, "stage 4");
-
- if (set_share_config () != 0)
- {
- NSPOL_LOGERR ("set_share_config failed.");
- return -1;
- }
- NSPOL_LOGINF (TCPIP_DEBUG, "stage 5");
-
- if (create_timer_thread () != 0)
- {
- //NSPOL_LOGERR(TCPIP_DEBUG,"init_timer_thread failed.");
- return -1;
- }
- NSPOL_LOGINF (TCPIP_DEBUG, "stage 6");
-
- if (create_tcpip_thread () != 0)
- {
- NSPOL_LOGERR ("init_tcpip_thread failed.");
- return -1;
- }
- NSPOL_LOGINF (TCPIP_DEBUG, "stage 7");
-
- if (init_ip_module_reader () != 0)
- {
- return -1;
- }
- NSPOL_LOGINF (TCPIP_DEBUG, "stage end");
-
- return 0;
-}
-
-void
-create_netif (struct stackx_port_info *p_port_info)
-{
- int ret;
- struct spl_ip_addr ip, mask, gw;
- struct netifExt *netifEx = NULL;
- struct netif *netif = malloc (sizeof (struct netif));
- if (!netif)
- {
- NSPOL_LOGERR ("malloc failed");
- return;
- }
-
- if (MEMSET_S (netif, sizeof (struct netif), 0, sizeof (struct netif)) < 0)
- {
- NSPOL_LOGERR ("MEMSET_S failed");
- goto error;
- }
-
- NSPOL_LOGINF (TCPIP_DEBUG, "I get netif]ip=%s,gw=%s,mask=%s,name=%c %c",
- p_port_info->linux_ip.ip_addr_linux,
- p_port_info->linux_ip.ip_addr_linux,
- p_port_info->linux_ip.mask_linux,
- netif->name[0], netif->name[1]);
-
- if (inet_aton (p_port_info->linux_ip.ip_addr_linux, &ip)
- && inet_aton (p_port_info->linux_ip.ip_addr_linux, &gw)
- && inet_aton (p_port_info->linux_ip.mask_linux, &mask))
- {
- ret =
- spl_netifapi_netif_add (netif, &ip, &mask, &gw, NULL, ethernetif_init,
- spl_tcpip_input, netif_set_up);
- if (ERR_OK != ret)
- {
- NSPOL_LOGERR ("netifapi_netif_add failed]ret=%d", ret);
- goto error;
- }
-#if 1
- if (0 != netifExt_add (netif))
- return;
-
-#endif
- netifEx = getNetifExt (netif->num);
- if (NULL == netifEx)
- return;
-
- netifEx->hdl = p_port_info->linux_ip.hdl;
- ret =
- STRCPY_S (netifEx->if_name, sizeof (netifEx->if_name),
- p_port_info->linux_ip.if_name);
- if (EOK != ret)
- {
- NSPOL_LOGERR ("STRCPY_S failed]ret=%d", ret);
- goto error;
- }
- return;
- }
-
-error:
- free (netif);
-}
-
-int
-post_ip_module_msg (void *arg, ip_module_type Type,
- ip_module_operate_type operate_type)
-{
- data_com_msg *p_msg_entry;
- msg_ip_module *imsg;
- sys_mbox_t mbox = get_primary_box ();
-
- if (!mbox)
- {
- NSOPR_LOGERR ("get_cur_mbox failed");
- return ERR_MEM;
- }
-
- if (sys_mbox_valid (&mbox))
- {
- if (spl_msg_malloc (&p_msg_entry) == -1)
- {
- NSOPR_LOGERR ("ip_route_apimsg:spl_msg_malloc failed.");
- return ERR_MEM;
- }
-
- sys_sem_init (&p_msg_entry->param.op_completed);
- p_msg_entry->param.module_type = MSG_MODULE_IP;
- p_msg_entry->param.op_type = MSG_SYN_POST;
-
- imsg = (msg_ip_module *) (p_msg_entry->buffer);
- imsg->arg = arg;
- imsg->type = Type;
- imsg->operate_type = operate_type;
-
- NSOPR_LOGINF ("post ip_module msg to tcpip_thread]action=%d,type=%d",
- operate_type, Type);
-
- if (msg_post (p_msg_entry, mbox->llring) != 0)
- {
- NSOPR_LOGERR
- ("msg_post failed,this can not happen]action=%d,type=%d",
- operate_type, Type);
- }
-
- spl_msg_free (p_msg_entry);
-
- return ERR_OK;
- }
-
- NSOPR_LOGERR ("mbox is invalid");
- return ERR_VAL;
-}
-
-int
-process_ip_module_msg (void *arg, ip_module_type module_type,
- ip_module_operate_type operate_type)
-{
- int retval = process_configuration (arg, module_type, operate_type);
-
- NSOPR_LOGINF ("tcpip_thread: ip_module cmd exec over, send SYNC_MSG_ACK");
- return retval;
-}
-
-int
-init_new_network_configuration ()
-{
- if (spl_hal_port_init () < 0)
- {
- return -1;
- }
-
- return 0;
-}
-
-static int
-_process_ip_module_msg (data_com_msg * m)
-{
- m->param.err = ERR_OK;
- msg_ip_module *_m = (msg_ip_module *) m->buffer;
- int ret = process_ip_module_msg (_m->arg, _m->type, _m->operate_type);
- SYNC_MSG_ACK (m);
- return ret;
-}
-
-int
-spl_post_msg (u16 mod, u16 maj, u16 min, u16 op, char *data, u16 data_len,
- u32 src_pid)
-{
- data_com_msg *p_msg_entry;
-
- sys_mbox_t mbox = get_primary_box ();
- if (!sys_mbox_valid (&mbox))
- {
- NSPOL_LOGERR
- ("get mbox null!]mod=%u,maj=%u,min=%u,op=%u,data=%p,len=%u", mod, maj,
- min, op, data, data_len);
- return ERR_MEM;
- }
-
- if (spl_msg_malloc (&p_msg_entry) == -1)
- {
- NSPOL_LOGERR ("get msg null!]mod=%u,maj=%u,min=%u,op=%u,data=%p,len=%u",
- mod, maj, min, op, data, data_len);
- return ERR_MEM;
- }
-
- sys_sem_init (&p_msg_entry->param.op_completed);
- p_msg_entry->param.module_type = mod;
- p_msg_entry->param.major_type = maj;
- p_msg_entry->param.minor_type = min;
- p_msg_entry->param.op_type = op;
- p_msg_entry->param.src_pid = src_pid;
-
- int retVal;
- if (NULL != data)
- {
- retVal =
- MEMCPY_S ((char *) p_msg_entry->buffer, sizeof (p_msg_entry->buffer),
- data, data_len);
- if (EOK != retVal)
- {
- NSPOL_LOGERR ("MEMCPY_S failed %d.", retVal);
- spl_msg_free (p_msg_entry);
- return ERR_MEM;
- }
- }
-
- if (msg_post_with_lock_rel (p_msg_entry, mbox->llring) != 0)
- {
- NSPOL_LOGERR
- ("post msg error!]mod=%u,maj=%u,min=%u,op=%u,data=%p,len=%u", mod,
- maj, min, op, data, data_len);
- spl_msg_free (p_msg_entry);
- return ERR_MEM;
- }
-
- if (MSG_SYN_POST == op)
- {
- spl_msg_free (p_msg_entry);
- }
-
- NSOPR_LOGDBG ("post msg suc!]mod=%u,maj=%u,min=%u,op=%u,data=%p,len=%u",
- mod, maj, min, op, data, data_len);
- return ERR_OK;
-}
-
-/*
-* Added by eliminate duplicated code degree, the function is moved to the public places
-*adjust memory size for pal and eal mem size: this func do the following things:
-*1. copy argv to gArgv and g_dpdk_argv
-*2. remove OPT_EAL_MEM_SIZE option so that the rtp and rte options process won't reprt unrecognized option error.
-*3. set eal mem size and pal_mem_size = mem - eal_mem_size
-*/
-int
-adjust_mem_arg (int argc, char *argv[])
-{
- int i = 0;
- int j = 0;
- int retVal;
- char *tmp = NULL;
- char *tmp2 = NULL;
- int arg_mem_index = -1;
- char *saveptr1 = NULL;
- int mem_size = 0;
- int mem_size_parsed = 0; // if multi -m argument is set, then only deal with the first one
- int eal_mem_size = DPDK_DEFAULT_EAL_MEM_SIZE; // Default
-
- if ((argc < NSTACK_MAIN_MIN_PARA) || (argc > NSTACK_MAIN_MAX_PARA))
- {
- NSPOL_LOGERR ("The number of parameters is incorrect");
- return -1;
- }
-
- globalArgc = argc;
- g_dpdk_argc = argc;
- gArgv = (char **) malloc (sizeof (char *) * argc);
- if (gArgv == NULL)
- {
- NSPOL_LOGERR ("Failed to alloc memory for adjust mem args\n");
- goto ERROR_INIT;
- }
-
- g_dpdk_argv = (char **) malloc (sizeof (char *) * argc);
- if (g_dpdk_argv == NULL)
- {
- NSPOL_LOGERR ("Failed to alloc memory for adjust mem args\n");
- goto ERROR_INIT;
- }
-
- retVal =
- MEMSET_S (gArgv, sizeof (char *) * argc, 0, sizeof (char *) * argc);
- if (EOK != retVal)
- {
- NSPOL_LOGERR ("MEMSET_S failed %d.", retVal);
- goto ERROR_INIT;
- }
- retVal =
- MEMSET_S (g_dpdk_argv, sizeof (char *) * argc, 0, sizeof (char *) * argc);
- if (EOK != retVal)
- {
- NSPOL_LOGERR ("MEMSET_S failed %d.", retVal);
- goto ERROR_INIT;
- }
-
- for (i = 0; i < argc; i++)
- {
- if (!strcmp ("-m", argv[i]) && !mem_size_parsed && (i + 1 < argc))
- {
- gArgv[j] = argv[i];
- g_dpdk_argv[j] = argv[i];
- i++;
- j++;
- gArgv[j] = (char *) malloc (32);
- g_dpdk_argv[j] = (char *) malloc (32);
- /* gArgv[j] is NULL and g_dpdk_argv[j] isnot NULL, need free g_dpdk_argv[j] */
- arg_mem_index = j;
- if ((!gArgv[j]) || (!g_dpdk_argv[j]))
- {
- NSPOL_LOGERR ("malloc failed.");
- goto ERROR_PARSE_MALLOC;
- }
- mem_size = atoi (argv[i]);
- /* add memory range check,avoid handle wrongly later begin */
- if (mem_size < 0)
- {
- goto ERROR_PARSE_MALLOC;
- }
-
- j++;
- mem_size_parsed = 1;
- }
- else
- if (!strncmp (OPT_EAL_MEM_SIZE, argv[i], strlen (OPT_EAL_MEM_SIZE)))
- {
- tmp = strdup (argv[i]);
- if (tmp == NULL)
- {
- goto ERROR_PARSE_MALLOC;
- }
- /* Always use re-entrant functions in multi-threaded environments */
- tmp2 = strtok_r (tmp, "=", &saveptr1);
- tmp2 = strtok_r (NULL, "=", &saveptr1);
- if (tmp2)
- {
- eal_mem_size = atoi (tmp2);
- /* add memory range check,avoid handle wrongly later */
- if (eal_mem_size < 0)
- {
- free (tmp);
- goto ERROR_PARSE_MALLOC;
- }
- }
- free (tmp);
- tmp = NULL;
- /*remove this option since dpdk can't recognize it and may cause error. */
- /*so we should deduct the count by 1. */
- globalArgc -= 1;
- g_dpdk_argc -= 1;
- }
- else
- {
- gArgv[j] = argv[i];
- g_dpdk_argv[j] = argv[i];
- j++;
- }
- }
-
- /* -m arg is set */
- if (arg_mem_index >= 0)
- {
- retVal =
- SPRINTF_S (gArgv[arg_mem_index], 32, "%d", mem_size - eal_mem_size);
- if (-1 == retVal)
- {
- NSPOL_LOGERR ("SPRINTF_S failed]ret=%d", retVal);
- goto ERROR_PARSE_MALLOC;
- }
- retVal = SPRINTF_S (g_dpdk_argv[arg_mem_index], 32, "%d", eal_mem_size);
- if (-1 == retVal)
- {
- NSPOL_LOGERR ("SPRINTF_S failed]ret=%d", retVal);
- goto ERROR_PARSE_MALLOC;
- }
- }
- else
- {
- // do nothing for no mem arg and leave it for default process of pal and eal.
- }
-
- return 0;
-ERROR_PARSE_MALLOC:
- if (arg_mem_index >= 0 && gArgv[arg_mem_index])
- {
- free (gArgv[arg_mem_index]);
- gArgv[arg_mem_index] = NULL;
- }
-
- if (arg_mem_index >= 0 && g_dpdk_argv[arg_mem_index])
- {
- free (g_dpdk_argv[arg_mem_index]);
- g_dpdk_argv[arg_mem_index] = NULL;
- }
-
-ERROR_INIT:
- if (gArgv)
- {
- free (gArgv);
- gArgv = NULL;
- globalArgc = 0;
- }
-
- if (g_dpdk_argv)
- {
- free (g_dpdk_argv);
- g_dpdk_argv = NULL;
- g_dpdk_argc = 0;
- }
-
- return -1;
-}
-
-REGIST_MSG_MODULE_FUN (MSG_MODULE_IP, _process_ip_module_msg);
-
-REGIST_MSG_MODULE_MAJOR_FUN (MSG_MODULE_SPL, SPL_TCPIP_MSG_CALLBACK,
- _do_spl_callback_msg);
-
-REGIST_MSG_MODULE_MAJOR_FUN (MSG_MODULE_TIMER, SPL_TCPIP_MSG_TIMER,
- _do_spl_timer_msg);
-
-REGIST_MSG_MODULE_MAJOR_MINOR_FUN (MSG_MODULE_TIMER, SPL_TCPIP_MSG_TIMER,
- TIMER_MSG_TIMEOUT, _do_timeout_handle);
-
-REGIST_MSG_MODULE_MAJOR_MINOR_FUN (MSG_MODULE_TIMER, SPL_TCPIP_MSG_TIMER,
- TIMER_MSG_CLEAR, _do_clear_timer);
diff --git a/stacks/lwip_stack/lwip_src/common/rb_tree.c b/stacks/lwip_stack/lwip_src/common/rb_tree.c
deleted file mode 100644
index 3dcb37a..0000000
--- a/stacks/lwip_stack/lwip_src/common/rb_tree.c
+++ /dev/null
@@ -1,393 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "rb_tree.h"
-
-static void
-__rb_rotate_right (struct rb_node *node, struct rb_root *root)
-{
- struct rb_node *left = node->rb_left;
- struct rb_node *parent = rb_parent (node);
-
- if ((node->rb_left = left->rb_right))
- {
- rb_set_parent (left->rb_right, node);
- }
-
- left->rb_right = node;
-
- rb_set_parent (left, parent);
-
- if (parent)
- {
- if (node == parent->rb_right)
- {
- parent->rb_right = left;
- }
- else
- {
- parent->rb_left = left;
- }
- }
- else
- {
- root->rb_node = left;
- }
-
- rb_set_parent (node, left);
-}
-
-static void
-__rb_rotate_left (struct rb_node *node, struct rb_root *root)
-{
- struct rb_node *parent = rb_parent (node);
-
- struct rb_node *right = node->rb_right;
-
- if ((node->rb_right = right->rb_left))
- {
- rb_set_parent (right->rb_left, node);
- }
-
- right->rb_left = node;
- rb_set_parent (right, parent);
-
- if (parent) /* judge parent node */
- {
- if (node == parent->rb_left)
- {
- parent->rb_left = right;
- }
- else
- {
- parent->rb_right = right;
- }
- }
- else
- {
- root->rb_node = right;
- }
-
- rb_set_parent (node, right);
-}
-
-static void
-__rb_erase_color (struct rb_node *rb_tree_node,
- struct rb_node *rb_tree_parent,
- struct rb_root *rb_tree_root)
-{
- struct rb_node *rb_tree_other;
-
- while ((!rb_tree_node || rb_is_black (rb_tree_node))
- && (rb_tree_node != rb_tree_root->rb_node))
- {
- if (rb_tree_parent == NULL)
- {
- break;
- }
-
- if (rb_tree_parent->rb_left == rb_tree_node)
- {
- rb_tree_other = rb_tree_parent->rb_right;
- if (rb_is_red (rb_tree_other))
- {
- rb_set_black (rb_tree_other);
- rb_set_red (rb_tree_parent);
- __rb_rotate_left (rb_tree_parent, rb_tree_root);
- rb_tree_other = rb_tree_parent->rb_right;
- }
-
- if ((!rb_tree_other->rb_left
- || rb_is_black (rb_tree_other->rb_left))
- && (!rb_tree_other->rb_right
- || rb_is_black (rb_tree_other->rb_right)))
- {
- rb_set_red (rb_tree_other);
- rb_tree_node = rb_tree_parent;
- rb_tree_parent = rb_parent (rb_tree_node);
- }
- else
- {
- if (!rb_tree_other->rb_right
- || rb_is_black (rb_tree_other->rb_right))
- {
- rb_set_black (rb_tree_other->rb_left);
- rb_set_red (rb_tree_other);
- __rb_rotate_right (rb_tree_other, rb_tree_root);
- rb_tree_other = rb_tree_parent->rb_right;
- }
-
- rb_set_color (rb_tree_other, rb_color (rb_tree_parent));
- rb_set_black (rb_tree_parent);
- rb_set_black (rb_tree_other->rb_right);
- __rb_rotate_left (rb_tree_parent, rb_tree_root);
- rb_tree_node = rb_tree_root->rb_node;
- break;
- }
- }
- else
- {
- rb_tree_other = rb_tree_parent->rb_left;
- if (rb_is_red (rb_tree_other))
- {
- rb_set_black (rb_tree_other);
- rb_set_red (rb_tree_parent);
- __rb_rotate_right (rb_tree_parent, rb_tree_root);
- rb_tree_other = rb_tree_parent->rb_left;
- }
-
- if ((!rb_tree_other->rb_left
- || rb_is_black (rb_tree_other->rb_left))
- && (!rb_tree_other->rb_right
- || rb_is_black (rb_tree_other->rb_right)))
- {
- rb_set_red (rb_tree_other);
- rb_tree_node = rb_tree_parent;
- rb_tree_parent = rb_parent (rb_tree_node);
- }
- else
- {
- if (!rb_tree_other->rb_left
- || rb_is_black (rb_tree_other->rb_left))
- {
- rb_set_black (rb_tree_other->rb_right);
- rb_set_red (rb_tree_other);
- __rb_rotate_left (rb_tree_other, rb_tree_root);
- rb_tree_other = rb_tree_parent->rb_left;
- }
-
- rb_set_color (rb_tree_other, rb_color (rb_tree_parent));
- rb_set_black (rb_tree_parent);
- rb_set_black (rb_tree_other->rb_left);
- __rb_rotate_right (rb_tree_parent, rb_tree_root);
- rb_tree_node = rb_tree_root->rb_node;
- break;
- }
- }
- }
-
- if (rb_tree_node)
- {
- rb_set_black (rb_tree_node);
- }
-}
-
-void
-rb_insert_color (struct rb_node *rb_tree_node, struct rb_root *rb_tree_root)
-{
- struct rb_node *rb_tree_parent, *rb_tree_gparent;
-
- if (!rb_tree_node || !rb_tree_root)
- return;
-
- while ((rb_tree_parent = rb_parent (rb_tree_node))
- && rb_is_red (rb_tree_parent))
- {
- rb_tree_gparent = rb_parent (rb_tree_parent);
-
- if (rb_tree_parent == rb_tree_gparent->rb_left)
- {
- {
- register struct rb_node *rb_tree_uncle =
- rb_tree_gparent->rb_right;
- if (rb_tree_uncle && rb_is_red (rb_tree_uncle))
- {
- rb_set_black (rb_tree_uncle);
- rb_set_black (rb_tree_parent);
- rb_set_red (rb_tree_gparent);
- rb_tree_node = rb_tree_gparent;
- continue;
- }
- }
-
- if (rb_tree_parent->rb_right == rb_tree_node)
- {
- register struct rb_node *rb_tree_tmp;
- __rb_rotate_left (rb_tree_parent, rb_tree_root);
- rb_tree_tmp = rb_tree_parent;
- rb_tree_parent = rb_tree_node;
- rb_tree_node = rb_tree_tmp;
- }
-
- rb_set_black (rb_tree_parent);
- rb_set_red (rb_tree_gparent);
- __rb_rotate_right (rb_tree_gparent, rb_tree_root);
- }
- else
- {
- {
- register struct rb_node *rb_tree_uncle = rb_tree_gparent->rb_left;
- if (rb_tree_uncle && rb_is_red (rb_tree_uncle))
- {
- rb_set_black (rb_tree_uncle);
- rb_set_black (rb_tree_parent);
- rb_set_red (rb_tree_gparent);
- rb_tree_node = rb_tree_gparent;
- continue;
- }
- }
-
- if (rb_tree_parent->rb_left == rb_tree_node)
- {
- register struct rb_node *rb_tree_tmp;
- __rb_rotate_right (rb_tree_parent, rb_tree_root);
- rb_tree_tmp = rb_tree_parent;
- rb_tree_parent = rb_tree_node;
- rb_tree_node = rb_tree_tmp;
- }
-
- rb_set_black (rb_tree_parent);
- rb_set_red (rb_tree_gparent);
- __rb_rotate_left (rb_tree_gparent, rb_tree_root);
- }
- }
-
- rb_set_black (rb_tree_root->rb_node);
-}
-
-void
-rb_erase (struct rb_node *node, struct rb_root *root)
-{
- struct rb_node *child, *parent;
- int color;
-
- if (!node || !root)
- return;
-
- if (!node->rb_left)
- {
- child = node->rb_right;
- }
- else if (!node->rb_right)
- {
- child = node->rb_left;
- }
- else
- {
- struct rb_node *old = node, *left;
-
- node = node->rb_right;
- while ((left = node->rb_left) != NULL)
- {
- node = left;
- }
-
- if (rb_parent (old))
- {
- if (rb_parent (old)->rb_left == old)
- {
- rb_parent (old)->rb_left = node;
- }
- else
- {
- rb_parent (old)->rb_right = node;
- }
- }
- else
- {
- root->rb_node = node;
- }
-
- child = node->rb_right;
- parent = rb_parent (node);
- color = rb_color (node);
-
- if (parent == old)
- {
- parent = node;
- }
- else
- {
- if (child)
- {
- rb_set_parent (child, parent);
- }
-
- parent->rb_left = child;
-
- node->rb_right = old->rb_right;
- rb_set_parent (old->rb_right, node);
- }
-
- node->rb_parent_color = old->rb_parent_color;
- node->rb_left = old->rb_left;
- rb_set_parent (old->rb_left, node);
-
- goto color;
- }
-
- parent = rb_parent (node);
- color = rb_color (node);
-
- if (child)
- {
- rb_set_parent (child, parent);
- }
-
- if (parent)
- {
- if (parent->rb_left == node)
- {
- parent->rb_left = child;
- }
- else
- {
- parent->rb_right = child;
- }
- }
- else
- {
- root->rb_node = child;
- }
-
-color:
- if (color == RB_BLACK)
- {
- __rb_erase_color (child, parent, root);
- }
-}
-
-struct rb_node *
-rb_next (const struct rb_node *node)
-{
- struct rb_node *parent;
-
- if (!node)
- return NULL;
-
- if (rb_parent (node) == node)
- {
- return NULL;
- }
-
- if (node->rb_right)
- {
- node = node->rb_right;
- while (node->rb_left)
- {
- node = node->rb_left;
- }
-
- return (struct rb_node *) node;
- }
-
- while ((parent = rb_parent (node)) && (node == parent->rb_right))
- {
- node = parent;
- }
-
- return parent;
-}
diff --git a/stacks/lwip_stack/lwip_src/common/rb_tree.h b/stacks/lwip_stack/lwip_src/common/rb_tree.h
deleted file mode 100644
index 87174fa..0000000
--- a/stacks/lwip_stack/lwip_src/common/rb_tree.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _UNX_RBTREE_H
-#define _UNX_RBTREE_H
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-#include <stdint.h>
-#include "types.h"
-#include "common_pal_bitwide_adjust.h"
-
-#define rb_parent(a) ((struct rb_node *)((a)->rb_parent_color & ~3))
-#define rb_color(a) ((a)->rb_parent_color & 1)
-
-struct rb_node
-{
- union
- {
- unsigned long rb_parent_color;
- u64 rb_parent_color_a;
- };
-
-#define RB_RED 0
-#define RB_BLACK 1
- union
- {
- struct rb_node *rb_right;
- u64 rb_right_a;
- };
-
- union
- {
- struct rb_node *rb_left;
- u64 rb_left_a;
- };
-};
-
-#define rb_set_red(c) do { (c)->rb_parent_color &= ~1; } while (0)
-#define rb_set_black(c) do { (c)->rb_parent_color |= 1; } while (0)
-
-/* The alignment might seem pointless, but allegedly CRIS needs it */
-
-struct rb_root
-{
- union
- {
- struct rb_node *rb_node;
- u64 rb_node_a;
- };
-};
-
-#define rb_is_red(e) (!rb_color(e))
-#define rb_is_black(e) rb_color(e)
-
-static inline void
-rb_set_color (struct rb_node *rb1, int color2)
-{
- rb1->rb_parent_color = (rb1->rb_parent_color & ~1) | color2;
-}
-
-static inline void
-rb_set_parent (struct rb_node *rb1, struct rb_node *pa)
-{
- rb1->rb_parent_color = (rb1->rb_parent_color & 3) | (unsigned long) pa;
-}
-
-#define RB_ROOT (struct rb_root) { NULL, }
-
-extern void rb_erase (struct rb_node *, struct rb_root *);
-
-extern void rb_insert_color (struct rb_node *, struct rb_root *);
-
-extern struct rb_node *rb_next (const struct rb_node *);
-
-#define rb_entry(ptr, type, member) container_of(ptr, type, member)
-
-#define RB_EMPTY_ROOT(root1) ((root1)->rb_node == NULL)
-#define RB_CLEAR_NODE(node2) (rb_set_parent(node2, node2))
-#define RB_EMPTY_NODE(node1) (rb_parent(node1) == node1)
-
-static inline void
-rb_link_node (struct rb_node *node1, struct rb_node *parent1,
- struct rb_node **rb_link1)
-{
- node1->rb_left = node1->rb_right = NULL;
- node1->rb_parent_color = (unsigned long) parent1;
- *rb_link1 = node1;
-}
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-#endif /* _UNX_RBTREE_H */
diff --git a/stacks/lwip_stack/lwip_src/common/spl_def.h b/stacks/lwip_stack/lwip_src/common/spl_def.h
deleted file mode 100644
index b62d179..0000000
--- a/stacks/lwip_stack/lwip_src/common/spl_def.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef __STACKX_DEF_H__
-#define __STACKX_DEF_H__
-
-/* arch.h might define NULL already */
-//#include "lwip/arch.h"
-#include "spl_opt.h"
-#include "stackx_types.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-#define STACKX_MAX(x, y) (((x) > (y)) ? (x) : (y))
-#define STACKX_MIN(x, y) (((x) < (y)) ? (x) : (y))
-
-/* Endianess-optimized shifting of two u8_t to create one u16_t */
-#if BYTE_ORDER == LITTLE_ENDIAN
-#define STACKX_MAKE_U16(a, b) ((a << 8) | b)
-#else
-#define STACKX_MAKE_U16(a, b) ((b << 8) | a)
-#endif
-
-#ifndef STACKX_PLATFORM_BYTESWAP
-#define STACKX_PLATFORM_BYTESWAP 0
-#endif
-
-#ifndef STACKX_PREFIX_BYTEORDER_FUNCS
-
-/* workaround for naming collisions on some platforms */
-
-#ifdef spl_htons
-#undef spl_htons
-#endif /* htons */
-#ifdef spl_htonl
-#undef spl_htonl
-#endif /* spl_htonl */
-#ifdef spl_ntohs
-#undef spl_ntohs
-#endif /* spl_ntohs */
-#ifdef spl_ntohl
-#undef spl_ntohl
-#endif /* spl_ntohl */
-
-#define spl_htons(x) stackx_htons(x)
-#define spl_ntohs(x) stackx_ntohs(x)
-#define spl_htonl(x) stackx_htonl(x)
-#define spl_ntohl(x) stackx_ntohl(x)
-#endif /* STACKX_PREFIX_BYTEORDER_FUNCS */
-
-#if BYTE_ORDER == BIG_ENDIAN
-#define stackx_htons(x) (x)
-#define stackx_ntohs(x) (x)
-#define stackx_htonl(x) (x)
-#define stackx_ntohl(x) (x)
-#define SPL_PP_HTONS(x) (x)
-#define SPL_PP_NTOHS(x) (x)
-#define SPL_PP_HTONL(x) (x)
-#define SPL_PP_NTOHL(x) (x)
-#else /* BYTE_ORDER != BIG_ENDIAN */
-#if STACKX_PLATFORM_BYTESWAP
-#define stackx_htons(x) STACKX_PLATFORM_HTONS(x)
-#define stackx_ntohs(x) STACKX_PLATFORM_HTONS(x)
-#define stackx_htonl(x) STACKX_PLATFORM_HTONL(x)
-#define stackx_ntohl(x) STACKX_PLATFORM_HTONL(x)
-#else /* STACKX_PLATFORM_BYTESWAP */
- /**
- * Convert an u16_t from host- to network byte order.
- *
- * @param n u16_t in host byte order
- * @return n in network byte order
- */
-static inline u16_t
-stackx_htons (u16_t x)
-{
- return ((x & 0xff) << 8) | ((x & 0xff00) >> 8);
-}
-
-static inline u16_t
-stackx_ntohs (u16_t x)
-{
- return stackx_htons (x);
-}
-
- /**
- * Convert an u32_t from host- to network byte order.
- *
- * @param n u32_t in host byte order
- * @return n in network byte order
- */
-static inline u32_t
-stackx_htonl (u32_t x)
-{
- return ((x & 0xff) << 24) |
- ((x & 0xff00) << 8) |
- ((x & 0xff0000UL) >> 8) | ((x & 0xff000000UL) >> 24);
-}
-
-static inline u32_t
-stackx_ntohl (u32_t x)
-{
- return stackx_htonl (x);
-}
-#endif /* STACKX_PLATFORM_BYTESWAP */
-
-/* These macros should be calculated by the preprocessor and are used
- with compile-time constants only (so that there is no little-endian
- overhead at runtime). */
-#define SPL_PP_HTONS(x) ((((x) & 0xff) << 8) | (((x) & 0xff00) >> 8))
-#define SPL_PP_NTOHS(x) SPL_PP_HTONS(x)
-#define SPL_PP_HTONL(x) ((((x) & 0xff) << 24) | \
- (((x) & 0xff00) << 8) | \
- (((x) & 0xff0000UL) >> 8) | \
- (((x) & 0xff000000UL) >> 24))
-#define SPL_PP_NTOHL(x) SPL_PP_HTONL(x)
-
-#endif /* BYTE_ORDER == BIG_ENDIAN */
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif /* __STACKX_DEF_H__ */
diff --git a/stacks/lwip_stack/lwip_src/common/spl_opt.h b/stacks/lwip_stack/lwip_src/common/spl_opt.h
deleted file mode 100644
index 98e6466..0000000
--- a/stacks/lwip_stack/lwip_src/common/spl_opt.h
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef __STACKX_OPT_H__
-#define __STACKX_OPT_H__
-
-#include "stackxopts.h"
-#include "stackx_debug.h"
-#include "compiling_check.h"
-
-#define PBUF_VLAN_HLEN 0
-
-//#define SIZEOF_ETH_HDR (14)
-
-#ifndef STACKX_NETIF_API
-#define STACKX_NETIF_API 1
-#endif
-
-/*
- ------------------------------------
- ---------- Thread options ----------
- ------------------------------------
- */
-
-#define PTIMER_THREAD_NAME "ptimer_thread"
-
-/**
- * TCPIP_THREAD_NAME: The name assigned to the main tcpip thread.
- */
-#ifndef TCPIP_THREAD_NAME
-#define TCPIP_THREAD_NAME "spl_tcpip_thread"
-#endif
-
-#ifndef TCPIP_THREAD_STACKSIZE
-#define TCPIP_THREAD_STACKSIZE 0
-#endif
-
-#ifndef INT_MAX
-#define INT_MAX 2147483647
-#endif
-
-#ifndef INT_64_MAX
-#define INT_64_MAX 9223372036854775807
-#endif
-
-#ifndef RECV_BUFSIZE_DEFAULT
-#define RECV_BUFSIZE_DEFAULT INT_MAX
-#endif
-
-/*
- ----------------------------------------
- ---------- Statistics options ----------
- ----------------------------------------
- */
-
-/*
- ---------------------------------------
- ---------- Debugging options ----------
- ---------------------------------------
- */
-
-#ifndef STACKX_DBG_TYPES_ON
-#define STACKX_DBG_TYPES_ON STACKX_DBG_ON //ON
-#endif
-
-#ifndef INTERRUPT_DEBUG
-#define INTERRUPT_DEBUG STACKX_DBG_ON //ON
-#endif
-
-#ifndef TESTSOCKET_DEBUG
-#define TESTSOCKET_DEBUG STACKX_DBG_ON //ON
-#endif
-
-#ifndef ETHARP_DEBUG
-#define ETHARP_DEBUG STACKX_DBG_ON
-#endif
-
-#ifndef NETIF_DEBUG
-#define NETIF_DEBUG STACKX_DBG_ON
-#endif
-
-#ifndef PBUF_DEBUG
-#define PBUF_DEBUG STACKX_DBG_ON
-#endif
-
-#ifndef API_LIB_DEBUG
-#define API_LIB_DEBUG STACKX_DBG_ON
-#endif
-
-#ifndef API_MSG_DEBUG
-#define API_MSG_DEBUG STACKX_DBG_ON
-#endif
-
-#ifndef SOCKETS_DEBUG
-#define SOCKETS_DEBUG STACKX_DBG_ON
-#endif
-
-#ifndef NS_EPOLL_DBG
-#define NS_EPOLL_DBG STACKX_DBG_ON
-#endif
-
-#ifndef ICMP_DEBUG
-#define ICMP_DEBUG STACKX_DBG_ON
-#endif
-
-#ifndef IGMP_DEBUG
-#define IGMP_DEBUG STACKX_DBG_ON
-#endif
-
-#ifndef INET_DEBUG
-#define INET_DEBUG STACKX_DBG_ON
-#endif
-
-#ifndef IP_DEBUG
-#define IP_DEBUG STACKX_DBG_ON
-#endif
-
-#ifndef IP_REASS_DEBUG
-#define IP_REASS_DEBUG STACKX_DBG_ON
-#endif
-
-#ifndef RAW_DEBUG
-#define RAW_DEBUG STACKX_DBG_ON
-#endif
-
-#ifndef MEMP_DEBUG
-#define MEMP_DEBUG STACKX_DBG_ON
-#endif
-
-#ifndef SYS_DEBUG
-#define SYS_DEBUG STACKX_DBG_OFF
-#endif
-
-#ifndef TIMERS_DEBUG
-#define TIMERS_DEBUG STACKX_DBG_ON
-#endif
-
-#ifndef TCP_DEBUG
-#define TCP_DEBUG STACKX_DBG_ON
-#endif
-
-#ifndef TCP_TEST_DEBUG
-#define TCP_TEST_DEBUG STACKX_DBG_ON
-#endif
-
-#ifndef TCP_INPUT_DEBUG
-#define TCP_INPUT_DEBUG STACKX_DBG_ON
-#endif
-
-#ifndef TCP_RTO_DEBUG
-#define TCP_RTO_DEBUG STACKX_DBG_ON
-#endif
-
-#ifndef TCP_FR_DEBUG
-#define TCP_FR_DEBUG STACKX_DBG_ON
-#endif
-
-#ifndef TCP_FLOW_CTL_DEBUG
-#define TCP_FLOW_CTL_DEBUG STACKX_DBG_ON
-#endif
-
-#ifndef TCP_CWND_DEBUG
-#define TCP_CWND_DEBUG STACKX_DBG_ON
-#endif
-
-#ifndef TCP_WND_DEBUG
-#define TCP_WND_DEBUG STACKX_DBG_ON
-#endif
-
-#ifndef TCP_OUTPUT_DEBUG
-#define TCP_OUTPUT_DEBUG STACKX_DBG_ON
-#endif
-
-#ifndef TCP_RST_DEBUG
-#define TCP_RST_DEBUG STACKX_DBG_ON
-#endif
-
-#ifndef UDP_DEBUG
-#define UDP_DEBUG STACKX_DBG_ON
-#endif
-
-#ifndef TCPIP_DEBUG
-#define TCPIP_DEBUG STACKX_DBG_ON
-#endif
-
-#ifndef NEW_RING_DEBUG
-#define NEW_RING_DEBUG STACKX_DBG_ON
-#endif
-
-#ifndef PACKET_DISPATCH
-#define PACKET_DISPATCH 1
-#endif
-
-#ifndef NETSTAT_SWITCH
-#define NETSTAT_SWITCH 1
-#endif
-
-#ifndef DISTRIBUTOR_DEBUG
-
-#define DISTRIBUTOR_DEBUG STACKX_DBG_ON
-#endif
-#define PBUF_REF_DEBUG STACKX_DBG_ON
-
-#ifndef CONTEXT_TIMER_DEBUG
-#define CONTEXT_TIMER_DEBUG STACKX_DBG_OFF
-#endif
-
-#if (DISTRIBUTOR_DEBUG == STACKX_DBG_ON)
-#define PD_DISTRIBUTOR_DEBUG
-
-#define DISTRIBUTOR_SINGLE
-#ifdef DISTRIBUTOR_SINGLE
-
-#ifndef __STACKX_DEBUG_H__
-#define STACKX_DBG_OFF 0x80U
-#define STACKX_DBG_ON 0x00U
-#endif
-
-#ifndef ETHARP_DEBUG
-#define ETHARP_DEBUG STACKX_DBG_ON
-#endif
-#ifndef NETIF_DEBUG
-#define NETIF_DEBUG STACKX_DBG_ON
-#endif
-#ifndef PBUF_DEBUG
-#define PBUF_DEBUG STACKX_DBG_ON
-#endif
-#ifndef API_LIB_DEBUG
-#define API_LIB_DEBUG STACKX_DBG_ON
-#endif
-#ifndef API_MSG_DEBUG
-#define API_MSG_DEBUG STACKX_DBG_ON
-#endif
-#ifndef ICMP_DEBUG
-#define ICMP_DEBUG STACKX_DBG_ON
-#endif
-#ifndef IGMP_DEBUG
-#define IGMP_DEBUG STACKX_DBG_ON
-#endif
-#ifndef INET_DEBUG
-#define INET_DEBUG STACKX_DBG_ON
-#endif
-#ifndef IP_DEBUG
-#define IP_DEBUG STACKX_DBG_ON
-#endif
-#ifndef IP_REASS_DEBUG
-#define IP_REASS_DEBUG STACKX_DBG_ON
-#endif
-#ifndef RAW_DEBUG
-#define RAW_DEBUG STACKX_DBG_ON
-#endif
-#ifndef MEMP_DEBUG
-#define MEMP_DEBUG STACKX_DBG_ON
-#endif
-#ifndef SYS_DEBUG
-#define SYS_DEBUG STACKX_DBG_ON
-#endif
-#ifndef TIMERS_DEBUG
-#define TIMERS_DEBUG STACKX_DBG_ON
-#endif
-#ifndef TCP_DEBUG
-#define TCP_DEBUG STACKX_DBG_ON
-#endif
-#ifndef TCP_TEST_DEBUG
-#define TCP_TEST_DEBUG STACKX_DBG_ON
-#endif
-#ifndef TCP_INPUT_DEBUG
-#define TCP_INPUT_DEBUG STACKX_DBG_ON
-#endif
-#ifndef TCP_FR_DEBUG
-#define TCP_FR_DEBUG STACKX_DBG_ON
-#endif
-#ifndef TCP_RTO_DEBUG
-#define TCP_RTO_DEBUG STACKX_DBG_ON
-#endif
-#ifndef TCP_CWND_DEBUG
-#define TCP_CWND_DEBUG STACKX_DBG_ON
-#endif
-#ifndef TCP_WND_DEBUG
-#define TCP_WND_DEBUG STACKX_DBG_ON
-#endif
-#ifndef TCP_OUTPUT_DEBUG
-#define TCP_OUTPUT_DEBUG STACKX_DBG_ON
-#endif
-#ifndef TCP_RST_DEBUG
-#define TCP_RST_DEBUG STACKX_DBG_ON
-#endif
-#ifndef UDP_DEBUG
-#define UDP_DEBUG STACKX_DBG_ON
-#endif
-#ifndef TCPIP_DEBUG
-#define TCPIP_DEBUG STACKX_DBG_ON
-#endif
-
-#define SC_DPDK_INFO STACKX_DBG_ON
-#define SOCK_INFO STACKX_DBG_ON
-#ifndef STACKX_DBG_OFF
-#define STACKX_DBG_OFF 0x00U
-#endif
-
-#ifndef NS_EPOLL_DBG
-#define NS_EPOLL_DBG STACKX_DBG_ON
-#endif
-
-#ifndef DFX_DBG
-#define DFX_DBG STACKX_DBG_ON
-#endif
-
-#endif
-#endif /* DISTRIBUTOR_DEBUG */
-
-#ifndef STACKX_FLOW_CTL
-#define STACKX_FLOW_CTL 0
-#endif
-
-#endif /* __STACKX_OPT_H__ */
diff --git a/stacks/lwip_stack/lwip_src/common/stackx_app_res.c b/stacks/lwip_stack/lwip_src/common/stackx_app_res.c
deleted file mode 100644
index 5c30271..0000000
--- a/stacks/lwip_stack/lwip_src/common/stackx_app_res.c
+++ /dev/null
@@ -1,972 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "stackx_app_res.h"
-#include "nstack_securec.h"
-#include "common_pal_bitwide_adjust.h"
-#include "nstack_log.h"
-#include "stackx_common.h"
-#include "nsfw_maintain_api.h"
-#include "stackx_tx_box.h"
-#include "nsfw_msg_api.h"
-#include "nsfw_recycle_api.h"
-#include "common_mem_mbuf.h"
-#include "stackx_pbuf.h"
-#include "nsfw_mt_config.h"
-#include "nsfw_mem_api.h"
-#include "spl_opt.h"
-#define SPL_MAX_MSG_NUM (MBOX_RING_SIZE*8*MAX_THREAD_NUM)
-
-spl_app_res_group *g_spl_app_res_group = NULL;
-
-spl_app_res_group_array *g_res_group_array = NULL;
-
-#ifdef SYS_MEM_RES_STAT
-mpool_handle g_app_tx_pool[SBR_TX_POOL_NUM];
-#endif
-
-/***************************************************
-* description:
-***************************************************/
-int
-spl_init_group_array ()
-{
- g_res_group_array =
- (spl_app_res_group_array *) sbr_create_mzone (SPL_RES_GROUP_ARRAY,
- sizeof
- (spl_app_res_group_array));
- if (!g_res_group_array)
- {
- NSPOL_LOGERR ("create g_res_group_array failed");
- return -1;
- }
-
- u32 i;
- for (i = 0; i < SBR_TX_POOL_NUM; ++i)
- {
- g_res_group_array->pid_array[i] = 0;
- }
-
- for (i = 0; i < MAX_THREAD_NUM; ++i)
- {
- g_res_group_array->res_group[i] = NULL;
- }
-
- g_res_group_array->thread_num = 0;
- return 0;
-}
-
-/***************************************************
-* description:
-***************************************************/
-int
-sbr_attach_group_array ()
-{
- g_res_group_array =
- (spl_app_res_group_array *) sbr_lookup_mzone (SPL_RES_GROUP_ARRAY);
- if (!g_res_group_array)
- {
- NSPOL_LOGERR ("attach g_res_group_array failed");
- return -1;
- }
-
- return 0;
-}
-
-/***************************************************
-* description:
-***************************************************/
-int
-spl_add_instance_res_group (u32 thread_index, spl_app_res_group * group)
-{
- if (thread_index >= MAX_THREAD_NUM)
- {
- NSPOL_LOGERR
- ("thread_index >= MAX_THREAD_NUM]thread_index=%u, MAX_THREAD_NUM=%u",
- thread_index, MAX_THREAD_NUM);
- return -1;
- }
-
- if (g_res_group_array->res_group[thread_index] != NULL)
- {
- NSPOL_LOGERR
- ("g_res_group_array in thread_index is not NULL, this can not happen");
- return -1;
- }
-
- g_res_group_array->res_group[thread_index] = group;
- __sync_add_and_fetch (&g_res_group_array->thread_num, 1);
- return 0;
-}
-
-/***************************************************
-* description:
-***************************************************/
-int
-spl_add_mbox (mring_handle mbox_array[], u32 array_size)
-{
- if (array_size != SPL_MSG_BOX_NUM)
- {
- NSPOL_LOGERR ("array_size must be %u, but not", SPL_MSG_BOX_NUM);
- return -1;
- }
-
- u32 i;
- for (i = 0; i < array_size; ++i)
- {
- g_spl_app_res_group->mbox_array[i] = mbox_array[i];
- }
-
- return 0;
-}
-
-/*****************************************************************************
-* Prototype : spl_create_group
-* Description : create group
-* Input : None
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-spl_app_res_group *
-spl_create_group ()
-{
- spl_app_res_group *group =
- (spl_app_res_group *) sbr_create_mzone (SPL_APP_RES_GROUP_NAME,
- sizeof (spl_app_res_group));
- if (!group)
- {
- NSPOL_LOGERR ("Create app_res_group zone fail]name=%s, size=%u",
- SPL_APP_RES_GROUP_NAME, sizeof (spl_app_res_group));
- return NULL;
- }
-
- group->msg_pool = NULL;
- group->conn_pool = NULL;
- group->conn_array = NULL;
- group->recv_ring_pool = NULL;
-
- u32 i;
- for (i = 0; i < SBR_TX_POOL_NUM; ++i)
- {
- group->tx_pool_array[i] = NULL;
- }
-
- for (i = 0; i < SPL_MSG_BOX_NUM; ++i)
- {
- group->mbox_array[i] = NULL;
- }
-
- group->extend_member_bit = 0;
-
- NSPOL_LOGINF (SC_DPDK_INFO, "Create app_res_group zone ok]name=%s, size=%u",
- SPL_APP_RES_GROUP_NAME, sizeof (spl_app_res_group));
- MEM_STAT (SPL_APP_RES, SPL_APP_RES_GROUP_NAME, NSFW_SHMEM,
- sizeof (spl_app_res_group));
- return group;
-}
-
-/*****************************************************************************
-* Prototype : _spl_create_ring_pool
-* Description : create ring pool
-* Input : char* pool_name
-* char* array_name
-* nsfw_mpool_type type
-* Output : None
-* Return Value : static inline mring_handle
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline mring_handle
-_spl_create_ring_pool (char *pool_name, char *array_name,
- nsfw_mpool_type type, u32 num, u32 ring_size)
-{
- mring_handle pool = sbr_create_ring (pool_name, num - 1);
-
- if (!pool)
- {
- return NULL;
- }
-
- NSPOL_LOGINF (SC_DPDK_INFO, "Create ring pool ok]name=%s, num=%u, size=%d",
- pool_name, num, nsfw_mem_get_len (pool, NSFW_MEM_RING));
- MEM_STAT (SPL_APP_RES, pool_name, NSFW_SHMEM,
- nsfw_mem_get_len (pool, NSFW_MEM_RING));
-
- mring_handle *array = malloc (num * sizeof (mring_handle));
- if (!array)
- {
- NSPOL_LOGERR ("malloc fail]size=%u", num * sizeof (mring_handle));
- return NULL;
- }
-
- if (sbr_create_multi_ring (array_name, ring_size - 1, num,
- array, type) != 0)
- {
- free (array);
- return NULL;
- }
-
- NSPOL_LOGINF (SC_DPDK_INFO,
- "Create multi rings ok]name=%s, ring_size=%u, ring_num=%u, total_mem=%d",
- array_name, ring_size, num,
- (nsfw_mem_get_len (array[0], NSFW_MEM_RING) * num));
- MEM_STAT (SPL_APP_RES, array_name, NSFW_SHMEM,
- nsfw_mem_get_len (array[0], NSFW_MEM_RING) * num);
-
- unsigned int i = 0;
- while (i < num)
- {
- if (nsfw_mem_ring_enqueue (pool, (void *) array[i]) != 1)
- {
- NSPOL_LOGERR ("nsfw_mem_ring_enqueue failed,this can not happen");
- free (array);
- return NULL;
- }
-
- i++;
- }
-
- free (array);
- return pool;
-}
-
-/*****************************************************************************
-* Prototype : spl_create_ring_pool
-* Description : create ring pool
-* Input : None
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-spl_create_ring_pool (spl_app_res_group * group)
-{
- group->recv_ring_pool =
- _spl_create_ring_pool (SPL_RECV_RING_POOL_NAME, SPL_RECV_RING_ARRAY_NAME,
- NSFW_MRING_SPSC, CUR_CFG_SOCKET_NUM,
- SPL_MAX_RING_SIZE);
- if (!group->recv_ring_pool)
- {
- NSPOL_LOGERR ("Create recv ring pool failed");
- return -1;
- }
-
- NSPOL_LOGINF (SC_DPDK_INFO, "Create recv ring pool ok]name=%s",
- SPL_RECV_RING_POOL_NAME);
- return 0;
-}
-
-int
-spl_force_netconn_free (void *data)
-{
- spl_netconn_t *conn = (spl_netconn_t *) data;
- if (TRUE == conn->res_chk.alloc_flag)
- {
- if (NULL != conn->recycle.accept_from)
- {
- return FALSE;
- }
-
- if (TRUE != nsfw_pidinfo_empty (&conn->recycle.pid_info))
- {
- return FALSE;
- }
- }
- ss_reset_conn (conn);
- (void) res_free (&conn->res_chk);
-
- if (nsfw_mem_ring_enqueue (ss_get_conn_pool (conn), (void *) conn) != 1)
- {
- NSSBR_LOGERR ("nsfw_mem_ring_enqueue failed,this can not happen");
- }
- NSFW_LOGINF ("force free conn]conn=%p", conn);
- return TRUE;
-}
-
-/*****************************************************************************
-* Prototype : spl_create_netconn_pool
-* Description : create netconn pool
-* Input : None
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-spl_create_netconn_pool (spl_app_res_group * group)
-{
- spl_netconn_t **conn_array =
- (spl_netconn_t **) sbr_create_mzone (SPL_CONN_ARRAY_NAME,
- sizeof (spl_netconn_t *) *
- CUR_CFG_SOCKET_NUM);
-
- if (!conn_array)
- {
- return -1;
- }
-
- NSPOL_LOGINF (SC_DPDK_INFO, "Create connn_array zone ok]name=%s, size=%zu",
- SPL_CONN_ARRAY_NAME,
- sizeof (spl_netconn_t *) * CUR_CFG_SOCKET_NUM);
- mring_handle pool =
- sbr_create_pool (SPL_CONN_POOL_NAME, CUR_CFG_SOCKET_NUM - 1,
- SBR_FD_NETCONN_SIZE);
-
- if (!pool)
- {
- return -1;
- }
-
- NSPOL_LOGINF (SC_DPDK_INFO,
- "Create conn_pool ok]name=%s, num=%u, total_mem=%d",
- SPL_CONN_POOL_NAME, CUR_CFG_SOCKET_NUM,
- nsfw_mem_get_len (pool, NSFW_MEM_SPOOL));
-
- sbr_recycle_group *recycle_group =
- (sbr_recycle_group *) sbr_create_mzone (SPL_RECYCLE_GROUP,
- sizeof (sbr_recycle_group));
- if (!recycle_group)
- {
- return -1;
- }
-
- NSPOL_LOGINF (SC_DPDK_INFO, "Create recycle_group zone ok]name=%s, size=%u",
- SPL_RECYCLE_GROUP, sizeof (sbr_recycle_group));
-
- recycle_group->conn_array = conn_array;
- recycle_group->conn_num = spl_get_conn_num ();
- recycle_group->conn_pool = pool;
- recycle_group->extend_member_bit = 0;
- recycle_group->msg_pool = group->msg_pool;
-
- spl_netconn_t *conn = NULL;
- unsigned int i = 0;
- while (i < CUR_CFG_SOCKET_NUM)
- {
- if (nsfw_mem_ring_dequeue (pool, (void **) &conn) != 1)
- {
- NSPOL_LOGERR ("nsfw_mem_ring_dequeue failed,this can not happen");
- return -1;
- }
-
- ss_reset_conn (conn);
- conn->recycle.group = recycle_group;
-
- if (nsfw_mem_ring_dequeue (group->recv_ring_pool, &conn->recv_ring) !=
- 1)
- {
- NSPOL_LOGERR ("nsfw_mem_ring_dequeue failed,this can not happen");
- return -1;
- }
-
- conn_array[i] = conn;
-
- if (nsfw_mem_ring_enqueue (pool, (void *) conn) != 1)
- {
- NSPOL_LOGERR ("nsfw_mem_ring_enqueue failed,this can not happen");
- return -1;
- }
-
- i++;
- }
-
- group->conn_pool = pool;
- group->conn_array = conn_array;
-
- MEM_STAT (SPL_APP_RES, SPL_RECYCLE_GROUP, NSFW_SHMEM,
- sizeof (sbr_recycle_group));
- MEM_STAT (SPL_APP_RES, SPL_CONN_ARRAY_NAME, NSFW_SHMEM,
- sizeof (spl_netconn_t *) * CUR_CFG_SOCKET_NUM);
- MEM_STAT (SPL_APP_RES, SPL_CONN_POOL_NAME, NSFW_SHMEM,
- nsfw_mem_get_len (group->conn_pool, NSFW_MEM_SPOOL));
- return 0;
-}
-
-int
-spl_force_msg_free (void *data)
-{
- data_com_msg *m = (data_com_msg *) data;
- if (NULL == m)
- {
- return FALSE;
- }
-
- NSFW_LOGINF ("force free msg]msg=%p", data);
- (void) res_free (&m->param.res_chk);
- m->param.recycle_pid = 0;
- if (nsfw_mem_ring_enqueue (m->param.msg_from, (void *) m) != 1)
- {
- NSFW_LOGERR ("nsfw_mem_ring_enqueue failed,this can not happen");
- }
- return TRUE;
-}
-
-/*****************************************************************************
-* Prototype : spl_create_msg_pool
-* Description : create msg pool
-* Input : None
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-spl_create_msg_pool (spl_app_res_group * group)
-{
- mring_handle pool =
- sbr_create_pool (SPL_MSG_POOL_NAME, SPL_MAX_MSG_NUM - 1, MAX_MSG_SIZE);
-
- if (!pool)
- {
- return -1;
- }
-
- data_com_msg *m = NULL;
- unsigned int i = 0;
- while (i < SPL_MAX_MSG_NUM)
- {
- if (nsfw_mem_ring_dequeue (pool, (void **) &m) != 1)
- {
- NSPOL_LOGERR ("nsfw_mem_ring_dequeue failed,this can not happen");
- return -1;
- }
-
- m->param.msg_from = pool;
- m->param.recycle_pid = 0;
- sys_sem_init (&m->param.op_completed);
-
- if (nsfw_mem_ring_enqueue (pool, (void *) m) != 1)
- {
- NSPOL_LOGERR ("nsfw_mem_ring_enqueue failed,this can not happen");
- return -1;
- }
-
- i++;
- }
-
- group->msg_pool = pool;
-
- NSPOL_LOGINF (SC_DPDK_INFO,
- "Create app msg pool ok]name=%s, num=%u, size=%u, total_mem=%d",
- SPL_MSG_POOL_NAME, SPL_MAX_MSG_NUM, MAX_MSG_SIZE,
- nsfw_mem_get_len (group->msg_pool, NSFW_MEM_SPOOL));
- MEM_STAT (SPL_APP_RES, SPL_MSG_POOL_NAME, NSFW_SHMEM,
- nsfw_mem_get_len (group->msg_pool, NSFW_MEM_SPOOL));
- return 0;
-}
-
-/*****************************************************************************
-* Prototype : spl_regist_recycle
-* Description : regist recycle
-* Input : None
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-spl_regist_recycle (spl_app_res_group * group)
-{
- void *ret =
- nsfw_recycle_reg_obj (NSFW_REC_PRO_DEFAULT, NSFW_REC_SBR_SOCKET, NULL);
-
- if (!ret)
- {
- NSSBR_LOGERR ("failed");
- return -1;
- }
-
- if (NULL == group)
- {
- NSSBR_LOGERR ("g_spl_app_res_group null");
- return -1;
- }
-
- nsfw_res_scn_cfg scn_cfg = { NSFW_RES_SCAN_SPOOL, 90, 3, 16,
- CUR_CFG_SOCKET_NUM / 128, CUR_CFG_SOCKET_NUM - 1,
- SBR_FD_NETCONN_SIZE,
- offsetof (spl_netconn_t, res_chk),
- (void *) group->conn_pool,
- (void *) group->conn_pool,
- spl_force_netconn_free
- };
-
- (void) nsfw_res_mgr_reg (&scn_cfg);
-
- nsfw_res_scn_cfg scn_cfg_msg = { NSFW_RES_SCAN_SPOOL, 60, 3, 16,
- SPL_MAX_MSG_NUM / 128, SPL_MAX_MSG_NUM,
- MAX_MSG_SIZE,
- offsetof (data_com_msg, param.res_chk),
- (void *) group->msg_pool,
- (void *) group->msg_pool,
- spl_force_msg_free
- };
- (void) nsfw_res_mgr_reg (&scn_cfg_msg);
-
- return 0;
-}
-
-void
-spl_reg_tx_pool_mgr (mpool_handle pool_array[], u32 num)
-{
- u32 loop;
- for (loop = 0; loop < num; loop++)
- {
- (void) spl_reg_res_txrx_mgr (pool_array[loop]); // will only return 0, no need to check return value
- }
-
- return;
-}
-
-/*****************************************************************************
-* Prototype : sbr_create_tx_pool
-* Description : create tx pool,spl call this fun
-* Input : None
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-spl_create_tx_pool (mpool_handle pool_array[], u32 array_size)
-{
- data_com_msg *tx_msg_array =
- (data_com_msg *) sbr_create_mzone (SBR_TX_MSG_ARRAY_NAME,
- (size_t) sizeof (data_com_msg) *
- SBR_TX_MSG_NUM);
-
- if (!tx_msg_array)
- {
- NSSBR_LOGERR ("Create tx_msg_array zone fail]name=%s, num=%u, size=%u",
- SBR_TX_MSG_ARRAY_NAME, SBR_TX_MSG_NUM,
- (size_t) sizeof (data_com_msg) * SBR_TX_MSG_NUM);
- return -1;
- }
-
- MEM_STAT (SBR_TX_POOL_NAME, SBR_TX_MSG_ARRAY_NAME, NSFW_SHMEM,
- (size_t) sizeof (data_com_msg) * SBR_TX_MSG_NUM);
- NSSBR_LOGINF
- ("Create tx_msg_array zone ok]name=%s, ptr=%p, num=%u, size=%u",
- SBR_TX_MSG_ARRAY_NAME, tx_msg_array, SBR_TX_MSG_NUM,
- sizeof (data_com_msg) * SBR_TX_MSG_NUM);
-
- mpool_handle mp;
- int ret;
- char tx_pool_name[64];
- u32 loop;
- for (loop = 0; loop < array_size; loop++)
- {
- ret =
- SPRINTF_S (tx_pool_name, sizeof (tx_pool_name), "%s_%d",
- SBR_TX_POOL_NAME, loop);
- if (-1 == ret)
- {
- NSSBR_LOGERR ("SPRINTF_S failed]ret=%d", ret);
- return -1;
- }
-
- nsfw_mem_mbfpool pool_param;
- if (STRCPY_S
- (pool_param.stname.aname, NSFW_MEM_NAME_LENTH, tx_pool_name) != 0)
- {
- NSSBR_LOGERR ("STRCPY_S failed]name=%s", tx_pool_name);
- return -1;
- }
-
- pool_param.isocket_id = -1;
- pool_param.stname.entype = NSFW_SHMEM;
- pool_param.enmptype = NSFW_MRING_MPMC;
- pool_param.uscash_size = 0;
- pool_param.uspriv_size = 0;
- pool_param.usdata_room = TX_MBUF_MAX_LEN;
- pool_param.usnum = SBR_TX_POOL_MBUF_NUM - 1;
-
- mp = nsfw_mem_mbfmp_create (&pool_param);
- if (!mp)
- {
- NSSBR_LOGERR ("Create tx_mbuf_pool fail]name=%s, num=%u, room=%u",
- tx_pool_name, SBR_TX_POOL_MBUF_NUM,
- pool_param.usdata_room);
- return -1;
- }
- else
- {
- struct common_mem_mbuf *mbuf = NULL;
- struct spl_pbuf *buf = NULL;
- int i = 0;
- while (i < (int) SBR_TX_POOL_MBUF_NUM)
- {
- mbuf = nsfw_mem_mbf_alloc (mp, NSFW_SHMEM);
- if (!mbuf)
- {
- NSSBR_LOGERR
- ("nsfw_mem_mbf_alloc failed,this can not happen");
- return -1;
- }
-
- buf =
- (struct spl_pbuf *) ((char *) mbuf +
- sizeof (struct common_mem_mbuf));
- int idx = loop * (int) SBR_TX_POOL_MBUF_NUM + i;
- sys_sem_init (&tx_msg_array[idx].param.op_completed);
- tx_msg_array[idx].param.msg_from = NULL;
- buf->msg = (void *) &tx_msg_array[idx];
- (void) res_free (&buf->res_chk); //no need to check return value, as it will do free operation depends on alloc_flag
-
- if (nsfw_mem_mbf_free (mbuf, NSFW_SHMEM) < 0)
- {
- NSSBR_LOGERR
- ("nsfw_mem_mbf_free failed,this can not happen");
- return -1;
- }
-
- i++;
- }
-
- pool_array[loop] = mp;
-#ifdef SYS_MEM_RES_STAT
- g_app_tx_pool[loop] = mp;
-#endif
- }
- }
-
- spl_reg_tx_pool_mgr (pool_array, array_size);
-
- NSSBR_LOGINF ("Create all tx_mbuf_pool ok]pool_num=%d, total_mem=%d",
- array_size, nsfw_mem_get_len (pool_array[0],
- NSFW_MEM_MBUF) * array_size);
- MEM_STAT (SBR_TX_POOL_NAME, SBR_TX_POOL_NAME, NSFW_SHMEM,
- nsfw_mem_get_len (pool_array[0], NSFW_MEM_MBUF) * array_size);
- return 0;
-}
-
-spl_app_res_group *
-spl_create_res_group ()
-{
- spl_app_res_group *group = spl_create_group ();
- if (NULL == group)
- {
- NSPOL_LOGERR ("spl_create_group failed");
- return NULL;
- }
-
- NSPOL_LOGDBG (SC_DPDK_INFO, "spl_create_group ok");
-
- if (spl_create_ring_pool (group) != 0)
- {
- NSPOL_LOGERR ("spl_create_ring_pool failed");
- return NULL;
- }
-
- NSPOL_LOGDBG (SC_DPDK_INFO, "spl_create_ring_pool ok");
-
- if (spl_create_msg_pool (group) != 0)
- {
- NSPOL_LOGERR ("spl_create_msg_pool failed");
- return NULL;
- }
-
- NSPOL_LOGDBG (SC_DPDK_INFO, "spl_create_msg_pool ok");
-
- if (spl_create_netconn_pool (group) != 0)
- {
- NSPOL_LOGERR ("spl_create_netconn_pool failed");
- return NULL;
- }
-
- NSPOL_LOGDBG (SC_DPDK_INFO, "spl_create_netconn_pool ok");
-
- if (spl_regist_recycle (group) != 0)
- {
- NSPOL_LOGERR ("spl_regist_recycle failed");
- return NULL;
- }
-
- NSPOL_LOGDBG (SC_DPDK_INFO, "spl_regist_recycle ok");
-
- if (spl_create_tx_pool (group->tx_pool_array, SBR_TX_POOL_NUM) != 0)
- {
- NSPOL_LOGERR ("spl_create_tx_pool failed");
- return NULL;
- }
-
- NSPOL_LOGDBG (SC_DPDK_INFO, "spl_create_tx_pool ok");
-
- return group;
-}
-
-/*****************************************************************************
-* Prototype : spl_init_app_res
-* Description : init app res
-* Input : None
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-spl_init_app_res ()
-{
- g_spl_app_res_group = spl_create_res_group ();
- if (NULL == g_spl_app_res_group)
- {
- NSPOL_LOGERR ("spl_create_group failed");
- return -1;
- }
-
- return spl_add_instance_res_group (0, g_spl_app_res_group);
-}
-
-/*****************************************************************************
-* Prototype : spl_get_conn_array
-* Description : get conn array
-* Input : u32 pid
-* Output : None
-* Return Value : spl_netconn_t**
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-spl_netconn_t **
-spl_get_conn_array (u32 pid)
-{
- return (spl_netconn_t **) ADDR_SHTOL (g_spl_app_res_group->conn_array);
-}
-
-/*****************************************************************************
-* Prototype : spl_get_conn_pool
-* Description : get conn pool
-* Input : None
-* Output : None
-* Return Value : mring_handle
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-mring_handle
-spl_get_conn_pool ()
-{
- return (mring_handle) ADDR_SHTOL (g_spl_app_res_group->conn_pool);
-}
-
-/*****************************************************************************
-* Prototype : spl_get_msg_pool
-* Description : get msg pool
-* Input : None
-* Output : None
-* Return Value : mring_handle
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-mring_handle
-spl_get_msg_pool ()
-{
- return (mring_handle) ADDR_SHTOL (g_spl_app_res_group->msg_pool);
-}
-
-/*****************************************************************************
-* Prototype : spl_recycle_msg
-* Description : recycle msg
-* Input : void *data
-* void* argv
-* Output : None
-* Return Value : static int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static int
-spl_recycle_msg (void *data, void *argv)
-{
- if (!data)
- {
- NSPOL_LOGERR ("data is NULL]data=%p,pid=%p", data, argv);
- return -1;
- }
-
- data_com_msg *m = (data_com_msg *) data;
- u64 pid_64 = (u64) argv;
- u32 pid = (u32) pid_64;
- if (pid == m->param.recycle_pid)
- {
- ASYNC_MSG_FREE (m);
- }
-
- return 0;
-}
-
-/*****************************************************************************
-* Prototype : spl_recycle_msg_pool
-* Description : recycle msg pool
-* Input : u32 pid
-* Output : None
-* Return Value : void
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-void
-spl_recycle_msg_pool (u32 pid)
-{
- mring_handle msg_pool = spl_get_msg_pool ();
- if (!msg_pool)
- {
- NSPOL_LOGERR ("msg_pool is NULL,this can not happen]pid=%u", pid);
- return;
- }
-
- u64 pid_64 = pid;
- (void) nsfw_mem_sp_iterator (msg_pool, 0, SPL_MAX_MSG_NUM, spl_recycle_msg,
- (void *) pid_64);
-}
-
-/*****************************************************************************
-* Prototype : spl_get_conn_num
-* Description : get conn num
-* Input : None
-* Output : None
-* Return Value : u32
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-u32
-spl_get_conn_num ()
-{
- return CUR_CFG_SOCKET_NUM;
-}
-
-/***************************************************
-* description:
-***************************************************/
-int
-sbr_malloc_tx_pool (u32 pid, mpool_handle pool[], u32 pool_num)
-{
- int loop;
- for (loop = 0; loop < SBR_TX_POOL_NUM; loop++)
- {
- if ((0 == g_res_group_array->pid_array[loop])
- &&
- __sync_bool_compare_and_swap (&g_res_group_array->pid_array[loop],
- 0, pid))
- {
- u32 i;
- for (i = 0; i < g_res_group_array->thread_num && i < pool_num; ++i)
- {
- spl_app_res_group *group =
- (spl_app_res_group *)
- ADDR_SHTOL (g_res_group_array->res_group[i]);
- pool[i] = ADDR_SHTOL (group->tx_pool_array[loop]);
- }
-
- NSSBR_LOGINF ("get tx pool]pid=%d,loop=%d.", pid, loop);
- return 0;
- }
- }
-
- for (loop = 0; loop < SBR_TX_POOL_NUM; loop++)
- {
- NSSBR_LOGERR ("no free pool]loop=%d,pid=%d", loop,
- g_res_group_array->pid_array[loop]);
- }
-
- return -1;
-}
-
-/***************************************************
-* description:
-***************************************************/
-void
-spl_free_tx_pool (u32 pid)
-{
- int loop;
- for (loop = 0; loop < SBR_TX_POOL_NUM; loop++)
- {
- if (pid == g_res_group_array->pid_array[loop])
- {
- u32 i;
- for (i = 0; i < g_res_group_array->thread_num; ++i)
- {
- (void)
- nsfw_mem_mbuf_pool_recycle (g_res_group_array->res_group
- [i]->tx_pool_array[loop]);
- }
-
- if (!__sync_bool_compare_and_swap
- (&g_res_group_array->pid_array[loop], pid, 0))
- {
- NSSBR_LOGERR ("free tx_pool failed]loop=%d,pid=%d", loop, pid);
- }
- else
- {
- NSSBR_LOGDBG ("free tx_pool ok]loop=%d,pid=%d", loop, pid);
- }
-
- break;
- }
- }
-}
-
-/***************************************************
-* description:
-***************************************************/
-mring_handle
-sbr_get_instance_conn_pool (u32 thread_index)
-{
- if (thread_index >= g_res_group_array->thread_num)
- {
- return NULL;
- }
-
- spl_app_res_group *group =
- (spl_app_res_group *)
- ADDR_SHTOL (g_res_group_array->res_group[thread_index]);
- return ADDR_SHTOL (group->conn_pool);
-}
-
-/***************************************************
-* description:
-***************************************************/
-mring_handle *
-ss_get_instance_msg_box (u16 thread_index, u16 idx)
-{
- if (thread_index >= g_res_group_array->thread_num)
- {
- thread_index = 0;
- }
-
- if (idx >= SPL_MSG_BOX_NUM)
- {
- idx = 0;
- }
-
- spl_app_res_group *group =
- (spl_app_res_group *)
- ADDR_SHTOL (g_res_group_array->res_group[thread_index]);
- return ADDR_SHTOL (group->mbox_array[idx]);
-}
diff --git a/stacks/lwip_stack/lwip_src/common/stackx_app_res.h b/stacks/lwip_stack/lwip_src/common/stackx_app_res.h
deleted file mode 100644
index 435f2f6..0000000
--- a/stacks/lwip_stack/lwip_src/common/stackx_app_res.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef STACKX_APP_RES_H
-#define STACKX_APP_RES_H
-#include "types.h"
-#include "nsfw_mem_api.h"
-#include "stackxopts.h"
-#include "stackx_spl_share.h"
-#include "nsfw_mt_config.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-#define SPL_RES_GROUP_ARRAY "spl_res_group_array"
-
-#define SPL_APP_RES "spl_app_res"
-#define SPL_APP_RES_GROUP_NAME "spl_app_res_group"
-#define SPL_TX_POOL_NAME "spl_tx_pool"
-#define SPL_CONN_POOL_NAME "spl_conn_pool"
-#define SPL_CONN_ARRAY_NAME "spl_conn_array"
-#define SPL_DFX_ARRAY_NAME "spl_dfx_array"
-#define SPL_MSG_POOL_NAME "spl_msg_pool"
-#define SPL_RECYCLE_GROUP "spl_recycle_group"
-#define SPL_RECV_RING_POOL_NAME "spl_recv_ring_pool"
-#define SPL_RECV_RING_ARRAY_NAME "spl_recv_array"
-
-#define SBR_TX_POOL_NUM APP_POOL_NUM
-#define SBR_TX_POOL_MBUF_NUM TX_MBUF_POOL_SIZE
-#define SBR_TX_MSG_NUM (SBR_TX_POOL_NUM * SBR_TX_POOL_MBUF_NUM)
-
-#define SBR_TX_POOL_ARRAY_NAME "sbr_tx_pool_array"
-#define SBR_TX_POOL_NAME "sbr_tx_pool"
-#define SBR_TX_MSG_ARRAY_NAME "sbr_tx_msg_array"
-
-#define SPL_MAX_MSG_NUM (MBOX_RING_SIZE*8*MAX_THREAD_NUM)
-
-typedef struct
-{
- PRIMARY_ADDR mring_handle msg_pool;
- PRIMARY_ADDR mring_handle conn_pool;
- PRIMARY_ADDR spl_netconn_t **conn_array;
- PRIMARY_ADDR mring_handle recv_ring_pool;
- PRIMARY_ADDR mpool_handle tx_pool_array[SBR_TX_POOL_NUM];
- PRIMARY_ADDR mring_handle mbox_array[SPL_MSG_BOX_NUM];
- i64 extend_member_bit;
-} spl_app_res_group;
-
-typedef struct
-{
- u32 pid_array[SBR_TX_POOL_NUM];
- PRIMARY_ADDR spl_app_res_group *res_group[MAX_THREAD_NUM];
- u16 thread_num;
-} spl_app_res_group_array;
-
-extern spl_app_res_group *g_spl_app_res_group;
-extern spl_app_res_group_array *g_res_group_array;
-
-/* call it main thread */
-int spl_init_group_array ();
-
-/* call these in tcpip thread */
-int spl_init_app_res ();
-spl_netconn_t **spl_get_conn_array (u32 pid);
-mring_handle spl_get_conn_pool ();
-mring_handle spl_get_msg_pool ();
-void spl_recycle_msg_pool (u32 pid);
-u32 spl_get_conn_num ();
-void spl_free_tx_pool (u32 pid);
-int spl_add_mbox (mring_handle mbox_array[], u32 array_size);
-int spl_add_instance_res_group (u32 thread_index, spl_app_res_group * group);
-
-/* call these in app */
-int sbr_malloc_tx_pool (u32 pid, mpool_handle pool[], u32 pool_num);
-int sbr_attach_group_array ();
-mring_handle sbr_get_instance_conn_pool (u32 thread_index);
-
-/* call these in app and spl */
-mring_handle *ss_get_instance_msg_box (u16 thread_index, u16 index);
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif
diff --git a/stacks/lwip_stack/lwip_src/common/stackx_common.c b/stacks/lwip_stack/lwip_src/common/stackx_common.c
deleted file mode 100644
index 750df74..0000000
--- a/stacks/lwip_stack/lwip_src/common/stackx_common.c
+++ /dev/null
@@ -1,357 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include <stdarg.h>
-#include <stddef.h>
-#include "stackx_common.h"
-#include "nstack_securec.h"
-#include "nstack_log.h"
-#include "types.h"
-#include "stackx_types.h"
-
-int
-spl_snprintf (char *buffer, int buflen, const char *format, ...)
-{
- int len;
- va_list ap;
-
- if ((NULL == buffer) || (0 >= buflen))
- {
- return -1;
- }
-
- if (format == NULL)
- {
- buffer[0] = '\0';
- return -1;
- }
-
- (void) va_start (ap, format);
- len = VSNPRINTF_S (buffer, buflen, buflen - 1, format, ap);
- if (-1 == len)
- {
- va_end (ap);
- return -1;
- }
-
- va_end (ap);
- if ((len >= buflen) && (buflen > 0) && (buffer != NULL))
- {
- buffer[buflen - 1] = '\0';
- }
-
- return len;
-}
-
-/*****************************************************************************
-* Prototype : sbr_create_mzone
-* Description : create mzone
-* Input : const char* name
-* size_t size
-* Output : None
-* Return Value : mzone_handle
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-mzone_handle
-sbr_create_mzone (const char *name, size_t size)
-{
- if (!name)
- {
- NSFW_LOGERR ("name is NULL");
- return NULL;
- }
-
- mzone_handle zone;
- nsfw_mem_zone param;
-
- param.isocket_id = -1;
- param.length = size;
- param.stname.entype = NSFW_SHMEM;
-
- if (STRCPY_S (param.stname.aname, NSFW_MEM_NAME_LENTH, name) != 0)
- {
- NSFW_LOGERR ("STRCPY_S failed]name=%s", name);
- return NULL;
- }
-
- zone = nsfw_mem_zone_create (&param);
- if (!zone)
- {
- NSFW_LOGERR ("nsfw_mem_zone_create failed]name=%s, size:%zu", name,
- size);
- return NULL;
- }
-
- return zone;
-}
-
-/*****************************************************************************
-* Prototype : sbr_lookup_mzone
-* Description : lookup mzone
-* Input : const char* name
-* Output : None
-* Return Value : mzone_handle
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-mzone_handle
-sbr_lookup_mzone (const char *name)
-{
- if (!name)
- {
- NSFW_LOGERR ("name is NULL");
- return NULL;
- }
-
- mzone_handle zone;
- nsfw_mem_name param;
-
- param.entype = NSFW_SHMEM;
- param.enowner = NSFW_PROC_MAIN;
- if (STRCPY_S (param.aname, NSFW_MEM_NAME_LENTH, name) != 0)
- {
- NSFW_LOGERR ("STRCPY_S failed]name=%s", name);
- return NULL;
- }
-
- zone = nsfw_mem_zone_lookup (&param);
- if (!zone)
- {
- NSFW_LOGERR ("nsfw_mem_zone_lookup failed]name=%s", name);
- return NULL;
- }
-
- return zone;
-}
-
-/*****************************************************************************
-* Prototype : sbr_create_pool
-* Description : create pool
-* Input : const char* name
-* i32 num
-* u16 size
-* Output : None
-* Return Value : mring_handle
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-mring_handle
-sbr_create_pool (const char *name, i32 num, u16 size)
-{
- if (!name)
- {
- NSFW_LOGERR ("name is NULL");
- return NULL;
- }
-
- nsfw_mem_sppool param;
- if (EOK != MEMSET_S (&param, sizeof (param), 0, sizeof (param)))
- {
- NSFW_LOGERR ("memset error]name=%s", name);
- return NULL;
- }
-
- param.enmptype = NSFW_MRING_MPMC;
- param.useltsize = size;
- param.usnum = num;
- param.stname.entype = NSFW_SHMEM;
- param.isocket_id = -1;
- if (STRCPY_S (param.stname.aname, NSFW_MEM_NAME_LENTH, name) != 0)
- {
- NSFW_LOGERR ("STRCPY_S failed]name=%s", name);
- return NULL;
- }
-
- mring_handle ring = nsfw_mem_sp_create (&param);
- if (!ring)
- {
- NSFW_LOGERR ("Create pool failed]name=%s, num=%d, size=%u", name, num,
- size);
- }
-
- return ring;
-}
-
-/*****************************************************************************
-* Prototype : sbr_create_ring
-* Description : create ring
-* Input : const char* name
-* i32 num
-* Output : None
-* Return Value : mring_handle
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-mring_handle
-sbr_create_ring (const char *name, i32 num)
-{
- if (!name)
- {
- NSFW_LOGERR ("name is NULL");
- return NULL;
- }
-
- nsfw_mem_mring param;
- if (EOK != MEMSET_S (&param, sizeof (param), 0, sizeof (param)))
- {
- NSFW_LOGERR ("memset error]name=%s", name);
- return NULL;
- }
-
- param.enmptype = NSFW_MRING_MPMC;
- param.isocket_id = -1;
- param.usnum = num;
- param.stname.entype = NSFW_SHMEM;
-
- if (STRCPY_S (param.stname.aname, NSFW_MEM_NAME_LENTH, name) != 0)
- {
- NSFW_LOGERR ("STRCPY_S failed]name=%s", name);
- return NULL;
- }
-
- mring_handle ring = nsfw_mem_ring_create (&param);
- if (!ring)
- {
- NSFW_LOGERR ("Create ring failed]name=%s, num=%d", name, num);
- }
-
- return ring;
-}
-
-/*****************************************************************************
-* Prototype : sbr_create_multi_ring
-* Description : create multi ring
-* Input : const char* name
-* u32 ring_size
-* i32 ring_num
-* mring_handle* array
-* nsfw_mpool_type type
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_create_multi_ring (const char *name, u32 ring_size, i32 ring_num,
- mring_handle * array, nsfw_mpool_type type)
-{
- if (!name)
- {
- NSFW_LOGERR ("name is NULL");
- return -1;
- }
-
- if (!array)
- {
- NSFW_LOGERR ("array is NULL");
- return -1;
- }
-
- nsfw_mem_mring param;
-
- if (EOK != MEMSET_S (&param, sizeof (param), 0, sizeof (param)))
- {
- NSSBR_LOGERR ("Error to memset]name=%s", name);
- return -1;
- }
-
- param.enmptype = type;
- param.stname.entype = NSFW_SHMEM;
- if (STRCPY_S (param.stname.aname, NSFW_MEM_NAME_LENTH, name) != 0)
- {
- NSSBR_LOGERR ("STRCPY_S failed]name=%s", name);
- return -1;
- }
-
- param.usnum = ring_size;
- param.isocket_id = -1;
- if (nsfw_mem_sp_ring_create (&param, array, ring_num) != 0)
- {
- NSSBR_LOGERR ("Create ring pool failed]name=%s, ring_num=%d", name,
- ring_num);
- return -1;
- }
-
- return 0;
-}
-
-/*****************************************************************************
-* Prototype : sbr_lookup_ring
-* Description : lookup ring
-* Input : const char* name
-* Output : None
-* Return Value : mring_handle
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-mring_handle
-sbr_lookup_ring (const char *name)
-{
- nsfw_mem_name param;
-
- param.entype = NSFW_SHMEM;
- param.enowner = NSFW_PROC_MAIN;
- if (STRCPY_S (param.aname, NSFW_MEM_NAME_LENTH, name) != 0)
- {
- NSFW_LOGERR ("STRCPY_S failed]name=%s", name);
- return NULL;
- }
-
- mring_handle ring = nsfw_mem_ring_lookup (&param);
- if (!ring)
- {
- NSFW_LOGERR ("lookup ring failed]name=%s", name);
- }
-
- return ring;
-}
-
-int
-sbr_timeval2msec (struct timeval *pTime, u64 * msec)
-{
- if ((pTime->tv_sec < 0) || (pTime->tv_usec < 0))
- {
- NSFW_LOGERR ("time->tv_sec is nagative");
- return -1;
- }
-
- if (STACKX_MAX_U64_NUM / 1000 < (u64_t) pTime->tv_sec)
- {
- NSFW_LOGERR ("tout.tv_sec is too large]tout.tv_sec=%lu", pTime->tv_sec);
- return -1;
- }
-
- u64 sec2msec = 1000 * pTime->tv_sec;
- u64 usec2msec = pTime->tv_usec / 1000;
-
- if (STACKX_MAX_U64_NUM - sec2msec < usec2msec)
- {
- NSFW_LOGERR
- ("nsec2msec plus sec2usec is too large]usec2msec=%lu,usec2msec=%lu",
- usec2msec, sec2msec);
- return -1;
- }
-
- *msec = sec2msec + usec2msec;
- return 0;
-}
diff --git a/stacks/lwip_stack/lwip_src/common/stackx_common.h b/stacks/lwip_stack/lwip_src/common/stackx_common.h
deleted file mode 100644
index 1df97d5..0000000
--- a/stacks/lwip_stack/lwip_src/common/stackx_common.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef STACKX_COMMON_H
-#define STACKX_COMMON_H
-#include "nsfw_mem_api.h"
-//#include "lwip/cc.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-int spl_snprintf (char *buffer, int buflen, const char *format, ...);
-mzone_handle sbr_create_mzone (const char *name, size_t size);
-mzone_handle sbr_lookup_mzone (const char *name);
-mring_handle sbr_create_pool (const char *name, i32 num, u16 size);
-mring_handle sbr_create_ring (const char *name, i32 num);
-int sbr_create_multi_ring (const char *name, u32 ring_size, i32 ring_num,
- mring_handle * array, nsfw_mpool_type type);
-mring_handle sbr_lookup_ring (const char *name);
-int sbr_timeval2msec (struct timeval *pTime, u64 * msec);
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif
diff --git a/stacks/lwip_stack/lwip_src/common/stackx_common_opt.h b/stacks/lwip_stack/lwip_src/common/stackx_common_opt.h
deleted file mode 100644
index feccc3f..0000000
--- a/stacks/lwip_stack/lwip_src/common/stackx_common_opt.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef STACKX_COMMON_OPT_H
-#define STACKX_COMMON_OPT_H
-#include <sys/ioctl.h>
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-#ifndef O_NONBLOCK
-#define O_NONBLOCK 0X800 /* nonblocking I/O */
-#endif
-
-#if !defined (FIONREAD) || !defined (FIONBIO)
-#define IOC_VOID 0x20000000UL /* no parameters */
-#define IOC_OUT 0x40000000UL /* copy out parameters */
-#define IOC_IN 0x80000000UL /* copy in parameters */
-#define IOCPARM_MASK 0x7fU /* parameters must be < 128 bytes */
-#define IOC_INOUT (IOC_IN | IOC_OUT) /* 0x20000000 distinguishes new & old ioctl's */
-#define _IO(x, y) (((x) << 8) | (y) | IOC_VOID)
-#define _IOR(x, y, t) (IOC_OUT | (((long)sizeof(t) & IOCPARM_MASK) << 16) | ((x) << 8) | (y))
-#define _IOW(x, y, t) (IOC_IN | (((long)sizeof(t) & IOCPARM_MASK) << 16) | ((x) << 8) | (y))
-#endif
-
-#ifndef FIONREAD
-#define FIONREAD _IOR('f', 127, unsigned long)
-#endif
-
-#ifndef FIONBIO
-#define FIONBIO _IOW('f', 126, unsigned long)
-#endif
-
-#ifndef F_GETFL
-#define F_GETFL 3
-#endif
-
-#ifndef F_SETFL
-#define F_SETFL 4
-#endif
-
-#ifndef SPL_SHUT_RD
-#define SPL_SHUT_RD 0
-#define SPL_SHUT_WR 1
-#define SPL_SHUT_RDWR 2
-#endif
-
-/* Flags for struct netconn.flags (u8_t) */
-
-/** TCP: when data passed to netconn_write doesn't fit into the send buffer,
- this temporarily stores whether to wake up the original application task
- if data couldn't be sent in the first try. */
-#define SPL_NETCONN_FLAG_WRITE_DELAYED 0x01
-
-/** Should this netconn avoid blocking? */
-#define SPL_NETCONN_FLAG_NON_BLOCKING 0x02
-
-/** Was the last connect action a non-blocking one? */
-#define SPL_NETCONN_FLAG_IN_NONBLOCKING_CONNECT 0x04
-
-/** If this is set, a TCP netconn must call netconn_recved() to update
- the TCP receive window (done automatically if not set). */
-#define SPL_NETCONN_FLAG_NO_AUTO_RECVED 0x08
-
-/** If a nonblocking write has been rejected before, poll_tcp needs to
- check if the netconn is writable again */
-#define SPL_NETCONN_FLAG_CHECK_WRITESPACE 0x10
-
-/* For the netconn API, these values are use as a bitmask! */
-#define SPL_NETCONN_SHUT_RD 1
-#define SPL_NETCONN_SHUT_WR 2
-#define SPL_NETCONN_SHUT_RDWR (SPL_NETCONN_SHUT_RD | SPL_NETCONN_SHUT_WR)
-#define STACKX_TIMER_THREAD_SUPPORT 1
-
-/* Flags for netconn_write (u8_t) */
-#define SPL_NETCONN_NOFLAG 0x00
-#define SPL_NETCONN_NOCOPY 0x00
-#define SPL_NETCONN_COPY 0x01
-#define SPL_NETCONN_MORE 0x02
-#define SPL_NETCONN_DONTBLOCK 0x04
-
-#define SPL_TCP_NODELAY 0x01
-#define SPL_TCP_KEEPALIVE 0x02
-#define SPL_TCP_KEEPIDLE 0x04
-#define SPL_TCP_KEEPINTVL 0x05
-#define SPL_TCP_KEEPCNT 0x06
-#define SPL_TCP_LINGER2 0x08
-#define SPL_TCP_DEFER_ACCEPT 0x09
-#define SPL_TCP_INFO 0x0B
-
-typedef enum spl_netconn_type
-{
- SPL_NETCONN_INVALID = 0,
- SPL_NETCONN_TCP = 0x10,
- SPL_NETCONN_UDP = 0x20,
- SPL_NETCONN_UDPLITE = 0x21,
- SPL_NETCONN_UDPNOCHKSUM = 0x22,
- SPL_NETCONN_RAW = 0x40,
-} spl_netconn_type_t;
-
-typedef enum spl_netconn_state
-{
- SPL_NETCONN_NONE,
- SPL_NETCONN_WRITE,
- SPL_NETCONN_LISTEN,
- SPL_NETCONN_CONNECT,
- SPL_NETCONN_CLOSE,
-} spl_netconn_state_t;
-
-typedef enum spl_tcp_state
-{
- SPL_CLOSED = 0,
- SPL_LISTEN = 1,
- SPL_SYN_SENT = 2,
- SPL_SYN_RCVD = 3,
- SPL_ESTABLISHED = 4,
- SPL_FIN_WAIT_1 = 5,
- SPL_FIN_WAIT_2 = 6,
- SPL_CLOSE_WAIT = 7,
- SPL_CLOSING = 8,
- SPL_LAST_ACK = 9,
- SPL_TIME_WAIT = 10
-} spl_tcp_state_t;
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif
diff --git a/stacks/lwip_stack/lwip_src/common/stackx_debug.h b/stacks/lwip_stack/lwip_src/common/stackx_debug.h
deleted file mode 100644
index 7c6395e..0000000
--- a/stacks/lwip_stack/lwip_src/common/stackx_debug.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef __STACKX_DEBUG_H__
-#define __STACKX_DEBUG_H__
-
-//#include "lwip/arch.h"
-#include <pthread.h>
-
-#include <sys/syscall.h>
-
-#include "nstack_log.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-/** lower two bits indicate dbug level
- * - 0 all
- * - 1 warning
- * - 2 serious
- * - 3 severe
- */
-#define STACKX_DBG_LEVEL_ALL 0x00
-#define STACKX_DBG_LEVEL_OFF STACKX_DBG_LEVEL_ALL /* compatibility define only */
-#define STACKX_DBG_LEVEL_WARNING 0x01 /* bad checksums, dropped packets, ... */
-#define STACKX_DBG_LEVEL_SERIOUS 0x02 /* memory allocation failures, ... */
-#define STACKX_DBG_LEVEL_SEVERE 0x03
-#define STACKX_DBG_MASK_LEVEL 0x00
-
-/** flag to enable that dbug message */
-#define STACKX_DBG_ON NS_LOG_STACKX_ON
-
-/** flag to disable that dbug message */
-#define STACKX_DBG_OFF NS_LOG_STACKX_OFF
-
-/** flag for indicating a tracing_message (to follow program flow) */
-#define STACKX_DBG_TRACE NS_LOG_STACKX_TRACE
-
-/** flag for indicating a state dbug message (to follow module states) */
-#define STACKX_DBG_STATE NS_LOG_STACKX_STATE
-
-/** flag for indicating newly added code, not thoroughly tested yet */
-#define STACKX_DBG_FRESH NS_LOG_STACKX_FRESH
-
-/** flag for to halt after printing this dbug message */
-#define STACKX_DBG_HALT NS_LOG_STACKX_HALT
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif /* __STACKX_DEBUG_H__ */
diff --git a/stacks/lwip_stack/lwip_src/common/stackx_err.h b/stacks/lwip_stack/lwip_src/common/stackx_err.h
deleted file mode 100644
index 1d0fc20..0000000
--- a/stacks/lwip_stack/lwip_src/common/stackx_err.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef STACKX_ERR_H
-#define STACKX_ERR_H
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-#define ERR_OK 0 /* No error, everything OK. */
-#define ERR_MEM -1 /* Out of memory error. */
-#define ERR_BUF -2 /* Buffer error. */
-#define ERR_TIMEOUT -3 /* Timeout. */
-#define ERR_RTE -4 /* Routing problem. */
-#define ERR_INPROGRESS -5 /* Operation in progress */
-#define ERR_VAL -6 /* Illegal value. */
-#define ERR_WOULDBLOCK -7 /* Operation would block. */
-#define ERR_USE -8 /* Address in use. */
-#define ERR_ISCONN -9 /* Already connected. */
-
-#define SPL_ERR_IS_FATAL(e) ((e) < ERR_ISCONN)
-
-#define ERR_ABRT -10 /* Connection aborted. */
-#define ERR_RST -11 /* Connection reset. */
-#define ERR_CLSD -12 /* Connection closed. */
-#define ERR_CONN -13 /* Not connected. */
-
-#define ERR_ARG -14 /* Illegal argument. */
-
-#define ERR_IF -15 /* Low-level netif error */
-#define ERR_ALREADY -16 /* previous connect attemt has not yet completed */
-#define ERR_PROTOTYPE -17 /* prototype error or some other generic error.
- the operation is not allowed on current socket */
-
-#define ERR_CALLBACK -18 /* callback error */
-#define ERR_CANTASSIGNADDR -19 /* Cannot assign requested address */
-#define ERR_CONTAINER_ID -20 /*Illegal container id */
-#define ERR_NOTSOCK -21 /*not a socket */
-
-#define ERR_CLOSE_WAIT -22 /*closed in established state */
-
-#define ERR_EPROTONOSUPPORT -23 /* Protocol not supported */
-
-#define ERR_FAULTRECOVERY -24 /*SPL just recovered from a fatal fault */
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif
diff --git a/stacks/lwip_stack/lwip_src/common/stackx_ip_addr.c b/stacks/lwip_stack/lwip_src/common/stackx_ip_addr.c
deleted file mode 100644
index 306bcaf..0000000
--- a/stacks/lwip_stack/lwip_src/common/stackx_ip_addr.c
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include <stdint.h>
-#include <stddef.h>
-#include "stackx_ip_addr.h"
-#include "nstack_log.h"
-#include "spl_def.h"
-
-/* Here for now until needed in other places in stackx*/
-#ifndef isprint
-#define in_range(c, lo, up) ((u8)c >= lo && (u8)c <= up)
-#define isprint(c) in_range(c, 0x20, 0x7f)
-#define isdigit(c) in_range(c, '0', '9')
-#define isxdigit(c) (isdigit(c) || in_range(c, 'a', 'f') || in_range(c, 'A', 'F'))
-#define islower(c) in_range(c, 'a', 'z')
-#define isspace(c) (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v')
-#endif
-
-/**
- * Ascii internet address interpretation routine.
- * The value returned is in network order.
- *
- * @param cp IPaddress in ascii represenation (e.g. "127.0.0.1")
- * @return ipaddress in network order
- */
-u32
-spl_ipaddr_addr (const char *cp)
-{
- spl_ip_addr_t val;
-
- if (spl_ipaddr_aton (cp, &val))
- {
- return ip4_addr_get_u32 (&val);
- }
-
- return (SPL_IPADDR_NONE);
-}
-
-/**
- * Check whether "cp" is a valid ascii representation
- * of an Internet address and convert to a binary address.
- * Returns 1 if the address is valid, 0 if not.
- * This replaces inet_addr, the return value from which
- * cannot distinguish between failure and a local broad cast address.
- *
- * @param cp IPaddress in ascii represenation (e.g. "127.0.0.1")
- * @param addr pointer to which to save the ipaddress in network order
- * @return 1 if cp could be converted to addr, 0 on failure
- */
-int
-spl_ipaddr_aton (const char *cp, spl_ip_addr_t * addr)
-{
- u32 val;
- u8 base;
- char c;
- u32 parts[4];
- u32 *pp = parts;
-
- if (cp == NULL)
- {
- return 0;
- }
-
- c = *cp;
- for (;;)
- {
- /*
- * Get number up to ``.''.
- * Values are specified as for C:
- * 0x=hex, 0=octal, 1-9=decimal.
- */
- if (!isdigit (c))
- {
- return (0);
- }
-
- val = 0;
- base = 10;
- if (c == '0')
- {
- c = *++cp;
- if ((c == 'x') || (c == 'X'))
- {
- base = 16;
- c = *++cp;
- }
- else
- {
- base = 8;
- }
- }
-
- for (;;)
- {
- if (isdigit (c))
- {
- val = (val * base) + (int) (c - '0');
- c = *++cp;
- }
- else if ((base == 16) && isxdigit (c))
- {
- val = (val << 4) | (int) (c + 10 - (islower (c) ? 'a' : 'A'));
- c = *++cp;
- }
- else
- {
- break;
- }
- }
-
- if (c == '.')
- {
- /*
- * Internet format:
- * a.b.c.d
- * a.b.c (with c treated as 16 bits)
- * a.b (with b treated as 24 bits)
- */
- if (pp >= parts + 3)
- {
- return (0);
- }
-
- *pp++ = val;
- c = *++cp;
- }
- else
- {
- break;
- }
- }
-
- /*
- * Check for trailing characters.
- */
- if ((c != '\0') && !isspace (c))
- {
- return (0);
- }
-
- /*
- * Concoct the address according to
- * the number of parts specified.
- */
- switch (pp - parts + 1)
- {
- case 0:
- return (0); /* initial nondigit */
-
- case 1: /* a -- 32 bits */
- break;
-
- case 2: /* a.b -- 8.24 bits */
- if (val > 0xffffffUL)
- {
- return (0);
- }
-
- val |= parts[0] << 24;
- break;
-
- case 3: /* a.b.c -- 8.8.16 bits */
- if (val > 0xffff)
- {
- return (0);
- }
-
- val |= (parts[0] << 24) | (parts[1] << 16);
- break;
-
- case 4: /* a.b.c.d -- 8.8.8.8 bits */
- if (val > 0xff)
- {
- return (0);
- }
-
- val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
- break;
- default:
- NSPOL_LOGERR ("unhandled");
-
- return (0);
- }
-
- if (addr)
- {
- ip4_addr_set_u32 (addr, spl_htonl (val));
- }
-
- return (1);
-}
-
-/**
- * Convert numeric IPaddress into decimal dotted ASCII representation.
- * returns ptr to static buffer; not reentrant!
- *
- * @param addr ipaddress in network order to convert
- * @return pointer to a global static (!) buffer that holds the ASCII
- * represenation of addr
- */
-char *
-spl_ipaddr_ntoa (const spl_ip_addr_t * addr)
-{
- static char str[16];
-
- return spl_ipaddr_ntoa_r (addr, str, 16);
-}
-
-/**
- * Same as spl_ipaddr_ntoa, but reentrant since a user-supplied buffer is used.
- *
- * @param addr ipaddress in network order to convert
- * @param buf target buffer where the string is stored
- * @param buflen length of buf
- * @return either pointer to buf which now holds the ASCII
- * representation of addr or NULL if buf was too small
- */
-char *
-spl_ipaddr_ntoa_r (const spl_ip_addr_t * addr, char *buf, int buflen)
-{
- u32 s_addr;
- char inv[3];
- char *rp;
- u8 *ap;
- u8 rem;
- u8 n;
- u8 i;
- int len = 0;
-
- s_addr = ip4_addr_get_u32 (addr);
-
- rp = buf;
- ap = (u8 *) & s_addr;
- for (n = 0; n < 4; n++)
- {
- i = 0;
- do
- {
- rem = *ap % (u8) 10;
- *ap /= (u8) 10;
- inv[i++] = '0' + rem;
- }
- while (*ap);
-
- while (i--)
- {
- if (len++ >= buflen)
- {
- return NULL;
- }
-
- *rp++ = inv[i];
- }
-
- if (len++ >= buflen)
- {
- return NULL;
- }
-
- *rp++ = '.';
- ap++;
- }
-
- *--rp = 0;
- return buf;
-}
diff --git a/stacks/lwip_stack/lwip_src/common/stackx_ip_addr.h b/stacks/lwip_stack/lwip_src/common/stackx_ip_addr.h
deleted file mode 100644
index 9f2dc07..0000000
--- a/stacks/lwip_stack/lwip_src/common/stackx_ip_addr.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef STACKX_IP_ADDR_H
-#define STACKX_IP_ADDR_H
-#include "types.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-/* This is the aligned version of ip_addr_t,
- used as local variable, on the stack, etc. */
-typedef struct spl_ip_addr
-{
- u32 addr;
-} spl_ip_addr_t;
-
-/** 127.0.0.1 */
-#define IPADDR_LOOPBACK ((u32_t)0x7f000001UL)
-
-/** 0.0.0.0 */
-#define IPADDR_ANY ((u32_t)0x00000000UL)
-
-/** 255.255.255.255 */
-#define IPADDR_BROADCAST ((u32_t)0xffffffffUL)
-
-/** 255.255.255.255 */
-#define SPL_IPADDR_NONE ((u32)0xffffffffUL)
-
-/** Set address to IPADDR_ANY (no need for spl_htonl()) */
-#define spl_ip_addr_set_any(ipaddr) ((ipaddr)->addr = IPADDR_ANY)
-
-/** Set complete address to zero */
-#define spl_ip_addr_set_zero(ipaddr) ((ipaddr)->addr = 0)
-
-/** IPv4 only: set the IPaddress given as an u32_t */
-#define ip4_addr_set_u32(dest_ipaddr, src_u32) ((dest_ipaddr)->addr = (src_u32))
-
-/** IPv4 only: get the IPaddress as an u32_t */
-#define ip4_addr_get_u32(src_ipaddr) ((src_ipaddr)->addr)
-
-#define inet_addr_to_ipaddr(target_ipaddr, source_inaddr) (ip4_addr_set_u32(target_ipaddr, (source_inaddr)->s_addr))
-#define inet_addr_from_ipaddr(target_inaddr, source_ipaddr) ((target_inaddr)->s_addr = ip4_addr_get_u32(source_ipaddr))
-
-/** For backwards compatibility */
-#define spl_ip_ntoa(ipaddr) spl_ipaddr_ntoa(ipaddr)
-
-u32 spl_ipaddr_addr (const char *cp);
-int spl_ipaddr_aton (const char *cp, spl_ip_addr_t * addr);
-
-/** returns ptr to static buffer; not reentrant! */
-char *spl_ipaddr_ntoa (const spl_ip_addr_t * addr);
-char *spl_ipaddr_ntoa_r (const spl_ip_addr_t * addr, char *buf, int buflen);
-
-#define spl_inet_addr(cp) spl_ipaddr_addr(cp)
-#define spl_inet_aton(cp, paddr) spl_ipaddr_aton(cp, (spl_ip_addr_t*)(paddr))
-#define spl_inet_ntoa(paddr) spl_ipaddr_ntoa((spl_ip_addr_t*)&(paddr))
-#define spl_inet_ntoa_r(addr, buf, buflen) spl_ipaddr_ntoa_r((spl_ip_addr_t*)&(addr), buf, buflen)
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif
diff --git a/stacks/lwip_stack/lwip_src/common/stackx_ip_tos.h b/stacks/lwip_stack/lwip_src/common/stackx_ip_tos.h
deleted file mode 100644
index 6ca2598..0000000
--- a/stacks/lwip_stack/lwip_src/common/stackx_ip_tos.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef STACKX_IP_TOS_H
-#define STACKX_IP_TOS_H
-#include "types.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-/*
- * The Type of Service provides an indication of the abstract
- * parameters of the quality of service desired. These parameters are
- * to be used to guide the selection of the actual service parameters
- * when transmitting a datagram through a particular network. Several
- * networks offer service precedence, which somehow treats high
- * precedence traffic as more important than other traffic (generally
- * by accepting only traffic above a certain precedence at time of high
- * load). The major choice is a three way tradeoff between low-delay,
- * high-reliability, and high-throughput.
- * The use of the Delay, Throughput, and Reliability indications may
- * increase the cost (in some sense) of the service. In many networks
- * better performance for one of these parameters is coupled with worse
- * performance on another. Except for very unusual cases at most two
- * of these three indications should be set.
- */
-#define IPTOS_LOWCOST 0x02
-#define IPTOS_RELIABILITY 0x04
-#define IPTOS_THROUGHPUT 0x08
-#define IPTOS_LOWDELAY 0x10
-#define IPTOS_TOS_MASK 0x1E
-#define IPTOS_MINCOST IPTOS_LOWCOST
-#define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK)
-
-/*
- * The Network Control precedence designation is intended to be used
- * within a network only. The actual use and control of that
- * designation is up to each network. The Internetwork Control
- * designation is intended for use by gateway control originators only.
- * If the actual use of these precedence designations is of concern to
- * a particular network, it is the responsibility of that network to
- * control the access to, and use of, those precedence designations.
- */
-#define IPTOS_PREC_ROUTINE 0x00
-#define IPTOS_PREC_PRIORITY 0x20
-#define IPTOS_PREC_IMMEDIATE 0x40
-#define IPTOS_PREC_FLASH 0x60
-#define IPTOS_PREC_FLASHOVERRIDE 0x80
-#define IPTOS_PREC_CRITIC_ECP 0xa0
-#define IPTOS_PREC_INTERNETCONTROL 0xc0
-#define IPTOS_PREC_MASK 0xe0
-#define IPTOS_PREC_NETCONTROL 0xe0
-#define IPTOS_PREC(tos) ((tos) & IPTOS_PREC_MASK)
-
-#define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
-
-#define TC_PRIO_BESTEFFORT 0
-#define TC_PRIO_FILLER 1
-#define TC_PRIO_BULK 2
-#define TC_PRIO_INTERACTIVE_BULK 4
-#define TC_PRIO_INTERACTIVE 6
-#define TC_PRIO_CONTROL 7
-#define TC_PRIO_MAX 15
-
-#define ECN_OR_COST(class ) TC_PRIO_ ## class
-
-static u8 stackx_ip_tos2prio[(IPTOS_TOS_MASK >> 1) + 1] = {
- TC_PRIO_BESTEFFORT,
- ECN_OR_COST (FILLER),
- TC_PRIO_BESTEFFORT,
- ECN_OR_COST (BESTEFFORT),
- TC_PRIO_BULK,
- ECN_OR_COST (BULK),
- TC_PRIO_BULK,
- ECN_OR_COST (BULK),
- TC_PRIO_INTERACTIVE,
- ECN_OR_COST (INTERACTIVE),
- TC_PRIO_INTERACTIVE,
- ECN_OR_COST (INTERACTIVE),
- TC_PRIO_INTERACTIVE_BULK,
- ECN_OR_COST (INTERACTIVE_BULK),
- TC_PRIO_INTERACTIVE_BULK,
- ECN_OR_COST (INTERACTIVE_BULK)
-};
-
-static inline char
-stackx_rt_tos2priority (u8 tos)
-{
- return stackx_ip_tos2prio[IPTOS_TOS (tos) >> 1];
-}
-
-typedef enum
-{
- STACKX_PRIM,
- STACKX_HIGH,
- STACKX_MEDIUM,
- STACKX_LOW
-} stackx_prio;
-
-static inline stackx_prio
-stackx_get_prio (u8 tos)
-{
- if (0 == tos)
- {
- return STACKX_PRIM;
- }
- char prio = stackx_rt_tos2priority (tos);
- if ((TC_PRIO_INTERACTIVE == prio))
- {
- return STACKX_HIGH;
- }
- else if ((TC_PRIO_BESTEFFORT == prio) || (TC_PRIO_INTERACTIVE_BULK == prio))
- {
- return STACKX_MEDIUM;
- }
- else if ((TC_PRIO_BULK == prio) || (TC_PRIO_FILLER == prio))
- {
- return STACKX_LOW;
- }
-
- return STACKX_PRIM;
-}
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif
diff --git a/stacks/lwip_stack/lwip_src/common/stackx_netbuf.h b/stacks/lwip_stack/lwip_src/common/stackx_netbuf.h
deleted file mode 100644
index a8be1a7..0000000
--- a/stacks/lwip_stack/lwip_src/common/stackx_netbuf.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef STACKX_NETBUF_H
-#define STACKX_NETBUF_H
-#include "stackx_pbuf.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-typedef struct spl_netbuf
-{
- struct spl_pbuf *p;
- spl_ip_addr_t addr;
- u16 port;
-} spl_netbuf;
-
-#define netbuf_fromaddr(buf) (&((buf)->addr))
-#define netbuf_fromport(buf) ((buf)->port)
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif
diff --git a/stacks/lwip_stack/lwip_src/common/stackx_pbuf.c b/stacks/lwip_stack/lwip_src/common/stackx_pbuf.c
deleted file mode 100644
index c176a4b..0000000
--- a/stacks/lwip_stack/lwip_src/common/stackx_pbuf.c
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "stackx_spl_share.h"
-#include "stackx_pbuf.h"
-#include "common_mem_mbuf.h"
-#include "nstack_securec.h"
-#include "nsfw_maintain_api.h"
-#include "stackx_tcp_opt.h"
-#ifdef HAL_LIB
-#else
-#include "rte_memcpy.h"
-#endif
-
-/*****************************************************************************
-* Prototype : sbr_malloc_pbuf
-* Description : malloc spl_pbuf,use it in app
-* Input : mpool_handle mp
-* u16 len
-* u32 mbuf_data_size
-* u16 offset
-* Output : None
-* Return Value : struct pbuf*
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-struct spl_pbuf *
-sbr_malloc_pbuf (mpool_handle mp, u16 len, u32 mbuf_data_size, u16 offset)
-{
- if ((len < offset) || (len > mbuf_data_size))
- {
- NSSBR_LOGERR ("len is invalid]len=%u", len);
- return NULL;
- }
-
- struct common_mem_mbuf *mbuf = NULL;
- struct spl_pbuf *buf = NULL;
-
- mbuf = nsfw_mem_mbf_alloc (mp, NSFW_SHMEM);
- if (unlikely (mbuf == NULL))
- {
- NS_LOG_CTRL (LOG_CTRL_HUGEPAGE_ALLOC_FAIL, LOGSBR, "NSSBR", NSLOG_WAR,
- "alloc mbuf failed");
- return NULL;
- }
-
- mbuf->data_len = len;
- mbuf->next = NULL;
- mbuf->nb_segs = 1;
- mbuf->pkt_len = len;
- buf = (struct spl_pbuf *) ((char *) mbuf + sizeof (struct common_mem_mbuf));
- res_alloc (&buf->res_chk);
- buf->next = 0;
- void *tmp = common_pktmbuf_mtod (mbuf, void *);
- buf->payload = (void *) (ADDR_LTOSH (tmp) + offset);
- buf->tot_len = len - offset;
- buf->len = len - offset;
- buf->type = SPL_PBUF_HUGE;
- buf->flags = 0;
- buf->freeNext = NULL;
- buf->conn_a = 0;
- buf->proto_type = SPL_PBUF_PROTO_NONE;
- NSSBR_LOGDBG ("malloc pbuf ok]buf=%p,PRIMARY_ADDR=%p", buf,
- ADDR_LTOSH (buf));
- return buf;
-}
-
-u32_t
-spl_pbuf_copy_partial (struct spl_pbuf * buf, void *dataptr, u32_t len,
- u32_t offset)
-{
- struct spl_pbuf *p = buf;
- u32_t buf_copy_len;
- u32_t copied_total = 0;
- char *databuf = (char *) dataptr;
-
- /* Note some systems use byte copy if dataptr or one of the pbuf payload pointers are unaligned. */
- for (p = buf; len != 0 && p != NULL;
- p = PTR_SHTOL (struct spl_pbuf *, p->next_a))
- {
- if (offset != 0 && offset >= p->len)
- {
- /* don't copy from this buffer -> on to the next */
- offset -= p->len;
- }
- else if (p->len - offset > len)
- {
- /* copy from this buffer. maybe only partially. */
- (void) common_memcpy (databuf, ADDR_SHTOL (p->payload_a + offset),
- len);
- copied_total += len;
- break;
- }
- else
- {
- buf_copy_len = p->len - offset;
- /* copy the necessary parts of the buffer */
- (void) common_memcpy (databuf, ADDR_SHTOL (p->payload_a + offset),
- buf_copy_len);
-
- copied_total += buf_copy_len;
- databuf += buf_copy_len;
- len -= buf_copy_len;
- offset = 0;
- }
- }
-
- return copied_total;
-}
-
-int
-spl_tx_force_buf_free (void *data)
-{
- struct common_mem_mbuf *mbuf = data;
- if (NULL == mbuf)
- {
- return FALSE;
- }
-
- struct spl_pbuf *p_buf =
- (struct spl_pbuf *) (((char *) mbuf) + sizeof (struct common_mem_mbuf));
- u8 tempflag = p_buf->res_chk.u8Reserve;
- if ((mbuf->refcnt == 0) || (tempflag & DPDK_SEND_FLAG))
- {
- return FALSE;
- }
-
- NSFW_LOGINF ("free mbuf]%p", data);
- (void) nsfw_mem_mbf_free ((mbuf_handle) mbuf, NSFW_SHMEM);
- return TRUE;
-}
-
-int
-spl_force_buf_free (void *data)
-{
- struct common_mem_mbuf *mbuf = data;
-
- if (NULL == mbuf || (mbuf->refcnt == 0))
- {
- return FALSE;
- }
-
- NSFW_LOGINF ("free mbuf]%p", data);
- (void) nsfw_mem_mbf_free ((mbuf_handle) mbuf, NSFW_SHMEM);
- return TRUE;
-}
-
-int
-spl_reg_res_tx_mgr (mpool_handle * pool)
-{
- struct common_mem_mempool *mp = (struct common_mem_mempool *) pool;
- if (NULL == mp)
- {
- return 0;
- }
-
- nsfw_res_scn_cfg scn_cfg = { NSFW_RES_SCAN_MBUF, 60, 3, 16,
- mp->size / 128, mp->size,
- mp->elt_size,
- sizeof (struct common_mem_mbuf) + offsetof (struct spl_pbuf, res_chk),
- mp,
- mp->pool_data,
- spl_tx_force_buf_free
- };
- (void) nsfw_res_mgr_reg (&scn_cfg);
- return 0;
-}
-
-int
-spl_reg_res_rxmt_mgr (mpool_handle * pool)
-{
- struct common_mem_mempool *mp = (struct common_mem_mempool *) pool;
- if (NULL == mp)
- {
- return 0;
- }
-
- nsfw_res_scn_cfg scn_cfg = { NSFW_RES_SCAN_MBUF, 60, 3, 16,
- mp->size / 128, mp->size,
- mp->elt_size,
- sizeof (struct common_mem_mbuf) + offsetof (struct spl_pbuf, res_chk),
- mp,
- mp->pool_data,
- spl_tx_force_buf_free
- }; /*Can use same function for time */
- (void) nsfw_res_mgr_reg (&scn_cfg);
- return 0;
-}
-
-int
-spl_reg_res_txrx_mgr (mpool_handle * pool)
-{
- struct common_mem_mempool *mp = (struct common_mem_mempool *) pool;
- if (NULL == mp)
- {
- return 0;
- }
-
- nsfw_res_scn_cfg scn_cfg = { NSFW_RES_SCAN_MBUF, 60, 3, 16,
- mp->size / 128, mp->size,
- mp->elt_size,
- sizeof (struct common_mem_mbuf) + offsetof (struct spl_pbuf, res_chk),
- mp,
- mp->pool_data,
- spl_force_buf_free
- };
- (void) nsfw_res_mgr_reg (&scn_cfg);
- return 0;
-}
diff --git a/stacks/lwip_stack/lwip_src/common/stackx_pbuf.h b/stacks/lwip_stack/lwip_src/common/stackx_pbuf.h
deleted file mode 100644
index 60f1772..0000000
--- a/stacks/lwip_stack/lwip_src/common/stackx_pbuf.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef STACKX_PBUF_H
-#define STACKX_PBUF_H
-
-#include "common_mem_base_type.h"
-#include "common_mem_mbuf.h"
-#include "nsfw_mem_api.h"
-#include "stackx_pbuf_comm.h"
-#ifdef HAL_LIB
-#else
-#include "common_pal_bitwide_adjust.h"
-#endif
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-#define NEED_ACK_FLAG 0x01 /* This spl_pbuf may have multiple references. */
-#define PBUF_FREE_FLAG 0x04 /* This spl_pbuf has been free. */
-#define DPDK_SEND_FLAG 0x10 /* This spl_pbuf has been sent to DPDK. */
-#define LOOP_SEND_FLAG 0x40 /* This spl_pbuf has been looped to IP layer and not received by app layer yet. */
-
-struct spl_pbuf *sbr_malloc_pbuf (mpool_handle mp, u16 len,
- u32 mbuf_data_size, u16 offset);
-void sbr_free_pbuf (struct spl_pbuf *p);
-u32 spl_pbuf_copy_partial (struct spl_pbuf *p, void *dataptr, u32_t len,
- u32_t offset);
-int spl_reg_res_txrx_mgr (mpool_handle * pool);
-int spl_reg_res_tx_mgr (mpool_handle * pool);
-
-/* release buf hold by app on abnormal exit */
-/*
- *For TX mbuf: recycle_flg can be: MBUF_UNUSED, MBUF_HLD_BY_APP, MBUF_HLD_BY_SPL.
- *For TX mbuf: recycle_flg can be: MBUF_UNSUED, app pid.
- */
-static inline void
-pbuf_set_recycle_flg (struct spl_pbuf *p, uint32_t flg)
-{
- uint32_t *recycle_flg;
- struct spl_pbuf *q = p;
- struct common_mem_mbuf *m;
-
- while (q != NULL)
- {
- m =
- (struct common_mem_mbuf *) ((char *) q -
- sizeof (struct common_mem_mbuf));
-#ifdef HAL_LIB
-#else
- recycle_flg =
- (uint32_t *) ((char *) (m->buf_addr) + RTE_PKTMBUF_HEADROOM -
- sizeof (uint32_t));
-#endif
- *recycle_flg = flg;
- q = (struct spl_pbuf *) ADDR_SHTOL (q->next_a);
- }
-}
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif
diff --git a/stacks/lwip_stack/lwip_src/common/stackx_pbuf_comm.h b/stacks/lwip_stack/lwip_src/common/stackx_pbuf_comm.h
deleted file mode 100644
index 6a21312..0000000
--- a/stacks/lwip_stack/lwip_src/common/stackx_pbuf_comm.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef STACKX_PBUF_COMM_H
-#define STACKX_PBUF_COMM_H
-#include "types.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-#define SPL_PBUF_TRANSPORT_HLEN 20
-#define SPL_PBUF_UDP_HLEN 8
-#define SPL_PBUF_IP_HLEN 20
-
-#define SPL_PBUF_VLAN_HLEN 0
-
-#ifndef SPL_PBUF_LINK_HLEN
-#define SPL_PBUF_LINK_HLEN (14 + SPL_PBUF_VLAN_HLEN)
-#endif
-
-typedef enum spl_pbuf_layer
-{
- SPL_PBUF_TRANSPORT,
- SPL_PBUF_UDP,
- SPL_PBUF_IP,
- SPL_PBUF_LINK,
- SPL_PBUF_RAW,
- SPL_PBUF_MAX_LAYER,
-} spl_pbuf_layer;
-
-typedef enum spl_pbuf_type
-{
- SPL_PBUF_RAM, /* pbuf data is stored in RAM */
- SPL_PBUF_ROM, /* pbuf data is stored in ROM */
- SPL_PBUF_REF, /* pbuf comes from the pbuf pool */
- SPL_PBUF_POOL, /* pbuf payload refers to RAM */
- SPL_PBUF_HUGE /* pbuf is stored in HugePage memory in struct common_mem_mbuf */
-} spl_pbuf_type;
-
-enum spl_pbuf_proto
-{
- SPL_PBUF_PROTO_NONE,
- SPL_PBUF_TCP_SEND,
- SPL_PBUF_TCP_RECV
-} spl_pbuf_proto;
-
-typedef struct spl_pbuf
-{
- /** next pbuf in singly linked pbuf chain */
- union
- {
- struct spl_pbuf *next;
- u64 next_a;
- };
-
- /** pointer to the actual data in the buffer */
- union
- {
- void *payload;
- u64 payload_a;
- };
-
- union
- {
- void *msg;
- u64 msg_a;
- };
-
- union
- {
- void *conn;
- u64 conn_a;
- };
-
- struct spl_pbuf *freeNext; // This pointer will point to next pbuf you want to free in stackx
-
- u32 tot_len;
- u32 len;
- int proto_type;
- u16 ref;
- u8 type;
- u8 flags;
- nsfw_res res_chk;
-
-} spl_pbuf;
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif
diff --git a/stacks/lwip_stack/lwip_src/common/stackx_spl_msg.h b/stacks/lwip_stack/lwip_src/common/stackx_spl_msg.h
deleted file mode 100644
index 3088150..0000000
--- a/stacks/lwip_stack/lwip_src/common/stackx_spl_msg.h
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef STACKX_SPL_MSG_H
-#define STACKX_SPL_MSG_H
-#include "nsfw_msg.h"
-#include "stackx_ip_addr.h"
-#include "stackx_spl_share.h"
-#include "stackx_common_opt.h"
-#include <sys/socket.h>
-#include <netinet/tcp.h>
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-enum spl_tcpip_msg_type
-{
- SPL_TCPIP_NEW_MSG_API,
-#if STACKX_TIMER_THREAD_SUPPORT
- SPL_TCPIP_MSG_TIMER,
-#endif
-#if STACKX_NETIF_API
- SPL_TCPIP_MSG_NETIFAPI,
-#endif
- SPL_TCPIP_MSG_CALLBACK,
- SPL_TCPIP_MSG_IP_MODULE,
-
- SPL_TCPIP_MSG_MAX, //the number of enum
- SPL_TCPIP_MSG_BOTTOM = MAX_MAJOR_TYPE //the max number of enum
-};
-
-enum api_msg_type
-{
- SPL_API_DO_NEWCONN = 0,
- SPL_API_DO_DELCON,
- SPL_API_DO_RECV,
- SPL_API_DO_GETADDR,
- SPL_API_DO_BIND,
- SPL_API_DO_CONNECT,
- SPL_API_DO_LISTEN,
- SPL_API_DO_CLOSE,
- SPL_API_DO_SET_SOCK_OPT,
- SPL_API_DO_GET_SOCK_OPT,
- SPL_API_DO_SEND,
- SPL_API_DO_WRITE,
- SPL_API_DO_POST,
- SPL_API_DO_SHOW,
- SPL_API_DO_EXTREN_SOCK_SET,
- SPL_API_DO_ENABLE_TRACE,
- SPL_API_GET_PROTOCOL,
- SPL_API_DO_IOCTL_OPT,
- SPL_API_DO_GETSOCK_NAME,
- SPL_API_DO_DUMP_L4,
- SPL_API_DO_PBUF_FREE,
- SPL_API_DO_APP_TOUCH, /* app send its version info to nStackMain */
-
- SPL_API_MSG_MAX, //the number of enum
- SPL_API_MSG_BOTTOM = MAX_MINOR_TYPE //the max number of enum
-};
-
-/* TODO: move thes to apporpriate file */
-#define TCP_RTO_MAX ((unsigned)(120*1000)) /* 120s */
-#define TCP_RTO_MIN ((unsigned)(200)) /* 200ms */
-
-#define TCP_TIMEOUT_INIT ((unsigned)(1*1000)) /* RFC6298 2.1 initial RTO value */
-#define CONN_TCP_MEM_MIN_LINE ((TX_MBUF_POOL_SIZE)/1024) //conn level : min value of send_buf
-#define CONN_TCP_MEM_DEF_LINE ((TX_MBUF_POOL_SIZE)/128) //conn level : default value of send_buf
-#define CONN_TCP_MEM_MAX_LINE ((TX_MBUF_POOL_SIZE)/12)
-
-#define SOF_DEBUG 0x01U
-#define SOF_ACCEPTCONN 0x02U
-#define SOF_DONTROUTE 0x10U
-#define SOF_USELOOPBACK 0x40U
-#define SOF_LINGER 0x80U
-#define SOF_OOBINLINE 0x0100U
-#define SOF_REUSEPORT 0x0200U
-
-/* General structure for calling APIs*/
-typedef struct api_param_t
-{
- data_com_msg *m;
- i64 comm_private_data;
-} api_param;
-
-/* SPL_API_DO_SEND */
-typedef struct
-{
- PRIMARY_ADDR struct spl_pbuf *p;
- spl_ip_addr_t local_ip;
- spl_ip_addr_t addr;
- spl_ip_addr_t srcAddr;
- u16 port;
- u16 srcPort;
- u16 toport_chksum;
- u8 tos;
- u8 pad;
- u8 flags;
- i64 extend_member_bit;
-} msg_send_buf;
-
-/* SPL_API_DO_BIND */
-typedef struct
-{
- spl_ip_addr_t ipaddr;
- u16 port;
- i64 extend_member_bit;
-} msg_bind;
-
-/* SPL_API_DO_CLOSE */
-typedef struct
-{
- long time_started;
- u8 shut;
- i64 extend_member_bit;
-} msg_close;
-
-/* SPL_API_DO_CONNECT */
-typedef struct
-{
- spl_ip_addr_t local_ip;
- spl_ip_addr_t ipaddr;
- u16 port;
- i64 extend_member_bit;
-} msg_connect;
-
-/* SPL_API_DO_DELCON */
-typedef struct
-{
- PRIMARY_ADDR struct spl_netconn *conn;
- PRIMARY_ADDR struct spl_pbuf *buf;
- long time_started;
- pid_t pid;
- u8 shut;
- u8 msg_box_ref; /* use it for priority */
- u8 notify_omc; /* bool */
- i64 extend_member_bit;
-} msg_delete_netconn;
-
-/* SPL_API_DO_WRITE */
-typedef struct msg_write_buf_T
-{
- PRIMARY_ADDR struct spl_pbuf *p;
- struct msg_write_buf_T *next;
- size_t len;
- u8 apiflags;
- i64 extend_member_bit;
-} msg_write_buf;
-
-/* SPL_API_DO_LISTEN */
-typedef struct
-{
- mring_handle conn_pool;
- u8 backlog;
- i64 extend_member_bit;
-} msg_listen;
-
-/* SPL_API_DO_NEWCONN */
-typedef struct
-{
- PRIMARY_ADDR struct spl_netconn *conn;
- spl_netconn_type_t type;
- u8 proto;
- int socket;
- i64 extend_member_bit;
-} msg_new_netconn;
-
-/* SPL_API_DO_RECV */
-typedef struct
-{
- PRIMARY_ADDR struct spl_pbuf *p;
- u32 len;
- i64 extend_member_bit;
-} msg_recv_buf;
-
-/* SPL_API_DO_GETSOCK_NAME */
-typedef struct
-{
- struct sockaddr sock_addr;
- u8 cmd;
- i64 extend_member_bit;
-} msg_getaddrname;
-
-/* SPL_API_DO_GET_SOCK_OPT,SPL_API_DO_SET_SOCK_OPT */
-typedef struct
-{
- int level;
- int optname;
- PRIMARY_ADDR mring_handle msg_box; /* IP_TOS, spl will get new msg box for app */
- union
- {
- int int_optval;
- //struct in_addr inaddr_optval;
- //struct linger _linger;
- struct timeval timeval_optval;
- struct tcp_info tpinfo;
- //ipmreq ipmreq_optval; //Multicast support later
- } optval;
-
- u32 optlen;
- i64 extend_member_bit;
-} msg_setgetsockopt;
-
-/* SPL_API_DO_PBUF_FREE */
-typedef struct
-{
- PRIMARY_ADDR struct spl_pbuf *buf;
- i64 extend_member_bit;
-} msg_free_buf;
-
-/* app send its version info to nStackMain */
-#define NSTACK_VERSION_LEN 128
-/* SPL_API_DO_APP_TOUCH */
-typedef struct
-{
- u32_t hostpid;
- char app_version[NSTACK_VERSION_LEN];
-} msg_app_touch;
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif
diff --git a/stacks/lwip_stack/lwip_src/common/stackx_spl_share.c b/stacks/lwip_stack/lwip_src/common/stackx_spl_share.c
deleted file mode 100644
index 4fa91d8..0000000
--- a/stacks/lwip_stack/lwip_src/common/stackx_spl_share.c
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "stackx_spl_msg.h"
-#include "stackx_spl_share.h"
-#include "nstack_log.h"
-#include "nsfw_msg_api.h"
-#include "nsfw_recycle_api.h"
-
-/*****************************************************************************
-* Prototype : ss_reset_conn_recycle
-* Description : reset conn recycle
-* Input : netconn_recycle* recycle
-* Output : None
-* Return Value : static inline void
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline void
-ss_reset_conn_recycle (netconn_recycle * recycle)
-{
- recycle->accept_from = NULL;
- recycle->is_listen_conn = 0;
- (void) nsfw_pidinfo_init (&recycle->pid_info);
- recycle->fork_ref = 0;
- recycle->delay_msg = NULL;
- recycle->delay_flag = SS_DELAY_STOPPED;
-}
-
-/*****************************************************************************
-* Prototype : ss_reset_conn
-* Description : reset conn
-* Input : spl_netconn_t* conn
-* Output : None
-* Return Value : void
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-void
-ss_reset_conn (spl_netconn_t * conn)
-{
- conn->recv_obj = 0;
- conn->private_data = 0;
- conn->msg_box = NULL;
- conn->snd_buf = 0;
- conn->epoll_flag = 0;
- conn->recv_avail_prod = 0;
- conn->recv_avail_cons = 0;
- conn->rcvevent = 0;
- conn->state = SPL_NETCONN_NONE;
- conn->sendevent = 0;
- conn->errevent = 0;
- conn->shut_status = 0xFFFF;
- conn->flags = 0;
- conn->last_err = 0;
- conn->CanNotReceive = 0;
- conn->bind_thread_index = 0;
- conn->tcp_sndbuf = 0;
- conn->tcp_wmem_alloc_cnt = 0;
- conn->tcp_wmem_sbr_free_cnt = 0;
- conn->tcp_wmem_spl_free_cnt = 0;
- conn->mss = 0;
- conn->remote_port = 0;
- conn->remote_ip.addr = 0;
- conn->local_ip.addr = 0;
- conn->local_port = 0;
- conn->type = SPL_NETCONN_INVALID;
- conn->tcp_state = SPL_CLOSED;
- ss_reset_conn_recycle (&conn->recycle);
- conn->extend_member_bit = 0;
- conn->epInfo = NULL;
-}
-
-/*****************************************************************************
-* Prototype : ss_init_conn
-* Description : init conn
-* Input : spl_netconn_t* conn
-* Output : None
-* Return Value : void
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline void
-ss_init_conn (spl_netconn_t * conn, mring_handle pool,
- spl_netconn_type_t type)
-{
- res_alloc (&conn->res_chk);
-
- conn->type = type;
- conn->recycle.fork_ref = 1;
- conn->recv_ring_valid = 1;
- sys_sem_init (&conn->close_completed);
- NSSBR_LOGINF ("malloc conn ok]conn=%p,pool=%p", conn, pool);
-}
-
-/*****************************************************************************
-* Prototype : ss_malloc_conn
-* Description : malloc conn, only used in spl
-* Input : mring_handle pool
-* netconn_type_t type
-* Output : None
-* Return Value : spl_netconn_t*
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-spl_netconn_t *
-ss_malloc_conn (mring_handle pool, spl_netconn_type_t type)
-{
- spl_netconn_t *conn = NULL;
-
- if (nsfw_mem_ring_dequeue (pool, (void **) &conn) != 1)
- {
- NSSBR_LOGERR ("malloc conn failed");
- return NULL;
- }
-
- ss_init_conn (conn, pool, type);
- return conn;
-}
-
-/*****************************************************************************
-* Prototype : ss_malloc_conn_app
-* Description : malloc conn, only used in app
-* Input : mring_handle pool
-* netconn_type_t type
-* Output : None
-* Return Value : spl_netconn_t*
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-spl_netconn_t *
-ss_malloc_conn_app (mring_handle pool, spl_netconn_type_t type)
-{
- spl_netconn_t *conn = NULL;
-
- if (nsfw_mem_ring_dequeue (pool, (void **) &conn) != 1)
- {
- NSSBR_LOGERR ("malloc conn failed");
- return NULL;
- }
-
- if (ss_add_pid (conn, get_sys_pid ()) < 0)
- {
- NSSBR_LOGERR ("ss_add_pid failed]conn=%p", conn);
- }
-
- ss_init_conn (conn, pool, type);
- return conn;
-}
-
-/*****************************************************************************
-* Prototype : ss_free_conn
-* Description : free conn
-* Input : spl_netconn_t* conn
-* mring_handle pool
-* Output : None
-* Return Value : void
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-void
-ss_free_conn (spl_netconn_t * conn)
-{
- ss_reset_conn (conn);
-
- if (res_free (&conn->res_chk))
- {
- NSFW_LOGERR ("conn refree!]conn=%p", conn);
- return;
- }
-
- mring_handle pool = ss_get_conn_pool (conn);
- if (nsfw_mem_ring_enqueue (pool, (void *) conn) != 1)
- {
- NSSBR_LOGERR ("nsfw_mem_ring_enqueue failed,this can not happen");
- }
-
- NSSBR_LOGINF ("free conn ok]conn=%p,pool=%p", conn, pool);
-}
diff --git a/stacks/lwip_stack/lwip_src/common/stackx_spl_share.h b/stacks/lwip_stack/lwip_src/common/stackx_spl_share.h
deleted file mode 100644
index 2d35dd0..0000000
--- a/stacks/lwip_stack/lwip_src/common/stackx_spl_share.h
+++ /dev/null
@@ -1,490 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef STACKX_SPL_SHARE_H
-#define STACKX_SPL_SHARE_H
-#include "types.h"
-#include "common_mem_api.h"
-#include "nsfw_mem_api.h"
-#include "common_pal_bitwide_adjust.h"
-#include "stackx_ip_addr.h"
-#include <sys/types.h>
-#include "spl_opt.h"
-#include "stackx_ip_tos.h"
-#include "stackx_common_opt.h"
-#include "stackx_tx_box.h"
-#include "pidinfo.h"
-//#include "stackx_dfx_api.h"
-#include "compiling_check.h"
-#include "nsfw_msg.h"
-#include "stackx_spl_msg.h"
-#include "hal_api.h"
-#include "stackx_types.h"
-#include <errno.h>
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-#define MSG_PRIO_QUEUE_NUM 3
-COMPAT_PROTECT (MSG_PRIO_QUEUE_NUM, 3);
-
-#define SPL_MSG_BOX_NUM (MSG_PRIO_QUEUE_NUM + 1)
-
-#define SBR_FD_NETCONN_SIZE (256 * 3)
-COMPAT_PROTECT (SBR_FD_NETCONN_SIZE, 256 * 3);
-
-#define SS_NETCONN_SIZE (256 * 2)
-#define SBR_FD_SIZE (SBR_FD_NETCONN_SIZE - SS_NETCONN_SIZE)
-
-typedef struct
-{
- PRIMARY_ADDR mring_handle msg_pool;
- PRIMARY_ADDR mring_handle conn_pool;
- PRIMARY_ADDR struct spl_netconn **conn_array;
- u32 conn_num;
- i64 extend_member_bit;
-} sbr_recycle_group;
-
-typedef enum
-{
- SS_DELAY_STARTED,
- SS_DELAY_STOPPING,
- SS_DELAY_STOPPED,
- SS_DELAY_AGAIN
-} ss_delay_flag;
-
-typedef enum
-{
- NORMAL_RECV_RING = 0,
- CUSTOM_RECV_RING = 1,
-} recv_ring_type;
-
-typedef struct
-{
- PRIMARY_ADDR sbr_recycle_group *group;
- PRIMARY_ADDR struct spl_netconn *accept_from; /* for recycle fd in listen */
- void *delay_msg;
- nsfw_pidinfo pid_info;
- volatile i16 fork_ref;
- i8 is_listen_conn;
- i8 delay_flag;
-} netconn_recycle;
-
-typedef struct spl_netconn
-{
- i64 recv_obj;
- i64 comm_pcb_data; /* only used by spl */
- i64 private_data; /* only used by spl */
- PRIMARY_ADDR mring_handle msg_box;
- PRIMARY_ADDR mring_handle recv_ring;
- volatile u32 snd_buf;
- volatile i32 epoll_flag;
- /*here using prod/cons to instead recv_avail, avoid atomic oper. */
- volatile u32_t recv_avail_prod; /*the product of recv_avail */
- volatile u32_t recv_avail_cons; /*the consume of recv_avail */
- volatile i32 rcvevent;
- spl_netconn_state_t state;
- u16 sendevent;
- u16 errevent;
- volatile u16 shut_status;
- u8 flags;
- i8 last_err;
- u8 CanNotReceive;
- u8 recv_ring_valid;
- u16 bind_thread_index;
- u16 mss;
- sys_sem_st close_completed;
- mring_handle conn_pool; /* where the conn in pcb is from */
-
- void *epInfo;
-
- /* The following shared field access rules: protocol stack process
- * is responsible for writing, socket api process read only
- */
- i32 send_bufsize;
- i32 tcp_sndbuf;
- u32 tcp_wmem_alloc_cnt;
- u32 tcp_wmem_sbr_free_cnt;
- volatile u32 tcp_wmem_spl_free_cnt;
- u16 remote_port;
- u16 local_port;
- spl_ip_addr_t remote_ip;
- spl_ip_addr_t local_ip;
- spl_netconn_type_t type;
- spl_tcp_state_t tcp_state;
-
- /* for recycle */
- netconn_recycle recycle;
- nsfw_res res_chk;
- i64 extend_member_bit;
-} spl_netconn_t; /* sizeof(spl_netconn_t) need < SS_NETCONN_SIZE */
-SIZE_OF_TYPE_PLUS8_NOT_LARGER_THAN (spl_netconn_t, SS_NETCONN_SIZE);
-
-typedef struct
-{
- /**
- * it will increase after every restart which used for
- * tell different runnings.
- */
- u32 running_ref_no;
-
- /* only increased when fault to restart */
- u32 fault_ref_no;
-
- /* the procedures before upgrade are finished successfully */
- u32 prepare_upgrade_done;
-
-} spl_init_info_t;
-
-typedef struct netifExt
-{
- struct netifExt *next;
- u16_t id;
- char if_name[HAL_MAX_NIC_NAME_LEN];
- hal_hdl_t hdl;
- u16_t num_packets_recv;
-} netifExt;
-
-static inline mring_handle
-ss_get_msg_pool (spl_netconn_t * sh)
-{
- sbr_recycle_group *group =
- (sbr_recycle_group *) ADDR_SHTOL (sh->recycle.group);
- return ADDR_SHTOL (group->msg_pool);
-}
-
-static inline mring_handle
-ss_get_conn_pool (spl_netconn_t * sh)
-{
- sbr_recycle_group *group =
- (sbr_recycle_group *) ADDR_SHTOL (sh->recycle.group);
- return ADDR_SHTOL (group->conn_pool);
-}
-
-static inline int
-ss_is_nonblock_flag (spl_netconn_t * sh)
-{
- return (sh->flags & SPL_NETCONN_FLAG_NON_BLOCKING) != 0;
-}
-
-static inline int
-ss_get_nonblock_flag (spl_netconn_t * sh)
-{
- return ss_is_nonblock_flag (sh) ? O_NONBLOCK : 0;
-}
-
-static inline void
-ss_set_nonblock_flag (spl_netconn_t * sh, u32 flag)
-{
- if (flag)
- {
- sh->flags |= SPL_NETCONN_FLAG_NON_BLOCKING;
- }
- else
- {
- sh->flags &= ~SPL_NETCONN_FLAG_NON_BLOCKING;
- }
-}
-
-static inline int
-ss_get_last_errno (spl_netconn_t * sh)
-{
- return sh->last_err;
-}
-
-static inline i32
-ss_get_recv_event (spl_netconn_t * sh)
-{
- return sh->rcvevent;
-}
-
-static inline int
-ss_can_not_recv (spl_netconn_t * sh)
-{
- return sh->CanNotReceive;
-}
-
-static inline int
-ss_is_shut_rd (spl_netconn_t * sh)
-{
- int status = sh->shut_status;
- return ((SPL_SHUT_RD == status) || (SPL_SHUT_RDWR == status));
-}
-
-static inline void
-ss_set_shut_status (spl_netconn_t * sh, u16 how)
-{
- sh->shut_status = how;
-}
-
-static inline u16
-ss_get_shut_status (spl_netconn_t * sh)
-{
- return sh->shut_status;
-}
-
-static inline void
-ss_sub_recv_event (spl_netconn_t * sh)
-{
- __sync_fetch_and_sub (&sh->rcvevent, 1);
-}
-
-static inline void
-ss_add_recv_event (spl_netconn_t * sh)
-{
- __sync_fetch_and_add (&sh->rcvevent, 1);
-}
-
-static inline i64
-ss_get_recv_obj (spl_netconn_t * sh)
-{
- return sh->recv_obj;
-}
-
-static inline i64
-ss_get_private_data (spl_netconn_t * sh)
-{
- return sh->private_data;
-}
-
-static inline i64
-ss_get_comm_private_data (spl_netconn_t * sh)
-{
- return sh->comm_pcb_data;
-}
-
-static inline int
-ss_recv_ring_valid (spl_netconn_t * sh)
-{
- return sh->recv_ring_valid;
-}
-
-static inline mring_handle
-ss_get_recv_ring (spl_netconn_t * sh)
-{
- return (mring_handle) ADDR_SHTOL (sh->recv_ring);
-}
-
-static inline void
-ss_set_send_event (spl_netconn_t * sh, u16 value)
-{
- sh->sendevent = value;
-}
-
-static inline int
-ss_is_noautorecved_flag (spl_netconn_t * sh)
-{
- return (sh->flags & SPL_NETCONN_FLAG_NO_AUTO_RECVED) != 0;
-}
-
-static inline int
-ss_get_noautorecved_flag (spl_netconn_t * sh)
-{
- return ss_is_noautorecved_flag (sh) ? SPL_NETCONN_FLAG_NO_AUTO_RECVED : 0;
-}
-
-static inline void
-ss_set_noautorecved_flag (spl_netconn_t * sh, u8 flag)
-{
- if (flag)
- {
- sh->flags |= SPL_NETCONN_FLAG_NO_AUTO_RECVED;
- }
- else
- {
- sh->flags &= ~SPL_NETCONN_FLAG_NO_AUTO_RECVED;
- }
-}
-
-static inline void
-ss_set_state (spl_netconn_t * sh, spl_netconn_state_t state)
-{
- sh->state = state;
-}
-
-static inline int
-ss_is_write_state (spl_netconn_t * sh)
-{
- return (SPL_NETCONN_WRITE == sh->state);
-}
-
-static inline int
-ss_is_listen_state (spl_netconn_t * sh)
-{
- return (SPL_NETCONN_LISTEN == sh->state);
-}
-
-static inline void
-ss_sub_recv_avail (spl_netconn_t * sh, int value)
-{
- sh->recv_avail_cons += value;
-}
-
-static inline i32
-ss_get_recv_avail (spl_netconn_t * sh)
-{
- return sh->recv_avail_prod - sh->recv_avail_cons;
-}
-
-static inline u16
-ss_get_mss (spl_netconn_t * sh)
-{
- return sh->mss;
-}
-
-static inline spl_ip_addr_t *
-ss_get_remote_ip (spl_netconn_t * sh)
-{
- return &(sh->remote_ip);
-}
-
-static inline u16
-ss_get_remote_port (spl_netconn_t * sh)
-{
- return sh->remote_port;
-}
-
-static inline spl_tcp_state_t
-ss_get_tcp_state (spl_netconn_t * sh)
-{
- return sh->tcp_state;
-}
-
-static inline u16
-ss_get_bind_thread_index (spl_netconn_t * sh)
-{
- return sh->bind_thread_index;
-}
-
-static inline void
-ss_set_bind_thread_index (spl_netconn_t * sh, u16 bind_thread_index)
-{
- sh->bind_thread_index = bind_thread_index;
-}
-
-static inline void
-ss_set_msg_box (spl_netconn_t * sh, mring_handle box)
-{
- sh->msg_box = (mring_handle) ADDR_LTOSH (box);
-}
-
-static inline mring_handle
-ss_get_msg_box (spl_netconn_t * sh)
-{
- return (mring_handle) ADDR_SHTOL (sh->msg_box);
-}
-
-static inline spl_ip_addr_t *
-ss_get_local_ip (spl_netconn_t * sh)
-{
- return &sh->local_ip;
-}
-
-static inline void
-ss_set_local_ip (spl_netconn_t * sh, u32 addr)
-{
- if (!sh)
- {
- return;
- }
- sh->local_ip.addr = addr;
-}
-
-static inline u16
-ss_get_local_port (spl_netconn_t * sh)
-{
- return sh->local_port;
-}
-
-static inline void
-ss_set_local_port (spl_netconn_t * sh, u16 local_port)
-{
- sh->local_port = local_port;
-}
-
-static inline void
-ss_set_accept_from (spl_netconn_t * sh, spl_netconn_t * accept_from)
-{
- sh->recycle.accept_from = accept_from;
-}
-
-static inline void
-ss_set_is_listen_conn (spl_netconn_t * sh, i8 is_listen_conn)
-{
- sh->recycle.is_listen_conn = is_listen_conn;
-}
-
-static inline i32
-ss_inc_fork_ref (spl_netconn_t * sh)
-{
- return __sync_add_and_fetch (&sh->recycle.fork_ref, 1);
-}
-
-static inline i32
-ss_dec_fork_ref (spl_netconn_t * sh)
-{
- return __sync_sub_and_fetch (&sh->recycle.fork_ref, 1);
-}
-
-static inline i32
-ss_get_fork_ref (spl_netconn_t * sh)
-{
- return sh->recycle.fork_ref;
-}
-
-static inline int
-ss_add_pid (spl_netconn_t * sh, pid_t pid)
-{
- return nsfw_add_pid (&sh->recycle.pid_info, pid);
-}
-
-static inline int
-ss_del_pid (spl_netconn_t * sh, pid_t pid)
-{
- return nsfw_del_pid (&sh->recycle.pid_info, pid);
-}
-
-static inline int
-ss_is_pid_exist (spl_netconn_t * sh, pid_t pid)
-{
- return nsfw_pid_exist (&sh->recycle.pid_info, pid);
-}
-
-static inline int
-ss_is_pid_array_empty (spl_netconn_t * sh)
-{
- return nsfw_pidinfo_empty (&sh->recycle.pid_info);
-}
-
-spl_netconn_t *ss_malloc_conn (mring_handle pool, spl_netconn_type_t type);
-spl_netconn_t *ss_malloc_conn_app (mring_handle pool,
- spl_netconn_type_t type);
-void ss_free_conn (spl_netconn_t * conn);
-void ss_reset_conn (spl_netconn_t * conn);
-
-typedef void (*ss_close_conn_fun) (void *close_data, u32 delay_sec);
-int ss_recycle_conn (void *close_data, ss_close_conn_fun close_conn);
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif
diff --git a/stacks/lwip_stack/lwip_src/common/stackx_tcp_opt.h b/stacks/lwip_stack/lwip_src/common/stackx_tcp_opt.h
deleted file mode 100644
index cac3dcb..0000000
--- a/stacks/lwip_stack/lwip_src/common/stackx_tcp_opt.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef __STACKX_TCP_OPT_H__
-#define __STACKX_TCP_OPT_H__
-
-#include "spl_opt.h"
-
-/* TCP Options flags */
-#define TF_ACK_DELAY ((u32_t)0x01U) /* Delayed ACK. */
-#define TF_ACK_NOW ((u32_t)0x02U) /* Immediate ACK. */
-#define TF_WINDOWSCALING ((u32_t)0x40U) /* Window scaling option enabled */
-#define TF_INFR ((u32_t)0x04U) /* In fast recovery. */
-#define TF_TIMESTAMP ((u32_t)0x08U) /* Timestamp option enabled */
-#define TF_RXCLOSED ((u32_t)0x10U) /* rx closed by tcp_shutdown */
-#define TF_FIN ((u32_t)0x20U) /* Connection was closed locally (FIN segment enqueued). */
-#define TF_NODELAY ((u32_t)0x100U) /* Disable Nagle algorithm */
-#define TF_NAGLEMEMERR ((u32_t)0x80U)
-
-/* TCP segment Options flags */
-#define TF_SEG_OPTS_MSS (u8_t)0x01U /* Include MSS option. */
-#define TF_SEG_OPTS_TS (u8_t)0x02U /* Include timestamp option. */
-#define TF_SEG_OPTS_WS (u8_t)0x08U /* Include window scaling option. */
-
-#define STACKX_TCP_OPT_LENGTH(flags) \
- (flags & TF_SEG_OPTS_MSS ? 4 : 0) + \
- (flags & TF_SEG_OPTS_TS ? 12 : 0) + \
- (flags & TF_SEG_OPTS_WS ? 4 : 0)
-#endif
diff --git a/stacks/lwip_stack/lwip_src/common/stackx_tx_box.c b/stacks/lwip_stack/lwip_src/common/stackx_tx_box.c
deleted file mode 100644
index 74673ad..0000000
--- a/stacks/lwip_stack/lwip_src/common/stackx_tx_box.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "stackxopts.h"
-#include "nstack_log.h"
-#include "stackx_tx_box.h"
-#include "nsfw_mt_config.h"
-
-#define MZ_STACKX_RING_NAME "VppTCP_Ring"
-#define MZ_STACKX_PRIORITY_RING_NAME "VppTCP_Priority%u_Ring"
-
-/*
- * Given the stackx ring name template above, get the queue name
- */
-const char *
-get_stackx_ring_name ()
-{
- /* buffer for return value. Size calculated by %u being replaced
- * by maximum 3 digits (plus an extra byte for safety) */
- static char rbuffer[sizeof (MZ_STACKX_RING_NAME) + 16];
-
- int retVal =
- spl_snprintf (rbuffer, sizeof (rbuffer) - 1, MZ_STACKX_RING_NAME);
-
- if (-1 == retVal)
- {
- NSPOL_LOGERR ("spl_snprintf failed]");
- return NULL;
- }
-
- return rbuffer;
-}
-
-const char *
-get_stackx_priority_ring_name (unsigned priority)
-{
- /* buffer for return value. Size calculated by %u being replaced
- * by maximum 3 digits (plus an extra byte for safety) */
- static char prbuffer[sizeof (MZ_STACKX_PRIORITY_RING_NAME) + 32];
-
- int retVal = spl_snprintf (prbuffer, sizeof (prbuffer) - 1,
- MZ_STACKX_PRIORITY_RING_NAME, priority);
-
- if (-1 == retVal)
- {
- NSPOL_LOGERR ("spl_snprintf failed]");
- return NULL;
- }
-
- return prbuffer;
-}
diff --git a/stacks/lwip_stack/lwip_src/common/stackx_types.h b/stacks/lwip_stack/lwip_src/common/stackx_types.h
deleted file mode 100644
index 6c78a20..0000000
--- a/stacks/lwip_stack/lwip_src/common/stackx_types.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef STACKX_TYPES_H
-#define STACKX_TYPES_H
-
-#include <sys/time.h>
-#include <sys/types.h>
-#include <stdint.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#if 1
-#ifndef STACKX_MAX_S16_NUM
-#define STACKX_MAX_S16_NUM ((s16_t)0x7fff)
-#endif
-
-#ifndef STACKX_MAX_U16_NUM
-#define STACKX_MAX_U16_NUM ((u16_t)0xFfff)
-#endif
-
-#ifndef STACKX_MAX_U32_NUM
-#define STACKX_MAX_U32_NUM ((u32_t)0xffffffff)
-#endif
-
-#ifndef STACKX_MAX_S32_NUM
-#define STACKX_MAX_S32_NUM ((s32_t)0x7fffffff)
-#endif
-
-#ifndef STACKX_MAX_U64_NUM
-#define STACKX_MAX_U64_NUM ((u64_t)0xffffffffffffffff)
-#endif
-
-#ifndef STACKX_MAX_S64_NUM
-#define STACKX_MAX_S64_NUM ((s64_t)0x7fffffffffffffff)
-#endif
-#endif
-
-#if 1
-typedef uint64_t u64_t;
-typedef int64_t s64_t;
-
-typedef uint32_t u32_t;
-typedef int32_t s32_t;
-
-typedef uint16_t u16_t;
-typedef int16_t s16_t;
-
-typedef uint8_t u8_t;
-typedef int8_t s8_t;
-
-typedef uintptr_t mem_ptr_t;
-#endif
-
-#endif
diff --git a/stacks/lwip_stack/lwip_src/common/stackxopts.h b/stacks/lwip_stack/lwip_src/common/stackxopts.h
deleted file mode 100644
index 04ff67d..0000000
--- a/stacks/lwip_stack/lwip_src/common/stackxopts.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef STACKX_OPTS_H
-#define STACKX_OPTS_H
-
-struct memory_statics
-{
- char name[120];
- long size;
-};
-
-extern u32 g_type;
-extern struct memory_statics memory_used_size[80];
-
-#define DPDK_MEMORY_COUNT(memory, len)\
-{\
- if (g_type < MAX_MEMORY_USED_SIZE)\
- {\
- const char * ptr_memory = memory;\
- if (ptr_memory && EOK != STRCPY_S(memory_used_size[g_type].name, sizeof(memory_used_size[g_type].name), ptr_memory))\
- {\
- NSPOL_LOGERR("STRCPY_S failed.");\
- }\
- memory_used_size[g_type].size =(long) len;\
- g_type++;\
- }\
-}
-
-#define SPL_MAX_UDP_MSG_LEN (0xFFFF -28)
-#define RECV_MAX_POOL 4
-#define MAX_TRY_GET_MEMORY_TIMES 4
-#define MAX_MEMORY_USED_SIZE 80
-#define SPL_IP_HLEN 20
-#define SPL_TCP_HLEN 20
-#define SPL_TCP_MAX_OPTION_LEN 40
-#define SPL_FRAME_MTU 1500
-#define SPL_TCP_SEND_MAX_SEG_PER_MSG 25
-
-#endif
diff --git a/stacks/lwip_stack/lwip_src/core/global_tick.c b/stacks/lwip_stack/lwip_src/core/global_tick.c
deleted file mode 100644
index ee180c9..0000000
--- a/stacks/lwip_stack/lwip_src/core/global_tick.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "nsfw_mem_api.h"
-#include "nstack_share_res.h"
-#include "nstack_securec.h"
-
-extern nstack_tick_info_t g_nstack_timer_tick;
-
-int
-init_stackx_global_tick (void)
-{
- nsfw_mem_zone mzone;
-
- if (STRCPY_S
- (mzone.stname.aname, NSFW_MEM_NAME_LENGTH, NSTACK_GLOBAL_TICK_SHM) != 0)
- {
- NSPOL_LOGERR ("STRCPY_S fail");
- return -1;
- }
-
- mzone.stname.entype = NSFW_SHMEM;
- mzone.isocket_id = -1;
- mzone.length = sizeof (uint64_t);
- mzone.ireserv = 0;
-
- g_nstack_timer_tick.tick_ptr = (uint64_t *) nsfw_mem_zone_create (&mzone);
- if (NULL == g_nstack_timer_tick.tick_ptr)
- {
- NSPOL_LOGERR ("Failed to create global timer tick memory");
- return -1;
- }
-
- return 0;
-}
diff --git a/stacks/lwip_stack/lwip_src/core/spl_pbuf.c b/stacks/lwip_stack/lwip_src/core/spl_pbuf.c
deleted file mode 100644
index e4aa014..0000000
--- a/stacks/lwip_stack/lwip_src/core/spl_pbuf.c
+++ /dev/null
@@ -1,611 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "spl_opt.h"
-
-#include "spl_def.h"
-#include "spl_pbuf.h"
-#include "stackx_pbuf.h"
-
-#include "stackx_spl_share.h"
-#include "spl_api.h"
-
-#include "nsfw_maintain_api.h"
-#include "netif/sc_dpdk.h"
-#include <common_mem_mbuf.h>
-
-#include <string.h>
-#include "nstack_log.h"
-#include "nstack_securec.h"
-#include "spl_instance.h"
-
-#include "sys.h"
-#include "mem.h"
-#include "memp.h"
-//#include "sockets.h"
-//#include <netinet/in.h>
-#include <stdio.h>
-#include <stdlib.h>
-#ifdef HAL_LIB
-#else
-#include "rte_memcpy.h"
-#endif
-#define SIZEOF_STRUCT_PBUF LWIP_MEM_ALIGN_SIZE(sizeof(struct spl_pbuf))
-u16_t g_offSetArry[SPL_PBUF_MAX_LAYER];
-
-u16_t g_offSetArry[SPL_PBUF_MAX_LAYER] =
- { PBUF_TRANSPORT_HLEN + PBUF_IP_HLEN + SPL_PBUF_LINK_HLEN,
- SPL_PBUF_UDP_HLEN + PBUF_IP_HLEN + SPL_PBUF_LINK_HLEN,
- PBUF_IP_HLEN + SPL_PBUF_LINK_HLEN,
- SPL_PBUF_LINK_HLEN,
- 0
-};
-
-inline struct spl_pbuf *
-spl_pbuf_alloc_hugepage (spl_pbuf_layer layer, u16_t length,
- spl_pbuf_type Type, u16_t proc_id, void *net_conn)
-{
- struct spl_pbuf *p;
- u16_t offset;
- u16_t count = 0;
- spl_netconn_t *conn = (spl_netconn_t *) net_conn;
-
- NSPOL_LOGDBG (PBUF_DEBUG | STACKX_DBG_TRACE,
- "spl_pbuf_alloc_hugepage]length=%" U16_F, length);
-
- /* determine header offset */
- if (likely (layer < SPL_PBUF_MAX_LAYER))
- {
- offset = g_offSetArry[layer];
- }
- else
- {
- NSPOL_LOGERR ("spl_pbuf_alloc_hugepage: bad pbuf layer");
- return NULL;
- }
-
- if (unlikely (length < offset || Type != SPL_PBUF_HUGE))
- {
- NSPOL_LOGERR ("input is invalid!]length=%u, Type = %d", length, Type);
- return NULL;
- }
-
- p = spl_mbuf_malloc (length, SPL_PBUF_HUGE, &count);
-
- if (p == NULL)
- {
- /* last_log_prt_time and unprint_log_count indeed have multi-thread issue,
- * but their values don't have precision requirement. No risk. */
- NS_LOG_CTRL (LOG_CTRL_HUGEPAGE_ALLOC_FAIL, STACKX, "NSLWIP", NSLOG_ERR,
- "pbuf_alloc_huge: Could not allocate PBUF for SPL_PBUF_HUGE");
-
- return NULL;
- }
-
- if (conn)
- {
- p->conn_a = ADDR_LTOSH (conn);
- }
- else
- {
- p->conn_a = 0;
- }
-
- p->tot_len -= offset;
- p->len -= offset;
- p->next_a = 0;
-
- p->payload_a = p->payload_a + offset;
-
- p->proto_type = SPL_PBUF_PROTO_NONE;
-
- NSPOL_LOGDBG (PBUF_DEBUG | STACKX_DBG_TRACE,
- "pbuf_alloc]length=%" U16_F ",p=%p", length, (void *) p);
- return p;
-}
-
-inline int
-spl_pbuf_internal_copy (struct spl_pbuf *dst, struct spl_pbuf *src)
-{
- u32_t dst_len = dst->len;
- u32_t src_len = src->len;
- u32_t dst_pos = 0;
- u32_t src_pos = 0;
- while (dst != NULL && src != NULL)
- {
- if (dst_len > src_len)
- {
- if (NULL ==
- common_memcpy (PTR_SHTOL (char *, dst->payload_a) + dst_pos,
- PTR_SHTOL (char *, src->payload_a) + src_pos,
- src_len))
- {
- NSPOL_LOGERR ("rte_memcpy error");
- return -1;
- }
-
- dst_len -= src_len;
- dst_pos += src_len;
- src = ADDR_SHTOL (src->next_a);
- src_len = src != NULL ? src->len : 0;
- src_pos = 0;
- }
- else if (dst_len < src_len)
- {
- if (NULL ==
- common_memcpy (PTR_SHTOL (char *, dst->payload_a) + dst_pos,
- PTR_SHTOL (char *, src->payload_a) + src_pos,
- dst_len))
- {
- NSPOL_LOGERR ("rte_memcpy error");
- return -1;
- }
-
- src_len -= dst_len;
- src_pos += dst_len;
- dst = ADDR_SHTOL (dst->next_a);
- dst_len = dst != NULL ? dst->len : 0;
- dst_pos = 0;
- }
- else
- {
- if (NULL ==
- common_memcpy (PTR_SHTOL (char *, dst->payload_a) + dst_pos,
- PTR_SHTOL (char *, src->payload_a) + src_pos,
- dst_len))
- {
- NSPOL_LOGERR ("rte_memcpy error");
- return -1;
- }
-
- src = ADDR_SHTOL (src->next_a);
- src_len = src != NULL ? src->len : 0;
- src_pos = 0;
- dst = ADDR_SHTOL (dst->next_a);
- dst_len = dst != NULL ? dst->len : 0;
- dst_pos = 0;
- }
- }
- return 0;
-}
-
-void
-spl_pbuf_realloc (struct spl_pbuf *p, u32_t new_len)
-{
- if (NULL != p && p->type == SPL_PBUF_HUGE)
- {
- p->tot_len = new_len;
- p->len = new_len;
- return;
- }
-}
-
-void
-spl_pbuf_free (struct spl_pbuf *p)
-{
- struct spl_pbuf *q;
- u8_t count = 0;
-
- NSPOL_LOGINF (PBUF_DEBUG, "Freeing PBF %p", p);
-
- if (unlikely (p == NULL || p->type != SPL_PBUF_HUGE))
- {
- NSPOL_LOGDBG (PBUF_DEBUG | STACKX_DBG_LEVEL_SERIOUS,
- "input param illegal]p=%p, type=%d", p, p ? p->type : -1);
- return;
- }
-
- (void) count;
-
- /* de-allocate all consecutive pbufs from the head of the chain that
- * obtain a zero reference count after decrementing*/
- do
- {
- /* remember next pbuf in chain for next iteration */
- NSPOL_LOGDBG (PBUF_DEBUG | STACKX_DBG_TRACE,
- "spl_pbuf_free: deallocating]buf=%p", (void *) p);
- q = (struct spl_pbuf *) ADDR_SHTOL (p->next_a);
- if (res_free (&p->res_chk))
- {
- //NSPOL_LOGERR("res_free failed]p=%p", p);
- }
-
- count++;
- {
- pbuf_set_recycle_flg (p, MBUF_UNUSED); /* release buf hold by app on abnormal exit */
- spl_mbuf_free ((char *) p - sizeof (struct common_mem_mbuf));
- p->res_chk.u8Reserve |= PBUF_FREE_FLAG;
- }
-
- /* proceed to next pbuf */
- p = q;
- }
- while (p != NULL);
-
- /* return number of de-allocated pbufs */
- return;
-}
-
-void
-spl_pbuf_cat (struct spl_pbuf *h, struct spl_pbuf *t)
-{
- struct spl_pbuf *p;
-
- if (h == NULL || t == NULL)
- {
- NSPOL_LOGERR ("pbuf_cat: h=NULL||t=NULL!!");
- return;
- }
-
- for (p = h; p->next_a != 0; p = PTR_SHTOL (struct spl_pbuf *, p->next_a))
- {
- /* add total length of second chain to all totals of first chain */
- p->tot_len += t->tot_len;
- }
-
- if (0 != p->next_a)
- {
- NSPOL_LOGERR
- ("pbuf_cat: p is not the last pbuf of the first chain, p->next_a != 0");
- return;
- }
-
- /* add total length of second chain to last pbuf total of first chain */
- p->tot_len += t->tot_len;
-
- /* chain last pbuf of head (p) with first of tail (t) */
- p->next_a = (uint64_t) ADDR_LTOSH_EXT (t);
-
- /* p->next now references t, but the caller will drop its reference to t,
- * so netto there is no change to the reference count of t.
- */
-}
-
-err_t
-spl_pbuf_copy (struct spl_pbuf * p_to, struct spl_pbuf * p_from)
-{
- u32_t offset_to = 0;
- u32_t offset_from = 0;
- u32_t len = 0;
- NSPOL_LOGDBG (PBUF_DEBUG | STACKX_DBG_TRACE, "pbuf_copy]p_to=%p,p_from=%p",
- (void *) p_to, (void *) p_from);
-
- if (!
- ((p_to != NULL) && (p_from != NULL)
- && (p_to->tot_len >= p_from->tot_len)))
- {
- NSPOL_LOGERR ("pbuf_copy: target not big enough to hold source");
- return ERR_ARG;
- }
-
- do
- {
- if (p_to == NULL)
- {
- NSPOL_LOGERR ("pbuf_copy: target pbuf not exist: p_to == NULL!!");
- return ERR_ARG;
- }
-
- if ((p_to->len - offset_to) >= (p_from->len - offset_from))
- {
-
- len = p_from->len - offset_from;
- }
- else
- {
-
- len = p_to->len - offset_to;
- }
-
- if (EOK !=
- MEMMOVE_S ((u8_t *) ADDR_SHTOL (p_to->payload_a) + offset_to, len,
- (u8_t *) ADDR_SHTOL (p_from->payload_a) + offset_from,
- len))
- {
- NSPOL_LOGERR ("MEMMOVE_S failed");
- return ERR_MEM;
- }
-
- offset_to += len;
- offset_from += len;
- if (offset_to > p_to->len)
- {
- NSPOL_LOGERR
- ("pbuf_copy: target offset not match: offset_to > p_to->len.");
- return ERR_VAL;
- }
- if (offset_to == p_to->len)
- {
- offset_to = 0;
- p_to = (struct spl_pbuf *) ADDR_SHTOL (p_to->next_a);
- }
-
- if (offset_from >= p_from->len)
- {
- /* on to next p_from (if any) */
- NSPOL_LOGDBG (PBUF_DEBUG | STACKX_DBG_TRACE,
- "pbuf_copy: source offset not match: offset_from >= p_from->len");
- offset_from = 0;
- p_from = (struct spl_pbuf *) ADDR_SHTOL (p_from->next_a);
- }
-
- if ((p_from != NULL) && (p_from->len == p_from->tot_len))
- {
- if ((p_from->next_a != 0))
- {
- NSPOL_LOGERR ("pbuf_copy() does not allow packet queues!");
- return ERR_VAL;
- }
- }
-
- if ((p_to != NULL) && (p_to->len == p_to->tot_len))
- {
- /* don't copy more than one packet! */
- if ((p_to->next_a != 0))
- {
- NSPOL_LOGERR ("pbuf_copy() does not allow packet queues!");
- return ERR_VAL;
- }
- }
- }
- while (p_from);
-
- NSPOL_LOGDBG (PBUF_DEBUG | STACKX_DBG_TRACE,
- "pbuf_copy: end of chain reached.");
- return ERR_OK;
-}
-
-err_t
-splpbuf_to_pbuf_transport_copy (struct pbuf * p_to, struct spl_pbuf * p_from)
-{
- if (EOK != MEMMOVE_S ((u8_t *) p_to->payload,
- p_to->len, (u8_t *) ADDR_SHTOL (p_from->payload_a),
- p_from->len))
- {
- NSPOL_LOGERR ("MEMMOVE_S failed");
- return ERR_MEM;
- }
-
- return ERR_OK;
-}
-
-err_t
-splpbuf_to_pbuf_copy (struct pbuf * p_to, struct spl_pbuf * p_from)
-{
- u32_t offset_to = 0;
- u32_t offset_from = 0;
- u32_t len = 0;
-
- NSPOL_LOGINF (NETIF_DEBUG, "splpbuf_to_pbuf_copy");
-
- if (!
- ((p_to != NULL) && (p_from != NULL)
- && (p_to->tot_len >= p_from->tot_len)))
- {
- NSPOL_LOGERR
- ("splpbuf_to_pbuf_copy: target not big enough to hold source");
- return ERR_ARG;
- }
- NSPOL_LOGINF (PBUF_DEBUG,
- "splpbuf_to_pbuf_copy]p_to=%p [type %d tot_len %d], p_from=%p [type %d tot_len %d]",
- (void *) p_to, p_to->type, p_to->tot_len, (void *) p_from,
- p_from->type, p_from->tot_len);
- do
- {
- NSPOL_LOGINF (NETIF_DEBUG, "copying....");
- if (p_to == NULL)
- {
- NSPOL_LOGERR
- ("splpbuf_to_pbuf_copy: target not big enough to hold source p_to len [%d] p_from len [%d]",
- p_to->tot_len, p_from->tot_len);
- return ERR_ARG;
- }
-
- if ((p_to->len - offset_to) >= (p_from->len - offset_from))
- {
-
- len = p_from->len - offset_from;
- }
- else
- {
-
- len = p_to->len - offset_to;
- }
-
- if (EOK != MEMMOVE_S ((u8_t *) p_to->payload + offset_to,
- len,
- (u8_t *) ADDR_SHTOL (p_from->payload_a) +
- offset_from, len))
- {
- NSPOL_LOGERR ("MEMMOVE_S failed");
- return ERR_MEM;
- }
-
- offset_to += len;
- offset_from += len;
- if (offset_to > p_to->len)
- {
- NSPOL_LOGERR
- ("splpbuf_to_pbuf_copy: target offset not match: offset_to > p_to->len.");
- return ERR_VAL;
- }
- if (offset_to == p_to->len)
- {
- offset_to = 0;
- p_to = p_to->next;
-
- NSPOL_LOGINF (NETIF_DEBUG,
- "splpbuf_to_pbuf_copy: p_to next %p", p_to);
- }
-
- if (offset_from >= p_from->len)
- {
- /* on to next p_from (if any) */
- NSPOL_LOGINF (NETIF_DEBUG,
- "splpbuf_to_pbuf_copy: source offset not match: offset_from >= p_from->len");
- offset_from = 0;
- p_from = (struct spl_pbuf *) ADDR_SHTOL (p_from->next_a);
- NSPOL_LOGINF (NETIF_DEBUG,
- "splpbuf_to_pbuf_copy: pfrom next %p", p_from);
- }
-
- if ((p_from != NULL) && (p_from->len == p_from->tot_len))
- {
- if ((p_from->next_a != 0))
- {
- NSPOL_LOGERR
- ("splpbuf_to_pbuf_copy() does not allow packet queues!");
- return ERR_VAL;
- }
- }
-
- if ((p_to != NULL) && (p_to->len == p_to->tot_len))
- {
- /* don't copy more than one packet! */
- if ((p_to->next != NULL))
- {
- NSPOL_LOGERR
- ("splpbuf_to_pbuf_copy() does not allow packet queues!");
- return ERR_VAL;
- }
- }
- }
- while (p_from);
-
- NSPOL_LOGDBG (NETIF_DEBUG, "splpbuf_to_pbuf_copy: end of chain reached.");
- return ERR_OK;
-}
-
-err_t
-pbuf_to_splpbuf_copy (struct spl_pbuf * p_to, struct pbuf * p_from)
-{
- int offset = 0;
- void *data = NULL;
-
- do
- {
- data = (u8_t *) (p_to->payload_a) + offset;
- memcpy (data, (u8_t *) p_from->payload, p_from->len);
- offset = offset + p_from->len;
- if (offset >= 2048)
- {
- NSPOL_LOGERR ("More thank 2K size");
- return ERR_MEM;
- }
- p_from = p_from->next;
- }
- while (p_from != NULL);
-
- return ERR_OK;
-}
-
-struct pbuf *
-spl_convert_spl_pbuf_to_pbuf (struct spl_pbuf *p_from)
-{
- struct pbuf *p_to = NULL;
-
- p_to = pbuf_alloc (PBUF_RAW, p_from->tot_len, PBUF_POOL);
- if (p_to)
- {
- splpbuf_to_pbuf_copy (p_to, p_from);
- }
- return p_to;
-}
-
-spl_pbuf_layer
-get_pbuf_layer_from_pbuf_payload (struct pbuf * buf)
-{
-
- struct eth_hdr *ethhdr;
- spl_pbuf_layer layer = SPL_PBUF_TRANSPORT;
- u16_t type;
-
- if (buf->len <= SIZEOF_ETH_HDR)
- {
- NSPOL_LOGINF (PBUF_DEBUG,
- "get_pbuf_layer_from_payload failed. length is wrong");
- return layer;
- }
- ethhdr = (struct eth_hdr *) buf->payload;
- type = spl_htons (ethhdr->type);
-
- NSPOL_LOGINF (PBUF_DEBUG, "packet type %x", type);
-
- switch (type)
- {
- case ETHTYPE_IP:
- layer = SPL_PBUF_IP;
- break;
- case ETHTYPE_ARP:
- layer = SPL_PBUF_LINK;
- break;
- default:
- layer = SPL_PBUF_TRANSPORT;
- break;
- }
-
- return layer;
-}
-
-void
-print_pbuf_payload_info (struct pbuf *buf, bool send)
-{
-
- struct eth_hdr *ethhdr;
- u16_t type;
-
- if (buf->len <= SIZEOF_ETH_HDR)
- {
- NSPOL_LOGINF (PBUF_DEBUG,
- "get_pbuf_layer_from_payload failed. length is wrong");
- return;
- }
- ethhdr = (struct eth_hdr *) buf->payload;
- type = spl_htons (ethhdr->type);
-
- if (send)
- {
- NSPOL_LOGINF (PBUF_DEBUG, "send packet start type %x len %d *****",
- type, buf->len);
- }
- else
- {
- NSPOL_LOGINF (PBUF_DEBUG,
- "receive packet start type %x len %d ########", type,
- buf->len);
- }
-
- switch (type)
- {
- case ETHTYPE_IP:
- NSPOL_LOGINF (TCPIP_DEBUG, "ip packet len %d tot len %d type %x",
- buf->len, buf->tot_len, type);
- struct ip_hdr *ip =
- (struct ip_hdr *) ((char *) buf->payload + SIZEOF_ETH_HDR);
- NSPOL_LOGINF (PBUF_DEBUG, "ip packet src %x dest %x proto %d", ip->src,
- ip->dest, ip->_proto);
- break;
- case ETHTYPE_ARP:
- NSPOL_LOGINF (TCPIP_DEBUG, "arp packet len %d tot len %d type %x",
- buf->len, buf->tot_len, type);
- break;
- default:
- NSPOL_LOGINF (TCPIP_DEBUG, "other packet len %d tot len %d type %x",
- buf->len, buf->tot_len, type);
- break;
- }
- return;
-}
diff --git a/stacks/lwip_stack/lwip_src/core/spl_timers.c b/stacks/lwip_stack/lwip_src/core/spl_timers.c
deleted file mode 100644
index cfa130b..0000000
--- a/stacks/lwip_stack/lwip_src/core/spl_timers.c
+++ /dev/null
@@ -1,607 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "opt.h"
-#include "nsfw_mem_api.h"
-#include "def.h"
-#include "sc_dpdk.h"
-#include "nstack_log.h"
-#include "nstack_securec.h"
-#include "nstack_share_res.h"
-
-#include <time.h>
-#include <signal.h>
-#include <pthread.h>
-#include <syscall.h>
-#include "nsfw_ps_api.h"
-#include "spl_timers.h"
-#include "common_mem_api.h"
-
-extern sys_thread_t g_timerThread_id;
-
-/*Since the range of the dpdk read TSC value is u64_t, it changes*/
-
-#ifndef typecheck
-#define typecheck(type, x) \
-({ type __dummy; \
- typeof(x)__dummy2; \
- (void)(&__dummy == &__dummy2); \
- 1; \
- })
-#endif
-
-#ifndef time_after_eq
-#define time_after_eq(a, b) \
-(typecheck(unsigned long, a) \
- && typecheck(unsigned long, b) \
- && ((long)(a) - (long)(b) >= 0))
-#endif
-
-#define MIN_TIME_PICE 50
-#define MICRO_PER_SECOND 1000
-#define NANO_PER_MICROSECOND 1000000
-#define NANO_PER_SECOND 1000000000
-
-#define PTIMER_MSG_BUFFER_SIZE 4096
-
-#define PTIMER_STATE_INACTIVE 0x00
-#define PTIMER_STATE_ENQUEUED 0x01
-#define gettid() syscall(__NR_gettid)
-
-#define TIMER_CONTEXT_NAME "TIMER_CONTEXT_NAME"
-
-static timer_t lazy_tim;
-static timer_t lazy_tim_retry;
-static struct ptimer_base ptimer;
-static sys_sem_t ptimer_lock;
-
-extern void recycle_tmr (struct ptimer_node *tmo);
-
-extern nstack_tick_info_t g_nstack_timer_tick;
-
-/*
- ***************************
- * rb_tree wrapper function*
- ***************************
- */
-NSTACK_STATIC void
-remove_ptimer (struct ptimer_node *tmo, struct ptimer_base *base)
-{
- if (tmo == NULL)
- {
- NSPOL_LOGERR ("input parameter tmo is null");
- return;
- }
- if (!(tmo->state & PTIMER_STATE_ENQUEUED))
- {
- NSPOL_LOGWAR (TIMERS_DEBUG | LWIP_DBG_LEVEL_WARNING,
- "the timer state is: PTIMER_STATE_INACTIVE, no need to remove!");
- return;
- }
-
- if (base->first == &tmo->node)
- {
- base->first = rb_next (&tmo->node);
- }
-
- rb_erase (&tmo->node, &base->active);
-
- tmo->state = PTIMER_STATE_INACTIVE;
-}
-
-NSTACK_STATIC struct ptimer_node *
-search_ptimer (struct ptimer_msg *msg)
-{
- if (msg == NULL)
- {
- NSPOL_LOGERR ("input parameter msg is null");
- return NULL;
- }
- if (msg->node)
- {
- return msg->node;
- }
-
- return NULL;
-
-}
-
-err_t
-del_ptimer (struct ptimer_msg * msg)
-{
- struct ptimer_node *tmo;
-
- tmo = search_ptimer (msg);
- if (tmo)
- {
- remove_ptimer (tmo, &ptimer);
- NSPOL_LOGDBG (TIMERS_DEBUG, "del]thread=%u,ptimer_node=%p", tmo->index,
- tmo);
- return ERR_OK;
- }
-
- NSPOL_LOGERR ("ptime_node not found!!");
- return ERR_VAL;
-}
-
-/*
- * Ptimer inserted into rb_tree
- * @param node: the ptimer node pointer
- * @param base: the ptimer root_base pointer
- */
-NSTACK_STATIC void
-enqueue_ptimer (struct ptimer_node *tmo, struct ptimer_base *base)
-{
- struct rb_node **linknode;
- struct rb_node *parent = NULL;
- struct ptimer_node *entry;
- int leftmost = 1;
- if (tmo == NULL || base == NULL)
- {
- NSPOL_LOGERR ("input parameter is null");
- return;
- }
-
- if ((tmo->state & PTIMER_STATE_ENQUEUED))
- {
- NSPOL_LOGWAR (TIMERS_DEBUG | LWIP_DBG_LEVEL_WARNING,
- "the timer state is: PTIMER_STATE_ENQUEUED");
- return;
- }
-
- linknode = &base->active.rb_node;
- while (*linknode)
- {
- parent = *linknode;
- entry = rb_entry (parent, struct ptimer_node, node);
- //XXX: do by the equal case is all of price of the large case
- if (time_after_eq (entry->abs_nsec, tmo->abs_nsec))
- {
- linknode = &(*linknode)->rb_left;
- }
- else
- {
- linknode = &(*linknode)->rb_right;
- leftmost = 0;
- }
- }
-
- /*
- * Insert the timer to the rb_tree and check whether it
- * replaces the first pending timer
- */
- if (leftmost)
- {
- base->first = &tmo->node;
- }
-
- rb_link_node (&tmo->node, parent, linknode);
- rb_insert_color (&tmo->node, &base->active);
- NSPOL_LOGDBG (TIMERS_DEBUG, "enqueue]thread=%u,ptimer_node=%p", tmo->index,
- tmo);
- tmo->state |= PTIMER_STATE_ENQUEUED;
-}
-
-void
-launch_tmr (timer_t * tim, u64_t nsec)
-{
- struct itimerspec vtim;
-
- vtim.it_value.tv_sec = (nsec) / NANO_PER_SECOND;
- vtim.it_value.tv_nsec = (nsec) % NANO_PER_SECOND;
- vtim.it_interval.tv_sec = 0;
- vtim.it_interval.tv_nsec = 0;
-
- if (timer_settime (*tim, 0, &vtim, NULL) < 0)
- {
- NSPOL_LOGERR ("add_ptimer:timer_settime failed");
- }
-
-}
-
-/*
- * add ptimer to rb_tree
- * @param tmo: the ptimer node pointer
- */
-void
-add_ptimer (struct ptimer_node *tmo)
-{
- if (tmo == NULL)
- {
- NSPOL_LOGERR ("input parameter is null");
- return;
- }
- enqueue_ptimer (tmo, &ptimer);
-
- if (ptimer.first == &tmo->node)
- {
- launch_tmr (&lazy_tim, tmo->info.msec * NANO_PER_MICROSECOND);
- }
-}
-
-#if 1
-/*
- * cond signal ,send a ptimer message
- * @param type: the message type
- * @param handler: timeout handler
- * @param node: the ptimer node pointer
- */
-void
-regedit_ptimer (enum msg_type Type, sys_timeout_handler handler,
- struct ptimer_node *node)
-{
- (void) handler;
- (void) pthread_mutex_lock (&ptimer.lock);
- if (ptimer.tail == NULL)
- {
- (void) pthread_mutex_unlock (&ptimer.lock);
- NSPOL_LOGERR ("ptimer.tail is null");
- free (node);
- node = NULL;
- return;
- }
- ptimer.tail->msg_type = Type;
- ptimer.tail->node = node;
- ptimer.tail = ptimer.tail->next;
- if (ptimer.head == ptimer.tail)
- {
- (void) pthread_mutex_unlock (&ptimer.lock);
- NSPOL_LOGERR ("ptimer.head equal to ptimer.tail");
- return;
- }
-
- (void) pthread_kill (g_timerThread_id, SIGRTMIN + 2);
-
- (void) pthread_mutex_unlock (&ptimer.lock);
- return;
-}
-#endif
-/*
- * deal with the timeout signal
- *
- */
-void
-deal_timeout_sig (void)
-{
- struct ptimer_node *tmo;
- struct timespec now;
- unsigned long abs_nsec;
- err_t err;
- int retval;
- if (ptimer.first == NULL)
- {
- return;
- }
- tmo = rb_entry (ptimer.first, struct ptimer_node, node);
- retval = clock_gettime (CLOCK_MONOTONIC, &now);
- if (0 != retval)
- {
- NSPOL_LOGERR ("clock_gettime failed]retval=%d,errno=%d", retval, errno);
- }
- abs_nsec = now.tv_sec * NANO_PER_SECOND + now.tv_nsec;
-
- // deal with all timeout point
- while (time_after_eq (abs_nsec, tmo->abs_nsec))
- {
- remove_ptimer (tmo, &ptimer);
-
- if (tmo->info.flags & PTIMER_ONESHOT)
- {
- }
- else
- {
- //re-entry periodic ptimer
- tmo->abs_nsec = now.tv_sec * NANO_PER_SECOND + now.tv_nsec
- + tmo->info.msec * NANO_PER_MICROSECOND;
- add_ptimer (tmo);
- }
-
- //send timeout message
- NSPOL_LOGDBG (INTERRUPT_DEBUG,
- "ptimer happened to thread_index]index=%u", tmo->index);
- if ((err = ltt_apimsg (tmo->info._phandle, (void *) tmo)))
- {
- NSPOL_LOGWAR (TIMERS_DEBUG | LWIP_DBG_LEVEL_WARNING,
- "send timeout message failed!]errno=%d", err);
- }
-
- if (ptimer.first == NULL)
- {
- NSPOL_LOGERR ("deal_timeout_sig: ptimer.first == NULL!!");
- return;
- }
- tmo = rb_entry (ptimer.first, struct ptimer_node, node);
- }
-
- if (tmo->abs_nsec <= abs_nsec)
- {
- NSPOL_LOGERR ("tmo->abs_nsec is smaller than abs_nsec");
- return;
- }
-
- NSPOL_LOGDBG (TIMERS_DEBUG, "TIMERSIGNAL : Launch timer for]time=%ul",
- tmo->abs_nsec - abs_nsec);
- launch_tmr (&lazy_tim, tmo->abs_nsec - abs_nsec); //timer interupted eveny 50ms instand by tmo->abs_nsec
-}
-
-/*
- * timeout signal handle function
- * @param v: unused argument
- */
-/*ptimer is already protected and used*/
-
-NSTACK_STATIC void
-timeout_sigaction (int sig)
-{
- (void) sig;
- if (!sys_arch_sem_trywait (&ptimer_lock))
- {
- launch_tmr (&lazy_tim_retry,
- (MIN_TIME_PICE / 5) * NANO_PER_MICROSECOND);
- return;
- }
-
- deal_timeout_sig ();
-
- sys_sem_signal (&ptimer_lock);
-
- return;
-}
-
-/*
- * initialize the ptimer buffer and timing mechanism
- */
-err_t
-init_ptimer (void)
-{
- int i, retval;
- struct sigevent timer_event;
- struct sigevent timer_event1;
- struct ptimer_msg *ptr;
-
- if (pthread_mutex_init (&ptimer.lock, NULL))
- {
- NSPOL_LOGERR ("pthread_mutex_init failed");
- return ERR_MEM;
- }
- /*codex fix */
- if (ERR_MEM == sys_sem_new (&ptimer_lock, 1))
- {
- NSPOL_LOGERR ("init_ptimer: sys_sem_new failure");
- return ERR_MEM;
- }
-
- ptimer.active.rb_node = NULL;
- ptimer.first = NULL;
-
- ptr =
- (struct ptimer_msg *) malloc (PTIMER_MSG_BUFFER_SIZE *
- sizeof (struct ptimer_msg));
- if (!ptr)
- {
- NSPOL_LOGERR ("init_ptimer: malloc ptimer buffer failed!");
- return ERR_MEM;
- }
-
- int ret =
- MEMSET_S (ptr, (PTIMER_MSG_BUFFER_SIZE * sizeof (struct ptimer_msg)),
- 0, (PTIMER_MSG_BUFFER_SIZE * sizeof (struct ptimer_msg)));
- if (EOK != ret)
- {
- free (ptr);
- NSPOL_LOGERR ("init_ptimer: MEMSET_S ptimer buffer failed]ret=%d", ret);
- return ERR_MEM;
- }
-
- for (i = 0; i < PTIMER_MSG_BUFFER_SIZE - 1; i++)
- {
- ptr[i].next = &ptr[(i + 1)];
- ptr[(i + 1)].prev = &ptr[i];
- }
-
- ptr[i].next = &ptr[0];
- ptr[0].prev = &ptr[i];
- ptimer.head = ptimer.tail = &ptr[0];
- retval =
- MEMSET_S (&timer_event, sizeof (struct sigevent), 0,
- sizeof (struct sigevent));
- if (EOK != retval)
- {
- free (ptr);
- ptr = NULL;
- NSPOL_LOGERR ("MEMSET_S failed]ret=%d", retval);
- return ERR_VAL;
- }
- timer_event.sigev_notify = SIGEV_SIGNAL;
- timer_event.sigev_signo = SIGRTMIN;
- timer_event.sigev_value.sival_ptr = (void *) &lazy_tim;
- timer_event1 = timer_event;
- timer_event1.sigev_value.sival_ptr = (void *) &lazy_tim_retry;
-
- if (timer_create (CLOCK_MONOTONIC, &timer_event, &lazy_tim) < 0)
- {
- free (ptr);
- ptr = NULL;
- NSPOL_LOGERR ("ptimer_init: timer_create failed!");
- return ERR_VAL;
- }
-
- if (timer_create (CLOCK_MONOTONIC, &timer_event1, &lazy_tim_retry) < 0)
- {
- free (ptr);
- ptr = NULL;
- NSPOL_LOGERR ("ptimer_init: timer_create failed!");
- return ERR_VAL;
- }
-
- return ERR_OK;
-}
-
-NSTACK_STATIC err_t
-process_timeout_msg (struct ptimer_msg * msg)
-{
- struct ptimer_node *tmo = msg->node;
- struct timespec now;
-
- switch (msg->msg_type)
- {
- case SYS_PTIMEROUT_MSG:
- if (tmo)
- {
- int retval = clock_gettime (CLOCK_MONOTONIC, &now);
- if (0 != retval)
- {
- NSPOL_LOGERR ("clock_gettime failed]retval=%d,errno=%d", retval,
- errno);
- }
- tmo->abs_nsec = now.tv_sec * NANO_PER_SECOND + now.tv_nsec
- + tmo->info.msec * NANO_PER_MICROSECOND;
- add_ptimer (tmo);
- }
- else
- {
- NSPOL_LOGERR ("process_timeout_msg: rb_node is NULL!");
- return ERR_MEM;
- }
-
- break;
- case SYS_UNPTIMEROUT_MSG:
- if (del_ptimer (msg) != ERR_OK)
- {
- NSPOL_LOGERR
- ("process_timeout_msg: can not find the timeout event(oops)!");
- }
-
- break;
- default:
- NSPOL_LOGERR
- ("process_timeout_msg: oops! lwip timeout_thread receive unacquainted message!");
- break;
- }
-
- return ERR_OK;
-}
-
-void
-ptimer_thread (void *arg)
-{
- LWIP_UNUSED_ARG (arg);
- int sig, ret = -1;
- sigset_t waitset;
- sigset_t oset;
- struct ptimer_msg *msg;
-
- if (0 != sigemptyset (&waitset))
- {
- NSTCP_LOGERR ("sigemptyset function call error");
- return;
- }
-
- if (0 != sigaddset (&waitset, SIGRTMIN))
- {
- NSTCP_LOGERR ("sigaddset function call error");
- return;
- }
-
- if (0 != sigaddset (&waitset, SIGRTMIN + 2))
- {
- NSTCP_LOGERR ("sigaddset function call error");
- return;
- }
-
- (void) pthread_sigmask (SIG_BLOCK, &waitset, &oset);
-
- (void) pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL);
- (void) pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
- NSPOL_LOGDBG (TIMERS_DEBUG, "ptimer: init done !");
-
- if (!g_nstack_timer_tick.tick_ptr)
- {
- NSTCP_LOGERR ("g_nstack_timer_tick not inited");
- return;
- }
- (void) gettimeofday (&g_nstack_timer_tick.ref_time, NULL);
- g_nstack_timer_tick.interval = 100;
- *g_nstack_timer_tick.tick_ptr = 0;
- g_nstack_timer_tick.ref_tick = 0;
- while (1)
- {
- ret = sigwait (&waitset, &sig);
- (void) nsfw_thread_chk (); // will only return TRUE, no need to check return value
- if (ret != -1)
- {
- /* for timer expirt handle */
- if (SIGRTMIN == sig)
- {
- timeout_sigaction (sig);
- continue;
- }
- }
- else
- {
- continue;
- }
-
- while (1)
- {
- (void) pthread_mutex_lock (&ptimer.lock);
- if (ptimer.head == ptimer.tail)
- {
- (void) pthread_mutex_unlock (&ptimer.lock);
- break;
- }
-
- msg = ptimer.head;
- ptimer.head = ptimer.head->next;
- (void) pthread_mutex_unlock (&ptimer.lock);
-
- sys_arch_sem_wait (&ptimer_lock, 0);
-
- if (process_timeout_msg (msg) != ERR_OK)
- {
- NSPOL_LOGERR ("oops: ptimer_thread panic!");
- }
-
- sys_sem_signal (&ptimer_lock);
- }
- }
-}
-
-void
-timeout_phandler (void *act, void *arg)
-{
- struct ptimer_node *tmo = arg;
- if (act == NULL)
- {
- NSPOL_LOGERR ("input parameter arg is null");
- return;
- }
-
- NSPOL_LOGINF (TIMERS_DEBUG, "Timer expire @timeout_phandler Handle %p",
- tmo->info._phandle);
- if (tmo->info.flags & PTIMER_ONESHOT)
- {
- sys_timeout_handler handle = act;
- handle (tmo->info.ctx);
- return;
- }
- else
- {
- NSPOL_LOGINF (TIMERS_DEBUG,
- "Timer expire error @timeout_phandler Handle %p",
- tmo->info._phandle);
- }
-}
diff --git a/stacks/lwip_stack/lwip_src/core/unmatch_version.c b/stacks/lwip_stack/lwip_src/core/unmatch_version.c
deleted file mode 100644
index 6c8cad3..0000000
--- a/stacks/lwip_stack/lwip_src/core/unmatch_version.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "nsfw_mem_api.h"
-#include "nstack_share_res.h"
-#include "nstack_securec.h"
-
-char *g_nstack_ver_info = NULL;
-
-int
-init_unmatch_version (void)
-{
- int ret;
- nsfw_mem_zone mzone;
-
- ret =
- STRCPY_S (mzone.stname.aname, NSFW_MEM_NAME_LENGTH, NSTACK_VERSION_SHM);
- if (EOK != ret)
- {
- NSPOL_LOGERR ("STRCPY_S fail]ret=%d", ret);
- return -1;
- }
- mzone.stname.entype = NSFW_SHMEM;
- mzone.isocket_id = -1;
- mzone.length =
- NSTACK_VERSION_LEN + MAX_UNMATCH_VER_CNT * sizeof (unmatch_ver_info_t);
- mzone.ireserv = 0;
-
- char *version = (char *) nsfw_mem_zone_create (&mzone);
- if (NULL == version)
- {
- NSPOL_LOGERR ("Failed to create unmatch_version memory");
- return -1;
- }
-
- ret = STRCPY_S (version, NSTACK_VERSION_LEN, NSTACK_VERSION);
- if (EOK != ret)
- {
- NSPOL_LOGERR ("STRCPY_S NSTACK_VERSION fail]ret=%d", ret);
- return -1;
- }
-
- g_nstack_ver_info = version;
-
- return 0;
-}
diff --git a/stacks/lwip_stack/lwip_src/include/ip_module/config_common.h b/stacks/lwip_stack/lwip_src/include/ip_module/config_common.h
deleted file mode 100644
index 0c88139..0000000
--- a/stacks/lwip_stack/lwip_src/include/ip_module/config_common.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _NSTACK_CONFIG_COMMON_H_
-#define _NSTACK_CONFIG_COMMON_H_
-
-#include "ip_module_api.h"
-
-#define MAX_IP_MODULE_BUFF_SIZE 1024*1024
-
-/* ip module config types */
-#define IP_MODULE_TYPE_IP "ip"
-#define IP_MODULE_TYPE_NETWORK "network"
-#define IP_MODULE_TYPE_PORT "port"
-#define IP_MODULE_TYPE_SETLOG "setlog"
-#define IP_MODULE_TYPE_SNAPSHOT "snapshot"
-#define IP_MODULE_TYPE_SETTRACE "settrace"
-
-#define TCP_MODULE_TYPE_SET_OOS_LEN "ooslen"
-
-#define IP_MODULE_NAME "./nStackCtrl: "
-#define IP_MODULE_INVALID_ARGUMENT_S "invalid argument -- \"%s\"\n"
-#define IP_MODULE_MORE_OPTION "need more options -- "
-#define IP_MODULE_LESS_OPTION "no need option -- "
-
-/* Error codes */
-#define IP_MODULE_OK 0
-#define IP_MODULE_DATA_ERROR 1
-#define IP_MODULE_DATA_NOT_EXIST 2
-
-struct config_param
-{
- int action;
- char type[IP_MODULE_LENGTH_256];
- char name[IP_MODULE_LENGTH_256];
- char value[IP_MODULE_LENGTH_64];
- char container_id[IP_MODULE_LENGTH_256];
- int error;
-
- char error_desc[NSCRTL_ERRBUF_LEN];
-
- u64 traceid;
-};
-
-struct config_data
-{
- struct config_param param;
- char json_buff[MAX_IP_MODULE_BUFF_SIZE - sizeof (struct config_param)];
-};
-
-#endif
diff --git a/stacks/lwip_stack/lwip_src/include/ip_module/configuration_reader.h b/stacks/lwip_stack/lwip_src/include/ip_module/configuration_reader.h
deleted file mode 100644
index 779ace8..0000000
--- a/stacks/lwip_stack/lwip_src/include/ip_module/configuration_reader.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _CONFIGURATION_READER_H
-#define _CONFIGURATION_READER_H
-#include <semaphore.h>
-#include "config_common.h"
-
-struct config_data *get_config_data ();
-int get_str_value (const char *arg);
-int setlog_level_value (const char *param, const char *value);
-
-#endif
diff --git a/stacks/lwip_stack/lwip_src/include/ip_module/container_ip.h b/stacks/lwip_stack/lwip_src/include/ip_module/container_ip.h
deleted file mode 100644
index e83c607..0000000
--- a/stacks/lwip_stack/lwip_src/include/ip_module/container_ip.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _CONTAINER_IP_H
-#define _CONTAINER_IP_H
-#include "ip_module_api.h"
-#include "json.h"
-
-struct ip_action_param
-{
- char container_id[IP_MODULE_LENGTH_256];
- char port_name[IP_MODULE_LENGTH_256];
-};
-
-void free_container (struct container_ip *container, bool_t only_free);
-struct container_port *parse_port_obj (struct json_object *port_obj);
-struct container_ip *parse_container_ip_json (char *param);
-int add_container (struct container_ip *container);
-struct container_ip *get_container_by_container_id (char *container_id);
-
-int del_port (char *container_id, char *port_name);
-struct container_port *get_port (char *container_id, char *port_name);
-struct container_port *get_port_from_container (struct container_port *port);
-int getIpCfgAll (char *jsonBuf, size_t size);
-
-#endif
diff --git a/stacks/lwip_stack/lwip_src/include/ip_module/ip_module_api.h b/stacks/lwip_stack/lwip_src/include/ip_module/ip_module_api.h
deleted file mode 100644
index acf5057..0000000
--- a/stacks/lwip_stack/lwip_src/include/ip_module/ip_module_api.h
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _IP_MODULE_API_H_
-#define _IP_MODULE_API_H_
-#include "types.h"
-
-typedef int bool_t;
-#define IP_MODULE_TRUE 1
-#define IP_MODULE_FALSE 0
-#define IP_MODULE_LENGTH_32 32
-#define IP_MODULE_LENGTH_64 64
-#define IP_MODULE_LENGTH_256 256
-#define IP_MODULE_LENGTH_1024 1024
-#define IP_MODULE_SUBNET_MASK_LEN IP_MODULE_LENGTH_32
-#define IP_MODULE_MAX_NAME_LEN IP_MODULE_LENGTH_256
-#define IP_MODULE_PORT_JSON_LEN (2048 * 2)
-#define IP_MODULE_NETWORK_JSON_LEN (2048 * 2)
-#define MAX_NETWORK_COUNT IP_MODULE_LENGTH_64
-#define MAX_NETWORK_IP_COUNT IP_MODULE_LENGTH_1024
-#define MAX_NETWORK_NUM (MAX_NETWORK_COUNT * 2)
-COMPAT_PROTECT (MAX_NETWORK_NUM, 128);
-#define MAX_PORT_NUM (MAX_NETWORK_IP_COUNT * 2)
-COMPAT_PROTECT (MAX_PORT_NUM, 2048);
-#define NSCRTL_ERRBUF_LEN IP_MODULE_LENGTH_256
-
-#define INVALID_EXPIRE_TIME 0x7FFFFFFF
-#define NSTACLCTRL_MAX_TRY_TIMES 60
-
-/*sockaddr_un.sun_path is an array of 108 bytes*/
-#define IP_MODULE_MAX_PATH_LEN 108
-
-typedef enum enumADERRCODE
-{
- NSCRTL_OK = 0,
- NSCRTL_ERR,
- NSCRTL_RD_NOT_EXIST,
- NSCRTL_RD_EXIST = 3,
- NSCRTL_INPUT_ERR,
- NSCRTL_STATUS_ERR,
- NSCRTL_NETWORK_COUNT_EXCEED,
- NSCRTL_IP_COUNT_EXCEED,
- NSCRTL_FREE_ALL_PORT, //when all ports in container were deleted, need to free container.
-
- NSCRTL_MAX_ERR = 127
-} NSCRTL_ERR_CODE;
-
-#define NSOPR_SET_ERRINFO(_errno, fmt, ...) \
- {\
- struct config_data* cf_data = get_config_data(); \
- if (cf_data)\
- {\
- size_t len_error_desc = strlen(cf_data->param.error_desc); \
- cf_data->param.error = _errno; \
- if ((_errno != NSCRTL_OK) && (len_error_desc < NSCRTL_ERRBUF_LEN))\
- {\
- if (-1 == (SNPRINTF_S(cf_data->param.error_desc + len_error_desc, \
- NSCRTL_ERRBUF_LEN - len_error_desc, NSCRTL_ERRBUF_LEN - len_error_desc - 1, fmt, ## __VA_ARGS__)))\
- {\
- NSOPR_LOGERR("SNPRINTF_S failed]"); \
- } \
- } \
- } \
- } \
-
-struct ref_nic
-{
- struct ref_nic *next;
- char nic_name[IP_MODULE_MAX_NAME_LEN];
-};
-
-struct phy_net
-{
- struct ref_nic *header;
- char bond_name[IP_MODULE_MAX_NAME_LEN];
- int bond_mode;
-};
-
-struct container_port_ip_cidr
-{
- struct container_port_ip_cidr *next;
- unsigned int ip;
- unsigned int mask_len;
-};
-
-struct container_multicast_id
-{
- struct container_multicast_id *next;
- unsigned int ip;
-};
-
-typedef struct
-{
- char port_json[IP_MODULE_PORT_JSON_LEN];
-} port_buffer;
-
-struct container_port
-{
- struct container_port *next;
- struct container_port_ip_cidr *ip_cidr_list;
- struct container_multicast_id *multicast_list;
- char port_name[IP_MODULE_MAX_NAME_LEN];
- port_buffer *buffer;
-};
-
-#define get_port_json(obj) obj->buffer->port_json
-
-struct container_ip
-{
- struct container_ip *next;
- struct container_port *ports_list;
- char container_id[IP_MODULE_MAX_NAME_LEN];
-};
-
-struct container_list
-{
- struct container_ip *header;
-};
-
-struct ip_subnet
-{
- struct ip_subnet *next;
- unsigned int subnet;
- unsigned int mask_len;
-};
-
-typedef struct
-{
- char network_json[IP_MODULE_NETWORK_JSON_LEN];
-} network_buffer;
-
-struct network_configuration
-{
- struct network_configuration *next;
- struct phy_net *phy_net;
- struct ip_subnet *ip_subnet;
- char network_name[IP_MODULE_MAX_NAME_LEN];
- char type_name[IP_MODULE_MAX_NAME_LEN];
- char nic_type_name[IP_MODULE_MAX_NAME_LEN];
- network_buffer *buffer;
-};
-
-#define get_network_json(obj) obj->buffer->network_json
-
-struct network_list
-{
- struct network_configuration *header;
-};
-
-void ip_subnet_print (struct ip_subnet *subnet);
-bool_t is_in_same_network (unsigned int src_ip, unsigned int dst_ip);
-bool_t is_ip_match_netif (unsigned int ip, char *netif_name);
-bool_t is_ip_exist (unsigned int ip);
-struct network_configuration *get_network_list ();
-inline struct network_configuration *get_network_by_ip_with_tree (unsigned int
- ip);
-
-/* "type" option */
-typedef enum
-{
- IP_MODULE_NETWORK,
- IP_MODULE_IP,
- IP_MODULE_NETWORK_ALL,
- IP_MODULE_IP_ALL,
- IP_MODULE_ALL,
-} ip_module_type;
-
-/* "action" option */
-typedef enum
-{
- IP_MODULE_OPERATE_NULL,
- IP_MODULE_OPERATE_ADD,
- IP_MODULE_OPERATE_DEL,
- IP_MODULE_OPERATE_QUERY,
- IP_MODULE_OPERATE_SET,
- IP_MODULE_GET_VERSION,
- IP_MODULE_QUERY_NET,
- IP_MODULE_MAX, //new type should be added before IP_MODULE_MAX
- IP_MODULE_BOTTOM = 0xFFFFFFFF
-} ip_module_operate_type;
-
-typedef int (*post_to_fn) (void *arg, ip_module_type type,
- ip_module_operate_type operate_type);
-typedef int (*add_netif_ip_fn) (char *netif_name, unsigned int ip,
- unsigned int mask);
-typedef int (*del_netif_ip_fn) (char *netif_name, unsigned int ip);
-
-typedef struct
-{
- post_to_fn post_to;
- add_netif_ip_fn add_netif_ip;
- del_netif_ip_fn del_netif_ip;
-} output_api;
-
-void regist_output_api (output_api * api);
-output_api *get_output_api ();
-int init_configuration_reader ();
-int process_post (void *arg, ip_module_type type,
- ip_module_operate_type operate_type);
-int process_configuration (void *arg, ip_module_type type,
- ip_module_operate_type operate_type);
-
-port_buffer *malloc_port_buffer ();
-void free_port_buffer (port_buffer * buffer);
-network_buffer *malloc_network_buffer ();
-void free_network_buffer (network_buffer * buffer);
-int get_network_json_data ();
-int get_ip_json_data ();
-
-#endif
diff --git a/stacks/lwip_stack/lwip_src/include/ip_module/network.h b/stacks/lwip_stack/lwip_src/include/ip_module/network.h
deleted file mode 100644
index 117b71c..0000000
--- a/stacks/lwip_stack/lwip_src/include/ip_module/network.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _NETWORK_H
-#define _NETWORK_H
-#include "ip_module_api.h"
-
-void free_network_configuration (struct network_configuration *network,
- bool_t only_free);
-struct network_configuration *parse_network_obj (struct json_object
- *network_obj);
-struct network_configuration *parse_network_json (char *param,
- struct network_configuration
- *network_list);
-int add_network_configuration (struct network_configuration
- *network_configuration);
-struct network_configuration *get_network_by_name (char *name);
-struct network_configuration *get_network_by_nic_name (char *name);
-int del_network_by_name (char *name);
-int get_network_all (char *jsonBuf, size_t size);
-int nic_already_init (const char *nic_name);
-
-#endif
diff --git a/stacks/lwip_stack/lwip_src/include/ip_module/trp_rb_tree.h b/stacks/lwip_stack/lwip_src/include/ip_module/trp_rb_tree.h
deleted file mode 100644
index ef0ac37..0000000
--- a/stacks/lwip_stack/lwip_src/include/ip_module/trp_rb_tree.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef __TRP_RB_TREE_H__
-#define __TRP_RB_TREE_H__
-
-typedef void *trp_key_t;
-typedef void *trp_data_t;
-
-#define RB_RED 0
-#define RB_BLACK 1
-
-typedef int (*key_compare) (trp_key_t left, trp_key_t right); // return > 0 left > right, return 0 left = right, return < 0 left < right
-
-typedef struct trp_rb_node
-{
- struct trp_rb_node *rb_parent;
- struct trp_rb_node *rb_right;
- struct trp_rb_node *rb_left;
- key_compare key_compare_fn;
- trp_key_t key;
- trp_data_t data;
- unsigned int color;
-} trp_rb_node_t;
-
-typedef struct trp_rb_root
-{
- struct trp_rb_node *rb_node;
-} trp_rb_root_t;
-
-int trp_rb_insert (trp_key_t, trp_data_t, trp_rb_root_t *, key_compare);
-int trp_rb_insert_allow_same_key (trp_key_t, trp_data_t, trp_rb_root_t *,
- key_compare);
-void trp_rb_erase (trp_key_t, trp_rb_root_t *, key_compare key_compare_fn);
-void trp_rb_erase_with_data (trp_key_t key, trp_data_t data,
- trp_rb_root_t * root, int count,
- key_compare key_compare_fn);
-
-static inline trp_rb_node_t *
-trp_rb_search (trp_key_t key, trp_rb_root_t * root,
- key_compare key_compare_fn)
-{
- trp_rb_node_t *node = root->rb_node;
- int ret;
- while (node)
- {
- ret = key_compare_fn (node->key, key);
- if (0 < ret)
- {
- node = node->rb_left;
- }
- else if (0 > ret)
- {
- node = node->rb_right;
- }
- else
- {
- return node;
- }
- }
-
- return NULL;
-}
-#endif
diff --git a/stacks/lwip_stack/lwip_src/include/ipv4/stackx/spl_ip_addr.h b/stacks/lwip_stack/lwip_src/include/ipv4/stackx/spl_ip_addr.h
deleted file mode 100644
index ae5c31f..0000000
--- a/stacks/lwip_stack/lwip_src/include/ipv4/stackx/spl_ip_addr.h
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef __LWIP_IP_ADDR_H__
-#define __LWIP_IP_ADDR_H__
-
-#include "spl_opt.h"
-#include "spl_def.h"
-#include "ip_module_api.h"
-#include "stackx_ip_addr.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-/** ip_addr_t uses a struct for convenience only, so that the same defines can
- * operate both on ip_addr_t as well as on ip_addr_p_t. */
-/* Forward declaration to not include netif.h */
-struct netif;
-#if BYTE_ORDER == BIG_ENDIAN
-
-/** Set an IPaddress given by the four byte-parts */
-#define SPL_IP4_ADDR(ipaddr, a, b, c, d) \
- (ipaddr)->addr = ((u32_t)((a) & 0xff) << 24) | \
- ((u32_t)((b) & 0xff) << 16) | \
- ((u32_t)((c) & 0xff) << 8) | \
- (u32_t)((d) & 0xff)
-#else
-
-/** Set an IPaddress given by the four byte-parts.
- Little-endian version that prevents the use of htonl. */
-#define SPL_IP4_ADDR(ipaddr, a, b, c, d) \
- (ipaddr)->addr = ((u32_t)((d) & 0xff) << 24) | \
- ((u32_t)((c) & 0xff) << 16) | \
- ((u32_t)((b) & 0xff) << 8) | \
- (u32_t)((a) & 0xff)
-#endif
-
-/** memcpy-like copying of IPaddresses where addresses are known to be
- * 16-bit-aligned if the port is correctly configured (so a port could define
- * this to copying 2 u16_t's) - no NULL-pointer-checking needed. */
-#ifndef IPADDR2_COPY
-#define IPADDR2_COPY(dest, src) MEMCPY_S(dest, sizeof(ip_addr_t), src, sizeof(ip_addr_t))
-#endif
-
-/** Copy IPaddress - faster than spl_ip_addr_set: no NULL check */
-#define spl_ip_addr_copy(dest, src) ((dest).addr = (src).addr)
-
-/** Safely copy one IPaddress to another (src may be NULL) */
-#define spl_ip_addr_set(dest, src) ((dest)->addr = \
- ((src) == NULL ? 0 : \
- (src)->addr))
-
-/** Safely copy one IPaddress to another and change byte order
- * from host- to network-order. */
-#define spl_ip_addr_set_hton(dest, src) ((dest)->addr = \
- ((src) == NULL ? 0 : \
- htonl((src)->addr)))
-
-/** Get the network address by combining host address with netmask */
-#define spl_ip_addr_get_network(target, host, netmask) ((target)->addr = ((host)->addr) & ((netmask)->addr))
-
-/**
- * Determine if two address are on the same network.
- *
- * @arg addr1 IPaddress 1
- * @arg addr2 IPaddress 2
- * @arg mask network identifier mask
- * @return !0 if the network identifiers of both address match
- */
-#define spl_ip_addr_netcmp(addr1, addr2, mask) (((addr1)->addr & \
- (mask)->addr) == \
- ((addr2)->addr & \
- (mask)->addr))
-
-/* && ((dest)->addr & tmp->netmask.addr) == (tmp->ip_addr.addr & tmp->netmask.addr) */
-/* add "netif = netif->root; \"*/
-#define ip_net_netif_cmp( dest, netif) ({ \
- netif = netif->root; \
- struct netif* tmp = netif; \
- int find = 0; \
- while(tmp) \
- { \
- if (is_in_same_network((dest)->addr, tmp->ip_addr.addr)) \
- { \
- netif->ip_addr.addr = tmp->ip_addr.addr; \
- netif->netmask.addr = tmp->netmask.addr; \
- find = 1; \
- break; \
- } \
- if (netif->is_out) \
- { \
- break; \
- } \
- tmp = tmp->vnext; \
- } \
- (!!find); \
- })
-
-/* Check if netif match dest , if not , find one and swap */
-/* add "netif = netif->root; \"*/
-
-#define ip_addr_netif_cmp_and_swap( dest, pnetif) ({ \
- pnetif = pnetif->root; \
- struct netif* tmp = pnetif; \
- int find = 0; \
- while(tmp) \
- { \
- if ((dest)->addr == tmp->ip_addr.addr) \
- { \
- pnetif->ip_addr.addr = tmp->ip_addr.addr; \
- pnetif->netmask.addr = tmp->netmask.addr; \
- find = 1; \
- break; \
- } \
- if (pnetif->is_out) \
- { \
- break; \
- } \
- tmp = tmp->vnext; \
- } \
- (!!find); \
- })
-
-#define ip_addr_netif_cmp( dest, pnetif) ({ \
- pnetif = pnetif->root; \
- struct netif* tmp = pnetif; \
- int find = 0; \
- while(tmp) \
- { \
- if ((dest)->addr == tmp->ip_addr.addr) \
- { \
- find = 1; \
- break; \
- } \
- tmp = tmp->vnext; \
- } \
- (!!find); \
- })
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif /* __LWIP_IP_ADDR_H__ */
diff --git a/stacks/lwip_stack/lwip_src/include/netif/common.h b/stacks/lwip_stack/lwip_src/include/netif/common.h
deleted file mode 100644
index 45e9c8f..0000000
--- a/stacks/lwip_stack/lwip_src/include/netif/common.h
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _COMMON_H_
-#define _COMMON_H_
-#include <stddef.h> /* for size_t */
-#include "stackx_common.h"
-#include "netif.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-//yyq
-
-/* define common names for structures shared between server and client */
-
-#define MP_STACKX_INSTANCE_POLL_NAME "VppTCP_instance_poll"
-#define MP_STACKX_PORT_ZONE "VppTCP_stackx_port_zone"
-#define MP_STACKX_PORT_INFO "VppTCP_stackx_port_info"
-#define MP_MEMPOLL_RX_NAME "VppTCP_MBUF_%u_%u_RX"
-#define MP_MEMPOLL_RXMSG_NAME "VppTCP_MSG_%u_%u_RX"
-#define MP_MEMPOLL_TX_NAME "VppTCP_MBUF_TX"
-#define MP_MEMPOLL_SEG_NAME "VppTCP_MBUF_SEG"
-#define MP_STACKX_MSG_NAME "VppTCP_msg"
-#define MP_STACKX_RING_NAME "VppTCP_%u_ring"
-#define MP_STACKX_LRING_NAME "VppTCP_%u_lring"
-
-#define MP_STACKX_BIT_SET_NAME "%s_bit_set"
-
-#define MP_STACKX_SOCKET_FREE_LIST_NAME "VppTCP_socket_list"
-
-#define MP_NETIF_LIST_NAME "VppTCP_Netif_list"
-
-/*
- move sharemem create from App to nstackMain
-advice rename app_tx_mbuf to VppTCP_APP_TXBUF_POOL
-*/
-#define MP_STACKX_APP_TXBUF_POOL "app_tx_mbuf"
-
-#define MP_MEMPOLL_TCP_BUFF_NAME "VppTCP_MBUF_%u_TCP_BUFF"
-
-extern int spl_snprintf (char *buffer, int buflen, const char *format, ...);
-
-/*According to the number of network cards, the establishment of recv lring,
- *each separate, each proc_id each NIC queue independent lring
- */
-static inline const char *
-get_mempoll_rx_name (unsigned proc_id, unsigned nic_id)
-{
- /* buffer for return value. Size calculated by %u being replaced
- * by maximum 3 digits (plus an extra byte for safety)
- * the id may reach 65535, need add more space*/
- static char buffer[sizeof (MP_MEMPOLL_RX_NAME) + 32];
-
- int retVal = spl_snprintf (buffer, sizeof (buffer) - 1, MP_MEMPOLL_RX_NAME, proc_id, nic_id); //???????????buffer??
- if (-1 == retVal)
- {
- NSPOL_LOGERR ("spl_snprintf failed]");
- return NULL;
- }
-
- return buffer;
-}
-
-static inline const char *
-get_mempoll_rxmsg_name (unsigned proc_id, unsigned nic_id)
-{
- /* buffer for return value. Size calculated by %u being replaced
- * by maximum 3 digits (plus an extra byte for safety)
- * the id may reach 65535, need add more space*/
- static char buffer[sizeof (MP_MEMPOLL_RXMSG_NAME) + 32];
-
- int retVal = spl_snprintf (buffer, sizeof (buffer) - 1, MP_MEMPOLL_RXMSG_NAME, proc_id, nic_id); //???????????buffer??
- if (-1 == retVal)
- {
- NSPOL_LOGERR ("spl_snprintf failed]");
- return NULL;
- }
-
- return buffer;
-}
-
-static inline const char *
-get_mempoll_ring_name (unsigned proc_id)
-{
- static char buffer[sizeof (MP_STACKX_RING_NAME) + 16];
-
- int retVal =
- spl_snprintf (buffer, sizeof (buffer) - 1, MP_STACKX_RING_NAME, proc_id);
- if (-1 == retVal)
- {
- NSPOL_LOGERR ("spl_snprintf failed]");
- return NULL;
- }
-
- return buffer;
-}
-
-static inline const char *
-get_mempoll_lring_name (unsigned proc_id)
-{
- static char buffer[sizeof (MP_STACKX_LRING_NAME) + 16];
-
- int retVal =
- spl_snprintf (buffer, sizeof (buffer) - 1, MP_STACKX_LRING_NAME, proc_id);
- if (-1 == retVal)
- {
- NSPOL_LOGERR ("spl_snprintf failed]");
- return NULL;
- }
-
- return buffer;
-}
-
-static inline const char *
-get_mempoll_msg_name ()
-{
- static char buffer[sizeof (MP_STACKX_MSG_NAME) + 16];
-
- int retVal = spl_snprintf (buffer, sizeof (buffer) - 1, MP_STACKX_MSG_NAME);
- if (-1 == retVal)
- {
- NSPOL_LOGERR ("spl_snprintf failed]");
- return NULL;
- }
-
- return buffer;
-}
-
-static inline const char *
-get_mempoll_tx_name ()
-{
- /* buffer for return value. Size calculated by %u being replaced
- * by maximum 3 digits (plus an extra byte for safety) */
- static char buffer[sizeof (MP_MEMPOLL_TX_NAME) + 16];
-
- int retVal = spl_snprintf (buffer, sizeof (buffer) - 1, MP_MEMPOLL_TX_NAME); //???????????buffer??
- if (-1 == retVal)
- {
- NSPOL_LOGERR ("spl_snprintf failed]");
- return NULL;
- }
-
- return buffer;
-}
-
-static inline const char *
-get_mempoll_seg_name ()
-{
- /* buffer for return value. Size calculated by %u being replaced
- * by maximum 3 digits (plus an extra byte for safety) */
- static char buffer[sizeof (MP_MEMPOLL_SEG_NAME) + 16];
-
- int retVal = spl_snprintf (buffer, sizeof (buffer) - 1, MP_MEMPOLL_SEG_NAME); //???????????buffer??
- if (-1 == retVal)
- {
- NSPOL_LOGERR ("spl_snprintf failed]");
- return NULL;
- }
-
- return buffer;
-}
-
-static inline const char *
-get_memStatusBitSet_name (const char *name, unsigned int num)
-{
- static char buffer[64];
-
- int retVal =
- spl_snprintf (buffer, sizeof (buffer) - 1, MP_STACKX_BIT_SET_NAME "%d",
- name, num);
- if (-1 == retVal)
- {
- NSPOL_LOGERR ("spl_snprintf failed]");
- return NULL;
- }
-
- return buffer;
-}
-
-static inline const char *
-get_memNameWithProc (const char *name)
-{
- static char buffer[64];
-
- int retVal = spl_snprintf (buffer, sizeof (buffer) - 1, "%s", name);
- if (-1 == retVal)
- {
- NSPOL_LOGERR ("spl_snprintf failed]");
- return NULL;
- }
-
- return buffer;
-}
-
-static inline const char *
-get_memInstancePoll_name (unsigned int type)
-{
- static char buffer[sizeof (MP_STACKX_INSTANCE_POLL_NAME) + 32];
- int retVal = spl_snprintf (buffer, sizeof (buffer) - 1, "%s" "%d",
- MP_STACKX_INSTANCE_POLL_NAME, type);
- if (-1 == retVal)
- {
- NSPOL_LOGERR ("spl_snprintf failed]");
- return NULL;
- }
-
- return buffer;
-}
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif
diff --git a/stacks/lwip_stack/lwip_src/include/netif/kni_proc.h b/stacks/lwip_stack/lwip_src/include/netif/kni_proc.h
deleted file mode 100644
index bcf4129..0000000
--- a/stacks/lwip_stack/lwip_src/include/netif/kni_proc.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _KNI_PROC_H_
-#define _KNI_PROC_H_
-#include <rte_kni.h>
-#include <rte_mempool.h>
-#include <rte_mbuf.h>
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-#define KNI_MAX_KTHREAD 32
-
-/* the kni is runned on the lcore from below on */
-#define DEFAULT_KNI_LCORE_BASE 24
-
-/* Structure of kni para */
-struct disp_kni_para
-{
- u8_t queue_id;
- u8_t port_id;
-};
-
-/*
- * Structure of port parameters
- */
-struct kni_port_params
-{
- uint8_t port_id; /* Port ID */
- unsigned lcore_rx; /* lcore ID for RX */
- unsigned lcore_tx; /* lcore ID for TX */
- uint32_t nb_lcore_k; /* Number of lcores for KNI multi kernel threads */
- uint32_t nb_kni; /* Number of KNI devices to be created */
- unsigned lcore_k[KNI_MAX_KTHREAD]; /* lcore ID list for kthreads */
- struct rte_kni *kni[KNI_MAX_KTHREAD]; /* KNI context pointers */
- struct rte_mempool *kni_pktmbuf_pool;
- u8_t ip_reconfigured;
-} __rte_cache_aligned;
-
-/* Structure type for storing kni interface specific stats */
-struct kni_interface_stats
-{
- /* number of pkts received from NIC, and sent to KNI */
- uint64_t rx_packets;
-
- /* number of pkts received from NIC, but failed to send to KNI */
- uint64_t rx_dropped;
-
- /* number of pkts received from KNI, and sent to NIC */
- uint64_t tx_packets;
-
- /* number of pkts received from KNI, but failed to send to NIC */
- uint64_t tx_dropped;
-};
-
-/* External interface for initilizing KNI subsystem */
-int kni_proc_init (enum rte_proc_type_t proc_type, int proc_id, u32_t pmask,
- struct kni_port_params **kni_para);
-
-int kni_proc_init_secondary (int proc_id, int port_id);
-/* External interface for destroy KNI subsystem */
-void kni_proc_free (void);
-
-/* External interface for kni tx thread entry */
-void kni_tx_thread_cycle (void *arg);
-
-int kni_config_net (void);
-void kni_handler_eth_operate_request (int port);
-
-/* External interface for commiting packet to kni device */
-void kni_dispatch_to_kernel (uint8_t port_id,
- struct rte_mbuf *pkts_burst[], uint8_t nb_rx);
-
-/* the lcore kni tx/rx thread run on */
-unsigned kni_get_tx_lcore (uint8_t port_id);
-unsigned kni_get_rx_lcore (uint8_t port_id);
-
-void init_kni (void);
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif /*#ifndef _KNI_PROC_H_ */
diff --git a/stacks/lwip_stack/lwip_src/include/netif/sc_dpdk.h b/stacks/lwip_stack/lwip_src/include/netif/sc_dpdk.h
deleted file mode 100644
index 99c3bc6..0000000
--- a/stacks/lwip_stack/lwip_src/include/netif/sc_dpdk.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef SC_DPDK_H_
-#define SC_DPDK_H_
-
-#include <pbuf.h>
-#include <sharedmemory.h>
-
-#include "lwip/etharp.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-#define NSTACK_CONFIG_SHM "nstack_config"
-
-#define MBUF_DATA_SIZE 2048
-#define MBUF_SIZE (MBUF_DATA_SIZE + sizeof(struct common_mem_mbuf) + COMMON_PKTMBUF_HEADROOM)
-
-extern int g_nstack_bind_cpu;
-
-inline uint16_t spl_mbuf_refcnt_update (void *mbuf, int16_t value);
-struct stack_proc_content *get_stack_proc_content ();
-
-inline int spl_msg_malloc (data_com_msg ** p_msg_entry);
-#define spl_msg_free(p_msg_entry) msg_free(p_msg_entry)
-struct spl_pbuf *spl_mbuf_malloc (uint16_t len, spl_pbuf_type type,
- u16_t * count);
-
-inline void spl_mbuf_free (void *mbuf);
-
-inline int spl_set_lcore_id (unsigned dest_lcore_id);
-
-static inline unsigned
-spl_get_lcore_id ()
-{
- unsigned core_id = 0;
-
-#if (DPDK_MODULE != 1)
-#ifdef HAL_LIB
-#else
- core_id = rte_lcore_id ();
-#endif
- if (core_id >= MAX_THREAD_NUM)
- {
- core_id = 0;
- }
-#endif
-
- return core_id;
-}
-
-int set_share_config ();
-
-int init_instance ();
-
-void printmeminfo ();
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-#endif /* SERVER_DPDK_H_ */
diff --git a/stacks/lwip_stack/lwip_src/include/netif/sharedmemory.h b/stacks/lwip_stack/lwip_src/include/netif/sharedmemory.h
deleted file mode 100644
index 6230ed8..0000000
--- a/stacks/lwip_stack/lwip_src/include/netif/sharedmemory.h
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef SHAREDMEMORY_H_
-#define SHAREDMEMORY_H_
-#include "stackxopts.h"
-#include <sys/types.h>
-#include <semaphore.h>
-//#include "stackx/raw.h"
-#include "tcp.h"
-#include "udp.h"
-//#include "stackx/ip.h"
-#include "spl_err.h"
-#include "list.h"
-#include "arch/queue.h"
-#include "spl_opt.h"
-#include "stackx/spl_ip_addr.h"
-
-#include "stackx/spl_api.h"
-#include <arch/sys_arch.h>
-#include "common_mem_api.h"
-//#include "stackx/memp.h"
-#include "stackx_instance.h"
-
-#include "hal_api.h"
-#ifdef HAL_LIB
-#else
-#include "rte_ring.h"
-#endif
-
-/** Description for a task waiting in select */
-struct stackx_select_cb
-{
- /** Pointer to the next waiting task */
- union
- {
- struct stackx_select_cb *next;
- PTR_ALIGN_TYPE next_a;
- };
-
- /** Pointer to the previous waiting task */
- union
- {
- struct stackx_select_cb *prev;
- PTR_ALIGN_TYPE prev_a;
- };
-
- /** semaphore to wake up a task waiting for select */
- //sys_sem_t sem;
- union
- {
- sys_sem_t_v1 sem;
- PTR_ALIGN_TYPE sem_a;
- };
-
- /** readset passed to select */
- fd_set readset;
-
- /** writeset passed to select */
- fd_set writeset;
-
- /** unimplemented: exceptset passed to select */
- fd_set exceptset;
-
- /** don't signal the same semaphore twice: set to 1 when signalled */
- volatile int sem_signalled;
-
- uint8_t pad_64bit[4];
-};
-/** From epoll.h: Definition of struct stackx_sock and stackx_select_cb ---------End*/
-
-enum tcp_run_type
-{
- TCP_MUTIPL_INSTANCE = 0,
- TCP_MASTER_WORKER,
- TCP_DISTRIBUTOR_WORKER,
- TCP_RUN_TO_COMPETE,
- TCP_PROC_TYPE_END
-};
-
-enum proc_run_type
-{
- PROC_MAIN_RUN_TYPE = 0,
- PROC_BACKUP_RUN_TYPE,
- PROC_RUN_TYPE_END
-};
-
-struct linux_port_info
-{
- char if_name[HAL_MAX_NIC_NAME_LEN];
- char if_type[HAL_MAX_NIC_NAME_LEN];
- char ip_addr_linux[18]; //uint32_t ip_addr_linux;
- char mask_linux[18]; //uint32_t mask_linux;
- char bcast_linux[18]; //uint32_t bcast_linux;
- char mac_addr[20]; //struct ether_addr mac_addr;
- hal_hdl_t hdl;
-};
-
-struct stackx_port_info
-{
- struct stackx_port_info *next_use_port;
- struct linux_port_info linux_ip;
-};
-
-struct stackx_port_zone
-{
- unsigned int port_num;
- unsigned int bonded_port_num;
- struct stackx_port_info *stackx_one_port;
-};
-
-struct select_cb_entry
-{
- struct stackx_select_cb select_cb;
-
- union
- {
- sem_t semForSelect;
- ALIGN_TYPE pad_64bit[4];
- };
-
- union
- {
- struct select_cb_entry *pre_empty_entry;
- PTR_ALIGN_TYPE pre_empty_entry_a;
- };
-
- union
- {
- struct select_cb_entry *next_empty_entry;
- PTR_ALIGN_TYPE next_empty_entry_a;
- };
-
-};
-
-#endif /* SHAREDMEMORY_H_ */
diff --git a/stacks/lwip_stack/lwip_src/include/netif/spl_hal.h b/stacks/lwip_stack/lwip_src/include/netif/spl_hal.h
deleted file mode 100644
index ca56663..0000000
--- a/stacks/lwip_stack/lwip_src/include/netif/spl_hal.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef SPL_HAL_H_
-#define SPL_HAL_H_
-
-#include "hal_api.h"
-#include "netif.h"
-#include "nsfw_maintain_api.h"
-#include "stackx_spl_share.h"
-#include "stackx_pbuf_comm.h"
-#include "netifapi.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-int spl_hal_init (int argc, char *argv[]);
-int spl_hal_port_init ();
-
-int spl_hal_stats_display (struct netif *pnetif, char *str, u32_t len,
- char *json, u32_t json_len);
-
-err_t spl_hal_output (struct netif *netif, struct pbuf *buf);
-void spl_hal_input (struct netif *netif, struct spl_pbuf **buf);
-
-inline u16_t spl_hal_recv (struct netif *netif, u8_t id);
-
-int spl_hal_tx_ip_cksum_enable ();
-int spl_hal_tx_udp_cksum_enable ();
-int spl_hal_tx_tcp_cksum_enable ();
-
-u32 spl_hal_is_nic_exist (const char *name);
-
-int spl_hal_is_bond_netif (struct netif *pnetif);
-
-static inline void
-spl_do_dump (struct spl_pbuf *p, u16 direction)
-{
- struct spl_pbuf *q = p;
- while (q)
- {
- ntcpdump (q->payload, q->len, direction);
- q = q->next;
- }
-}
-
-/* information of bond*/
-#define MAX_BOND_PORT_NUM 4
-
-/* information of one bond port */
-struct bond_set
-{
- char bond_port_name[HAL_MAX_NIC_NAME_LEN];
- char slave_ports[HAL_MAX_SLAVES_PER_BOND][HAL_MAX_NIC_NAME_LEN];
- u8_t slave_port_cnt;
-};
-
-#define NETIF_ETH_ADDR_LEN 6
-
-/* information of all bond ports */
-struct bond_ports_info
-{
- u8_t cnt;
- struct bond_set ports[MAX_BOND_PORT_NUM];
-};
-
-struct ether_addr
-{
- u8_t addr_bytes[NETIF_ETH_ADDR_LEN];
-
-};
-
-struct netif *get_netif_by_ip (unsigned int ip);
-struct netif *netif_check_broadcast_addr (spl_ip_addr_t * addr);
-struct netifExt *getNetifExt (u16_t id);
-int netifExt_add (struct netif *netif);
-
-int add_netif_ip (char *netif_name, unsigned int ip, unsigned int mask);
-int del_netif_ip (char *netif_name, unsigned int ip);
-
-err_t spl_netifapi_netif_add (struct netif *pnetif,
- spl_ip_addr_t * ipaddr,
- spl_ip_addr_t * netmask,
- spl_ip_addr_t * gw,
- void *state,
- netif_init_fn init,
- netif_input_fn input,
- netifapi_void_fn voidfunc);
-struct netif *find_netif_by_if_name (char *if_name);
-void ethernetif_packets_input (struct netif *pstnetif);
-err_t ethernetif_init (struct netif *pnetif);
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-#endif /* SPL_HAL_H_ */
diff --git a/stacks/lwip_stack/lwip_src/include/stackx/internal_msg.h b/stacks/lwip_stack/lwip_src/include/stackx/internal_msg.h
deleted file mode 100644
index 584ab06..0000000
--- a/stacks/lwip_stack/lwip_src/include/stackx/internal_msg.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef __internal_msg_h__
-#define __internal_msg_h__
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-#include "nsfw_msg.h"
-#include "netif.h"
-#include "lwip/netifapi.h"
-#include "ip_module_api.h"
-
-enum netif_msg_type
-{
- NETIF_DO_ADD,
- NETIF_MSG_API_MAX = MAX_MINOR_TYPE
-};
-
-/* NETIF_DO_ADD */
-typedef struct msg_add_netif_T
-{
- void (*function) (struct msg_add_netif_T * m);
- struct netif *netif;
- spl_ip_addr_t *ipaddr;
- spl_ip_addr_t *netmask;
- spl_ip_addr_t *gw;
- void *state;
- netif_init_fn init;
- netif_input_fn input;
- netifapi_void_fn voidfunc;
- /* no need to extend member */
-} msg_add_netif;
-
-typedef struct
-{
- ip_module_type type;
- ip_module_operate_type operate_type;
- void *arg;
-} msg_ip_module;
-
-typedef struct msg_internal_callback_T
-{
- void (*function) (void *ctx);
- void *ctx;
-} msg_internal_callback;
-
-enum timer_msg_type
-{
- TIMER_MSG_TIMEOUT,
- TIMER_MSG_CLEAR,
- TIMER_MSG_MAX = MAX_MINOR_TYPE
-};
-
-typedef struct msg_timer_T
-{
- void *act;
- void *arg;
-} msg_timer;
-
-enum mt_msg_type
-{
- MT_MSG_VER_MGR,
- MT_MSG_MAX = MAX_MINOR_TYPE
-};
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif /* __internal_msg_h__ */
diff --git a/stacks/lwip_stack/lwip_src/include/stackx/spl_api.h b/stacks/lwip_stack/lwip_src/include/stackx/spl_api.h
deleted file mode 100644
index ea63e90..0000000
--- a/stacks/lwip_stack/lwip_src/include/stackx/spl_api.h
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef __SPL_API_H__
-#define __SPL_API_H__
-
-#include "opt.h"
-#include "common_mem_base_type.h"
-#include <stddef.h> /* for size_t */
-#include "arch/queue.h"
-#include "arch/sys_arch.h"
-#include "arch/atomic_32.h"
-#include "stackx_common_opt.h"
-#include "stackx_spl_share.h"
-
-/* From lwip */
-#include "api.h"
-#include "sys.h"
-#include "sys_arch.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-#define MAX_WAIT_TIMEOUT 0x7FFFFFFF
-
-/* Throughout this file, IPaddresses and port numbers are expected to be in
- * the same byte order as in the corresponding pcb.
- */
-
-/* Flags for struct netconn.flags (u8_t) */
-
-/** TCP: when data passed to netconn_write doesn't fit into the send buffer,
- this temporarily stores whether to wake up the original application task
- if data couldn't be sent in the first try. */
-#define SPL_NETCONN_FLAG_WRITE_DELAYED 0x01
-
-/** Should this netconn avoid blocking? */
-#define SPL_NETCONN_FLAG_NON_BLOCKING 0x02
-
-/** Was the last connect action a non-blocking one? */
-#define SPL_NETCONN_FLAG_IN_NONBLOCKING_CONNECT 0x04
-
-/** If this is set, a TCP netconn must call netconn_recved() to update
- the TCP receive window (done automatically if not set). */
-#define SPL_NETCONN_FLAG_NO_AUTO_RECVED 0x08
-
-/** If a nonblocking write has been rejected before, poll_tcp needs to
- check if the netconn is writable again */
-// #define NETCONN_FLAG_CHECK_WRITESPACE 0x10
-
-enum stackx_model
-{
- SOCKET_STACKX = 0,
- CALLBACK_STACKX
-};
-
-enum callback_type
-{
- API_ACCEPT_EVENT = 0xF0,
- API_RECV_EVENT,
- API_SEND_EVENT,
- API_CLOSE_EVENT
-};
-#if 1
-/** Use to inform the callback function about changes */
-enum spl_netconn_evt
-{
- SPL_NETCONN_EVT_RCVPLUS,
- SPL_NETCONN_EVT_RCVMINUS,
- SPL_NETCONN_EVT_SENDPLUS,
- SPL_NETCONN_EVT_SENDMINUS,
- SPL_NETCONN_EVT_ERROR,
- SPL_NETCONN_EVT_HUP,
- SPL_NETCONN_EVT_RDHUP,
- SPL_NETCONN_EVT_AGAIN,
- SPL_NETCONN_EVT_ACCEPT
-};
-#endif
-enum
-{
- INET_ECN_NOT_ECT = 0,
- INET_ECN_ECT_1 = 1,
- INET_ECN_ECT_0 = 2,
- INET_ECN_CE = 3,
- INET_ECN_MASK = 3,
-};
-
-#define SPL_NETCONNTYPE_GROUP(t) (t & 0xF0)
-#define SPL_NETCONNTYPE_DATAGRAM(t) (t & 0xE0)
-
-/* forward-declare some structs to avoid to include their headers */
-typedef struct common_pcb
-{
- enum stackx_model model;
-
- int socket;
-
- /** type of the netconn (TCP, UDP or RAW) */
- enum spl_netconn_type type;
-
- /* share memory between sbr and stackx */
- spl_netconn_t *conn;
-
- u16 bind_thread_index;
- u8 close_progress;
- u8 recv_ring_not_empty;
-
- /** TCP: when data passed to netconn_write doesn't fit into the send buffer,
- this temporarily stores the message.
- Also used during connect and close.
- */
- data_com_msg *current_msg;
-
- msg_write_buf *msg_head;
- msg_write_buf *msg_tail;
-
- size_t write_offset;
-
- /** timeout to wait for new data to be received
- (or connections to arrive for listening netconns) */
- int recv_timeout;
-
- /* timeout to wait for send buffer writtable */
- int send_timeout;
-
- int sk_rcvlowat;
-
- //DFX stat for connection packet
- /* dfx_conn_t dfx; */
-
- /*store the hostpid info for release */
- uint32_t hostpid;
- u8_t l4_tick; /* if is odd number, use l4 ring first */
- u8_t dataSentFlag;
-
- nsfw_res res_chk;
-} common_pcb;
-
-/** A callback prototype to inform about events for a netconn */
-//typedef void (*netconn_callback)(struct spl_netconn *, enum netconn_evt, u16_t len);
-
-/* Though these callback pointers are not set and referenced in nStack Core, still
-the padding is required since the structure will be used in netconn and it needs
-padding across 32-bit and 64-bit architecture */
-typedef struct
-{
- union
- {
- int (*accept_event) (struct spl_netconn * conn);
- PTR_ALIGN_TYPE accept_event_a;
- };
-
- union
- {
- int (*recv_event) (struct spl_netconn * conn);
- PTR_ALIGN_TYPE recv_event_a;
- };
- union
- {
- int (*send_event) (struct spl_netconn * conn);
- PTR_ALIGN_TYPE send_event_a;
- };
- union
- {
- int (*close_event) (struct spl_netconn * conn);
- PTR_ALIGN_TYPE close_event_a;
- };
-} callback_funcation;
-
-union ring_addr_u
-{
- void *ring_addr;
- PTR_ALIGN_TYPE ring_addr_a;
-};
-
-struct mem_manage
-{
- volatile uint32_t current_read;
- volatile uint32_t current_write;
- union ring_addr_u ring_addr[RECV_MAX_POOL];
- union ring_addr_u l4_ring; /* recv ring for l4 */
- //void *ring_addr[RECV_MAX_POOL];
-};
-
-/* Pbuf free should be done in network stack */
-struct spl_netconn_recvbuf_recoder
-{
- struct spl_pbuf *head;
- struct spl_pbuf *tail;
- int totalLen;
-};
-
-/** Register an Network connection event */
-void spl_event_callback (spl_netconn_t * conn, enum spl_netconn_evt evt,
- int postFlag);
-
-#define SPL_API_EVENT(c, e, p) spl_event_callback(c, e, p)
-
-/** Set conn->last_err to err but don't overwrite fatal errors */
-#define SPL_NETCONN_SET_SAFE_ERR(conn, err) do { \
- SYS_ARCH_PROTECT(lev); \
- if (!ERR_IS_FATAL((conn)->last_err)) { \
- (conn)->last_err = err; \
- } \
- SYS_ARCH_UNPROTECT(lev); \
- } while (0);
-
-/** Set the blocking status of netconn calls (@todo: write/send is missing) */
-#define spl_netconn_set_nonblocking(conn, val) do { if (val) { \
- (conn)->flags |= SPL_NETCONN_FLAG_NON_BLOCKING; \
- } else { \
- (conn)->flags &= ~SPL_NETCONN_FLAG_NON_BLOCKING; }} while (0)
-
-/** Get the blocking status of netconn calls (@todo: write/send is missing) */
-#define spl_netconn_is_nonblocking(conn) (((conn)->flags & SPL_NETCONN_FLAG_NON_BLOCKING) != 0)
-
-/** TCP: Set the no-auto-recved status of netconn calls (see NETCONN_FLAG_NO_AUTO_RECVED) */
-#define spl_netconn_set_noautorecved(conn, val) do { if (val) { \
- (conn)->flags |= SPL_NETCONN_FLAG_NO_AUTO_RECVED; \
- } else { \
- (conn)->flags &= ~SPL_NETCONN_FLAG_NO_AUTO_RECVED; }} while (0)
-
-/** TCP: Get the no-auto-recved status of netconn calls (see NETCONN_FLAG_NO_AUTO_RECVED) */
-#define spl_netconn_get_noautorecved(conn) (((conn)->flags & SPL_NETCONN_FLAG_NO_AUTO_RECVED) != 0)
-
-/** Set the receive timeout in milliseconds */
-#define spl_netconn_set_recvtimeout(cpcb, timeout) ((cpcb)->recv_timeout = (timeout))
-
-/** Get the receive timeout in milliseconds */
-#define spl_netconn_get_recvtimeout(cpcb) ((cpcb)->recv_timeout)
-
-/** Set the send timeout in milliseconds */
-#define spl_netconn_set_sendtimeout(cpcb, timeout) ((cpcb)->send_timeout = (timeout))
-
-/** Get the send timeout in milliseconds */
-#define spl_netconn_get_sendtimeout(cpcb) ((cpcb)->send_timeout)
-
-#define spl_netconn_set_sendbufsize(conn, sendbufsize) ((conn)->send_bufsize = (sendbufsize))
-
-/* "man 7 socket" information
- SO_SNDBUF
- Sets or _gets the maximum socket send buffer in bytes. The kernel doubles
- this value (to allow space for bookkeeping overhead) when it is set using
- setsockopt(2), and this doubled value is returned by getsockopt(2).
-*/
-#define spl_netconn_get_sendbufsize(conn) (2 *((conn)->send_bufsize))
-
-#define spl_netconn_set_reclowbufsize(cpcb, recvlowbufsize) ((cpcb)->sk_rcvlowat = ((recvlowbufsize) > 0) ? recvlowbufsize : 1)
-#define spl_netconn_get_reclowbufsize(cpcb) ((cpcb)->sk_rcvlowat)
-
-extern int spl_post_msg (u16 mod, u16 maj, u16 min, u16 op, char *data,
- u16 data_len, u32 src_pid);
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif /* __LWIP_API_H__ */
diff --git a/stacks/lwip_stack/lwip_src/include/stackx/spl_api_msg.h b/stacks/lwip_stack/lwip_src/include/stackx/spl_api_msg.h
deleted file mode 100644
index 94b681e..0000000
--- a/stacks/lwip_stack/lwip_src/include/stackx/spl_api_msg.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef __LWIP_API_MSG_H__
-#define __LWIP_API_MSG_H__
-
-#include <stddef.h>
-#include <net/if.h>
-#include <sys/ioctl.h>
-
-#include "nsfw_msg.h"
-#include "spl_opt.h"
-#include "spl_ip_addr.h"
-#include "spl_err.h"
-#include "spl_api.h"
-//#include "sockets.h"
-#include "stackx_spl_share.h"
-#include "stackx_spl_msg.h"
-
-/* From lwip */
-#include "tcp.h"
-#include "udp.h"
-#include "sys.h"
-
-#ifdef HAL_LIB
-#else
-#include "rte_memcpy.h"
-#endif
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-/* For the netconn API, these values are use as a bitmask! */
-#define NETCONN_SHUT_RD 1
-#define NETCONN_SHUT_WR 2
-#define NETCONN_SHUT_RDWR (NETCONN_SHUT_RD | NETCONN_SHUT_WR)
-
-struct callback_fn
-{
- tcp_sent_fn sent_fn;
- tcp_recv_fn recv_fn;
- tcp_connected_fn connected_fn;
- tcp_poll_fn poll_fn;
- tcp_err_fn err_fn;
- tcp_err_fn close_fn;
- tcp_accept_fn accept_fn;
-};
-
-#ifdef HAL_LIB
-#else
-typedef enum _mbuf_recyle_flg
-{
- MBUF_UNUSED = 0,
- MBUF_HLD_BY_APP = 1,
- MBUF_HLD_BY_SPL = 2,
-} mbuf_recycle_flg;
-#endif
-
-err_t sp_enqueue (struct common_pcb *cpcb, void *p);
-err_t accept_dequeue (spl_netconn_t * lconn, void **new_buf,
- u32_t timeout /*miliseconds */ );
-err_t accept_enqueue (spl_netconn_t * conn, void *p);
-void free_conn_by_spl (spl_netconn_t * conn);
-void unlink_pcb (struct common_pcb *cpcb);
-void do_try_delconn (void *close_data, u32 delay_sec);
-void do_delconn (struct common_pcb *cpcb, msg_delete_netconn * msg);
-void do_bind (struct common_pcb *cpcb, msg_bind * msg);
-void do_pbuf_free (struct spl_pbuf *buf);
-void do_connect (struct common_pcb *cpcb, msg_connect * msg);
-void do_listen (struct common_pcb *cpcb, msg_listen * msg);
-void do_send (struct common_pcb *cpcb, msg_send_buf * msg);
-void do_recv (struct common_pcb *cpcb, msg_recv_buf * msg);
-void do_write (struct common_pcb *cpcb, msg_write_buf * msg);
-void do_getaddr (struct common_pcb *cpcb, msg_getaddrname * msg);
-void do_close (struct common_pcb *cpcb, msg_close * msg);
-void do_getsockopt_internal (struct common_pcb *cpcb,
- msg_setgetsockopt * smsg);
-void do_setsockopt_internal (struct common_pcb *cpcb,
- msg_setgetsockopt * smsg);
-void do_getsockname (struct common_pcb *cpcb, msg_getaddrname * amsg);
-int netconn_drain (enum spl_netconn_type t, spl_netconn_t * conn);
-int spl_pcb_new (msg_new_netconn * m);
-void do_app_touch (msg_app_touch * smsg);
-int do_close_finished (struct common_pcb *cpcb, u8_t close_finished,
- u8_t shut, err_t err, int OpShutDown);
-err_t do_writemore (struct spl_netconn *conn);
-err_t do_close_internal (struct common_pcb *cpcb, int OpShutDown);
-
-u8 get_shut_op (data_com_msg * m);
-int ks_to_stk_opt (int opt);
-void update_tcp_state (spl_netconn_t * conn, enum tcp_state state);
-
-err_t spl_poll_tcp (void *arg, struct tcp_pcb *pcb);
-err_t spl_recv_tcp (void *arg, struct tcp_pcb *pcb, struct pbuf *p,
- err_t err);
-err_t spl_sent_tcp (void *arg, struct tcp_pcb *pcb, u16_t len);
-void spl_err_tcp (void *arg, err_t err);
-err_t spl_tcp_recv_null (void *arg, struct tcp_pcb *pcb, struct pbuf *p,
- err_t err);
-err_t spl_do_connected (void *arg, struct tcp_pcb *pcb, err_t err);
-err_t spl_accept_function (void *arg, struct tcp_pcb *newpcb, err_t err);
-
-struct common_pcb *alloc_common_pcb ();
-void free_common_pcb (struct common_pcb *cpcb);
-int common_pcb_init (struct common_pcb *cpcb);
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif /* __LWIP_API_MSG_H__ */
diff --git a/stacks/lwip_stack/lwip_src/include/stackx/spl_instance.h b/stacks/lwip_stack/lwip_src/include/stackx/spl_instance.h
deleted file mode 100644
index 697c67d..0000000
--- a/stacks/lwip_stack/lwip_src/include/stackx/spl_instance.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _SPL_INSTANCE_H_
-#define _SPL_INSTANCE_H_
-#include "nsfw_msg_api.h"
-#include "stackx_instance.h"
-
-extern stackx_instance *p_def_stack_instance;
-
-int spl_process (data_com_msg * m);
-
-void add_disp_netif (struct netif *netif);
-void do_update_pcbstate ();
-void init_stackx_lwip ();
-
-#endif /* _SPL_INSTANCE_H_ */
diff --git a/stacks/lwip_stack/lwip_src/include/stackx/spl_netbuf.h b/stacks/lwip_stack/lwip_src/include/stackx/spl_netbuf.h
deleted file mode 100644
index cd2e1bf..0000000
--- a/stacks/lwip_stack/lwip_src/include/stackx/spl_netbuf.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef __LWIP_NETBUF_H__
-#define __LWIP_NETBUF_H__
-
-#include "spl_opt.h"
-#include "spl_pbuf.h"
-#include "spl_ip_addr.h"
-#include "common_mem_base_type.h"
-#include "common_mem_pal.h"
-#include "common_pal_bitwide_adjust.h"
-#include "stackx_netbuf.h"
-#include <sys/uio.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <errno.h>
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-/** This spl_netbuf has dest-addr/port set */
-#define NETBUF_FLAG_DESTADDR 0x01
-
-/** This spl_netbuf includes a checksum */
-#define NETBUF_FLAG_CHKSUM 0x02
-
-void spl_netbuf_delete (struct spl_netbuf *buf);
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif /* __LWIP_NETBUF_H__ */
diff --git a/stacks/lwip_stack/lwip_src/include/stackx/spl_pbuf.h b/stacks/lwip_stack/lwip_src/include/stackx/spl_pbuf.h
deleted file mode 100644
index 79deace..0000000
--- a/stacks/lwip_stack/lwip_src/include/stackx/spl_pbuf.h
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef __STACKX_PBUF_H__
-#define __STACKX_PBUF_H__
-
-#include "cc.h"
-
-#include "common_mem_base_type.h"
-#include "stackx_pbuf_comm.h"
-#include "common_mem_mbuf.h"
-
-#ifdef HAL_LIB
-#else
-#include "common_pal_bitwide_adjust.h"
-#endif
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-extern u16_t g_offSetArry[SPL_PBUF_MAX_LAYER];
-
-/** indicates this pbuf is loop buf .*/
-#define PBUF_FLAG_LOOPBUF 0x08U
-
-#define PBUF_SET_LOOP_FLAG(buf) ((buf)->flags |= PBUF_FLAG_LOOPBUF)
-#define PBUF_IS_LOOP_BUF(buf) ((buf)->flags & PBUF_FLAG_LOOPBUF)
-
-/*Add 1 parameter, the last one, indicating which dpdk_malloc
- *should be allocated from the pool; non-PBUF_ALLOC type regardless of this parameter*/
-struct spl_pbuf *spl_pbuf_alloc_hugepage (spl_pbuf_layer l, u16_t length,
- spl_pbuf_type type,
- u16_t thread_index, void *net_conn);
-struct pbuf *spl_convert_spl_pbuf_to_pbuf (struct spl_pbuf *p_from);
-err_t
-splpbuf_to_pbuf_transport_copy (struct pbuf *p_to, struct spl_pbuf *p_from);
-
-err_t pbuf_to_splpbuf_copy (struct spl_pbuf *p_to, struct pbuf *p_from);
-err_t splpbuf_to_pbuf_copy (struct pbuf *p_to, struct spl_pbuf *p_from);
-spl_pbuf_layer get_pbuf_layer_from_pbuf_payload (struct pbuf *buf);
-void print_pbuf_payload_info (struct pbuf *buf, bool send);
-
-static inline u8_t
-spl_pbuf_header (struct spl_pbuf *p, s16_t header_size_increment)
-{
- u8_t pbuf_ret;
- /* header max len is tcp len+ ip len: 0xf*4+PBUF_IP_HLEN */
- if (unlikely
- (((header_size_increment) < 0 && (-(header_size_increment)) > p->len)
- || (header_size_increment > 0
- && (header_size_increment) >= (0xf * 4 + SPL_PBUF_IP_HLEN))))
- {
- pbuf_ret = 1;
- }
- else
- {
- p->payload_a = p->payload_a - (header_size_increment);
- p->len += (header_size_increment);
- p->tot_len += (header_size_increment);
- pbuf_ret = 0;
- }
- return pbuf_ret;
-}
-
-void spl_pbuf_realloc (struct spl_pbuf *p, u32_t size);
-
-void spl_pbuf_cat (struct spl_pbuf *head, struct spl_pbuf *tail);
-void spl_pbuf_free (struct spl_pbuf *p);
-
-#define pbuf_free_safe(x)\
-{\
- spl_pbuf_free((x));\
- (x) = NULL;\
-}
-
-/**
- * Count number of pbufs in a chain
- *
- * @param p first pbuf of chain
- * @return the number of pbufs in a chain
- */
-static inline u16_t
-spl_pbuf_clen (struct spl_pbuf *p)
-{
- u16_t len = 0;
- while (p != NULL)
- {
- ++len;
- p = (struct spl_pbuf *) ADDR_SHTOL (p->next_a);
- }
- return len;
-}
-
-static inline u16_t
-mbuf_count (struct spl_pbuf *p)
-{
- u16_t count = 0;
- struct spl_pbuf *buf = p;
- struct common_mem_mbuf *mbuf;
- while (buf)
- {
- mbuf =
- (struct common_mem_mbuf *) ((char *) buf -
- sizeof (struct common_mem_mbuf));
- while (mbuf)
- {
- count++;
-#ifdef HAL_LIB
-#else
- mbuf = mbuf->next;
-#endif
- }
- buf = (struct spl_pbuf *) ADDR_SHTOL (buf->next_a); //buf->next;
- }
- return count;
-}
-
-static inline u16_t
-mbuf_count_in_one_pbuf (struct spl_pbuf *p)
-{
-
- u16_t cnt = 0;
- struct common_mem_mbuf *mbuf;
- if (NULL == p)
- {
- NSPOL_LOGERR ("Invalid param : p(null) !");
- return 0;
- }
-
- mbuf =
- (struct common_mem_mbuf *) ((char *) p - sizeof (struct common_mem_mbuf));
-
- /* no need to check mbuf itself */
-#ifdef HAL_LIB
-#else
- if (!mbuf->next)
-#endif
- return 1;
-
- while (mbuf)
- {
- ++cnt;
-#ifdef HAL_LIB
-#else
- mbuf = mbuf->next;
-#endif
- }
-
- return cnt;
-}
-
-inline int pbuf_internal_copy (struct spl_pbuf *dst, struct spl_pbuf *src);
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif /* __STACKX_PBUF_H__ */
diff --git a/stacks/lwip_stack/lwip_src/include/stackx/spl_sbr.h b/stacks/lwip_stack/lwip_src/include/stackx/spl_sbr.h
deleted file mode 100644
index a4d6ccc..0000000
--- a/stacks/lwip_stack/lwip_src/include/stackx/spl_sbr.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _SPL_SBR_H_
-#define _SPL_SBR_H_
-#include "nsfw_msg_api.h"
-#include "tcp.h"
-#include "udp.h"
-//#include "stackx/raw.h"
-#define COMM_PRIVATE_PTR(m) \
- ((m->param.receiver) ? ((struct common_pcb *)m->param.comm_receiver) : 0)
-#define TCP_PRIVATE_PTR(m) \
- ((m->param.receiver) ? (*(struct tcp_pcb **)m->param.receiver) : 0)
-#define UDP_PRIVATE_PTR(m) \
- ((m->param.receiver) ? (*(struct udp_pcb **)m->param.receiver) : 0)
-/*#define RAW_PRIVATE_PTR(m) \
- ((m->param.receiver) ? (*(void *)m->param.receiver) : 0) */
-
-int spl_sbr_process (data_com_msg * m);
-#endif /* _SPL_SBR_H_ */
diff --git a/stacks/lwip_stack/lwip_src/include/stackx/spl_sockets.h b/stacks/lwip_stack/lwip_src/include/stackx/spl_sockets.h
deleted file mode 100644
index 278bb02..0000000
--- a/stacks/lwip_stack/lwip_src/include/stackx/spl_sockets.h
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef __STACKX_SOCKETS_H__
-#define __STACKX_SOCKETS_H__
-
-#include <errno.h>
-#include <stddef.h> /* for size_t */
-#include "arch/sys_arch.h"
-#include "sys/socket.h"
-#include <errno.h>
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-#ifndef socklen_t
-#define socklen_t u32_t
-#endif
-
-#define SET_STACKP_ERRNO(err) (errno = (err)) //thread-local errno
-
-#ifndef set_errno
-#define set_errno(err) SET_STACKP_ERRNO(err)
-#endif
-
-#define sock_set_errno(sk, e) do { \
- (sk)->err = (e); \
- if ((sk)->err != 0) \
- set_errno((sk)->err); \
- } while (0)
-
-#ifndef __BITS_SOCKET_H
-/* Socket protocol types (TCP/UDP/RAW) */
-#define SOCK_STREAM 1
-#define SOCK_DGRAM 2
-#define SOCK_RAW 3
-/*
- * Option flags per-socket. These must match the SOF_ flags in ip.h (checked in init.c)
- */
-#define SO_DEBUG 0x0001 /* Unimplemented: turn on debugging info storing */
-#define SO_REUSEADDR 0x0002
-#endif
-
-#define SO_DONTROUTE 5 //0x0010 /* Unimplemented: just use interface addresses */
-#define SO_BROADCAST 6 //0x0020 /* permit to send and to receive broad cast messages*/
-#define SO_KEEPALIVE 9 //0x0008 gaussdb /* keep connections alive */
-#define SO_OOBINLINE 10 //0x0100 /* Unimplemented: leave received OOB data in line */
-#define SO_LINGER 13 //0x0080 /* linger on close if data present */
-#define SO_REUSEPORT 15 /* Unimplemented: allow local address & port reuse */
-#define SO_ACCEPTCONN 30 //0x0002 /* socket has had listen() */
-#define SO_USELOOPBACK 0x0040 /* Unimplemented: bypass hardware when possible */
-
-#define SO_DONTLINGER ((int)(~SO_LINGER))
-
-/*
- * Additional options, not kept in so_options.
- */
-#define SO_TYPE 3 /* get socket type */
-#define SO_ERROR 4
-#define SO_SNDBUF 7 /* send buffer size */
-#define SO_RCVBUF 8 /* receive buffer size */
-#define SO_NO_CHECK 11 /* don't create UDP checksum */
-#define SO_RCVLOWAT 18 /* receive low-water mark */
-#define SO_SNDLOWAT 19 /* send low-water mark */
-#define SO_RCVTIMEO 20 /* receive timeout */
-#define SO_SNDTIMEO 21 /* Unimplemented: send timeout */
-
-#define SO_CONTIMEO 0x1009 /* Unimplemented: connect timeout */
-
-/*
- * Level number for (get/set)sockopt() to apply to socket itself.
- */
-#define SOL_SOCKET 1 //0xfff
-
-#ifndef __BITS_SOCKET_H
-
-#define AF_UNSPEC 0
-#define PF_UNSPEC AF_UNSPEC
-#define AF_INET 2
-#define PF_INET AF_INET
-
-#define IPPROTO_TCP 6
-#define IPPROTO_UDP 17
-#define IPPROTO_UDPLITE 136
-
-#define IPPROTO_IP 0
-
-#define MSG_PEEK 0x02
-#define MSG_WAITALL 0x100
-#define MSG_OOB 0x01
-#define MSG_DONTWAIT 0x40
-#define MSG_MORE 0x8000
-#endif
-
-#define IP_TOS 1
-#define IP_TTL 2
-
-#define RCV_WND 0x21
-#define RCV_ANN_WND 0x22
-#define INIT_CWND 0x23
-#define THRESHOLD_FACTOR 0x24
-#define TMR_INTERVAL 0x25
-
-/*
- * Options and types for UDP multicast traffic handling
- */
-#ifndef __BITS_SOCKET_H
-#define IP_ADD_MEMBERSHIP 3
-#define IP_DROP_MEMBERSHIP 4
-#define IP_MULTICAST_TTL 5
-#define IP_MULTICAST_IF 6
-#define IP_MULTICAST_LOOP 7
-#endif
-
-/*
- * The Type of Service provides an indication of the abstract
- * parameters of the quality of service desired. These parameters are
- * to be used to guide the selection of the actual service parameters
- * when transmitting a datagram through a particular network. Several
- * networks offer service precedence, which somehow treats high
- * precedence traffic as more important than other traffic (generally
- * by accepting only traffic above a certain precedence at time of high
- * load). The major choice is a three way tradeoff between low-delay,
- * high-reliability, and high-throughput.
- * The use of the Delay, Throughput, and Reliability indications may
- * increase the cost (in some sense) of the service. In many networks
- * better performance for one of these parameters is coupled with worse
- * performance on another. Except for very unusual cases at most two
- * of these three indications should be set.
- */
-#define IPTOS_LOWCOST 0x02
-#define IPTOS_RELIABILITY 0x04
-#define IPTOS_THROUGHPUT 0x08
-#define IPTOS_LOWDELAY 0x10
-#define IPTOS_TOS_MASK 0x1E
-#define IPTOS_MINCOST IPTOS_LOWCOST
-#define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK)
-
-/*
- * The Network Control precedence designation is intended to be used
- * within a network only. The actual use and control of that
- * designation is up to each network. The Internetwork Control
- * designation is intended for use by gateway control originators only.
- * If the actual use of these precedence designations is of concern to
- * a particular network, it is the responsibility of that network to
- * control the access to, and use of, those precedence designations.
- */
-#define IPTOS_PREC_ROUTINE 0x00
-#define IPTOS_PREC_PRIORITY 0x20
-#define IPTOS_PREC_IMMEDIATE 0x40
-#define IPTOS_PREC_FLASH 0x60
-#define IPTOS_PREC_FLASHOVERRIDE 0x80
-#define IPTOS_PREC_CRITIC_ECP 0xa0
-#define IPTOS_PREC_INTERNETCONTROL 0xc0
-#define IPTOS_PREC_MASK 0xe0
-#define IPTOS_PREC_NETCONTROL 0xe0
-#define IPTOS_PREC(tos) ((tos) & IPTOS_PREC_MASK)
-
-#if !defined (FIONREAD) || !defined (FIONBIO)
-#define IOC_VOID 0x20000000UL /* no parameters */
-#define IOC_OUT 0x40000000UL /* copy out parameters */
-#define IOC_IN 0x80000000UL /* copy in parameters */
-#define IOCPARM_MASK 0x7fU /* parameters must be < 128 bytes */
-#define IOC_INOUT (IOC_IN | IOC_OUT) /* 0x20000000 distinguishes new & old ioctl's */
-
-#define _IO(x, y) (((x) << 8) | (y) |IOC_VOID )
-
-#define _IOR(x, y, t) (IOC_OUT | (((long)sizeof(t) & IOCPARM_MASK) << 16) | ((x) << 8) | (y))
-
-#define _IOW(x, y, t) (IOC_IN | (((long)sizeof(t) & IOCPARM_MASK) << 16) | ((x) << 8) | (y))
-#endif /* !defined(FIONREAD) || !defined(FIONBIO) */
-
-#ifndef FIONREAD
-#define FIONREAD _IOR('f', 127, unsigned long)
-#endif
-#ifndef FIONBIO
-#define FIONBIO _IOW('f', 126, unsigned long)
-#endif
-
-/*unimplemented */
-#ifndef SIOCSHIWAT
-#define SIOCSHIWAT _IOW('s', 0, unsigned long)
-#define SIOCGHIWAT _IOR('s', 1, unsigned long)
-#define SIOCSLOWAT _IOW('s', 2, unsigned long)
-#define SIOCGLOWAT _IOR('s', 3, unsigned long)
-#ifndef __BITS_SOCKET_H
-#define SIOCATMARK _IOR('s', 7, unsigned long)
-#endif
-#endif
-
-/* commands for fnctl */
-#ifndef F_GETFL
-#define F_GETFL 3
-#endif
-#ifndef F_SETFL
-#define F_SETFL 4
-#endif
-
-/* File status flags and file access modes for fnctl,
- these are bits in an int. */
-#ifndef O_NONBLOCK
-#define O_NONBLOCK 0X800 /* nonblocking I/O */
-#endif
-#ifndef O_NDELAY
-#define O_NDELAY O_NONBLOCK /* same as O_NONBLOCK, for compatibility */
-#endif
-
-#ifndef O_CLOEXEC
-#define O_CLOEXEC 0x80000 /* set close_on_exec */
-#endif
-#ifndef __BITS_SOCKET_H
-#define SOCK_CLOEXEC O_CLOEXEC
-#endif
-#ifndef FD_CLOEXEC
-#define FD_CLOEXEC 1
-#endif
-#ifndef SHUT_RD
-#define SHUT_RD 0
-#define SHUT_WR 1
-#define SHUT_RDWR 2
-#endif
-
-struct pollfd
-{
-
- int fd; /* file descriptor */
- short events; /* wait event */
- short revents; /* actual event happened */
-};
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif /* __STACKX_SOCKETS_H__ */
diff --git a/stacks/lwip_stack/lwip_src/include/stackx/spl_tcpip.h b/stacks/lwip_stack/lwip_src/include/stackx/spl_tcpip.h
deleted file mode 100644
index 0f885d6..0000000
--- a/stacks/lwip_stack/lwip_src/include/stackx/spl_tcpip.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef __STACKX_TCPIP_H__
-#define __STACKX_TCPIP_H__
-
-#include "spl_opt.h"
-#include "stackx/spl_ip_addr.h"
-#include "tcp.h"
-
-#define USEAGE_LOW 60
-#define USEAGE_HIGHT 80
-#define USEAGE_INVALID 0xFF
-
-/*** Put into stackx_instance *********
-
-************************************/
-#include "stackx/spl_api_msg.h"
-#include "netifapi.h"
-#include "stackx/spl_pbuf.h"
-#include "stackx/spl_api.h"
-#include "sys.h"
-#include "netif.h"
-#include "ip_module_api.h"
-#include "internal_msg.h"
-#include "pbuf.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-/** Function prototype for send timeout message */
-err_t ltt_apimsg (sys_timeout_handler h, void *arg);
-
-/** Function prototype for the init_done function passed to tcpip_init */
-typedef void (*tcpip_init_done_fn) (void *arg);
-
-/** Function prototype for functions passed to tcpip_callback() */
-typedef void (*tcpip_callback_fn) (void *ctx);
-
-int init_by_main_thread ();
-int init_by_tcpip_thread ();
-err_t spl_tcpip_input (struct pbuf *p, struct netif *inp);
-
-int post_ip_module_msg (void *arg, ip_module_type type,
- ip_module_operate_type operate_type);
-int process_ip_module_msg (void *arg, ip_module_type type,
- ip_module_operate_type operate_type);
-int init_new_network_configuration ();
-
-#if STACKX_NETIF_API
-err_t tcpip_netif_add (msg_add_netif * tmp);
-#endif /* STACKX_NETIF_API */
-
-err_t ltt_clearTmrmsg (void *pcb, void *arg);
-
-sys_mbox_t get_primary_box ();
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif /* __STACKX_TCPIP_H__ */
diff --git a/stacks/lwip_stack/lwip_src/include/stackx/spl_timers.h b/stacks/lwip_stack/lwip_src/include/stackx/spl_timers.h
deleted file mode 100644
index 4809b2b..0000000
--- a/stacks/lwip_stack/lwip_src/include/stackx/spl_timers.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef __SPL_TIMERS_H__
-#define __SPL_TIMERS_H__
-
-#include "opt.h"
-#include "common_mem_base_type.h"
-
-typedef void (*sys_timeout_handler) (void *arg);
-
-#include "rb_tree.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-/** Function prototype for a timeout callback function. Register such a function
- * using sys_timeout().
- *
- * @param arg Additional argument to pass to the function - set up by sys_timeout()
- */
-
-/*
- * *************************************************************************
- * PTIMER defined 2013/3/15
- * *************************************************************************
- */
-#define PTIMER_DEFAULT 0x00 /* periodic mode */
-#define PTIMER_ONESHOT 0x01
-#define PTIMER_USER_DEF 0x02
-
-enum msg_type
-{
- SYS_PTIMEROUT_MSG,
- SYS_UNPTIMEROUT_MSG,
-};
-
-struct msg_context
-{
- unsigned long msec;
- union
- {
- sys_timeout_handler handle;
- } action;
-#define _act_category action.act_category
-#define _phandle action.handle
- u32_t flags; /* oneshot|user_def|... */
- void *ctx; /* pcb ptr */
-};
-
-struct ptimer_node
-{
- struct rb_node node;
- unsigned long abs_nsec;
- struct msg_context info;
- unsigned long state;
- u16_t index; /* store a lwip thread message box id */
-};
-
-struct ptimer_msg
-{
- enum msg_type msg_type;
- struct ptimer_node *node;
- struct ptimer_msg *next, *prev;
-};
-
-struct ptimer_base
-{
- struct rb_root active;
- struct rb_node *first; /* point the recently timeout */
- pthread_mutex_t lock;
- pthread_cond_t cond;
- struct ptimer_msg *head, *tail;
-};
-
-/*
- * *****************************************************
- * ptimer E-N-D
- * *****************************************************
- */
-void ptimer_thread (void *arg);
-void timeout_phandler (void *act, void *arg);
-void regedit_ptimer (enum msg_type type, sys_timeout_handler handler,
- struct ptimer_node *node);
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif /* __LWIP_TIMERS_H__ */
diff --git a/stacks/lwip_stack/lwip_src/include/stackx/stackx_instance.h b/stacks/lwip_stack/lwip_src/include/stackx/stackx_instance.h
deleted file mode 100644
index 679d2ac..0000000
--- a/stacks/lwip_stack/lwip_src/include/stackx/stackx_instance.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef __STACKX_INSTANCE_H__
-#define __STACKX_INSTANCE_H__
-
-#include "stackx/spl_tcpip.h"
-#include "netif.h"
-#include "lwip/ip4_frag.h"
-#include "stackx/spl_pbuf.h"
-#include "arch/sys_arch.h"
-#include "arch/queue.h"
-#include "stackx_tx_box.h"
-#include "nsfw_msg.h"
-#include "stackx_app_res.h"
-#include "ip_module_api.h"
-#include "tcp.h"
-#include "udp.h"
-
-#define PKT_BURST 32
-
-#define TASK_BURST 16
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-#define MAX_NETBUFS 1024*2 //define for C10M
-
-#define TOTAL_MSG_QUEUE_NUM (MSG_PRIO_QUEUE_NUM+1) /* three priority queue and one primary queue */
-
-struct stackx_stat
-{
- struct rti_queue primary_stat; //primary box stat
- u64_t extend_member_bit;
-};
-
-struct stackx_stack
-{
- struct queue primary_mbox;
- struct queue priority_mbox[MSG_PRIO_QUEUE_NUM]; //0-highest; 1-medium; 2-lowest
- //stackx_apis stackx_api;
-};
-
-struct disp_netif_list
-{
- struct disp_netif_list *next;
- struct netif *netif;
-};
-
-typedef struct stackx_instance
-{
- uint16_t rss_queue_id;
-
- mpool_handle mp_tx;
- //mring_handle mp_seg;
- mring_handle cpcb_seg;
- mring_handle lmsg_pool;
-
- struct stackx_stack lstack;
- struct stackx_stat lstat; //point to p_stackx_table->lstat[i];
-
- /**
- * Header of the input packet currently being processed.
- */
- /* global variables */
- struct disp_netif_list *netif_list;
-} stackx_instance;
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif /* __STACKX_INSTANCE_H__ */
diff --git a/stacks/lwip_stack/lwip_src/instance/spl_instance.c b/stacks/lwip_stack/lwip_src/instance/spl_instance.c
deleted file mode 100644
index 69b9d82..0000000
--- a/stacks/lwip_stack/lwip_src/instance/spl_instance.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "nsfw_msg_api.h"
-#include "nsfw_init.h"
-#include "stackx/spl_sbr.h"
-#include "stackx/stackx_instance.h"
-
-stackx_instance *p_def_stack_instance = NULL;
-
-/**
- * process message from other module, but the MT module message will be delayed
- * to handle in the end of the loop to avoid to lose the message dequeued out.
- *
- * @param m the data_com_msg to handle
- */
-int
-spl_process (data_com_msg * m)
-{
- return call_msg_fun (m);
-}
-
-void
-add_disp_netif (struct netif *netif)
-{
- struct disp_netif_list *item = malloc (sizeof (struct disp_netif_list));
- if (!item)
- {
- NSPOL_LOGERR ("malloc failed");
- return;
- }
-
- item->netif = netif;
- item->next = p_def_stack_instance->netif_list;
- p_def_stack_instance->netif_list = item;
-}
diff --git a/stacks/lwip_stack/lwip_src/ip_module/configuration_reader.c b/stacks/lwip_stack/lwip_src/ip_module/configuration_reader.c
deleted file mode 100644
index 6e10c7a..0000000
--- a/stacks/lwip_stack/lwip_src/ip_module/configuration_reader.c
+++ /dev/null
@@ -1,1052 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include <unistd.h>
-#include <sys/wait.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <netinet/in.h>
-#include <time.h>
-#include <pthread.h>
-#include <sys/types.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include "configuration_reader.h"
-#include "container_ip.h"
-#include "network.h"
-#include "nstack_log.h"
-#include "nstack_securec.h"
-#include "json.h"
-#include "spl_tcpip.h"
-
-#include <types.h>
-#include <nsfw_mgr_com_api.h>
-#include <nsfw_base_linux_api.h>
-#include "nsfw_maintain_api.h"
-
-NSTACK_STATIC struct config_data g_ip_module_buff;
-NSTACK_STATIC struct config_data *g_config_data;
-NSTACK_STATIC char ip_module_unix_socket[IP_MODULE_MAX_PATH_LEN + 1];
-NSTACK_STATIC char ip_module_unix_socket_dir_path[IP_MODULE_MAX_PATH_LEN + 1];
-//static unsigned long int g_thread_id = 0;
-
-#define MAX_CONNECTION_NUMBER 5
-#define TCP_OOS_LEN_MAX 250
-
-NSTACK_STATIC int read_configuration ();
-NSTACK_STATIC int unix_socket_listen (const char *servername);
-NSTACK_STATIC int process_query ();
-
-/*****************************************************************************
-* Prototype : is_digit_str
-* Description : check if a string contains only digit
-* Input : char *input
-* Output : 1 for yes, 0 for no
-* Return Value : int
-* Calls :
-* Called By : get_main_pid
-*
-*****************************************************************************/
-NSTACK_STATIC int
-is_digit_str (char *input)
-{
- if (NULL == input || '\0' == input[0])
- {
- return 0;
- }
-
- while (*input)
- {
- if (*input > '9' || *input < '0')
- {
- return 0;
- }
- input++;
- }
-
- return 1;
-}
-
-/*****************************************************************************
-* Prototype : process_query
-* Description : ./nStackCtrl -a query
-* Input : none
-* Output : none
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-NSTACK_STATIC int
-process_query ()
-{
- int retval;
-
- if (0 == g_config_data->param.type[0])
- {
- return process_post (NULL, IP_MODULE_ALL, IP_MODULE_OPERATE_QUERY);
- }
-
- /*name & p are freed inside process_post */
- if (0 == strcmp (g_config_data->param.type, IP_MODULE_TYPE_PORT))
- {
- struct ip_action_param *p = malloc (sizeof (struct ip_action_param));
- if (p == NULL)
- {
- NSOPR_LOGERR ("name allocation failed!");
- NSOPR_SET_ERRINFO (NSCRTL_ERR, "mem alloc error!");
- return -1;
- }
-
- retval =
- MEMSET_S (p, sizeof (struct ip_action_param), 0,
- sizeof (struct ip_action_param));
- if (EOK != retval)
- {
- NSOPR_LOGERR ("MEMSET_S failed]ret=%d", retval);
- NSOPR_SET_ERRINFO (NSCRTL_ERR, "MEMSET_S error!");
- free (p);
- return -1;
- }
-
- retval =
- STRCPY_S (p->container_id, sizeof (p->container_id),
- g_config_data->param.container_id);
- if (EOK != retval)
- {
- NSOPR_LOGERR ("STRCPY_S failed]ret=%d", retval);
- NSOPR_SET_ERRINFO (NSCRTL_ERR, "STRCPY_S error!");
- free (p);
- return -1;
- }
-
- retval =
- STRCPY_S (p->port_name, sizeof (p->port_name),
- g_config_data->param.name);
- if (EOK != retval)
- {
- NSOPR_LOGERR ("STRCPY_S failed]ret=%d", retval);
- NSOPR_SET_ERRINFO (NSCRTL_ERR, "STRCPY_S error!");
- free (p);
- return -1;
- }
-
- return process_post ((void *) p, IP_MODULE_IP, IP_MODULE_OPERATE_QUERY);
- }
- else if (0 == strcmp (g_config_data->param.type, IP_MODULE_TYPE_NETWORK))
- {
- if (0 == g_config_data->param.name[0])
- {
- return process_post (NULL, IP_MODULE_NETWORK_ALL,
- IP_MODULE_OPERATE_QUERY);
- }
- else
- {
- char *name = malloc (sizeof (g_config_data->param.name));
- if (NULL == name)
- {
- NSOPR_LOGERR ("name allocation failed!");
- NSOPR_SET_ERRINFO (NSCRTL_ERR, "mem alloc error!");
- return -1;
- }
-
- retval =
- MEMSET_S (name, sizeof (g_config_data->param.name), 0,
- sizeof (g_config_data->param.name));
- if (EOK != retval)
- {
- NSOPR_LOGERR ("MEMSET_S failed]ret=%d", retval);
- NSOPR_SET_ERRINFO (NSCRTL_ERR, "MEMSET_S error!");
- free (name);
- return -1;
- }
-
- retval =
- STRCPY_S (name, sizeof (g_config_data->param.name),
- g_config_data->param.name);
- if (EOK != retval)
- {
- NSOPR_LOGERR ("STRCPY_S failed]ret=%d", retval);
- NSOPR_SET_ERRINFO (NSCRTL_ERR, "STRCPY_S error!");
- free (name);
- return -1;
- }
-
- return process_post ((void *) name, IP_MODULE_NETWORK,
- IP_MODULE_OPERATE_QUERY);
- }
- }
- else if (0 == strcmp (g_config_data->param.type, IP_MODULE_TYPE_IP))
- {
- if (0 == g_config_data->param.name[0])
- {
- return process_post (NULL, IP_MODULE_IP_ALL,
- IP_MODULE_OPERATE_QUERY);
- }
- else
- {
- NSOPR_SET_ERRINFO (NSCRTL_INPUT_ERR, "input error!");
- }
- }
- else
- {
- NSOPR_SET_ERRINFO (NSCRTL_INPUT_ERR, "input error!");
- }
-
- return -1;
-}
-
-int
-read_ipmoduleoperatesetnet_configuration ()
-{
- if (strcmp (g_config_data->param.type, IP_MODULE_TYPE_SETLOG) == 0)
- {
- if (NSCRTL_OK ==
- setlog_level_value (g_config_data->param.name,
- g_config_data->param.value))
- {
- NSOPR_LOGDBG ("set log level ok!");
- }
- else
- {
- NSOPR_SET_ERRINFO (NSCRTL_INPUT_ERR, "input error!");
- }
- }
- else if (strcmp (g_config_data->param.type, TCP_MODULE_TYPE_SET_OOS_LEN) ==
- 0)
- {
- if (is_digit_str (g_config_data->param.value) == 0)
- {
- NSOPR_SET_ERRINFO (NSCRTL_INPUT_ERR,
- "Invalid value:value must be digital and smaller than %u]value=\"%s\"",
- TCP_OOS_LEN_MAX, g_config_data->param.value);
- return 0;
- }
-
- unsigned int value_len = strlen (g_config_data->param.value);
- if ((value_len >= 2) && (g_config_data->param.value[0] == '0'))
- {
- NSOPR_SET_ERRINFO (NSCRTL_INPUT_ERR,
- "Invalid value:value cannot start with 0");
- return 0;
- }
- }
- else
- {
- NSOPR_SET_ERRINFO (NSCRTL_INPUT_ERR, "input error!");
- }
-
- return 0;
-}
-
-/*****************************************************************************
-* Prototype : read_version
-* Description : Query Version by nStackCtrl
-* Input : None
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-read_version ()
-{
- int retVal;
- json_object *version = json_object_new_object ();
-
- if (NULL == version)
- {
- NSOPR_SET_ERRINFO (NSCRTL_ERR, "internal error for version=NULL!");
- return NSCRTL_ERR;
- }
-
- json_object_object_add (version, "moudle",
- json_object_new_string (NSTACK_GETVER_MODULE));
- json_object_object_add (version, "version",
- json_object_new_string (NSTACK_GETVER_VERSION));
- json_object_object_add (version, "buildtime",
- json_object_new_string (NSTACK_GETVER_BUILDTIME));
-
- json_object *version_array = json_object_new_array ();
- if (NULL == version_array)
- {
- json_object_put (version);
- NSOPR_SET_ERRINFO (NSCRTL_ERR,
- "internal error for version_array=NULL!");
- return NSCRTL_ERR;
- }
-
- retVal = json_object_array_add (version_array, version);
-
- if (0 != retVal)
- {
- json_object_put (version_array);
- json_object_put (version);
- NSOPR_SET_ERRINFO (NSCRTL_ERR,
- "internal error for json_object_array_add failed!");
- return NSCRTL_ERR;
- }
-
- const char *str = json_object_to_json_string (version_array);
-
- if (NULL == str)
- {
- json_object_put (version_array);
- NSOPR_SET_ERRINFO (NSCRTL_ERR, "internal error for str=NULL!");
- return NSCRTL_ERR;
- }
-
- size_t str_len = strlen (str);
- if (str_len >= sizeof (get_config_data ()->json_buff))
- {
- json_object_put (version_array);
- NSOPR_SET_ERRINFO (NSCRTL_ERR, "internal error!");
- return NSCRTL_ERR;
- }
-
- retVal =
- STRNCPY_S (get_config_data ()->json_buff,
- sizeof (get_config_data ()->json_buff), str, str_len);
- if (EOK != retVal)
- {
- json_object_put (version_array);
- NSOPR_SET_ERRINFO (NSCRTL_ERR, "STRNCPY_S error!");
- return NSCRTL_ERR;
- }
-
- json_object_put (version_array);
- return NSCRTL_OK;
-}
-
-void
-reset_config_data (void)
-{
- int retval = MEMSET_S (g_config_data, sizeof (struct config_data), 0,
- sizeof (struct config_data));
- if (EOK != retval)
- {
- printf ("MEMSET_S failed]retval=%d.\n", retval);
- exit (1);
- }
-}
-
-int
-get_network_json_data ()
-{
- STRCPY_S (g_config_data->param.type, sizeof (g_config_data->param.type),
- "network");
- g_config_data->param.action = IP_MODULE_OPERATE_ADD;
-
- char *tmp_config_path;
- tmp_config_path = realpath ("./network_data_tonStack.json", NULL);
- if (!tmp_config_path)
- {
- NSTCP_LOGINF ("Warning! It use the second search path ../configure");
- tmp_config_path =
- realpath ("../configure/network_data_tonStack.json", NULL);
- }
-
- if (!tmp_config_path)
- {
- return 1;
- }
-
- int fp = open (tmp_config_path, O_RDONLY);
- if (-1 == fp)
- {
- free (tmp_config_path);
- NSTCP_LOGINF ("network file open failed.\n");
- exit (1);
- }
- free (tmp_config_path);
-
- int nread = read (fp, g_config_data->json_buff,
- sizeof (g_config_data->json_buff) - 1);
- if (nread <= 0)
- {
- close (fp);
- NSTCP_LOGINF ("read failed %d.\n", nread);
- exit (1);
- }
-
- /* though MEMSET_S is done above, MEMSET_S can be removed */
- g_config_data->json_buff[nread] = '\0';
- close (fp);
-
- struct network_configuration *network = NULL;
- struct network_configuration *tmp = NULL;
-
- /* input shouldnot be same with return */
- network = parse_network_json (g_config_data->json_buff, NULL);
- if (!network)
- {
- NSTCP_LOGINF ("Invalid network data!");
- NSOPR_SET_ERRINFO (NSCRTL_INPUT_ERR, "Invalid network data!");
- return -1;
- }
-
- /* run process_post for each network, not only the head node */
- while (network)
- {
- tmp = network;
- network = network->next;
- int retval =
- add_network_configuration ((struct network_configuration *) tmp);
-
- /* When network exceeds max number, just log warning at operation.log */
- if (retval == NSCRTL_NETWORK_COUNT_EXCEED)
- {
- NSTCP_LOGINF
- ("Warning!! Network count exceed max allowed number]max=%d",
- MAX_NETWORK_COUNT);
- }
- else
- {
-
- NSTCP_LOGINF ("add_network_configuration %d", retval);
- NSOPR_SET_ERRINFO (retval, "add_network_configuration return %d",
- retval);
- }
-
- if (!retval)
- {
- /*init DPDK eth */
- if ((retval = init_new_network_configuration ()) != ERR_OK)
- {
- NSTCP_LOGINF ("process_configuration failed! %d", retval);
- free_network_configuration ((struct network_configuration *)
- tmp, IP_MODULE_TRUE);
- NSOPR_SET_ERRINFO (retval,
- "init_new_network_configuration return %d",
- retval);
- return -1;
- }
- }
- }
- NSTCP_LOGINF ("Get_network_json_data done!");
-
- return 0;
-}
-
-int
-get_ip_json_data ()
-{
- NSTCP_LOGINF ("get_ip_json_data start!");
-
- STRCPY_S (g_config_data->param.type, sizeof (g_config_data->param.type),
- "ip");
- g_config_data->param.action = IP_MODULE_OPERATE_ADD;
-
- char *tmp_config_path;
- tmp_config_path = realpath ("./ip_data.json", NULL);
- if (!tmp_config_path)
- {
- NSTCP_LOGINF ("Warning! It use the second search path ../configure");
- tmp_config_path = realpath ("../configure/ip_data.json", NULL);
- }
-
- if (!tmp_config_path)
- {
- return 1;
- }
-
- int fp = open (tmp_config_path, O_RDONLY);
- if (-1 == fp)
- {
- free (tmp_config_path);
- NSTCP_LOGINF ("network file open failed\n");
- exit (1);
- }
- free (tmp_config_path);
-
- int nread = read (fp, g_config_data->json_buff,
- sizeof (g_config_data->json_buff) - 1);
- if (nread <= 0)
- {
- close (fp);
- NSTCP_LOGINF ("read failed %d.\n", nread);
- exit (1);
- }
-
- /* though MEMSET_S is done above, MEMSET_S can be removed */
- g_config_data->json_buff[nread] = '\0';
- close (fp);
-
- struct container_ip *container =
- parse_container_ip_json (g_config_data->json_buff);
- if (container)
- {
- int retval = add_container (container);
-
- NSTCP_LOGINF ("add_container %d", retval);
- NSOPR_SET_ERRINFO (retval, "add_container return %d", retval);
- }
- else
- {
- NSTCP_LOGINF ("Invalid IP config data!");
- NSOPR_SET_ERRINFO (NSCRTL_INPUT_ERR, "Invalid IP config data!");
- return -1;
- }
- NSTCP_LOGINF ("get_ip_json_data done!");
-
- return 0;
-}
-
-int
-read_ipmoduleoperateadd_configuration ()
-{
- struct network_configuration *tmp = NULL;
- if (strcmp (g_config_data->param.type, IP_MODULE_TYPE_IP) == 0)
- {
- struct container_ip *container =
- parse_container_ip_json (g_config_data->json_buff);
- if (container)
- {
- return process_post ((void *) container, IP_MODULE_IP,
- IP_MODULE_OPERATE_ADD);
- }
- else
- {
- NSOPR_LOGERR ("Invalid IP config data!");
- NSOPR_SET_ERRINFO (NSCRTL_INPUT_ERR, "Invalid IP config data!");
- return -1;
- }
- }
- else if (strcmp (g_config_data->param.type, IP_MODULE_TYPE_NETWORK) == 0)
- {
- struct network_configuration *network = NULL;
-
- //Read network.json
-
- /* input shouldnot be same with return */
- network = parse_network_json (g_config_data->json_buff, NULL);
- if (!network)
- {
- NSOPR_LOGERR ("Invalid network data!");
- NSOPR_SET_ERRINFO (NSCRTL_INPUT_ERR, "Invalid network data!");
- return -1;
- }
-
- /* run process_post for each network, not only the head node */
- while (network)
- {
- tmp = network;
- network = network->next;
- int ret = process_post ((void *) tmp, IP_MODULE_NETWORK,
- IP_MODULE_OPERATE_ADD);
- if (ret == -1)
- {
- NSOPR_LOGERR ("process_configuration failed!");
- return -1;
- }
- }
- return 0;
- }
- else
- {
- NSOPR_SET_ERRINFO (NSCRTL_INPUT_ERR, "input error!");
- return -1;
- }
-}
-
-int
-read_ipmoduleoperatedel_configuration ()
-{
- int retval;
-
- if (strcmp (g_config_data->param.type, IP_MODULE_TYPE_IP) == 0)
- {
- struct ip_action_param *p = malloc (sizeof (struct ip_action_param));
- if (NULL == p)
- {
- NSOPR_LOGERR ("ip_action_param allocation failed!");
- NSOPR_SET_ERRINFO (NSCRTL_ERR, "mem alloc error!");
- return -1;
- }
-
- retval =
- MEMSET_S (p, sizeof (struct ip_action_param), 0,
- sizeof (struct ip_action_param));
- if (EOK != retval)
- {
- NSOPR_LOGERR ("MEMSET_S failed]ret=%d", retval);
- NSOPR_SET_ERRINFO (NSCRTL_ERR, "MEMSET_S error!");
- free (p);
- return -1;
- }
-
- retval =
- STRCPY_S (p->container_id, sizeof (p->container_id),
- g_config_data->param.container_id);
- if (EOK != retval)
- {
- NSOPR_LOGERR ("STRCPY_S failed]ret=%d", retval);
- NSOPR_SET_ERRINFO (NSCRTL_ERR, "STRCPY_S error!");
- free (p);
- return -1;
- }
-
- retval =
- STRCPY_S (p->port_name, sizeof (p->port_name),
- g_config_data->param.name);
- if (EOK != retval)
- {
- NSOPR_LOGERR ("STRCPY_S failed]ret=%d", retval);
- NSOPR_SET_ERRINFO (NSCRTL_ERR, "STRCPY_S error!");
- free (p);
- return -1;
- }
-
- return process_post ((void *) p, IP_MODULE_IP, IP_MODULE_OPERATE_DEL);
- }
- else if (strcmp (g_config_data->param.type, IP_MODULE_TYPE_NETWORK) == 0)
- {
- char *name = malloc (sizeof (g_config_data->param.name));
- if (name == NULL)
- {
- NSOPR_LOGERR ("name allocation failed!");
- NSOPR_SET_ERRINFO (NSCRTL_ERR, "mem alloc error!");
- return -1;
- }
-
- retval =
- MEMSET_S (name, sizeof (g_config_data->param.name), 0,
- sizeof (g_config_data->param.name));
- if (EOK != retval)
- {
- NSOPR_LOGERR ("MEMSET_S failed]ret=%d", retval);
- NSOPR_SET_ERRINFO (NSCRTL_ERR, "MEMSET_S error!");
- free (name);
- return -1;
- }
-
- retval =
- STRCPY_S (name, sizeof (g_config_data->param.name),
- g_config_data->param.name);
- if (EOK != retval)
- {
- NSOPR_LOGERR ("STRCPY_S failed]ret=%d", retval);
- NSOPR_SET_ERRINFO (NSCRTL_ERR, "STRCPY_S error!");
- free (name);
- return -1;
- }
-
- return process_post ((void *) name, IP_MODULE_NETWORK,
- IP_MODULE_OPERATE_DEL);
- }
- else
- {
- NSOPR_SET_ERRINFO (NSCRTL_INPUT_ERR, "input error!");
- return -1;
- }
-}
-
-NSTACK_STATIC int
-read_configuration ()
-{
- int retval = -1;
- //u64 traceid = 0;
-
- /* initialise default memory */
- g_config_data->param.error = NSCRTL_OK;
-
- /* Make sure error_desc is inited to null string */
- g_config_data->param.error_desc[0] = '\0';
-
- //traceid = g_config_data->param.traceid;
-
- NSOPR_LOGINF
- ("g_config_data]type=%s,name=%s,value=%s,container_id=%s,action=%d,Json_buf=%s, traceid=%llu",
- g_config_data->param.type, g_config_data->param.name,
- g_config_data->param.value, g_config_data->param.container_id,
- g_config_data->param.action, g_config_data->json_buff,
- g_config_data->param.traceid);
-
- retval =
- MEMSET_S (g_config_data->param.error_desc,
- sizeof (g_config_data->param.error_desc), 0,
- sizeof (g_config_data->param.error_desc));
- if (0 != retval)
- {
- NSOPR_SET_ERRINFO (NSCRTL_ERR, "ERR:internal error, MEMSET_S failed]");
- return -1;
- }
-
- switch (g_config_data->param.action)
- {
- case IP_MODULE_OPERATE_DEL:
- {
- retval = read_ipmoduleoperatedel_configuration ();
- break;
- }
- case IP_MODULE_OPERATE_QUERY:
- {
- retval = process_query ();
- break;
- }
- case IP_MODULE_OPERATE_ADD:
- {
- retval = read_ipmoduleoperateadd_configuration ();
- break;
- }
- case IP_MODULE_OPERATE_SET:
- retval = read_ipmoduleoperatesetnet_configuration ();
- break;
- case IP_MODULE_GET_VERSION:
- {
- retval = read_version ();
- break;
- }
-
- default:
- {
- retval = -1; //here, must set retval to -1
- NSOPR_SET_ERRINFO (NSCRTL_INPUT_ERR, "input error!");
- break;
- }
- }
-
- return retval;
-}
-
-NSTACK_STATIC int
-unix_socket_listen (const char *servername)
-{
- int fd, retval;
- unsigned int len;
- struct stat st;
- struct sockaddr_un un;
-
- if (stat (ip_module_unix_socket_dir_path, &st) == 0)
- {
- NSOPR_LOGDBG (" /directory is present");
- }
- else
- {
- NSOPR_LOGERR (" /var/run/nStack/ directory is not present ");
- return (-1);
- }
-
- if ((fd = nsfw_base_socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
- {
- return -1;
- }
-
- retval = unlink (servername); /* in case it already exists */
- if (0 != retval)
- {
- NSOPR_LOGWAR ("unlink failed]retval=%d,errno=%d", retval, errno);
- }
-
- retval = MEMSET_S (&un, sizeof (un), 0, sizeof (un));
- if (EOK != retval)
- {
- (void) nsfw_base_close (fd);
- NSOPR_LOGERR ("MEMSET_S failed]ret=%d", retval);
- return -1;
- }
-
- un.sun_family = AF_UNIX;
- retval = STRCPY_S (un.sun_path, sizeof (un.sun_path), servername);
- if (EOK != retval)
- {
- (void) nsfw_base_close (fd);
- NSOPR_LOGERR ("STRCPY_S failed]ret=%d", retval);
- return -1;
- }
-
- len =
- (unsigned int) (offsetof (struct sockaddr_un, sun_path) +
- strlen (servername));
-
- if (nsfw_base_bind (fd, (struct sockaddr *) &un, len) < 0)
- {
- (void) nsfw_base_close (fd);
- return -1;
- }
- else
- {
- if (nsfw_base_listen (fd, MAX_CONNECTION_NUMBER) < 0)
- {
- (void) nsfw_base_close (fd);
- return -1;
- }
- else
- {
- return fd;
- }
- }
-}
-
-/*****************************************************************************
-* Prototype : read_fn
-* Description : process new ip module msg
-* Input : i32 fd
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-void
-read_fn (i32 fd)
-{
- ssize_t size;
- ssize_t offset = 0;
- size_t left = MAX_IP_MODULE_BUFF_SIZE;
- while (left > 0)
- {
- size = nsfw_base_recv (fd, (char *) g_config_data + offset, left, 0);
- if (size > 0)
- {
- offset += size;
- left -= (size_t) size;
- }
- else
- {
- NSOPR_LOGERR ("Error when recieving]errno=%d,err_string=%s", errno,
- strerror (errno));
- break;
- }
- }
-
- if (left != 0)
- {
- (void) nsfw_base_close (fd);
- return;
- }
-
- (void) read_configuration (); // if it returns -1, the err desc info will be wrote to g_config_data, so no need to check return value.
-
- offset = 0;
- left = MAX_IP_MODULE_BUFF_SIZE;
- while (left > 0)
- {
- size =
- nsfw_base_send (fd, (char *) g_config_data + offset, left,
- MSG_NOSIGNAL);
-
- if (size > 0)
- {
- offset += size;
- left -= (size_t) size;
- }
- else
- {
- NSOPR_LOGERR ("Error when Sending data]errno=%d", errno);
- break;
- }
- }
-
- (void) nsfw_base_close (fd);
- return;
-}
-
-/*****************************************************************************
-* Prototype : ip_module_new_msg
-* Description : recv new config message
-* Input : i32 epfd
-* i32 fd
-* u32 events
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-ip_module_new_msg (i32 epfd, i32 fd, u32 events)
-{
- if ((events & EPOLLERR) || (events & EPOLLHUP) || (!(events & EPOLLIN)))
- {
- nsfw_mgr_unreg_sock_fun (fd);
- (void) nsfw_base_close (fd);
- return TRUE;
- }
-
- nsfw_mgr_unreg_sock_fun (fd);
- read_fn (fd);
- return TRUE;
-}
-
-int
-init_ip_module_unix_socket_path ()
-{
- const char *directory = "/var/log/nStack";
- const char *home_dir = getenv ("HOME");
-
- if (getuid () != 0 && home_dir != NULL)
- directory = home_dir;
-
- if (STRCPY_S
- (ip_module_unix_socket_dir_path, IP_MODULE_MAX_PATH_LEN, directory) < 0)
- {
- NSOPR_LOGERR ("STRCPY_S fail]");
- return -1;
- }
-
- if (STRCAT_S
- (ip_module_unix_socket_dir_path, IP_MODULE_MAX_PATH_LEN,
- "/ip_module") < 0)
- {
- NSOPR_LOGERR ("STRCAT_S fail]");
- return -1;
- }
-
- if (STRCPY_S
- (ip_module_unix_socket, IP_MODULE_MAX_PATH_LEN,
- ip_module_unix_socket_dir_path) < 0)
- {
- NSOPR_LOGERR ("STRCPY_S fail]");
- return -1;
- }
-
- if (STRCAT_S
- (ip_module_unix_socket, IP_MODULE_MAX_PATH_LEN,
- "/ip_module_unix_sock") < 0)
- {
- NSOPR_LOGERR ("STRCAT_S fail]");
- return -1;
- }
-
- NSOPR_LOGINF ("ip_module_unix_socket=%s", ip_module_unix_socket);
- NSOPR_LOGINF ("ip_module_unix_socket_dir_path=%s",
- ip_module_unix_socket_dir_path);
- return 0;
-}
-
-/*****************************************************************************
-* Prototype : ip_module_new_connection
-* Description : recv new connect for network config
-* Input : i32 epfd
-* i32 fd
-* u32 events
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-ip_module_new_connection (i32 epfd, i32 fd, u32 events)
-{
- if ((events & EPOLLERR) || (events & EPOLLHUP) || (!(events & EPOLLIN)))
- {
- (void) nsfw_base_close (fd);
- NSFW_LOGINF ("listen disconnect!]epfd=%d,listen=%d,event=0x%x", epfd,
- fd, events);
- nsfw_mgr_unreg_sock_fun (fd);
-
- if (init_ip_module_unix_socket_path () < 0)
- {
- NSFW_LOGERR ("Error when init path]epfd=%d,listen_fd=%d,event=0x%x",
- epfd, fd, events);
- return FALSE;
- }
-
- i32 listen_fd = unix_socket_listen (ip_module_unix_socket);
- if (listen_fd < 0)
- {
- NSFW_LOGERR ("get listen_fd faied!]epfd=%d,listen_fd=%d,event=0x%x",
- epfd, fd, events);
- return FALSE;
- }
-
- if (FALSE ==
- nsfw_mgr_reg_sock_fun (listen_fd, ip_module_new_connection))
- {
- (void) nsfw_base_close (listen_fd);
- return FALSE;
- }
- return TRUE;
- }
-
- struct sockaddr in_addr;
- socklen_t in_len;
- int infd;
- in_len = sizeof in_addr;
-
- while (1)
- {
- infd = nsfw_base_accept (fd, &in_addr, &in_len);
- if (infd == -1)
- {
- break;
- }
-
- if (FALSE == nsfw_mgr_reg_sock_fun (infd, ip_module_new_msg))
- {
- NSFW_LOGINF ("accept new fd but reg failed]new_mgr_fd=%d", infd);
- return FALSE;
- }
- NSFW_LOGINF ("accept new fd]new_mgr_fd=%d", infd);
- }
-
- return TRUE;
-}
-
-int
-init_configuration_reader ()
-{
- int error_number = 0;
- INITPOL_LOGINF ("CONFIGURATION", "init_configuration_reader", NULL_STRING,
- LOG_INVALID_VALUE, MODULE_INIT_START);
- g_config_data = &g_ip_module_buff;
-
- if (init_ip_module_unix_socket_path () < 0)
- {
- INITPOL_LOGERR ("CONFIGURATION", "init_configuration_reader",
- "Error when init path", LOG_INVALID_VALUE,
- MODULE_INIT_FAIL);
- return -1;
- }
-
- i32 listen_fd = unix_socket_listen (ip_module_unix_socket);
- if (listen_fd < 0)
- {
- error_number = errno;
- INITPOL_LOGERR ("CONFIGURATION", "init_configuration_reader",
- "when listening ip_module_unix_socket", error_number,
- MODULE_INIT_FAIL);
- return -1;
- }
-
- NSOPR_LOGINF ("start mgr_com module!]listern_fd=%d", listen_fd);
-
- if (FALSE == nsfw_mgr_reg_sock_fun (listen_fd, ip_module_new_connection))
- {
- (void) nsfw_base_close (listen_fd);
- NSOPR_LOGERR ("nsfw_mgr_reg_sock_fun failed]listen_fd=%d", listen_fd);
- return -1;
- }
-
- INITPOL_LOGINF ("CONFIGURATION", "init_configuration_reader", NULL_STRING,
- LOG_INVALID_VALUE, MODULE_INIT_SUCCESS);
- return 0;
-}
-
-struct config_data *
-get_config_data ()
-{
- return g_config_data;
-}
diff --git a/stacks/lwip_stack/lwip_src/ip_module/container_ip.c b/stacks/lwip_stack/lwip_src/ip_module/container_ip.c
deleted file mode 100644
index 52f7c64..0000000
--- a/stacks/lwip_stack/lwip_src/ip_module/container_ip.c
+++ /dev/null
@@ -1,1132 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <limits.h>
-#include <string.h>
-#include "lwip/inet.h"
-#include "trp_rb_tree.h"
-#include "container_ip.h"
-#include "network.h"
-#include "netif.h"
-#include "nstack_log.h"
-#include "nstack_securec.h"
-#include "config_common.h"
-#include "igmp.h"
-#include "spl_def.h"
-#include "stackx_ip_addr.h"
-#include "hal_api.h"
-#include "spl_hal.h"
-
-struct container_list g_container_list = { 0 };
-static trp_rb_root_t g_container_ip_root = { 0 }; //only handled in tcpip thread, no need protect it with a lock
-static trp_rb_root_t g_container_multicast_root = { 0 }; //only handled in tcpip thread, no need protect it with a lock
-
-static void free_container_port (struct container_port *port,
- bool_t only_free);
-
-/*unsigned int value is typecasted into void * pointer and passed as argument to
-this function. so the value can never be > 0xFFFFFFFF. so can suppress the warning*/
-
-static int
-ip_compare (trp_key_t left, trp_key_t right)
-{
- //return (int)((unsigned long)left - (unsigned long)right);
-
- if (left > right)
- {
- return 1;
- }
- else if (left < right)
- {
- return -1;
- }
- else
- {
- return 0;
- }
-}
-
-NSTACK_STATIC bool_t
-is_container_ok (struct container_ip * container)
-{
- if (!container->ports_list)
- {
- return 0;
- }
-
- return 1;
-}
-
-NSTACK_STATIC void
-add_port (struct container_ip *container, struct container_port *port)
-{
- if (port->ip_cidr_list)
- {
- port->next = container->ports_list;
- container->ports_list = port;
- }
- else
- {
- free_container_port (port, IP_MODULE_TRUE);
- }
-}
-
-static void
-add_ip_cidr (struct container_port *port,
- struct container_port_ip_cidr *ip_cidr)
-{
- if (!ip_cidr)
- {
- return;
- }
-
- ip_cidr->next = port->ip_cidr_list;
- port->ip_cidr_list = ip_cidr;
- return;
-}
-
-NSTACK_STATIC void
-add_multilcast_ip (struct container_port *port,
- struct container_multicast_id *muticastIP)
-{
- if (!muticastIP)
- {
- return;
- }
-
- muticastIP->next = port->multicast_list;
- port->multicast_list = muticastIP;
- return;
-}
-
-NSTACK_STATIC void
-free_container_port_ip_cidr (struct container_port_ip_cidr *ip_cidr,
- bool_t only_free)
-{
- output_api *api = get_output_api ();
- struct container_port_ip_cidr *ip_cidr_tmp = NULL;
-
- while (ip_cidr)
- {
- ip_cidr_tmp = ip_cidr;
- ip_cidr = ip_cidr_tmp->next;
- if (!only_free)
- {
- if (api->del_netif_ip)
- {
- struct network_configuration *network =
- get_network_by_ip_with_tree (ip_cidr_tmp->ip);
- if (network)
- {
- if (network->phy_net->bond_name[0] != 0)
- {
- (void) api->del_netif_ip (network->phy_net->bond_name, ip_cidr_tmp->ip); //fails only when netif_name not exist, no side effect so don't check return value.
- }
- else
- {
- (void) api->del_netif_ip (network->phy_net->
- header->nic_name,
- ip_cidr_tmp->ip);
- }
- }
- else
- {
- NSOPR_LOGERR ("can't find network by]IP=%u",
- ip_cidr_tmp->ip);
- }
- }
-
- trp_rb_erase ((void *) (u64_t) ip_cidr_tmp->ip,
- &g_container_ip_root, ip_compare);
- }
-
- free (ip_cidr_tmp);
- ip_cidr_tmp = NULL;
- }
-}
-
-static void
-free_container_multicast (struct container_multicast_id *multicast,
- bool_t only_free)
-{
- struct container_multicast_id *tmp = NULL;
-
- while (multicast)
- {
- tmp = multicast;
- multicast = multicast->next;
- if (!only_free)
- {
- trp_rb_erase ((void *) (u64_t) tmp->ip, &g_container_multicast_root,
- ip_compare);
- }
-
- free (tmp);
- tmp = NULL;
- }
-}
-
-static void
-free_container_port (struct container_port *port, bool_t only_free)
-{
- struct container_port *port_tmp = NULL;
- struct container_port *port_curr = port;
-
- while (port_curr)
- {
- port_tmp = port_curr;
- port_curr = port_tmp->next;
-
- free_container_multicast (port_tmp->multicast_list, only_free);
- free_container_port_ip_cidr (port_tmp->ip_cidr_list, only_free);
-
- if (port_tmp->buffer)
- {
- free_port_buffer (port_tmp->buffer);
- port_tmp->buffer = NULL;
- }
-
- free (port_tmp);
- port_tmp = NULL;
- }
-}
-
-void
-free_container (struct container_ip *container, bool_t only_free)
-{
- struct container_ip *container_tmp = NULL;
- struct container_ip *container_curr = container;
-
- while (container_curr)
- {
- container_tmp = container_curr;
- container_curr = container_tmp->next;
- if (container_tmp->ports_list)
- {
- free_container_port (container_tmp->ports_list, only_free);
- }
-
- free (container_tmp);
- container_tmp = NULL;
- }
-}
-
-struct container_port *
-parse_port_obj (struct json_object *port_obj)
-{
- int retval;
- struct json_object *port_name_obj = NULL;
- struct json_object *ip_cidr_list_obj = NULL;
- struct json_object *mcIDObj = NULL;
-
- if (!port_obj)
- {
- NSOPR_LOGERR ("port_obj is null");
- return NULL;
- }
-
- struct container_port *port = malloc (sizeof (struct container_port));
- if (!port)
- {
- NSOPR_LOGERR ("malloc failed");
- return NULL;
- }
-
- retval =
- MEMSET_S (port, sizeof (struct container_port), 0,
- sizeof (struct container_port));
- if (EOK != retval)
- {
- NSOPR_LOGERR ("MEMSET_S failed]ret=%d", retval);
- free (port);
- return NULL;
- }
-
- json_object_object_get_ex (port_obj, "port_name", &port_name_obj);
- if (port_name_obj)
- {
- const char *port_name = json_object_get_string (port_name_obj);
- if ((NULL == port_name)
- || (strlen (port_name) >= IP_MODULE_MAX_NAME_LEN))
- {
- NSOPR_LOGERR ("port name is not ok");
- goto RETURN_ERROR;
- }
-
- retval =
- STRCPY_S (port->port_name, sizeof (port->port_name), port_name);
-
- if (EOK != retval)
- {
- NSOPR_LOGERR ("STRCPY_S failed]ret=%d", retval);
- goto RETURN_ERROR;
- }
- }
-
- json_object_object_get_ex (port_obj, "ip_cidr", &ip_cidr_list_obj);
- if (ip_cidr_list_obj)
- {
- int j;
- int ip_cidr_num = json_object_array_length (ip_cidr_list_obj);
- for (j = 0; j < ip_cidr_num; ++j)
- {
- struct json_object *ip_cidr_obj =
- json_object_array_get_idx (ip_cidr_list_obj, j);
- if (ip_cidr_obj)
- {
- char tmp[IP_MODULE_LENGTH_32] = { 0 };
- struct container_port_ip_cidr *port_ip_cidr =
- malloc (sizeof (struct container_port_ip_cidr));
- if (NULL == port_ip_cidr)
- {
- NSOPR_LOGERR ("malloc failed");
- goto RETURN_ERROR;
- }
-
- retval =
- MEMSET_S (port_ip_cidr,
- sizeof (struct container_port_ip_cidr), 0,
- sizeof (struct container_port_ip_cidr));
- if (EOK != retval)
- {
- NSOPR_LOGERR ("MEMSET_S failed]ret=%d", retval);
- free (port_ip_cidr);
- port_ip_cidr = NULL;
- goto RETURN_ERROR;
- }
-
- const char *ip_cidr = json_object_get_string (ip_cidr_obj);
- if ((NULL == ip_cidr) || (ip_cidr[0] == 0))
- {
- NSOPR_LOGERR ("ip_cidr is not ok");
- free (port_ip_cidr);
- port_ip_cidr = NULL;
- goto RETURN_ERROR;
- }
-
- const char *sub = strstr (ip_cidr, "/");
- if ((NULL == sub)
- || (sizeof (tmp) - 1 < (unsigned int) (sub - ip_cidr))
- || (strlen (sub) > sizeof (tmp) - 1))
- {
- NSOPR_LOGERR
- ("Error : Ipaddress notation must be in ip cidr notation!");
- free (port_ip_cidr);
- port_ip_cidr = NULL;
- goto RETURN_ERROR;
- }
-
- retval =
- STRNCPY_S (tmp, sizeof (tmp), ip_cidr,
- (size_t) (sub - ip_cidr));
- if (EOK != retval)
- {
- NSOPR_LOGERR ("STRNCPY_S failed]ret=%d", retval);
- free (port_ip_cidr);
- port_ip_cidr = NULL;
- goto RETURN_ERROR;
- }
-
- struct in_addr addr;
- int iRet;
- retval = MEMSET_S (&addr, sizeof (addr), 0, sizeof (addr));
- if (EOK != retval)
- {
- NSOPR_LOGERR ("MEMSET_S failed]ret=%d", retval);
- free (port_ip_cidr);
- port_ip_cidr = NULL;
- goto RETURN_ERROR;
- }
-
- iRet = spl_inet_aton (tmp, &addr);
- if (0 == iRet)
- {
- NSOPR_LOGERR ("spl_inet_aton failed");
- free (port_ip_cidr);
- port_ip_cidr = NULL;
- goto RETURN_ERROR;
- }
-
- port_ip_cidr->ip = addr.s_addr;
- iRet = atoi (sub + 1);
- if ((iRet <= 0) || (iRet > IP_MODULE_LENGTH_32))
- {
- NSOPR_LOGERR ("IP mask length is not correct");
- free (port_ip_cidr);
- port_ip_cidr = NULL;
- goto RETURN_ERROR;
- }
-
- port_ip_cidr->mask_len = (unsigned int) iRet;
- add_ip_cidr (port, port_ip_cidr);
- }
- }
- }
-
- json_object_object_get_ex (port_obj, "multicast_id", &mcIDObj);
- if (mcIDObj)
- {
- int j;
- int arrLen = json_object_array_length (mcIDObj);
- if (0 == arrLen)
- {
- NSOPR_LOGERR ("arrLen is 0");
- goto RETURN_ERROR;
- }
-
- for (j = 0; j < arrLen; ++j)
- {
- struct json_object *elemObj =
- json_object_array_get_idx (mcIDObj, j);
-
- if (elemObj)
- {
- struct json_object *tObj = NULL;
- const char *tStr;
- int ret;
- struct in_addr addr;
-
- struct container_multicast_id *mcID =
- malloc (sizeof (struct container_multicast_id));
- if (NULL == mcID)
- {
- NSOPR_LOGERR ("Can't alloc container multicast id");
- goto RETURN_ERROR;
- }
-
- json_object_object_get_ex (elemObj, "group_ip", &tObj);
- if (NULL == tObj)
- {
- NSOPR_LOGERR ("No group_IP");
- free (mcID);
- mcID = NULL;
- goto RETURN_ERROR;
- }
-
- tStr = json_object_get_string (tObj);
- if (NULL == tStr)
- {
- NSOPR_LOGERR ("Get Multiple cast group IP Failed");
- free (mcID);
- mcID = NULL;
- goto RETURN_ERROR;
- }
-
- ret = spl_inet_aton (tStr, &addr);
- if (0 == ret)
- {
- NSOPR_LOGERR ("Parse group IP Failed");
- free (mcID);
- mcID = NULL;
- goto RETURN_ERROR;
- }
-
- mcID->ip = addr.s_addr;
- add_multilcast_ip (port, mcID);
- }
- }
- }
-
- const char *port_json = json_object_get_string (port_obj);
- if ((NULL == port_json) || (0 == strlen (port_json)))
- {
- NSOPR_LOGERR ("json_object_get_string failed");
- goto RETURN_ERROR;
- }
-
- port->buffer = malloc_port_buffer ();
- if (!port->buffer)
- {
- goto RETURN_ERROR;
- }
-
- retval =
- STRCPY_S (get_port_json (port), IP_MODULE_PORT_JSON_LEN, port_json);
- if (EOK != retval)
- {
- NSOPR_LOGERR ("STRCPY_S failed]ret=%d", retval);
- goto RETURN_ERROR;
- }
-
- return port;
-RETURN_ERROR:
- free_container_port (port, IP_MODULE_TRUE);
- return NULL;
-}
-
-struct container_ip *
-parse_container_ip_json (char *param)
-{
- int retval;
- struct json_object *obj = json_tokener_parse (param);
- struct json_object *container_id_obj = NULL;
- struct json_object *ports_list_obj = NULL;
-
- if (!obj)
- {
- return NULL;
- }
-
- struct container_ip *container = malloc (sizeof (struct container_ip));
- if (container == NULL)
- {
- json_object_put (obj);
- return NULL;
- }
-
- retval =
- MEMSET_S (container, sizeof (struct container_ip), 0,
- sizeof (struct container_ip));
- if (EOK != retval)
- {
- NSOPR_LOGERR ("MEMSET_S failed]ret=%d", retval);
- goto RETURN_ERROR;
- }
-
- json_object_object_get_ex (obj, "containerID", &container_id_obj);
- if (container_id_obj)
- {
- const char *container_id = json_object_get_string (container_id_obj);
- if ((container_id == NULL) || (container_id[0] == 0)
- || (strlen (container_id) >= IP_MODULE_MAX_NAME_LEN))
- {
- goto RETURN_ERROR;
- }
-
- retval =
- MEMSET_S (container->container_id, sizeof (container->container_id),
- 0, sizeof (container->container_id));
- if (EOK != retval)
- {
- NSOPR_LOGERR ("MEMSET_S failed]ret=%d", retval);
- goto RETURN_ERROR;
- }
-
- retval =
- STRCPY_S (container->container_id, sizeof (container->container_id),
- container_id);
-
- if (EOK != retval)
- {
- NSOPR_LOGERR ("STRCPY_S failed]ret=%d", retval);
- goto RETURN_ERROR;
- }
- }
- else
- {
- /* this mandatory parameter */
- NSOPR_LOGWAR ("json_object_object_get_ex containerID failed");
- }
-
- json_object_object_get_ex (obj, "ports_list", &ports_list_obj);
- if (ports_list_obj)
- {
- int i;
- int port_num = json_object_array_length (ports_list_obj);
-
- if (port_num == 0)
- {
- /* this mandatory parameter */
- goto RETURN_ERROR;
- }
-
- for (i = 0; i < port_num; i++)
- {
- struct json_object *port_obj =
- json_object_array_get_idx (ports_list_obj, i);
- struct container_port *port = parse_port_obj (port_obj);
- if (!port)
- {
- goto RETURN_ERROR;
- }
-
- add_port (container, port);
- }
- }
- else
- {
- /* mandatory parameter */
- goto RETURN_ERROR;
- }
-
- /* Check if this function is required, or needs more check inside this function,
- as some of them are alraedy validated
- */
- if (!is_container_ok (container))
- {
- goto RETURN_ERROR;
- }
-
- json_object_put (obj);
- return container;
-
-RETURN_ERROR:
- json_object_put (obj);
- free_container (container, IP_MODULE_TRUE);
- return NULL;
-}
-
-bool_t
-is_ip_match_netif (unsigned int ip, char *netif_name)
-{
- if (!netif_name)
- {
- return 0;
- }
-
- if (trp_rb_search ((void *) (u64_t) ip, &g_container_ip_root, ip_compare))
- {
- struct network_configuration *network =
- get_network_by_ip_with_tree (ip);
- if (network && network->phy_net && network->phy_net->header)
- {
- if (0 ==
- strncmp (netif_name, network->phy_net->header->nic_name,
- HAL_MAX_NIC_NAME_LEN))
- {
- return 1;
- }
- }
- }
-
- return 0;
-}
-
-inline bool_t
-is_ip_exist (unsigned int ip)
-{
- if (trp_rb_search ((void *) (u64_t) ip, &g_container_ip_root, ip_compare))
- {
- return 1;
- }
-
- return 0;
-}
-
-int
-validate_addcontainerconfig (struct container_ip *container)
-{
- struct container_port *port;
- struct container_ip *old =
- get_container_by_container_id (container->container_id);
- struct container_port *tmp = container->ports_list;
-
- if (old)
- {
- struct container_port *last = NULL;
-
- while (tmp)
- {
- if (get_port (container->container_id, tmp->port_name))
- {
- NSOPR_LOGERR ("port=%s already exists!", tmp->port_name);
- return NSCRTL_RD_EXIST;
- }
-
- last = tmp;
- tmp = tmp->next;
- }
-
- (void) last;
- }
-
- /* check if port_name duplicates in one json configuration */
- tmp = container->ports_list;
- while (tmp)
- {
- if (get_port_from_container (tmp))
- {
- NSOPR_LOGERR ("port=%s duplicates!", tmp->port_name);
- return NSCRTL_RD_EXIST;
- }
-
- tmp = tmp->next;
- }
-
- bool_t is_nstack_dpdk_port;
- struct container_port **ref = &container->ports_list;
- while ((port = *ref))
- {
- is_nstack_dpdk_port = 1;
- struct container_port_ip_cidr *ip_cidr = port->ip_cidr_list;
- while (ip_cidr)
- {
- struct network_configuration *network =
- get_network_by_ip_with_tree (ip_cidr->ip);
- if (network && (0 == strcmp (network->type_name, "nstack-dpdk")))
- {
- struct netif *pnetif;
- if (get_netif_by_ip (ip_cidr->ip))
- {
- NSOPR_LOGERR ("ip exists]IP=0x%08x", ip_cidr->ip);
- return NSCRTL_RD_EXIST;
- }
-
- if (network->phy_net->bond_name[0] != 0)
- {
- pnetif =
- find_netif_by_if_name (network->phy_net->bond_name);
- }
- else
- {
- pnetif =
- find_netif_by_if_name (network->phy_net->
- header->nic_name);
- }
-
- if (!pnetif)
- {
- NSOPR_LOGERR ("can't find netif, network json:%s",
- get_network_json (network));
- return NSCRTL_ERR;
- }
-
- if (0 == port->port_name[0])
- {
- NSOPR_LOGINF
- ("ip=0x%08x is in nstack dpdk network, but port_name is null, json:%s",
- ip_cidr->ip, get_port_json (port));
- is_nstack_dpdk_port = 0;
- break;
- }
- }
- else
- {
- NSOPR_LOGINF ("port %s is not in nstack dpdk network, json:%s",
- port->port_name, get_port_json (port));
- is_nstack_dpdk_port = 0;
- break;
- }
-
- ip_cidr = ip_cidr->next;
- }
-
- /* only use nstack dpdk port */
- if (is_nstack_dpdk_port)
- {
- ref = &port->next;
- }
- else
- {
- *ref = port->next;
- port->next = NULL;
- free_container_port (port, IP_MODULE_TRUE);
- }
- }
-
- return (!container->ports_list) ? NSCRTL_FREE_ALL_PORT : NSCRTL_OK;
-}
-
-/* get the num of IPs in a container , which in a certain subnet */
-extern struct network_list g_network_list;
-extern inline int is_in_subnet (unsigned int ip, struct ip_subnet *subnet);
-NSTACK_STATIC inline int get_network_ip_count
- (struct container_ip *container, struct ip_subnet *subnet)
-{
- int ip_count = 0;
- struct container_port *port_list = NULL;
- struct container_ip *ci = container;
-
- while (ci)
- {
- port_list = ci->ports_list;
- while (port_list)
- {
- struct container_port_ip_cidr *ip_list = port_list->ip_cidr_list;
- while (ip_list)
- {
- if (!is_in_subnet (ip_list->ip, subnet))
- {
- ip_count++;
- }
-
- ip_list = ip_list->next;
- }
-
- port_list = port_list->next;
- }
-
- ci = ci->next;
- }
-
- return ip_count;
-}
-
-int
-check_ip_count (struct container_ip *container)
-{
- int cur_count = 0;
- int new_count = 0;
-
- if (NULL == container)
- {
- return 1;
- }
-
- struct network_configuration *network = g_network_list.header;
- while (network)
- {
- cur_count =
- get_network_ip_count (g_container_list.header, network->ip_subnet);
- new_count = get_network_ip_count (container, network->ip_subnet);
-
- if ((cur_count > MAX_NETWORK_IP_COUNT)
- || (new_count > MAX_NETWORK_IP_COUNT)
- || (cur_count + new_count > MAX_NETWORK_IP_COUNT))
- {
- NSOPR_LOGERR
- ("reach ip addr max count]network=%s, max=%d, current=%d, new=%d.",
- network->network_name, MAX_NETWORK_IP_COUNT, cur_count,
- new_count);
- return 0;
- }
-
- network = network->next;
- }
-
- return 1;
-}
-
-int
-match_groupaddr (struct container_multicast_id *multi_list,
- spl_ip_addr_t * groupaddr)
-{
- struct container_multicast_id *group_info = multi_list;
-
- while (group_info)
- {
- if (group_info->ip == groupaddr->addr)
- {
- return 1;
- }
-
- group_info = group_info->next;
- }
-
- return 0;
-}
-
-int
-add_container (struct container_ip *container)
-{
- int retVal = 0;
-
- /* need to check if any of the netif operation failed, then we should return fail */
- retVal = validate_addcontainerconfig (container);
- if (retVal != NSCRTL_OK)
- {
- free_container (container, IP_MODULE_TRUE);
- return (NSCRTL_FREE_ALL_PORT == retVal) ? NSCRTL_OK : retVal;
- }
-
- /* control max network and ipaddress count */
- if (!check_ip_count (container))
- {
- free_container (container, IP_MODULE_TRUE);
- return NSCRTL_IP_COUNT_EXCEED;
- }
-
- struct container_port *last = NULL;
- struct container_ip *old =
- get_container_by_container_id (container->container_id);
- if (old)
- {
- struct container_port *tmp = container->ports_list;
- while (tmp)
- {
- /* here we don't need to check "if tmp->port_name == NULL", as validate_addcontainerconfig() has done this. */
- if (get_port (container->container_id, tmp->port_name))
- {
- free_container (container, IP_MODULE_TRUE);
- NSOPR_LOGERR ("port exist!");
- return NSCRTL_RD_EXIST;
- }
-
- last = tmp;
- tmp = tmp->next;
- }
- }
- else
- {
- container->next = g_container_list.header;
- g_container_list.header = container;
- }
-
- output_api *api = get_output_api ();
- struct container_port *port = container->ports_list;
- while (port)
- {
- struct container_port_ip_cidr *ip_cidr = port->ip_cidr_list;
- while (ip_cidr)
- {
- if (api->add_netif_ip)
- {
- struct network_configuration *network =
- get_network_by_ip_with_tree (ip_cidr->ip);
- if (network)
- {
- unsigned int mask = ~0;
- mask =
- (mask << (IP_MODULE_SUBNET_MASK_LEN - ip_cidr->mask_len));
- mask = spl_htonl (mask);
- if (network->phy_net->bond_name[0] != 0)
- {
- (void) api->add_netif_ip (network->phy_net->bond_name, ip_cidr->ip, mask); //no need to check return value, validate_addcontainerconfig() has been checked parameters.
- }
- else
- {
- (void) api->add_netif_ip (network->phy_net->
- header->nic_name, ip_cidr->ip,
- mask);
- }
- }
- else
- {
- NSOPR_LOGERR ("can't find network by]IP=%u,port_name=%s",
- ip_cidr->ip, port->port_name);
- }
- }
-
- retVal =
- trp_rb_insert ((void *) (u64_t) ip_cidr->ip, (void *) port,
- &g_container_ip_root, ip_compare);
-
- if (0 != retVal)
- {
- NSOPR_LOGERR ("trp_rb_insert failed]ip_cidr->ip=%u",
- ip_cidr->ip);
- }
-
- ip_cidr = ip_cidr->next;
- }
- port = port->next;
- }
-
- if (old)
- {
- if (last)
- {
- last->next = old->ports_list;
- old->ports_list = container->ports_list;
- }
-
- container->ports_list = NULL;
- free_container (container, IP_MODULE_FALSE);
- }
-
- return NSCRTL_OK;
-}
-
-struct container_ip *
-get_container_by_container_id (char *container_id)
-{
- if (NULL == container_id)
- {
- NSOPR_LOGERR ("Param input container ID is NULL");
- return NULL;
- }
-
- struct container_ip *container = g_container_list.header;
- while (container)
- {
- if (0 == strcmp (container->container_id, container_id))
- {
- return container;
- }
-
- container = container->next;
- }
-
- return NULL;
-}
-
-/*****************************************************************************
-* Prototype : getIpCfgAll
-* Description : Get All ip configurations
-* Input : char *
-* size_t
-* Output : char * patern:[***,***,***]
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-getIpCfgAll (char *jsonBuf, size_t size)
-{
- int retval;
-
- if (NULL == jsonBuf)
- {
- return NSCRTL_ERR;
- }
-
- if (size < 2)
- {
- NSOPR_LOGERR ("get all ip cfg error, buffer is not enough.");
- return NSCRTL_STATUS_ERR;
- }
-
- char bfirstData = 1;
- *jsonBuf = '[';
- jsonBuf = jsonBuf + 1;
-
- /*need another two char to keep [and ] */
- size_t len = size - 2;
- size_t strsize = 0;
- struct container_port *port = NULL;
- struct container_ip *container = g_container_list.header;
- while (container)
- {
- port = container->ports_list;
- while (port)
- {
- if (NULL == port->buffer)
- {
- port = port->next;
- continue;
- }
-
- strsize = strlen (get_port_json (port)) + 1;
-
- /*always reserve 1 char */
- if ((strsize > 0) && (strsize < len))
- {
- if (bfirstData)
- {
- bfirstData = 0;
- }
- else
- {
- *jsonBuf = ',';
- jsonBuf = jsonBuf + 1;
- len = len - 1;
- }
-
- retval = STRCPY_S (jsonBuf, len, get_port_json (port));
- if (EOK != retval)
- {
- NSOPR_LOGERR ("STRCPY_S failed]ret=%d", retval);
- return NSCRTL_ERR;
- }
-
- len = len - strlen (get_port_json (port));
- jsonBuf = jsonBuf + strlen (get_port_json (port));
- }
- else
- {
- NSOPR_LOGERR ("get all ip cfg error, buffer is not enough.");
- return NSCRTL_STATUS_ERR;
- }
-
- port = port->next;
- }
-
- container = container->next;
- }
-
- *jsonBuf = ']';
- return 0;
-}
-
-int
-del_port (char *container_id, char *port_name)
-{
- struct container_port *port = NULL;
- struct container_port **ref = NULL;
- struct container_ip *container = NULL;
- struct container_ip **container_ref = &g_container_list.header;
-
- while ((container = *container_ref))
- {
- NSOPR_LOGDBG ("container->container_id=%s,container_id=%p",
- container->container_id, container_id);
- if (strcmp (container->container_id, container_id) == 0)
- {
- ref = &container->ports_list;
- while ((port = *ref))
- {
- if (strcmp (port_name, port->port_name) == 0)
- {
- *ref = port->next;
- port->next = NULL;
- free_container_port (port, IP_MODULE_FALSE);
- return 0;
- }
-
- ref = &port->next;
- }
-
- break;
- }
-
- container_ref = &container->next;
- }
-
- return NSCRTL_RD_NOT_EXIST;
-}
-
-struct container_port *
-get_port (char *container_id, char *port_name)
-{
- struct container_port *port = NULL;
- struct container_ip *container = g_container_list.header;
-
- while (container)
- {
- if (strcmp (container->container_id, container_id) == 0)
- {
- port = container->ports_list;
- while (port)
- {
- if (strcmp (port_name, port->port_name) == 0)
- {
- return port;
- }
-
- port = port->next;
- }
- }
-
- container = container->next;
- }
-
- return NULL;
-}
-
-struct container_port *
-get_port_from_container (struct container_port *port)
-{
- char *port_name = port->port_name;
- struct container_port *tmp = port->next;
-
- while (tmp)
- {
- if (strcmp (port_name, tmp->port_name) == 0)
- {
- return tmp;
- }
-
- tmp = tmp->next;
- }
-
- return NULL;
-}
diff --git a/stacks/lwip_stack/lwip_src/ip_module/ip_module_api.c b/stacks/lwip_stack/lwip_src/ip_module/ip_module_api.c
deleted file mode 100644
index 0ae61ed..0000000
--- a/stacks/lwip_stack/lwip_src/ip_module/ip_module_api.c
+++ /dev/null
@@ -1,347 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include <stdlib.h>
-#include <string.h>
-#include "inet.h"
-#include "spl_ip_addr.h"
-#include "ip_module_api.h"
-#include "container_ip.h"
-#include "network.h"
-#include "config_common.h"
-#include "configuration_reader.h"
-#include "nstack_log.h"
-#include "nstack_securec.h"
-#include "spl_hal.h"
-#include "stackx_spl_share.h"
-#include "stackx/spl_api.h"
-#include "stackx_common.h"
-#include "spl_tcpip.h"
-
-static output_api g_output_api = { 0 };
-
-void
-regist_output_api (output_api * api)
-{
- if (NULL == api)
- {
- NSOPR_LOGERR ("error!!!param api==NULL]");
- return;
- }
-
- g_output_api = *api;
-}
-
-output_api *
-get_output_api ()
-{
- return &g_output_api;
-}
-
-int
-process_post (void *arg, ip_module_type Type,
- ip_module_operate_type operate_type)
-{
- /* only when add network, in other words:
- only when (IP_MODULE_NETWORK == Type) && (IP_MODULE_OPERATE_ADD == operate_type),
- process_configuration() is called in read_fn thread itself.
- other cases, will post_to tcpip_thread to handle them.
-
- tips: when add network, it need to post msg(add netif) to tcpip thread and wait a sem,
- but after the msg is handled by tcpip thread, the sem could be post.
- so adding netword is handled in read_fn thread, can't be moved to tcpip thread.
-
- But we should know, many global and static variables maybe not safe(netif,sc_dpdk etc.),
- because they can be visited by multi-thread. */
- if ((IP_MODULE_NETWORK == Type) && (IP_MODULE_OPERATE_ADD == operate_type))
- {
- return process_configuration (arg, Type, operate_type);
- }
-
- if (g_output_api.post_to)
- {
- int retval = g_output_api.post_to (arg, Type, operate_type);
- if ((post_ip_module_msg == g_output_api.post_to) && (retval != ERR_OK)
- && (arg != NULL))
- {
- if ((IP_MODULE_IP == Type)
- && (IP_MODULE_OPERATE_ADD == operate_type))
- {
- free_container ((struct container_ip *) arg, IP_MODULE_TRUE);
- }
- else
- {
- free (arg);
- }
-
- arg = NULL;
- NSOPR_LOGERR ("post failed]ret=%d", retval);
- NSOPR_SET_ERRINFO (NSCRTL_INPUT_ERR, "process_post failed!");
- }
-
- return retval;
- }
- else
- {
- NSOPR_LOGERR ("g_output_api.post_to==NULL");
- NSOPR_SET_ERRINFO (NSCRTL_ERR,
- "ERR:internal error, g_output_api.post_to==NULL]");
- return -1;
- }
-}
-
-/* arg can be NULL, no need check */
-int
-process_configuration (void *arg, ip_module_type Type,
- ip_module_operate_type operate_type)
-{
- NSOPR_LOGINF ("precoess begin]arg=%p,action=%d,type=%d", arg, operate_type,
- Type);
- int retval = 0;
-
- switch (Type)
- {
- case IP_MODULE_NETWORK:
- switch (operate_type)
- {
- case IP_MODULE_OPERATE_ADD:
- retval =
- add_network_configuration ((struct network_configuration *) arg);
-
- /* When network exceeds max number, just log warning at operation.log */
- if (retval == NSCRTL_NETWORK_COUNT_EXCEED)
- {
- NSOPR_LOGWAR
- ("Warning!! Network count exceed max allowed number]max=%d",
- MAX_NETWORK_COUNT);
- }
- else
- {
- NSOPR_SET_ERRINFO (retval,
- "add_network_configuration return %d",
- retval);
- }
-
- if (!retval)
- {
- /*init DPDK eth */
- if ((retval = init_new_network_configuration ()) != ERR_OK)
- {
- free_network_configuration ((struct network_configuration *)
- arg, IP_MODULE_TRUE);
- NSOPR_SET_ERRINFO (retval,
- "init_new_network_configuration return %d",
- retval);
- }
- }
- break;
- case IP_MODULE_OPERATE_DEL:
- {
- retval = del_network_by_name ((char *) arg);
- NSOPR_SET_ERRINFO (retval, "del_network_by_name return %d",
- retval);
- free (arg);
- arg = NULL;
- }
- break;
- case IP_MODULE_OPERATE_QUERY:
- {
- struct network_configuration *network =
- get_network_by_name ((char *) arg);
- if (!network)
- {
- retval = NSCRTL_RD_NOT_EXIST;
- NSOPR_SET_ERRINFO (retval, "get_network_by_name return %d",
- retval);
- }
- else
- {
- if (strlen (get_network_json (network)) >
- sizeof (get_config_data ()->json_buff) - 1)
- {
- NSOPR_LOGERR
- ("length of network->network_json too big]len=%u",
- strlen (get_network_json (network)));
- NSOPR_SET_ERRINFO (NSCRTL_ERR,
- "ERR:internal error, buf is not enough]");
- retval = NSCRTL_ERR;
- }
-
- retval =
- STRCPY_S (get_config_data ()->json_buff,
- sizeof (get_config_data ()->json_buff),
- get_network_json (network));
- if (EOK != retval)
- {
- NSOPR_LOGERR ("STRCPY_S failed]ret=%d", retval);
- NSOPR_SET_ERRINFO (NSCRTL_ERR,
- "ERR:internal error, STRCPY_S failed]ret=%d",
- retval);
- retval = NSCRTL_ERR;
- }
-
- }
-
- free (arg);
- arg = NULL;
- }
- break;
- default:
- break;
- }
-
- break;
- case IP_MODULE_IP:
- switch (operate_type)
- {
- case IP_MODULE_OPERATE_ADD:
- retval = add_container ((struct container_ip *) arg);
- NSOPR_SET_ERRINFO (retval, "add_container return %d", retval);
- break;
- case IP_MODULE_OPERATE_DEL:
- {
- struct ip_action_param *p = (struct ip_action_param *) arg;
- retval = del_port (p->container_id, p->port_name);
- NSOPR_SET_ERRINFO (retval, "del_port return %d", retval);
- free (arg);
- arg = NULL;
- }
- break;
- case IP_MODULE_OPERATE_QUERY:
- {
- struct ip_action_param *p = (struct ip_action_param *) arg;
- struct container_port *port =
- get_port (p->container_id, p->port_name);
- if (!port)
- {
- retval = NSCRTL_RD_NOT_EXIST;
- NSOPR_SET_ERRINFO (retval, "get_port return %d", retval);
- }
- else
- {
- if (strlen (get_port_json (port)) >
- sizeof (get_config_data ()->json_buff) - 1)
- {
- NSOPR_LOGERR
- ("length of network->network_json too big]len=%u",
- strlen (get_port_json (port)));
- retval = NSCRTL_ERR;
- }
-
- retval =
- STRCPY_S (get_config_data ()->json_buff,
- sizeof (get_config_data ()->json_buff),
- get_port_json (port));
- if (EOK != retval)
- {
- NSOPR_LOGERR ("STRCPY_S failed]ret=%d", retval);
- retval = NSCRTL_ERR;
- }
-
- }
-
- free (arg);
- arg = NULL;
- }
- break;
- default:
- break;
- }
-
- break;
- case IP_MODULE_NETWORK_ALL:
- if (operate_type == IP_MODULE_OPERATE_QUERY)
- {
- retval =
- get_network_all (get_config_data ()->json_buff,
- sizeof (get_config_data ()->json_buff));
- NSOPR_SET_ERRINFO (retval, "get_network_all return %d", retval);
- }
-
- break;
-
- case IP_MODULE_IP_ALL:
- if (operate_type == IP_MODULE_OPERATE_QUERY)
- {
- retval =
- getIpCfgAll (get_config_data ()->json_buff,
- sizeof (get_config_data ()->json_buff));
- NSOPR_SET_ERRINFO (retval, "getIpCfgAll return %d", retval);
- }
-
- break;
-
- case IP_MODULE_ALL:
- if (operate_type == IP_MODULE_OPERATE_QUERY)
- {
- NSOPR_LOGERR
- ("---------- IP_MODULE_ALL query is not implemented --------------");
- NSOPR_SET_ERRINFO (NSCRTL_ERR,
- "ERR:This query interface is not implemented. ErrCode:%d",
- NSCRTL_ERR);
- }
-
- break;
-
- default:
- break;
- }
-
- NSOPR_LOGINF ("process finished]result=%d", retval);
-
- return retval;
-}
-
-void
-ip_subnet_print (struct ip_subnet *subnet)
-{
- spl_ip_addr_t ipAddr;
-
- if (subnet == NULL)
- {
- return;
- }
-
- ipAddr.addr = spl_htonl (subnet->subnet);
- NSPOL_LOGINF (IP_DEBUG, "]\t Subnet=%s/%u", spl_inet_ntoa (ipAddr),
- subnet->mask_len);
-}
-
-port_buffer *
-malloc_port_buffer ()
-{
- port_buffer *buffer = malloc (sizeof (port_buffer));
- return buffer;
-}
-
-void
-free_port_buffer (port_buffer * buffer)
-{
- free (buffer);
-}
-
-network_buffer *
-malloc_network_buffer ()
-{
- network_buffer *buffer = malloc (sizeof (network_buffer));
- return buffer;
-}
-
-void
-free_network_buffer (network_buffer * buffer)
-{
- free (buffer);
-}
diff --git a/stacks/lwip_stack/lwip_src/ip_module/network.c b/stacks/lwip_stack/lwip_src/ip_module/network.c
deleted file mode 100644
index d7c9630..0000000
--- a/stacks/lwip_stack/lwip_src/ip_module/network.c
+++ /dev/null
@@ -1,1106 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include <stdio.h>
-#include <sys/socket.h>
-#include <string.h>
-#include "json.h"
-#include "trp_rb_tree.h"
-#include "network.h"
-#include "nstack_log.h"
-#include "config_common.h"
-#include "stackx_spl_share.h"
-#include "stackx/spl_api.h"
-#include "sharedmemory.h"
-#include "nstack_securec.h"
-#include "spl_hal.h"
-#include "inet.h"
-
-struct network_list g_network_list = { 0 };
-
-extern struct stackx_port_zone *p_stackx_port_zone;
-extern u32 spl_hal_is_nic_exist (const char *name);
-
-static bool_t
-is_phy_net_ok (struct phy_net *pst_phy_net)
-{
- if (!pst_phy_net || !pst_phy_net->header)
- {
- NSOPR_LOGERR ("phy_net is not ok");
- return 0;
- }
-
- return 1;
-}
-
-static bool_t
-is_network_configuration_ok (struct network_configuration *network)
-{
- while (network)
- {
- if (!is_phy_net_ok (network->phy_net))
- {
- return 0;
- }
-
- network = network->next;
- }
-
- return 1;
-}
-
-static void
-add_ref_nic (struct phy_net *pst_phy_net, struct ref_nic *pst_ref_nic)
-{
- pst_ref_nic->next = pst_phy_net->header;
- pst_phy_net->header = pst_ref_nic;
-}
-
-static void
-free_ref_nic (struct ref_nic *pst_ref_nic)
-{
- struct ref_nic *nic = pst_ref_nic;
- struct ref_nic *tmp = NULL;
-
- while (nic)
- {
- tmp = nic;
- nic = tmp->next;
- free (tmp);
- }
-}
-
-static void
-free_phy_net (struct phy_net *pst_phy_net)
-{
- if (pst_phy_net)
- {
- free_ref_nic (pst_phy_net->header);
- free (pst_phy_net);
- }
-}
-
-static void
-free_ip_subnet (struct ip_subnet *subnet, bool_t only_free)
-{
- struct ip_subnet *tmp = NULL;
-
- while (subnet)
- {
- tmp = subnet;
- subnet = subnet->next;
- free (tmp);
- }
-}
-
-void
-free_network_configuration (struct network_configuration *network,
- bool_t only_free)
-{
- if (network)
- {
- free_ip_subnet (network->ip_subnet, only_free);
- free_phy_net (network->phy_net);
-
- if (network->buffer)
- {
- free_network_buffer (network->buffer);
- network->buffer = NULL;
- }
-
- free (network);
- }
-}
-
-inline int
-is_in_subnet (unsigned int ip, struct ip_subnet *subnet)
-{
- unsigned int mask = ~0;
- unsigned int seg_ip, seg;
-
- mask = mask << (IP_MODULE_SUBNET_MASK_LEN - subnet->mask_len);
-
- seg_ip = ip & mask;
- seg = subnet->subnet & mask;
-
- return seg_ip != seg ? 1 : 0;
-}
-
-inline struct network_configuration *
-get_network_by_ip_with_tree (unsigned int ip)
-{
- unsigned int h_ip = spl_ntohl (ip);
- struct network_configuration *p = g_network_list.header;
-
- while (p)
- {
- if (!is_in_subnet (h_ip, p->ip_subnet))
- {
- return p;
- }
-
- p = p->next;
- }
-
- return NULL;
-}
-
-struct network_configuration *
-get_network_by_name (char *name)
-{
- struct network_configuration *network = g_network_list.header;
-
- while (network)
- {
- if (strcasecmp (name, network->network_name) == 0)
- {
- return network;
- }
-
- network = network->next;
- }
-
- return NULL;
-}
-
-struct network_configuration *
-get_network_by_nic_name (char *name)
-{
- if (NULL == name)
- {
- return NULL;
- }
-
- struct ref_nic *refnic = NULL;
- struct phy_net *phynet = NULL;
- struct network_configuration *network = g_network_list.header;
- while (network)
- {
- phynet = network->phy_net;
- if (phynet)
- {
- if ((phynet->bond_mode != -1)
- && strcmp (name, phynet->bond_name) == 0)
- {
- return network;
- }
-
- refnic = phynet->header;
- while (refnic)
- {
- if (strcmp (name, refnic->nic_name) == 0)
- {
- return network;
- }
-
- refnic = refnic->next;
- }
- }
-
- network = network->next;
- }
-
- return NULL;
-}
-
-struct network_configuration *
-get_network_by_name_from_json (struct network_configuration *network)
-{
- char *name = network->network_name;
- struct network_configuration *tmp = network->next;
-
- while (tmp)
- {
- if (strcasecmp (name, tmp->network_name) == 0)
- {
- return tmp;
- }
-
- tmp = tmp->next;
- }
-
- return NULL;
-}
-
-NSTACK_STATIC inline int
-get_network_count ()
-{
- int count = 0;
- struct network_configuration *network = g_network_list.header;
-
- while (network)
- {
- count++;
- network = network->next;
- }
-
- return count;
-}
-
-int
-get_network_all (char *jsonBuf, size_t size)
-{
- if (NULL == jsonBuf)
- {
- return NSCRTL_ERR;
- }
-
- if (size < 2)
- {
- NSOPR_LOGERR ("get all ip cfg error, buffer is not enough.");
- return NSCRTL_STATUS_ERR;
- }
-
- int retVal;
- char bfirstData = 1;
- *jsonBuf = '[';
- jsonBuf = jsonBuf + 1;
-
- size_t len = size - 2; // strlen("[]")
- size_t strsize = 0;
- struct network_configuration *network = g_network_list.header;
- while (network)
- {
- if (NULL == network->buffer)
- {
- network = network->next;
- continue;
- }
-
- if (bfirstData)
- {
- bfirstData = 0;
- }
- else
- {
- *jsonBuf = ',';
- jsonBuf = jsonBuf + 1;
- len = len - 1;
- }
-
- strsize = strlen (get_network_json (network)) + 1;
- if ((strsize > 0) && (strsize < len))
- {
- retVal = STRCPY_S (jsonBuf, len, get_network_json (network));
- if (EOK != retVal)
- {
- NSOPR_LOGERR ("STRCPY_S failed]ret=%d.", retVal);
- return NSCRTL_STATUS_ERR;
- }
-
- len = len - strlen (get_network_json (network));
- jsonBuf = jsonBuf + strlen (get_network_json (network));
- }
- else
- {
- NSOPR_LOGERR ("get all network cfg error, buffer is not enough.");
- return NSCRTL_STATUS_ERR;
- }
-
- network = network->next;
- }
-
- *jsonBuf = ']';
- return 0;
-}
-
-int
-nic_already_bind (const char *nic_name)
-{
- struct ref_nic *pnic = NULL;
- struct network_configuration *pnetwork = g_network_list.header;
-
- while (pnetwork)
- {
- pnic = pnetwork->phy_net->header;
- while (pnic)
- {
- if (0 == strcmp (pnic->nic_name, nic_name))
- {
- return 1;
- }
-
- pnic = pnic->next;
- }
-
- pnetwork = pnetwork->next;
- }
-
- return 0;
-}
-
-int
-nic_already_init (const char *nic_name)
-{
- unsigned int i;
-
- for (i = 0; i < p_stackx_port_zone->port_num; i++)
- {
- if (0 ==
- strcmp (p_stackx_port_zone->stackx_one_port[i].linux_ip.if_name,
- nic_name))
- {
- return 1;
- }
- }
-
- return 0;
-}
-
-extern struct stackx_port_info *head_used_port_list;
-int
-bonded_nic_already_bind (struct network_configuration *pnetwork,
- const char *nic_name)
-{
- struct stackx_port_info *p_port_list = head_used_port_list;
-
- while (p_port_list)
- {
- if (0 == strcmp (p_port_list->linux_ip.if_name, nic_name))
- {
- return 1;
- }
-
- p_port_list = p_port_list->next_use_port;
- }
-
- struct ref_nic *pnic = NULL;
-
- while (pnetwork)
- {
- if (pnetwork->phy_net->bond_mode == -1)
- {
- pnic = pnetwork->phy_net->header;
- if (0 == strcmp (pnic->nic_name, nic_name))
- {
- return 1;
- }
- }
-
- pnetwork = pnetwork->next;
- }
-
- return 0;
-}
-
-extern struct bond_ports_info bond_ports_array;
-int
-nic_already_bond (struct network_configuration *pnetwork,
- const char *nic_name)
-{
- u8_t i, j;
- struct bond_set *s;
-
- for (i = 0; i < bond_ports_array.cnt; i++)
- {
- s = &bond_ports_array.ports[i];
- for (j = 0; j < s->slave_port_cnt; j++)
- {
- if (strcmp (s->slave_ports[j], nic_name) == 0)
- {
- return 1;
- }
- }
- }
-
- struct ref_nic *pnic = NULL;
-
- while (pnetwork)
- {
- if (pnetwork->phy_net->bond_mode != -1)
- {
- pnic = pnetwork->phy_net->header;
- while (pnic)
- {
- if (0 == strcmp (pnic->nic_name, nic_name))
- {
- return 1;
- }
-
- pnic = pnic->next;
- }
- }
-
- pnetwork = pnetwork->next;
- }
-
- return 0;
-}
-
-/* add network to list in descending sort */
-void
-add_network_to_list (struct network_configuration *network)
-{
- struct network_configuration *curr = g_network_list.header;
- struct network_configuration *prev = NULL;
-
- network->next = NULL;
-
- while (curr)
- {
- if (network->ip_subnet->mask_len >= curr->ip_subnet->mask_len)
- {
- break;
- }
-
- prev = curr;
- curr = curr->next;
- }
-
- if (NULL == prev)
- {
- network->next = curr;
- g_network_list.header = network;
- }
- else
- {
- network->next = prev->next;
- prev->next = network;
- }
-}
-
-int
-add_network_configuration (struct network_configuration
- *pst_network_configuration)
-{
- struct network_configuration *tmp = pst_network_configuration;
- struct ref_nic *pheader;
-
- if (tmp)
- {
- if (get_network_by_name (tmp->network_name)
- || get_network_by_name_from_json (tmp))
- {
- NSOPR_LOGERR ("network exists or duplicates]network_name=%s",
- tmp->network_name);
- free_network_configuration (pst_network_configuration,
- IP_MODULE_TRUE);
- return NSCRTL_RD_EXIST;
- }
-
- if (strcasecmp ("nstack-dpdk", tmp->type_name) != 0)
- {
- NSOPR_LOGWAR ("illegal network type]type_name=%s", tmp->type_name);
- }
-
- /* control max network and ipaddress count */
- if (get_network_count () >= MAX_NETWORK_COUNT)
- {
- NSOPR_LOGERR ("network reach]max_count=%d", MAX_NETWORK_COUNT);
- free_network_configuration (pst_network_configuration,
- IP_MODULE_TRUE);
- return NSCRTL_NETWORK_COUNT_EXCEED;
- }
-
- /* If nic is not existed or not initiated, return error */
- pheader = tmp->phy_net->header;
- while (pheader)
- {
- if (!spl_hal_is_nic_exist (pheader->nic_name)
- && !nic_already_init (pheader->nic_name)
- && strncmp (tmp->nic_type_name, "vhost", strlen ("vhost")))
- {
- NSOPR_LOGERR ("Invalid configuration %s not exist Error! ",
- pheader->nic_name);
- free_network_configuration (pst_network_configuration,
- IP_MODULE_TRUE);
- return NSCRTL_RD_NOT_EXIST;
- }
-
- pheader = pheader->next;
- }
-
- /* if a bonded nic has been inited in a non-bond network, return error */
- if (tmp->phy_net->bond_mode != -1)
- {
- pheader = tmp->phy_net->header;
- while (pheader)
- {
- if (bonded_nic_already_bind
- (pst_network_configuration, pheader->nic_name))
- {
- NSOPR_LOGERR ("Invalid configuration %s already bind! ",
- pheader->nic_name);
- free_network_configuration (pst_network_configuration,
- IP_MODULE_TRUE);
- return NSCRTL_INPUT_ERR;
- }
-
- pheader = pheader->next;
- }
- }
-
- /* if a non-bond nic has been inited in a bonded network, return error */
- if (tmp->phy_net->bond_mode == -1)
- {
- pheader = tmp->phy_net->header;
- while (pheader)
- {
- if (nic_already_bond
- (pst_network_configuration, pheader->nic_name))
- {
- NSOPR_LOGERR ("Invalid configuration %s already bind! ",
- pheader->nic_name);
- free_network_configuration (pst_network_configuration,
- IP_MODULE_TRUE);
- return NSCRTL_INPUT_ERR;
- }
-
- pheader = pheader->next;
- }
- }
- }
- else
- {
- NSOPR_LOGERR ("Invalid network configuration!");
- return NSCRTL_INPUT_ERR;
- }
-
- /*looping through each node has move to read_ipmoduleoperateadd_configuration */
- ip_subnet_print (tmp->ip_subnet);
- add_network_to_list (tmp);
-
- return NSCRTL_OK;
-}
-
-struct network_configuration *
-parse_network_obj (struct json_object *network_obj)
-{
- int retVal;
- struct network_configuration *pst_network_configuration = NULL;
- struct json_object *network_name_obj = NULL, *args_obj = NULL, *phy_obj =
- NULL, *type_name_obj = NULL;
- struct json_object *ref_nic_list_obj = NULL, *bond_mode_obj =
- NULL, *bond_name_obj = NULL, *ipam_obj = NULL;
- struct json_object *subnet_obj = NULL, *nic_type_obj = NULL;
-
- if (!network_obj)
- {
- NSOPR_LOGERR ("network_obj is null");
- goto RETURN_ERROR;
- }
-
- pst_network_configuration = malloc (sizeof (struct network_configuration));
- if (NULL == pst_network_configuration)
- {
- NSOPR_LOGERR ("malloc failed");
- goto RETURN_ERROR;
- }
-
- retVal =
- MEMSET_S (pst_network_configuration,
- sizeof (struct network_configuration), 0,
- sizeof (struct network_configuration));
- if (EOK != retVal)
- {
- NSOPR_LOGERR ("MEMSET_S failed]ret=%d.", retVal);
- goto RETURN_ERROR;
- }
-
- json_object_object_get_ex (network_obj, "name", &network_name_obj);
- if (network_name_obj)
- {
- const char *network_name = json_object_get_string (network_name_obj);
- if ((NULL == network_name) || (network_name[0] == 0)
- || (strlen (network_name) >= IP_MODULE_MAX_NAME_LEN))
- {
- NSOPR_LOGERR ("network_name is not ok");
- goto RETURN_ERROR;
- }
-
- retVal =
- STRCPY_S (pst_network_configuration->network_name,
- sizeof (pst_network_configuration->network_name),
- network_name);
-
- if (EOK != retVal)
- {
- NSOPR_LOGERR ("STRCPY_S failed]ret=%d.", retVal);
- goto RETURN_ERROR;
- }
- }
- else
- {
- NSOPR_LOGERR ("name is not ok");
- goto RETURN_ERROR;
- }
-
- json_object_object_get_ex (network_obj, "type", &type_name_obj);
- if (type_name_obj)
- {
- const char *type_name = json_object_get_string (type_name_obj);
- if ((NULL == type_name) || (type_name[0] == 0)
- || (strlen (type_name) >= IP_MODULE_MAX_NAME_LEN))
- {
- NSOPR_LOGERR ("type parse error");
- goto RETURN_ERROR;
- }
-
- retVal =
- STRCPY_S (pst_network_configuration->type_name,
- sizeof (pst_network_configuration->type_name), type_name);
-
- if (EOK != retVal)
- {
- NSOPR_LOGERR ("STRCPY_S failed]ret=%d", retVal);
- goto RETURN_ERROR;
- }
- }
- else
- {
- NSOPR_LOGERR ("type is not ok");
- goto RETURN_ERROR;
- }
-
- json_object_object_get_ex (network_obj, "args", &args_obj);
- if (args_obj)
- {
- json_object_object_get_ex (args_obj, "phynet", &phy_obj);
- if (phy_obj)
- {
- struct phy_net *pst_phy_net = malloc (sizeof (struct phy_net));
- if (NULL == pst_phy_net)
- {
- NSOPR_LOGERR ("malloc failed");
- goto RETURN_ERROR;
- }
-
- retVal =
- MEMSET_S (pst_phy_net, sizeof (struct phy_net), 0,
- sizeof (struct phy_net));
- if (EOK != retVal)
- {
- NSOPR_LOGERR ("MEMSET_S failed]ret=%d", retVal);
- free_phy_net (pst_phy_net);
- goto RETURN_ERROR;
- }
-
- json_object_object_get_ex (phy_obj, "nic_type", &nic_type_obj); /*lint !e534 no need to check return value */
- if (nic_type_obj)
- {
- const char *nic_type_name =
- json_object_get_string (nic_type_obj);
- if (strcmp (nic_type_name, "pci") != 0
- && strcmp (nic_type_name, "vhost") != 0)
- {
- NSOPR_LOGERR ("unsupported nic_type]nic_type=%s",
- nic_type_name);
- goto RETURN_ERROR;
- }
-
- retVal =
- STRCPY_S (pst_network_configuration->nic_type_name,
- sizeof (pst_network_configuration->nic_type_name),
- nic_type_name);
- if (EOK != retVal)
- {
- NSOPR_LOGERR ("strcpy_s failed]ret=%d", retVal);
- goto RETURN_ERROR;
- }
- }
- else
- {
- NSOPR_LOGINF
- ("nic_type not specified, use default type]defaul nic_type=pci");
- retVal =
- STRCPY_S (pst_network_configuration->nic_type_name,
- sizeof (pst_network_configuration->nic_type_name),
- "pci");
- if (EOK != retVal)
- {
- NSOPR_LOGERR ("strcpy_s failed]ret=%d", retVal);
- goto RETURN_ERROR;
- }
- }
-
- json_object_object_get_ex (phy_obj, "ref_nic", &ref_nic_list_obj);
- if (ref_nic_list_obj)
- {
- int j;
- int ref_nic_num = json_object_array_length (ref_nic_list_obj);
- if (0 == ref_nic_num)
- {
- NSOPR_LOGERR ("ref_nic is empty");
- free_phy_net (pst_phy_net);
- goto RETURN_ERROR;
- }
-
- for (j = ref_nic_num - 1; j >= 0; j--)
- {
- struct json_object *ref_nic_obj =
- json_object_array_get_idx (ref_nic_list_obj, j);
- if (ref_nic_obj)
- {
- const char *nic_name =
- json_object_get_string (ref_nic_obj);
- if ((NULL == nic_name) || (nic_name[0] == 0)
- || (strlen (nic_name) >= HAL_MAX_NIC_NAME_LEN))
- {
- NSOPR_LOGERR ("nic_name is not ok");
- free_phy_net (pst_phy_net);
- goto RETURN_ERROR;
- }
-
- struct ref_nic *pst_ref_nic =
- malloc (sizeof (struct ref_nic));
- if (NULL == pst_ref_nic)
- {
- NSOPR_LOGERR ("malloc failed");
- free_phy_net (pst_phy_net);
- goto RETURN_ERROR;
- }
-
- retVal =
- MEMSET_S (pst_ref_nic, sizeof (struct ref_nic), 0,
- sizeof (struct ref_nic));
- if (EOK != retVal)
- {
- NSOPR_LOGERR ("MEMSET_S failed]ret=%d.", retVal);
- free (pst_ref_nic);
- pst_ref_nic = NULL;
- free_phy_net (pst_phy_net);
- goto RETURN_ERROR;
- }
-
- retVal =
- STRCPY_S (pst_ref_nic->nic_name,
- sizeof (pst_ref_nic->nic_name), nic_name);
-
- if (EOK != retVal)
- {
- NSOPR_LOGERR ("STRCPY_S failed]ret=%d.", retVal);
- free (pst_ref_nic);
- free_phy_net (pst_phy_net);
- goto RETURN_ERROR;
- }
-
- add_ref_nic (pst_phy_net, pst_ref_nic);
- }
- }
- }
- else
- {
- NSOPR_LOGERR ("ref_nic is not ok");
- free_phy_net (pst_phy_net);
- goto RETURN_ERROR;
- }
-
- json_object_object_get_ex (phy_obj, "bond_mode", &bond_mode_obj);
- if (bond_mode_obj)
- {
- pst_phy_net->bond_mode = json_object_get_int (bond_mode_obj);
- if (pst_phy_net->bond_mode != -1)
- {
- json_object_object_get_ex (phy_obj, "bond_name",
- &bond_name_obj);
- if (bond_name_obj)
- {
- const char *bond_name =
- json_object_get_string (bond_name_obj);
- if ((NULL == bond_name)
- || (strlen (bond_name) >= IP_MODULE_MAX_NAME_LEN))
- {
- NSOPR_LOGERR ("bond_name is not ok");
- free_phy_net (pst_phy_net);
- goto RETURN_ERROR;
- }
-
- retVal =
- MEMSET_S (pst_phy_net->bond_name,
- sizeof (pst_phy_net->bond_name), 0,
- sizeof (pst_phy_net->bond_name));
-
- if (EOK != retVal)
- {
- NSOPR_LOGERR ("MEMSET_S failed]ret=%d.", retVal);
- free_phy_net (pst_phy_net);
- goto RETURN_ERROR;
- }
-
- retVal =
- STRNCPY_S (pst_phy_net->bond_name,
- sizeof (pst_phy_net->bond_name), bond_name,
- strlen (bond_name));
-
- if (EOK != retVal)
- {
- NSOPR_LOGERR ("STRNCPY_S failed]retVal=%d", retVal);
- free_phy_net (pst_phy_net);
- goto RETURN_ERROR;
- }
- }
- else
- {
- NSOPR_LOGERR ("bond_name is not ok");
- free_phy_net (pst_phy_net);
- goto RETURN_ERROR;
- }
- }
- }
- else
- {
- pst_phy_net->bond_mode = -1;
- }
-
- pst_network_configuration->phy_net = pst_phy_net;
- }
- else
- {
- NSOPR_LOGERR ("phy_net is not ok");
- goto RETURN_ERROR;
- }
- }
- else
- {
- NSOPR_LOGERR ("args is not ok");
- goto RETURN_ERROR;
- }
-
- json_object_object_get_ex (network_obj, "ipam", &ipam_obj);
- if (ipam_obj)
- {
- json_object_object_get_ex (ipam_obj, "subnet", &subnet_obj);
- if (subnet_obj)
- {
- int iRet;
- char tmp[IP_MODULE_LENGTH_32] = { 0 };
- const char *subnet = json_object_get_string (subnet_obj);
- struct in_addr addr;
-
- retVal = MEMSET_S (&addr, sizeof (addr), 0, sizeof (addr));
- if (EOK != retVal)
- {
- NSOPR_LOGERR ("MEMSET_S failed]ret=%d.", retVal);
- goto RETURN_ERROR;
- }
-
- if ((NULL == subnet) || (subnet[0] == 0)
- || (strlen (subnet) > IP_MODULE_LENGTH_32))
- {
- NSOPR_LOGERR ("subnet is not ok");
- goto RETURN_ERROR;
- }
-
- const char *sub = strstr (subnet, "/");
- if ((NULL == sub)
- || (sizeof (tmp) - 1 <= (unsigned int) (sub - subnet))
- || (strlen (sub) >= sizeof (tmp) - 1))
- {
- NSOPR_LOGERR ("subnet is not ok");
- goto RETURN_ERROR;
- }
-
- iRet =
- STRNCPY_S (tmp, sizeof (tmp), subnet, (size_t) (sub - subnet));
- if (EOK != iRet)
- {
- NSOPR_LOGERR ("STRNCPY_S failed]ret=%d", iRet);
- goto RETURN_ERROR;
- }
-
- iRet = spl_inet_aton (tmp, &addr);
- if (0 == iRet)
- {
- NSOPR_LOGERR ("subnet is not ok");
- goto RETURN_ERROR;
- }
-
- pst_network_configuration->ip_subnet =
- (struct ip_subnet *) malloc (sizeof (struct ip_subnet));
- if (!pst_network_configuration->ip_subnet)
- {
- NSOPR_LOGERR ("malloc failed");
- goto RETURN_ERROR;
- }
-
- retVal =
- MEMSET_S (pst_network_configuration->ip_subnet,
- sizeof (struct ip_subnet), 0,
- sizeof (struct ip_subnet));
- if (EOK != retVal)
- {
- NSOPR_LOGERR ("MEMSET_S failed]ret=%d.", retVal);
- goto RETURN_ERROR;
- }
-
- pst_network_configuration->ip_subnet->next = NULL;
- pst_network_configuration->ip_subnet->subnet =
- spl_ntohl (addr.s_addr);
-
- iRet = atoi (sub + 1);
- if ((iRet < 0) || (iRet > IP_MODULE_LENGTH_32))
- {
- NSOPR_LOGERR ("mask is not ok");
- goto RETURN_ERROR;
- }
-
- pst_network_configuration->ip_subnet->mask_len =
- (unsigned int) iRet;
- }
- else
- {
- NSOPR_LOGERR ("subnet is not ok");
- goto RETURN_ERROR;
- }
- }
- else
- {
- NSOPR_LOGERR ("ipam is not ok");
- goto RETURN_ERROR;
- }
-
- const char *network_json = json_object_get_string (network_obj);
- if ((NULL == network_json) || (network_json[0] == 0))
- {
- NSOPR_LOGERR ("json_object_get_string failed");
- goto RETURN_ERROR;
- }
-
- pst_network_configuration->buffer = malloc_network_buffer ();
- if (!pst_network_configuration->buffer)
- {
- NSOPR_LOGERR ("malloc_network_buffer failed");
- goto RETURN_ERROR;
- }
-
- retVal =
- STRCPY_S (get_network_json (pst_network_configuration),
- IP_MODULE_NETWORK_JSON_LEN, network_json);
- if (EOK != retVal)
- {
- NSOPR_LOGERR ("STRCPY_S failed]ret=%d.", retVal);
- goto RETURN_ERROR;
- }
-
- return pst_network_configuration;
-
-RETURN_ERROR:
- if (pst_network_configuration)
- {
- free_network_configuration (pst_network_configuration, IP_MODULE_TRUE);
- pst_network_configuration = NULL;
- }
-
- return NULL;
-}
-
-struct network_configuration *
-parse_network_json (char *param, struct network_configuration *pnetwork_list)
-{
- struct json_object *obj = json_tokener_parse (param);
- struct network_configuration *pst_network_configuration = NULL;
-
- if (!obj)
- {
- NSOPR_LOGERR ("parse error");
- return NULL;
- }
-
- int network_num = json_object_array_length (obj);
- if (0 == network_num)
- {
- json_object_put (obj);
- return NULL;
- }
-
- int i;
- for (i = 0; i < network_num; i++)
- {
- struct json_object *network_obj = json_object_array_get_idx (obj, i);
- if (network_obj)
- {
- pst_network_configuration = parse_network_obj (network_obj);
- if (!pst_network_configuration)
- {
- NSOPR_LOGERR ("parse_network_obj error");
- goto RETURN_ERROR;
- }
-
- pst_network_configuration->next = pnetwork_list;
- pnetwork_list = pst_network_configuration;
- pst_network_configuration = NULL;
- }
- else
- {
- NSOPR_LOGERR ("network_obj is NULL");
- goto RETURN_ERROR;
- }
- }
-
- if (pnetwork_list)
- {
- if (!is_network_configuration_ok (pnetwork_list))
- {
- NSOPR_LOGERR ("network_configuration is not ok");
- goto RETURN_ERROR;
- }
- }
-
- json_object_put (obj);
- return pnetwork_list;
-
-RETURN_ERROR:
- free_network_configuration (pnetwork_list, IP_MODULE_TRUE);
- json_object_put (obj);
- return NULL;
-}
-
-int
-del_network_by_name (char *name)
-{
- struct network_configuration *network = NULL;
- struct network_configuration **ref = &g_network_list.header;
-
- while ((network = *ref))
- {
- if (strcasecmp (name, network->network_name) == 0)
- {
- *ref = network->next;
- network->next = NULL;
-
- free_network_configuration (network, IP_MODULE_FALSE);
- return 0;
- }
-
- ref = &network->next;
- }
-
- return NSCRTL_RD_NOT_EXIST;
-}
-
-int
-is_in_same_network (unsigned int src_ip, unsigned int dst_ip)
-{
- if (src_ip == dst_ip)
- {
- return 1;
- }
-
- struct network_configuration *src = get_network_by_ip_with_tree (src_ip);
- struct network_configuration *dst = get_network_by_ip_with_tree (dst_ip);
- if (src && (src == dst))
- {
- return 1;
- }
-
- return 0;
-}
-
-struct network_configuration *
-get_network_list ()
-{
- return g_network_list.header;
-}
diff --git a/stacks/lwip_stack/lwip_src/ip_module/trp_rb_tree.c b/stacks/lwip_stack/lwip_src/ip_module/trp_rb_tree.c
deleted file mode 100644
index 1990f52..0000000
--- a/stacks/lwip_stack/lwip_src/ip_module/trp_rb_tree.c
+++ /dev/null
@@ -1,563 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "trp_rb_tree.h"
-
-NSTACK_STATIC void
-__rb_rotate_left (struct trp_rb_node *X, struct trp_rb_root *root)
-{
- /**************************
- * rotate Node X to left *
- **************************/
-
- struct trp_rb_node *Y = X->rb_right;
-
- /* estblish X->Right link */
- X->rb_right = Y->rb_left;
- if (Y->rb_left != NULL)
- Y->rb_left->rb_parent = X;
-
- /* estblish Y->Parent link */
- Y->rb_parent = X->rb_parent;
- if (X->rb_parent)
- {
- if (X == X->rb_parent->rb_left)
- X->rb_parent->rb_left = Y;
- else
- X->rb_parent->rb_right = Y;
- }
- else
- {
- root->rb_node = Y;
- }
-
- /* link X and Y */
- Y->rb_left = X;
- X->rb_parent = Y;
-
- return;
-}
-
-NSTACK_STATIC void
-__rb_rotate_right (struct trp_rb_node *X, struct trp_rb_root *root)
-{
- /****************************
- * rotate Node X to right *
- ****************************/
-
- struct trp_rb_node *Y = X->rb_left;
-
- /* estblish X->Left link */
- X->rb_left = Y->rb_right;
- if (Y->rb_right != NULL)
- Y->rb_right->rb_parent = X;
-
- /* estblish Y->Parent link */
- Y->rb_parent = X->rb_parent;
- if (X->rb_parent)
- {
- if (X == X->rb_parent->rb_right)
- X->rb_parent->rb_right = Y;
- else
- X->rb_parent->rb_left = Y;
- }
- else
- {
- root->rb_node = Y;
- }
-
- /* link X and Y */
- Y->rb_right = X;
- X->rb_parent = Y;
-
- return;
-}
-
-/* X, Y are for application */
-NSTACK_STATIC void
-__rb_erase_color (struct trp_rb_node *X, struct trp_rb_node *Parent,
- struct trp_rb_root *root)
-{
- /*************************************
- * maintain red-black tree balance *
- * after deleting node X *
- *************************************/
-
- while (X != root->rb_node && (!X || X->color == RB_BLACK))
- {
-
- if (Parent == NULL)
- {
- break;
- }
-
- if (X == Parent->rb_left)
- {
- struct trp_rb_node *W = Parent->rb_right;
- if (W->color == RB_RED)
- {
- W->color = RB_BLACK;
- Parent->color = RB_RED; /* Parent != NIL? */
- __rb_rotate_left (Parent, root);
- W = Parent->rb_right;
- }
-
- if ((!W->rb_left || W->rb_left->color == RB_BLACK)
- && (!W->rb_right || W->rb_right->color == RB_BLACK))
- {
- W->color = RB_RED;
- X = Parent;
- Parent = X->rb_parent;
- }
- else
- {
- if (!W->rb_right || W->rb_right->color == RB_BLACK)
- {
- if (W->rb_left != NULL)
- W->rb_left->color = RB_BLACK;
- W->color = RB_RED;
- __rb_rotate_right (W, root);
- W = Parent->rb_right;
- }
-
- W->color = Parent->color;
- Parent->color = RB_BLACK;
- if (W->rb_right->color != RB_BLACK)
- {
- W->rb_right->color = RB_BLACK;
- }
- __rb_rotate_left (Parent, root);
- X = root->rb_node;
- break;
- }
- }
- else
- {
-
- struct trp_rb_node *W = Parent->rb_left;
- if (W->color == RB_RED)
- {
- W->color = RB_BLACK;
- Parent->color = RB_RED; /* Parent != NIL? */
- __rb_rotate_right (Parent, root);
- W = Parent->rb_left;
- }
-
- if ((!W->rb_left || (W->rb_left->color == RB_BLACK))
- && (!W->rb_right || (W->rb_right->color == RB_BLACK)))
- {
- W->color = RB_RED;
- X = Parent;
- Parent = X->rb_parent;
- }
- else
- {
- if (!W->rb_left || (W->rb_left->color == RB_BLACK))
- {
- if (W->rb_right != NULL)
- W->rb_right->color = RB_BLACK;
- W->color = RB_RED;
- __rb_rotate_left (W, root);
- W = Parent->rb_left;
- }
-
- W->color = Parent->color;
- Parent->color = RB_BLACK;
- if (W->rb_left->color != RB_BLACK)
- {
- W->rb_left->color = RB_BLACK;
- }
- __rb_rotate_right (Parent, root);
- X = root->rb_node;
- break;
- }
- }
- }
-
- if (X)
- {
- X->color = RB_BLACK;
- }
-
- return;
-}
-
-static void
-rb_insert_color (struct trp_rb_node *X, struct trp_rb_root *root)
-{
- /*************************************
- * maintain red-black tree balance *
- * after inserting node X *
- *************************************/
-
- /* check red-black properties */
- while (X != root->rb_node && X->rb_parent->color == RB_RED)
- {
- /* we have a violation */
- if (X->rb_parent == X->rb_parent->rb_parent->rb_left)
- {
- struct trp_rb_node *Y = X->rb_parent->rb_parent->rb_right;
- if (Y && Y->color == RB_RED)
- {
-
- /* uncle is red */
- X->rb_parent->color = RB_BLACK;
- Y->color = RB_BLACK;
- X->rb_parent->rb_parent->color = RB_RED;
- X = X->rb_parent->rb_parent;
- }
- else
- {
-
- /* uncle is black */
- if (X == X->rb_parent->rb_right)
- {
- /* make X a left child */
- X = X->rb_parent;
- __rb_rotate_left (X, root);
- }
-
- /* recolor and rotate */
- X->rb_parent->color = RB_BLACK;
- X->rb_parent->rb_parent->color = RB_RED;
- __rb_rotate_right (X->rb_parent->rb_parent, root);
- }
- }
- else
- {
-
- /* miror image of above code */
- struct trp_rb_node *Y = X->rb_parent->rb_parent->rb_left;
- if (Y && (Y->color == RB_RED))
- {
-
- /* uncle is red */
- X->rb_parent->color = RB_BLACK;
- Y->color = RB_BLACK;
- X->rb_parent->rb_parent->color = RB_RED;
- X = X->rb_parent->rb_parent;
- }
- else
- {
-
- /* uncle is black */
- if (X == X->rb_parent->rb_left)
- {
- X = X->rb_parent;
- __rb_rotate_right (X, root);
- }
- X->rb_parent->color = RB_BLACK;
- X->rb_parent->rb_parent->color = RB_RED;
- __rb_rotate_left (X->rb_parent->rb_parent, root);
- }
- }
- }
-
- root->rb_node->color = RB_BLACK;
-
- return;
-}
-
-static void
-rb_erase (struct trp_rb_node *node, struct trp_rb_root *root)
-{
- struct trp_rb_node *child, *parent;
- unsigned int color;
-
- if (!node->rb_left)
- {
- child = node->rb_right;
- }
- else if (!node->rb_right)
- {
- child = node->rb_left;
- }
- else
- {
- struct trp_rb_node *old = node, *left;
-
- node = node->rb_right;
- while ((left = node->rb_left) != NULL)
- {
- node = left;
- }
-
- if (old->rb_parent)
- {
- if (old->rb_parent->rb_left == old)
- {
- old->rb_parent->rb_left = node;
- }
- else
- {
- old->rb_parent->rb_right = node;
- }
- }
- else
- {
- root->rb_node = node;
- }
-
- child = node->rb_right;
- parent = node->rb_parent;
- color = node->color;
-
- if (parent == old)
- {
- parent = node;
- }
- else
- {
- if (child)
- {
- child->rb_parent = parent;
- }
-
- parent->rb_left = child;
-
- node->rb_right = old->rb_right;
- old->rb_right->rb_parent = node;
- }
-
- node->color = old->color;
- node->rb_parent = old->rb_parent;
- node->rb_left = old->rb_left;
- old->rb_left->rb_parent = node;
-
- if (color == RB_BLACK)
- {
- __rb_erase_color (child, parent, root);
- }
-
- return;
-
- }
-
- parent = node->rb_parent;
- color = node->color;
-
- if (child)
- {
- child->rb_parent = parent;
- }
-
- if (parent)
- {
- if (parent->rb_left == node)
- {
- parent->rb_left = child;
- }
- else
- {
- parent->rb_right = child;
- }
- }
- else
- {
- root->rb_node = child;
- }
-
- if (color == RB_BLACK)
- {
- __rb_erase_color (child, parent, root);
- }
-
- return;
-}
-
-NSTACK_STATIC trp_rb_node_t *
-rb_new_node (trp_key_t key, trp_data_t data,
- trp_rb_node_t * parent /*, key_compare key_compare_fn */ )
-{
- trp_rb_node_t *node = (trp_rb_node_t *) malloc (sizeof (trp_rb_node_t));
- if (!node)
- {
- return NULL;
- }
- node->key = key;
- node->data = data;
- node->rb_parent = parent;
- node->rb_left = node->rb_right = NULL;
- node->color = RB_RED;
- /*node->key_compare_fn = key_compare_fn; */
- return node;
-}
-
-int
-trp_rb_insert (trp_key_t key, trp_data_t data, trp_rb_root_t * root,
- key_compare key_compare_fn)
-{
- trp_rb_node_t *node = root->rb_node, *parent = NULL;
- int ret = 0; /* CID 24640 */
- while (node)
- {
- parent = node;
- ret = key_compare_fn (node->key, key);
- if (0 < ret)
- {
- node = node->rb_left;
- }
- else if (0 > ret)
- {
- node = node->rb_right;
- }
- else
- {
- return -1;
- }
- }
-
- node = rb_new_node (key, data, parent /*, key_compare_fn */ );
- if (!node)
- {
- return -1;
- }
-
- if (parent)
- {
- if (ret > 0)
- {
- parent->rb_left = node;
- }
- else
- {
- parent->rb_right = node;
- }
- }
- else
- {
- root->rb_node = node;
- }
-
- rb_insert_color (node, root);
- return 0;
-}
-
-int
-trp_rb_insert_allow_same_key (trp_key_t key, trp_data_t data,
- trp_rb_root_t * root,
- key_compare key_compare_fn)
-{
- trp_rb_node_t *node = root->rb_node, *parent = NULL;
- int ret = 0; /*CID 24638 */
- while (node)
- {
- parent = node;
- ret = key_compare_fn (node->key, key);
- if (0 < ret)
- {
- node = node->rb_left;
- }
- else
- {
- node = node->rb_right;
- }
- }
-
- node = rb_new_node (key, data, parent /*, key_compare_fn */ );
- if (!node)
- {
- return -1;
- }
-
- if (parent)
- {
- if (ret > 0)
- {
- parent->rb_left = node;
- }
- else
- {
- parent->rb_right = node;
- }
- }
- else
- {
- root->rb_node = node;
- }
-
- rb_insert_color (node, root);
- return 0;
-}
-
-NSTACK_STATIC trp_rb_node_t *
-trp_rb_search_inorder (trp_key_t key, trp_data_t data,
- trp_rb_node_t * node, int *count,
- key_compare key_compare_fn)
-{
- if (!node)
- {
- return NULL;
- }
-
- int ret = key_compare_fn (node->key, key);;
- if (0 == ret && data == node->data)
- {
- return node;
- }
-
- if ((NULL == count) || (0 >= --(*count)))
- {
- return NULL;
- }
-
- trp_rb_node_t *ret_node =
- trp_rb_search_inorder (key, data, node->rb_left, count, key_compare_fn);
- if (ret_node)
- {
- return ret_node;
- }
-
- ret_node =
- trp_rb_search_inorder (key, data, node->rb_right, count, key_compare_fn);
- return ret_node;
-}
-
-void
-trp_rb_erase_with_data (trp_key_t key, trp_data_t data, trp_rb_root_t * root,
- int count, key_compare key_compare_fn)
-{
- trp_rb_node_t *node;
- /* recursion operation need depth protect */
- if (!
- (node =
- trp_rb_search_inorder (key, data, root->rb_node, &count,
- key_compare_fn)))
- {
- return;
- }
-
- rb_erase (node, root);
- free (node);
- node = NULL;
-}
-
-void
-trp_rb_erase (trp_key_t key, trp_rb_root_t * root, key_compare key_compare_fn)
-{
- trp_rb_node_t *node;
- if (!(node = trp_rb_search (key, root, key_compare_fn)))
- {
- return;
- }
-
- rb_erase (node, root);
- free (node);
- node = NULL;
-}
diff --git a/stacks/lwip_stack/lwip_src/netif/ethernetif.c b/stacks/lwip_stack/lwip_src/netif/ethernetif.c
deleted file mode 100644
index 6a3e810..0000000
--- a/stacks/lwip_stack/lwip_src/netif/ethernetif.c
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "spl_opt.h"
-
-#include "spl_def.h"
-#include "mem.h"
-#include "stackx/spl_pbuf.h"
-//#include <stackx/stats.h>
-//#include "sockets.h"
-#include <netinet/in.h>
-
-#include "stackx_spl_share.h"
-#include "stackx/spl_api.h"
-#include "lwip/etharp.h"
-
-#include <sc_dpdk.h>
-#include "sc_dpdk.h"
-
-#include "cpuid.h"
-#include "nstack_log.h"
-#include "nstack_securec.h"
-#include "spl_hal.h"
-#include "hal_api.h"
-
-#include "sys.h"
-
-#define IFNAME0 'e'
-#define IFNAME1 'n'
-
-struct ethernetif
-{
- struct eth_addr *ethaddr;
-
-};
-
-#if (DPDK_MODULE != 1)
-NSTACK_STATIC void
-low_level_init (struct netif *pnetif)
-{
- struct ether_addr eth_addr;
-
- struct netifExt *pnetifExt = NULL;
- NSPOL_LOGINF (NETIF_DEBUG, "low_level_init \n");
-
- pnetifExt = getNetifExt (pnetif->num);
- if (NULL == pnetifExt)
- return;
-
- hal_get_macaddr (pnetifExt->hdl, &eth_addr);
- NSPOL_LOGINF (SC_DPDK_INFO,
- "low_level_init: Port %s, MAC : %02X:%02X:%02X:%02X:%02X:%02X",
- pnetifExt->if_name, eth_addr.addr_bytes[0],
- eth_addr.addr_bytes[1], eth_addr.addr_bytes[2],
- eth_addr.addr_bytes[3], eth_addr.addr_bytes[4],
- eth_addr.addr_bytes[5]);
-
- pnetif->hwaddr_len = 6;
- pnetif->hwaddr[0] = eth_addr.addr_bytes[0]; //0x00;
- pnetif->hwaddr[1] = eth_addr.addr_bytes[1]; //0x1b;
- pnetif->hwaddr[2] = eth_addr.addr_bytes[2]; //0x21;
- pnetif->hwaddr[3] = eth_addr.addr_bytes[3]; //0x6b;
- pnetif->hwaddr[4] = eth_addr.addr_bytes[4]; //0x24;
- pnetif->hwaddr[5] = eth_addr.addr_bytes[5]; //0x40;
- pnetif->mtu = SPL_FRAME_MTU;
-
- /* don't set SPL_NETIF_FLAG_ETHARP if this device is not an ethernet one */
- pnetif->flags =
- NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP;
- pnetif->flags |= NETIF_FLAG_IGMP;
-
-}
-#endif
-
-#if (DPDK_MODULE != 1)
-
-/**
- * Should be called at the beginning of the program to set up the
- * network interface. It calls the function low_level_init() to do the
- * actual setup of the hardware.
- *
- * This function should be passed as a parameter to spl_netif_add().
- *
- * @param netif the lwip network interface structure for this ethernetif
- * @return ERR_OK if the loopif is initialized
- * ERR_MEM if privatedata couldn't be allocated
- * any other err_t on error
- */
-err_t
-ethernetif_init (struct netif * pnetif)
-{
- struct ethernetif *eth_netif;
-
- if (NULL == pnetif)
- {
- NSPOL_LOGERR ("netif=NULL");
- return ERR_VAL;
- }
- NSPOL_LOGINF (NETIF_DEBUG, "ethernetif_init \n");
-
- eth_netif = (struct ethernetif *) malloc (sizeof (struct ethernetif));
- if (eth_netif == NULL)
- {
- NSPOL_LOGERR ("ethernetif_init: out of memory");
- return ERR_MEM;
- }
-
- pnetif->state = eth_netif;
- pnetif->name[0] = IFNAME0;
- pnetif->name[1] = IFNAME1;
-
- /* We directly use etharp_output() here to save a function call.
- * You can instead declare your own function an call etharp_output()
- * from it if you have to do some checks before sending (e.g. if link
- * is available...) */
- pnetif->output = etharp_output;
- pnetif->linkoutput = spl_hal_output;
-
- eth_netif->ethaddr = (struct eth_addr *) &(pnetif->hwaddr[0]);
-
- // Add extra netif information here
- if (0 != netifExt_add (pnetif))
- {
- return ERR_VAL;
- }
-
- /* initialize the hardware */
- low_level_init (pnetif);
- NSPOL_LOGINF (NETIF_DEBUG,
- "ethernetif_init complete ifname [%c][%c][%d] \n",
- pnetif->name[0], pnetif->name[1], pnetif->num);
-
- return ERR_OK;
-}
-
-void
-ethernetif_packets_input (struct netif *pstnetif)
-{
- struct spl_pbuf *p = NULL;
- spl_hal_input (pstnetif, &p);
-
- /* no packet could be read, silently ignore this */
- if (p != NULL
- && pstnetif->input (spl_convert_spl_pbuf_to_pbuf (p),
- pstnetif) != ERR_OK)
- {
- NSPOL_LOGERR ("netif->input failed]p=%p, netif=%p", p, pstnetif);
- }
-
- /* Free the spl pbuf */
- spl_pbuf_free (p);
-}
-#endif
-//#endif /* 0 */
diff --git a/stacks/lwip_stack/lwip_src/netif/sc_dpdk.c b/stacks/lwip_stack/lwip_src/netif/sc_dpdk.c
deleted file mode 100644
index 95f3eec..0000000
--- a/stacks/lwip_stack/lwip_src/netif/sc_dpdk.c
+++ /dev/null
@@ -1,574 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "sc_dpdk.h"
-#include "common_mem_mbuf.h"
-#include "netif/common.h"
-#include "nstack_log.h"
-#include "nstack_securec.h"
-#include "nsfw_msg_api.h"
-#include "nsfw_maintain_api.h"
-#include "nsfw_recycle_api.h"
-#include "stackx_app_res.h"
-#include "stackx_pbuf.h"
-#ifdef SYS_MEM_RES_STAT
-#include "memp.h"
-#endif
-#include "spl_instance.h"
-#ifdef HAL_LIB
-#else
-#include "rte_memzone.h"
-#endif
-
-#define SPL_MEM_MODULE "spl_mem_module"
-
-#define TMR_TICK_LENGTH TCP_TMR_INTERVAL /* define the tick length */
-
-u32_t uStackArgIndex = 0;
-int stackx_core_mask = 40;
-
-int g_nstack_bind_cpu = 0;
-int g_tcpip_thread_sleep_time = 0;
-
-extern int sbr_create_tx_pool ();
-extern int stackx_stat_zone_create ();
-
-#define GLOBAL_STACK_CORE_ARG "-c"
-#define GLOBAL_STACK_CORE_BINE "-bind_cpu"
-
-u32 g_type;
-struct memory_statics memory_used_size[80];
-
-void
-printmeminfo ()
-{
- unsigned int i = 0;
- long size = 0;
-
- NSPOL_LOGDBG (SC_DPDK_INFO,
- "*************************************************************");
- for (i = 0; i < g_type; i++)
- {
- NSPOL_LOGDBG (SC_DPDK_INFO, "%s : %ld", memory_used_size[i].name,
- memory_used_size[i].size);
- size += memory_used_size[i].size;
- }
-
- size += (g_type * sizeof (struct common_mem_memzone));
- NSPOL_LOGDBG (SC_DPDK_INFO, "total size %ld", size);
- NSPOL_LOGDBG (SC_DPDK_INFO,
- "*************************************************************");
-}
-
-void
-print_call_stack ()
-{
-}
-
-/* Parse the argument given in the command line of the application */
-void
-smp_parse_stack_args (int argc, char **argv)
-{
- int i = 0;
-
- const unsigned int global_core_length = 2; //GLOBAL_STACK_CORE_ARG "-c" string length is 2
-
- for (i = uStackArgIndex + 1; i < argc; i++)
- {
- if ((i + 1) < argc)
- {
- if (strncmp (argv[i], "-sleep", 6) == 0) //compare "-sleep" string, length is 6
- {
- g_tcpip_thread_sleep_time = atoi (argv[++i]);
- NSPOL_LOGDBG (SC_DPDK_INFO, "g_tcpip_thread_sleep_time=%d",
- g_tcpip_thread_sleep_time);
- continue;
- }
-
- if (strncmp (argv[i], GLOBAL_STACK_CORE_ARG, global_core_length) ==
- 0)
- {
- stackx_core_mask = atoi (argv[++i]);
- if (stackx_core_mask < 1)
- {
- NSPOL_LOGDBG (SC_DPDK_INFO,
- "Invalid Args:core_mask can't be less than 1,input value is:%s",
- argv[i]);
- }
-
- continue;
- }
-
- if (strncmp
- (argv[i], GLOBAL_STACK_CORE_BINE,
- sizeof (GLOBAL_STACK_CORE_BINE)) == 0)
- {
- if (argv[++i])
- {
- g_nstack_bind_cpu = atoi (argv[i]);
- }
-
- if (g_nstack_bind_cpu < 0)
- {
- g_nstack_bind_cpu = 0;
- }
-
- continue;
- }
- }
- else
- {
- NSPOL_LOGDBG (SC_DPDK_INFO, "Invalid args:%s miss value ", argv[i]); //now ,only support this format ,others maybe supported in future
- }
- }
-
- return;
-}
-
-mpool_handle
-create_tx_mbuf_pool ()
-{
- mpool_handle mbf_pool_handle = NULL;
-
- nsfw_mem_mbfpool mbuf_pool;
-
- mbuf_pool.stname.entype = NSFW_SHMEM;
- int retval =
- spl_snprintf (mbuf_pool.stname.aname, NSFW_MEM_NAME_LENGTH - 1, "%s",
- get_mempoll_tx_name ());
- if (retval < 0)
- {
- NSPOL_LOGERR ("spl_snprintf failed");
- return NULL;
- }
-
- mbuf_pool.usnum = TX_MBUF_POOL_SIZE - 1;
- mbuf_pool.uscash_size = 0;
- mbuf_pool.uspriv_size = 0;
- mbuf_pool.usdata_room = TX_MBUF_MAX_LEN;
- mbuf_pool.isocket_id = SOCKET_ID_ANY;
- mbuf_pool.enmptype = NSFW_MRING_SPSC;
- mbf_pool_handle = nsfw_mem_mbfmp_create (&mbuf_pool);
- if (NULL == mbf_pool_handle)
- {
- NSPOL_LOGERR ("create_tx_mbuf_pool failed]name=%s, num=%u, room=%u",
- mbuf_pool.stname.aname, mbuf_pool.usnum,
- mbuf_pool.usdata_room);
- return NULL;
- }
-
- NSPOL_LOGINF (SC_DPDK_INFO,
- "tx_mempool_malloc=%p, num=%u, room=%u, total_mem=%d",
- mbf_pool_handle, TX_MBUF_POOL_SIZE, mbuf_pool.usdata_room,
- nsfw_mem_get_len (mbf_pool_handle, NSFW_MEM_MBUF));
- DPDK_MEMORY_COUNT ((get_mempoll_tx_name ()),
- nsfw_mem_get_len (mbf_pool_handle, NSFW_MEM_MBUF));
- MEM_STAT (SPL_MEM_MODULE, "spl_mbuf_pool", NSFW_SHMEM,
- nsfw_mem_get_len (mbf_pool_handle, NSFW_MEM_MBUF));
-
- return mbf_pool_handle;
-}
-
-mring_handle
-create_segment_pool ()
-{
- nsfw_mem_sppool seg_pool;
- seg_pool.stname.entype = NSFW_SHMEM;
- int retval =
- spl_snprintf (seg_pool.stname.aname, NSFW_MEM_NAME_LENGTH - 1, "%s",
- get_mempoll_seg_name ());
- if (retval < 0)
- {
- NSPOL_LOGERR ("spl_snprintf failed");
- return NULL;
- }
-
- seg_pool.usnum = 16;
- seg_pool.useltsize = sizeof (struct common_pcb);
- seg_pool.isocket_id = SOCKET_ID_ANY;
- seg_pool.enmptype = NSFW_MRING_SPSC;
-
- mring_handle seg_mp_handle = nsfw_mem_sp_create (&seg_pool);
- if (NULL == seg_mp_handle)
- {
- NSPOL_LOGERR
- ("create_segment_pool common failed]name=%s, num=%u, size=%u",
- seg_pool.stname.aname, SPL_MEMP_NUM_TCP_SEG, seg_pool.useltsize);
- return NULL;
- }
-
- NSPOL_LOGINF (SC_DPDK_INFO,
- "common seg_mempool_malloc=%p, num=%u, size=%u, total_mem=%d",
- seg_mp_handle, SPL_MEMP_NUM_TCP_SEG, seg_pool.useltsize,
- nsfw_mem_get_len (seg_mp_handle, NSFW_MEM_SPOOL));
- DPDK_MEMORY_COUNT ((get_mempoll_seg_name ()),
- nsfw_mem_get_len (seg_mp_handle, NSFW_MEM_SPOOL));
- MEM_STAT (SPL_MEM_MODULE, "spl_seg_pool", NSFW_SHMEM,
- nsfw_mem_get_len (seg_mp_handle, NSFW_MEM_SPOOL));
- return seg_mp_handle;
-}
-
-mring_handle
-create_msg_pool ()
-{
- nsfw_mem_sppool msg_pool;
- msg_pool.stname.entype = NSFW_SHMEM;
- int retval =
- spl_snprintf (msg_pool.stname.aname, NSFW_MEM_NAME_LENGTH - 1, "%s",
- get_mempoll_msg_name ());
- if (retval < 0)
- {
- NSPOL_LOGERR ("spl_snprintf fail");
- return NULL;
- }
-
- msg_pool.usnum = TX_MSG_POOL_SIZE;
- msg_pool.useltsize = sizeof (data_com_msg);
- msg_pool.isocket_id = SOCKET_ID_ANY;
- msg_pool.enmptype = NSFW_MRING_MPMC;
- mring_handle msg_mp_handle = nsfw_mem_sp_create (&msg_pool);
-
- if (NULL == msg_mp_handle)
- {
- NSPOL_LOGERR ("create_msg_pool failed]name=%s, num=%u, size=%u",
- msg_pool.stname.aname, TX_MSG_POOL_SIZE,
- msg_pool.useltsize);
- return NULL;
- }
-
- NSPOL_LOGINF (SC_DPDK_INFO,
- "msg_pool_malloc=%p, num=%u, size=%u, total_mem=%d",
- msg_mp_handle, TX_MSG_POOL_SIZE, msg_pool.useltsize,
- nsfw_mem_get_len (msg_mp_handle, NSFW_MEM_SPOOL));
- DPDK_MEMORY_COUNT ((get_mempoll_msg_name ()),
- nsfw_mem_get_len (msg_mp_handle, NSFW_MEM_SPOOL));
- MEM_STAT (SPL_MEM_MODULE, "spl_msg_pool", NSFW_SHMEM,
- nsfw_mem_get_len (msg_mp_handle, NSFW_MEM_SPOOL));
- return msg_mp_handle;
-}
-
-mring_handle
-create_primary_box ()
-{
- nsfw_mem_mring mbox_pool;
- mbox_pool.stname.entype = NSFW_SHMEM;
- int retval =
- spl_snprintf (mbox_pool.stname.aname, NSFW_MEM_NAME_LENGTH - 1, "%s",
- get_stackx_ring_name ());
- if (retval < 0)
- {
- NSPOL_LOGERR ("spl_snprintf failed");
- return NULL;
- }
-
- mbox_pool.usnum = MBOX_RING_SIZE - 1;
- mbox_pool.isocket_id = SOCKET_ID_ANY;
- mbox_pool.enmptype = NSFW_MRING_MPSC;
- mring_handle mbox_handle = nsfw_mem_ring_create (&mbox_pool);
- if (NULL == mbox_handle)
- {
- NSPOL_LOGERR ("create_primary_mbox failed]name=%s, num=%u",
- mbox_pool.stname.aname, mbox_pool.usnum + 1);
- return NULL;
- }
-
- NSPOL_LOGINF (SC_DPDK_INFO, "primary_mbox_malloc=%p, num=%u, total_mem=%d",
- mbox_handle, MBOX_RING_SIZE,
- (nsfw_mem_get_len (mbox_handle, NSFW_MEM_RING)));
- DPDK_MEMORY_COUNT ((get_stackx_ring_name ()),
- (nsfw_mem_get_len (mbox_handle, NSFW_MEM_RING)));
- MEM_STAT (SPL_MEM_MODULE, "primary_mbox_ring", NSFW_SHMEM,
- (nsfw_mem_get_len (mbox_handle, NSFW_MEM_RING)));
- return mbox_handle;
-}
-
-mring_handle
-create_priority_box (u32 prio)
-{
- nsfw_mem_mring mbox_pool;
- mbox_pool.stname.entype = NSFW_SHMEM;
- int retval =
- spl_snprintf (mbox_pool.stname.aname, NSFW_MEM_NAME_LENGTH - 1, "%s",
- get_stackx_priority_ring_name (prio));
- if (retval < 0)
- {
- NSPOL_LOGERR ("spl_snprintf failed");
- return NULL;
- }
-
- mbox_pool.usnum = MBOX_RING_SIZE - 1;
- mbox_pool.isocket_id = SOCKET_ID_ANY;
- mbox_pool.enmptype = NSFW_MRING_MPSC;
- mring_handle mbox_handle = nsfw_mem_ring_create (&mbox_pool);
- if (NULL == mbox_handle)
- {
- NSPOL_LOGERR ("Create priority mbox fail]name=%s, num=%u",
- mbox_pool.stname.aname, mbox_pool.usnum + 1);
- return NULL;
- }
-
- NSPOL_LOGINF (SC_DPDK_INFO, "prio=%u, mbox=%p, num=%u, total_mem=%d", prio,
- mbox_handle, MBOX_RING_SIZE,
- (nsfw_mem_get_len (mbox_handle, NSFW_MEM_RING)));
- DPDK_MEMORY_COUNT ((get_stackx_priority_ring_name (prio)),
- (nsfw_mem_get_len (mbox_handle, NSFW_MEM_RING)));
- MEM_STAT (SPL_MEM_MODULE, mbox_pool.stname.aname, NSFW_SHMEM,
- (nsfw_mem_get_len (mbox_handle, NSFW_MEM_RING)));
- return mbox_handle;
-
-}
-
-int
-init_instance ()
-{
- int ret;
- p_def_stack_instance =
- (stackx_instance *) malloc (sizeof (stackx_instance));
- if (NULL == p_def_stack_instance)
- {
- NSPOL_LOGERR ("malloc failed");
- return -1;
- }
-
- ret = MEMSET_S (p_def_stack_instance, sizeof (stackx_instance), 0,
- sizeof (stackx_instance));
- if (EOK != ret)
- {
- NSPOL_LOGERR ("MEMSET_S failed]ret=%d", ret);
- return -1;
- }
-
- p_def_stack_instance->rss_queue_id = 0;
- p_def_stack_instance->netif_list = NULL;
- p_def_stack_instance->mp_tx = create_tx_mbuf_pool ();
- if (!p_def_stack_instance->mp_tx)
- {
- return -1;
- }
-
- (void) spl_reg_res_tx_mgr (p_def_stack_instance->mp_tx); // will only return 0, no need to check return value
-
- /* Modified above code to hold common_pcb */
- p_def_stack_instance->cpcb_seg = create_segment_pool ();
- if (!p_def_stack_instance->cpcb_seg)
- {
- return -1;
- }
-
- p_def_stack_instance->lmsg_pool = create_msg_pool ();
- if (!p_def_stack_instance->lmsg_pool)
- {
- return -1;
- }
-
- mring_handle mbox_array[SPL_MSG_BOX_NUM] = { NULL };
- p_def_stack_instance->lstack.primary_mbox.llring = create_primary_box ();
- if (!p_def_stack_instance->lstack.primary_mbox.llring)
- {
- return -1;
- }
- mbox_array[0] = p_def_stack_instance->lstack.primary_mbox.llring;
-
- u32 m = 0;
- while (m < MSG_PRIO_QUEUE_NUM)
- {
- p_def_stack_instance->lstack.priority_mbox[m].llring =
- create_priority_box (m);
- if (!p_def_stack_instance->lstack.priority_mbox[m].llring)
- {
- return -1;
- }
- mbox_array[m + 1] =
- p_def_stack_instance->lstack.priority_mbox[m].llring;
- m++;
- }
-
- (void) spl_add_mbox (mbox_array, SPL_MSG_BOX_NUM);
-
- g_nsfw_rti_primary_stat = &p_def_stack_instance->lstat.primary_stat; //save to g_nsfw_rti_primary_stat(this is a SH addr)
- return 0;
-}
-
-void
-spl_free_msgs_in_box (mring_handle r)
-{
- i32 count = 0, i = 0;
-
- void **msgs = NULL;
- data_com_msg *m = NULL;
-
- while ((count = nsfw_mem_ring_dequeuev (r, msgs, 32)) > 0)
- {
- /* drop all of them */
- if (msgs == NULL)
- break;
-
- for (i = 0; i < count; i++)
- {
- m = (data_com_msg *) msgs[i];
- if (m->param.op_type == MSG_ASYN_POST)
- ASYNC_MSG_FREE (m);
- else
- SYNC_MSG_ACK (m);
- }
- }
-}
-
-inline int
-spl_msg_malloc (data_com_msg ** p_msg_entry)
-{
- mring_handle msg_pool = NULL;
- int rslt;
- stackx_instance *instance = p_def_stack_instance;
- msg_pool = instance->lmsg_pool;
- if (!msg_pool)
- {
- NSPOL_LOGERR ("msg_pool is NULL");
- return -1;
- }
-
- rslt = nsfw_mem_ring_dequeue (msg_pool, (void **) p_msg_entry);
- if ((rslt == 0) || (*p_msg_entry == NULL))
- {
- NSPOL_LOGERR ("failed to get msg from ring");
- return -1;
- }
-
- res_alloc (&(*p_msg_entry)->param.res_chk);
-
- (*p_msg_entry)->param.msg_from = msg_pool;
- (*p_msg_entry)->param.err = ERR_OK;
- return 0;
-}
-
-struct spl_pbuf *
-spl_mbuf_malloc (uint16_t len, spl_pbuf_type Type, u16_t * count)
-{
- struct common_mem_mbuf *mbuf = NULL;
- struct common_mem_mbuf *mbuf_first = NULL;
- struct common_mem_mbuf *mbuf_tail = NULL;
- struct spl_pbuf *buf = NULL;
- struct spl_pbuf *first = NULL;
- struct spl_pbuf *tail = NULL;
-
- mpool_handle mp = NULL;
-
- mp = p_def_stack_instance->mp_tx;
- if (mp == NULL)
- {
- return NULL; /*if mp is NULL when init app will Inform */
- }
-
- while (len > 0)
- {
- mbuf = (struct common_mem_mbuf *) nsfw_mem_mbf_alloc (mp, NSFW_SHMEM);
- if (unlikely (mbuf == NULL))
- {
- if (mbuf_first != NULL)
- {
- if (res_free
- (&
- (((struct spl_pbuf *) ((char *) mbuf_first +
- sizeof (struct
- common_mem_mbuf)))->res_chk)))
- {
- NSPOL_LOGERR ("res_free failed");
- }
- spl_mbuf_free (mbuf_first);
- }
-
- return NULL;
- }
-
- uint16_t alloc = TX_MBUF_MAX_LEN;
- if (len < TX_MBUF_MAX_LEN)
- {
- alloc = len;
- }
-
- (*count)++;
- mbuf->data_len = alloc;
- mbuf->next = NULL;
- buf =
- (struct spl_pbuf *) ((char *) mbuf + sizeof (struct common_mem_mbuf));
- res_alloc (&buf->res_chk);
-
- buf->next_a = 0;
- buf->payload_a = ADDR_LTOSH_EXT (common_pktmbuf_mtod (mbuf, void *));
- buf->tot_len = len;
- buf->len = alloc;
- buf->type = Type;
- buf->flags = 0;
-
- buf->freeNext = NULL;
-
- buf->conn_a = 0;
-
- if (first == NULL)
- {
- first = buf;
- mbuf_first = mbuf;
- tail = buf;
- mbuf_tail = mbuf;
- mbuf_first->nb_segs = 1;
- mbuf_first->pkt_len = alloc;
- }
- else
- {
- /* Already there is a check for the return value of rtp_pktmbuf_alloc,
- hence not an issue */
-
- tail->next_a = ADDR_LTOSH_EXT (buf);
- tail = buf;
-#ifdef HAL_LIB
-#else
- mbuf_tail->next = mbuf;
-#endif
- mbuf_tail = mbuf;
-
- mbuf_first->pkt_len = (mbuf_first->pkt_len + mbuf->data_len);
- mbuf_first->nb_segs++;
-
- }
-
- len -= alloc;
- }
-
- return first;
-}
-
-/*
- * Ring distribution function: protocol stack once a packet processing, so there is no use of bulk package
- * @param buf pbuf means * @param packet_inport the packet from which the port to enter, for the configuration table with the ip comparison
- * @ Protocol stack add location: ip.c-> ip_input () -> (if (netif == NULL) branch)
- * @ Return value: 0 for the send into * 0 for the transmission failed: send the original failure 1,
- * err = -20 did not match to the client, err = -1Ring full, overflow, will release the package
-*/
-
-inline void
-spl_mbuf_free (void *mbuf)
-{
- (void) nsfw_mem_mbf_free ((mbuf_handle) mbuf, NSFW_SHMEM);
-}
-
-inline uint16_t
-spl_mbuf_refcnt_update (void *mbuf, int16_t value)
-{
- common_mbuf_refcnt_set ((struct common_mem_mbuf *) mbuf,
- common_mbuf_refcnt_read ((struct common_mem_mbuf *)
- mbuf) + value);
- return 1;
-}
diff --git a/stacks/lwip_stack/lwip_src/netif/spl_hal.c b/stacks/lwip_stack/lwip_src/netif/spl_hal.c
deleted file mode 100644
index db843d4..0000000
--- a/stacks/lwip_stack/lwip_src/netif/spl_hal.c
+++ /dev/null
@@ -1,1774 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "sys_arch.h"
-#include "netif.h"
-#include "spl_sockets.h"
-//#include <netinet/in.h>
-
-#include "stackx_spl_share.h"
-#include "stackx_pbuf.h"
-#include "spl_api.h"
-#include "sharedmemory.h"
-//#include "nettool.h"
-#include "lwip/etharp.h"
-#include "ip_module_api.h"
-#include "sc_dpdk.h"
-#include "nstack_log.h"
-#include "common.h"
-#include "nstack_securec.h"
-//#include "ip.h"
-#include "configuration_reader.h"
-#include "spl_hal.h"
-#include "nsfw_maintain_api.h"
-#include "stackx_common.h"
-#include "spl_instance.h"
-#include <netinet/in.h>
-#include "prot/tcp.h"
-
-extern u32_t g_mbuf_size[MAX_THREAD_NUM];
-extern u32_t uStackArgIndex;
-extern void smp_parse_stack_args (int argc, char **argv);
-extern void spl_do_dump (struct spl_pbuf *p, u16 direction);
-
-#define SPL_HAL_SEND_TRY 100000
-
-#define SPL_HAL_MODULE "SPL_HAL_MODULE"
-extern u16_t g_offSetArry[SPL_PBUF_MAX_LAYER];
-
-/* structure to store the rx and tx packets. Put two per cache line as ports
- * used in pairs */
-struct port_stats
-{
- unsigned rx;
- unsigned tx;
- unsigned drop;
- u64_t rx_size;
- u64_t tx_size;
- u64_t recv_last_cycles;
- u64_t send_last_cycles;
-} __attribute__ ((aligned (COMMON_CACHE_LINE_SIZE / 2)));
-
-struct port_capa
-{
- u32_t tx_ipv4_cksum_offload;
- u32_t tx_udp_cksum_offload;
- u32_t tx_tcp_cksum_offload;
-};
-
-struct rx_pkts
-{
- u16_t num;
- u16_t index;
- struct common_mem_mbuf *pkts[PKT_BURST];
-};
-
-struct tx_pkts
-{
- u16_t num;
- struct common_mem_mbuf *pkts[PKT_BURST];
-};
-
-struct port_pkts
-{
- struct rx_pkts rx;
- struct tx_pkts tx;
-};
-
-struct psd_header
-{
- u32_t src_addr; /* IPaddress of source host. */
- u32_t dst_addr; /* IPaddress of destination host(s). */
- u8_t zero; /* zero. */
- u8_t proto; /* L4 protocol type. */
- u16_t len; /* L4 length. */
-} __attribute__ ((__packed__));
-
-NSTACK_STATIC unsigned num_ports_NIC = 0;
-NSTACK_STATIC unsigned num_ports_NIC_start = 0;
-
-struct stackx_port_info *head_used_port_list;
-struct stackx_port_zone *p_stackx_port_zone = NULL;
-
-struct bond_ports_info bond_ports_array = {.cnt = 0 };
-
-static u8_t bond_ports_array_cnt_start = 0;
-
-static struct port_capa spl_hal_capa = { 0 };
-
-static struct port_pkts spl_hal_pkts[HAL_MAX_NIC_NUM];
-
-NSTACK_STATIC inline u16_t
-get_ipv4_16b_sum (u16_t * ptr16, u32_t nr)
-{
- u32_t sum = 0;
-
- while (nr > 1)
- {
- sum += *ptr16;
- nr -= sizeof (u16_t);
- ptr16++;
-
- if (sum > UINT16_MAX)
- {
- sum -= UINT16_MAX;
- }
- }
-
- /* If length is in odd bytes */
- if (nr)
- {
- sum += *((u8_t *) ptr16);
- }
-
- sum = ((sum & 0xffff0000) >> 16) + (sum & 0xffff);
- sum &= 0x0ffff;
- return (u16_t) sum;
-}
-
-NSTACK_STATIC inline u16_t
-get_ipv4_bswap16 (u16_t x)
-{
- return (u16_t) (((x & 0x00ffU) << 8) | ((x & 0xff00U) >> 8));
-}
-
-NSTACK_STATIC inline u16_t
-get_ipv4_psd_sum (struct ip_hdr * iphdr, u64_t ol_flags)
-{
- struct psd_header psd_hdr;
-
- psd_hdr.src_addr = iphdr->src.addr;
- psd_hdr.dst_addr = iphdr->dest.addr;
- psd_hdr.zero = 0;
- psd_hdr.proto = iphdr->_proto;
-
- if (ol_flags & PKT_TX_TCP_SEG)
- {
- psd_hdr.len = 0;
- }
- else
- {
- psd_hdr.len = get_ipv4_bswap16 ((get_ipv4_bswap16 (iphdr->_len)
- - sizeof (struct ip_hdr)));
- }
-
- return get_ipv4_16b_sum ((u16_t *) & psd_hdr, sizeof (struct psd_header));
-}
-
-/* should be called after head_used_port_list is initialized */
-NSTACK_STATIC hal_hdl_t
-get_port_hdl_by_name (const char *name)
-{
- unsigned int i = 0;
- struct stackx_port_info *p = p_stackx_port_zone->stackx_one_port;
-
- while (i < p_stackx_port_zone->port_num)
- {
- if (!strncasecmp (p->linux_ip.if_name, name, strlen (name)))
- {
- return p->linux_ip.hdl;
- }
-
- p = &p_stackx_port_zone->stackx_one_port[++i];
- }
-
- NSPOL_LOGERR ("failed to find port id]name=%s", name);
- return hal_get_invalid_hdl ();
-}
-
-NSTACK_STATIC struct stackx_port_info *
-get_port_info_by_name (const char *name)
-{
- struct stackx_port_info *p = p_stackx_port_zone->stackx_one_port;
- unsigned int i = 0;
-
- while (i < p_stackx_port_zone->port_num)
- {
- if (!strncasecmp (p->linux_ip.if_name, name, strlen (name)))
- {
- return p;
- }
-
- p = &p_stackx_port_zone->stackx_one_port[++i];
- }
-
- return NULL;
-}
-
-NSTACK_STATIC int
-del_port_in_port_list (const char *name)
-{
- struct stackx_port_info *inf = head_used_port_list;
- struct stackx_port_info *prev = NULL;
-
- while (inf)
- {
- if (!strncasecmp (inf->linux_ip.if_name, name, strlen (name)))
- {
- if (prev != NULL)
- {
- prev->next_use_port = inf->next_use_port;
- }
- else
- {
- head_used_port_list = inf->next_use_port;
- }
-
- break;
- }
-
- prev = inf;
- inf = inf->next_use_port;
- }
-
- return 0;
-}
-
-extern void create_netif (struct stackx_port_info *p_port_info);
-
-NSTACK_STATIC int
-add_port_in_port_list (struct stackx_port_info *p)
-{
- char *name;
- struct stackx_port_info *inf = head_used_port_list;
- struct stackx_port_info *prev = NULL;
-
- name = p->linux_ip.if_name;
-
- while (inf)
- {
- if (!strncasecmp (inf->linux_ip.if_name, name, strlen (name)))
- {
- NSPOL_LOGERR ("ERROR: add an existing port!");
- return -1;
- }
-
- prev = inf;
- inf = inf->next_use_port;
- }
-
- if (prev == NULL)
- {
- head_used_port_list = p;
- }
- else
- {
- prev->next_use_port = p;
- }
-
- p->next_use_port = NULL;
- create_netif (p);
- return 0;
-}
-
-/* Queries the link status of a port and prints it to screen */
-NSTACK_STATIC void
-report_port_link_status (struct stackx_port_info *p)
-{
- /* get link status */
- u32 status;
-
- status = hal_link_status (p->linux_ip.hdl);
-
- if (status)
- {
- NSPOL_LOGINF (SC_DPDK_INFO, "Port=%s: Link Up", p->linux_ip.if_name);
- }
- else
- {
- NSPOL_LOGINF (SC_DPDK_INFO, "Port=%s: Link Down", p->linux_ip.if_name);
- }
-}
-
-int
-spl_hal_ether_etoa (const unsigned char *e, int e_len, char *a, int a_len)
-{
- char *c = a;
- int i;
- int retVal;
-
- if (!e || !a || e_len < 0)
- return -1;
-
- if (e_len > NETIF_ETH_ADDR_LEN)
- e_len = NETIF_ETH_ADDR_LEN;
-
- if (a_len < e_len * 3)
- return -1;
-
- for (i = 0; i < e_len; i++)
- {
- if (i)
- {
- *c++ = ':';
- }
- retVal = SPRINTF_S (c, a_len - (c - a), "%02x", e[i] & 0xff);
- if (-1 == retVal)
- {
- NSPOL_LOGERR ("SPRINTF_S failed]ret=%d.", retVal);
- return -1;
- }
- c = c + retVal;
- }
-
- return 0;
-}
-
-NSTACK_STATIC inline void
-spl_hal_buf_convert (struct common_mem_mbuf *mbuf, struct spl_pbuf **buf)
-{
- struct common_mem_mbuf *before = NULL;
- struct spl_pbuf *last = NULL;
- struct spl_pbuf *first = NULL;
- struct spl_pbuf *tmp = NULL;
-
- while (mbuf != NULL)
- {
- //dpdk 2.1
- tmp =
- (struct spl_pbuf *) ((char *) mbuf + sizeof (struct common_mem_mbuf));
- res_alloc (&tmp->res_chk);
- tmp->payload = common_pktmbuf_mtod (mbuf, void *);
- tmp->tot_len = mbuf->pkt_len;
- tmp->len = mbuf->data_len;
- tmp->type = SPL_PBUF_HUGE;
- tmp->proto_type = SPL_PBUF_PROTO_NONE;
- tmp->next = NULL;
- tmp->flags = 0;
-
- if (first == NULL)
- {
- first = tmp;
- last = first;
- }
- else
- {
- /* Always the "if(first == NULL)" code segment is executed and then
- "else" segment code is executed, so the "last" variable is not
- NULL always when "else" case is executed */
- last->next = tmp;
- last = tmp;
- }
-
- before = mbuf;
- mbuf = mbuf->next;
-
- before->next = NULL;
- }
-
- *buf = first;
-}
-
-NSTACK_STATIC int
-spl_hal_port_zone_init ()
-{
- int retVal;
- nsfw_mem_zone create_port_zone;
- nsfw_mem_zone create_port_info;
- struct stackx_port_info *mz_port_info;
- INITPOL_LOGINF ("HAL", "spl_hal_port_zone_init", NULL_STRING,
- LOG_INVALID_VALUE, MODULE_INIT_START);
-
- if ((CUR_CFG_HAL_PORT_NUM < 1)
- || (SIZE_MAX / sizeof (struct stackx_port_info) < CUR_CFG_HAL_PORT_NUM))
- {
- NSPOL_LOGERR ("malloc parameter incorrect]max_linux_port=%u",
- CUR_CFG_HAL_PORT_NUM);
- return -1;
- }
-
- if (spl_snprintf
- (create_port_zone.stname.aname, NSFW_MEM_NAME_LENGTH - 1, "%s",
- MP_STACKX_PORT_ZONE) < 0)
- {
- NSPOL_LOGERR ("spl_snprintf fail");
-
- return -1;
- }
-
- create_port_zone.stname.entype = NSFW_SHMEM;
- create_port_zone.isocket_id = SOCKET_ID_ANY;
- create_port_zone.length = sizeof (struct stackx_port_zone);
- create_port_zone.ireserv = 0;
- p_stackx_port_zone =
- (struct stackx_port_zone *) nsfw_mem_zone_create (&create_port_zone);
-
- if (NULL == p_stackx_port_zone)
- {
- INITPOL_LOGERR ("HAL", "spl_hal_port_zone_init",
- "Cannot create memory zone for MP_STACKX_PORT_ZONE information",
- LOG_INVALID_VALUE, MODULE_INIT_FAIL);
- common_exit (EXIT_FAILURE,
- "Cannot create memory zone for MP_STACKX_PORT_ZONE information");
- }
-
- retVal =
- MEMSET_S (p_stackx_port_zone, sizeof (struct stackx_port_zone), 0,
- sizeof (struct stackx_port_zone));
-
- if (EOK != retVal)
- {
- INITPOL_LOGERR ("HAL", "spl_hal_port_zone_init", "MEMSET_S return fail",
- retVal, MODULE_INIT_FAIL);
- nsfw_mem_zone_release (&create_port_zone.stname);
- return -1;
- }
-
- if (spl_snprintf
- (create_port_info.stname.aname, NSFW_MEM_NAME_LENGTH - 1, "%s",
- MP_STACKX_PORT_INFO) < 0)
- {
- NSPOL_LOGERR ("VSNPRINTF_S fail");
- return -1;
- }
-
- create_port_info.stname.entype = NSFW_SHMEM;
- create_port_info.isocket_id = SOCKET_ID_ANY;
- create_port_info.length =
- CUR_CFG_HAL_PORT_NUM * sizeof (struct stackx_port_info);
- create_port_info.ireserv = 0;
- mz_port_info =
- (struct stackx_port_info *) nsfw_mem_zone_create (&create_port_info);
-
- if (NULL == mz_port_info)
- {
- INITPOL_LOGERR ("HAL", "spl_hal_port_zone_init",
- "Cannot create memory zone for MP_STACKX_PORT_INFO information",
- LOG_INVALID_VALUE, MODULE_INIT_FAIL);
- common_exit (EXIT_FAILURE,
- "Cannot create memory zone for MP_STACKX_PORT_INFO information");
- }
-
- retVal =
- MEMSET_S (mz_port_info, create_port_info.length, 0,
- create_port_info.length);
-
- if (EOK != retVal)
- {
- INITPOL_LOGERR ("HAL", "spl_hal_port_zone_init", "MEMSET_S return fail",
- retVal, MODULE_INIT_FAIL);
- nsfw_mem_zone_release (&create_port_info.stname);
- nsfw_mem_zone_release (&create_port_zone.stname);
- return -1;
- }
-
- MEM_STAT (SPL_HAL_MODULE, create_port_zone.stname.aname, NSFW_SHMEM,
- create_port_info.length);
-
- p_stackx_port_zone->stackx_one_port = mz_port_info;
-
- INITPOL_LOGINF ("HAL", "spl_hal_port_zone_init", NULL_STRING,
- LOG_INVALID_VALUE, MODULE_INIT_SUCCESS);
-
- return 0;
-}
-
-int
-spl_hal_init (int argc, char *argv[])
-{
- int retval = -1;
- int idx_init;
-
- NSPOL_LOGINF (SC_DPDK_INFO, "spl_hal_init start");
-
- /* Get nstack args */
- smp_parse_stack_args (argc, argv);
-
- if (0 == uStackArgIndex)
- {
- NSPOL_LOGERR ("uStackArgIndex is 0, can lead to long loop]");
- return retval;
- }
-
- /* Init DPDK */
- argc = uStackArgIndex--;
- INITPOL_LOGINF ("HAL", "hal_init_global", NULL_STRING, LOG_INVALID_VALUE,
- MODULE_INIT_START);
-
- for (idx_init = 0; idx_init < argc; idx_init++)
- {
- NSPOL_LOGINF (SC_DPDK_INFO,
- "hal_init_global]idx_init=%d,argv[idx_init]=%s", idx_init,
- argv[idx_init]);
- }
-
- retval = hal_init_global (argc, argv);
-
- if (0 != retval)
- {
- NSPOL_LOGERR ("call hal_init_global fail]retval = %d", retval);
- return -1;
- }
-
- retval = hal_init_local ();
-
- if (0 != retval)
- {
- NSPOL_LOGERR ("call hal_init_local fail]retval = %d", retval);
- return -1;
- }
-
- retval = spl_hal_port_zone_init ();
- if (0 != retval)
- {
- NSPOL_LOGERR ("call hal_init_local fail]retval = %d", retval);
- return -1;
- }
-
- NSPOL_LOGDBG (SC_DPDK_INFO, "Finished Process Init");
-
- return 0;
-
-}
-
-static inline int
-spl_hal_rx_mbuf_free (void *data, void *arg)
-{
- struct spl_pbuf *tmp = NULL;
- struct common_mem_mbuf *mbuf = (struct common_mem_mbuf *) data;
- (void) arg;
-
- tmp = (struct spl_pbuf *) ((char *) mbuf + sizeof (struct common_mem_mbuf));
- if (tmp->res_chk.alloc_flag == TRUE)
- return 1;
-
- if (common_mbuf_refcnt_read (mbuf) == 0)
- return 1;
-
- NSPOL_LOGDBG (SC_DPDK_INFO, "rx_pool init in fault case: free mbuf=%p",
- mbuf);
- spl_mbuf_free (mbuf);
- return 0;
-}
-
-struct common_mem_mempool *
-spl_hal_rx_pool_create (int nic_id, int queue_id, int start_type)
-{
- int retval;
- struct common_mem_mempool *mp;
- nsfw_mem_mbfpool create_mbuf_pool;
- nsfw_mem_name lookup_mbuf_pool;
- struct common_mem_ring *ring;
-
- if (start_type == 1)
- {
- create_mbuf_pool.stname.entype = NSFW_SHMEM;
- create_mbuf_pool.uscash_size = 0;
- create_mbuf_pool.uspriv_size = 0;
- create_mbuf_pool.isocket_id = SOCKET_ID_ANY;
- create_mbuf_pool.enmptype = NSFW_MRING_SPSC;
-
- retval =
- spl_snprintf (create_mbuf_pool.stname.aname, NSFW_MEM_NAME_LENGTH - 1,
- "%s", get_mempoll_rx_name (queue_id, nic_id));
-
- if (-1 == retval)
- {
- NSPOL_LOGERR ("spl_snprintf fail");
- return NULL;
- }
-
- create_mbuf_pool.usnum = RX_MBUF_POOL_SIZE - 1;
- /*performance, rx buf cap is special, ((size - HEADROOM) >> 10) <<10, see ixgbe_dev_rx_init;
- if want cap size == TX_MBUF_MAX_LEN, must let data_root=TX_MBUF_MAX_LEN+COMMON_PKTMBUF_HEADROOM and
- TX_MBUF_MAX_LEN must N*1024;
- */
- create_mbuf_pool.usdata_room =
- TX_MBUF_MAX_LEN + COMMON_PKTMBUF_HEADROOM;
-
- NSPOL_LOGDBG (SC_DPDK_INFO, "hal_rx_pool.usnum=%u, usdata_room=%u",
- create_mbuf_pool.usnum, create_mbuf_pool.usdata_room);
-
- mp =
- (struct common_mem_mempool *)
- nsfw_mem_mbfmp_create (&create_mbuf_pool);
-
- if (mp == NULL)
- {
- NSPOL_LOGERR ("nsfw_mem_mbfmp_create fail");
- return NULL;
- }
-
- MEM_STAT (SPL_HAL_MODULE, create_mbuf_pool.stname.aname, NSFW_SHMEM,
- nsfw_mem_get_len (mp, NSFW_MEM_MBUF));
- NSPOL_LOGDBG (SC_DPDK_INFO, "create:thread=%d,nic_id=%d,mp=%p,size=%d",
- queue_id, nic_id, mp, nsfw_mem_get_len (mp,
- NSFW_MEM_MBUF));
-
- char rx_msg_arr_name[NSFW_MEM_NAME_LENGTH];
- data_com_msg *rx_msg_array = NULL;
- retval = spl_snprintf (rx_msg_arr_name, NSFW_MEM_NAME_LENGTH, "%s",
- get_mempoll_rxmsg_name (queue_id, nic_id));
-
- if (-1 != retval)
- {
- rx_msg_array = (data_com_msg *) sbr_create_mzone (rx_msg_arr_name,
- (size_t)
- sizeof
- (data_com_msg) *
- RX_MBUF_POOL_SIZE);
- }
-
- if (!rx_msg_array)
- {
- NSSBR_LOGERR
- ("Create rx_msg_array zone fail]name=%s, num=%u, size=%zu",
- rx_msg_arr_name, RX_MBUF_POOL_SIZE,
- (size_t) sizeof (data_com_msg) * RX_MBUF_POOL_SIZE);
- }
- else
- {
- /*bind msg to pbuf */
- MEM_STAT (SPL_HAL_MODULE, rx_msg_arr_name, NSFW_SHMEM,
- (size_t) sizeof (data_com_msg) * RX_MBUF_POOL_SIZE);
- NSSBR_LOGINF
- ("Create rx_msg_array zone ok]name=%s, ptr=%p, num=%u, size=%zu",
- rx_msg_arr_name, rx_msg_array, RX_MBUF_POOL_SIZE,
- sizeof (data_com_msg) * RX_MBUF_POOL_SIZE);
-
- struct common_mem_mbuf *mbuf = NULL;
- struct spl_pbuf *buf = NULL;
- u32 loop = 0;
-
- for (; loop < RX_MBUF_POOL_SIZE; loop++)
- {
- mbuf = nsfw_mem_mbf_alloc (mp, NSFW_SHMEM);
-
- if (!mbuf)
- {
- /* alloc failed , still can work, no prebind success just not so faster */
- NSSBR_LOGERR
- ("nsfw_mem_mbf_alloc failed,this can not happen");
- break;
- }
-
- buf =
- (struct spl_pbuf *) ((char *) mbuf +
- sizeof (struct common_mem_mbuf));
- sys_sem_init (&rx_msg_array[loop].param.op_completed);
- rx_msg_array[loop].param.msg_from = NULL;
- buf->msg = (void *) &rx_msg_array[loop];
- (void) res_free (&buf->res_chk); //no need to check return value, as it will do free operation depends on alloc_flag
-
- if (nsfw_mem_mbf_free (mbuf, NSFW_SHMEM) < 0)
- {
- /* free failed , still can work, no prebind work just not so faster */
- NSSBR_LOGERR
- ("nsfw_mem_mbf_free failed,this can not happen");
- break;
- }
- }
-
- }
-
- }
- else
- {
- retval =
- spl_snprintf (lookup_mbuf_pool.aname, NSFW_MEM_NAME_LENGTH - 1, "%s",
- get_mempoll_rx_name (queue_id, nic_id));
-
- if (-1 == retval)
- {
- NSPOL_LOGERR ("spl_snprintf fail");
- return NULL;
- }
-
- lookup_mbuf_pool.entype = NSFW_SHMEM;
- lookup_mbuf_pool.enowner = NSFW_PROC_MAIN;
- mp =
- (struct common_mem_mempool *)
- nsfw_mem_mbfmp_lookup (&lookup_mbuf_pool);
-
- if (mp == NULL)
- {
- NSPOL_LOGERR ("nsfw_mem_mbfmp_lookup fail, name=%s, try to create",
- lookup_mbuf_pool.aname);
- return spl_hal_rx_pool_create (nic_id, queue_id, 1);
- }
-
- NSPOL_LOGDBG (SC_DPDK_INFO, "lookup:thread=%d,nic_id=%d,mp=%p,size=%d",
- queue_id, nic_id, mp, nsfw_mem_get_len (mp,
- NSFW_MEM_MBUF));
-
- /*We have to recycle RX mbufs hold by DPDK when fault recovering of upgrading nstack */
- if (start_type == 3 || start_type == 2)
- {
- ring = (struct common_mem_ring *) (mp->pool_data);
- NSPOL_LOGINF (SC_DPDK_INFO,
- "BEFORE clear rx_mpool]prod.head=%u, prod.tail=%u, "
- "cons.head=%u, cons.tail=%u", ring->prod.head,
- ring->prod.tail, ring->cons.head, ring->cons.tail);
-
- if (nsfw_mem_mbuf_iterator (mp, 0, mp->size,
- spl_hal_rx_mbuf_free, NULL) < 0)
- {
- NSPOL_LOGERR ("nsfw_mem_mbuf_iterator return fail");
- return NULL;
- }
-
- NSPOL_LOGINF (SC_DPDK_INFO,
- "AFTER clear rx_mpool]prod.head=%u, prod.tail=%u, "
- "cons.head=%u, cons.tail=%u", ring->prod.head,
- ring->prod.tail, ring->cons.head, ring->cons.tail);
- }
-
- }
-
- return mp;
-
-}
-
-int
-spl_hal_bond_config (struct network_configuration *network)
-{
- struct phy_net *phynet = network->phy_net;
- struct ref_nic *phead = phynet->header;
- static u8_t bond_index = 0; /* for auto-generating bond_name */
- unsigned int check_bond = 0, check_name;
- int retVal;
- u8_t j, k, idx = 0;
-
- /* get bond info from network configuration */
- if (phynet->bond_mode != -1 && bond_ports_array.cnt < MAX_BOND_PORT_NUM)
- {
- struct ref_nic *phead_bond = phead;
- char *name = phynet->bond_name;
- struct bond_set *s = &bond_ports_array.ports[bond_ports_array.cnt];
-
- while (phead_bond != NULL)
- {
- /* check slave name, repeated slave nic cannot be added to bond set. */
- check_name = 0;
-
- for (j = 0; j < idx; j++)
- {
- if (strcmp (s->slave_ports[j], phead_bond->nic_name) == 0)
- {
- check_name = 1;
- break;
- }
- }
-
- if (check_name)
- {
- break;
- }
-
- /* if this nic has been added to a bond_set, ignore it */
- check_bond = 0;
-
- for (k = 0; k < bond_ports_array.cnt && !check_bond; k++)
- {
- for (j = 0;
- j < bond_ports_array.ports[k].slave_port_cnt
- && !check_bond; j++)
- {
- if (strcmp
- (bond_ports_array.ports[k].slave_ports[j],
- phead_bond->nic_name) == 0)
- {
- check_bond = 1;
-
- if (name[0] == 0)
- {
- retVal =
- STRNCPY_S (name, IP_MODULE_MAX_NAME_LEN,
- bond_ports_array.
- ports[k].bond_port_name,
- strlen (bond_ports_array.
- ports[k].bond_port_name));
- if (EOK != retVal)
- {
- NSPOL_LOGERR ("STRNCPY_S failed]ret=%d.",
- retVal);
- return -1;
- }
- }
-
- if (strcmp
- (name,
- bond_ports_array.ports[k].bond_port_name) != 0)
- {
- NSOPR_SET_ERRINFO (-1, "%s init failed!\n", name);
- NSPOL_LOGERR
- ("%s init failed! %s in both %s and %s", name,
- phead_bond->nic_name, name,
- bond_ports_array.ports[k].bond_port_name);
- return -1;
- }
- }
- }
- }
-
- if (check_bond == 1)
- {
- break;
- }
-
- /* copy slave ports name to bond array */
- retVal =
- STRNCPY_S (s->slave_ports[idx], HAL_MAX_NIC_NAME_LEN,
- phead_bond->nic_name, strlen (phead_bond->nic_name));
-
- if (EOK != retVal)
- {
- NSPOL_LOGERR ("STRNCPY_S failed]ret=%d.", retVal);
- return -1;
- }
-
- idx++;
- phead_bond = phead_bond->next;
-
- if (idx >= HAL_MAX_SLAVES_PER_BOND)
- {
- break;
- }
- }
-
- if (check_bond == 0)
- {
- if (name[0] == 0)
- {
- /* if bond_name is a empty string, generate a new bond name */
- retVal =
- SPRINTF_S (name, HAL_MAX_NIC_NAME_LEN, "bond%u_auto",
- bond_index++);
-
- if (-1 == retVal)
- {
- NSPOL_LOGERR ("SPRINTF_S failed]ret=%d.", retVal);
- return -1;
- }
- }
-
- /* copy bond_name to bond array */
- retVal =
- STRNCPY_S (s->bond_port_name, HAL_MAX_NIC_NAME_LEN, name,
- strlen (name));
-
- if (EOK != retVal)
- {
- NSPOL_LOGERR ("STRNCPY_S failed]ret=%d.", retVal);
- return -1;
- }
-
- s->slave_port_cnt = idx;
- bond_ports_array.cnt++;
- NSPOL_LOGINF (SC_DPDK_INFO,
- "bond_ports_array.cnt=%u,slave_port_cnt=%u",
- bond_ports_array.cnt, s->slave_port_cnt);
- }
- }
-
- return 0;
-}
-
-int
-spl_hal_port_config (unsigned int *port_num)
-{
- int retVal;
- unsigned int check;
- struct phy_net *phynet;
-
- struct network_configuration *network = get_network_list ();
-
- if (!network)
- {
- NSPOL_LOGERR ("fail to get_provider_node");
- return -1;
- }
-
- unsigned int port_index = p_stackx_port_zone->port_num;
-
- while (network && (phynet = network->phy_net))
- {
- struct ref_nic *phead = phynet->header;
- NSPOL_LOGINF (SC_DPDK_INFO, "network=%p,network_name=%s", network,
- network->network_name);
-
- if (spl_hal_bond_config (network) < 0)
- {
- NSPOL_LOGERR ("spl_hal_bond_config fail.");
- return -1;
- }
-
- while (phead != NULL)
- {
- /* check if the NIC is inited */
- for (check = 0; check < port_index; ++check)
- {
- if (strcmp
- (p_stackx_port_zone->stackx_one_port[check].
- linux_ip.if_name, phead->nic_name) == 0)
- {
- break;
- }
- }
-
- if (check != port_index)
- {
- phead = phead->next;
- continue;
- }
-
- /* check if the number of VF exceeds MAX_VF_NUM */
- if (port_index >= MAX_VF_NUM + p_stackx_port_zone->bonded_port_num)
- {
- NSOPR_SET_ERRINFO (-1, "Support Only %d VF. %s init failed!\n",
- MAX_VF_NUM, phead->nic_name);
- NSPOL_LOGERR ("Support Only %d VF. %s init failed!", MAX_VF_NUM,
- phead->nic_name);
- NSOPR_SET_ERRINFO (-1, "Add network %s failed!\n",
- network->network_name);
- break;
- }
-
- if (strlen (phead->nic_name) >=
- sizeof (p_stackx_port_zone->
- stackx_one_port[port_index].linux_ip.if_name) - 1
- || strlen (phead->nic_name) <= 3)
- {
- NSPOL_LOGERR ("Invalid configuration");
- return -1;
- }
-
- retVal =
- STRCPY_S (p_stackx_port_zone->
- stackx_one_port[port_index].linux_ip.if_name,
- sizeof (p_stackx_port_zone->
- stackx_one_port[port_index].linux_ip.if_name),
- phead->nic_name);
-
- if (EOK != retVal)
- {
- NSPOL_LOGERR ("STRCPY_S failed]ret=%d.", retVal);
- return -1;
- }
-
- NSPOL_LOGINF (SC_DPDK_INFO, "if_name %s",
- p_stackx_port_zone->
- stackx_one_port[port_index].linux_ip.if_name);
-
- retVal =
- STRCPY_S (p_stackx_port_zone->
- stackx_one_port[port_index].linux_ip.if_type,
- sizeof (p_stackx_port_zone->
- stackx_one_port[port_index].linux_ip.if_type),
- network->nic_type_name);
- if (EOK != retVal)
- {
- NSPOL_LOGERR ("strcpy_s failed]ret=%d.", retVal);
- return -1;
- }
-
- NSPOL_LOGINF (SC_DPDK_INFO, "if_type %s",
- p_stackx_port_zone->
- stackx_one_port[port_index].linux_ip.if_type);
-
- retVal =
- STRCPY_S (p_stackx_port_zone->
- stackx_one_port[port_index].linux_ip.ip_addr_linux,
- sizeof (p_stackx_port_zone->
- stackx_one_port[port_index].linux_ip.
- ip_addr_linux), "0.0.0.0");
-
- if (EOK != retVal)
- {
- NSPOL_LOGERR ("STRCPY_S failed]ret=%d.", retVal);
- return -1;
- }
-
- retVal =
- STRCPY_S (p_stackx_port_zone->
- stackx_one_port[port_index].linux_ip.mask_linux,
- sizeof (p_stackx_port_zone->
- stackx_one_port[port_index].linux_ip.
- mask_linux), "0.0.0.0");
-
- if (EOK != retVal)
- {
- NSPOL_LOGERR ("STRCPY_S failed]ret=%d.", retVal);
- return -1;
- }
-
- retVal =
- STRCPY_S (p_stackx_port_zone->
- stackx_one_port[port_index].linux_ip.bcast_linux,
- sizeof (p_stackx_port_zone->
- stackx_one_port[port_index].linux_ip.
- bcast_linux), "0.0.0.0");
-
- if (EOK != retVal)
- {
- NSPOL_LOGERR ("STRCPY_S failed]ret=%d.", retVal);
- return -1;
- }
-
- ++port_index;
- NSPOL_LOGINF (SC_DPDK_INFO, "port_index=%u", port_index);
-
- if (CUR_CFG_HAL_PORT_NUM <= port_index + bond_ports_array.cnt)
- {
- // TODO: Invalid configuration received, return immediately
- NSPOL_LOGERR
- ("Insufficient nStack configuration when compared to configuration from network.json");
- return -1;
- }
-
- /* [TA33636] [2017-04-11] Do not need provider.json */
- if (phynet->bond_mode ==
- -1 /*&& strncmp(network->network_name, "provider", 8) != 0 */ )
- {
- break;
- }
- else
- {
- phead = phead->next;
- }
- }
-
- network = network->next;
- }
-
- *port_num = port_index;
-
- return ERR_OK;
-}
-
-void
-spl_hal_capa_init ()
-{
- u32_t ipv4_cksum_offload = 1;
- u32_t udp_cksum_offload = 1;
- u32_t tcp_cksum_offload = 1;
- hal_netif_capa_t info = { 0 };
- struct stackx_port_info *p_port_info = head_used_port_list;
-
- while (p_port_info)
- {
- hal_get_capability (p_port_info->linux_ip.hdl, &info);
-
- if ((info.tx_offload_capa & HAL_ETH_TX_OFFLOAD_IPV4_CKSUM) == 0)
- {
- ipv4_cksum_offload = 0;
-
- NSPOL_LOGDBG (SC_DPDK_INFO, "Port %s TX_OFFLOAD_IPV4_CKSUM Disable",
- p_port_info->linux_ip.if_name);
- }
-
- if ((info.tx_offload_capa & HAL_ETH_TX_OFFLOAD_UDP_CKSUM) == 0)
- {
- udp_cksum_offload = 0;
-
- NSPOL_LOGDBG (SC_DPDK_INFO, "Port %s TX_OFFLOAD_UDP_CKSUM Disable",
- p_port_info->linux_ip.if_name);
- }
-
- if ((info.tx_offload_capa & HAL_ETH_TX_OFFLOAD_TCP_CKSUM) == 0)
- {
- tcp_cksum_offload = 0;
-
- NSPOL_LOGDBG (SC_DPDK_INFO, "Port %s TX_OFFLOAD_TCP_CKSUM Disable",
- p_port_info->linux_ip.if_name);
- }
-
- p_port_info = p_port_info->next_use_port;
- }
-
- spl_hal_capa.tx_ipv4_cksum_offload = ipv4_cksum_offload;
- spl_hal_capa.tx_udp_cksum_offload = udp_cksum_offload;
- spl_hal_capa.tx_tcp_cksum_offload = tcp_cksum_offload;
-
- NSPOL_LOGINF (SC_DPDK_INFO,
- "ipv4_cksum_offload(%u),udp_cksum_offload(%u),tcp_cksum_offload(%u)",
- ipv4_cksum_offload, udp_cksum_offload, tcp_cksum_offload);
-
-}
-
-NSTACK_STATIC void
-spl_hal_bond_info_init (hal_hdl_t hdl, struct bond_set *s,
- struct stackx_port_info *p)
-{
-#define MAX_MAC_STR_LEN 20
- char mac_string[MAX_MAC_STR_LEN];
- int retVal;
- struct ether_addr addr;
-
- p->linux_ip.hdl = hdl;
-
- struct stackx_port_info *slave_port;
- slave_port = get_port_info_by_name (s->slave_ports[0]);
-
- if (slave_port == NULL)
- {
- NSPOL_LOGERR ("get_port_info_by_name failed]bond_port_name=%s",
- s->bond_port_name);
- return;
- }
-
- /* check the lenght of bond_port_name */
- retVal =
- STRCPY_S (p->linux_ip.if_name, sizeof (p->linux_ip.if_name),
- s->bond_port_name);
- if (EOK != retVal)
- {
- NSPOL_LOGERR ("STRCPY_S failed]ret=%d", retVal);
- return;
- }
-
- hal_get_macaddr (hdl, &addr);
- retVal =
- spl_hal_ether_etoa (addr.addr_bytes, sizeof (addr.addr_bytes), mac_string,
- sizeof (mac_string));
- if (retVal < 0)
- {
- NSPOL_LOGERR ("spl_hal_ether_etoa failed]ret=%d", retVal);
- return;
- }
-
- retVal =
- STRCPY_S (p->linux_ip.mac_addr, sizeof (p->linux_ip.mac_addr),
- mac_string);
- if (EOK != retVal)
- {
- NSPOL_LOGERR ("STRCPY_S failed]ret=%d", retVal);
- return;
- }
-
- retVal =
- STRCPY_S (p->linux_ip.ip_addr_linux, sizeof (p->linux_ip.ip_addr_linux),
- slave_port->linux_ip.ip_addr_linux);
- if (EOK != retVal)
- {
- NSPOL_LOGERR ("STRCPY_S failed]ret=%d", retVal);
- return;
- }
-
- retVal =
- STRCPY_S (p->linux_ip.mask_linux, sizeof (p->linux_ip.mask_linux),
- slave_port->linux_ip.mask_linux);
- if (EOK != retVal)
- {
- NSPOL_LOGERR ("STRCPY_S failed]ret=%d", retVal);
- return;
- }
-
- retVal =
- STRCPY_S (p->linux_ip.bcast_linux, sizeof (p->linux_ip.bcast_linux),
- slave_port->linux_ip.bcast_linux);
- if (EOK != retVal)
- {
- NSPOL_LOGERR ("STRCPY_S failed]ret=%d", retVal);
- return;
- }
-
- NSPOL_LOGINF (SC_DPDK_INFO, "===== the bond port info ======");
- NSPOL_LOGINF (SC_DPDK_INFO, "bond port name=%s", p->linux_ip.if_name);
- NSPOL_LOGINF (SC_DPDK_INFO, "bond port mac=%s", p->linux_ip.mac_addr);
- NSPOL_LOGINF (SC_DPDK_INFO, "bond port ip=%s", p->linux_ip.ip_addr_linux);
- NSPOL_LOGINF (SC_DPDK_INFO, "bond port netmask=%s", p->linux_ip.mask_linux);
- NSPOL_LOGINF (SC_DPDK_INFO, "bond port broad_cast addr=%s",
- p->linux_ip.bcast_linux);
-
-}
-
-NSTACK_STATIC int
-spl_hal_bond_start (void)
-{
- u8_t i, j = 0;
- struct stackx_port_info *bond_port = NULL;
- hal_hdl_t hdl;
- hal_hdl_t slave_hdl[HAL_MAX_SLAVES_PER_BOND];
-
- NSPOL_LOGINF (SC_DPDK_INFO, "bond_ports_array.cnt=%u",
- bond_ports_array.cnt);
-
- for (i = bond_ports_array_cnt_start; i < bond_ports_array.cnt; i++)
- {
- struct bond_set *s = &bond_ports_array.ports[i];
- NSPOL_LOGINF (SC_DPDK_INFO, "i=%u,bond_port_name=%s", i,
- s->bond_port_name);
-
- u8_t slave_num = 0;
- for (j = 0; j < s->slave_port_cnt; j++)
- {
- NSPOL_LOGINF (SC_DPDK_INFO, "s->slave_ports[%u]=%s", j,
- s->slave_ports[j]);
- hdl = get_port_hdl_by_name (s->slave_ports[j]);
-
- if (!hal_is_valid (hdl))
- {
- continue;
- }
-
- slave_hdl[slave_num++] = hdl;
-
- /* here we didn't release the port mem allocated in p_stackx_port_zone */
- del_port_in_port_list (s->slave_ports[j]);
- }
-
- hdl = hal_bond (s->bond_port_name, slave_num, slave_hdl);
-
- if (!hal_is_valid (hdl))
- {
- NSPOL_LOGERR ("hal_bond fail: bond_name =%s", s->bond_port_name);
- return -1;
- }
-
- bond_port =
- &p_stackx_port_zone->stackx_one_port[p_stackx_port_zone->port_num];
- num_ports_NIC++;
- p_stackx_port_zone->port_num++;
- p_stackx_port_zone->bonded_port_num++;
-
- spl_hal_bond_info_init (hdl, s, bond_port);
- add_port_in_port_list (bond_port);
-
- }
-
- bond_ports_array_cnt_start = bond_ports_array.cnt;
- return 0;
-}
-
-/*
- * Initialises a given port using global settings and with the rx buffers
- * coming from the mbuf_pool passed as parameter
- */
-
-NSTACK_STATIC inline int
-spl_hal_port_start (uint16_t nic_id, struct stackx_port_info *p_port_info,
- u16_t num_queues)
-{
- u16_t num_queues_request, q;
- hal_hdl_t hdl;
- struct common_mem_mempool *mp;
- hal_netif_config_t conf;
-#define MAX_MAC_STR_LEN 20
- char mac_string[MAX_MAC_STR_LEN];
- int retVal;
- struct ether_addr addr;
-
- // change the queues number per configuration.
- // even we only receive packets from one rx queue when dispatch mode is on, the tx queue
- // shoule set to the queues number requested.
- num_queues_request = num_queues;
- if (num_queues_request > HAL_ETH_MAX_QUEUE_NUM)
- {
- NSPOL_LOGERR
- ("no enougth queue num for thread!]num_queues_request=%u,MAX_QUEUE_NUM=%u",
- num_queues_request, HAL_ETH_MAX_QUEUE_NUM);
- return -1;
- }
-
- NSPOL_LOGDBG (SC_DPDK_INFO, "# Initialising index=%s... ",
- p_port_info->linux_ip.if_name);
- /* used to have fflush,no use code ,remove it. */
-
- conf.bit.hw_vlan_filter = 1;
- conf.bit.hw_vlan_strip = 1;
-
- conf.rx.queue_num = num_queues_request;
- conf.tx.queue_num = num_queues_request;
-
- for (q = 0; q < num_queues_request; q++)
- {
- mp =
- (struct common_mem_mempool *) spl_hal_rx_pool_create (nic_id, q, 1);
-
- if (mp == NULL)
- {
- NSPOL_LOGERR
- ("spl_hal_rx_pool_create fail]mp=NULL,nic_id=%u,if_name=%s",
- nic_id, p_port_info->linux_ip.if_name);
- return -1;
- }
-
- (void) spl_reg_res_txrx_mgr ((mpool_handle *) mp); // will only return 0, no need to check return value
- conf.rx.ring_pool[q] = mp;
- conf.rx.ring_size[q] = HAL_RX_RING_SIZE;
- conf.tx.ring_size[q] = HAL_TX_RING_SIZE;
- }
-
- hdl =
- hal_create (p_port_info->linux_ip.if_name, p_port_info->linux_ip.if_type,
- &conf);
-
- if (!hal_is_valid (hdl))
- {
- NSPOL_LOGERR ("hal_create fail]if_name =%s",
- p_port_info->linux_ip.if_name);
- return -1;
- }
-
- p_port_info->linux_ip.hdl = hdl;
-
- /* add mac address */
- hal_get_macaddr (hdl, &addr);
- retVal =
- spl_hal_ether_etoa (addr.addr_bytes, sizeof (addr.addr_bytes), mac_string,
- sizeof (mac_string));
- if (retVal < 0)
- {
- NSPOL_LOGERR ("spl_hal_ether_etoa failed]ret=%d", retVal);
- return -1;
- }
-
- retVal =
- STRCPY_S (p_port_info->linux_ip.mac_addr,
- sizeof (p_port_info->linux_ip.mac_addr), mac_string);
- if (EOK != retVal)
- {
- NSPOL_LOGERR ("STRCPY_S failed]ret=%d", retVal);
- return -1;
- }
-
- return 0;
-}
-
-NSTACK_STATIC int
-spl_hal_port_setup ()
-{
- unsigned int i;
- struct stackx_port_info *p_port_info = NULL;
-
- INITPOL_LOGINF ("HAL", "spl_hal_port_setup", NULL_STRING, LOG_INVALID_VALUE,
- MODULE_INIT_START);
-
- for (i = num_ports_NIC_start; i < num_ports_NIC; i++)
- {
- p_port_info = &(p_stackx_port_zone->stackx_one_port[i]);
-
- if (spl_hal_port_start (i, p_port_info, (u16_t) 1) < 0)
- {
- NSPOL_LOGERR ("Error initialising]nic_id=%u", i);
-
- INITPOL_LOGERR ("HAL", "spl_hal_port_setup", NULL_STRING,
- LOG_INVALID_VALUE, MODULE_INIT_FAIL);
-
- return -1;
- }
- else
- {
- report_port_link_status (p_port_info);
- add_port_in_port_list (p_port_info);
- }
- }
-
- if (spl_hal_bond_start () < 0)
- {
- NSPOL_LOGERR ("bond port init failed!");
-
- INITPOL_LOGERR ("HAL", "spl_hal_port_setup", NULL_STRING,
- LOG_INVALID_VALUE, MODULE_INIT_FAIL);
-
- return -1;
- }
-
- spl_hal_capa_init ();
-
- INITPOL_LOGINF ("HAL", "spl_hal_port_setup", NULL_STRING, LOG_INVALID_VALUE,
- MODULE_INIT_SUCCESS);
-
- return 0;
-
-}
-
-int
-spl_hal_port_init ()
-{
- int retval;
- unsigned int i, port_num = 0;
-
- int port_num_start = p_stackx_port_zone->port_num;
- num_ports_NIC_start = num_ports_NIC;
-
- //Read network info
- INITPOL_LOGINF ("IP", "spl_hal_port_config", NULL_STRING, LOG_INVALID_VALUE,
- MODULE_INIT_START);
- retval = spl_hal_port_config (&port_num);
-
- if (retval != ERR_OK)
- {
- INITPOL_LOGERR ("IP", "spl_hal_port_config", NULL_STRING,
- LOG_INVALID_VALUE, MODULE_INIT_FAIL);
- return -1;
- }
-
- p_stackx_port_zone->port_num = port_num;
-
- NSPOL_LOGINF (SC_DPDK_INFO, "port_num=%u", port_num);
- INITPOL_LOGINF ("IP", "spl_hal_port_config", NULL_STRING, LOG_INVALID_VALUE,
- MODULE_INIT_SUCCESS);
-
- if (port_num_start == p_stackx_port_zone->port_num)
- {
- NSPOL_LOGERR ("No new NIC find.");
- return 0;
- }
-
- //Get ports num
- for (i = port_num_start; i < p_stackx_port_zone->port_num; i++)
- {
- if (p_stackx_port_zone->stackx_one_port[i].linux_ip.if_name[0] != 0)
- {
- /* right now hard coded, */
- int eth_num =
- atoi (p_stackx_port_zone->stackx_one_port[i].linux_ip.if_name +
- 3);
-
- num_ports_NIC++;
-
- NSPOL_LOGDBG (SC_DPDK_INFO, "port_mask=%d ,eth_name=%s", eth_num,
- p_stackx_port_zone->stackx_one_port[i].
- linux_ip.if_name);
- }
- }
-
- if (num_ports_NIC > HAL_MAX_NIC_NUM)
- {
- NSPOL_LOGERR ("just support one eth");
- common_exit (EXIT_FAILURE, "just surport one eth");
- }
-
- if (num_ports_NIC == num_ports_NIC_start)
- {
- NSPOL_LOGERR ("No new NIC find.");
- return 0;
- }
-
- retval = spl_hal_port_setup ();
-
- if (retval == -1)
- {
- return -1;
- }
-
- NSPOL_LOGDBG (SC_DPDK_INFO, "Finished Process Init.");
-
- return 1;
-}
-
-inline NSTACK_STATIC void
-spl_hal_send (struct netif *pnetif)
-{
- u16_t i, sent = 0;
- struct netifExt *pnetifExt = NULL;
- u16_t netif_id = pnetif->num;
- u16_t tx_num = spl_hal_pkts[netif_id].tx.num;
- struct common_mem_mbuf **tx_ptks = spl_hal_pkts[netif_id].tx.pkts;
-
- for (i = 0; i < tx_num; i++)
- {
- (void)
- res_free (&
- (((struct spl_pbuf *) (((char *) tx_ptks[i]) +
- sizeof (struct
- common_mem_mbuf)))->res_chk));
- }
-
- int _retry = 0;
-
- pnetifExt = getNetifExt (pnetif->num);
- if (NULL == pnetifExt)
- return;
-
- do
- {
- sent +=
- hal_send_packet (pnetifExt->hdl, 0, (hal_mbuf_t **) & (tx_ptks[sent]),
- tx_num - sent);
- _retry++;
-
- if (_retry > SPL_HAL_SEND_TRY)
- {
- NSPOL_LOGERR ("send loop %d times but dpdk send data fail ",
- SPL_HAL_SEND_TRY);
- break;
- }
- }
- while (unlikely (sent != tx_num));
-
- if (unlikely (sent != tx_num))
- {
- for (i = sent; i < tx_num; i++)
- {
- (void) nsfw_mem_mbf_free ((mbuf_handle) (tx_ptks[i]), NSFW_SHMEM);
- }
- }
- for (i = 0; i < tx_num; i++)
- {
- /* set dpdk_send flag */
- ((struct spl_pbuf *) (((char *) tx_ptks[i]) +
- sizeof (struct common_mem_mbuf)))->
- res_chk.u8Reserve |= DPDK_SEND_FLAG;
- }
-
- spl_hal_pkts[netif_id].tx.num = 0;
-
-}
-
-inline u16_t
-spl_hal_recv (struct netif *pnetif, u8_t id)
-{
- u16_t netif_id, rx_c = 0;
- struct netifExt *pnetifExt = NULL;
-
- netif_id = pnetif->num;
-
- pnetifExt = getNetifExt (pnetif->num);
- if (NULL == pnetifExt)
- return 0;
-
- rx_c =
- hal_recv_packet (pnetifExt->hdl, 0,
- (hal_mbuf_t **) spl_hal_pkts[netif_id].rx.pkts,
- PKT_BURST);
-
- if (rx_c <= 0)
- {
- return 0;
- }
-
- spl_hal_pkts[netif_id].rx.num = rx_c;
- spl_hal_pkts[netif_id].rx.index = 0;
-
- return rx_c;
-}
-
-/*needflush set 1 has pbuf release problem, ref maybe set 0 before release*/
-NSTACK_STATIC inline void
-spl_hal_set_cksum (struct spl_pbuf *buf, struct common_mem_mbuf *mbuf)
-{
-
- //need to be careful, special when small packet oversize
- if (buf->tot_len > mbuf->pkt_len)
- {
- NSPOL_LOGWAR (SC_DPDK_INFO,
- "small packet OVERSIZE]pbuf_len=%u,mbuf_len=%u", buf->len,
- mbuf->pkt_len);
- mbuf->pkt_len = buf->len;
- }
-
- if (!spl_hal_tx_ip_cksum_enable () || !spl_hal_tx_tcp_cksum_enable ()
- || !spl_hal_tx_udp_cksum_enable ())
- {
- struct tcp_hdr *t_hdr;
- struct udp_hdr *u_hdr;
- u16_t flag_offset;
- u64_t ol_flags = (mbuf->ol_flags); //& (~PKT_TX_L4_MASK));
-
- struct eth_hdr *ethhdr = (struct eth_hdr *) ((char *) buf->payload);
-
- if (ethhdr->type == 8)
- {
- struct ip_hdr *iphdr =
- (struct ip_hdr *) ((char *) buf->payload +
- sizeof (struct eth_hdr));
-
- if (!spl_hal_tx_ip_cksum_enable ())
- {
- ol_flags |= PKT_TX_IPV4 | PKT_TX_IP_CKSUM;
- iphdr->_chksum = 0;
- }
-
- flag_offset = spl_ntohs (iphdr->_offset);
-
- /*ip frag, only the first packet has udp or tcp head */
- if (0 == (flag_offset & IP_OFFMASK))
- {
- switch (iphdr->_proto)
- {
- case IPPROTO_TCP:
- if (!spl_hal_tx_tcp_cksum_enable ())
- {
- t_hdr =
- (struct tcp_hdr *) ((char *) buf->payload +
- sizeof (struct eth_hdr) +
- sizeof (struct ip_hdr));
- t_hdr->chksum = get_ipv4_psd_sum (iphdr, ol_flags);
- ol_flags |= PKT_TX_TCP_CKSUM;
- }
-
- break;
-
- case IPPROTO_UDP:
- {
- if ((mbuf->ol_flags & PKT_TX_UDP_CKSUM) ==
- PKT_TX_UDP_CKSUM)
- {
- u_hdr = (struct udp_hdr *) ((char *) buf->payload + sizeof (struct eth_hdr) + sizeof (struct ip_hdr)); //l2_len + l3_len);
- u_hdr->chksum =
- get_ipv4_psd_sum (iphdr, mbuf->ol_flags);
- }
- }
-
- break;
-
- default:
-
- break;
- }
- }
- mbuf->l2_len = sizeof (struct eth_hdr); //l2_len;
- mbuf->l3_len = sizeof (struct ip_hdr);
- mbuf->ol_flags = ol_flags;
- }
- }
-}
-
-/*needflush set 1 has pbuf release problem, ref maybe set 0 before release*/
-err_t
-spl_hal_output (struct netif *pnetif, struct pbuf *buf)
-{
- u16_t netif_id, idx;
- struct common_mem_mbuf *mbuf;
- struct spl_pbuf *spbuf = NULL;
- //spl_pbuf_layer layer = SPL_PBUF_TRANSPORT;
- //u16_t offset;
-
- if (!p_def_stack_instance)
- {
- NSPOL_LOGERR ("p_def_stack_instance is NULL");
- return -1;
- }
-
- u16_t proc_id = spl_get_lcore_id ();
-
- NSPOL_LOGINF (SC_DPDK_INFO, "spl_hal_output. len %d totlen %d", buf->len,
- buf->tot_len);
- print_pbuf_payload_info (buf, true);
-
- if (buf->tot_len > DEF_MBUF_DATA_SIZE)
- {
- NSPOL_LOGINF (TCP_DEBUG, "spl_pbuf_alloc_hugepage Failed!!!");
- return ERR_MEM;
-
- }
- spbuf = spl_pbuf_alloc_hugepage (SPL_PBUF_RAW,
- buf->tot_len,
- SPL_PBUF_HUGE, proc_id, NULL);
-
- if (!spbuf)
- {
- NSPOL_LOGINF (TCP_DEBUG, "spl_pbuf_alloc_hugepage Failed!!!");
- return ERR_MEM;
- }
-
- if (ERR_OK != pbuf_to_splpbuf_copy (spbuf, buf))
- {
- NSPOL_LOGERR ("pbuf to splpbuf copy failed");
- return -1;
- }
-
- mbuf =
- (struct common_mem_mbuf *) ((char *) spbuf -
- sizeof (struct common_mem_mbuf));
-
- if (spbuf->tot_len > mbuf->pkt_len)
- {
- NSPOL_LOGWAR (SC_DPDK_INFO,
- "small packet OVERSIZE]pbuf_len=%u,mbuf_len=%u",
- spbuf->len, mbuf->pkt_len);
- mbuf->pkt_len = spbuf->len;
- }
-
- spl_hal_set_cksum (spbuf, mbuf);
-
- netif_id = pnetif->num;
- idx = spl_hal_pkts[netif_id].tx.num++;
- spl_hal_pkts[netif_id].tx.pkts[idx] = mbuf;
- spl_do_dump (spbuf, DUMP_SEND);
- spl_hal_send (pnetif);
-
- return 0;
-}
-
-void
-spl_hal_input (struct netif *pnetif, struct spl_pbuf **buf)
-{
- u16_t netif_id;
-
- struct common_mem_mbuf *mbuf;
-
- netif_id = pnetif->num;
-
- if (likely
- (spl_hal_pkts[netif_id].rx.num > spl_hal_pkts[netif_id].rx.index))
- {
- mbuf = spl_hal_pkts[netif_id].rx.pkts[spl_hal_pkts[netif_id].rx.index];
- spl_hal_pkts[netif_id].rx.index++;
- spl_hal_buf_convert (mbuf, buf);
- spl_do_dump (*buf, DUMP_RECV);
- }
- else
- {
- NSPOL_LOGERR
- ("recv from spl_dev has a problem]pnetif=%p, num=%u, index=%u",
- pnetif, spl_hal_pkts[netif_id].rx.num,
- spl_hal_pkts[netif_id].rx.index);
- *buf = NULL;
- }
- return;
-}
-
-int
-spl_hal_tx_ip_cksum_enable ()
-{
- return !spl_hal_capa.tx_ipv4_cksum_offload;
-}
-
-int
-spl_hal_tx_udp_cksum_enable ()
-{
- return !spl_hal_capa.tx_udp_cksum_offload;
-}
-
-int
-spl_hal_tx_tcp_cksum_enable ()
-{
- return !spl_hal_capa.tx_tcp_cksum_offload;
-}
-
-u32
-spl_hal_is_nic_exist (const char *name)
-{
- return hal_is_nic_exist (name);
-}
-
-int
-spl_hal_is_bond_netif (struct netif *pnetif)
-{
- int i;
- struct bond_set *s;
- struct netifExt *pnetifExt = NULL;
-
- pnetifExt = getNetifExt (pnetif->num);
- if (NULL == pnetifExt)
- return 0;
-
- for (i = 0; i < bond_ports_array.cnt; i++)
- {
- s = &bond_ports_array.ports[i];
- if (!strncmp
- (pnetifExt->if_name, s->bond_port_name, HAL_MAX_NIC_NAME_LEN))
- {
- return 1;
- }
- }
-
- return 0;
-}
diff --git a/stacks/lwip_stack/lwip_src/recycle/stackx_recycle.c b/stacks/lwip_stack/lwip_src/recycle/stackx_recycle.c
deleted file mode 100644
index addc0e6..0000000
--- a/stacks/lwip_stack/lwip_src/recycle/stackx_recycle.c
+++ /dev/null
@@ -1,676 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "stackx_spl_share.h"
-#include "nsfw_recycle_api.h"
-#include "nstack_log.h"
-#include "nsfw_msg_api.h"
-#include "stackx_socket.h"
-#include "stackx_spl_msg.h"
-#include "stackx_app_res.h"
-#include "common.h"
-#include "sc_dpdk.h"
-#include "nsfw_mt_config.h"
-#include "spl_instance.h"
-
-#define SS_DELAY_CLOSE_SEC 5
-
-extern struct stackx_port_zone *p_stackx_port_zone;
-
-/*****************************************************************************
-* Prototype : sbr_recycle_rx_mbuf
-* Description : iterator and free rx mbufs with pid flags, when the app
- with certain pid is no longer exist
-* Input : void *data
-* void *arg
-* Output : None
-* Return Value : static inline int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline int
-sbr_recycle_rx_mbuf (void *data, void *arg)
-{
- u32 *recycle_flg;
- pid_t *pid = (pid_t *) arg;
- struct common_mem_mbuf *m_buf = (struct common_mem_mbuf *) data;
-#ifdef HAL_LIB
-#else
- recycle_flg =
- (u32 *) ((char *) (m_buf->buf_addr) + RTE_PKTMBUF_HEADROOM -
- sizeof (u32));
-#endif
- if (m_buf->refcnt > 0 && *recycle_flg == *pid)
- {
- NSSBR_LOGDBG ("free rx mbuf hold by app], mbuf=%p", m_buf);
- *recycle_flg = MBUF_UNUSED;
- spl_mbuf_free (m_buf);
- }
- return 0;
-}
-
-/*****************************************************************************
-* Prototype : sbr_recycle_rx_pool
-* Description : recycle rx mbufs hold by app when app crahes
-* Input : pid_t pid
-* Output : None
-* Return Value : static int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-NSTACK_STATIC int
-sbr_recycle_rx_pool (pid_t pid)
-{
- static struct common_mem_mempool *rx_pool[MAX_VF_NUM * 2][MAX_THREAD_NUM] =
- { {0} };
- struct common_mem_mempool *mp;
- nsfw_mem_name lookup_mbuf_pool;
- u32 nic_id, queue_id = 0;
- int retval;
- struct common_mem_ring *ring;
-
- for (nic_id = 0;
- nic_id < p_stackx_port_zone->port_num && nic_id < MAX_VF_NUM * 2;
- nic_id++)
- {
- mp = rx_pool[nic_id][queue_id];
- if (mp == NULL)
- {
- retval =
- spl_snprintf (lookup_mbuf_pool.aname, NSFW_MEM_NAME_LENGTH - 1,
- "%s", get_mempoll_rx_name (queue_id, nic_id));
- if (-1 == retval)
- {
- NSPOL_LOGERR ("spl_snprintf fail");
- break;
- }
-
- lookup_mbuf_pool.entype = NSFW_SHMEM;
- lookup_mbuf_pool.enowner = NSFW_PROC_MAIN;
- mp =
- (struct common_mem_mempool *)
- nsfw_mem_mbfmp_lookup (&lookup_mbuf_pool);
- if (mp == NULL)
- break;
- rx_pool[nic_id][queue_id] = mp;
- }
- if (nsfw_mem_mbuf_iterator
- (mp, 0, mp->size, sbr_recycle_rx_mbuf, (void *) &pid) < 0)
- {
- NSSBR_LOGERR ("nsfw_mem_mbuf_iterator return fail");
- return -1;
- }
- ring = (struct common_mem_ring *) (mp->pool_data);
- NSSBR_LOGINF
- ("after recycling rx pbuf hold by app]ring=%p,prod.head=%u,prod.tail=%u,"
- "cons.head=%u,cons.tail=%u.", ring, ring->prod.head, ring->prod.tail,
- ring->cons.head, ring->cons.tail);
- }
-
- return 0;
-}
-
-/*****************************************************************************
-* Prototype : sbr_recycle_rx_pool
-* Description : recycle stackx tx mbufs hold by app when app crahes
-* Input : pid_t pid
-* Output : None
-* Return Value : static int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-NSTACK_STATIC int
-sbr_recycle_tx_pool (pid_t pid)
-{
- struct common_mem_mempool *mp;
- struct common_mem_ring *ring;
-
- /* Try to free all the RX mbufs which are holded in stackx TX pool */
- mp = (struct common_mem_mempool *) p_def_stack_instance->mp_tx;
- if (mp == NULL)
- return -1;
-
- if (nsfw_mem_mbuf_iterator
- (mp, 0, mp->size, sbr_recycle_rx_mbuf, (void *) &pid) < 0)
- {
- NSSBR_LOGERR ("nsfw_mem_mbuf_iterator return fail");
- return -1;
- }
- ring = (struct common_mem_ring *) (mp->pool_data);
- NSSBR_LOGINF
- ("after recycling stackx tx pbuf hold by app]ring=%p,prod.head=%u,prod.tail=%u,"
- "cons.head=%u,cons.tail=%u.", ring, ring->prod.head, ring->prod.tail,
- ring->cons.head, ring->cons.tail);
-
- return 0;
-}
-
-/*****************************************************************************
-* Prototype : ss_free_del_conn_msg
-* Description : free msg
-* Input : msg_delete_netconn *dmsg
-* Output : None
-* Return Value : static inline void
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline void
-ss_free_del_conn_msg (msg_delete_netconn * dmsg)
-{
- data_com_msg *msg = (data_com_msg *) ((char *) dmsg - MAX_MSG_PARAM_SIZE);
-
- if (MSG_ASYN_POST == msg->param.op_type) /* should check type for linger */
- {
- msg_free (msg);
- }
-}
-
-extern int nsep_recycle_ep (u32 pid);
-
-/*****************************************************************************
-* Prototype : ss_recycle_done
-* Description : recycle done,need recycle ep and rx pool
-* Input : pid_t pid
-* Output : None
-* Return Value : static inline void
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline void
-ss_recycle_done (pid_t pid)
-{
- spl_free_tx_pool (pid);
- spl_recycle_msg_pool (pid);
- (void) sbr_recycle_rx_pool (pid);
- (void) sbr_recycle_tx_pool (pid);
- (void) nsep_recycle_ep (pid);
- (void) nsfw_recycle_obj_end (pid);
-}
-
-/*****************************************************************************
-* Prototype : ss_notify_omc
-* Description : try to notify omc
-* Input : spl_netconn_t** conn_array
-* u32 conn_num
-* u8 notify_omc
-* pid_t pid
-* Output : None
-* Return Value : static inline void
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline void
-ss_notify_omc (spl_netconn_t ** conn_array, u32 conn_num, u8 notify_omc,
- pid_t pid)
-{
- if (notify_omc)
- {
- u32 i;
- for (i = 0; i < conn_num; ++i)
- {
- struct spl_netconn *conn = conn_array[i];
- if (ss_is_pid_exist (conn, pid))
- {
- NSSBR_LOGINF ("there are still conn at work]pid=%d", pid);
- break;
- }
-
- msg_delete_netconn *delay_msg = conn->recycle.delay_msg;
- if (delay_msg && (delay_msg->pid == pid))
- {
- delay_msg->notify_omc = notify_omc;
- NSSBR_LOGINF ("there are still conn at delay]pid=%d", pid);
- break;
- }
- }
-
- if (conn_num == i)
- {
- NSSBR_LOGINF ("recycle done,notify omc]pid=%d", pid);
- ss_recycle_done (pid);
- }
- }
-}
-
-extern void do_pbuf_free (struct spl_pbuf *buf);
-
-static void
-ss_recycle_fd_share (sbr_fd_share * fd_share)
-{
- /* to free pbufs which are attached to sbr_fd_share */
- if (fd_share->recoder.head)
- {
- struct spl_pbuf *buf = fd_share->recoder.head;
- fd_share->recoder.head = NULL;
- fd_share->recoder.tail = NULL;
- fd_share->recoder.totalLen = 0;
- do_pbuf_free (buf);
- }
-}
-
-extern void nsep_recycle_epfd (void *epinfo, u32 pid);
-extern void tcp_free_accept_ring (spl_netconn_t * conn);
-extern void free_conn_by_spl (spl_netconn_t * conn);
-extern void tcp_drop_conn (spl_netconn_t * conn);
-
-/*****************************************************************************
-* Prototype : ss_close_conn_now
-* Description : close netconn now
-* Input : spl_netconn_t *conn
-* msg_delete_netconn *dmsg
-* pid_t pid
-* ss_close_conn_fun close_conn
-* Output : None
-* Return Value : static inline void
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline void
-ss_close_conn_now (spl_netconn_t * conn, msg_delete_netconn * dmsg, pid_t pid,
- ss_close_conn_fun close_conn)
-{
- spl_netconn_t **conn_array = conn->recycle.group->conn_array;
- u32 conn_num = conn->recycle.group->conn_num;
- u8 notify_omc = dmsg->notify_omc;
-
- close_conn (dmsg, 0);
-
- nsep_recycle_epfd (conn->epInfo, pid);
- conn->epInfo = NULL; /*must be set to NULL */
-
- u32 i;
- if (conn->recycle.is_listen_conn)
- {
- /* drop the conn inside the accept ring */
- tcp_free_accept_ring (conn);
-
- /* app coredump and accept_from not changed, need recyle */
- for (i = 0; i < conn_num; ++i)
- {
- struct spl_netconn *accept_conn = conn_array[i];
- if ((accept_conn->recycle.accept_from == conn)
- && ss_is_pid_array_empty (accept_conn))
- {
- NSSBR_LOGINF
- ("recycle lost conn]listen_conn=%p,listen_private_data=%p,accept_conn=%p,accept_private_data=%p,pid=%d",
- conn, conn->private_data, accept_conn,
- accept_conn->private_data, pid);
- data_com_msg *msg =
- (data_com_msg *) ((char *) dmsg - MAX_MSG_PARAM_SIZE);
- msg->param.receiver = ss_get_recv_obj (accept_conn);
- dmsg->buf = NULL;
- dmsg->time_started = sys_now ();
- dmsg->shut = 0;
- dmsg->conn = accept_conn;
- close_conn (dmsg, 0);
-
- nsep_recycle_epfd (accept_conn->epInfo, pid);
- accept_conn->epInfo = NULL; /*must be set to NULL */
-
- /* lost conn need drop first, can't just free conn */
- tcp_drop_conn (accept_conn);
- }
- }
- }
-
- if (SS_DELAY_STOPPED == conn->recycle.delay_flag)
- {
- sbr_fd_share *fd_share =
- (sbr_fd_share *) ((char *) conn + SS_NETCONN_SIZE);
- ss_recycle_fd_share (fd_share);
- free_conn_by_spl (conn);
- }
-
- ss_free_del_conn_msg (dmsg);
- ss_notify_omc (conn_array, conn_num, notify_omc, pid);
-}
-
-/*****************************************************************************
-* Prototype : ss_close_conn_delay
-* Description : delay to close conn
-* Input : spl_netconn_t *conn
-* pid_t pid
-* msg_delete_netconn *dmsg
-* ss_close_conn_fun close_conn
-* Output : None
-* Return Value : static inline void
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline void
-ss_close_conn_delay (spl_netconn_t * conn, pid_t pid,
- msg_delete_netconn * dmsg, ss_close_conn_fun close_conn)
-{
- NSSBR_LOGINF
- ("ref > 0 and pid array is empty, start delay closing conn]conn=%p,pid=%d,private_data=%p",
- conn, pid, conn->private_data);
- close_conn (dmsg, SS_DELAY_CLOSE_SEC);
-}
-
-/*****************************************************************************
-* Prototype : ss_process_delay_up
-* Description : delay is up
-* Input : spl_netconn_t *conn
-* pid_t pid
-* msg_delete_netconn *dmsg
-* ss_close_conn_fun close_conn
-* Output : None
-* Return Value : static inline void
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline void
-ss_process_delay_up (spl_netconn_t * conn, pid_t pid,
- msg_delete_netconn * dmsg, ss_close_conn_fun close_conn)
-{
- spl_netconn_t **conn_array = conn->recycle.group->conn_array;
- u32 conn_num = conn->recycle.group->conn_num;
- u8 notify_omc = dmsg->notify_omc;
-
- if (SS_DELAY_STARTED == conn->recycle.delay_flag)
- {
- if (ss_is_pid_array_empty (conn))
- {
- NSSBR_LOGINF
- ("delay time is up,close conn now]conn=%p,pid=%d,private_data=%p",
- conn, pid, conn->private_data);
- conn->recycle.delay_flag = SS_DELAY_STOPPED;
- conn->recycle.delay_msg = NULL;
- ss_close_conn_now (conn, dmsg, pid, close_conn);
- return;
- }
- else
- {
- NSSBR_LOGINF
- ("stop delay closing conn,conn still working]conn=%p,pid=%d,private_data=%p",
- conn, pid, conn->private_data);
- conn->recycle.delay_flag = SS_DELAY_STOPPED;
- conn->recycle.delay_msg = NULL;
- ss_free_del_conn_msg (dmsg);
- ss_notify_omc (conn_array, conn_num, notify_omc, pid);
- return;
- }
- }
- else if (SS_DELAY_AGAIN == conn->recycle.delay_flag)
- {
- if (ss_is_pid_array_empty (conn))
- {
- NSSBR_LOGINF
- ("delay time is up,but need delay again]conn=%p,pid=%d,private_data=%p",
- conn, pid, conn->private_data);
- conn->recycle.delay_flag = SS_DELAY_STARTED;
- ss_close_conn_delay (conn, pid, dmsg, close_conn);
- return;
- }
- else
- {
- NSSBR_LOGINF
- ("stop delay closing conn,conn still working]conn=%p,pid=%d,private_data=%p",
- conn, pid, conn->private_data);
- conn->recycle.delay_flag = SS_DELAY_STOPPED;
- conn->recycle.delay_msg = NULL;
- ss_free_del_conn_msg (dmsg);
- ss_notify_omc (conn_array, conn_num, notify_omc, pid);
- return;
- }
- }
- else if (SS_DELAY_STOPPING == conn->recycle.delay_flag)
- {
- NSSBR_LOGINF
- ("the conn has been closed,free conn]conn=%p,pid=%d,private_data=%p",
- conn, pid, conn->private_data);
- conn->recycle.delay_flag = SS_DELAY_STOPPED;
- conn->recycle.delay_msg = NULL;
- free_conn_by_spl (conn);
- ss_free_del_conn_msg (dmsg);
- ss_notify_omc (conn_array, conn_num, notify_omc, pid);
- return;
- }
- else
- {
- NSSBR_LOGERR ("this can not happen]conn=%p,pid=%d,private_data=%p",
- conn, pid, conn->private_data);
- }
-}
-
-/*****************************************************************************
-* Prototype : ss_recycle_conn
-* Description : recycle conn
-* Input : void *close_data
-* ss_close_conn_fun close_conn
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-ss_recycle_conn (void *close_data, ss_close_conn_fun close_conn)
-{
- msg_delete_netconn *dmsg = (msg_delete_netconn *) close_data;
- spl_netconn_t *conn = dmsg->conn;
- pid_t pid = dmsg->pid;
- u8 notify_omc = dmsg->notify_omc;
- struct spl_netconn **conn_array = conn->recycle.group->conn_array;
- u32 conn_num = conn->recycle.group->conn_num;
-
- int ret = ss_del_pid (conn, pid);
- if (0 == ret)
- {
- i32 ref = ss_dec_fork_ref (conn);
- if (0 == ref)
- {
- if (conn->recycle.delay_flag != SS_DELAY_STOPPED)
- {
- conn->recycle.delay_flag = SS_DELAY_STOPPING;
- NSSBR_LOGINF
- ("stop delay closing conn,close conn now]conn=%p,pid=%d,private_data=%p",
- conn, pid, conn->private_data);
- }
- else
- {
- NSSBR_LOGINF ("close conn now]conn=%p,pid=%d,private_data=%p",
- conn, pid, conn->private_data);
- }
-
- ss_close_conn_now (conn, dmsg, pid, close_conn);
- return 0;
- }
- else
- {
- if (ss_is_pid_array_empty (conn))
- {
- if (SS_DELAY_STOPPED == conn->recycle.delay_flag) /* only start one delay */
- {
- conn->recycle.delay_flag = SS_DELAY_STARTED;
- conn->recycle.delay_msg = close_data;
- ss_close_conn_delay (conn, pid, dmsg, close_conn);
- return 0;
- }
- else if (SS_DELAY_STARTED == conn->recycle.delay_flag)
- {
- conn->recycle.delay_flag = SS_DELAY_AGAIN;
- NSSBR_LOGINF
- ("ref > 0 and pid array is empty, delay again]conn=%p,pid=%d,private_data=%p",
- conn, pid, conn->private_data);
- }
- }
- }
- }
- else
- {
- if (conn->recycle.delay_msg && (conn->recycle.delay_msg == close_data)) /* only the stater can process */
- {
- ss_process_delay_up (conn, pid, dmsg, close_conn);
- return 0;
- }
- }
-
- NSSBR_LOGINF ("go to notify omc]conn=%p,pid=%d,private_data=%p", conn, pid,
- conn->private_data);
- ss_free_del_conn_msg (dmsg);
- ss_notify_omc (conn_array, conn_num, notify_omc, pid);
- return 0;
-}
-
-/*****************************************************************************
-* Prototype : sbr_handle_recycle_conn
-* Description : post msg to spl
-* Input : spl_netconn_t* conn
-* pid_t pid
-* u8 notify_omc
-* Output : None
-* Return Value : static inline int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline int
-sbr_handle_recycle_conn (spl_netconn_t * conn, pid_t pid, u8 notify_omc)
-{
- data_com_msg *m = msg_malloc (ss_get_msg_pool (conn));
-
- if (!m)
- {
- NSSBR_LOGERR ("malloc msg failed]conn=%p,pid=%d,private_data=%p", conn,
- pid, conn->private_data);
- return -1;
- }
-
- NSSBR_LOGINF ("recycle conn]conn=%p,pid=%d,private_data=%p", conn, pid,
- conn->private_data);
-
- m->param.module_type = MSG_MODULE_SBR;
- m->param.major_type = SPL_TCPIP_NEW_MSG_API;
- m->param.minor_type = SPL_API_DO_DELCON;
- m->param.err = 0;
- m->param.op_type = MSG_ASYN_POST;
- sys_sem_init (&m->param.op_completed);
- m->param.receiver = ss_get_recv_obj (conn);
- m->param.extend_member_bit = 0;
-
- msg_delete_netconn *p = (msg_delete_netconn *) m->buffer;
- p->extend_member_bit = 0;
- p->time_started = sys_now ();
- p->shut = 0;
- p->pid = pid;
- p->conn = conn;
- p->notify_omc = notify_omc;
- p->msg_box_ref = SPL_MSG_BOX_NUM;
- p->buf = NULL;
-
- /* to ensure that the last deal with SPL_API_DO_DELCON message */
- int i;
- for (i = 0; i < SPL_MSG_BOX_NUM; ++i)
- {
- if (msg_post_with_lock_rel
- (m,
- ss_get_instance_msg_box (ss_get_bind_thread_index (conn), i)) < 0)
- {
- msg_free (m);
- NSSBR_LOGERR ("post msg failed]conn=%p,pid=%d,private_data=%p",
- conn, pid, conn->private_data);
- return -1;
- }
- }
-
- return 0;
-}
-
-/*****************************************************************************
-* Prototype : sbr_recycle_fd_share
-* Description : recycle sbr_fd_share
-* Input : sbr_fd_share* fd_share
-* pid_t pid
-* Output : None
-* Return Value : static inline void
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline void
-sbr_recycle_fd_share (sbr_fd_share * fd_share, pid_t pid)
-{
- if (fd_share->common_lock.locked == pid)
- {
- common_spinlock_unlock (&fd_share->common_lock);
- }
-
- if (fd_share->recv_lock.locked == pid)
- {
- common_spinlock_unlock (&fd_share->recv_lock);
- }
-}
-
-/*****************************************************************************
-* Prototype : sbr_recycle_conn
-* Description : recycle api,called by recycle module
-* Input : u32 exit_pid
-* void *pdata
-* u16 rec_type
-* Output : None
-* Return Value : nsfw_rcc_stat
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-nsfw_rcc_stat
-sbr_recycle_conn (u32 exit_pid, void *pdata, u16 rec_type)
-{
- NSSBR_LOGINF ("start recycle]pid=%d", exit_pid);
-
- if (0 == exit_pid)
- {
- NSSBR_LOGERR ("pid is not ok]pid=%d", exit_pid);
- return NSFW_RCC_CONTINUE;
- }
-
- spl_netconn_t **conn_array = spl_get_conn_array (exit_pid);
- if (!conn_array)
- {
- NSSBR_LOGERR ("conn_array is NULL]pid=%d", exit_pid);
- return NSFW_RCC_CONTINUE;
- }
-
- u32 num = spl_get_conn_num ();
- spl_netconn_t *conn;
- sbr_fd_share *fd_share;
- u32 i;
- for (i = 0; i < num; ++i)
- {
- conn = conn_array[i];
- if (ss_is_pid_exist (conn, exit_pid))
- {
- fd_share = (sbr_fd_share *) ((char *) conn + SS_NETCONN_SIZE);
- sbr_recycle_fd_share (fd_share, exit_pid);
- sbr_handle_recycle_conn (conn, exit_pid, FALSE);
- }
- }
-
- sbr_handle_recycle_conn (conn_array[0], exit_pid, TRUE);
- return NSFW_RCC_SUSPEND;
-}
-
-REGIST_RECYCLE_OBJ_FUN (NSFW_REC_SBR_SOCKET, sbr_recycle_conn)
diff --git a/stacks/lwip_stack/lwip_src/socket/CMakeLists.txt b/stacks/lwip_stack/lwip_src/socket/CMakeLists.txt
deleted file mode 100644
index e7915d2..0000000
--- a/stacks/lwip_stack/lwip_src/socket/CMakeLists.txt
+++ /dev/null
@@ -1,76 +0,0 @@
-#########################################################################
-#
-# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-# 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.
-#########################################################################
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -g -fPIE -pie -fPIC -m64 -mssse3 -std=gnu89")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -Wshadow -Wfloat-equal -Wformat=2")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector -fstack-protector-all")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-z,relro,-z,now -Wl,--disable-new-dtags")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-z,noexecstack -mcmodel=medium")
-
-SET(ADAPT_DIRECTORIES "${PROJECT_SOURCE_DIR}/src/adapt/")
-#SET(DMM_API "${PROJECT_SOURCE_DIR}/src/nSocket/include/")
-
-ADD_DEFINITIONS(-D_GNU_SOURCE -D_FORTIFY_SOURCE=2)
-ADD_DEFINITIONS(-DDPDK_MODULE=0)
-if(WITH_HAL_LIB)
-SET(RTP_CONFIG ${CMAKE_CURRENT_LIST_DIR}/../../../src/include/rtp_config.h)
-else()
- SET(PAL_H_DIRECTORIES "/usr/include/dpdk/")
- SET(RTP_CONFIG ${PROJECT_SOURCE_DIR}/../../src/framework/common/base/include/common/common_sys_config.h)
- INCLUDE_DIRECTORIES(
- ${PAL_H_DIRECTORIES}
- ${ADAPT_DIRECTORIES}
-# ${DMM_API}
- )
-endif()
-SET(COMPLE_CONFIG ${CMAKE_CURRENT_LIST_DIR}/../../src/include/compile_config.h)
-#SET(MGR_COM ${PROJECT_SOURCE_DIR}/src/framework/ipc/mgr_com/mgr_com.h)
-SET(MGR_COM ${CMAKE_CURRENT_LIST_DIR}/../../src/include/mgr_com.h)
-ADD_DEFINITIONS(-include ${RTP_CONFIG})
-ADD_DEFINITIONS(-include ${COMPLE_CONFIG})
-ADD_DEFINITIONS(-include ${MGR_COM})
-if(WITH_SECUREC_LIB)
-LINK_LIBRARIES(pthread rt securec)
-else()
-LINK_LIBRARIES(pthread rt)
-endif()
-LINK_DIRECTORIES(${LIB_PATH_SHARED} ${LIB_PATH_STATIC})
-INCLUDE_DIRECTORIES(
- ${CMAKE_CURRENT_LIST_DIR}/../../../../thirdparty/json/json-c-0.12.1/
- ${CMAKE_CURRENT_LIST_DIR}/../../../../thirdparty/glog/glog-0.3.4/src/
- ${CMAKE_CURRENT_LIST_DIR}/../../src/include/
-# ${PROJECT_SOURCE_DIR}/src/framework/include/
-# ${PROJECT_SOURCE_DIR}/src/framework/common/include/
-# ${ADAPT_DIRECTORIES}
-# ${DMM_API}
-)
-
-FILE(GLOB COMMON ../common/*.c)
-FILE(GLOB SOCKET ./*.c)
-ADD_LIBRARY(socket STATIC ${COMMON} ${SOCKET})
-ADD_DEPENDENCIES(socket JSON GLOG DPDK)
-TARGET_INCLUDE_DIRECTORIES(
- socket
- PRIVATE
- ../common/
- ./
- ${CMAKE_CURRENT_LIST_DIR}/../../src/sbr/
- ${CMAKE_CURRENT_LIST_DIR}/../../src/include/
-# ${PROJECT_SOURCE_DIR}/src/framework/include/
-# ${PROJECT_SOURCE_DIR}/src/framework/common/include/
-# ${ADAPT_DIRECTORIES}
-# ${DMM_API}
-)
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_cfg.h b/stacks/lwip_stack/lwip_src/socket/stackx_cfg.h
deleted file mode 100644
index 4f4749d..0000000
--- a/stacks/lwip_stack/lwip_src/socket/stackx_cfg.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef STACKX_CONTAINER_CFG_H
-#define STACKX_CONTAINER_CFG_H
-#include "types.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-#define SBR_MAX_CFG_PATH_LEN 256
-#define SBR_MAX_CONTAINER_IP_NUM 1024
-#define SBR_MAX_CFG_FILE_SIZE (1 * 1024 * 1024)
-
-typedef struct
-{
- u32 ip;
- u32 mask_len;
-} sbr_container_ip;
-
-typedef struct
-{
- sbr_container_ip ip_array[SBR_MAX_CONTAINER_IP_NUM];
- u32 ip_num;
-} sbr_container_ip_group;
-
-extern sbr_container_ip_group g_container_ip_group;
-
-int sbr_init_cfg ();
-int sbr_get_src_ip (u32 dst_ip, u32 * src_ip);
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_container_cfg.c b/stacks/lwip_stack/lwip_src/socket/stackx_container_cfg.c
deleted file mode 100644
index b6580ed..0000000
--- a/stacks/lwip_stack/lwip_src/socket/stackx_container_cfg.c
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <arpa/inet.h>
-#include "stackx_cfg.h"
-#include "json.h"
-#include "nstack_log.h"
-#include "spl_def.h"
-#include "nstack_securec.h"
-#include "stackx_ip_addr.h"
-
-sbr_container_ip_group g_container_ip_group;
-
-/*****************************************************************************
-* Prototype : sbr_parse_container_ip_json
-* Description : parse port json
-* Input : char* param
-* Output : None
-* Return Value : static void
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static void
-sbr_parse_container_ip_json (char *param)
-{
- int retval;
- struct json_object *obj = json_tokener_parse (param);
- struct json_object *container_id_obj = NULL;
- struct json_object *ports_list_obj = NULL;
- struct json_object *ip_cidr_list_obj = NULL;
-
- if (!obj)
- {
- NSSBR_LOGERR ("json_tokener_parse failed");
- return;
- }
-
- json_object_object_get_ex (obj, "containerID", &container_id_obj);
- if (!container_id_obj)
- {
- NSSBR_LOGERR ("can't get containerID");
- goto RETURN_ERROR;
- }
-
- json_object_object_get_ex (obj, "ports_list", &ports_list_obj);
- if (ports_list_obj)
- {
- int i;
- int port_num = json_object_array_length (ports_list_obj);
-
- if (0 == port_num)
- {
- NSSBR_LOGERR ("port num is 0");
- goto RETURN_ERROR;
- }
-
- for (i = 0; i < port_num; i++)
- {
- struct json_object *port_obj =
- json_object_array_get_idx (ports_list_obj, i);
- json_object_object_get_ex (port_obj, "ip_cidr", &ip_cidr_list_obj);
- if (ip_cidr_list_obj)
- {
- int j;
- int ip_cidr_num = json_object_array_length (ip_cidr_list_obj);
- for (j = 0; j < ip_cidr_num; ++j)
- {
- struct json_object *ip_cidr_obj =
- json_object_array_get_idx (ip_cidr_list_obj, j);
- if (ip_cidr_obj)
- {
- char tmp[32] = { 0 };
- const char *ip_cidr =
- json_object_get_string (ip_cidr_obj);
- if ((NULL == ip_cidr) || (ip_cidr[0] == 0))
- {
- NSSBR_LOGERR ("ip is empty");
- goto RETURN_ERROR;
- }
-
- const char *sub = strstr (ip_cidr, "/");
- if ((NULL == sub)
- || (sizeof (tmp) - 1 <
- (unsigned int) (sub - ip_cidr))
- || (strlen (sub) > sizeof (tmp) - 1))
- {
- NSSBR_LOGERR ("ip format is not ok");
- goto RETURN_ERROR;
- }
-
- retval =
- STRNCPY_S (tmp, sizeof (tmp), ip_cidr,
- (size_t) (sub - ip_cidr));
- if (EOK != retval)
- {
- NSSBR_LOGERR ("STRNCPY_S failed]ret=%d", retval);
- goto RETURN_ERROR;
- }
-
- struct in_addr addr;
- retval =
- MEMSET_S (&addr, sizeof (addr), 0, sizeof (addr));
- if (EOK != retval)
- {
- NSSBR_LOGERR ("MEMSET_S failed]ret=%d", retval);
- goto RETURN_ERROR;
- }
-
- retval = spl_inet_aton (tmp, &addr);
- if (0 == retval)
- {
- NSSBR_LOGERR ("spl_inet_aton failed]ret=%d",
- retval);
- goto RETURN_ERROR;
- }
-
- g_container_ip_group.
- ip_array[g_container_ip_group.ip_num].ip =
- addr.s_addr;
- int mask_len = atoi (sub + 1);
- if ((mask_len <= 0) || (mask_len > 32))
- {
- NSSBR_LOGERR ("mask len is not ok");
- goto RETURN_ERROR;
- }
-
- g_container_ip_group.
- ip_array[g_container_ip_group.ip_num].mask_len =
- (u32) mask_len;
- g_container_ip_group.ip_num++;
-
- if (g_container_ip_group.ip_num >=
- SBR_MAX_CONTAINER_IP_NUM)
- {
- NSSBR_LOGWAR ("container ip num is full]ip_num=%u",
- g_container_ip_group.ip_num);
- goto RETURN_OK;
- }
- }
- }
- }
- }
- }
- else
- {
- NSSBR_LOGERR ("can't get ports_list");
- goto RETURN_ERROR;
- }
-
-RETURN_OK:
- json_object_put (obj);
- NSSBR_LOGINF ("container ip num is %u", g_container_ip_group.ip_num);
- u32 idx;
- for (idx = 0; idx < g_container_ip_group.ip_num; ++idx)
- {
- NSSBR_LOGDBG ("container ip=0x%08x",
- g_container_ip_group.ip_array[idx].ip);
- }
- return;
-
-RETURN_ERROR:
- json_object_put (obj);
- if (MEMSET_S
- (&g_container_ip_group, sizeof (sbr_container_ip_group), 0,
- sizeof (sbr_container_ip_group)) != EOK)
- {
- NSSBR_LOGERR ("MEMSET_S failed");
- }
-}
-
-/*****************************************************************************
-* Prototype : sbr_get_cfg_path
-* Description : get cfg path
-* Input : None
-* Output : None
-* Return Value : NSTACK_STATIC const char*
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-NSTACK_STATIC const char *
-sbr_get_cfg_path ()
-{
- static char cfg_file[SBR_MAX_CFG_PATH_LEN] = "/canal/output/portinfo.json";
- return cfg_file;
-}
-
-/*****************************************************************************
-* Prototype : sbr_init_cfg
-* Description : init cfg from file
-* Input : None
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_init_cfg ()
-{
- int ret;
- off_t file_len = 0;
- off_t buff_len = 0;
- char *buff = NULL;
- const char *cfg_file = sbr_get_cfg_path (); /* no need check ret */
-
- int fp = open (cfg_file, O_RDONLY);
-
- if (fp < 0)
- {
- NSSBR_LOGWAR ("failed to open file]file name=%s", cfg_file);
- goto RETURN_ERROR;
- }
-
- file_len = lseek (fp, 0, SEEK_END);
- if (file_len <= 0)
- {
- NSSBR_LOGWAR ("failed to get file len]file name=%s", cfg_file);
- goto RETURN_ERROR;
- }
-
- if (file_len > SBR_MAX_CFG_FILE_SIZE)
- {
- NSSBR_LOGWAR
- ("file len is too big]file len=%d, max len=%d, file name=%s",
- file_len, SBR_MAX_CFG_FILE_SIZE, cfg_file);
- goto RETURN_ERROR;
- }
-
- ret = lseek (fp, 0, SEEK_SET);
- if (ret < 0)
- {
- NSSBR_LOGWAR ("seek to start failed]file name=%s", cfg_file);
- goto RETURN_ERROR;
- }
-
- buff_len = file_len + 1;
- buff = (char *) malloc (buff_len);
- if (!buff)
- {
- NSSBR_LOGWAR ("malloc buff failed]buff_len=%d", buff_len);
- goto RETURN_ERROR;
- }
-
- ret = MEMSET_S (buff, buff_len, 0, buff_len);
- if (EOK != ret)
- {
- NSSBR_LOGWAR ("MEMSET_S failed]ret=%d.", ret);
- goto RETURN_ERROR;
- }
-
- ret = read (fp, buff, buff_len - 1);
- if (ret <= 0)
- {
- NSSBR_LOGWAR ("read failed]ret=%d", ret);
- goto RETURN_ERROR;
- }
-
- sbr_parse_container_ip_json (buff);
- close (fp);
- free (buff);
- return 0;
-
-RETURN_ERROR:
- if (fp >= 0)
- {
- close (fp);
- }
-
- if (buff)
- {
- free (buff);
- }
-
- return -1;
-}
-
-/*****************************************************************************
-* Prototype : sbr_get_src_ip
-* Description : get src ip from cfg
-* Input : u32 dst_ip
-* u32* src_ip
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_get_src_ip (u32 dst_ip, u32 * src_ip)
-{
- if (!src_ip)
- {
- NSSBR_LOGERR ("src_ip is NULL");
- return -1;
- }
-
- u32 i;
- for (i = 0; i < g_container_ip_group.ip_num; ++i)
- {
- unsigned int mask = ~0;
- mask = (mask << (32 - g_container_ip_group.ip_array[i].mask_len));
- mask = htonl (mask);
- if ((dst_ip & mask) == (g_container_ip_group.ip_array[i].ip & mask))
- {
- *src_ip = g_container_ip_group.ip_array[i].ip;
- NSSBR_LOGDBG ("find src ip]container_ip=0x%08x,dest_ip=0x%08x",
- *src_ip, dst_ip);
- return 0;
- }
- }
-
- NSSBR_LOGDBG ("can't find src ip]dest_ip=0x%08x", dst_ip);
- return -1;
-}
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_epoll_api.c b/stacks/lwip_stack/lwip_src/socket/stackx_epoll_api.c
deleted file mode 100644
index 0223ac9..0000000
--- a/stacks/lwip_stack/lwip_src/socket/stackx_epoll_api.c
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "stackx_epoll_api.h"
-#include "stackx_spl_share.h"
-#include "common_pal_bitwide_adjust.h"
-#include "nstack_dmm_adpt.h"
-#include "nstack_dmm_api.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif /* _cplusplus */
-
-void
-epoll_triggle_event_from_api (sbr_socket_t * sock, int op)
-{
- struct spl_netconn *conn = sbr_get_conn (sock);
- void *epInfo = ADDR_SHTOL (conn->epInfo);
- //NSPOL_LOGDBG(SOCKETS_DEBUG, "enter]fd=%d,op=%d", sock, op);
- switch (op)
- {
- case EPOLL_API_OP_RECV:
- break;
- case EPOLL_API_OP_SEND:
- if (conn->epoll_flag && epInfo)
- {
- nstack_event_callback (epInfo, EPOLLOUT);
- }
- break;
- case EPOLL_API_OP_STACK_RECV:
- if (conn->epoll_flag && epInfo)
- {
- nstack_event_callback (epInfo, EPOLLIN);
- }
- break;
- default:
- break;
- }
- return;
-}
-
-/*
- * This function will be registed to application
- * The context will be in the application
- */
-unsigned int
-stackx_eventpoll_triggle (sbr_socket_t * sock, int triggle_ops,
- struct epoll_event *pevent, void *pdata)
-{
- struct spl_netconn *conn = sbr_get_conn (sock);
- unsigned int events = 0;
- if (!conn)
- {
- NSPOL_LOGINF (SOCKETS_DEBUG, "get socket failed]fd=%d", sock->fd);
- return -1;
- }
-
- NSPOL_LOGINF (SOCKETS_DEBUG,
- "]fd=%d,triggle_ops=%d conn=%p event:%d pdata=%p", sock->fd,
- triggle_ops, conn, pevent->events, pdata);
- /*
- * sock->epoll_flag must be set before sock->rcvevent check.
- * Consider this Scenario : 1) network stack has got one packet, but event_callback not called yet
- * 2) Do epoll ctl add, then stackx triggle will check event, it will get 0
- * 3) network stack call event_callback , it will check epoll_flag
- * So, if epoll_flag not set before sock->rcvent check, neither of network stack and stackx triggle
- * will add this event to epoll. because : for network stack, event_callback check epoll_flag fail
- * for stackx triggle, event check fail.
- */
- if (nstack_ep_triggle_add == triggle_ops)
- {
- /*log info */
- conn->epInfo = pdata;
- __sync_fetch_and_add (&conn->epoll_flag, 1);
- }
-
- if ((pevent->events & EPOLLIN)
- &&
- (!((conn->rcvevent == 0) && (sbr_get_fd_share (sock)->lastdata == 0)
- && (sbr_get_fd_share (sock)->lastoffset == 0))))
- events |= EPOLLIN;
- if ((pevent->events & EPOLLOUT) && conn->sendevent)
- events |= EPOLLOUT;
- if (conn->errevent)
- events |= pevent->events & (conn->errevent);
-
- switch (triggle_ops)
- {
- case nstack_ep_triggle_add:
- break;
- case nstack_ep_triggle_mod:
- break;
- case nstack_ep_triggle_del:
- if (conn->epoll_flag > 0)
- {
- __sync_fetch_and_sub (&conn->epoll_flag, 1);
- }
- events = 0;
- break;
- default:
- return -1;
- }
- return events;
-}
-
-/*
- * This function will be registed to application
- * The context will be in the application
- * RETURN VALUE : Event exists in current protocol
- */
-unsigned int
-stackx_eventpoll_getEvt (sbr_socket_t * sock, unsigned int events)
-{
- struct spl_netconn *conn = sbr_get_conn (sock);
- unsigned int tevent = 0;
- if ((events & EPOLLIN)
- &&
- (!((conn->rcvevent == 0) && (sbr_get_fd_share (sock)->lastdata == 0)
- && (sbr_get_fd_share (sock)->lastoffset == 0))))
- {
- tevent |= EPOLLIN;
- }
-
- if ((events & EPOLLOUT) && conn->sendevent)
- {
- tevent |= EPOLLOUT;
- }
- return tevent;
-}
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif /* _cplusplus */
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_epoll_api.h b/stacks/lwip_stack/lwip_src/socket/stackx_epoll_api.h
deleted file mode 100644
index 59a1d21..0000000
--- a/stacks/lwip_stack/lwip_src/socket/stackx_epoll_api.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef STACKX_EPOLL_API_H
-#define STACKX_EPOLL_API_H
-#include "stackx_socket.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-typedef enum
-{
- EPOLL_API_OP_RECV,
- EPOLL_API_OP_SEND,
- EPOLL_API_OP_STACK_RECV
-} EPOLL_TRIGGLE_EVENT_API_OPS_T;
-
-extern void epoll_triggle_event_from_api (sbr_socket_t * sock, int op);
-extern unsigned int stackx_eventpoll_getEvt (sbr_socket_t * sock,
- unsigned int events);
-extern unsigned int stackx_eventpoll_triggle (sbr_socket_t * sock,
- int triggle_ops,
- struct epoll_event *pevent,
- void *pdata);
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_event.c b/stacks/lwip_stack/lwip_src/socket/stackx_event.c
deleted file mode 100644
index 1967ecc..0000000
--- a/stacks/lwip_stack/lwip_src/socket/stackx_event.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "stackx_spl_share.h"
-#include "common_pal_bitwide_adjust.h"
-#include "stackx_event.h"
-
-#define FREE_FD_SET(readfd, writefd, exceptfd) {\
-if(readfd)\
-free(readfd);\
-if(writefd)\
-free(writefd);\
-if(exceptfd)\
-free(exceptfd);\
-}
-
-int
-lwip_try_select (int fdsize, fd_set * fdread, fd_set * fdwrite,
- fd_set * fderr, struct timeval *timeout)
-{
- int i;
- int nready = 0;
- nstack_fd_set *read_out;
- nstack_fd_set *write_out;
- nstack_fd_set *err_out;
- nstack_fd_set *readfd = (nstack_fd_set *) fdread;
- nstack_fd_set *writefd = (nstack_fd_set *) fdwrite;
- nstack_fd_set *exceptfd = (nstack_fd_set *) fderr;
- sbr_socket_t *sock;
- spl_netconn_t *conn;
-
- if ((fdsize >= NSTACK_SETSIZE) || (fdsize < 0))
- {
- return 0;
- }
- read_out = malloc (sizeof (nstack_fd_set));
- write_out = malloc (sizeof (nstack_fd_set));
- err_out = malloc (sizeof (nstack_fd_set));
- if ((!read_out) || (!write_out) || (!err_out))
- {
- NSPOL_LOGERR ("malloc nstack_fd_set fail");
- FREE_FD_SET (read_out, write_out, err_out);
- return -1;
- }
- int ret = NSTACK_FD_ZERO (read_out);
- int ret1 = NSTACK_FD_ZERO (write_out);
- int ret2 = NSTACK_FD_ZERO (err_out);
-
- if ((EOK != ret) || (EOK != ret1) || (EOK != ret2))
- {
- NSPOL_LOGERR ("NSTACK_FD_ZERO fail");
- FREE_FD_SET (read_out, write_out, err_out);
- return -1;
- }
-
- for (i = 0; i < fdsize; i++)
- {
- if (!((readfd && NSTACK_FD_ISSET (i, readfd))
- || (writefd && NSTACK_FD_ISSET (i, writefd))
- || (exceptfd && NSTACK_FD_ISSET (i, exceptfd))))
- {
- continue;
- }
- sock = sbr_lookup_sk (i);
- if (sock == NULL)
- {
- errno = EBADF;
- FREE_FD_SET (read_out, write_out, err_out);
- return -1;
- }
- conn = sbr_get_conn (sock);
- if (!conn)
- {
- errno = EBADF;
- FREE_FD_SET (read_out, write_out, err_out);
- return -1;
- }
- if (readfd && NSTACK_FD_ISSET (i, readfd) &&
- ((sbr_get_fd_share (sock)->lastdata != NULL)
- || (conn->rcvevent > 0)))
- {
- NSTACK_FD_SET (i, read_out);
- nready++;
- }
- if (writefd && NSTACK_FD_ISSET (i, writefd) && (conn->sendevent != 0))
- {
- NSTACK_FD_SET (i, write_out);
- nready++;
- }
- if (exceptfd && NSTACK_FD_ISSET (i, exceptfd) && (conn->errevent != 0))
- {
- NSTACK_FD_SET (i, write_out);
- nready++;
- }
- }
-
- //TODO: need to handle fd_set and nstack_fd_set memory issue
- if (readfd)
- {
- *readfd = *read_out;
- }
-
- if (writefd)
- {
- *writefd = *write_out;
- }
-
- if (exceptfd)
- {
- *exceptfd = *err_out;
- }
-
- FREE_FD_SET (read_out, write_out, err_out);
- return nready;
-}
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_event.h b/stacks/lwip_stack/lwip_src/socket/stackx_event.h
deleted file mode 100644
index f95b370..0000000
--- a/stacks/lwip_stack/lwip_src/socket/stackx_event.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef __STACKX_EVENT_H__
-#define __STACKX_EVENT_H__
-
-#include <sys/types.h>
-#include <sys/time.h>
-#include <stdio.h>
-#include <unistd.h>
-#include "stackx_socket.h"
-#include "nstack_securec.h"
-#include "sbr_res_mgr.h"
-#include "sbr_index_ring.h"
-#define NSTACK_SETSIZE SBR_MAX_FD_NUM
-
-typedef struct
-{
- unsigned char fds_bits[(NSTACK_SETSIZE + 7) / 8];
-} __attribute__ ((packed)) nstack_fd_set;
-
-#define NSTACK_FD_SET(n, p) ((p)->fds_bits[(n)/8]|=1U<<((n)&0x07))
-#define NSTACK_FD_ISSET(n,p) (((p)->fds_bits[(n)/8]&(1U<<((n)&0x07)))?1:0)
-#define NSTACK_FD_CLR(n,p) ((p)->fds_bits[(n)/8]&=~(1U<<((n)&0x07)))
-#define NSTACK_FD_ZERO(p) (MEMSET_S((void *)(p), sizeof(*(p)),0,sizeof(*(p))))
-#define NSTACK_FD_OR(p1 ,p2) {\
- int i;\
- for(i = 0; i < (NSTACK_SETSIZE+7)/8; i++){\
- (p1)->fds_bits[i] |= (p2)->fds_bits[i];\
- }\
-}
-
-#endif /* __STACKX_EVENT_H__ */
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_macro.h b/stacks/lwip_stack/lwip_src/socket/stackx_macro.h
deleted file mode 100644
index 96a0b91..0000000
--- a/stacks/lwip_stack/lwip_src/socket/stackx_macro.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef STACKX_MACRO_H
-#define STACKX_MACRO_H
-
-#ifndef SBR_USE_LOCK
-#define SBR_USE_LOCK
-#endif
-
-#endif
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_msg_handler.c b/stacks/lwip_stack/lwip_src/socket/stackx_msg_handler.c
deleted file mode 100644
index 6fcde44..0000000
--- a/stacks/lwip_stack/lwip_src/socket/stackx_msg_handler.c
+++ /dev/null
@@ -1,775 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "stackx_msg_handler.h"
-#include "stackx_spl_share.h"
-#include "stackx_spl_msg.h"
-#include "nsfw_msg_api.h"
-#include "common_pal_bitwide_adjust.h"
-#include "stackx_res_mgr.h"
-#include "stackx_prot_com.h"
-#include "nstack_securec.h"
-//#include "stackx_dfx_api.h"
-
-#define SBR_MSG_MALLOC(sk) msg_malloc(ss_get_msg_pool(sbr_get_conn(sk)))
-#define SBR_MSG_FREE(msg) msg_free(msg)
-
-#define SBR_MSG_POST(msg, ring) \
- do { \
- if (MSG_ASYN_POST == msg->param.op_type)\
- {\
- if (msg_post(msg, ring) < 0)\
- {\
- SBR_MSG_FREE(msg); \
- NSSBR_LOGERR("msg_post failed]major=%u,minor=%u,type=%u", \
- msg->param.major_type, msg->param.minor_type, msg->param.op_type); \
- }\
- } \
- else \
- {\
- if (msg_post(msg, ring) < 0)\
- {\
- msg->param.err = ECONNABORTED; \
- NSSBR_LOGERR("msg_post_with_ref failed]major=%u,minor=%u,type=%u", \
- msg->param.major_type, msg->param.minor_type, msg->param.op_type); \
- }\
- } \
- } while (0)
-
-#define SBR_MSG_POST_RET(msg, ring, ret) \
- do { \
- if (MSG_ASYN_POST == msg->param.op_type)\
- {\
- if ((ret = msg_post(msg, ring)) < 0)\
- {\
- SBR_MSG_FREE(msg); \
- NSSBR_LOGERR("msg_post failed]major=%u,minor=%u,type=%u", \
- msg->param.major_type, msg->param.minor_type, msg->param.op_type); \
- }\
- } \
- else \
- {\
- if ((ret = msg_post(msg, ring)) < 0)\
- {\
- msg->param.err = ECONNABORTED; \
- NSSBR_LOGERR("msg_post_with_ref failed]major=%u,minor=%u,type=%u", \
- msg->param.major_type, msg->param.minor_type, msg->param.op_type); \
- }\
- } \
- } while (0)
-
-NSTACK_STATIC inline void
-_sbr_construct_msg (data_com_msg * m, u16 major_type, u16 minor_type,
- u16 type, sbr_socket_t * sk)
-{
- m->param.module_type = MSG_MODULE_SBR;
- m->param.major_type = major_type;
- m->param.minor_type = minor_type;
- m->param.err = 0;
- m->param.op_type = type;
- sys_sem_init (&m->param.op_completed);
- m->param.receiver = ss_get_recv_obj (sbr_get_conn (sk));
- m->param.comm_receiver = ss_get_comm_private_data (sbr_get_conn (sk));
- m->param.extend_member_bit = 0;
-}
-
-#define sbr_construct_msg(m, major_type, minor_type, type, sk) { \
- _sbr_construct_msg(m, major_type, minor_type, type, sk); \
- NSSBR_LOGINF("fd=%d,conn=%p,private_data=%p", sk->fd, sbr_get_conn(sk), ss_get_private_data(sbr_get_conn(sk))); \
- }
-
-#define sbr_construct_msg_dbg(m, major_type, minor_type, type, sk) { \
- _sbr_construct_msg(m, major_type, minor_type, type, sk); \
- NSSBR_LOGDBG("fd=%d,conn=%p,private_data=%p", sk->fd, sbr_get_conn(sk), ss_get_private_data(sbr_get_conn(sk))); \
- }
-
-/*****************************************************************************
-* Prototype : sbr_attach_msg
-* Description : use buf's msg first
-* Input : sbr_socket_t * sk
-* struct pbuf* buf
-* Output : None
-* Return Value : static inline data_com_msg*
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline data_com_msg *
-sbr_attach_msg (sbr_socket_t * sk, struct spl_pbuf *buf)
-{
- data_com_msg *m = NULL;
- if (!sk)
- {
- return m;
- }
-
- if (buf && buf->msg)
- {
- m = (data_com_msg *) ADDR_SHTOL (buf->msg);
- }
- else
- {
- m = SBR_MSG_MALLOC (sk);
- }
-
- return m;
-}
-
-/*****************************************************************************
-* Prototype : sbr_handle_socket
-* Description : create socket
-* Input : sbr_socket_t * sk
-* netconn_type_t type
-* u8 proto
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_handle_socket (sbr_socket_t * sk, spl_netconn_type_t type, u8 proto)
-{
- data_com_msg *m = SBR_MSG_MALLOC (sk);
-
- if (!m)
- {
- NSSBR_LOGERR ("malloc msg failed]fd=%d", sk->fd);
- sbr_set_sk_errno (sk, ENOMEM);
- return -1;
- }
-
- sbr_construct_msg (m, SPL_TCPIP_NEW_MSG_API, SPL_API_DO_NEWCONN,
- MSG_SYN_POST, sk);
- msg_new_netconn *p = (msg_new_netconn *) m->buffer;
- p->conn = (spl_netconn_t *) ADDR_LTOSH (sbr_get_conn (sk));
- p->type = type;
- p->proto = proto;
- p->socket = sk->fd;
- p->extend_member_bit = 0;
- SBR_MSG_POST (m, sbr_get_msg_box (sk));
- int err = sbr_spl_err_to_errno (m->param.err);
- SBR_MSG_FREE (m);
- if (err != 0)
- {
- NSSBR_LOGERR ("handle socket failed]fd=%d,type=%d,proto=%u,err=%d",
- sk->fd, type, proto, err);
- sbr_set_sk_errno (sk, err);
- return -1;
- }
-
- return 0;
-}
-
-/*****************************************************************************
-* Prototype : sbr_handle_bind
-* Description : bind
-* Input : sbr_socket_t * sk
-* spl_ip_addr_t * addr
-* u16 port
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_handle_bind (sbr_socket_t * sk, spl_ip_addr_t * addr, u16 port)
-{
- data_com_msg *m = SBR_MSG_MALLOC (sk);
-
- if (!m)
- {
- NSSBR_LOGERR ("malloc msg failed]fd=%d", sk->fd);
- sbr_set_sk_errno (sk, ENOMEM);
- return -1;
- }
-
- sbr_construct_msg (m, SPL_TCPIP_NEW_MSG_API, SPL_API_DO_BIND, MSG_SYN_POST,
- sk);
- msg_bind *p = (msg_bind *) m->buffer;
- p->ipaddr = *addr;
- p->port = port;
- p->extend_member_bit = 0;
- SBR_MSG_POST (m, sbr_get_msg_box (sk));
- int err = sbr_spl_err_to_errno (m->param.err);
- SBR_MSG_FREE (m);
- if (err != 0)
- {
- NSSBR_LOGERR ("handle bind failed]fd=%d,err=%d", sk->fd, err);
- sbr_set_sk_errno (sk, err);
- return -1;
- }
-
- return 0;
-}
-
-int
-sbr_handle_listen (sbr_socket_t * sk, int backlog)
-{
- data_com_msg *m = SBR_MSG_MALLOC (sk);
-
- if (!m)
- {
- sbr_set_sk_errno (sk, ENOMEM);
- return -1;
- }
-
- sbr_construct_msg (m, SPL_TCPIP_NEW_MSG_API, SPL_API_DO_LISTEN,
- MSG_SYN_POST, sk);
- msg_listen *p = (msg_listen *) m->buffer;
- p->conn_pool = sbr_get_conn_pool ();
- p->backlog = backlog;
- p->extend_member_bit = 0;
- SBR_MSG_POST (m, sbr_get_msg_box (sk));
- int err = sbr_spl_err_to_errno (m->param.err);
- SBR_MSG_FREE (m);
- if (err != 0)
- {
- NSSBR_LOGERR ("handle listen failed]fd=%d,err=%d", sk->fd, err);
- sbr_set_sk_errno (sk, err);
- return -1;
- }
-
- return 0;
-}
-
-/*****************************************************************************
-* Prototype : sbr_handle_connect
-* Description : connect
-* Input : sbr_socket_t * sk
-* spl_ip_addr_t * addr
-* u16 port
-* spl_ip_addr_t* local_ip
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_handle_connect (sbr_socket_t * sk, spl_ip_addr_t * addr, u16 port,
- spl_ip_addr_t * local_ip)
-{
- data_com_msg *m = SBR_MSG_MALLOC (sk);
-
- if (!m)
- {
- NSSBR_LOGERR ("malloc msg failed]fd=%d", sk->fd);
- sbr_set_sk_errno (sk, ENOMEM);
- return -1;
- }
-
- sbr_construct_msg (m, SPL_TCPIP_NEW_MSG_API, SPL_API_DO_CONNECT,
- MSG_SYN_POST, sk);
- msg_connect *p = (msg_connect *) m->buffer;
- p->local_ip = *local_ip;
- p->ipaddr = *addr;
- p->port = port;
- p->extend_member_bit = 0;
- SBR_MSG_POST (m, sbr_get_msg_box (sk));
- int err = sbr_spl_err_to_errno (m->param.err);
- SBR_MSG_FREE (m);
- if (err != 0)
- {
- NSSBR_LOGERR ("handle connect failed]fd=%d,err=%d", sk->fd, err);
- sbr_set_sk_errno (sk, err);
- return -1;
- }
-
- return 0;
-}
-
-/*****************************************************************************
-* Prototype : sbr_handle_get_name
-* Description : get name
-* Input : sbr_socket_t * sk
-* struct sockaddr * name
-* socklen_t * namelen
-* u8 cmd
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_handle_get_name (sbr_socket_t * sk, struct sockaddr *name,
- socklen_t * namelen, u8 cmd)
-{
- data_com_msg *m = SBR_MSG_MALLOC (sk);
-
- if (!m)
- {
- NSSBR_LOGERR ("malloc msg failed]fd=%d", sk->fd);
- sbr_set_sk_errno (sk, ENOMEM);
- return -1;
- }
-
- sbr_construct_msg (m, SPL_TCPIP_NEW_MSG_API, SPL_API_DO_GETSOCK_NAME,
- MSG_SYN_POST, sk);
- msg_getaddrname *p = (msg_getaddrname *) m->buffer;
- p->cmd = cmd;
- p->extend_member_bit = 0;
- SBR_MSG_POST (m, sbr_get_msg_box (sk));
- int err = sbr_spl_err_to_errno (m->param.err);
- if (err != 0)
- {
- NSSBR_LOGERR ("handle get name failed]fd=%d,err=%d", sk->fd, err);
- goto error;
- }
- else
- {
- if (*namelen > sizeof (p->sock_addr))
- {
- *namelen = sizeof (p->sock_addr);
- }
-
- int ret = MEMCPY_S (name, *namelen, &p->sock_addr, *namelen);
- if (0 != ret)
- {
- NSSBR_LOGERR ("MEMCPY_S failed]fd=%d,ret=%d", sk->fd, ret);
- err = EINVAL;
- goto error;
- }
-
- *namelen = sizeof (p->sock_addr);
- }
-
- SBR_MSG_FREE (m);
- return 0;
-
-error:
- sbr_set_sk_errno (sk, err);
- SBR_MSG_FREE (m);
- return -1;
-}
-
-/*****************************************************************************
-* Prototype : sbr_handle_setsockopt
-* Description : msg box will changed in IP_TOS
-* Input : sbr_socket_t * sk
-* int level
-* int optname
-* const void *optval
-* socklen_t optlen
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_handle_setsockopt (sbr_socket_t * sk, int level, int optname,
- const void *optval, socklen_t optlen)
-{
- data_com_msg *m = SBR_MSG_MALLOC (sk);
-
- if (!m)
- {
- NSSBR_LOGERR ("malloc msg failed]fd=%d", sk->fd);
- sbr_set_sk_errno (sk, ENOMEM);
- return -1;
- }
-
- sbr_construct_msg (m, SPL_TCPIP_NEW_MSG_API, SPL_API_DO_SET_SOCK_OPT,
- MSG_SYN_POST, sk);
- msg_setgetsockopt *p = (msg_setgetsockopt *) m->buffer;
- p->extend_member_bit = 0;
- p->level = level;
- p->optname = optname;
- p->msg_box = NULL; /* init the value to avoid unexpected consequences */
-
- if (optlen > sizeof (p->optval))
- {
- optlen = sizeof (p->optval);
- }
-
- p->optlen = optlen;
- int err;
- int ret = MEMCPY_S (&p->optval, sizeof (p->optval), optval, optlen);
- if (0 != ret)
- {
- NSSBR_LOGERR ("MEMCPY_S failed]fd=%d,ret=%d", sk->fd, ret);
- err = EINVAL;
- goto error;
- }
-
- SBR_MSG_POST (m, sbr_get_msg_box (sk));
- err = sbr_spl_err_to_errno (m->param.err);
- if (err != 0)
- {
- NSSBR_LOGERR ("handle setsockopt failed]fd=%d,err=%d", sk->fd, err);
- goto error;
- }
-
- if (IPPROTO_IP == level && IP_TOS == optname && p->msg_box)
- {
- ss_set_msg_box (sbr_get_conn (sk),
- (mring_handle) ADDR_SHTOL (p->msg_box));
- }
-
- SBR_MSG_FREE (m);
- return 0;
-
-error:
- sbr_set_sk_errno (sk, err);
- SBR_MSG_FREE (m);
- return -1;
-}
-
-/*****************************************************************************
-* Prototype : sbr_handle_getsockopt
-* Description : get sockopt
-* Input : sbr_socket_t * sk
-* int level
-* int optname
-* void *optval
-* socklen_t* optlen
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_handle_getsockopt (sbr_socket_t * sk, int level, int optname,
- void *optval, socklen_t * optlen)
-{
- data_com_msg *m = SBR_MSG_MALLOC (sk);
-
- if (!m)
- {
- NSSBR_LOGERR ("malloc msg failed]fd=%d", sk->fd);
- sbr_set_sk_errno (sk, ENOMEM);
- return -1;
- }
-
- sbr_construct_msg (m, SPL_TCPIP_NEW_MSG_API, SPL_API_DO_GET_SOCK_OPT,
- MSG_SYN_POST, sk);
- msg_setgetsockopt *p = (msg_setgetsockopt *) m->buffer;
- p->extend_member_bit = 0;
- p->level = level;
- p->optname = optname;
-
- if (*optlen > sizeof (p->optval))
- {
- *optlen = sizeof (p->optval);
- }
-
- p->optlen = *optlen;
- int err;
- int ret = MEMCPY_S (&p->optval, sizeof (p->optval), optval, *optlen);
- if (0 != ret)
- {
- NSSBR_LOGERR ("MEMCPY_S failed]fd=%d,ret=%d", sk->fd, ret);
- err = EINVAL;
- goto error;
- }
-
- SBR_MSG_POST (m, sbr_get_msg_box (sk));
-
- err = sbr_spl_err_to_errno (m->param.err);
- if (err != 0)
- {
- NSSBR_LOGERR ("handle getsockopt failed]fd=%d,err=%d", sk->fd, err);
- goto error;
- }
-
- ret = MEMCPY_S (optval, *optlen, &p->optval.int_optval, *optlen);
- if (0 != ret)
- {
- NSSBR_LOGERR ("MEMCPY_S failed]fd=%d,ret=%d", sk->fd, ret);
- err = EINVAL;
- goto error;
- }
-
- SBR_MSG_FREE (m);
- return 0;
-
-error:
- sbr_set_sk_errno (sk, err);
- SBR_MSG_FREE (m);
- return -1;
-}
-
-/*****************************************************************************
-* Prototype : sbr_handle_close
-* Description : need care msg_box_ref,make sure to finalize this message
-* Input : sbr_socket_t * sk
-* u8 how
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_handle_close (sbr_socket_t * sk, u8 how)
-{
- data_com_msg *m = sbr_attach_msg (sk,
- (struct spl_pbuf *)
- ADDR_SHTOL (sbr_get_fd_share
- (sk)->recoder.head));
-
- if (!m)
- {
- NSSBR_LOGERR ("attach msg failed]fd=%d", sk->fd);
- sbr_set_sk_errno (sk, ENOMEM);
- return -1;
- }
-
- sbr_construct_msg (m, SPL_TCPIP_NEW_MSG_API, SPL_API_DO_DELCON,
- MSG_ASYN_POST, sk);
- msg_delete_netconn *p = (msg_delete_netconn *) m->buffer;
- p->extend_member_bit = 0;
- p->buf = NULL;
- p->time_started = sys_now ();
- p->shut = how;
- p->pid = get_sys_pid ();
- p->conn = (spl_netconn_t *) ADDR_LTOSH (sbr_get_conn (sk));
- p->notify_omc = FALSE;
- p->msg_box_ref = SPL_MSG_BOX_NUM;
-
- /* to ensure that the last deal with SPL_API_DO_DELCON message */
- int i;
- for (i = 0; i < SPL_MSG_BOX_NUM; ++i)
- {
- SBR_MSG_POST (m,
- ss_get_instance_msg_box (ss_get_bind_thread_index
- (sbr_get_conn (sk)), i));
- }
-
- return 0;
-}
-
-/*****************************************************************************
-* Prototype : sbr_handle_udp_send
-* Description : udp send
-* Input : sbr_socket_t * sk
-* struct netbuf *buf
-* spl_ip_addr_t* local_ip
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_handle_udp_send (sbr_socket_t * sk, struct spl_netbuf *buf,
- spl_ip_addr_t * local_ip)
-{
- data_com_msg *m =
- sbr_attach_msg (sk, (struct spl_pbuf *) ADDR_SHTOL (buf->p));
-
- if (!m)
- {
- NSSBR_LOGERR ("attach msg failed]fd=%d", sk->fd);
- sbr_set_sk_io_errno (sk, ENOMEM);
- return -1;
- }
-
- sbr_construct_msg_dbg (m, SPL_TCPIP_NEW_MSG_API, SPL_API_DO_SEND,
- MSG_ASYN_POST, sk);
- msg_send_buf *p = (msg_send_buf *) m->buffer;
- p->local_ip.addr = local_ip->addr;
- int ret = MEMCPY_S (&p->addr, sizeof (spl_ip_addr_t), &buf->addr,
- sizeof (spl_ip_addr_t));
- if (ret != 0)
- {
- NSSBR_LOGERR ("MEMCPY_S failed]fd=%d,ret=%d", sk->fd, ret);
- sbr_set_sk_io_errno (sk, EINVAL);
- SBR_MSG_FREE (m);
- return -1;
- }
-
- p->p = buf->p;
- p->port = buf->port;
- p->extend_member_bit = 0;
- SBR_MSG_POST_RET (m, sbr_get_msg_box (sk), ret);
-
- if (0 == ret)
- {
- return 0;
- }
- else
- {
- NSSBR_LOGERR ("post msg failed]fd=%d", sk->fd);
- sbr_set_sk_io_errno (sk, EAGAIN);
- return -1;
- }
-}
-
-/*****************************************************************************
-* Prototype : sbr_handle_free_recv_buf
-* Description : free recv buf,can't free buf in app
-* Input : sbr_socket_t * sk
-* Output : None
-* Return Value : void
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-void
-sbr_handle_free_recv_buf (sbr_socket_t * sk)
-{
- data_com_msg *m = sbr_attach_msg (sk,
- (struct spl_pbuf *)
- ADDR_SHTOL (sbr_get_fd_share
- (sk)->recoder.head));
-
- if (!m)
- {
- NSSBR_LOGERR ("attach msg failed]fd=%d", sk->fd);
- return;
- }
-
- sbr_construct_msg_dbg (m, SPL_TCPIP_NEW_MSG_API, SPL_API_DO_PBUF_FREE,
- MSG_ASYN_POST, sk);
- msg_free_buf *p = (msg_free_buf *) m->buffer;
- p->extend_member_bit = 0;
- p->buf = sbr_get_fd_share (sk)->recoder.head;
- sbr_get_fd_share (sk)->recoder.head = NULL;
- sbr_get_fd_share (sk)->recoder.tail = NULL;
- sbr_get_fd_share (sk)->recoder.totalLen = 0;
- SBR_MSG_POST (m, sbr_get_msg_box (sk));
-}
-
-void
-sbr_handle_free_send_buf (sbr_socket_t * sk, struct spl_pbuf *buf)
-{
- if (buf != NULL)
- {
- data_com_msg *m = sbr_attach_msg (sk, buf);
-
- if (!m)
- {
- NSSBR_LOGERR ("attach msg failed]fd=%d", sk->fd);
- return;
- }
-
- sbr_construct_msg_dbg (m, SPL_TCPIP_NEW_MSG_API, SPL_API_DO_PBUF_FREE,
- MSG_ASYN_POST, sk);
- msg_free_buf *p = (msg_free_buf *) m->buffer;
- p->extend_member_bit = 0;
- p->buf = (struct spl_pbuf *) ADDR_LTOSH (buf);
- SBR_MSG_POST (m, sbr_get_msg_box (sk));
- }
-}
-
-/*****************************************************************************
-* Prototype : sbr_handle_shutdown
-* Description : shut down
-* Input : sbr_socket_t * sk
-* u8 how
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_handle_shutdown (sbr_socket_t * sk, u8 how)
-{
- int err;
- data_com_msg *m = SBR_MSG_MALLOC (sk);
-
- if (!m)
- {
- NSSBR_LOGERR ("malloc msg failed]fd=%d", sk->fd);
- sbr_set_sk_errno (sk, ENOMEM);
- return -1;
- }
-
- sbr_construct_msg (m, SPL_TCPIP_NEW_MSG_API, SPL_API_DO_CLOSE, MSG_SYN_POST,
- sk);
- msg_close *p = (msg_close *) m->buffer;
- p->extend_member_bit = 0;
- p->time_started = sys_now ();
- p->shut = how;
- SBR_MSG_POST (m, sbr_get_msg_box (sk));
- err = sbr_spl_err_to_errno (m->param.err);
- SBR_MSG_FREE (m);
- if (err != 0)
- {
- NSSBR_LOGERR ("handle getsockopt failed]fd=%d,err=%d", sk->fd, err);
- sbr_set_sk_errno (sk, err);
- return -1;
- }
-
- return 0;
-}
-
-void
-sbr_handle_tcp_recv (sbr_socket_t * sk, u32 len, struct spl_pbuf *buf)
-{
- data_com_msg *m = sbr_attach_msg (sk, buf);
-
- if (!m)
- {
- NSSBR_LOGERR ("attach msg failed]fd=%d", sk->fd);
- return;
- }
-
- sbr_construct_msg_dbg (m, SPL_TCPIP_NEW_MSG_API, SPL_API_DO_RECV,
- MSG_ASYN_POST, sk);
- msg_recv_buf *p = (msg_recv_buf *) m->buffer;
- p->extend_member_bit = 0;
- p->len = len;
- p->p = (struct spl_pbuf *) ADDR_LTOSH (buf);
- SBR_MSG_POST (m, sbr_get_msg_box (sk));
-}
-
-int
-sbr_handle_tcp_send (sbr_socket_t * sk, size_t size, struct spl_pbuf *buf,
- u8 api_flag)
-{
- int ret;
- data_com_msg *m = sbr_attach_msg (sk, buf);
-
- if (!m)
- {
- NSSBR_LOGERR ("attach msg failed]fd=%d", sk->fd);
- sbr_set_sk_io_errno (sk, ENOMEM);
- return -1;
- }
-
- sbr_construct_msg_dbg (m, SPL_TCPIP_NEW_MSG_API, SPL_API_DO_WRITE,
- MSG_ASYN_POST, sk);
- msg_write_buf *p = (msg_write_buf *) m->buffer;
- p->extend_member_bit = 0;
- p->len = size;
- p->p = (struct spl_pbuf *) ADDR_LTOSH (buf);
- p->apiflags = api_flag;
- SBR_MSG_POST_RET (m, sbr_get_msg_box (sk), ret);
-
- if (0 == ret)
- {
- return 0;
- }
- else
- {
- NSSBR_LOGERR ("post msg failed]fd=%d", sk->fd);
- sbr_set_sk_io_errno (sk, EAGAIN);
- return -1;
- }
-}
-
-/* need delete sbr_handle_app_touch */
-void
-sbr_handle_app_touch (void)
-{
-}
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_msg_handler.h b/stacks/lwip_stack/lwip_src/socket/stackx_msg_handler.h
deleted file mode 100644
index a52d026..0000000
--- a/stacks/lwip_stack/lwip_src/socket/stackx_msg_handler.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef STACKX_MSG_HANDLER_H
-#define STACKX_MSG_HANDLER_H
-#include "stackx_socket.h"
-#include "stackx_ip_addr.h"
-#include "stackx_netbuf.h"
-#include "stackx_spl_share.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-#define SBR_GET_SOCK_NAME 1
-#define SBR_GET_PEER_NAME 0
-
-int sbr_handle_socket (sbr_socket_t * sk, spl_netconn_type_t type, u8 proto);
-
-int sbr_handle_bind (sbr_socket_t * sk, spl_ip_addr_t * addr, u16 port);
-
-int sbr_handle_listen (sbr_socket_t * sk, int backlog);
-
-int sbr_handle_connect (sbr_socket_t * sk, spl_ip_addr_t * addr, u16 port,
- spl_ip_addr_t * local_ip);
-
-int sbr_handle_get_name (sbr_socket_t * sk, struct sockaddr *name,
- socklen_t * namelen, u8 cmd);
-
-int sbr_handle_setsockopt (sbr_socket_t * sk, int level, int optname,
- const void *optval, socklen_t optlen);
-
-int sbr_handle_getsockopt (sbr_socket_t * sk, int level, int optname,
- void *optval, socklen_t * optlen);
-
-int sbr_handle_close (sbr_socket_t * sk, u8 how);
-
-int sbr_handle_udp_send (sbr_socket_t * sk, struct spl_netbuf *buf,
- spl_ip_addr_t * local_ip);
-
-void sbr_handle_free_recv_buf (sbr_socket_t * sk);
-
-void sbr_handle_free_send_buf (sbr_socket_t * sk, struct spl_pbuf *buf);
-
-int sbr_handle_shutdown (sbr_socket_t * sk, u8 how);
-
-void sbr_handle_tcp_recv (sbr_socket_t * sk, u32 len, struct spl_pbuf *buf);
-
-int sbr_handle_tcp_send (sbr_socket_t * sk, size_t size, struct spl_pbuf *buf,
- u8 api_flag);
-
-int sbr_handle_custom_send (sbr_socket_t * sk, struct spl_pbuf *buf,
- spl_ip_addr_t * src, spl_ip_addr_t * dst, u8 tos);
-
-int sbr_handle_custom_close (sbr_socket_t * sk, spl_ip_addr_t * addr);
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_prot_com.c b/stacks/lwip_stack/lwip_src/socket/stackx_prot_com.c
deleted file mode 100644
index 292c17a..0000000
--- a/stacks/lwip_stack/lwip_src/socket/stackx_prot_com.c
+++ /dev/null
@@ -1,679 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include "stackx_msg_handler.h"
-#include "stackx_prot_com.h"
-#include "common_pal_bitwide_adjust.h"
-#include "stackx_err.h"
-#include "nstack_securec.h"
-#include "nsfw_rti.h"
-//#include "stackx_custom.h"
-
-#define FAST_SLEEP_TIME 10000
-#define FAST_RETRY_COUNT 100
-#define MAX_WAIT_TIMEOUT 0x7FFFFFFF
-
-/*****************************************************************************
-* Prototype : sbr_getsockopt_sol_socket
-* Description : get sol socket
-* Input : sbr_socket_t * sk
-* int optname
-* void * optval
-* socklen_t optlen
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_getsockopt_sol_socket (sbr_socket_t * sk, int optname, void *optval,
- socklen_t optlen)
-{
- int err = 0;
-
- switch (optname)
- {
- case SO_ERROR:
- {
- if (optlen < sizeof (int))
- {
- return EINVAL;
- }
-
- /* only overwrite ERR_OK or tempoary errors */
- err = sbr_get_sk_errno (sk);
-
- if ((0 == err) || (EINPROGRESS == err))
- {
- err =
- sbr_spl_err_to_errno (ss_get_last_errno (sbr_get_conn (sk)));
- sbr_set_sk_errno (sk, err);
- }
- else
- {
- sbr_set_sk_errno (sk, 0);
- }
-
- *(int *) optval = sbr_get_sk_errno (sk);
-
- return 0;
- }
- case SO_BROADCAST:
- case SO_KEEPALIVE:
- case SO_RCVBUF:
- case SO_SNDBUF:
- case SO_REUSEADDR:
- if (optlen < sizeof (int))
- {
- err = EINVAL;
- }
-
- break;
- case SO_RCVTIMEO:
- case SO_SNDTIMEO:
- if (optlen < sizeof (struct timeval))
- {
- err = EINVAL;
- }
-
- break;
- case SO_LINGER:
- if (optlen < sizeof (struct linger))
- {
- err = EINVAL;
- }
-
- break;
- default:
- err = ENOPROTOOPT;
- break;
- }
-
- return err;
-}
-
-/*****************************************************************************
-* Prototype : sbr_getsockopt_ipproto_ip
-* Description : get ipproto ip
-* Input : int optname
-* void * optval
-* socklen_t optlen
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_getsockopt_ipproto_ip (int optname, void *optval, socklen_t optlen)
-{
- int err = 0;
-
- switch (optname)
- {
- case IP_TOS:
- if (optlen < sizeof (u8))
- {
- err = EINVAL;
- }
-
- break;
- default:
- err = ENOPROTOOPT;
- break;
- }
-
- return err;
-}
-
-/*****************************************************************************
-* Prototype : sbr_pick_timeout
-* Description : pick time
-* Input : const void * optval
-* socklen_t optlen
-* i32* timeout
-* Output : None
-* Return Value : static inline int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline int
-sbr_pick_timeout (const void *optval, socklen_t optlen, i32 * timeout)
-{
- if (optlen < sizeof (struct timeval))
- {
- return EINVAL;
- }
-
- struct timeval *time_val = (struct timeval *) optval;
- if ((time_val->tv_usec < 0) || (time_val->tv_usec > USEC_TO_SEC))
- {
- return EDOM;
- }
- else
- {
- if (time_val->tv_sec < 0)
- {
- *timeout = 0;
- }
- else
- {
- *timeout = MAX_WAIT_TIMEOUT;
- if ((time_val->tv_sec != 0) || (time_val->tv_usec != 0))
- {
- if (time_val->tv_sec < ((MAX_WAIT_TIMEOUT / 1000) - 1))
- {
- *timeout =
- time_val->tv_sec * 1000 + time_val->tv_usec / 1000;
- }
- }
- }
- }
-
- return 0;
-}
-
-/*****************************************************************************
-* Prototype : sbr_setsockopt_sol_socket
-* Description : set sol socket
-* Input : sbr_socket_t * sk
-* int optname
-* const void * optval
-* socklen_t optlen
-* netconn_type_t type
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_setsockopt_sol_socket (sbr_socket_t * sk, int optname, const void *optval,
- socklen_t optlen, spl_netconn_type_t type)
-{
- int err = 0;
-
- switch (optname)
- {
- case SO_REUSEADDR:
- case SO_BROADCAST:
- case SO_KEEPALIVE:
- case SO_RCVBUF:
- case SO_SNDBUF:
- if (optlen < sizeof (int))
- {
- err = EINVAL;
- }
-
- break;
- case SO_RCVTIMEO:
- err =
- sbr_pick_timeout (optval, optlen,
- &sbr_get_fd_share (sk)->recv_timeout);
- break;
- case SO_SNDTIMEO:
- err =
- sbr_pick_timeout (optval, optlen,
- &sbr_get_fd_share (sk)->send_timeout);
- break;
- case SO_LINGER:
- if (optlen < sizeof (struct linger))
- {
- err = EINVAL;
- }
-
- break;
- default:
- err = ENOPROTOOPT;
- break;
- }
-
- return err;
-}
-
-/*****************************************************************************
-* Prototype : sbr_setsockopt_ipproto_ip
-* Description : set ipproto ip
-* Input : int optname
-* const void * optval
-* socklen_t optlen
-* netconn_type_t type
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_setsockopt_ipproto_ip (int optname, const void *optval, socklen_t optlen,
- spl_netconn_type_t type)
-{
- int err = 0;
-
- switch (optname)
- {
- case IP_TOS:
- if (optlen < sizeof (u8))
- {
- err = EINVAL;
- }
-
- break;
- case IP_MULTICAST_TTL:
- if (optlen < sizeof (u8))
- {
- err = EINVAL;
- break;
- }
-
- if (type != SPL_NETCONN_UDP)
- {
- err = EAFNOSUPPORT;
- break;
- }
-
- break;
- case IP_MULTICAST_IF:
- if (optlen < sizeof (struct in_addr))
- {
- err = EINVAL;
- break;
- }
-
- if (type != SPL_NETCONN_UDP)
- {
- err = EAFNOSUPPORT;
- break;
- }
-
- break;
- case IP_MULTICAST_LOOP:
- if (optlen < sizeof (u8))
- {
- err = EINVAL;
- break;
- }
-
- if (type != SPL_NETCONN_UDP)
- {
- err = EAFNOSUPPORT;
- break;
- }
-
- break;
- default:
- err = ENOPROTOOPT;
- break;
- }
-
- return err;
-}
-
-/*****************************************************************************
-* Prototype : sbr_dequeue_buf
-* Description : dequeue buf
-* Input : sbr_socket_t * sk
-* void **buf
-* i32 timeout
-* u8 use_l4_ring
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_dequeue_buf (sbr_socket_t * sk, void **buf, i32 timeout)
-{
- mring_handle ring = ss_get_recv_ring (sbr_get_conn (sk));
-
- struct timespec start, end;
- long timediff;
- long timediff_sec;
- long timeout_sec = (long) (timeout / 1000);
- unsigned int retry_count = 0;
-
- if (timeout > 0)
- {
- if (unlikely (0 != clock_gettime (CLOCK_MONOTONIC, &start)))
- {
- NSSBR_LOGERR ("Failed to get time, errno = %d", errno);
- }
- }
-
- if (!ss_recv_ring_valid (sbr_get_conn (sk)))
- {
- NSSBR_LOGDBG ("ring is invalid]fd=%d", sk->fd);
- sbr_set_sk_io_errno (sk, ENOTCONN);
- return -1;
- }
-
- int dequeue_ret = 0;
- pid_t pid = get_sys_pid ();
-
- while (1)
- {
- if (ss_is_shut_rd (sbr_get_conn (sk)))
- {
- NSSBR_LOGDBG ("is shut rd]fd=%d", sk->fd);
- sbr_set_sk_io_errno (sk, EINVAL);
- return -1;
- }
-
- dequeue_ret = nsfw_mem_ring_dequeue (ring, buf);
- if (1 == dequeue_ret)
- {
- pbuf_set_recycle_flg ((struct spl_pbuf *) *buf, pid); /*release buf hold by app on abnormal exit */
- return 0;
- }
- else if (0 == dequeue_ret)
- {
- /*If the peer reset connect, try to receive data only once */
- if (ss_can_not_recv (sbr_get_conn (sk)))
- {
- NS_LOG_CTRL (LOG_CTRL_RECV_QUEUE_FULL, LOGSBR, "NSSBR",
- NSLOG_WAR, "try to fetch one more time]fd=%d",
- sk->fd);
- /**
- * l4_ring will not be processed here as can_not_recv flag is
- * set by TCP only.
- */
- if (1 == nsfw_mem_ring_dequeue (ring, buf))
- {
- pbuf_set_recycle_flg ((struct spl_pbuf *) *buf, pid);
- return 0;
- }
-
- sbr_set_sk_io_errno (sk, ENOTCONN);
- return -1;
- }
-
- int err = ss_get_last_errno (sbr_get_conn (sk));
- if (SPL_ERR_IS_FATAL (err) || err == ERR_TIMEOUT) /* have to handle ERR_TIMEOUT here, when TCP keepalive timeout. */
- {
- NS_LOG_CTRL (LOG_CTRL_RECV_QUEUE_FULL, LOGSBR, "NSSBR",
- NSLOG_ERR, "connection fatal error!err=%d", err);
-
- /* l4_ring need to be handled in the future */
- if (1 == nsfw_mem_ring_dequeue (ring, buf))
- {
- pbuf_set_recycle_flg ((struct spl_pbuf *) *buf, pid);
- return 0;
- }
-
- sbr_set_sk_io_errno (sk, sbr_spl_err_to_errno (err));
- return -1;
- }
-
- if (0 > timeout)
- {
- sbr_set_sk_io_errno (sk, EWOULDBLOCK);
- return -1;
- }
-
- if (retry_count < FAST_RETRY_COUNT)
- {
- sys_sleep_ns (0, FAST_SLEEP_TIME);
- retry_count++;
- }
- else
- {
- sys_sleep_ns (0, sbr_get_fd_share (sk)->block_polling_time);
- }
-
- if (timeout > 0)
- {
- if (unlikely (0 != clock_gettime (CLOCK_MONOTONIC, &end)))
- {
- NSSBR_LOGERR ("Failed to get time, errno = %d", errno);
- }
- timediff_sec = end.tv_sec - start.tv_sec;
- if (timediff_sec >= timeout_sec)
- {
- timediff = end.tv_nsec > start.tv_nsec ?
- (timediff_sec * 1000) + (end.tv_nsec -
- start.tv_nsec) /
- USEC_TO_SEC : (timediff_sec * 1000) -
- ((start.tv_nsec - end.tv_nsec) / USEC_TO_SEC);
- if (timediff > timeout)
- {
- NSSBR_LOGDBG ("recv timeout]fd=%d", sk->fd);
- sbr_set_sk_io_errno (sk, EWOULDBLOCK);
- return -1;
- }
- }
- }
- }
- else
- {
- NSSBR_LOGERR ("dequeue failed]fd=%d", sk->fd);
- sbr_set_sk_io_errno (sk, EINVAL);
- return -1;
- }
- }
-}
-
-int
-sbr_com_peak (sbr_socket_t * sk)
-{
- NSSBR_LOGERR ("not implement]fd=%d", sk->fd);
- return -1;
-}
-
-/*****************************************************************************
-* Prototype : sbr_com_try_lock_recv
-* Description : try lock recv
-* Input : sbr_socket_t * sk
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_com_try_lock_recv (sbr_socket_t * sk)
-{
-#ifdef SBR_USE_LOCK
- return common_spinlock_try_lock_with_pid (&sbr_get_fd_share (sk)->recv_lock,
- get_sys_pid ());
-#else
- return 1;
-#endif
-}
-
-/*****************************************************************************
-* Prototype : sbr_com_lock_common
-* Description : lock common
-* Input : sbr_socket_t * sk
-* Output : None
-* Return Value : void
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-void
-sbr_com_lock_common (sbr_socket_t * sk)
-{
-#ifdef SBR_USE_LOCK
- while (!common_spinlock_try_lock_with_pid
- (&sbr_get_fd_share (sk)->common_lock, get_sys_pid ()))
- {
- sys_sleep_ns (0, 0);
- }
-#endif
-
-}
-
-void
-sbr_com_fork_parent (sbr_socket_t * sk, pid_t p)
-{
- i32 ref = ss_inc_fork_ref (sbr_get_conn (sk));
- NSSBR_LOGINF ("inc fork ref] fd=%d, p=%d, ref=%d, conn=%p, private_data=%p",
- sk->fd, p, ref, sbr_get_conn (sk),
- sbr_get_conn (sk)->private_data);
-}
-
-void
-sbr_com_fork_child (sbr_socket_t * sk, pid_t p, pid_t c)
-{
- if (ss_add_pid (sbr_get_conn (sk), c) != 0)
- {
- NSSBR_LOGERR
- ("add pid failed] fd=%d, p=%d, c=%d, ref=%d, conn=%p, private_data=%p",
- sk->fd, p, c, ss_get_fork_ref (sbr_get_conn (sk)), sbr_get_conn (sk),
- sbr_get_conn (sk)->private_data);
- }
- else
- {
- NSSBR_LOGINF
- ("add pid ok] fd=%d, p=%d, c=%d, ref=%d, conn=%p, private_data=%p",
- sk->fd, p, c, ss_get_fork_ref (sbr_get_conn (sk)), sbr_get_conn (sk),
- sbr_get_conn (sk)->private_data);
- }
-}
-
-/*****************************************************************************
-* Prototype : sbr_com_unlock_common
-* Description : unlock common
-* Input : sbr_socket_t * sk
-* Output : None
-* Return Value : void
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-void
-sbr_com_unlock_common (sbr_socket_t * sk)
-{
-#ifdef SBR_USE_LOCK
- common_spinlock_unlock (&sbr_get_fd_share (sk)->common_lock);
-#endif
-}
-
-/*****************************************************************************
-* Prototype : sbr_com_free_recv_buf
-* Description : free recv buf,can't free buf in app
-* Input : sbr_socket_t * sk
-* struct spl_pbuf *p
-* Output : None
-* Return Value : void
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-void
-sbr_com_free_recv_buf (sbr_socket_t * sk, struct spl_pbuf *p)
-{
- struct spl_pbuf *p_orig = p;
- if (p)
- {
- p->freeNext = NULL;
- p = (struct spl_pbuf *) ADDR_LTOSH (p);
-
- if (sbr_get_fd_share (sk)->recoder.totalLen > 0)
- {
- ((struct spl_pbuf *)
- ADDR_SHTOL (sbr_get_fd_share (sk)->recoder.tail))->freeNext = p;
- sbr_get_fd_share (sk)->recoder.tail = p;
- }
- else
- {
- sbr_get_fd_share (sk)->recoder.head = p;
- sbr_get_fd_share (sk)->recoder.tail = p;
- }
-
- sbr_get_fd_share (sk)->recoder.totalLen++;
- }
-
- /* send MSG only if it's a big packet or number of packets larger than 32 */
- if ((p_orig && p_orig->tot_len > MAX_RECV_FREE_LEN) ||
- (sbr_get_fd_share (sk)->recoder.totalLen >= MAX_RECV_FREE_BUF))
- {
- sbr_handle_free_recv_buf (sk);
- }
-
-}
-
-/*****************************************************************************
-* Prototype : sbr_get_sockaddr_and_len
-* Description : get addr and len
-* Input : u16 port
-* spl_ip_addr_t * ipaddr
-* struct sockaddr * addr
-* socklen_t * addrlen
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_get_sockaddr_and_len (u16 port, spl_ip_addr_t * ipaddr,
- struct sockaddr *addr, socklen_t * addrlen)
-{
- int ret;
- struct sockaddr_in sin;
-
- ret = MEMSET_S (&sin, sizeof (sin), 0, sizeof (sin));
- if (0 != ret)
- {
- NSSBR_LOGERR ("MEMSET_S failed]ret=%d.", ret);
- return -1;
- }
-
- sin.sin_family = AF_INET;
- sin.sin_port = htons (port);
- inet_addr_from_ipaddr (&sin.sin_addr, ipaddr);
- if (*addrlen > sizeof (struct sockaddr))
- {
- *addrlen = sizeof (struct sockaddr);
- }
-
- if (*addrlen > 0)
- {
- ret = MEMCPY_S (addr, sizeof (struct sockaddr), &sin, *addrlen);
- if (0 != ret)
- {
- NSSBR_LOGERR ("MEMCPY_S failed]ret=%d", ret);
-
- return -1;
- }
- }
-
- return 0;
-}
-
-/*****************************************************************************
-* Prototype : sbr_com_set_app_info
-* Description : set app info to netconn
-* Input : sbr_socket_t * sk
-* void* appinfo
-* Output : None
-* Return Value : void
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-void
-sbr_com_set_app_info (sbr_socket_t * sk, void *appinfo)
-{
- return;
-}
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_prot_com.h b/stacks/lwip_stack/lwip_src/socket/stackx_prot_com.h
deleted file mode 100644
index 1be44cb..0000000
--- a/stacks/lwip_stack/lwip_src/socket/stackx_prot_com.h
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef STACKX_PROT_COM_H
-#define STACKX_PROT_COM_H
-#include "stackx_socket.h"
-#include "stackx_ip_addr.h"
-#include "stackx_res_mgr.h"
-#include "stackx_pbuf.h"
-#include "stackx_macro.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-#define MAX_RECV_FREE_BUF 32
-#define MAX_RECV_FREE_LEN (SPL_FRAME_MTU - SPL_IP_HLEN)
-#define USEC_TO_SEC 1000000
-
-#ifndef NSTACK_SOCKOPT_CHECK
-#define NSTACK_SOCKOPT_CHECK
-/* setsockopt level type*/
-enum
-{
- NSTACK_SOCKOPT = 0xff02
-};
-/*setsockopt optname type*/
-enum
-{
- NSTACK_SEM_SLEEP = 0X001
-};
-#endif
-
-#define sbr_malloc_tx_pbuf(len, offset) sbr_malloc_pbuf(sbr_get_tx_pool(), len, TX_MBUF_MAX_LEN, offset)
-
-static inline int
-sbr_spl_err_to_errno (i32 err)
-{
- static int table[] = {
- 0, /* ERR_OK 0 No error, everything OK. */
- ENOMEM, /* ERR_MEM -1 Out of memory error. */
- ENOBUFS, /* ERR_BUF -2 Buffer error. */
- ETIMEDOUT, /* ERR_TIMEOUT -3 Timeout */
- EHOSTUNREACH, /* ERR_RTE -4 Routing problem. */
- EINPROGRESS, /* ERR_INPROGRESS -5 Operation in progress */
- EINVAL, /* ERR_VAL -6 Illegal value. */
- EWOULDBLOCK, /* ERR_WOULDBLOCK -7 Operation would block. */
- EADDRINUSE, /* ERR_USE -8 Address in use. */
- EISCONN, /* ERR_ISCONN -9 Already connected. */
- ECONNABORTED, /* ERR_ABRT -10 Connection aborted. */
- ECONNRESET, /* ERR_RST -11 Connection reset. */
- ENOTCONN, /* ERR_CLSD -12 Connection closed. */
- ENOTCONN, /* ERR_CONN -13 Not connected. */
- EIO, /* ERR_ARG -14 Illegal argument. */
- -1, /* ERR_IF -15 Low-level netif error */
- EALREADY, /*ERR_ALREADY -16 previous connect attemt has not yet completed */
- EPROTOTYPE, /*ERR_PROTOTYPE -17 prototype error or some other generic error.
- the operation is not allowed on current socket */
- EINVAL, /* ERR_CALLBACK -18 callback error */
- EADDRNOTAVAIL, /* ERR_CANTASSIGNADDR -19 Cannot assign requested address */
- EIO, /* ERR_CONTAINER_ID -20 Illegal container id */
- ENOTSOCK, /*ERR_NOTSOCK -21 not a socket */
- -1, /* ERR_CLOSE_WAIT -22 closed in established state */
- EPROTONOSUPPORT, /* ERR_EPROTONOSUPPORT -23 Protocol not supported */
- ECONNABORTED /* ERR_FAULTRECOVERY -24 SPL just recovered from a fatal fault */
- };
-
- if (((-(err)) >= 0)
- && (-(err)) < (i32) (sizeof (table) / sizeof (table[0])))
- {
- return table[-(err)];
- }
- else
- {
- return EIO;
- }
-}
-
-int sbr_getsockopt_sol_socket (sbr_socket_t * sk, int optname, void *optval,
- socklen_t optlen);
-int sbr_getsockopt_ipproto_ip (int optname, void *optval, socklen_t optlen);
-int sbr_setsockopt_sol_socket (sbr_socket_t * sk, int optname,
- const void *optval, socklen_t optlen,
- spl_netconn_type_t type);
-int sbr_setsockopt_ipproto_ip (int optname, const void *optval,
- socklen_t optlen, spl_netconn_type_t type);
-int sbr_dequeue_buf (sbr_socket_t * sk, void **buf, i32 timeout);
-int sbr_com_peak (sbr_socket_t * sk);
-int sbr_com_try_lock_recv (sbr_socket_t * sk);
-/*****************************************************************************
-* Prototype : sbr_com_lock_recv
-* Description : lock recv
-* Input : sbr_socket_t * sk
-* Output : None
-* Return Value : void
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline void
-sbr_com_lock_recv (sbr_socket_t * sk)
-{
-#ifdef SBR_USE_LOCK
- while (!common_spinlock_try_lock_with_pid
- (&sbr_get_fd_share (sk)->recv_lock, get_sys_pid ()))
- {
- sys_sleep_ns (0, 0);
- }
-#endif
-
-}
-
-/*****************************************************************************
-* Prototype : sbr_com_unlock_recv
-* Description : unlock recv
-* Input : sbr_socket_t * sk
-* Output : None
-* Return Value : void
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline void
-sbr_com_unlock_recv (sbr_socket_t * sk)
-{
-#ifdef SBR_USE_LOCK
- common_spinlock_unlock (&sbr_get_fd_share (sk)->recv_lock);
-#endif
-}
-
-void sbr_com_lock_common (sbr_socket_t * sk);
-void sbr_com_unlock_common (sbr_socket_t * sk);
-void sbr_com_free_recv_buf (sbr_socket_t * sk, struct spl_pbuf *p);
-int sbr_get_sockaddr_and_len (u16 port, spl_ip_addr_t * ip_addr,
- struct sockaddr *addr, socklen_t * addrlen);
-void sbr_com_set_app_info (sbr_socket_t * sk, void *appinfo);
-
-void sbr_com_fork_parent (sbr_socket_t * sk, pid_t p);
-void sbr_com_fork_child (sbr_socket_t * sk, pid_t p, pid_t c);
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_protocol_api.c b/stacks/lwip_stack/lwip_src/socket/stackx_protocol_api.c
deleted file mode 100644
index 0be8d7b..0000000
--- a/stacks/lwip_stack/lwip_src/socket/stackx_protocol_api.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "sbr_protocol_api.h"
-#include "stackx_epoll_api.h"
-#include "stackx_socket.h"
-#include "stackx_res_mgr.h"
-#include "stackx_common_opt.h"
-#include "common_mem_api.h"
-#include "stackx_event.h"
-
-extern sbr_fdopt tcp_fdopt;
-extern sbr_fdopt udp_fdopt;
-extern sbr_fdopt raw_fdopt;
-extern sbr_fdopt custom_fdopt;
-
-/*****************************************************************************
-* Prototype : sbr_init_protocol
-* Description : init protocol
-* Input : None
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_init_protocol ()
-{
- return sbr_init_stackx ();
-}
-
-/*****************************************************************************
-* Prototype : sbr_fork_protocol
-* Description : init protocol
-* Input : None
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_fork_protocol ()
-{
- pid_t pid = update_sys_pid ();
-
- NSSBR_LOGINF ("update pid in child]pid=%d", pid);
- return sbr_fork_stackx ();
-}
-
-/*****************************************************************************
-* Prototype : sbr_get_fdopt
-* Description : get fdopt by domain type protocol
-* Input : int domain
-* int type
-* int protocol
-* Output : None
-* Return Value : sbr_fdopt*
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-sbr_fdopt *
-sbr_get_fdopt (int domain, int type, int protocol)
-{
- if (domain != AF_INET)
- {
- NSSBR_LOGERR ("domain is not AF_INET]domain=%d", domain);
- sbr_set_errno (EAFNOSUPPORT);
- return NULL;
- }
-
- sbr_fdopt *fdopt = NULL;
-
- switch (type & (~(O_NONBLOCK | SOCK_CLOEXEC)))
- {
- case SOCK_DGRAM:
- fdopt = &udp_fdopt;
- break;
- case SOCK_STREAM:
- fdopt = &tcp_fdopt;
- break;
-
- default:
- NSSBR_LOGDBG ("type is unknown]type=%d", type);
- sbr_set_errno (ESOCKTNOSUPPORT);
- return NULL;
- }
-
- return fdopt;
-}
-
-/* app send its version info to nStackMain */
-extern void sbr_handle_app_touch (void);
-void
-sbr_app_touch_in (void)
-{
- sbr_handle_app_touch ();
-}
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_res_mgr.c b/stacks/lwip_stack/lwip_src/socket/stackx_res_mgr.c
deleted file mode 100644
index f3cb5b5..0000000
--- a/stacks/lwip_stack/lwip_src/socket/stackx_res_mgr.c
+++ /dev/null
@@ -1,279 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "stackx_res_mgr.h"
-#include "stackx_common.h"
-#include "nstack_securec.h"
-#include "nsfw_msg.h"
-#include "stackx_common.h"
-#include "nsfw_mgr_com_api.h"
-#include "stackx_cfg.h"
-#include "nsfw_maintain_api.h"
-//#include "stackx_dfx_api.h"
-#include "stackx_app_res.h"
-
-sbr_share_group g_share_group = { 0 };
-
-#define SLOW_SLEEP_TIME 500000
-
-NSTACK_STATIC inline void
-sbr_reset_fd_share (sbr_fd_share * fd_share)
-{
- common_mem_spinlock_init (&fd_share->recv_lock);
- common_mem_spinlock_init (&fd_share->common_lock);
- fd_share->err = 0;
- fd_share->lastoffset = 0;
- fd_share->lastdata = NULL;
- fd_share->recoder.head = NULL;
- fd_share->recoder.tail = NULL;
- fd_share->recoder.totalLen = 0;
- fd_share->recv_timeout = 0;
- fd_share->send_timeout = 0;
- fd_share->rcvlowat = 1;
- fd_share->block_polling_time = SLOW_SLEEP_TIME;
-}
-
-/*****************************************************************************
-* Prototype : sbr_init_tx_pool
-* Description : get tx buf pool
-* Input : None
-* Output : None
-* Return Value : static int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-NSTACK_STATIC int
-sbr_init_tx_pool ()
-{
- mpool_handle pool[1];
- pool[0] = NULL;
-
- (void) sbr_malloc_tx_pool (get_sys_pid (), pool, 1);
- if (pool[0])
- {
- g_share_group.tx_pool = pool[0];
- return 0;
- }
-
- return -1;
-}
-
-/*****************************************************************************
-* Prototype : sbr_init_app_res
-* Description : get msg, conn pool
-* Input : None
-* Output : None
-* Return Value : static int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-NSTACK_STATIC int
-sbr_init_app_res ()
-{
- g_share_group.conn_pool = sbr_get_instance_conn_pool (0);
- if (!g_share_group.conn_pool)
- {
- return -1;
- }
-
- return 0;
-}
-
-/*=========== get share config for app =============*/
-NSTACK_STATIC inline int
-get_share_config ()
-{
- static nsfw_mem_name g_cfg_mem_info =
- { NSFW_SHMEM, NSFW_PROC_MAIN, NSTACK_SHARE_CONFIG };
-
- mzone_handle base_cfg_mem = nsfw_mem_zone_lookup (&g_cfg_mem_info);
- if (NULL == base_cfg_mem)
- {
- NSSOC_LOGERR ("get config share mem failed.");
- return -1;
- }
-
- if (get_share_cfg_from_mem (base_cfg_mem) < 0)
- {
- NSSOC_LOGERR ("get share config failed.");
- return -1;
- }
-
- NSSOC_LOGDBG ("get share config success.");
- return 0;
-}
-
-int
-nstack_set_share_config ()
-{
- return 0;
-}
-
-/*****************************************************************************
-* Prototype : sbr_init_stackx
-* Description : init stackx res
-* Input : None
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_init_stackx ()
-{
- sbr_init_cfg ();
- if (get_share_config () < 0)
- {
- NSSBR_LOGERR ("get_share_config failed");
- return -1;
- }
-
- if (sbr_attach_group_array () != 0)
- {
- NSSBR_LOGERR ("sbr_attach_group_array failed");
- return -1;
- }
-
- NSSBR_LOGDBG ("sbr_attach_group_array ok");
-
- if (sbr_init_tx_pool () != 0)
- {
- NSSBR_LOGERR ("init tx pool failed");
- return -1;
- }
-
- NSSBR_LOGDBG ("init tx pool ok");
-
- if (sbr_init_app_res () != 0)
- {
- NSSBR_LOGERR ("sbr_init_app_res failed");
- return -1;
- }
-
- NSSBR_LOGDBG ("sbr_init_app_res ok");
- NSSBR_LOGDBG ("sbr_init_stackx ok");
- return 0;
-}
-
-/*****************************************************************************
-* Prototype : sbr_fork_stackx
-* Description : init stackx res
-* Input : None
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_fork_stackx ()
-{
-
- if (sbr_attach_group_array () != 0)
- {
- NSSBR_LOGERR ("sbr_attach_group_array failed");
- return -1;
- }
-
- NSSBR_LOGDBG ("sbr_attach_group_array ok");
-
- if (sbr_init_tx_pool () != 0)
- {
- NSSBR_LOGERR ("init tx pool failed");
- return -1;
- }
-
- NSSBR_LOGDBG ("init tx pool ok");
- NSSBR_LOGDBG ("sbr_fork_stackx ok");
- return 0;
-}
-
-/*****************************************************************************
-* Prototype : sbr_malloc_conn_for_sk
-* Description : malloc netconn for sk,need add pid
-* Input : sbr_socket_t* sk
-* netconn_type_t type
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_malloc_conn_for_sk (sbr_socket_t * sk, spl_netconn_type_t type)
-{
- spl_netconn_t *conn = ss_malloc_conn_app (g_share_group.conn_pool, type);
-
- if (!conn)
- {
- NSSBR_LOGERR ("malloc conn failed]fd=%d", sk->fd);
- sbr_set_errno (ENOBUFS);
- return -1;
- }
-
- NSSBR_LOGINF ("malloc conn ok]fd=%d,conn=%p", sk->fd, conn);
-
- u16 thread_index = 0;
- ss_set_bind_thread_index (conn, thread_index);
- ss_set_msg_box (conn, ss_get_instance_msg_box (thread_index, 0));
-
- sbr_fd_share *fd_share = (sbr_fd_share *) ((char *) conn + SS_NETCONN_SIZE);
- sbr_reset_fd_share (fd_share);
-
- sk->stack_obj = (void *) conn;
- sk->sk_obj = (void *) fd_share;
- return 0;
-}
-
-int
-sbr_init_conn_for_accept (sbr_socket_t * sk, spl_netconn_t * conn)
-{
- if (!conn)
- {
- sbr_set_sk_errno (sk, ENOBUFS);
- return -1;
- }
-
- NSSBR_LOGINF ("accept conn ok]fd=%d,conn=%p,private_data=%p", sk->fd, conn,
- conn->private_data);
-
- if (ss_add_pid (conn, get_sys_pid ()) < 0)
- {
- NSSBR_LOGERR ("ss_add_pid failed]fd=%d", sk->fd);
- }
-
- ss_set_accept_from (conn, NULL); /* need clear flag */
-
- sbr_fd_share *fd_share = (sbr_fd_share *) ((char *) conn + SS_NETCONN_SIZE);
- sbr_reset_fd_share (fd_share);
-
- sk->stack_obj = (void *) conn;
- sk->sk_obj = (void *) fd_share;
-
- return 0;
-}
-
-void
-sbr_free_conn_from_sk (sbr_socket_t * sk)
-{
- ss_free_conn (sbr_get_conn (sk));
- sk->stack_obj = NULL;
- sk->sk_obj = NULL;
- NSSBR_LOGDBG ("free conn ok]fd=%d", sk->fd);
-}
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_res_mgr.h b/stacks/lwip_stack/lwip_src/socket/stackx_res_mgr.h
deleted file mode 100644
index 73cec7f..0000000
--- a/stacks/lwip_stack/lwip_src/socket/stackx_res_mgr.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef STACKX_RES_MGR_H
-#define STACKX_RES_MGR_H
-#include "stackx_socket.h"
-#include "stackx_ip_tos.h"
-#include "stackx_tx_box.h"
-#include "stackx_app_res.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-typedef struct
-{
- mring_handle conn_pool;
- mpool_handle tx_pool;
-} sbr_share_group;
-
-extern sbr_share_group g_share_group;
-
-static inline mpool_handle
-sbr_get_tx_pool ()
-{
- return g_share_group.tx_pool;
-}
-
-static inline mring_handle
-sbr_get_conn_pool ()
-{
- return (mring_handle) ADDR_LTOSH (g_share_group.conn_pool);
-}
-
-static inline mring_handle
-sbr_get_spl_msg_box (sbr_socket_t * sk, u8 tos)
-{
- return
- ss_get_instance_msg_box (ss_get_bind_thread_index (sbr_get_conn (sk)),
- stackx_get_prio (tos));
-}
-
-int sbr_init_stackx ();
-int sbr_fork_stackx ();
-int sbr_malloc_conn_for_sk (sbr_socket_t * sk, spl_netconn_type_t type);
-int sbr_init_conn_for_accept (sbr_socket_t * sk, spl_netconn_t * conn);
-void sbr_free_conn_from_sk (sbr_socket_t * sk);
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_socket.h b/stacks/lwip_stack/lwip_src/socket/stackx_socket.h
deleted file mode 100644
index e344535..0000000
--- a/stacks/lwip_stack/lwip_src/socket/stackx_socket.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef STACKX_SOCKET_H
-#define STACKX_SOCKET_H
-#include "sbr_protocol_api.h"
-#include "stackx_spl_share.h"
-#include "nstack_log.h"
-#include "stackx_pbuf.h"
-#include "common_mem_spinlock.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-typedef struct
-{
- PRIMARY_ADDR struct spl_pbuf *head;
- PRIMARY_ADDR struct spl_pbuf *tail;
- int totalLen;
-} sbr_recvbuf_recoder;
-
-/* need fork and recycle */
-typedef struct
-{
- common_mem_spinlock_t recv_lock;
- common_mem_spinlock_t common_lock;
- PRIMARY_ADDR void *lastdata;
- u32 lastoffset;
- sbr_recvbuf_recoder recoder;
- i32 recv_timeout;
- i32 send_timeout;
- i32 rcvlowat;
- int err;
- u64 block_polling_time;
- i64 extend_member_bit;
-} sbr_fd_share;
-
-/* check sbr_fd_share size */
-SIZE_OF_TYPE_NOT_LARGER_THAN (sbr_fd_share, SBR_FD_SIZE);
-
-#define sbr_get_fd_share(sk) ((sbr_fd_share*)sk->sk_obj)
-
-#define sbr_get_conn(sk) ((spl_netconn_t*)sk->stack_obj)
-
-#define sbr_get_msg_box(sk) ss_get_msg_box(sbr_get_conn(sk))
-
-/*****************************************************************************
-* Prototype : sbr_set_sk_errno
-* Description : set errno for sk
-* Input : sbr_socket_t * sk
-* int err
-* Output : None
-* Return Value : static inline void
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline void
-sbr_set_sk_errno (sbr_socket_t * sk, int err)
-{
- sbr_get_fd_share (sk)->err = err;
- if (err != 0)
- {
- if (sbr_get_conn (sk))
- {
- NSSBR_LOGERR ("fd=%d,errno=%d,conn=%p,private_data=%p", sk->fd, err,
- sbr_get_conn (sk),
- ss_get_private_data (sbr_get_conn (sk)));
- }
-
- sbr_set_errno (err);
- }
-}
-
-/*****************************************************************************
-* Prototype : sbr_set_sk_io_errno
-* Description : set errno for sk in send/recv func, in case of too many logs
-* Input : sbr_socket_t * sk
-* int err
-* Output : None
-* Return Value : static inline void
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline void
-sbr_set_sk_io_errno (sbr_socket_t * sk, int err)
-{
- sbr_get_fd_share (sk)->err = err;
- if (err != 0)
- {
- if (sbr_get_conn (sk))
- {
- NSSBR_LOGDBG ("fd=%d,errno=%d,conn=%p,private_data=%p", sk->fd, err,
- sbr_get_conn (sk),
- ss_get_private_data (sbr_get_conn (sk)));
- }
-
- sbr_set_errno (err);
- }
-}
-
-/*****************************************************************************
-* Prototype : sbr_get_sk_errno
-* Description : get sk's errno
-* Input : sbr_socket_t * sk
-* Output : None
-* Return Value : static inline int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline int
-sbr_get_sk_errno (sbr_socket_t * sk)
-{
- return sbr_get_fd_share (sk)->err;
-}
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_tcp.c b/stacks/lwip_stack/lwip_src/socket/stackx_tcp.c
deleted file mode 100644
index a410a4f..0000000
--- a/stacks/lwip_stack/lwip_src/socket/stackx_tcp.c
+++ /dev/null
@@ -1,1691 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "stackx_prot_com.h"
-#include "stackx_msg_handler.h"
-#include "stackx_pbuf.h"
-#include "stackx_epoll_api.h"
-#include "nstack_securec.h"
-#include "common_pal_bitwide_adjust.h"
-#include "common_mem_mbuf.h"
-#include "stackx_spl_share.h"
-#include "stackx_err.h"
-#include "stackx_cfg.h"
-#include "spl_opt.h"
-//#include "stackx_tcp_sctl.h"
-#include "stackx_tcp_opt.h"
-//#include "stackx_dfx_api.h"
-#include "stackx_spl_msg.h"
-#ifdef HAL_LIB
-#else
-#include "rte_memcpy.h"
-#endif
-
-static void
-sbr_tcp_init_conn (spl_netconn_t * conn)
-{
- conn->tcp_sndbuf = CONN_TCP_MEM_DEF_LINE;
- conn->conn_pool = sbr_get_conn_pool ();
-}
-
-/* need close after accept failed */
-static void
-sbr_tcp_accept_failed (sbr_socket_t * sk)
-{
- (void) sbr_handle_close (sk, 0);
- sk->stack_obj = NULL;
- sk->sk_obj = NULL;
-}
-
-NSTACK_STATIC int
-sbr_tcp_socket (sbr_socket_t * sk, int domain, int type, int protocol)
-{
- int err = 0;
-
- if (sbr_malloc_conn_for_sk (sk, SPL_NETCONN_TCP) != 0)
- {
- return -1;
- }
-
- sbr_tcp_init_conn (sbr_get_conn (sk));
-
- err = sbr_handle_socket (sk, SPL_NETCONN_TCP, 0);
- if (0 == err)
- {
- /* Prevent automatic window updates, we do this on our own! */
- ss_set_noautorecved_flag (sbr_get_conn (sk), 1);
-
- ss_set_nonblock_flag (sbr_get_conn (sk), (type & O_NONBLOCK));
-
- ss_add_recv_event (sbr_get_conn (sk));
-
- ss_set_send_event (sbr_get_conn (sk), 1);
-
- NSSBR_LOGINF ("add write and read events]fd=%d", sk->fd);
-
- return 0;
- }
- else
- {
- sbr_free_conn_from_sk (sk);
- return err;
- }
-}
-
-NSTACK_STATIC int
-sbr_tcp_bind (sbr_socket_t * sk, const struct sockaddr *name,
- socklen_t namelen)
-{
- const struct sockaddr_in *addr_in = (const struct sockaddr_in *) name;
- NSSBR_LOGINF ("fd=%d,addr=%s,port=%d,conn=%p,private_data=%p", sk->fd,
- spl_inet_ntoa (addr_in->sin_addr), ntohs (addr_in->sin_port),
- sbr_get_conn (sk), ss_get_private_data (sbr_get_conn (sk)));
- spl_ip_addr_t local_addr;
- inet_addr_to_ipaddr (&local_addr, &addr_in->sin_addr);
- u16 local_port = addr_in->sin_port;
- return sbr_handle_bind (sk, &local_addr, ntohs (local_port));
-}
-
-NSTACK_STATIC int
-sbr_tcp_listen (sbr_socket_t * sk, int backlog)
-{
- ss_set_is_listen_conn (sbr_get_conn (sk), 1);
- return sbr_handle_listen (sk, backlog);
-}
-
-static inline int
-sbr_tcp_recv_is_timeout (sbr_socket_t * sk, struct timespec *starttm)
-{
- struct timespec currtm;
- i64 timediff_ms, timediff_sec;
- i64 timeout_thr_ms, timeout_thr_sec;
-
- timeout_thr_ms = sbr_get_fd_share (sk)->recv_timeout;
- if (0 == timeout_thr_ms)
- {
- return ERR_OK;
- }
-
- timeout_thr_sec = (i64) (timeout_thr_ms / 1000);
-
- /* Handle system time change side-effects */
- if (unlikely (0 != clock_gettime (CLOCK_MONOTONIC, &currtm)))
- {
- NSSBR_LOGERR ("Failed to get time, errno = %d", errno);
- }
-
- timediff_sec = currtm.tv_sec - starttm->tv_sec;
- if (timediff_sec >= timeout_thr_sec)
- {
- timediff_ms = currtm.tv_nsec > starttm->tv_nsec ?
- (timediff_sec * 1000) + (currtm.tv_nsec -
- starttm->tv_nsec) /
- USEC_TO_SEC : (timediff_sec * 1000) -
- ((starttm->tv_nsec - currtm.tv_nsec) / USEC_TO_SEC);
-
- /*NOTE: if user configured the timeout as say 0.5 ms, then timediff value
- will be negetive if still 0.5 ms is not elapsed. this is intended and we should
- not typecast to any unsigned type during this below if check */
- if (timediff_ms > timeout_thr_ms)
- {
- sbr_set_sk_errno (sk, ETIMEDOUT);
- return ETIMEDOUT;
- }
- }
-
- return ERR_OK;
-}
-
-static inline int
-sbr_tcp_wait_new_conn (sbr_socket_t * sk, void **new_buf)
-{
- int ret = 0;
- int elem_num;
- u32 timeout_thr_sec;
- struct timespec starttm = { 0, 0 };
- unsigned int retry_count = 0;
- mring_handle ring = NULL;
-
-#define FAST_SLEEP_TIME 10000
-#define SLOW_SLEEP_TIME 500000
-#define FAST_RETRY_COUNT 100
-
- ring = ss_get_recv_ring (sbr_get_conn (sk)); //clear codeDEX warning , CID:24284
- timeout_thr_sec = sbr_get_fd_share (sk)->recv_timeout / 1000;
- if (0 != timeout_thr_sec)
- {
- if (unlikely (0 != clock_gettime (CLOCK_MONOTONIC, &starttm)))
- {
- NSSBR_LOGERR ("Failed to get time, errno = %d", errno);
- }
- }
-
- while (1)
- {
- if (ss_is_shut_rd (sbr_get_conn (sk)))
- {
- sbr_set_sk_errno (sk, EINVAL);
- ret = EINVAL;
- break;
- }
-
- elem_num = nsfw_mem_ring_dequeue (ring, new_buf);
- if (1 == elem_num)
- {
- break;
- }
- else if (0 == elem_num)
- {
- ret = sbr_tcp_recv_is_timeout (sk, &starttm);
- if (0 != ret)
- {
- break;
- }
-
- /* reduce CPU usage in blocking mode- Begin */
- if (retry_count < FAST_RETRY_COUNT)
- {
- sys_sleep_ns (0, FAST_SLEEP_TIME);
- retry_count++;
- }
- else
- {
- sys_sleep_ns (0, sbr_get_fd_share (sk)->block_polling_time);
- }
-
- continue;
- }
- else
- {
- sbr_set_sk_errno (sk, EINVAL);
- ret = EINVAL;
- break;
- }
- }
-
- return ret;
-}
-
-NSTACK_STATIC inline int
-sbr_tcp_get_sockaddr (sbr_socket_t * sk, struct sockaddr *addr,
- socklen_t * addrlen)
-{
- int ret;
- spl_netconn_t *conn = sbr_get_conn (sk);
-
- ret = (addr
- && addrlen) ? sbr_get_sockaddr_and_len (ss_get_remote_port (conn),
- ss_get_remote_ip (conn),
- addr, addrlen) : 0;
- if (0 != ret)
- {
- sbr_set_sk_io_errno (sk, EINVAL);
- NSSBR_LOGERR ("sbr_tcp_get_sockaddr]fd=%d", sk->fd);
- return -1;
- }
-
- return 0;
-}
-
-static int
-sbr_tcp_accept_socket (sbr_socket_t * sk, sbr_socket_t * new_sk,
- struct sockaddr *addr, socklen_t * addrlen)
-{
- int err;
- spl_netconn_t *newconn = NULL;
-
- err = sbr_tcp_wait_new_conn (sk, (void **) &newconn);
- if (ERR_OK != err)
- {
- return err;
- }
-
- err = sbr_init_conn_for_accept (new_sk, newconn);
- if (ERR_OK != err)
- {
- /*When conn is null, return err; then do not need to free conn */
- return err;
- }
-
- err = sbr_tcp_get_sockaddr (new_sk, addr, addrlen);
- if (ERR_OK != err)
- {
- NSSBR_LOGERR ("sbr_get_sockaddr_and_socklen]ret=%d.", err);
- sbr_tcp_accept_failed (new_sk);
- return -1;
- }
-
- NSSBR_LOGINF
- ("return]listen fd=%d,listen conn=%p,listen private_data=%p,accept fd=%d,accept conn=%p,accept private_data=%p",
- sk->fd, sbr_get_conn (sk), ss_get_private_data (sbr_get_conn (sk)),
- new_sk->fd, sbr_get_conn (new_sk),
- ss_get_private_data (sbr_get_conn (new_sk)));
-
- //ip_addr_info_print(SOCKETS_DEBUG, &sbr_get_conn(new_sk)->share_remote_ip);
-
- /* test_epollCtl_003_001: Accept a conn. Add epoll_ctl with IN event and
- send a msg from peer. The event will be given once epoll_wait is called.
- Now, modify to IN|OUT. Calling epoll_event should return immediately since
- the socket is writable. Currently, returns 0 events.
- This issue is fixed here
- */
-
- /* Prevent automatic window updates, we do this on our own! */
- ss_set_noautorecved_flag (sbr_get_conn (new_sk), 1);
-
- ss_set_send_event (sbr_get_conn (new_sk), 1);
-
- /* don't set conn->last_err: it's only ERR_OK, anyway */
- return ERR_OK;
-}
-
-NSTACK_STATIC int
-sbr_tcp_accept (sbr_socket_t * sk, sbr_socket_t * new_sk,
- struct sockaddr *addr, socklen_t * addrlen)
-{
- int err;
-
- /* If conn is not in listen state then return failure with error code: EINVAL(22) */
- if (!ss_is_listen_state (sbr_get_conn (sk)))
- {
- NSSBR_LOGERR ("fd is not listening for connections]fd=%d,err=%d",
- sk->fd, EINVAL);
- sbr_set_sk_errno (sk, EINVAL);
-
- return -1;
- }
-
- if (ss_is_nonblock_flag (sbr_get_conn (sk))
- && (0 >= ss_get_recv_event (sbr_get_conn (sk))))
- {
- NSSBR_LOGERR ("fd is nonblocking and rcvevent<=0]fd=%d,err=%d", sk->fd,
- EWOULDBLOCK);
- sbr_set_sk_errno (sk, EWOULDBLOCK);
-
- return -1;
- }
-
- err = ss_get_last_errno (sbr_get_conn (sk));
- if (SPL_ERR_IS_FATAL (err))
- {
- /* don't recv on fatal errors: this might block the application task
- waiting on acceptmbox forever! */
- sbr_set_sk_errno (sk, sbr_spl_err_to_errno (err));
-
- return -1;
- }
-
- /* wait for a new connection */
- err = sbr_tcp_accept_socket (sk, new_sk, addr, addrlen);
- if (ERR_OK != err)
- {
- NSSBR_LOGERR ("sbr_tcp_accept_socket failed]fd=%d,err=%d", sk->fd, err);
-
- return -1;
- }
-
- /* Prevent automatic window updates, we do this on our own! */
- ss_sub_recv_event (sbr_get_conn (sk));
-
- sbr_set_sk_errno (sk, ERR_OK);
-
- /* test_epollCtl_003_001: Accept a conn. Add epoll_ctl with IN event and
- send a msg from peer. The event will be given once epoll_wait is called.
- Now, modify to IN|OUT. Calling epoll_event should return immediately since
- the socket is writable. Currently, returns 0 events.
- This issue is fixed here
- */
-
- ss_set_send_event (sbr_get_conn (new_sk), 1);
-
- return new_sk->fd;
-}
-
-NSTACK_STATIC int
-sbr_tcp_accept4 (sbr_socket_t * sk, sbr_socket_t * new_sk,
- struct sockaddr *addr, socklen_t * addrlen, int flags)
-{
- int fd = sbr_tcp_accept (sk, new_sk, addr, addrlen);
-
- if (0 > fd)
- {
- return fd;
- }
-
- if (flags & O_NONBLOCK)
- {
- int opts = new_sk->fdopt->fcntl (new_sk, F_GETFL, 0);
- if (opts < 0)
- {
- NSSBR_LOGERR ("sbr_tcp_fcntl(sock,GETFL)");
- sbr_tcp_accept_failed (new_sk);
- return -1;
- }
-
- opts = opts | O_NONBLOCK;
-
- if (new_sk->fdopt->fcntl (new_sk, F_SETFL, opts) < 0)
-
- {
- NSSBR_LOGERR ("sbr_tcp_fcntl(sock,F_SETFL,opts)");
- sbr_tcp_accept_failed (new_sk);
- return -1;
- }
- }
-
- return new_sk->fd;
-}
-
-NSTACK_STATIC int
-sbr_tcp_connect (sbr_socket_t * sk, const struct sockaddr *name,
- socklen_t namelen)
-{
- const struct sockaddr_in *addr_in = (const struct sockaddr_in *) name;
-
- NSSBR_LOGINF ("fd=%d,addr=%s,port=%d,conn=%p,private_data=%p", sk->fd,
- spl_inet_ntoa (addr_in->sin_addr), ntohs (addr_in->sin_port),
- sbr_get_conn (sk), ss_get_private_data (sbr_get_conn (sk)));
- spl_ip_addr_t remote_addr;
-
- inet_addr_to_ipaddr (&remote_addr, &addr_in->sin_addr);
- u16 remote_port = addr_in->sin_port;
-
- spl_ip_addr_t local_addr = { IPADDR_ANY };
-
- if (sbr_handle_connect (sk, &remote_addr, ntohs (remote_port), &local_addr)
- != 0)
- {
- NSSBR_LOGERR ("fail]fd=%d", sk->fd);
- return -1;
- }
-
- if (ss_is_shut_rd (sbr_get_conn (sk)))
- {
- NSSBR_LOGERR ("shut_rd]fd=%d", sk->fd);
- sbr_set_sk_errno (sk, ECONNRESET);
- return -1;
- }
-
- NSSBR_LOGINF ("succeeded]fd=%d", sk->fd);
- sbr_set_sk_errno (sk, ERR_OK);
-
- return 0;
-}
-
-static u8 netconn_shutdown_opt[] = {
- SPL_NETCONN_SHUT_RD,
- SPL_NETCONN_SHUT_WR,
- SPL_NETCONN_SHUT_RDWR
-};
-
-NSTACK_STATIC int
-sbr_tcp_shutdown (sbr_socket_t * sk, int how)
-{
- err_t err;
-
- if (ss_is_listen_state (sbr_get_conn (sk)))
- {
- return 0;
- }
-
- ss_set_shut_status (sbr_get_conn (sk), how);
-
- err = sbr_handle_shutdown (sk, netconn_shutdown_opt[how]);
-
- return (err == ERR_OK ? 0 : -1);
-}
-
-NSTACK_STATIC int
-sbr_tcp_getsockname (sbr_socket_t * sk, struct sockaddr *name,
- socklen_t * namelen)
-{
-
- NSSBR_LOGINF ("sockname]fd=%d,tcp_state=%d", sk->fd,
- ss_get_tcp_state (sbr_get_conn (sk)));
-
- return sbr_handle_get_name (sk, name, namelen, SBR_GET_SOCK_NAME);
-}
-
-NSTACK_STATIC int
-sbr_tcp_getpeername (sbr_socket_t * sk, struct sockaddr *name,
- socklen_t * namelen)
-{
-
- if (SPL_CLOSED == ss_get_tcp_state (sbr_get_conn (sk)))
- {
- NSSBR_LOGERR ("connection not exist]fd=%d", sk->fd);
- sbr_set_sk_errno (sk, ENOTCONN);
- return -1;
- }
-
- NSSBR_LOGINF ("peername]fd=%d,tcp_state=%d", sk->fd,
- ss_get_tcp_state (sbr_get_conn (sk)));
-
- return sbr_handle_get_name (sk, name, namelen, SBR_GET_PEER_NAME);
-}
-
-static int
-sbr_getsockopt_ipproto_tcp (int optname, void *optval, socklen_t optlen)
-{
- int err = ERR_OK;
-
- switch (optname)
- {
- case SPL_TCP_NODELAY:
- break;
- case SPL_TCP_KEEPIDLE:
- case SPL_TCP_KEEPINTVL:
- case SPL_TCP_KEEPCNT:
- case SPL_TCP_INFO:
- break;
- default:
- err = ENOPROTOOPT;
- break;
- }
-
- return err;
-}
-
-NSTACK_STATIC int inline
-sbr_tcp_set_sockopt_err (sbr_socket_t * sk, int err)
-{
- if (ENOPROTOOPT == err)
- {
- return 0;
- }
- else
- {
- sbr_set_sk_errno (sk, err);
- return -1;
- }
-}
-
-NSTACK_STATIC int inline
-sbr_tcp_get_sockopt_err (sbr_socket_t * sk, int err)
-{
- sbr_set_sk_errno (sk, err);
- return -1;
-}
-
-NSTACK_STATIC int
-sbr_tcp_getsockopt (sbr_socket_t * sk, int level, int optname, void *optval,
- socklen_t * optlen)
-{
- int err = 0;
-
- switch (level)
- {
- case SOL_SOCKET:
- err = sbr_getsockopt_sol_socket (sk, optname, optval, *optlen);
- break;
-
- case IPPROTO_IP:
- err = sbr_getsockopt_ipproto_ip (optname, optval, *optlen);
- break;
-
- case IPPROTO_TCP:
- err = sbr_getsockopt_ipproto_tcp (optname, optval, *optlen);
- break;
-
- case NSTACK_SOCKOPT:
- if ((optname == NSTACK_SEM_SLEEP) || (*optlen < sizeof (u32_t)))
- {
- *(u32_t *) optval =
- sbr_get_fd_share (sk)->block_polling_time / 1000;
- NSSOC_LOGINF
- ("tcp get recv sleep time success, usleep time = %d,fd = %d",
- sbr_get_fd_share (sk)->block_polling_time, sk->fd);
- return ERR_OK;
- }
- else
- {
- NSSOC_LOGINF ("get recv sleep time failed, fd = %d", sk->fd);
- sbr_set_sk_io_errno (sk, EINVAL);
- return -1;
- }
- default:
- err = ENOPROTOOPT;
- break;
- }
-
- if (0 != err)
- {
- NSSBR_LOGERR ("fail]fd=%d,level=%d,optname=%d,err=%d", sk->fd, level,
- optname, err);
- /* for option not support ,getsockopt() should return fail */
- return sbr_tcp_get_sockopt_err (sk, err);
- }
-
- return sbr_handle_getsockopt (sk, level, optname, optval, optlen);
-}
-
-int
-sbr_setsockopt_ipproto_tcp (int optname, socklen_t optlen)
-{
- int err = 0;
-
- if (optlen < sizeof (int))
- {
- return EINVAL;
- }
-
- switch (optname)
- {
- case SPL_TCP_NODELAY:
- case SPL_TCP_KEEPIDLE:
- case SPL_TCP_KEEPINTVL:
- case SPL_TCP_KEEPCNT:
- break;
- default:
- err = ENOPROTOOPT;
- break;
- }
-
- return err;
-}
-
-NSTACK_STATIC int
-sbr_tcp_setsockopt (sbr_socket_t * sk, int level, int optname,
- const void *optval, socklen_t optlen)
-{
- int err = 0;
-
- switch (level)
- {
- case SOL_SOCKET:
- err =
- sbr_setsockopt_sol_socket (sk, optname, optval, optlen,
- SPL_NETCONN_TCP);
- break;
- case IPPROTO_IP:
- err =
- sbr_setsockopt_ipproto_ip (optname, optval, optlen, SPL_NETCONN_TCP);
- break;
- case IPPROTO_TCP:
- err = sbr_setsockopt_ipproto_tcp (optname, optlen);
- break;
- case NSTACK_SOCKOPT:
- {
- u32_t sleep_time = *(u32_t *) optval;
- /*sleep time should less than 1s */
- if ((optname == NSTACK_SEM_SLEEP) && (optlen >= sizeof (u32_t))
- && (sleep_time < 1000000))
- {
- sbr_get_fd_share (sk)->block_polling_time = sleep_time * 1000;
- NSSOC_LOGINF
- ("tcp set recv sleep time success, usleep time = %d,fd = %d",
- sbr_get_fd_share (sk)->block_polling_time, sk->fd);
- return ERR_OK;
- }
- else
- {
- NSSOC_LOGINF ("set recv sleep time failed, fd = %d", sk->fd);
- sbr_set_sk_io_errno (sk, EINVAL);
- return -1;
- }
- }
-
- default:
- err = ENOPROTOOPT;
- break;
- }
-
- if (0 != err)
- {
- NSSBR_LOGERR ("fail]fd=%d,level=%d,optname=%d,err=%d", sk->fd, level,
- optname, err);
-
- return sbr_tcp_set_sockopt_err (sk, err);
- }
-
- return sbr_handle_setsockopt (sk, level, optname, optval, optlen);
-}
-
-static inline u16
-sbr_tcp_mbuf_count (struct spl_pbuf *p)
-{
- u16 count = 0;
- struct spl_pbuf *buf = p;
- struct common_mem_mbuf *mbuf;
-
- while (buf)
- {
- mbuf =
- (struct common_mem_mbuf *) ((char *) buf -
- sizeof (struct common_mem_mbuf));
- while (mbuf)
- {
- count++;
-#ifdef HAL_LIB
-#else
- mbuf = mbuf->next;
-#endif
- }
-
- buf = (struct spl_pbuf *) ADDR_SHTOL (buf->next_a);
- }
-
- return count;
-}
-
-static inline void
-sbr_tcp_free_recvbuf (sbr_socket_t * sk, struct spl_pbuf *p)
-{
- int len;
-
- if (ss_is_noautorecved_flag (sbr_get_conn (sk)))
- {
- len = sbr_tcp_mbuf_count (p);
- sbr_handle_tcp_recv (sk, len, p);
- }
-}
-
-static inline void
-sbr_tcp_recv_no_peak (sbr_socket_t * sk, struct spl_pbuf *buf, u32 buflen,
- u32 copylen)
-{
- if ((buflen - copylen) > 0)
- {
- sbr_get_fd_share (sk)->lastdata = (void *) ADDR_LTOSH (buf);
- sbr_get_fd_share (sk)->lastoffset += copylen;
- }
- else
- {
- sbr_get_fd_share (sk)->lastdata = 0;
- sbr_get_fd_share (sk)->lastoffset = 0;
- sbr_tcp_free_recvbuf (sk, buf);
- }
-}
-
-static inline int
-sbr_tcp_recv_from_ring (sbr_socket_t * sk, struct spl_pbuf **buf, i32 timeout)
-{
- int err;
- spl_netconn_t *conn = sbr_get_conn (sk);
-
- err = ss_get_last_errno (conn);
- if (SPL_ERR_IS_FATAL (err))
- {
- /* don't recv on fatal errors: this might block the application task
- waiting on recvmbox forever! */
-
- /* @todo: this does not allow us to fetch data that has been put into recvmbox
- before the fatal error occurred - is that a problem? */
- NSSBR_LOGDBG ("last err when recv:]=%d", err);
- if (ERR_CLSD != err)
- {
- sbr_set_sk_io_errno (sk, sbr_spl_err_to_errno (err));
- return -1;
- }
- }
-
- *buf = NULL;
- if (0 != sbr_dequeue_buf (sk, (void **) buf, timeout))
- {
- return -1;
- }
-
- ss_sub_recv_avail (sbr_get_conn (sk), (*buf)->tot_len);
-
- ss_sub_recv_event (sbr_get_conn (sk));
-
- return 0;
-}
-
-static inline int
-sbr_tcp_recv_state_check (sbr_socket_t * sk)
-{
-
- spl_tcp_state_t state = ss_get_tcp_state (sbr_get_conn (sk));
-
- NSSBR_LOGDBG ("tcp state when recv:]=%d", state);
-
- //close_wait state also can recive data
- //no connect cannot recive data
- if (SPL_ESTABLISHED > state)
- {
- if (SPL_SHUT_WR != ss_get_shut_status (sbr_get_conn (sk)))
- {
- /* after all data retrnasmission, connection is active */
- /* patch solution as last_err is not maintained properly */
- if ((SPL_CLOSED == state)
- && (ERR_TIMEOUT == ss_get_last_errno (sbr_get_conn (sk))))
- {
- sbr_set_sk_io_errno (sk, ETIMEDOUT);
- }
- else if ((SPL_CLOSED == state)
- && (ERR_RST == ss_get_last_errno (sbr_get_conn (sk))))
- {
- sbr_set_sk_io_errno (sk, ECONNRESET);
- }
- else
- {
- sbr_set_sk_io_errno (sk, ENOTCONN);
- }
-
- return -1;
- }
- }
-
- return 0;
-}
-
-NSTACK_STATIC int
-sbr_tcp_recvfrom (sbr_socket_t * sk, void *mem, size_t len, int flags,
- struct sockaddr *from, socklen_t * fromlen)
-{
- struct spl_pbuf *p;
- u32 buflen;
- u32 copylen;
- u32 off = 0;
- u8 done = 0;
- int para_len = len;
- int retval = 0;
-
- sbr_com_lock_recv (sk);
- NSSOC_LOGINF ("recv start, fd = %d last data %p flags to be set %d", sk->fd,
- ADDR_SHTOL (sbr_get_fd_share (sk)->lastdata), MSG_DONTWAIT);
-
- if (0 != sbr_tcp_recv_state_check (sk))
- {
- retval = -1;
- goto sbr_tcp_recvfrom_exit;
- }
-
- do
- {
- if (sbr_get_fd_share (sk)->lastdata)
- {
- p = ADDR_SHTOL (sbr_get_fd_share (sk)->lastdata);
- }
- else
- {
- if ((flags & MSG_DONTWAIT)
- || ss_is_nonblock_flag (sbr_get_conn (sk)))
- {
- NSSOC_LOGINF ("call ss_get_recv_event");
- if (0 >= ss_get_recv_event (sbr_get_conn (sk)))
- {
- NSSOC_LOGINF ("no recv event]fd=%d", sk->fd);
- sbr_set_sk_io_errno (sk, EWOULDBLOCK);
- retval = -1;
- goto sbr_tcp_recvfrom_exit;
- }
- }
-
- if (0 !=
- sbr_tcp_recv_from_ring (sk, &p,
- sbr_get_fd_share (sk)->recv_timeout))
- {
- /* already received data, return that */
- if (off > 0)
- {
- sbr_set_sk_io_errno (sk, ERR_OK);
- retval = off;
- goto sbr_tcp_recvfrom_exit;
- }
-
- /* we tell the user the connection is closed by returning zero */
- if (sbr_get_sk_errno (sk) == ENOTCONN)
- {
- retval = 0;
- goto sbr_tcp_recvfrom_exit;
- }
-
- retval = -1;
- goto sbr_tcp_recvfrom_exit;
- }
-
- sbr_get_fd_share (sk)->lastdata = (void *) ADDR_LTOSH (p);
- }
-
- buflen = p->tot_len - sbr_get_fd_share (sk)->lastoffset;
- copylen = len > buflen ? buflen : len;
-
- if ((copylen > 0)
- && 0 == spl_pbuf_copy_partial (p, (u8 *) mem + off, copylen,
- sbr_get_fd_share (sk)->lastoffset))
- {
- NSSBR_LOGERR ("copy failed]fd=%d", sk->fd);
- sbr_set_sk_io_errno (sk, EFAULT);
- retval = -1;
- goto sbr_tcp_recvfrom_exit;
- }
-
- off += copylen;
-
- len -= copylen;
-
- if ((len == 0) || (ss_get_recv_event (sbr_get_conn (sk)) <= 0)
- || ((flags & MSG_PEEK) != 0))
- {
- if ((off >= sbr_get_fd_share (sk)->rcvlowat)
- || (para_len <= sbr_get_fd_share (sk)->rcvlowat))
- {
- done = 1;
- }
- }
-
- if (done)
- {
- if (sbr_tcp_get_sockaddr (sk, from, fromlen) != 0)
- {
- retval = -1;
- goto sbr_tcp_recvfrom_exit;
- }
- }
-
- /* If this is a TCP socket, check if there is data left in the buffer,
- If so, it should be saved in the sock structure for next time around. */
- if (!(flags & MSG_PEEK))
- {
- sbr_tcp_recv_no_peak (sk, p, buflen, copylen);
- }
- }
- while (!done);
-
- retval = off;
-
- NSSOC_LOGINF ("recv done, fd = %d last data %p", sk->fd);
-sbr_tcp_recvfrom_exit:
-
- NSSOC_LOGINF ("recv exit, fd = %d last data %p", sk->fd);
- sbr_com_unlock_recv (sk);
- return retval;
-}
-
-/*****************************************************************************
-* Prototype : sbr_tcp_recvdata
-* Description : recvdata
-* Input : sbr_socket_t* sk
-* const struct iovec* iov
-* int iovcnt
-* int flags
-* Output : None
-* Return Value : static inline int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline int
-sbr_tcp_recvdata (sbr_socket_t * sk, const struct iovec *iov, int iovcnt)
-{
- int max = SBR_MAX_INTEGER;
- int len = 0;
- int ret = 0;
- int i = 0;
-
- do
- {
- len += ret;
-
- if (!iov[i].iov_base || (0 == iov[i].iov_len))
- {
- ret = 0;
- continue;
- }
-
- ret = sbr_tcp_recvfrom (sk, (char *) iov[i].iov_base, iov[i].iov_len, 0,
- NULL, NULL);
- }
- while ((ret == (int) iov[i].iov_len) && (iovcnt > (++i))
- && (max - len - ret > (int) iov[i].iov_len));
-
- if (len == 0)
- {
- return ret;
- }
- else
- {
- return (ret == -1 ? len : len + ret);
- }
-}
-
-/*****************************************************************************
-* Prototype : sbr_tcp_readv
-* Description : readv
-* Input : sbr_socket_t* sk
-* const struct iovec* iov
-* int iovcnt
-* Output : None
-* Return Value : static int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static int
-sbr_tcp_readv (sbr_socket_t * sk, const struct iovec *iov, int iovcnt)
-{
- return sbr_tcp_recvdata (sk, iov, iovcnt);
-}
-
-/*****************************************************************************
-* Prototype : sbr_tcp_recvmsg
-* Description : recvmsg,unsupport flags
-* Input : sbr_socket_t* sk
-* struct msghdr* msg
-* int flags
-* Output : None
-* Return Value : static int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static int
-sbr_tcp_recvmsg (sbr_socket_t * sk, struct msghdr *msg, int flags)
-{
- if (sbr_tcp_get_sockaddr
- (sk, (struct sockaddr *) msg->msg_name, &msg->msg_namelen) != 0)
- {
- return -1;
- }
-
- return sbr_tcp_recvdata (sk, msg->msg_iov, msg->msg_iovlen);
-}
-
-static int
-sbr_tcp_send_is_timeout (sbr_socket_t * sk, struct timespec *starttm)
-{
- struct timespec currtm;
- i64 timediff_ms, timediff_sec;
- i64 timeout_thr_ms, timeout_thr_sec;
-
- timeout_thr_ms = sbr_get_fd_share (sk)->send_timeout;
- if (0 == timeout_thr_ms)
- {
- return 0;
- }
-
- /* it is possible that starttm don't be inited,
- if send_timeout is change when this write function is running */
- timeout_thr_sec = (timeout_thr_ms + 240) >> 10;
-
- /* Handle system time change side-effects */
- if (unlikely (0 != clock_gettime (CLOCK_MONOTONIC, &currtm)))
- {
- NSSBR_LOGERR ("Failed to get time, errno = %d", errno);
- }
-
- timediff_sec = currtm.tv_sec - starttm->tv_sec;
- if (timediff_sec >= timeout_thr_sec)
- {
- timediff_ms = currtm.tv_nsec > starttm->tv_nsec ?
- (timediff_sec * 1000) + (currtm.tv_nsec -
- starttm->tv_nsec) /
- USEC_TO_SEC : (timediff_sec * 1000) -
- ((starttm->tv_nsec - currtm.tv_nsec) / USEC_TO_SEC);
-
- /*NOTE: if user configured the timeout as say 0.5 ms, then timediff value
- will be negetive if still 0.5 ms is not elapsed. this is intended and we should
- not typecast to any unsigned type during this below if check */
- if (timediff_ms > timeout_thr_ms)
- {
- return 1;
- }
- }
-
- return 0;
-}
-
-static inline int
-sbr_tcp_write_is_wait (sbr_socket_t * sk, struct timespec *starttm,
- int noneblockFlg)
-{
- if (noneblockFlg || sbr_tcp_send_is_timeout (sk, starttm))
- {
- return 0;
- }
- else
- {
- return 1;
- }
-}
-
-static struct spl_pbuf *
-sbr_tcp_write_alloc_buf (sbr_socket_t * sk, size_t seglen, u8 api_flag,
- struct timespec *starttm, u8 * errno_flag)
-{
- spl_netconn_t *conn = sbr_get_conn (sk);
-
- struct spl_pbuf *curr_buf = NULL;
- size_t head_len = SPL_TCP_HLEN + SPL_PBUF_IP_HLEN + SPL_PBUF_LINK_HLEN;
- int noneblockFlg = (api_flag & SPL_NETCONN_DONTBLOCK)
- || ss_is_nonblock_flag (sbr_get_conn (sk));
-
- do
- {
- /* When packages are lost more than TCP_MAXRTX times,
- * conn will be closed and pcb will be removed. */
- if (ss_get_tcp_state (conn) == SPL_CLOSED)
- {
- NSSBR_LOGERR ("pcb SPL_CLOSED]conn=%p", conn);
- sbr_set_sk_io_errno (sk, ECONNABORTED);
- /* Must set errno_flag when set errno, to avoid errnno overwritten by sbr_tcp_write */
- *errno_flag = 1;
- return NULL;
- }
-
- curr_buf = sbr_malloc_tx_pbuf (seglen + head_len, head_len);
- if (NULL == curr_buf)
- {
- if (!sbr_tcp_write_is_wait (sk, starttm, noneblockFlg))
- {
- return NULL;
- }
-
- int err = ss_get_last_errno (sbr_get_conn (sk));
- if (SPL_ERR_IS_FATAL (err))
- {
- NSSBR_LOGERR ("connection fatal error!err=%d", err);
- sbr_set_sk_io_errno (sk, sbr_spl_err_to_errno (err));
- *errno_flag = 1;
- return NULL;
- }
-
- sched_yield ();
- }
- }
- while (curr_buf == NULL);
-
- return curr_buf;
-}
-
-static inline void
-sbr_tcp_write_rel_buf (sbr_socket_t * sk, struct spl_pbuf *buf,
- u32 thread_index)
-{
- if (buf != NULL)
- {
- sbr_handle_free_send_buf (sk, buf);
- }
-}
-
-static inline int
-sbr_tcp_write_fill_buf (const void *data, size_t * pos,
- struct spl_pbuf *seg_buf, size_t seglen,
- size_t optlen)
-{
- size_t start = *pos;
- size_t copy = seglen;
- struct spl_pbuf *first = seg_buf;
-
- while ((0 < copy) && (NULL != first))
- {
- char *dst_ptr = PTR_SHTOL (char *, first->payload_a) + optlen;
-
- if (NULL ==
- common_memcpy (dst_ptr, (u8_t *) data + start, first->len - optlen))
- {
- NSSBR_LOGERR ("common_memcpy error]dst=%p,src=%p,len=%u",
- dst_ptr, (u8_t *) data + start, first->len);
- return -1;
- }
-
- start += (first->len - optlen);
- copy -= (first->len - optlen);
- first = ADDR_SHTOL (first->next_a);
- }
-
- (*pos) = start;
-
- return 0;
-}
-
-static inline int
-sbr_tcp_writev_fill_buf (const struct iovec *iov, size_t * iov_pos,
- int *iov_var, size_t * pos, struct spl_pbuf *seg_buf,
- size_t seglen, size_t optlen)
-{
- size_t valid_copy_len;
- size_t iov_data_left;
-
- size_t copy = seglen;
- size_t start = *pos;
- size_t current_iov_pos = *iov_pos;
- int current_iov_var = *iov_var;
-
- u32 pbuf_offset = optlen;
- u32 pbuf_data_len;
- struct spl_pbuf *first = seg_buf;
-
- while ((0 < copy) && (NULL != first))
- {
- iov_data_left = iov[current_iov_var].iov_len - current_iov_pos;
- if (seglen == copy)
- {
- pbuf_offset = optlen;
- }
-
- pbuf_data_len = first->len - pbuf_offset;
- valid_copy_len =
- (iov_data_left > pbuf_data_len ? pbuf_data_len : iov_data_left);
- if (NULL ==
- common_memcpy ((char *) ADDR_SHTOL (first->payload_a) + pbuf_offset,
- (u8_t *) iov[current_iov_var].iov_base +
- current_iov_pos, valid_copy_len))
- {
- NSSBR_LOGERR
- ("common_memcpy error]current_iov_var=%d, dst=%p,src=%p,len=%zu",
- current_iov_var,
- (char *) ADDR_SHTOL (first->payload_a) + pbuf_offset,
- (u8_t *) iov[current_iov_var].iov_base + current_iov_pos,
- valid_copy_len);
- return -1;
- }
-
- start += valid_copy_len;
- copy -= valid_copy_len;
-
- if (iov_data_left == pbuf_data_len)
- {
- first = PTR_SHTOL (struct spl_pbuf *, first->next_a);
- pbuf_offset = optlen; //+= valid_copy_len;
- current_iov_var++;
- current_iov_pos = 0;
- }
- else if (iov_data_left > pbuf_data_len)
- {
- first = PTR_SHTOL (struct spl_pbuf *, first->next_a);
- pbuf_offset = optlen; //+= valid_copy_len;
- current_iov_pos += valid_copy_len;
- }
- else
- {
- pbuf_offset += valid_copy_len;
-
- current_iov_var++;
- current_iov_pos = 0;
- }
- }
-
- *iov_pos = current_iov_pos;
- *iov_var = current_iov_var;
- *pos = start;
-
- return 0;
-}
-
-static inline void
-sbr_tcp_write_add_buf_to_list (struct spl_pbuf **p_head,
- struct spl_pbuf **p_tail,
- struct spl_pbuf *seg_buf, size_t seglen,
- size_t optlen)
-{
- seg_buf->len = seglen + optlen;
- seg_buf->tot_len = seglen + optlen;
- seg_buf->next_a = 0;
-
- /*put seg_buf after p_head */
- if (NULL == (*p_head))
- {
- (*p_head) = seg_buf;
- (*p_tail) = seg_buf;
- }
- else
- {
- (*p_tail)->next_a = ADDR_LTOSH (seg_buf);
- (*p_tail) = seg_buf;
- }
-}
-
-NSTACK_STATIC int
-sbr_tcp_write (sbr_socket_t * sk, const void *data, size_t size, u8 api_flag,
- size_t * written)
-{
- err_t err = -1;
- size_t pos = 0, left, seglen;
- u32 pbuf_seg_cnt = 0;
- u32 thread_index = 0;
- struct spl_pbuf *seg_buf = NULL;
- struct spl_pbuf *p_head = NULL;
- struct spl_pbuf *p_tail = p_head;
- struct spl_netconn *conn = sbr_get_conn (sk);
- u32 mss = ss_get_mss (sbr_get_conn (sk));
-
- if (0 == size)
- {
- NSSBR_LOGERR ("fd=%d,size=%u", sk->fd, (u32) size);
- return 0;
- }
-
- struct timespec ts;
- if (unlikely (0 != clock_gettime (CLOCK_MONOTONIC, &ts)))
- {
- NSSBR_LOGERR ("Failed to get time, errno = %d", errno);
- }
-
- while (pos < size)
- {
- left = size - pos;
- seglen = left > mss ? mss : left;
- u8 errno_set = 0;
- seg_buf =
- sbr_tcp_write_alloc_buf (sk, seglen, api_flag, &ts, &errno_set);
- if (NULL == seg_buf)
- {
- NSSBR_LOGINF ("sbr_tcp_write_alloc_buf failed......");
- if (NULL != p_head)
- {
- err = sbr_handle_tcp_send (sk, size, p_head, api_flag);
- if (ERR_OK != err)
- {
- NSSBR_LOGERR ("sbr_handle_tcp_send error]err(%d)", err);
- goto err_ref_buf;
- }
- }
-
- if (0 == pos)
- {
- /* If errno is already set in sbr_tcp_write_alloc_buf, do not overwrite here */
- if (!errno_set)
- {
- sbr_set_sk_io_errno (sk, EWOULDBLOCK);
- }
- return -1;
- }
-
- NSSBR_LOGDBG ("sent size %zu", pos);
- *written = pos;
-
- return ERR_OK;
- }
-
- if (0 != sbr_tcp_write_fill_buf (data, &pos, seg_buf, seglen, 0))
- {
- sbr_set_sk_io_errno (sk, EFAULT);
- NSSBR_LOGERR ("sbr_tcp_write_fill_buf error]");
- goto err_ref_buf;
- }
-
- sbr_tcp_write_add_buf_to_list (&p_head, &p_tail, seg_buf, seglen, 0);
-
- ++pbuf_seg_cnt;
- if (p_head
- && ((SPL_TCP_SEND_MAX_SEG_PER_MSG <= pbuf_seg_cnt)
- || (pos >= size)))
- {
- pbuf_seg_cnt = 0;
- err = sbr_handle_tcp_send (sk, size, p_head, api_flag);
- if (ERR_OK != err)
- {
- NSSBR_LOGERR ("sbr_handle_tcp_send error]err(%d)", err);
- goto err_ref_buf;
- }
-
- p_head = NULL;
- }
- }
-
- *written = size;
-
- (void) conn;
- return ERR_OK;
-
-err_ref_buf:
- sbr_tcp_write_rel_buf (sk, p_head, thread_index);
- (void) conn;
- return -1;
-}
-
-NSTACK_STATIC int
-sbr_tcp_writev (sbr_socket_t * sk, const struct iovec *iov, int iovcnt)
-{
- err_t err = -1;
- int idx = 0;
- size_t pos = 0, left, seglen, optlen = 0;
- u32 pbuf_seg_cnt = 0;
- u32 thread_index = 0;
- size_t size = 0;
- size_t iov_pos = 0;
- int iov_var = 0;
- struct spl_pbuf *seg_buf = NULL;
- struct spl_pbuf *p_head = NULL;
- struct spl_pbuf *p_tail = p_head;
- struct spl_netconn *conn = sbr_get_conn (sk);
- u32 mss = ss_get_mss (sbr_get_conn (sk));
-
- if (mss <= optlen)
- {
- NSSBR_LOGERR ("mss invalid]mss=%u,optlen=%zu,fd=%d", mss, optlen,
- sk->fd);
- sbr_set_sk_io_errno (sk, EINVAL);
- return -1;
- }
-
- /* mss dose't include the tcp options length */
- mss -= optlen;
-
- while (idx < iovcnt)
- {
- if (SBR_MAX_INTEGER - iov[idx].iov_len <= size)
- {
- size = SBR_MAX_INTEGER;
- break;
- }
-
- size += iov[idx].iov_len;
- idx++;
- }
-
- struct timespec starttm;
- if (unlikely (0 != clock_gettime (CLOCK_MONOTONIC, &starttm)))
- {
- NSSBR_LOGERR ("Failed to get time, errno = %d", errno);
- }
-
- while (pos < size)
- {
- left = size - pos;
-
- seglen = left > mss ? mss : left;
- u8 errno_set = 0;
- seg_buf =
- sbr_tcp_write_alloc_buf (sk, seglen + optlen, SPL_NETCONN_COPY,
- &starttm, &errno_set);
- if (NULL == seg_buf)
- {
- if (NULL != p_head)
- {
- err = sbr_handle_tcp_send (sk, size, p_head, SPL_NETCONN_COPY);
- /*If errno is already set in sbr_tcp_write_alloc_buf, do not overwrite here */
- if (err != ERR_OK)
- {
- NSSBR_LOGERR ("sbr_handle_tcp_send error]err(%d)", err);
- goto err_ref_buf;
- }
- }
-
- /* [Start]
- 1)Set SO_SNDTIMEO to 10
- 2)Send a msg of larger buff size.and let the timeout happen for send (dont receive at peer side.)
- 3)iRet will be 0 and errno received will be 11 (EAGAIN).
-
- Above issue is fixed.
- */
- if (0 == pos)
- {
- if (!errno_set)
- {
- sbr_set_sk_io_errno (sk, EWOULDBLOCK);
- }
- return -1;
- }
- /* [End] */
-
- NSSBR_LOGDBG ("sent size %zu", pos);
-
- return pos;
- }
-
- if (0 !=
- sbr_tcp_writev_fill_buf (iov, &iov_pos, &iov_var, &pos, seg_buf,
- seglen, optlen))
- {
- sbr_set_sk_io_errno (sk, EFAULT);
- NSSBR_LOGERR ("sbr_tcp_writev_fill_buf error]");
- goto err_ref_buf;
- }
-
- sbr_tcp_write_add_buf_to_list (&p_head, &p_tail, seg_buf, seglen,
- optlen);
-
- /* @todo: for non-blocking write, check if 'size' would ever fit into
- snd_queue or snd_buf */
- ++pbuf_seg_cnt;
- if (p_head
- && ((SPL_TCP_SEND_MAX_SEG_PER_MSG <= pbuf_seg_cnt)
- || (pos >= size)))
- {
- pbuf_seg_cnt = 0;
- err = sbr_handle_tcp_send (sk, size, p_head, SPL_NETCONN_COPY);
- if (ERR_OK != err)
- {
- NSSBR_LOGERR ("sbr_handle_tcp_send error]err(%d)", err);
- goto err_ref_buf;
- }
-
- p_head = NULL;
- }
- }
- (void) conn;
- return size;
-
-err_ref_buf:
- sbr_tcp_write_rel_buf (sk, p_head, thread_index);
- (void) conn;
- return -1;
-}
-
-NSTACK_STATIC int
-sbr_tcp_sendto (sbr_socket_t * sk, const void *data, size_t size, int flags,
- const struct sockaddr *to, socklen_t tolen)
-{
- return sk->fdopt->send (sk, data, size, flags);
-}
-
-static inline int
-sbr_tcp_send_state_check (sbr_socket_t * sk)
-{
- if ((SPL_SHUT_WR == ss_get_shut_status (sbr_get_conn (sk)))
- || (SPL_SHUT_RDWR == ss_get_shut_status (sbr_get_conn (sk))))
- {
- sbr_set_sk_io_errno (sk, EPIPE);
- return -1;
- }
-
- spl_tcp_state_t state = ss_get_tcp_state (sbr_get_conn (sk));
- if ((SPL_ESTABLISHED != state) && (SPL_CLOSE_WAIT != state))
- {
- /* after all data retrnasmission, connection is active */
- /* patch solution as last_err is not maintained properly */
- if ((SPL_CLOSED == state)
- && (ERR_TIMEOUT == ss_get_last_errno (sbr_get_conn (sk))))
- {
- sbr_set_sk_io_errno (sk, ETIMEDOUT);
- }
- else if ((SPL_CLOSED == state)
- && (ERR_RST == ss_get_last_errno (sbr_get_conn (sk))))
- {
- sbr_set_sk_io_errno (sk, ECONNRESET);
- }
- else
- {
- sbr_set_sk_io_errno (sk, EPIPE);
- }
-
- return -1;
- }
-
- return 0;
-}
-
-NSTACK_STATIC int
-sbr_tcp_send (sbr_socket_t * sk, const void *data, size_t size, int flags)
-{
- int err;
- size_t written = 0;
- u8 write_flags;
-
- if (0 != sbr_tcp_send_state_check (sk))
- {
- NSSBR_LOGDBG ("tcp state not correct]fd=%d, err=%d", sk->fd,
- sbr_get_sk_errno (sk));
- return -1;
- }
-
- write_flags = SPL_NETCONN_COPY |
- ((flags & MSG_MORE) ? SPL_NETCONN_MORE : 0) |
- ((flags & MSG_DONTWAIT) ? SPL_NETCONN_DONTBLOCK : 0);
-
- NSSBR_LOGINF ("Sbr tcp write start");
- err = sbr_tcp_write (sk, data, size, write_flags, &written);
- NSSBR_LOGINF ("Sbr tcp write end written %d", written);
-
- return (err == ERR_OK ? written : -1);
-}
-
-NSTACK_STATIC int
-sbr_tcp_sendmsg (sbr_socket_t * sk, const struct msghdr *pmsg, int flags)
-{
- if (0 != sbr_tcp_send_state_check (sk))
- {
- NSSBR_LOGDBG ("tcp state not correct]fd=%d, err=%d", sk->fd,
- sbr_get_sk_errno (sk));
- return -1;
- }
-
- return sbr_tcp_writev (sk, pmsg->msg_iov, pmsg->msg_iovlen);
-}
-
-NSTACK_STATIC int
-sbr_tcp_fcntl (sbr_socket_t * sk, int cmd, long arg)
-{
- int ret = 0;
-
- switch (cmd)
- {
- case F_GETFL:
- ret = ss_get_nonblock_flag (sbr_get_conn (sk));
- NSSBR_LOGDBG ("F_GETFL]fd=%d,ret=%d", sk->fd, ret);
- break;
-
- case F_SETFL:
- if (arg & O_NONBLOCK)
- {
- NSSBR_LOGDBG ("F_SETFL set O_NONBLOCK val]fd=%d,arg=%ld", sk->fd,
- arg);
- ss_set_nonblock_flag (sbr_get_conn (sk), (arg & O_NONBLOCK));
- }
- else
- {
- NSSBR_LOGDBG ("F_SETFL clean O_NONBLOCK val]fd=%d,arg=%ld", sk->fd,
- arg);
- ss_set_nonblock_flag (sbr_get_conn (sk), 0);
- }
-
- break;
-
- default:
- NSSBR_LOGERR ("cmd is not support]fd=%d,cmd=%d", sk->fd, cmd);
- ret = -1;
- sbr_set_sk_errno (sk, EINVAL);
- break;
- }
-
- return ret;
-}
-
-NSTACK_STATIC int
-sbr_tcp_ioctl (sbr_socket_t * sk, unsigned long cmd, void *arg)
-{
- int ret = 0;
- int recv_avail;
-
- switch (cmd)
- {
- case FIONREAD:
- {
- if (ss_is_listen_state (sbr_get_conn (sk)))
- {
- ret = -1;
- sbr_set_sk_errno (sk, EINVAL);
- break;
- }
-
- recv_avail = ss_get_recv_avail (sbr_get_conn (sk));
- *((u32 *) arg) = recv_avail >= 0 ? recv_avail : 0;
- if (sbr_get_fd_share (sk)->lastdata)
- {
- struct spl_pbuf *buf =
- ADDR_SHTOL (sbr_get_fd_share (sk)->lastdata);
- *((u32 *) arg) +=
- (buf->tot_len - sbr_get_fd_share (sk)->lastoffset);
- }
- }
-
- break;
-
- case FIONBIO:
- {
- u8 val = 0;
-
- if (arg && *(u32 *) arg)
- {
- val = 1;
- }
-
- ss_set_nonblock_flag (sbr_get_conn (sk), val);
- NSSBR_LOGDBG ("FIONBIO]fd=%d,val=%u", sk->fd, val);
- }
-
- break;
-
- default:
- {
- NSSBR_LOGERR ("cmd is not support]fd=%d,cmd=%lu", sk->fd, cmd);
- ret = -1;
- sbr_set_sk_errno (sk, ENOTTY);
- }
- break;
- }
-
- return ret;
-}
-
-NSTACK_STATIC int
-sbr_tcp_close (sbr_socket_t * sk)
-{
- if (sbr_get_fd_share (sk)->lastdata)
- {
- struct spl_netbuf *buf = ADDR_SHTOL (sbr_get_fd_share (sk)->lastdata);
- struct spl_pbuf *p = (struct spl_pbuf *) ADDR_SHTOL (buf->p);
- sbr_tcp_free_recvbuf (sk, p);
- }
-
- return sbr_handle_close (sk, 0);
-}
-
-sbr_fdopt tcp_fdopt = {
- .socket = sbr_tcp_socket,
- .bind = sbr_tcp_bind,
- .listen = sbr_tcp_listen,
- .accept = sbr_tcp_accept,
- .accept4 = sbr_tcp_accept4,
- .connect = sbr_tcp_connect,
- .shutdown = sbr_tcp_shutdown,
- .getsockname = sbr_tcp_getsockname,
- .getpeername = sbr_tcp_getpeername,
- .getsockopt = sbr_tcp_getsockopt,
- .setsockopt = sbr_tcp_setsockopt,
- .recvfrom = sbr_tcp_recvfrom,
- .readv = sbr_tcp_readv,
- .recvmsg = sbr_tcp_recvmsg,
- .send = sbr_tcp_send,
- .sendto = sbr_tcp_sendto,
- .sendmsg = sbr_tcp_sendmsg,
- .writev = sbr_tcp_writev,
- .fcntl = sbr_tcp_fcntl,
- .ioctl = sbr_tcp_ioctl,
- .close = sbr_tcp_close,
- .peak = sbr_com_peak,
- .lock_common = sbr_com_lock_common,
- .unlock_common = sbr_com_unlock_common,
- .fork_parent = sbr_com_fork_parent,
- .fork_child = sbr_com_fork_child,
- .ep_getevt = stackx_eventpoll_getEvt,
- .ep_ctl = stackx_eventpoll_triggle,
- .set_close_stat = NULL,
-};
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_udp.c b/stacks/lwip_stack/lwip_src/socket/stackx_udp.c
deleted file mode 100644
index 1f382cf..0000000
--- a/stacks/lwip_stack/lwip_src/socket/stackx_udp.c
+++ /dev/null
@@ -1,1153 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "stackx_prot_com.h"
-#include "stackx_msg_handler.h"
-#include "stackx_pbuf.h"
-#include "stackx_epoll_api.h"
-#include "stackx_err.h"
-#include "nstack_securec.h"
-#include "common_pal_bitwide_adjust.h"
-#include "stackx_cfg.h"
-#include <netinet/in.h>
-#ifdef HAL_LIB
-#else
-#include "rte_memcpy.h"
-#endif
-
-#define SPL_PBUF_UDP_LEN (SPL_FRAME_MTU + SPL_PBUF_LINK_HLEN)
-#define L2_L3_ROOM_LEN (SPL_PBUF_LINK_HLEN + SPL_PBUF_IP_HLEN)
-#define L4_ROOM_LEN SPL_PBUF_UDP_HLEN
-
-/*****************************************************************************
-* Prototype : sbr_udp_socket
-* Description : create socket
-* Input : sbr_socket_t * sk
-* int domain
-* int type
-* int protocol
-* Output : None
-* Return Value : static int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static int
-sbr_udp_socket (sbr_socket_t * sk, int domain, int type, int protocol)
-{
- if (sbr_malloc_conn_for_sk (sk, SPL_NETCONN_UDP) != 0)
- {
- return -1;
- }
-
- int ret = sbr_handle_socket (sk, SPL_NETCONN_UDP, 0);
- if (ret != 0)
- {
- sbr_free_conn_from_sk (sk);
- return ret;
- }
-
- ss_set_nonblock_flag (sbr_get_conn (sk), (type & O_NONBLOCK));
- ss_set_send_event (sbr_get_conn (sk), 1);
- return ret;
-}
-
-/*****************************************************************************
-* Prototype : sbr_udp_bind
-* Description : udp bind
-* Input : sbr_socket_t * sk
-* const struct sockaddr * name
-* socklen_t namelen
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_udp_bind (sbr_socket_t * sk, const struct sockaddr *name,
- socklen_t namelen)
-{
- const struct sockaddr_in *addr_in = (const struct sockaddr_in *) name;
-
- NSSBR_LOGINF ("fd=%d,addr=%s,port=%d,conn=%p,private_data=%p", sk->fd,
- spl_inet_ntoa (addr_in->sin_addr), ntohs (addr_in->sin_port),
- sbr_get_conn (sk), ss_get_private_data (sbr_get_conn (sk)));
- spl_ip_addr_t local_addr;
- inet_addr_to_ipaddr (&local_addr, &addr_in->sin_addr);
- u16 local_port = addr_in->sin_port;
- return sbr_handle_bind (sk, &local_addr, ntohs (local_port));
-}
-
-/*****************************************************************************
-* Prototype : sbr_udp_listen
-* Description : unsupport
-* Input : sbr_socket_t * sk
-* int backlog
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_udp_listen (sbr_socket_t * sk, int backlog)
-{
- NSSBR_LOGERR ("type is not TCP]fd=%d", sk->fd);
- sbr_set_sk_errno (sk, EOPNOTSUPP);
- return -1;
-}
-
-/*****************************************************************************
-* Prototype : sbr_udp_accept
-* Description : unsupport
-* Input : sbr_socket_t * sk
-* sbr_socket_t * new_sk
-* struct sockaddr * addr
-* socklen_t * addrlen
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_udp_accept (sbr_socket_t * sk, sbr_socket_t * new_sk,
- struct sockaddr *addr, socklen_t * addrlen)
-{
- NSSBR_LOGERR ("type is not TCP]fd=%d", sk->fd);
- sbr_set_sk_errno (sk, EOPNOTSUPP);
- return -1;
-}
-
-/*****************************************************************************
-* Prototype : sbr_udp_accept4
-* Description : unsupport
-* Input : sbr_socket_t * sk
-* sbr_socket_t * new_sk
-* struct sockaddr * addr
-* socklen_t * addrlen
-* int flags
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_udp_accept4 (sbr_socket_t * sk, sbr_socket_t * new_sk,
- struct sockaddr *addr, socklen_t * addrlen, int flags)
-{
- NSSBR_LOGERR ("type is not TCP]fd=%d", sk->fd);
- sbr_set_sk_errno (sk, EOPNOTSUPP);
- return -1;
-}
-
-/*****************************************************************************
-* Prototype : sbr_udp_connect
-* Description : udp connect
-* Input : sbr_socket_t * sk
-* const struct sockaddr * name
-* socklen_t namelen
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_udp_connect (sbr_socket_t * sk, const struct sockaddr *name,
- socklen_t namelen)
-{
- const struct sockaddr_in *addr_in = (const struct sockaddr_in *) name;
-
- NSSBR_LOGINF ("fd=%d,addr=%s,port=%d,conn=%p,private_data=%p", sk->fd,
- spl_inet_ntoa (addr_in->sin_addr), ntohs (addr_in->sin_port),
- sbr_get_conn (sk), ss_get_private_data (sbr_get_conn (sk)));
- spl_ip_addr_t remote_addr;
-
- inet_addr_to_ipaddr (&remote_addr, &addr_in->sin_addr);
- u16 remote_port = addr_in->sin_port;
-
- spl_ip_addr_t local_addr = { IPADDR_ANY };
-
- return sbr_handle_connect (sk, &remote_addr, ntohs (remote_port),
- &local_addr);
-}
-
-/*****************************************************************************
-* Prototype : sbr_udp_shutdown
-* Description : udp shutdown
-* Input : sbr_socket_t * sk
-* int how
-* Output : None
-* Return Value : static int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static int
-sbr_udp_shutdown (sbr_socket_t * sk, int how)
-{
- ss_set_shut_status (sbr_get_conn (sk), how);
- NSSBR_LOGERR ("type is not TCP]fd=%d", sk->fd);
- sbr_set_sk_errno (sk, EOPNOTSUPP);
- return -1;
-}
-
-/*****************************************************************************
-* Prototype : sbr_udp_getsockname
-* Description : get sock name
-* Input : sbr_socket_t * sk
-* struct sockaddr * name
-* socklen_t * namelen
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_udp_getsockname (sbr_socket_t * sk, struct sockaddr *name,
- socklen_t * namelen)
-{
- return sbr_handle_get_name (sk, name, namelen, SBR_GET_SOCK_NAME);
-}
-
-/*****************************************************************************
-* Prototype : sbr_udp_getpeername
-* Description : get peer name
-* Input : sbr_socket_t * sk
-* struct sockaddr * name
-* socklen_t * namelen
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_udp_getpeername (sbr_socket_t * sk, struct sockaddr *name,
- socklen_t * namelen)
-{
- return sbr_handle_get_name (sk, name, namelen, SBR_GET_PEER_NAME);
-}
-
-/*****************************************************************************
-* Prototype : sbr_udp_getsockopt
-* Description : get sockopt
-* Input : sbr_socket_t * sk
-* int level
-* int optname
-* void * optval
-* socklen_t * optlen
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_udp_getsockopt (sbr_socket_t * sk, int level, int optname, void *optval,
- socklen_t * optlen)
-{
- int err = 0;
-
- switch (level)
- {
- case SOL_SOCKET:
- err = sbr_getsockopt_sol_socket (sk, optname, optval, *optlen);
- break;
- case IPPROTO_IP:
- err = sbr_getsockopt_ipproto_ip (optname, optval, *optlen);
- break;
-
- case NSTACK_SOCKOPT:
- if ((optname == NSTACK_SEM_SLEEP) || (*optlen < sizeof (u32_t)))
- {
- *(u32_t *) optval =
- sbr_get_fd_share (sk)->block_polling_time / 1000;
- NSSOC_LOGINF
- ("udp get recv sleep time success]usleep time=%d,fd=%d",
- sbr_get_fd_share (sk)->block_polling_time, sk->fd);
- return ERR_OK;
- }
- else
- {
- NSSOC_LOGINF ("get recv sleep time failed]fd=%d", sk->fd);
- sbr_set_sk_io_errno (sk, EINVAL);
- return -1;
- }
-
- default:
- err = ENOPROTOOPT;
- break;
- }
-
- if (err != 0)
- {
- NSSBR_LOGERR ("fail]fd=%d,level=%d,optname=%d,err=%d", sk->fd, level,
- optname, err);
- /* for option not support ,getsockopt() should return fail */
- sbr_set_sk_errno (sk, err);
- return -1;
- }
-
- return sbr_handle_getsockopt (sk, level, optname, optval, optlen);
-}
-
-/*****************************************************************************
-* Prototype : sbr_udp_setsockopt
-* Description : set sockopt
-* Input : sbr_socket_t * sk
-* int level
-* int optname
-* const void * optval
-* socklen_t optlen
-* Output : None
-* Return Value : static int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static int
-sbr_udp_setsockopt (sbr_socket_t * sk, int level, int optname,
- const void *optval, socklen_t optlen)
-{
- NSSBR_LOGDBG ("udp setsockopt]fd=%d,level=%d,optname=%d", sk->fd, level,
- optname);
- int err = 0;
- switch (level)
- {
- case SOL_SOCKET:
- err =
- sbr_setsockopt_sol_socket (sk, optname, optval, optlen,
- SPL_NETCONN_UDP);
- break;
- case IPPROTO_IP:
- err =
- sbr_setsockopt_ipproto_ip (optname, optval, optlen, SPL_NETCONN_UDP);
- break;
- case NSTACK_SOCKOPT:
- {
- u32_t sleep_time = *(u32_t *) optval;
- /*sleep time should less than 1s */
- if ((optname == NSTACK_SEM_SLEEP) && (optlen >= sizeof (u32_t))
- && (sleep_time < 1000000))
- {
- sbr_get_fd_share (sk)->block_polling_time = sleep_time * 1000;
- NSSOC_LOGINF
- ("udp set recv sleep time success]usleep time=%d,fd=%d",
- sbr_get_fd_share (sk)->block_polling_time, sk->fd);
- return ERR_OK;
- }
- else
- {
- NSSOC_LOGINF ("set recv sleep time failed]fd=%d", sk->fd);
- sbr_set_sk_io_errno (sk, EINVAL);
- return -1;
- }
- }
-
- default:
- err = ENOPROTOOPT;
- break;
- }
-
- if (err != 0)
- {
- NSSBR_LOGERR ("fail]fd=%d,level=%d,optname=%d,err=%d", sk->fd, level,
- optname, err);
-
- if (ENOPROTOOPT == err)
- {
- return 0;
- }
- else
- {
- sbr_set_sk_errno (sk, err);
- return -1;
- }
- }
-
- return sbr_handle_setsockopt (sk, level, optname, optval, optlen);
-}
-
-static inline int
-sbr_udp_get_from_addr (sbr_socket_t * sk, struct sockaddr *from,
- socklen_t * fromlen, struct spl_netbuf *buf)
-{
- int ret;
- u16 port = netbuf_fromport (buf);
- spl_ip_addr_t *addr = netbuf_fromaddr (buf);
-
- ret = (from
- && fromlen) ? sbr_get_sockaddr_and_len (port, addr, from,
- fromlen) : 0;
- if (0 != ret)
- {
- sbr_set_sk_io_errno (sk, EINVAL);
- NSSBR_LOGERR ("sbr_udp_get_from_addr]fd=%d", sk->fd);
- return -1;
- }
-
- return 0;
-}
-
-/*****************************************************************************
-* Prototype : sbr_udp_recv_from_ring
-* Description : recv buf from ring
-* Input : sbr_socket_t * sk
-* struct spl_netbuf ** buf
-* i32 timeout
-* Output : None
-* Return Value : static inline int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline int
-sbr_udp_recv_from_ring (sbr_socket_t * sk, struct spl_netbuf **buf,
- i32 timeout)
-{
- void *p = NULL;
- spl_netconn_t *conn = sbr_get_conn (sk);
-
- if (sbr_dequeue_buf (sk, &p, timeout) != 0)
- {
- return -1;
- }
-
- *buf = (struct spl_netbuf *) ((char *) p + sizeof (struct spl_pbuf));
- ss_sub_recv_event (conn);
- return 0;
-}
-
-/*****************************************************************************
-* Prototype : _sbr_udp_recvfrom
-* Description : base recvfrom,without lock
-* Input : sbr_socket_t * sk
-* void * mem
-* size_t len
-* int flags
-* struct sockaddr * from
-* socklen_t * fromlen
-* Output : None
-* Return Value : static inline int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline int
-_sbr_udp_recvfrom (sbr_socket_t * sk, void *mem, size_t len, int flags,
- struct sockaddr *from, socklen_t * fromlen)
-{
- struct spl_netbuf *buf = NULL;
- struct spl_pbuf *p;
- u32 buflen;
- u32 copylen;
- u32 off = 0;
-
- if (sbr_get_fd_share (sk)->lastdata)
- {
- buf = ADDR_SHTOL (sbr_get_fd_share (sk)->lastdata);
- }
- else
- {
- if ((flags & MSG_DONTWAIT) || ss_is_nonblock_flag (sbr_get_conn (sk)))
- {
- /*
- * return with last err when
- * some fatal err occurs, for example, spl just recovered from a fault.
- */
- int err = ss_get_last_errno (sbr_get_conn (sk));
- if (SPL_ERR_IS_FATAL (err))
- {
- NSSBR_LOGDBG ("connection fatal error]sk->fd=%d,errno=%d",
- sk->fd, err);
- sbr_set_sk_io_errno (sk, sbr_spl_err_to_errno (err));
- return -1;
- }
-
- if (ss_get_recv_event (sbr_get_conn (sk)) <= 0)
- {
- NSSBR_LOGDBG ("no recv event]fd=%d", sk->fd);
- sbr_set_sk_io_errno (sk, EWOULDBLOCK);
- return -1;
- }
- }
-
- if (sbr_udp_recv_from_ring
- (sk, &buf, sbr_get_fd_share (sk)->recv_timeout) != 0)
- {
- return -1;
- }
-
- sbr_get_fd_share (sk)->lastdata = (void *) ADDR_LTOSH (buf);
- }
-
- p = (struct spl_pbuf *) ADDR_SHTOL (buf->p);
- buflen = p->tot_len;
-
- if (mem)
- {
- copylen = len > buflen ? buflen : len;
-
- if ((copylen > 0) && 0 == spl_pbuf_copy_partial (p, mem, copylen, 0))
- {
- NSSBR_LOGERR ("copy failed]fd=%d", sk->fd);
- sbr_set_sk_io_errno (sk, EFAULT);
- return -1;
- }
-
- off += copylen;
- }
-
- if (sbr_udp_get_from_addr (sk, from, fromlen, buf) != 0)
- {
- return -1;
- }
-
- if (!(flags & MSG_PEEK))
- {
- sbr_get_fd_share (sk)->lastdata = NULL;
- sbr_com_free_recv_buf (sk, (struct spl_pbuf *) ADDR_SHTOL (buf->p));
- }
-
- return off;
-}
-
-/*****************************************************************************
-* Prototype : sbr_udp_recvfrom
-* Description : recv from
-* Input : sbr_socket_t * sk
-* void * mem
-* size_t len
-* int flags
-* struct sockaddr * from
-* socklen_t * fromlen
-* Output : None
-* Return Value : static int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static int
-sbr_udp_recvfrom (sbr_socket_t * sk, void *mem, size_t len, int flags,
- struct sockaddr *from, socklen_t * fromlen)
-{
- sbr_com_lock_recv (sk);
- int ret = _sbr_udp_recvfrom (sk, mem, len, flags, from, fromlen);
- sbr_com_unlock_recv (sk);
- return ret;
-}
-
-/*****************************************************************************
-* Prototype : sbr_udp_recvdata
-* Description : recv data
-* Input : sbr_socket_t * sk
-* const struct iovec* iov
-* int iovcnt
-* struct spl_netbuf *buf
-* Output : None
-* Return Value : static inline
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline int
-sbr_udp_recvdata (sbr_socket_t * sk, const struct iovec *iov, int iovcnt,
- int flags, struct sockaddr *from, socklen_t * fromlen)
-{
- sbr_com_lock_recv (sk);
- if (-1 == _sbr_udp_recvfrom (sk, NULL, 0, MSG_PEEK, from, fromlen))
- {
- sbr_com_unlock_recv (sk);
- return -1;
- }
-
- struct spl_netbuf *buf = ADDR_SHTOL (sbr_get_fd_share (sk)->lastdata);
- struct spl_pbuf *p = (struct spl_pbuf *) ADDR_SHTOL (buf->p);
- u32 buflen = p->tot_len;
- u32 copylen = 0;
- u32 offset = 0;
-
- int i;
-
- for (i = 0; i < iovcnt; ++i)
- {
- if (!iov[i].iov_base || (0 == iov[i].iov_len))
- {
- continue;
- }
-
- copylen = buflen > iov[i].iov_len ? iov[i].iov_len : buflen;
- if ((copylen > 0)
- && 0 == spl_pbuf_copy_partial (p, iov[i].iov_base, copylen, offset))
- {
- NSSBR_LOGERR ("copy failed]fd=%d", sk->fd);
- goto done;
- }
-
- offset += copylen;
- buflen -= copylen;
-
- if (0 == buflen)
- {
- goto done;
- }
- }
-
-done:
- if (!(flags & MSG_PEEK))
- {
- sbr_get_fd_share (sk)->lastdata = NULL;
- sbr_com_free_recv_buf (sk, (struct spl_pbuf *) ADDR_SHTOL (buf->p));
- }
-
- sbr_com_unlock_recv (sk);
- return offset;
-}
-
-/*****************************************************************************
-* Prototype : sbr_udp_readv
-* Description : readv
-* Input : sbr_socket_t* sk
-* const struct iovec* iov
-* int iovcnt
-* Output : None
-* Return Value : static int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static int
-sbr_udp_readv (sbr_socket_t * sk, const struct iovec *iov, int iovcnt)
-{
- return sbr_udp_recvdata (sk, iov, iovcnt, 0, NULL, NULL);
-}
-
-/*****************************************************************************
-* Prototype : sbr_udp_recvmsg
-* Description : recv msg
-* Input : sbr_socket_t* sk
-* struct msghdr* msg
-* int flags
-* Output : None
-* Return Value : static int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static int
-sbr_udp_recvmsg (sbr_socket_t * sk, struct msghdr *msg, int flags)
-{
- return sbr_udp_recvdata (sk, msg->msg_iov, msg->msg_iovlen, flags,
- (struct sockaddr *) msg->msg_name,
- &msg->msg_namelen);
-}
-
-/*****************************************************************************
-* Prototype : sbr_copy_iov
-* Description : copy iov
-* Input : sbr_socket_t * sk
-* const struct iovec * iov
-* int iovcnt
-* struct spl_pbuf* buf
-* Output : None
-* Return Value : static inline int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline int
-sbr_copy_iov (sbr_socket_t * sk, const struct iovec *iov, int iovcnt,
- struct spl_pbuf *buf)
-{
- u32 buf_left = buf->len;
- i8 *buf_data = (i8 *) ADDR_SHTOL (buf->payload);
- u32 iov_left;
- i8 *iov_data;
- u32 copy_len;
-
- int i;
-
- for (i = 0; i < iovcnt; ++i)
- {
- if (!iov[i].iov_base || (0 == iov[i].iov_len))
- {
- continue;
- }
-
- iov_left = (u32) iov[i].iov_len; /* to u32 is ok,len is checked in sbr_udp_senddata */
- iov_data = (i8 *) iov[i].iov_base;
- while (iov_left)
- {
- copy_len = buf_left > iov_left ? iov_left : buf_left;
-
- if (NULL == common_memcpy (buf_data, iov_data, copy_len))
- {
- NSSBR_LOGERR ("common_memcpy error]fd=%d", sk->fd);
- sbr_set_sk_errno (sk, EFAULT);
- return -1;
- }
-
- buf_data += copy_len;
- buf_left -= copy_len;
- iov_data += copy_len;
- iov_left -= copy_len;
- if (0 == buf_left)
- {
- buf = (struct spl_pbuf *) ADDR_SHTOL (buf->next);
- if (buf)
- {
- buf_left = buf->len;
- buf_data = (i8 *) ADDR_SHTOL (buf->payload);
- }
- else
- {
- return 0;
- }
- }
- }
- }
-
- return 0;
-}
-
-/*****************************************************************************
-* Prototype : sbr_udp_senddata
-* Description : send data
-* Input : sbr_socket_t * sk
-* const struct iovec * iov
-* int iovcnt
-* int flags
-* const struct sockaddr * to
-* socklen_t tolen
-* Output : None
-* Return Value : static inline int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline int
-sbr_udp_senddata (sbr_socket_t * sk, const struct iovec *iov, int iovcnt,
- int flags, const struct sockaddr *to, socklen_t tolen)
-{
- size_t size = 0;
- int iov_idx;
-
- for (iov_idx = 0; iov_idx < iovcnt; ++iov_idx)
- {
- if ((SPL_MAX_UDP_MSG_LEN - size) < iov[iov_idx].iov_len)
- {
- NSSBR_LOGERR
- ("size > SPL_MAX_UDP_MSG_LEN]fd=%d,SPL_MAX_UDP_MSG_LEN=%u",
- sk->fd, SPL_MAX_UDP_MSG_LEN);
- sbr_set_sk_io_errno (sk, EMSGSIZE);
- return -1;
- }
-
- size += iov[iov_idx].iov_len;
- }
-
- if (to == NULL)
- {
- /* if not bind , then dest address should not be NULL */
- if (IPADDR_ANY == ss_get_remote_ip (sbr_get_conn (sk))->addr)
- {
- NSSBR_LOGERR ("dest address is null]fd=%d", sk->fd);
- sbr_set_sk_io_errno (sk, EDESTADDRREQ);
- return -1;
- }
- }
- else if (to->sa_family != AF_INET)
- {
- NSSBR_LOGERR ("invalid address family]fd=%d,family=%d", sk->fd,
- to->sa_family);
- sbr_set_sk_io_errno (sk, EAFNOSUPPORT);
- return -1;
- }
- else if (tolen != sizeof (struct sockaddr_in))
- {
- NSSBR_LOGERR ("invalid address len]fd=%d,tolen=%u", sk->fd, tolen);
- sbr_set_sk_io_errno (sk, EINVAL);
- return -1;
- }
-
- struct spl_netbuf buf;
- const struct sockaddr_in *to_in = (const struct sockaddr_in *) to;
- buf.p = NULL;
- if (to_in)
- {
- NSSBR_LOGDBG ("fd=%d,addr=%s,port=%d,conn=%p,private_data=%p", sk->fd,
- spl_inet_ntoa (to_in->sin_addr), ntohs (to_in->sin_port),
- sbr_get_conn (sk),
- ss_get_private_data (sbr_get_conn (sk)));
- inet_addr_to_ipaddr (&buf.addr, &to_in->sin_addr);
- netbuf_fromport (&buf) = ntohs (to_in->sin_port);
- }
- else
- {
- spl_ip_addr_set_any (&buf.addr);
- netbuf_fromport (&buf) = 0;
- }
-
- spl_ip_addr_t local_ip = { IPADDR_ANY };
-
- int err = ss_get_last_errno (sbr_get_conn (sk));
- if (SPL_ERR_IS_FATAL (err))
- {
- NS_LOG_CTRL (LOG_CTRL_SEND, LOGSBR, "NSSBR", NSLOG_ERR,
- "connection fatal error!err=%d", err);
- sbr_set_sk_errno (sk, sbr_spl_err_to_errno (err));
- return -1;
- }
-
- u16 remain_len = size; //+ head_room_len;
- struct spl_pbuf *p = NULL;
- PRIMARY_ADDR struct spl_pbuf *header = NULL;
- struct spl_pbuf **tail = &header;
- u16 head_len = L2_L3_ROOM_LEN + L4_ROOM_LEN;
- u16 copy_len;
- u16 alloc_len;
-
- do
- {
- copy_len =
- remain_len >
- (SPL_PBUF_UDP_LEN - head_len) ? (SPL_PBUF_UDP_LEN -
- head_len) : remain_len;
- alloc_len = head_len + copy_len;
- p = sbr_malloc_tx_pbuf (alloc_len, head_len);
- if (unlikely (!p))
- {
- NSSBR_LOGDBG ("malloc pbuf failed]fd=%d", sk->fd);
- sbr_set_sk_io_errno (sk, ENOMEM);
- sbr_handle_free_send_buf (sk,
- (struct spl_pbuf *) ADDR_SHTOL (header));
- // ss_set_send_event(sbr_get_conn(sk), 0);
- return -1;
- }
-
- struct spl_pbuf *tmp = (struct spl_pbuf *) ADDR_SHTOL (header);
- while (tmp)
- {
- tmp->tot_len += p->len;
- tmp = (struct spl_pbuf *) ADDR_SHTOL (tmp->next);
- }
-
- *tail = (struct spl_pbuf *) ADDR_LTOSH (p); /* header will changed to share */
- tail = &p->next;
-
- remain_len -= copy_len;
- head_len = L2_L3_ROOM_LEN;
- }
- while (remain_len);
-
- /*udp support len=0 */
- if (size != 0)
- {
- if (sbr_copy_iov
- (sk, iov, iovcnt, (struct spl_pbuf *) ADDR_SHTOL (header)) != 0)
- {
- sbr_handle_free_send_buf (sk,
- (struct spl_pbuf *) ADDR_SHTOL (header));
- return -1;
- }
- }
-
- buf.p = header;
- err = sbr_handle_udp_send (sk, &buf, &local_ip);
- if (0 == err)
- {
- epoll_triggle_event_from_api (sk, EPOLL_API_OP_SEND);
- //ss_set_send_event(sbr_get_conn(sk), 1);
- return size;
- }
- else
- {
- sbr_handle_free_send_buf (sk, (struct spl_pbuf *) ADDR_SHTOL (buf.p));
- return -1;
- }
-
-}
-
-/*****************************************************************************
-* Prototype : sbr_udp_sendto
-* Description : sendto
-* Input : sbr_socket_t * sk
-* const void * data
-* size_t size
-* int flags
-* const struct sockaddr * to
-* socklen_t tolen
-* Output : None
-* Return Value : static int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static int
-sbr_udp_sendto (sbr_socket_t * sk, const void *data, size_t size, int flags,
- const struct sockaddr *to, socklen_t tolen)
-{
- struct iovec iov;
-
- iov.iov_base = (void *) data;
- iov.iov_len = size;
- return sbr_udp_senddata (sk, &iov, 1, flags, to, tolen);
-}
-
-/*****************************************************************************
-* Prototype : sbr_udp_send
-* Description : send
-* Input : sbr_socket_t * sk
-* const void * data
-* size_t size
-* int flags
-* Output : None
-* Return Value : static int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static int
-sbr_udp_send (sbr_socket_t * sk, const void *data, size_t size, int flags)
-{
- return sk->fdopt->sendto (sk, data, size, flags, NULL, 0);
-}
-
-/*****************************************************************************
-* Prototype : sbr_udp_sendmsg
-* Description : send msg
-* Input : sbr_socket_t * sk
-* const struct msghdr * pmsg
-* int flags
-* Output : None
-* Return Value : static int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static int
-sbr_udp_sendmsg (sbr_socket_t * sk, const struct msghdr *pmsg, int flags)
-{
- return sbr_udp_senddata (sk, pmsg->msg_iov, pmsg->msg_iovlen, flags,
- (struct sockaddr *) pmsg->msg_name,
- pmsg->msg_namelen);
-}
-
-/*****************************************************************************
-* Prototype : sbr_udp_writev
-* Description : writev
-* Input : sbr_socket_t * sk
-* const struct iovec * iov
-* int iovcnt
-* Output : None
-* Return Value : static int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static int
-sbr_udp_writev (sbr_socket_t * sk, const struct iovec *iov, int iovcnt)
-{
- return sbr_udp_senddata (sk, iov, iovcnt, 0, NULL, 0);
-}
-
-/*****************************************************************************
-* Prototype : sbr_udp_fcntl
-* Description : fcntl
-* Input : sbr_socket_t * sk
-* int cmd
-* long arg
-* Output : None
-* Return Value : static int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static int
-sbr_udp_fcntl (sbr_socket_t * sk, int cmd, long arg)
-{
- int ret = 0;
-
- switch (cmd)
- {
- case F_GETFL:
- ret = ss_get_nonblock_flag (sbr_get_conn (sk));
- NSSBR_LOGDBG ("F_GETFL]fd=%d,ret=%d", sk->fd, ret);
- break;
- case F_SETFL:
- if (arg & O_NONBLOCK)
- {
- NSSBR_LOGDBG ("F_SETFL set O_NONBLOCK val]fd=%d,arg=%ld", sk->fd,
- arg);
- ss_set_nonblock_flag (sbr_get_conn (sk), (arg & O_NONBLOCK));
- }
- else
- {
- NSSBR_LOGDBG ("F_SETFL clean O_NONBLOCK val]fd=%d,arg=%ld", sk->fd,
- arg);
- ss_set_nonblock_flag (sbr_get_conn (sk), 0);
- }
-
- break;
- default:
- NSSBR_LOGERR ("cmd is not support]fd=%d,cmd=%d", sk->fd, cmd);
- ret = -1;
- sbr_set_sk_errno (sk, EINVAL);
-
- break;
- }
-
- return ret;
-}
-
-/*****************************************************************************
-* Prototype : sbr_udp_ioctl
-* Description : ioctl
-* Input : sbr_socket_t * sk
-* unsigned long cmd
-* void * arg
-* Output : None
-* Return Value : static int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static int
-sbr_udp_ioctl (sbr_socket_t * sk, unsigned long cmd, void *arg)
-{
- int ret = 0;
-
- switch (cmd)
- {
- case FIONREAD:
- {
- if (!sbr_com_try_lock_recv (sk))
- {
- return 0;
- }
-
- struct spl_pbuf *p = NULL;
- struct spl_netbuf *buf = NULL;
- if (!sbr_get_fd_share (sk)->lastdata)
- {
- ret = sbr_udp_recv_from_ring (sk, &buf, -1);
- if (ret != 0)
- {
- sbr_com_unlock_recv (sk);
- return EWOULDBLOCK == errno ? 0 : -1;
- }
-
- sbr_get_fd_share (sk)->lastdata = (void *) ADDR_LTOSH (buf);
- p = (struct spl_pbuf *) ADDR_SHTOL (buf->p);
- }
- else
- {
- buf =
- (struct spl_netbuf *)
- ADDR_SHTOL (sbr_get_fd_share (sk)->lastdata);
- p = (struct spl_pbuf *) ADDR_SHTOL (buf->p);
- }
-
- *((u32 *) arg) = p->tot_len;
- sbr_com_unlock_recv (sk);
- }
- break;
- case FIONBIO:
- {
- u8 val = 0;
-
- if (arg && *(u32 *) arg)
- {
- val = 1;
- }
-
- ss_set_nonblock_flag (sbr_get_conn (sk), val);
- NSSBR_LOGDBG ("FIONBIO]fd=%d,val=%u", sk->fd, val);
- }
- break;
- default:
- {
- NSSBR_LOGERR ("cmd is not support]fd=%d,cmd=%lu", sk->fd, cmd);
- ret = -1;
- sbr_set_sk_errno (sk, ENOTTY);
- }
-
- break;
- }
-
- return ret;
-}
-
-/*****************************************************************************
-* Prototype : sbr_udp_close
-* Description : close
-* Input : sbr_socket_t * sk
-* Output : None
-* Return Value : static int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static int
-sbr_udp_close (sbr_socket_t * sk)
-{
- if (sbr_get_fd_share (sk)->lastdata)
- {
- struct spl_netbuf *buf = ADDR_SHTOL (sbr_get_fd_share (sk)->lastdata);
- struct spl_pbuf *p = (struct spl_pbuf *) ADDR_SHTOL (buf->p);
- sbr_com_free_recv_buf (sk, p);
- }
-
- /* if failed,free it in recycle */
- return sbr_handle_close (sk, 0);
-}
-
-sbr_fdopt udp_fdopt = {
- .socket = sbr_udp_socket,
- .bind = sbr_udp_bind,
- .listen = sbr_udp_listen,
- .accept = sbr_udp_accept,
- .accept4 = sbr_udp_accept4,
- .connect = sbr_udp_connect,
- .shutdown = sbr_udp_shutdown,
- .getsockname = sbr_udp_getsockname,
- .getpeername = sbr_udp_getpeername,
- .getsockopt = sbr_udp_getsockopt,
- .setsockopt = sbr_udp_setsockopt,
- .recvfrom = sbr_udp_recvfrom,
- .readv = sbr_udp_readv,
- .recvmsg = sbr_udp_recvmsg,
- .send = sbr_udp_send,
- .sendto = sbr_udp_sendto,
- .sendmsg = sbr_udp_sendmsg,
- .writev = sbr_udp_writev,
- .fcntl = sbr_udp_fcntl,
- .ioctl = sbr_udp_ioctl,
- .close = sbr_udp_close,
- .peak = sbr_com_peak,
- .lock_common = sbr_com_lock_common,
- .unlock_common = sbr_com_unlock_common,
- .fork_parent = sbr_com_fork_parent,
- .fork_child = sbr_com_fork_child,
- .ep_getevt = stackx_eventpoll_getEvt,
- .ep_ctl = stackx_eventpoll_triggle,
- .set_close_stat = NULL,
-};
diff --git a/stacks/lwip_stack/release/configure/ip_data.json b/stacks/lwip_stack/release/configure/ip_data.json
deleted file mode 100644
index 1d52b77..0000000
--- a/stacks/lwip_stack/release/configure/ip_data.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "ports_list": [
- {
- "port_name": "PortA",
- "ip_cidr": ["192.168.1.207/24"]
- }
- ]
-}
diff --git a/stacks/lwip_stack/release/configure/nStackConfig.json b/stacks/lwip_stack/release/configure/nStackConfig.json
deleted file mode 100644
index 3cc54c5..0000000
--- a/stacks/lwip_stack/release/configure/nStackConfig.json
+++ /dev/null
@@ -1,32 +0,0 @@
-{
-"cfg_seg_socket": [
-{
- "socket_num": 8192,
- "arp_stale_time": 300,
- "arp_bc_retrans_num": 5
-}
-],
-"cfg_seg_log": [
-{
- "run_log_size": 50,
- "run_log_count": 10,
- "mon_log_size": 10,
- "mon_log_count": 10
-}
-],
-"cfg_seg_thread_pri": [
-{
- "comment":"0:SCHED_OTHER, 1:SCHED_FIFO, 2:SCHED_RR",
- "sched_policy": 0,
- "thread_pri": 0
-}
-],
-"cfg_seg_path": [
-{
- "stackpool_log_path": "/var/log/nStack",
- "master_log_path": "/var/log/nStack",
- "nstack_log_path": "/var/log/nStack",
- "dpdk_log_path": "/var/log/nstack-dpdk"
-}
-]
-}
diff --git a/stacks/lwip_stack/release/configure/network_data_tonStack.json b/stacks/lwip_stack/release/configure/network_data_tonStack.json
deleted file mode 100644
index 7b734b0..0000000
--- a/stacks/lwip_stack/release/configure/network_data_tonStack.json
+++ /dev/null
@@ -1,16 +0,0 @@
-[
- {
- "name": "network1",
- "type": "nstack-dpdk",
- "ipam": {
- "subnet": "192.168.1.1/24"
- },
- "args": {
- "phynet": {
- "ref_nic": [
- "eth7"
- ]
- }
- }
- },
-]
diff --git a/stacks/lwip_stack/release/include/nstack_custom_api.h b/stacks/lwip_stack/release/include/nstack_custom_api.h
deleted file mode 100644
index e6cae1e..0000000
--- a/stacks/lwip_stack/release/include/nstack_custom_api.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef __NSTACK_CUSTOM_API_H__
-#define __NSTACK_CUSTOM_API_H__
-
-/*****************************************************************************
-* Prototype : create a custom socket ,when using this type .
-*****************************************************************************/
-#ifndef SOCK_NS_CUSTOM
-#define SOCK_NS_CUSTOM 0xf001
-#endif
-
-/*****************************************************************************
-* Prototype : setsockopt level type
-*****************************************************************************/
-enum
-{
- NSTACK_SOCKOPT = 0xff02
-};
-
-/*****************************************************************************
-* Prototype : setsockopt optname type
-*****************************************************************************/
-enum
-{
- NSTACK_SEM_SLEEP = 0X0001
-};
-#endif
diff --git a/stacks/lwip_stack/release/lwip_helper_files/arch/queue.c b/stacks/lwip_stack/release/lwip_helper_files/arch/queue.c
deleted file mode 100644
index 4916dae..0000000
--- a/stacks/lwip_stack/release/lwip_helper_files/arch/queue.c
+++ /dev/null
@@ -1,120 +0,0 @@
-#include <pthread.h>
-#include "lwip/memp.h"
-#include "lwip/mem.h"
-
-#include "arch/queue.h"
-#include "lwip/sys.h"
-#include "nstack_log.h"
-#include "lwip/sockets.h"
-#include "stackx_spl_share.h"
-#include "lwip/api.h"
-#include "lwip/ip.h"
-#include <netif/sc_dpdk.h>
-
-err_t
-queue_push (queue_t * q, void *pmsg, int isTrypush)
-{
- int pushRet;
- // struct tcpip_msg* _msg = pmsg;
-
- //enum tcpip_msg_type tcpip_type = TCPIP_MSG_MAX;
- //struct new_api_msg* lo_newapimsg = NULL;
- // enum api_msg_type api_type = NEW_MSG_API_MAX;
- // struct netconn *lo_conn = NULL;
- //u64_t tcp_tx_bytes = 0;
- while (1)
- {
- pushRet = nsfw_mem_ring_enqueue (q->llring, pmsg);
-
- switch (pushRet)
- {
-
- case -1:
- NSSOC_LOGERR ("Box range check has failed]llring_a=%p, msg=%p",
- q->llring, pmsg);
- return ERR_MEM;
-
- case 1:
- return ERR_OK;
-
- default:
- if (isTrypush)
- {
- return ERR_MEM;
- }
- else
- {
- continue;
- }
- }
- }
-}
-
-void *
-queue_pop (queue_t * q, u32_t * timeout, int isTryPop)
-{
- void *pmsg;
- int popRet;
- int retVal;
- u32_t ellapsetime = 0;
-// struct tcpip_msg* _msg;
- struct timespec starttm = { 0 };
- struct timespec endtm;
- u32_t timeDiff;
- if (*timeout != 0)
- {
- retVal = clock_gettime (CLOCK_MONOTONIC, &starttm);
- if (0 != retVal)
- {
- NSPOL_LOGERR ("clock_gettime() failed]");
- *timeout = SYS_ARCH_TIMEOUT;
- return NULL;
- }
- }
-
- while (1)
- {
- //TODO:May have to consider, take out the data sharing problem
- popRet = nsfw_mem_ring_dequeue (q->llring, &pmsg);
-
- switch (popRet)
- {
- case 1:
- *timeout = ellapsetime;
- return pmsg;
-
- default:
-
- if (isTryPop)
- {
- *timeout = SYS_ARCH_TIMEOUT;
- return NULL;
- }
- else
- {
- if (*timeout != 0)
- {
- retVal = clock_gettime (CLOCK_MONOTONIC, &endtm);
- if (0 != retVal)
- {
- NSPOL_LOGERR ("clock_gettime() failed]");
- *timeout = SYS_ARCH_TIMEOUT;
- return NULL;
- }
-
- timeDiff = endtm.tv_sec - starttm.tv_sec;
- if (timeDiff > *timeout)
- {
- *timeout = SYS_ARCH_TIMEOUT;
- return NULL;
- }
- sys_sleep_ns (0, 100000);
- }
-
- continue;
- }
-
- }
- }
-
-}
diff --git a/stacks/lwip_stack/release/lwip_helper_files/arch/sys_arch.c b/stacks/lwip_stack/release/lwip_helper_files/arch/sys_arch.c
deleted file mode 100644
index bdda4d2..0000000
--- a/stacks/lwip_stack/release/lwip_helper_files/arch/sys_arch.c
+++ /dev/null
@@ -1,237 +0,0 @@
-#include <sys/queue.h>
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <errno.h>
-#include <stdint.h>
-
-#include <pthread.h>
-#include <sys/time.h>
-#include <time.h>
-#include <linux/sched.h>
-
-#include <asm/unistd.h>
-#include <linux/unistd.h>
-#include <syscall.h>
-
-#include <lwip/sys.h>
-#include <cc.h>
-#include <arch/sys_arch.h>
-#include <arch/queue.h>
-#include "nstack_log.h"
-#include "lwip/sockets.h"
-#include "spl_timers.h"
-#include "nstack_securec.h"
-#include "nstack_share_res.h"
-#include "nstack_log.h"
-
-#include "stackx_spl_share.h"
-#include "lwip/api.h"
-#include "lwip/ip.h"
-#include <netif/sc_dpdk.h>
-#include <netif/sharedmemory.h>
-
-#include "common_mem_common.h"
-#include "common_func.h"
-#include "common_mem_api.h"
-
-#include "mgr_com.h"
-#ifdef HAL_LIB
-#else
-#include "rte_ring.h"
-#endif
-
-#include "timeouts.h"
-
-sys_sem_st g_global_semaphore;
-
-/** Check if an mbox is valid/allocated: return 1 for valid, 0 for invalid */
-int
-sys_mbox_valid (sys_mbox_t * mbox)
-{
- return ((*mbox == SYS_MBOX_NULL) ? 0 : 1);
-}
-
-struct lwip_thread
-{
- void (*func) (void *arg);
- void *arg;
-};
-
-static void *
-lwip_thread_entry (void *arg)
-{
- struct lwip_thread *lt = arg;
-
- lt->func (lt->arg);
-
- free (lt);
- return 0;
-}
-
-/** The only thread function:
- * Creates a new thread
- * @param name human-readable name for the thread (used for debugging purposes)
- * @param thread thread-function
- * @param arg parameter passed to 'thread'
- * @param stacksize stack size in bytes for the new thread (may be ignored by ports)
- * @param prio priority of the new thread (may be ignored by ports) */
-sys_thread_t
-sys_thread_new2 (const char *name, lwip_thread_fn thread, void *arg,
- int stacksize, int prio, int policy)
-{
- pthread_attr_t attr;
- set_thread_attr (&attr, stacksize, prio, policy);
-
- struct lwip_thread *lt = malloc (sizeof (*lt));
- if (lt == NULL)
- {
- NSPOL_LOGERR ("process abort:cannot allocate thread struct");
- abort ();
- }
-
- lt->func = thread;
- lt->arg = arg;
-
- pthread_t t;
- int r = pthread_create (&t, &attr, lwip_thread_entry, lt);
-
- if (r != 0)
- {
- NSPOL_LOGERR ("process abort:lwip:annot create]errno_string=%s",
- strerror (r));
- abort ();
- }
- else
- {
- NSPOL_LOGINF (SC_DPDK_INFO, "]thread_name=%s.", name);
- }
-
- (void) pthread_setname_np (t, name);
-
- return t;
-}
-
-/** The only thread function:
- * Creates a new thread
- * @param name human-readable name for the thread (used for debugging purposes)
- * @param thread thread-function
- * @param arg parameter passed to 'thread'
- * @param stacksize stack size in bytes for the new thread (may be ignored by ports)
- * @param prio priority of the new thread (may be ignored by ports) */
-sys_thread_t
-sys_thread_new (const char *name, lwip_thread_fn thread, void *arg,
- int stacksize, int prio)
-{
- pthread_attr_t attr;
- set_thread_attr (&attr, stacksize, prio, 0);
-
- struct lwip_thread *lt = malloc (sizeof (*lt));
- if (lt == NULL)
- {
- NSPOL_LOGERR ("process abort:cannot allocate thread struct");
- abort ();
- }
-
- lt->func = thread;
- lt->arg = arg;
-
- pthread_t t;
- int r = pthread_create (&t, &attr, lwip_thread_entry, lt);
-
- if (r != 0)
- {
- NSPOL_LOGERR ("process abort:lwip:annot create]errno_string=%s",
- strerror (r));
- abort ();
- }
- else
- {
- NSPOL_LOGINF (SC_DPDK_INFO, "]thread_name=%s.", name);
- }
-
- (void) pthread_setname_np (t, name);
-
- return t;
-}
-
-void
-stackx_global_lock (void)
-{
- sys_arch_lock_with_pid (&g_global_semaphore);
-}
-
-void
-stackx_global_unlock (void)
-{
- sys_sem_s_signal (&g_global_semaphore);
-}
-
-void
-sys_init (void)
-{
- return;
-}
-
-void
-sys_timeouts_mbox_fetch (sys_mbox_t * mbox, void **msg)
-{
- return;
-}
-
-void
-sys_timeout (u32_t msecs, sys_timeout_handler handler, void *arg)
-{
- struct ptimer_node *tmo = arg;
-
- tmo = malloc (sizeof (struct ptimer_node)); /*lint !e586 */
- if (NULL == tmo)
- {
- NSPOL_LOGERR ("malloc ptimer node failed!");
- return;
- }
-
- int ret = MEMSET_S (tmo, sizeof (struct ptimer_node), 0,
- sizeof (struct ptimer_node));
- if (EOK != ret)
- {
- NSPOL_LOGERR ("MEMSET_S failed]ret=%d", ret);
- free (tmo);
- return;
- }
-
- NSPOL_LOGDBG (TIMERS_DEBUG, "alloc]ptimer_node=%p", tmo);
-
- tmo->info.msec = msecs;
- tmo->info._phandle = handler;
- tmo->info.ctx = arg;
- tmo->info.flags = PTIMER_ONESHOT;
- tmo->index = 0;
- regedit_ptimer (SYS_PTIMEROUT_MSG, handler, tmo);
-}
-
-void
-sys_untimeout (sys_timeout_handler handler, void *arg)
-{
- regedit_ptimer (SYS_UNPTIMEROUT_MSG, handler, arg);
- return;
-}
-
-/**
- * Timer callback function that calls mld6_tmr() and reschedules itself.
- *
- * @param arg unused argument
- */
-void
-cyclic_timer (void *arg)
-{
- const struct lwip_cyclic_timer *cyclic =
- (const struct lwip_cyclic_timer *) arg;
-#if LWIP_DEBUG_TIMERNAMES
- LWIP_DEBUGF (TIMERS_DEBUG, ("tcpip: %s()\n", cyclic->handler_name));
-#endif
- cyclic->handler ();
- sys_timeout (cyclic->interval_ms, cyclic_timer, arg);
-}
diff --git a/stacks/lwip_stack/release/lwip_helper_files/core/timeouts.c b/stacks/lwip_stack/release/lwip_helper_files/core/timeouts.c
deleted file mode 100644
index efbda94..0000000
--- a/stacks/lwip_stack/release/lwip_helper_files/core/timeouts.c
+++ /dev/null
@@ -1,527 +0,0 @@
-/**
- * @file
- * Stack-internal timers implementation.
- * This file includes timer callbacks for stack-internal timers as well as
- * functions to set up or stop timers and check for expired timers.
- *
- */
-
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * 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. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
- *
- * This file is part of the lwIP TCP/IP stack.
- *
- * Author: Adam Dunkels <adam@sics.se>
- * Simon Goldschmidt
- *
- */
-
-#include "lwip/opt.h"
-
-#include "lwip/timeouts.h"
-#include "lwip/priv/tcp_priv.h"
-
-#include "lwip/def.h"
-#include "lwip/memp.h"
-#include "lwip/priv/tcpip_priv.h"
-
-#include "lwip/ip4_frag.h"
-#include "lwip/etharp.h"
-#include "lwip/dhcp.h"
-#include "lwip/autoip.h"
-#include "lwip/igmp.h"
-#include "lwip/dns.h"
-#include "lwip/nd6.h"
-#include "lwip/ip6_frag.h"
-#include "lwip/mld6.h"
-#include "lwip/sys.h"
-#include "lwip/pbuf.h"
-
-#if LWIP_DEBUG_TIMERNAMES
-#define HANDLER(x) x, #x
-#else /* LWIP_DEBUG_TIMERNAMES */
-#define HANDLER(x) x
-#endif /* LWIP_DEBUG_TIMERNAMES */
-
-/** This array contains all stack-internal cyclic timers. To get the number of
- * timers, use LWIP_ARRAYSIZE() */
-const struct lwip_cyclic_timer lwip_cyclic_timers[] = {
-#if LWIP_TCP
- /* The TCP timer is a special case: it does not have to run always and
- is triggered to start from TCP using tcp_timer_needed() */
- {TCP_TMR_INTERVAL, HANDLER (tcp_tmr)},
-#endif /* LWIP_TCP */
-#if LWIP_IPV4
-#if IP_REASSEMBLY
- {IP_TMR_INTERVAL, HANDLER (ip_reass_tmr)},
-#endif /* IP_REASSEMBLY */
-#if LWIP_ARP
- {ARP_TMR_INTERVAL, HANDLER (etharp_tmr)},
-#endif /* LWIP_ARP */
-#if LWIP_DHCP
- {DHCP_COARSE_TIMER_MSECS, HANDLER (dhcp_coarse_tmr)},
- {DHCP_FINE_TIMER_MSECS, HANDLER (dhcp_fine_tmr)},
-#endif /* LWIP_DHCP */
-#if LWIP_AUTOIP
- {AUTOIP_TMR_INTERVAL, HANDLER (autoip_tmr)},
-#endif /* LWIP_AUTOIP */
-#if LWIP_IGMP
- {IGMP_TMR_INTERVAL, HANDLER (igmp_tmr)},
-#endif /* LWIP_IGMP */
-#endif /* LWIP_IPV4 */
-#if LWIP_DNS
- {DNS_TMR_INTERVAL, HANDLER (dns_tmr)},
-#endif /* LWIP_DNS */
-#if LWIP_IPV6
- {ND6_TMR_INTERVAL, HANDLER (nd6_tmr)},
-#if LWIP_IPV6_REASS
- {IP6_REASS_TMR_INTERVAL, HANDLER (ip6_reass_tmr)},
-#endif /* LWIP_IPV6_REASS */
-#if LWIP_IPV6_MLD
- {MLD6_TMR_INTERVAL, HANDLER (mld6_tmr)},
-#endif /* LWIP_IPV6_MLD */
-#endif /* LWIP_IPV6 */
-};
-
-#if LWIP_TIMERS && !LWIP_TIMERS_CUSTOM
-
-/** The one and only timeout list */
-static struct sys_timeo *next_timeout;
-static u32_t timeouts_last_time;
-
-#if LWIP_TCP
-/** global variable that shows if the tcp timer is currently scheduled or not */
-static int tcpip_tcp_timer_active;
-
-/**
- * Timer callback function that calls tcp_tmr() and reschedules itself.
- *
- * @param arg unused argument
- */
-static void
-tcpip_tcp_timer (void *arg)
-{
- LWIP_UNUSED_ARG (arg);
-
- /* call TCP timer handler */
- tcp_tmr ();
- /* timer still needed? */
- if (tcp_active_pcbs || tcp_tw_pcbs)
- {
- /* restart timer */
- sys_timeout (TCP_TMR_INTERVAL, tcpip_tcp_timer, NULL);
- }
- else
- {
- /* disable timer */
- tcpip_tcp_timer_active = 0;
- }
-}
-
-/**
- * Called from TCP_REG when registering a new PCB:
- * the reason is to have the TCP timer only running when
- * there are active (or time-wait) PCBs.
- */
-void
-tcp_timer_needed (void)
-{
- /* timer is off but needed again? */
- if (!tcpip_tcp_timer_active && (tcp_active_pcbs || tcp_tw_pcbs))
- {
- /* enable and start timer */
- tcpip_tcp_timer_active = 1;
- sys_timeout (TCP_TMR_INTERVAL, tcpip_tcp_timer, NULL);
- }
-}
-#endif /* LWIP_TCP */
-
-/**
- * Timer callback function that calls mld6_tmr() and reschedules itself.
- *
- * @param arg unused argument
- */
-static void
-cyclic_timer (void *arg)
-{
- const struct lwip_cyclic_timer *cyclic =
- (const struct lwip_cyclic_timer *) arg;
-#if LWIP_DEBUG_TIMERNAMES
- LWIP_DEBUGF (TIMERS_DEBUG, ("tcpip: %s()\n", cyclic->handler_name));
-#endif
- cyclic->handler ();
- sys_timeout (cyclic->interval_ms, cyclic_timer, arg);
-}
-
-/** Initialize this module */
-void
-sys_timeouts_init (void)
-{
- size_t i;
- /* tcp_tmr() at index 0 is started on demand */
- for (i = (LWIP_TCP ? 1 : 0); i < LWIP_ARRAYSIZE (lwip_cyclic_timers); i++)
- {
- /* we have to cast via size_t to get rid of const warning
- (this is OK as cyclic_timer() casts back to const* */
- sys_timeout (lwip_cyclic_timers[i].interval_ms, cyclic_timer,
- LWIP_CONST_CAST (void *, &lwip_cyclic_timers[i]));
- }
-
- /* Initialise timestamp for sys_check_timeouts */
- timeouts_last_time = sys_now ();
-}
-
-/**
- * Create a one-shot timer (aka timeout). Timeouts are processed in the
- * following cases:
- * - while waiting for a message using sys_timeouts_mbox_fetch()
- * - by calling sys_check_timeouts() (NO_SYS==1 only)
- *
- * @param msecs time in milliseconds after that the timer should expire
- * @param handler callback function to call when msecs have elapsed
- * @param arg argument to pass to the callback function
- */
-#if LWIP_DEBUG_TIMERNAMES
-void
-sys_timeout_debug (u32_t msecs, sys_timeout_handler handler, void *arg,
- const char *handler_name)
-#else /* LWIP_DEBUG_TIMERNAMES */
-void
-sys_timeout (u32_t msecs, sys_timeout_handler handler, void *arg)
-#endif /* LWIP_DEBUG_TIMERNAMES */
-{
- struct sys_timeo *timeout, *t;
- u32_t now, diff;
-
- timeout = (struct sys_timeo *) memp_malloc (MEMP_SYS_TIMEOUT);
- if (timeout == NULL)
- {
- LWIP_ASSERT
- ("sys_timeout: timeout != NULL, pool MEMP_SYS_TIMEOUT is empty",
- timeout != NULL);
- return;
- }
-
- now = sys_now ();
- if (next_timeout == NULL)
- {
- diff = 0;
- timeouts_last_time = now;
- }
- else
- {
- diff = now - timeouts_last_time;
- }
-
- timeout->next = NULL;
- timeout->h = handler;
- timeout->arg = arg;
- timeout->time = msecs + diff;
-#if LWIP_DEBUG_TIMERNAMES
- timeout->handler_name = handler_name;
- LWIP_DEBUGF (TIMERS_DEBUG,
- ("sys_timeout: %p msecs=%" U32_F " handler=%s arg=%p\n",
- (void *) timeout, msecs, handler_name, (void *) arg));
-#endif /* LWIP_DEBUG_TIMERNAMES */
-
- if (next_timeout == NULL)
- {
- next_timeout = timeout;
- return;
- }
-
- if (next_timeout->time > msecs)
- {
- next_timeout->time -= msecs;
- timeout->next = next_timeout;
- next_timeout = timeout;
- }
- else
- {
- for (t = next_timeout; t != NULL; t = t->next)
- {
- timeout->time -= t->time;
- if (t->next == NULL || t->next->time > timeout->time)
- {
- if (t->next != NULL)
- {
- t->next->time -= timeout->time;
- }
- else if (timeout->time > msecs)
- {
- /* If this is the case, 'timeouts_last_time' and 'now' differs too much.
- This can be due to sys_check_timeouts() not being called at the right
- times, but also when stopping in a breakpoint. Anyway, let's assume
- this is not wanted, so add the first timer's time instead of 'diff' */
- timeout->time = msecs + next_timeout->time;
- }
- timeout->next = t->next;
- t->next = timeout;
- break;
- }
- }
- }
-}
-
-/**
- * Go through timeout list (for this task only) and remove the first matching
- * entry (subsequent entries remain untouched), even though the timeout has not
- * triggered yet.
- *
- * @param handler callback function that would be called by the timeout
- * @param arg callback argument that would be passed to handler
-*/
-void
-sys_untimeout (sys_timeout_handler handler, void *arg)
-{
- struct sys_timeo *prev_t, *t;
-
- if (next_timeout == NULL)
- {
- return;
- }
-
- for (t = next_timeout, prev_t = NULL; t != NULL; prev_t = t, t = t->next)
- {
- if ((t->h == handler) && (t->arg == arg))
- {
- /* We have a match */
- /* Unlink from previous in list */
- if (prev_t == NULL)
- {
- next_timeout = t->next;
- }
- else
- {
- prev_t->next = t->next;
- }
- /* If not the last one, add time of this one back to next */
- if (t->next != NULL)
- {
- t->next->time += t->time;
- }
- memp_free (MEMP_SYS_TIMEOUT, t);
- return;
- }
- }
- return;
-}
-
-/**
- * @ingroup lwip_nosys
- * Handle timeouts for NO_SYS==1 (i.e. without using
- * tcpip_thread/sys_timeouts_mbox_fetch(). Uses sys_now() to call timeout
- * handler functions when timeouts expire.
- *
- * Must be called periodically from your main loop.
- */
-#if !NO_SYS && !defined __DOXYGEN__
-static
-#endif /* !NO_SYS */
- void
-sys_check_timeouts (void)
-{
- if (next_timeout)
- {
- struct sys_timeo *tmptimeout;
- u32_t diff;
- sys_timeout_handler handler;
- void *arg;
- u8_t had_one;
- u32_t now;
-
- now = sys_now ();
- /* this cares for wraparounds */
- diff = now - timeouts_last_time;
- do
- {
- PBUF_CHECK_FREE_OOSEQ ();
- had_one = 0;
- tmptimeout = next_timeout;
- if (tmptimeout && (tmptimeout->time <= diff))
- {
- /* timeout has expired */
- had_one = 1;
- timeouts_last_time += tmptimeout->time;
- diff -= tmptimeout->time;
- next_timeout = tmptimeout->next;
- handler = tmptimeout->h;
- arg = tmptimeout->arg;
-#if LWIP_DEBUG_TIMERNAMES
- if (handler != NULL)
- {
- LWIP_DEBUGF (TIMERS_DEBUG, ("sct calling h=%s arg=%p\n",
- tmptimeout->handler_name, arg));
- }
-#endif /* LWIP_DEBUG_TIMERNAMES */
- memp_free (MEMP_SYS_TIMEOUT, tmptimeout);
- if (handler != NULL)
- {
-#if !NO_SYS
- /* For LWIP_TCPIP_CORE_LOCKING, lock the core before calling the
- timeout handler function. */
- LOCK_TCPIP_CORE ();
-#endif /* !NO_SYS */
- handler (arg);
-#if !NO_SYS
- UNLOCK_TCPIP_CORE ();
-#endif /* !NO_SYS */
- }
- LWIP_TCPIP_THREAD_ALIVE ();
- }
- /* repeat until all expired timers have been called */
- }
- while (had_one);
- }
-}
-
-/** Set back the timestamp of the last call to sys_check_timeouts()
- * This is necessary if sys_check_timeouts() hasn't been called for a long
- * time (e.g. while saving energy) to prevent all timer functions of that
- * period being called.
- */
-void
-sys_restart_timeouts (void)
-{
- timeouts_last_time = sys_now ();
-}
-
-/** Return the time left before the next timeout is due. If no timeouts are
- * enqueued, returns 0xffffffff
- */
-#if !NO_SYS
-static
-#endif /* !NO_SYS */
- u32_t
-sys_timeouts_sleeptime (void)
-{
- u32_t diff;
- if (next_timeout == NULL)
- {
- return 0xffffffff;
- }
- diff = sys_now () - timeouts_last_time;
- if (diff > next_timeout->time)
- {
- return 0;
- }
- else
- {
- return next_timeout->time - diff;
- }
-}
-
-#if !NO_SYS
-
-/**
- * Wait (forever) for a message to arrive in an mbox.
- * While waiting, timeouts are processed.
- *
- * @param mbox the mbox to fetch the message from
- * @param msg the place to store the message
- */
-void
-sys_timeouts_mbox_fetch (sys_mbox_t * mbox, void **msg)
-{
- u32_t sleeptime;
-
-again:
- if (!next_timeout)
- {
- sys_arch_mbox_fetch (mbox, msg, 0);
- return;
- }
-
- sleeptime = sys_timeouts_sleeptime ();
- if (sleeptime == 0
- || sys_arch_mbox_fetch (mbox, msg, sleeptime) == SYS_ARCH_TIMEOUT)
- {
- /* If a SYS_ARCH_TIMEOUT value is returned, a timeout occurred
- before a message could be fetched. */
- sys_check_timeouts ();
- /* We try again to fetch a message from the mbox. */
- goto again;
- }
-}
-
-#endif /* NO_SYS */
-
-#else /* LWIP_TIMERS && !LWIP_TIMERS_CUSTOM */
-/* Satisfy the TCP code which calls this function */
-static int tcpip_tcp_timer_active;
-
-void
-tcp_timer_needed (void)
-{
- /* timer is off but needed again? */
- if (!tcpip_tcp_timer_active && (tcp_active_pcbs || tcp_tw_pcbs))
- {
- /* enable and start timer */
- tcpip_tcp_timer_active = 1;
- sys_timeout (TCP_TMR_INTERVAL, tcpip_tcp_timer, NULL);
- }
-}
-
-/**
- * Timer callback function that calls tcp_tmr() and reschedules itself.
- *
- * @param arg unused argument
- */
-void
-tcpip_tcp_timer (void *arg)
-{
- LWIP_UNUSED_ARG (arg);
-
- /* call TCP timer handler */
- tcp_tmr ();
- /* timer still needed? */
- if (tcp_active_pcbs || tcp_tw_pcbs)
- {
- /* restart timer */
- sys_timeout (TCP_TMR_INTERVAL, tcpip_tcp_timer, NULL);
- }
- else
- {
- /* disable timer */
- tcpip_tcp_timer_active = 0;
- }
-}
-
-void
-sys_timeouts_init (void)
-{
- size_t i;
- /* tcp_tmr() at index 0 is started on demand */
- for (i = (LWIP_TCP ? 1 : 0); i < LWIP_ARRAYSIZE (lwip_cyclic_timers); i++)
- {
- /* we have to cast via size_t to get rid of const warning
- (this is OK as cyclic_timer() casts back to const* */
- sys_timeout (lwip_cyclic_timers[i].interval_ms, cyclic_timer,
- LWIP_CONST_CAST (void *, &lwip_cyclic_timers[i]));
- }
-}
-
-#endif /* LWIP_TIMERS && !LWIP_TIMERS_CUSTOM */
diff --git a/stacks/lwip_stack/release/lwip_helper_files/download_lwip.sh b/stacks/lwip_stack/release/lwip_helper_files/download_lwip.sh
deleted file mode 100755
index bbb8afb..0000000
--- a/stacks/lwip_stack/release/lwip_helper_files/download_lwip.sh
+++ /dev/null
@@ -1,35 +0,0 @@
-#########################################################################
-# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-# 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.
-#########################################################################
-#!/bin/bash -x
-
-set -x
-
-SCRIPT_DIR=$(dirname "$0")
-echo $SCRIPT_DIR
-LWIP_DOWNLOAD_DIR="${SCRIPT_DIR}/../../lwip_src/"
-echo $LWIP_DOWNLOAD_DIR
-if [ ! -d "${LWIP_DOWNLOAD_DIR}/lwip/" ]; then
- mkdir -p ${LWIP_DOWNLOAD_DIR}/lwip/
- cd ${LWIP_DOWNLOAD_DIR}/
- wget -N --no-check-certificate http://download-mirror.savannah.nongnu.org/releases/lwip/lwip-2.0.3.zip
- unzip ${LWIP_DOWNLOAD_DIR}/lwip-2.0.3.zip "lwip-2.0.3/src/*" -d ${LWIP_DOWNLOAD_DIR}/lwip
- mv ${LWIP_DOWNLOAD_DIR}/lwip/lwip-2.0.3/src/* ${LWIP_DOWNLOAD_DIR}/lwip/
- rm -rf ${LWIP_DOWNLOAD_DIR}/lwip/lwip-2.0.3/
- cp -r ${SCRIPT_DIR}/arch/ ${LWIP_DOWNLOAD_DIR}/lwip/
- cp -r ${SCRIPT_DIR}/lwip/arch/ ${LWIP_DOWNLOAD_DIR}/lwip/include/lwip/
- cp -r ${SCRIPT_DIR}/core/* ${LWIP_DOWNLOAD_DIR}/lwip/core/
- cp -r ${SCRIPT_DIR}/include/* ${LWIP_DOWNLOAD_DIR}/lwip/include/lwip/
- mv ${LWIP_DOWNLOAD_DIR}/lwip/include/lwip/errno.h ${LWIP_DOWNLOAD_DIR}/lwip/include/lwip/lwip_errno.h
-fi
diff --git a/stacks/lwip_stack/release/lwip_helper_files/include/lwipopts.h b/stacks/lwip_stack/release/lwip_helper_files/include/lwipopts.h
deleted file mode 100644
index 46c4af2..0000000
--- a/stacks/lwip_stack/release/lwip_helper_files/include/lwipopts.h
+++ /dev/null
@@ -1,47 +0,0 @@
-#ifndef LWIP_LWIPOPTS_H
-#define LWIP_LWIPOPTS_H
-
-#define RING_CACHE_SIZE 1024
-#define LISTEN_CACHE_SIZE 1024
-#define RECV_MAX_POOL 4
-#define MAX_TRY_GET_MEMORY_TIMES 4
-#define MAX_MEMORY_USED_SIZE 80
-
-#define IP_HLEN 20
-#define TCP_HLEN 20
-#define TCP_MAX_OPTION_LEN 40
-
-#define _cache_aligned __attribute__((__aligned__(64)))
-#define LWIP_NETIF_API 1
-
-#define TCP_OVERSIZE 1
-#define LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS
-#define SYS_LIGHTWEIGHT_PROT 1
-#define LWIP_DISABLE_TCP_SANITY_CHECKS 1
-#define LWIP_COMPAT_MUTEX_ALLOWED 1
-#define LWIP_ERRNO_INCLUDE <errno.h>
-#define LWIP_SKIP_PACKING_CHECK 1
-#define PBUF_POOL_FREE_OOSEQ 0
-
-#define LWIP_DEBUG 1
-#define LWIP_TIMERS 0
-#define LWIP_TIMERS_CUSTOM 1
-#define LWIP_TCPIP_CORE_LOCKING 1
-#define MEM_LIBC_MALLOC 1
-#define MEMP_MEM_MALLOC 1
-#define LWIP_CALLBACK_API 1
-#define LWIP_SOCKET 0
-#define LWIP_POSIX_SOCKETS_IO_NAMES 0
-#define LWIP_TCP_KEEPALIVE 1
-#define LWIP_TIMEVAL_PRIVATE 0
-#define LWIP_COMPAT_MUTEX 1
-#ifdef TCP_MSS
-#undef TCP_MSS
-#endif
-#define TCP_MSS 1460
-#define TCP_WND (20 * TCP_MSS)
-#define TCP_SND_BUF (10 * TCP_MSS)
-#define TCP_SND_QUEUELEN ((20 * (TCP_SND_BUF) + (TCP_MSS - 1))/(TCP_MSS))
-#define LWIP_WND_SCALE 1
-#define TCP_RCV_SCALE 7
-#endif
diff --git a/stacks/lwip_stack/release/lwip_helper_files/include/opt.h b/stacks/lwip_stack/release/lwip_helper_files/include/opt.h
deleted file mode 100644
index 040e9cf..0000000
--- a/stacks/lwip_stack/release/lwip_helper_files/include/opt.h
+++ /dev/null
@@ -1,2875 +0,0 @@
-/**
- * @file
- *
- * lwIP Options Configuration
- */
-
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * 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. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
- *
- * This file is part of the lwIP TCP/IP stack.
- *
- * Author: Adam Dunkels <adam@sics.se>
- *
- */
-
-/*
- * NOTE: || defined __DOXYGEN__ is a workaround for doxygen bug -
- * without this, doxygen does not see the actual #define
- */
-
-#if !defined LWIP_HDR_OPT_H
-#define LWIP_HDR_OPT_H
-
-/*
- * Include user defined options first. Anything not defined in these files
- * will be set to standard values. Override anything you don't like!
- */
-#include "lwipopts.h"
-#include "lwip/debug.h"
-
-/**
- * @defgroup lwip_opts Options (lwipopts.h)
- * @ingroup lwip
- *
- * @defgroup lwip_opts_debug Debugging
- * @ingroup lwip_opts
- *
- * @defgroup lwip_opts_infrastructure Infrastructure
- * @ingroup lwip_opts
- *
- * @defgroup lwip_opts_callback Callback-style APIs
- * @ingroup lwip_opts
- *
- * @defgroup lwip_opts_threadsafe_apis Thread-safe APIs
- * @ingroup lwip_opts
- */
-
- /*
- ------------------------------------
- -------------- NO SYS --------------
- ------------------------------------
- */
-/**
- * @defgroup lwip_opts_nosys NO_SYS
- * @ingroup lwip_opts_infrastructure
- * @{
- */
-/**
- * NO_SYS==1: Use lwIP without OS-awareness (no thread, semaphores, mutexes or
- * mboxes). This means threaded APIs cannot be used (socket, netconn,
- * i.e. everything in the 'api' folder), only the callback-style raw API is
- * available (and you have to watch out for yourself that you don't access
- * lwIP functions/structures from more than one context at a time!)
- */
-#if !defined NO_SYS || defined __DOXYGEN__
-#define NO_SYS 0
-#endif
-/**
- * @}
- */
-
-/**
- * @defgroup lwip_opts_timers Timers
- * @ingroup lwip_opts_infrastructure
- * @{
- */
-/**
- * LWIP_TIMERS==0: Drop support for sys_timeout and lwip-internal cyclic timers.
- * (the array of lwip-internal cyclic timers is still provided)
- * (check NO_SYS_NO_TIMERS for compatibility to old versions)
- */
-#if !defined LWIP_TIMERS || defined __DOXYGEN__
-#ifdef NO_SYS_NO_TIMERS
-#define LWIP_TIMERS (!NO_SYS || (NO_SYS && !NO_SYS_NO_TIMERS))
-#else
-#define LWIP_TIMERS 1
-#endif
-#endif
-
-/**
- * LWIP_TIMERS_CUSTOM==1: Provide your own timer implementation.
- * Function prototypes in timeouts.h and the array of lwip-internal cyclic timers
- * are still included, but the implementation is not. The following functions
- * will be required: sys_timeouts_init(), sys_timeout(), sys_untimeout(),
- * sys_timeouts_mbox_fetch()
- */
-#if !defined LWIP_TIMERS_CUSTOM || defined __DOXYGEN__
-#define LWIP_TIMERS_CUSTOM 0
-#endif
-/**
- * @}
- */
-
-/**
- * @defgroup lwip_opts_memcpy memcpy
- * @ingroup lwip_opts_infrastructure
- * @{
- */
-/**
- * MEMCPY: override this if you have a faster implementation at hand than the
- * one included in your C library
- */
-#if !defined MEMCPY || defined __DOXYGEN__
-#define MEMCPY(dst,src,len) memcpy(dst,src,len)
-#endif
-
-/**
- * SMEMCPY: override this with care! Some compilers (e.g. gcc) can inline a
- * call to memcpy() if the length is known at compile time and is small.
- */
-#if !defined SMEMCPY || defined __DOXYGEN__
-#define SMEMCPY(dst,src,len) memcpy(dst,src,len)
-#endif
-/**
- * @}
- */
-
-/*
- ------------------------------------
- ----------- Core locking -----------
- ------------------------------------
-*/
-/**
- * @defgroup lwip_opts_lock Core locking and MPU
- * @ingroup lwip_opts_infrastructure
- * @{
- */
-/**
- * LWIP_MPU_COMPATIBLE: enables special memory management mechanism
- * which makes lwip able to work on MPU (Memory Protection Unit) system
- * by not passing stack-pointers to other threads
- * (this decreases performance as memory is allocated from pools instead
- * of keeping it on the stack)
- */
-#if !defined LWIP_MPU_COMPATIBLE || defined __DOXYGEN__
-#define LWIP_MPU_COMPATIBLE 0
-#endif
-
-/**
- * LWIP_TCPIP_CORE_LOCKING
- * Creates a global mutex that is held during TCPIP thread operations.
- * Can be locked by client code to perform lwIP operations without changing
- * into TCPIP thread using callbacks. See LOCK_TCPIP_CORE() and
- * UNLOCK_TCPIP_CORE().
- * Your system should provide mutexes supporting priority inversion to use this.
- */
-#if !defined LWIP_TCPIP_CORE_LOCKING || defined __DOXYGEN__
-#define LWIP_TCPIP_CORE_LOCKING 1
-#endif
-
-/**
- * LWIP_TCPIP_CORE_LOCKING_INPUT: when LWIP_TCPIP_CORE_LOCKING is enabled,
- * this lets tcpip_input() grab the mutex for input packets as well,
- * instead of allocating a message and passing it to tcpip_thread.
- *
- * ATTENTION: this does not work when tcpip_input() is called from
- * interrupt context!
- */
-#if !defined LWIP_TCPIP_CORE_LOCKING_INPUT || defined __DOXYGEN__
-#define LWIP_TCPIP_CORE_LOCKING_INPUT 0
-#endif
-
-/**
- * SYS_LIGHTWEIGHT_PROT==1: enable inter-task protection (and task-vs-interrupt
- * protection) for certain critical regions during buffer allocation, deallocation
- * and memory allocation and deallocation.
- * ATTENTION: This is required when using lwIP from more than one context! If
- * you disable this, you must be sure what you are doing!
- */
-#if !defined SYS_LIGHTWEIGHT_PROT || defined __DOXYGEN__
-#define SYS_LIGHTWEIGHT_PROT 1
-#endif
-/**
- * @}
- */
-
-/*
- ------------------------------------
- ---------- Memory options ----------
- ------------------------------------
-*/
-/**
- * @defgroup lwip_opts_mem Heap and memory pools
- * @ingroup lwip_opts_infrastructure
- * @{
- */
-/**
- * MEM_LIBC_MALLOC==1: Use malloc/free/realloc provided by your C-library
- * instead of the lwip internal allocator. Can save code size if you
- * already use it.
- */
-#if !defined MEM_LIBC_MALLOC || defined __DOXYGEN__
-#define MEM_LIBC_MALLOC 0
-#endif
-
-/**
- * MEMP_MEM_MALLOC==1: Use mem_malloc/mem_free instead of the lwip pool allocator.
- * Especially useful with MEM_LIBC_MALLOC but handle with care regarding execution
- * speed (heap alloc can be much slower than pool alloc) and usage from interrupts
- * (especially if your netif driver allocates PBUF_POOL pbufs for received frames
- * from interrupt)!
- * ATTENTION: Currently, this uses the heap for ALL pools (also for private pools,
- * not only for internal pools defined in memp_std.h)!
- */
-#if !defined MEMP_MEM_MALLOC || defined __DOXYGEN__
-#define MEMP_MEM_MALLOC 0
-#endif
-
-/**
- * MEM_ALIGNMENT: should be set to the alignment of the CPU
- * 4 byte alignment -> \#define MEM_ALIGNMENT 4
- * 2 byte alignment -> \#define MEM_ALIGNMENT 2
- */
-#if !defined MEM_ALIGNMENT || defined __DOXYGEN__
-#define MEM_ALIGNMENT 1
-#endif
-
-/**
- * MEM_SIZE: the size of the heap memory. If the application will send
- * a lot of data that needs to be copied, this should be set high.
- */
-#if !defined MEM_SIZE || defined __DOXYGEN__
-#define MEM_SIZE 1600
-#endif
-
-/**
- * MEMP_OVERFLOW_CHECK: memp overflow protection reserves a configurable
- * amount of bytes before and after each memp element in every pool and fills
- * it with a prominent default value.
- * MEMP_OVERFLOW_CHECK == 0 no checking
- * MEMP_OVERFLOW_CHECK == 1 checks each element when it is freed
- * MEMP_OVERFLOW_CHECK >= 2 checks each element in every pool every time
- * memp_malloc() or memp_free() is called (useful but slow!)
- */
-#if !defined MEMP_OVERFLOW_CHECK || defined __DOXYGEN__
-#define MEMP_OVERFLOW_CHECK 0
-#endif
-
-/**
- * MEMP_SANITY_CHECK==1: run a sanity check after each memp_free() to make
- * sure that there are no cycles in the linked lists.
- */
-#if !defined MEMP_SANITY_CHECK || defined __DOXYGEN__
-#define MEMP_SANITY_CHECK 0
-#endif
-
-/**
- * MEM_USE_POOLS==1: Use an alternative to malloc() by allocating from a set
- * of memory pools of various sizes. When mem_malloc is called, an element of
- * the smallest pool that can provide the length needed is returned.
- * To use this, MEMP_USE_CUSTOM_POOLS also has to be enabled.
- */
-#if !defined MEM_USE_POOLS || defined __DOXYGEN__
-#define MEM_USE_POOLS 0
-#endif
-
-/**
- * MEM_USE_POOLS_TRY_BIGGER_POOL==1: if one malloc-pool is empty, try the next
- * bigger pool - WARNING: THIS MIGHT WASTE MEMORY but it can make a system more
- * reliable. */
-#if !defined MEM_USE_POOLS_TRY_BIGGER_POOL || defined __DOXYGEN__
-#define MEM_USE_POOLS_TRY_BIGGER_POOL 0
-#endif
-
-/**
- * MEMP_USE_CUSTOM_POOLS==1: whether to include a user file lwippools.h
- * that defines additional pools beyond the "standard" ones required
- * by lwIP. If you set this to 1, you must have lwippools.h in your
- * include path somewhere.
- */
-#if !defined MEMP_USE_CUSTOM_POOLS || defined __DOXYGEN__
-#define MEMP_USE_CUSTOM_POOLS 0
-#endif
-
-/**
- * Set this to 1 if you want to free PBUF_RAM pbufs (or call mem_free()) from
- * interrupt context (or another context that doesn't allow waiting for a
- * semaphore).
- * If set to 1, mem_malloc will be protected by a semaphore and SYS_ARCH_PROTECT,
- * while mem_free will only use SYS_ARCH_PROTECT. mem_malloc SYS_ARCH_UNPROTECTs
- * with each loop so that mem_free can run.
- *
- * ATTENTION: As you can see from the above description, this leads to dis-/
- * enabling interrupts often, which can be slow! Also, on low memory, mem_malloc
- * can need longer.
- *
- * If you don't want that, at least for NO_SYS=0, you can still use the following
- * functions to enqueue a deallocation call which then runs in the tcpip_thread
- * context:
- * - pbuf_free_callback(p);
- * - mem_free_callback(m);
- */
-#if !defined LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT || defined __DOXYGEN__
-#define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 0
-#endif
-/**
- * @}
- */
-
-/*
- ------------------------------------------------
- ---------- Internal Memory Pool Sizes ----------
- ------------------------------------------------
-*/
-/**
- * @defgroup lwip_opts_memp Internal memory pools
- * @ingroup lwip_opts_infrastructure
- * @{
- */
-/**
- * MEMP_NUM_PBUF: the number of memp struct pbufs (used for PBUF_ROM and PBUF_REF).
- * If the application sends a lot of data out of ROM (or other static memory),
- * this should be set high.
- */
-#if !defined MEMP_NUM_PBUF || defined __DOXYGEN__
-#define MEMP_NUM_PBUF 16
-#endif
-
-/**
- * MEMP_NUM_RAW_PCB: Number of raw connection PCBs
- * (requires the LWIP_RAW option)
- */
-#if !defined MEMP_NUM_RAW_PCB || defined __DOXYGEN__
-#define MEMP_NUM_RAW_PCB 4
-#endif
-
-/**
- * MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
- * per active UDP "connection".
- * (requires the LWIP_UDP option)
- */
-#if !defined MEMP_NUM_UDP_PCB || defined __DOXYGEN__
-#define MEMP_NUM_UDP_PCB 4
-#endif
-
-/**
- * MEMP_NUM_TCP_PCB: the number of simultaneously active TCP connections.
- * (requires the LWIP_TCP option)
- */
-#if !defined MEMP_NUM_TCP_PCB || defined __DOXYGEN__
-#define MEMP_NUM_TCP_PCB 5
-#endif
-
-/**
- * MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP connections.
- * (requires the LWIP_TCP option)
- */
-#if !defined MEMP_NUM_TCP_PCB_LISTEN || defined __DOXYGEN__
-#define MEMP_NUM_TCP_PCB_LISTEN 8
-#endif
-
-/**
- * MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP segments.
- * (requires the LWIP_TCP option)
- */
-#if !defined MEMP_NUM_TCP_SEG || defined __DOXYGEN__
-#define MEMP_NUM_TCP_SEG 16
-#endif
-
-/**
- * MEMP_NUM_REASSDATA: the number of IP packets simultaneously queued for
- * reassembly (whole packets, not fragments!)
- */
-#if !defined MEMP_NUM_REASSDATA || defined __DOXYGEN__
-#define MEMP_NUM_REASSDATA 5
-#endif
-
-/**
- * MEMP_NUM_FRAG_PBUF: the number of IP fragments simultaneously sent
- * (fragments, not whole packets!).
- * This is only used with LWIP_NETIF_TX_SINGLE_PBUF==0 and only has to be > 1
- * with DMA-enabled MACs where the packet is not yet sent when netif->output
- * returns.
- */
-#if !defined MEMP_NUM_FRAG_PBUF || defined __DOXYGEN__
-#define MEMP_NUM_FRAG_PBUF 15
-#endif
-
-/**
- * MEMP_NUM_ARP_QUEUE: the number of simultaneously queued outgoing
- * packets (pbufs) that are waiting for an ARP request (to resolve
- * their destination address) to finish.
- * (requires the ARP_QUEUEING option)
- */
-#if !defined MEMP_NUM_ARP_QUEUE || defined __DOXYGEN__
-#define MEMP_NUM_ARP_QUEUE 30
-#endif
-
-/**
- * MEMP_NUM_IGMP_GROUP: The number of multicast groups whose network interfaces
- * can be members at the same time (one per netif - allsystems group -, plus one
- * per netif membership).
- * (requires the LWIP_IGMP option)
- */
-#if !defined MEMP_NUM_IGMP_GROUP || defined __DOXYGEN__
-#define MEMP_NUM_IGMP_GROUP 8
-#endif
-
-/**
- * MEMP_NUM_SYS_TIMEOUT: the number of simultaneously active timeouts.
- * The default number of timeouts is calculated here for all enabled modules.
- * The formula expects settings to be either '0' or '1'.
- */
-#if !defined MEMP_NUM_SYS_TIMEOUT || defined __DOXYGEN__
-#define MEMP_NUM_SYS_TIMEOUT (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + (PPP_SUPPORT*6*MEMP_NUM_PPP_PCB) + (LWIP_IPV6 ? (1 + LWIP_IPV6_REASS + LWIP_IPV6_MLD) : 0))
-#endif
-
-/**
- * MEMP_NUM_NETBUF: the number of struct netbufs.
- * (only needed if you use the sequential API, like api_lib.c)
- */
-#if !defined MEMP_NUM_NETBUF || defined __DOXYGEN__
-#define MEMP_NUM_NETBUF 2
-#endif
-
-/**
- * MEMP_NUM_NETCONN: the number of struct netconns.
- * (only needed if you use the sequential API, like api_lib.c)
- */
-#if !defined MEMP_NUM_NETCONN || defined __DOXYGEN__
-#define MEMP_NUM_NETCONN 4
-#endif
-
-/**
- * MEMP_NUM_TCPIP_MSG_API: the number of struct tcpip_msg, which are used
- * for callback/timeout API communication.
- * (only needed if you use tcpip.c)
- */
-#if !defined MEMP_NUM_TCPIP_MSG_API || defined __DOXYGEN__
-#define MEMP_NUM_TCPIP_MSG_API 8
-#endif
-
-/**
- * MEMP_NUM_TCPIP_MSG_INPKT: the number of struct tcpip_msg, which are used
- * for incoming packets.
- * (only needed if you use tcpip.c)
- */
-#if !defined MEMP_NUM_TCPIP_MSG_INPKT || defined __DOXYGEN__
-#define MEMP_NUM_TCPIP_MSG_INPKT 8
-#endif
-
-/**
- * MEMP_NUM_NETDB: the number of concurrently running lwip_addrinfo() calls
- * (before freeing the corresponding memory using lwip_freeaddrinfo()).
- */
-#if !defined MEMP_NUM_NETDB || defined __DOXYGEN__
-#define MEMP_NUM_NETDB 1
-#endif
-
-/**
- * MEMP_NUM_LOCALHOSTLIST: the number of host entries in the local host list
- * if DNS_LOCAL_HOSTLIST_IS_DYNAMIC==1.
- */
-#if !defined MEMP_NUM_LOCALHOSTLIST || defined __DOXYGEN__
-#define MEMP_NUM_LOCALHOSTLIST 1
-#endif
-
-/**
- * PBUF_POOL_SIZE: the number of buffers in the pbuf pool.
- */
-#if !defined PBUF_POOL_SIZE || defined __DOXYGEN__
-#define PBUF_POOL_SIZE 16
-#endif
-
-/** MEMP_NUM_API_MSG: the number of concurrently active calls to various
- * socket, netconn, and tcpip functions
- */
-#if !defined MEMP_NUM_API_MSG || defined __DOXYGEN__
-#define MEMP_NUM_API_MSG MEMP_NUM_TCPIP_MSG_API
-#endif
-
-/** MEMP_NUM_DNS_API_MSG: the number of concurrently active calls to netconn_gethostbyname
- */
-#if !defined MEMP_NUM_DNS_API_MSG || defined __DOXYGEN__
-#define MEMP_NUM_DNS_API_MSG MEMP_NUM_TCPIP_MSG_API
-#endif
-
-/** MEMP_NUM_SOCKET_SETGETSOCKOPT_DATA: the number of concurrently active calls
- * to getsockopt/setsockopt
- */
-#if !defined MEMP_NUM_SOCKET_SETGETSOCKOPT_DATA || defined __DOXYGEN__
-#define MEMP_NUM_SOCKET_SETGETSOCKOPT_DATA MEMP_NUM_TCPIP_MSG_API
-#endif
-
-/** MEMP_NUM_NETIFAPI_MSG: the number of concurrently active calls to the
- * netifapi functions
- */
-#if !defined MEMP_NUM_NETIFAPI_MSG || defined __DOXYGEN__
-#define MEMP_NUM_NETIFAPI_MSG MEMP_NUM_TCPIP_MSG_API
-#endif
-/**
- * @}
- */
-
-/*
- ---------------------------------
- ---------- ARP options ----------
- ---------------------------------
-*/
-/**
- * @defgroup lwip_opts_arp ARP
- * @ingroup lwip_opts_ipv4
- * @{
- */
-/**
- * LWIP_ARP==1: Enable ARP functionality.
- */
-#if !defined LWIP_ARP || defined __DOXYGEN__
-#define LWIP_ARP 1
-#endif
-
-/**
- * ARP_TABLE_SIZE: Number of active MAC-IP address pairs cached.
- */
-#if !defined ARP_TABLE_SIZE || defined __DOXYGEN__
-#define ARP_TABLE_SIZE 10
-#endif
-
-/** the time an ARP entry stays valid after its last update,
- * for ARP_TMR_INTERVAL = 1000, this is
- * (60 * 5) seconds = 5 minutes.
- */
-#if !defined ARP_MAXAGE || defined __DOXYGEN__
-#define ARP_MAXAGE 300
-#endif
-
-/**
- * ARP_QUEUEING==1: Multiple outgoing packets are queued during hardware address
- * resolution. By default, only the most recent packet is queued per IP address.
- * This is sufficient for most protocols and mainly reduces TCP connection
- * startup time. Set this to 1 if you know your application sends more than one
- * packet in a row to an IP address that is not in the ARP cache.
- */
-#if !defined ARP_QUEUEING || defined __DOXYGEN__
-#define ARP_QUEUEING 0
-#endif
-
-/** The maximum number of packets which may be queued for each
- * unresolved address by other network layers. Defaults to 3, 0 means disabled.
- * Old packets are dropped, new packets are queued.
- */
-#if !defined ARP_QUEUE_LEN || defined __DOXYGEN__
-#define ARP_QUEUE_LEN 3
-#endif
-
-/**
- * ETHARP_SUPPORT_VLAN==1: support receiving and sending ethernet packets with
- * VLAN header. See the description of LWIP_HOOK_VLAN_CHECK and
- * LWIP_HOOK_VLAN_SET hooks to check/set VLAN headers.
- * Additionally, you can define ETHARP_VLAN_CHECK to an u16_t VLAN ID to check.
- * If ETHARP_VLAN_CHECK is defined, only VLAN-traffic for this VLAN is accepted.
- * If ETHARP_VLAN_CHECK is not defined, all traffic is accepted.
- * Alternatively, define a function/define ETHARP_VLAN_CHECK_FN(eth_hdr, vlan)
- * that returns 1 to accept a packet or 0 to drop a packet.
- */
-#if !defined ETHARP_SUPPORT_VLAN || defined __DOXYGEN__
-#define ETHARP_SUPPORT_VLAN 0
-#endif
-
-/** LWIP_ETHERNET==1: enable ethernet support even though ARP might be disabled
- */
-#if !defined LWIP_ETHERNET || defined __DOXYGEN__
-#define LWIP_ETHERNET LWIP_ARP
-#endif
-
-/** ETH_PAD_SIZE: number of bytes added before the ethernet header to ensure
- * alignment of payload after that header. Since the header is 14 bytes long,
- * without this padding e.g. addresses in the IP header will not be aligned
- * on a 32-bit boundary, so setting this to 2 can speed up 32-bit-platforms.
- */
-#if !defined ETH_PAD_SIZE || defined __DOXYGEN__
-#define ETH_PAD_SIZE 0
-#endif
-
-/** ETHARP_SUPPORT_STATIC_ENTRIES==1: enable code to support static ARP table
- * entries (using etharp_add_static_entry/etharp_remove_static_entry).
- */
-#if !defined ETHARP_SUPPORT_STATIC_ENTRIES || defined __DOXYGEN__
-#define ETHARP_SUPPORT_STATIC_ENTRIES 0
-#endif
-
-/** ETHARP_TABLE_MATCH_NETIF==1: Match netif for ARP table entries.
- * If disabled, duplicate IP address on multiple netifs are not supported
- * (but this should only occur for AutoIP).
- */
-#if !defined ETHARP_TABLE_MATCH_NETIF || defined __DOXYGEN__
-#define ETHARP_TABLE_MATCH_NETIF 0
-#endif
-/**
- * @}
- */
-
-/*
- --------------------------------
- ---------- IP options ----------
- --------------------------------
-*/
-/**
- * @defgroup lwip_opts_ipv4 IPv4
- * @ingroup lwip_opts
- * @{
- */
-/**
- * LWIP_IPV4==1: Enable IPv4
- */
-#if !defined LWIP_IPV4 || defined __DOXYGEN__
-#define LWIP_IPV4 1
-#endif
-
-/**
- * IP_FORWARD==1: Enables the ability to forward IP packets across network
- * interfaces. If you are going to run lwIP on a device with only one network
- * interface, define this to 0.
- */
-#if !defined IP_FORWARD || defined __DOXYGEN__
-#define IP_FORWARD 0
-#endif
-
-/**
- * IP_REASSEMBLY==1: Reassemble incoming fragmented IP packets. Note that
- * this option does not affect outgoing packet sizes, which can be controlled
- * via IP_FRAG.
- */
-#if !defined IP_REASSEMBLY || defined __DOXYGEN__
-#define IP_REASSEMBLY 1
-#endif
-
-/**
- * IP_FRAG==1: Fragment outgoing IP packets if their size exceeds MTU. Note
- * that this option does not affect incoming packet sizes, which can be
- * controlled via IP_REASSEMBLY.
- */
-#if !defined IP_FRAG || defined __DOXYGEN__
-#define IP_FRAG 1
-#endif
-
-#if !LWIP_IPV4
-/* disable IPv4 extensions when IPv4 is disabled */
-#undef IP_FORWARD
-#define IP_FORWARD 0
-#undef IP_REASSEMBLY
-#define IP_REASSEMBLY 0
-#undef IP_FRAG
-#define IP_FRAG 0
-#endif /* !LWIP_IPV4 */
-
-/**
- * IP_OPTIONS_ALLOWED: Defines the behavior for IP options.
- * IP_OPTIONS_ALLOWED==0: All packets with IP options are dropped.
- * IP_OPTIONS_ALLOWED==1: IP options are allowed (but not parsed).
- */
-#if !defined IP_OPTIONS_ALLOWED || defined __DOXYGEN__
-#define IP_OPTIONS_ALLOWED 1
-#endif
-
-/**
- * IP_REASS_MAXAGE: Maximum time (in multiples of IP_TMR_INTERVAL - so seconds, normally)
- * a fragmented IP packet waits for all fragments to arrive. If not all fragments arrived
- * in this time, the whole packet is discarded.
- */
-#if !defined IP_REASS_MAXAGE || defined __DOXYGEN__
-#define IP_REASS_MAXAGE 3
-#endif
-
-/**
- * IP_REASS_MAX_PBUFS: Total maximum amount of pbufs waiting to be reassembled.
- * Since the received pbufs are enqueued, be sure to configure
- * PBUF_POOL_SIZE > IP_REASS_MAX_PBUFS so that the stack is still able to receive
- * packets even if the maximum amount of fragments is enqueued for reassembly!
- */
-#if !defined IP_REASS_MAX_PBUFS || defined __DOXYGEN__
-#define IP_REASS_MAX_PBUFS 10
-#endif
-
-/**
- * IP_DEFAULT_TTL: Default value for Time-To-Live used by transport layers.
- */
-#if !defined IP_DEFAULT_TTL || defined __DOXYGEN__
-#define IP_DEFAULT_TTL 255
-#endif
-
-/**
- * IP_SOF_BROADCAST=1: Use the SOF_BROADCAST field to enable broadcast
- * filter per pcb on udp and raw send operations. To enable broadcast filter
- * on recv operations, you also have to set IP_SOF_BROADCAST_RECV=1.
- */
-#if !defined IP_SOF_BROADCAST || defined __DOXYGEN__
-#define IP_SOF_BROADCAST 0
-#endif
-
-/**
- * IP_SOF_BROADCAST_RECV (requires IP_SOF_BROADCAST=1) enable the broadcast
- * filter on recv operations.
- */
-#if !defined IP_SOF_BROADCAST_RECV || defined __DOXYGEN__
-#define IP_SOF_BROADCAST_RECV 0
-#endif
-
-/**
- * IP_FORWARD_ALLOW_TX_ON_RX_NETIF==1: allow ip_forward() to send packets back
- * out on the netif where it was received. This should only be used for
- * wireless networks.
- * ATTENTION: When this is 1, make sure your netif driver correctly marks incoming
- * link-layer-broadcast/multicast packets as such using the corresponding pbuf flags!
- */
-#if !defined IP_FORWARD_ALLOW_TX_ON_RX_NETIF || defined __DOXYGEN__
-#define IP_FORWARD_ALLOW_TX_ON_RX_NETIF 0
-#endif
-
-/**
- * LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS==1: randomize the local port for the first
- * local TCP/UDP pcb (default==0). This can prevent creating predictable port
- * numbers after booting a device.
- */
-#if !defined LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS || defined __DOXYGEN__
-#define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 0
-#endif
-/**
- * @}
- */
-
-/*
- ----------------------------------
- ---------- ICMP options ----------
- ----------------------------------
-*/
-/**
- * @defgroup lwip_opts_icmp ICMP
- * @ingroup lwip_opts_ipv4
- * @{
- */
-/**
- * LWIP_ICMP==1: Enable ICMP module inside the IP stack.
- * Be careful, disable that make your product non-compliant to RFC1122
- */
-#if !defined LWIP_ICMP || defined __DOXYGEN__
-#define LWIP_ICMP 1
-#endif
-
-/**
- * ICMP_TTL: Default value for Time-To-Live used by ICMP packets.
- */
-#if !defined ICMP_TTL || defined __DOXYGEN__
-#define ICMP_TTL (IP_DEFAULT_TTL)
-#endif
-
-/**
- * LWIP_BROADCAST_PING==1: respond to broadcast pings (default is unicast only)
- */
-#if !defined LWIP_BROADCAST_PING || defined __DOXYGEN__
-#define LWIP_BROADCAST_PING 0
-#endif
-
-/**
- * LWIP_MULTICAST_PING==1: respond to multicast pings (default is unicast only)
- */
-#if !defined LWIP_MULTICAST_PING || defined __DOXYGEN__
-#define LWIP_MULTICAST_PING 0
-#endif
-/**
- * @}
- */
-
-/*
- ---------------------------------
- ---------- RAW options ----------
- ---------------------------------
-*/
-/**
- * @defgroup lwip_opts_raw RAW
- * @ingroup lwip_opts_callback
- * @{
- */
-/**
- * LWIP_RAW==1: Enable application layer to hook into the IP layer itself.
- */
-#if !defined LWIP_RAW || defined __DOXYGEN__
-#define LWIP_RAW 0
-#endif
-
-/**
- * LWIP_RAW==1: Enable application layer to hook into the IP layer itself.
- */
-#if !defined RAW_TTL || defined __DOXYGEN__
-#define RAW_TTL (IP_DEFAULT_TTL)
-#endif
-/**
- * @}
- */
-
-/*
- ----------------------------------
- ---------- DHCP options ----------
- ----------------------------------
-*/
-/**
- * @defgroup lwip_opts_dhcp DHCP
- * @ingroup lwip_opts_ipv4
- * @{
- */
-/**
- * LWIP_DHCP==1: Enable DHCP module.
- */
-#if !defined LWIP_DHCP || defined __DOXYGEN__
-#define LWIP_DHCP 0
-#endif
-#if !LWIP_IPV4
-/* disable DHCP when IPv4 is disabled */
-#undef LWIP_DHCP
-#define LWIP_DHCP 0
-#endif /* !LWIP_IPV4 */
-
-/**
- * DHCP_DOES_ARP_CHECK==1: Do an ARP check on the offered address.
- */
-#if !defined DHCP_DOES_ARP_CHECK || defined __DOXYGEN__
-#define DHCP_DOES_ARP_CHECK ((LWIP_DHCP) && (LWIP_ARP))
-#endif
-
-/**
- * LWIP_DHCP_CHECK_LINK_UP==1: dhcp_start() only really starts if the netif has
- * NETIF_FLAG_LINK_UP set in its flags. As this is only an optimization and
- * netif drivers might not set this flag, the default is off. If enabled,
- * netif_set_link_up() must be called to continue dhcp starting.
- */
-#if !defined LWIP_DHCP_CHECK_LINK_UP
-#define LWIP_DHCP_CHECK_LINK_UP 0
-#endif
-
-/**
- * LWIP_DHCP_BOOTP_FILE==1: Store offered_si_addr and boot_file_name.
- */
-#if !defined LWIP_DHCP_BOOTP_FILE || defined __DOXYGEN__
-#define LWIP_DHCP_BOOTP_FILE 0
-#endif
-
-/**
- * LWIP_DHCP_GETS_NTP==1: Request NTP servers with discover/select. For each
- * response packet, an callback is called, which has to be provided by the port:
- * void dhcp_set_ntp_servers(u8_t num_ntp_servers, ip_addr_t* ntp_server_addrs);
-*/
-#if !defined LWIP_DHCP_GET_NTP_SRV || defined __DOXYGEN__
-#define LWIP_DHCP_GET_NTP_SRV 0
-#endif
-
-/**
- * The maximum of NTP servers requested
- */
-#if !defined LWIP_DHCP_MAX_NTP_SERVERS || defined __DOXYGEN__
-#define LWIP_DHCP_MAX_NTP_SERVERS 1
-#endif
-
-/**
- * LWIP_DHCP_MAX_DNS_SERVERS > 0: Request DNS servers with discover/select.
- * DHCP servers received in the response are passed to DNS via @ref dns_setserver()
- * (up to the maximum limit defined here).
- */
-#if !defined LWIP_DHCP_MAX_DNS_SERVERS || defined __DOXYGEN__
-#define LWIP_DHCP_MAX_DNS_SERVERS DNS_MAX_SERVERS
-#endif
-/**
- * @}
- */
-
-/*
- ------------------------------------
- ---------- AUTOIP options ----------
- ------------------------------------
-*/
-/**
- * @defgroup lwip_opts_autoip AUTOIP
- * @ingroup lwip_opts_ipv4
- * @{
- */
-/**
- * LWIP_AUTOIP==1: Enable AUTOIP module.
- */
-#if !defined LWIP_AUTOIP || defined __DOXYGEN__
-#define LWIP_AUTOIP 0
-#endif
-#if !LWIP_IPV4
-/* disable AUTOIP when IPv4 is disabled */
-#undef LWIP_AUTOIP
-#define LWIP_AUTOIP 0
-#endif /* !LWIP_IPV4 */
-
-/**
- * LWIP_DHCP_AUTOIP_COOP==1: Allow DHCP and AUTOIP to be both enabled on
- * the same interface at the same time.
- */
-#if !defined LWIP_DHCP_AUTOIP_COOP || defined __DOXYGEN__
-#define LWIP_DHCP_AUTOIP_COOP 0
-#endif
-
-/**
- * LWIP_DHCP_AUTOIP_COOP_TRIES: Set to the number of DHCP DISCOVER probes
- * that should be sent before falling back on AUTOIP (the DHCP client keeps
- * running in this case). This can be set as low as 1 to get an AutoIP address
- * very quickly, but you should be prepared to handle a changing IP address
- * when DHCP overrides AutoIP.
- */
-#if !defined LWIP_DHCP_AUTOIP_COOP_TRIES || defined __DOXYGEN__
-#define LWIP_DHCP_AUTOIP_COOP_TRIES 9
-#endif
-/**
- * @}
- */
-
-/*
- ----------------------------------
- ----- SNMP MIB2 support -----
- ----------------------------------
-*/
-/**
- * @defgroup lwip_opts_mib2 SNMP MIB2 callbacks
- * @ingroup lwip_opts_infrastructure
- * @{
- */
-/**
- * LWIP_MIB2_CALLBACKS==1: Turn on SNMP MIB2 callbacks.
- * Turn this on to get callbacks needed to implement MIB2.
- * Usually MIB2_STATS should be enabled, too.
- */
-#if !defined LWIP_MIB2_CALLBACKS || defined __DOXYGEN__
-#define LWIP_MIB2_CALLBACKS 0
-#endif
-/**
- * @}
- */
-
-/*
- ----------------------------------
- ----- Multicast/IGMP options -----
- ----------------------------------
-*/
-/**
- * @defgroup lwip_opts_igmp IGMP
- * @ingroup lwip_opts_ipv4
- * @{
- */
-/**
- * LWIP_IGMP==1: Turn on IGMP module.
- */
-#if !defined LWIP_IGMP || defined __DOXYGEN__
-#define LWIP_IGMP 0
-#endif
-#if !LWIP_IPV4
-#undef LWIP_IGMP
-#define LWIP_IGMP 0
-#endif
-
-/**
- * LWIP_MULTICAST_TX_OPTIONS==1: Enable multicast TX support like the socket options
- * IP_MULTICAST_TTL/IP_MULTICAST_IF/IP_MULTICAST_LOOP
- */
-#if !defined LWIP_MULTICAST_TX_OPTIONS || defined __DOXYGEN__
-#define LWIP_MULTICAST_TX_OPTIONS (LWIP_IGMP && LWIP_UDP)
-#endif
-/**
- * @}
- */
-
-/*
- ----------------------------------
- ---------- DNS options -----------
- ----------------------------------
-*/
-/**
- * @defgroup lwip_opts_dns DNS
- * @ingroup lwip_opts_callback
- * @{
- */
-/**
- * LWIP_DNS==1: Turn on DNS module. UDP must be available for DNS
- * transport.
- */
-#if !defined LWIP_DNS || defined __DOXYGEN__
-#define LWIP_DNS 0
-#endif
-
-/** DNS maximum number of entries to maintain locally. */
-#if !defined DNS_TABLE_SIZE || defined __DOXYGEN__
-#define DNS_TABLE_SIZE 4
-#endif
-
-/** DNS maximum host name length supported in the name table. */
-#if !defined DNS_MAX_NAME_LENGTH || defined __DOXYGEN__
-#define DNS_MAX_NAME_LENGTH 256
-#endif
-
-/** The maximum of DNS servers
- * The first server can be initialized automatically by defining
- * DNS_SERVER_ADDRESS(ipaddr), where 'ipaddr' is an 'ip_addr_t*'
- */
-#if !defined DNS_MAX_SERVERS || defined __DOXYGEN__
-#define DNS_MAX_SERVERS 2
-#endif
-
-/** DNS do a name checking between the query and the response. */
-#if !defined DNS_DOES_NAME_CHECK || defined __DOXYGEN__
-#define DNS_DOES_NAME_CHECK 1
-#endif
-
-/** LWIP_DNS_SECURE: controls the security level of the DNS implementation
- * Use all DNS security features by default.
- * This is overridable but should only be needed by very small targets
- * or when using against non standard DNS servers. */
-#if !defined LWIP_DNS_SECURE || defined __DOXYGEN__
-#define LWIP_DNS_SECURE (LWIP_DNS_SECURE_RAND_XID | LWIP_DNS_SECURE_NO_MULTIPLE_OUTSTANDING | LWIP_DNS_SECURE_RAND_SRC_PORT)
-#endif
-
-/* A list of DNS security features follows */
-#define LWIP_DNS_SECURE_RAND_XID 1
-#define LWIP_DNS_SECURE_NO_MULTIPLE_OUTSTANDING 2
-#define LWIP_DNS_SECURE_RAND_SRC_PORT 4
-
-/** DNS_LOCAL_HOSTLIST: Implements a local host-to-address list. If enabled, you have to define an initializer:
- * \#define DNS_LOCAL_HOSTLIST_INIT {DNS_LOCAL_HOSTLIST_ELEM("host_ip4", IPADDR4_INIT_BYTES(1,2,3,4)), \
- * DNS_LOCAL_HOSTLIST_ELEM("host_ip6", IPADDR6_INIT_HOST(123, 234, 345, 456)}
- *
- * Instead, you can also use an external function:
- * \#define DNS_LOOKUP_LOCAL_EXTERN(x) extern err_t my_lookup_function(const char *name, ip_addr_t *addr, u8_t dns_addrtype)
- * that looks up the IP address and returns ERR_OK if found (LWIP_DNS_ADDRTYPE_xxx is passed in dns_addrtype).
- */
-#if !defined DNS_LOCAL_HOSTLIST || defined __DOXYGEN__
-#define DNS_LOCAL_HOSTLIST 0
-#endif /* DNS_LOCAL_HOSTLIST */
-
-/** If this is turned on, the local host-list can be dynamically changed
- * at runtime. */
-#if !defined DNS_LOCAL_HOSTLIST_IS_DYNAMIC || defined __DOXYGEN__
-#define DNS_LOCAL_HOSTLIST_IS_DYNAMIC 0
-#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
-
-/** Set this to 1 to enable querying ".local" names via mDNS
- * using a One-Shot Multicast DNS Query */
-#if !defined LWIP_DNS_SUPPORT_MDNS_QUERIES || defined __DOXYGEN__
-#define LWIP_DNS_SUPPORT_MDNS_QUERIES 0
-#endif
-/**
- * @}
- */
-
-/*
- ---------------------------------
- ---------- UDP options ----------
- ---------------------------------
-*/
-/**
- * @defgroup lwip_opts_udp UDP
- * @ingroup lwip_opts_callback
- * @{
- */
-/**
- * LWIP_UDP==1: Turn on UDP.
- */
-#if !defined LWIP_UDP || defined __DOXYGEN__
-#define LWIP_UDP 1
-#endif
-
-/**
- * LWIP_UDPLITE==1: Turn on UDP-Lite. (Requires LWIP_UDP)
- */
-#if !defined LWIP_UDPLITE || defined __DOXYGEN__
-#define LWIP_UDPLITE 0
-#endif
-
-/**
- * UDP_TTL: Default Time-To-Live value.
- */
-#if !defined UDP_TTL || defined __DOXYGEN__
-#define UDP_TTL (IP_DEFAULT_TTL)
-#endif
-
-/**
- * LWIP_NETBUF_RECVINFO==1: append destination addr and port to every netbuf.
- */
-#if !defined LWIP_NETBUF_RECVINFO || defined __DOXYGEN__
-#define LWIP_NETBUF_RECVINFO 0
-#endif
-/**
- * @}
- */
-
-/*
- ---------------------------------
- ---------- TCP options ----------
- ---------------------------------
-*/
-/**
- * @defgroup lwip_opts_tcp TCP
- * @ingroup lwip_opts_callback
- * @{
- */
-/**
- * LWIP_TCP==1: Turn on TCP.
- */
-#if !defined LWIP_TCP || defined __DOXYGEN__
-#define LWIP_TCP 1
-#endif
-
-/**
- * TCP_TTL: Default Time-To-Live value.
- */
-#if !defined TCP_TTL || defined __DOXYGEN__
-#define TCP_TTL (IP_DEFAULT_TTL)
-#endif
-
-/**
- * TCP_WND: The size of a TCP window. This must be at least
- * (2 * TCP_MSS) for things to work well.
- * ATTENTION: when using TCP_RCV_SCALE, TCP_WND is the total size
- * with scaling applied. Maximum window value in the TCP header
- * will be TCP_WND >> TCP_RCV_SCALE
- */
-#if !defined TCP_WND || defined __DOXYGEN__
-#define TCP_WND (4 * TCP_MSS)
-#endif
-
-/**
- * TCP_MAXRTX: Maximum number of retransmissions of data segments.
- */
-#if !defined TCP_MAXRTX || defined __DOXYGEN__
-#define TCP_MAXRTX 12
-#endif
-
-/**
- * TCP_SYNMAXRTX: Maximum number of retransmissions of SYN segments.
- */
-#if !defined TCP_SYNMAXRTX || defined __DOXYGEN__
-#define TCP_SYNMAXRTX 6
-#endif
-
-/**
- * TCP_QUEUE_OOSEQ==1: TCP will queue segments that arrive out of order.
- * Define to 0 if your device is low on memory.
- */
-#if !defined TCP_QUEUE_OOSEQ || defined __DOXYGEN__
-#define TCP_QUEUE_OOSEQ (LWIP_TCP)
-#endif
-
-/**
- * TCP_MSS: TCP Maximum segment size. (default is 536, a conservative default,
- * you might want to increase this.)
- * For the receive side, this MSS is advertised to the remote side
- * when opening a connection. For the transmit size, this MSS sets
- * an upper limit on the MSS advertised by the remote host.
- */
-#if !defined TCP_MSS || defined __DOXYGEN__
-#define TCP_MSS 536
-#endif
-
-/**
- * TCP_CALCULATE_EFF_SEND_MSS: "The maximum size of a segment that TCP really
- * sends, the 'effective send MSS,' MUST be the smaller of the send MSS (which
- * reflects the available reassembly buffer size at the remote host) and the
- * largest size permitted by the IP layer" (RFC 1122)
- * Setting this to 1 enables code that checks TCP_MSS against the MTU of the
- * netif used for a connection and limits the MSS if it would be too big otherwise.
- */
-#if !defined TCP_CALCULATE_EFF_SEND_MSS || defined __DOXYGEN__
-#define TCP_CALCULATE_EFF_SEND_MSS 1
-#endif
-
-/**
- * TCP_SND_BUF: TCP sender buffer space (bytes).
- * To achieve good performance, this should be at least 2 * TCP_MSS.
- */
-#if !defined TCP_SND_BUF || defined __DOXYGEN__
-#define TCP_SND_BUF (2 * TCP_MSS)
-#endif
-
-/**
- * TCP_SND_QUEUELEN: TCP sender buffer space (pbufs). This must be at least
- * as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work.
- */
-#if !defined TCP_SND_QUEUELEN || defined __DOXYGEN__
-#define TCP_SND_QUEUELEN ((4 * (TCP_SND_BUF) + (TCP_MSS - 1))/(TCP_MSS))
-#endif
-
-/**
- * TCP_SNDLOWAT: TCP writable space (bytes). This must be less than
- * TCP_SND_BUF. It is the amount of space which must be available in the
- * TCP snd_buf for select to return writable (combined with TCP_SNDQUEUELOWAT).
- */
-#if !defined TCP_SNDLOWAT || defined __DOXYGEN__
-#define TCP_SNDLOWAT LWIP_MIN(LWIP_MAX(((TCP_SND_BUF)/2), (2 * TCP_MSS) + 1), (TCP_SND_BUF) - 1)
-#endif
-
-/**
- * TCP_SNDQUEUELOWAT: TCP writable bufs (pbuf count). This must be less
- * than TCP_SND_QUEUELEN. If the number of pbufs queued on a pcb drops below
- * this number, select returns writable (combined with TCP_SNDLOWAT).
- */
-#if !defined TCP_SNDQUEUELOWAT || defined __DOXYGEN__
-#define TCP_SNDQUEUELOWAT LWIP_MAX(((TCP_SND_QUEUELEN)/2), 5)
-#endif
-
-/**
- * TCP_OOSEQ_MAX_BYTES: The maximum number of bytes queued on ooseq per pcb.
- * Default is 0 (no limit). Only valid for TCP_QUEUE_OOSEQ==1.
- */
-#if !defined TCP_OOSEQ_MAX_BYTES || defined __DOXYGEN__
-#define TCP_OOSEQ_MAX_BYTES 0
-#endif
-
-/**
- * TCP_OOSEQ_MAX_PBUFS: The maximum number of pbufs queued on ooseq per pcb.
- * Default is 0 (no limit). Only valid for TCP_QUEUE_OOSEQ==1.
- */
-#if !defined TCP_OOSEQ_MAX_PBUFS || defined __DOXYGEN__
-#define TCP_OOSEQ_MAX_PBUFS 0
-#endif
-
-/**
- * TCP_LISTEN_BACKLOG: Enable the backlog option for tcp listen pcb.
- */
-#if !defined TCP_LISTEN_BACKLOG || defined __DOXYGEN__
-#define TCP_LISTEN_BACKLOG 0
-#endif
-
-/**
- * The maximum allowed backlog for TCP listen netconns.
- * This backlog is used unless another is explicitly specified.
- * 0xff is the maximum (u8_t).
- */
-#if !defined TCP_DEFAULT_LISTEN_BACKLOG || defined __DOXYGEN__
-#define TCP_DEFAULT_LISTEN_BACKLOG 0xff
-#endif
-
-/**
- * TCP_OVERSIZE: The maximum number of bytes that tcp_write may
- * allocate ahead of time in an attempt to create shorter pbuf chains
- * for transmission. The meaningful range is 0 to TCP_MSS. Some
- * suggested values are:
- *
- * 0: Disable oversized allocation. Each tcp_write() allocates a new
- pbuf (old behaviour).
- * 1: Allocate size-aligned pbufs with minimal excess. Use this if your
- * scatter-gather DMA requires aligned fragments.
- * 128: Limit the pbuf/memory overhead to 20%.
- * TCP_MSS: Try to create unfragmented TCP packets.
- * TCP_MSS/4: Try to create 4 fragments or less per TCP packet.
- */
-#if !defined TCP_OVERSIZE || defined __DOXYGEN__
-#define TCP_OVERSIZE TCP_MSS
-#endif
-
-/**
- * LWIP_TCP_TIMESTAMPS==1: support the TCP timestamp option.
- * The timestamp option is currently only used to help remote hosts, it is not
- * really used locally. Therefore, it is only enabled when a TS option is
- * received in the initial SYN packet from a remote host.
- */
-#if !defined LWIP_TCP_TIMESTAMPS || defined __DOXYGEN__
-#define LWIP_TCP_TIMESTAMPS 0
-#endif
-
-/**
- * TCP_WND_UPDATE_THRESHOLD: difference in window to trigger an
- * explicit window update
- */
-#if !defined TCP_WND_UPDATE_THRESHOLD || defined __DOXYGEN__
-#define TCP_WND_UPDATE_THRESHOLD LWIP_MIN((TCP_WND / 4), (TCP_MSS * 4))
-#endif
-
-/**
- * LWIP_EVENT_API and LWIP_CALLBACK_API: Only one of these should be set to 1.
- * LWIP_EVENT_API==1: The user defines lwip_tcp_event() to receive all
- * events (accept, sent, etc) that happen in the system.
- * LWIP_CALLBACK_API==1: The PCB callback function is called directly
- * for the event. This is the default.
- */
-#if !defined(LWIP_EVENT_API) && !defined(LWIP_CALLBACK_API) || defined __DOXYGEN__
-#define LWIP_EVENT_API 0
-#define LWIP_CALLBACK_API 1
-#else
-#ifndef LWIP_EVENT_API
-#define LWIP_EVENT_API 0
-#endif
-#ifndef LWIP_CALLBACK_API
-#define LWIP_CALLBACK_API 0
-#endif
-#endif
-
-/**
- * LWIP_WND_SCALE and TCP_RCV_SCALE:
- * Set LWIP_WND_SCALE to 1 to enable window scaling.
- * Set TCP_RCV_SCALE to the desired scaling factor (shift count in the
- * range of [0..14]).
- * When LWIP_WND_SCALE is enabled but TCP_RCV_SCALE is 0, we can use a large
- * send window while having a small receive window only.
- */
-#if !defined LWIP_WND_SCALE || defined __DOXYGEN__
-#define LWIP_WND_SCALE 0
-#define TCP_RCV_SCALE 0
-#endif
-/**
- * @}
- */
-
-/*
- ----------------------------------
- ---------- Pbuf options ----------
- ----------------------------------
-*/
-/**
- * @defgroup lwip_opts_pbuf PBUF
- * @ingroup lwip_opts
- * @{
- */
-/**
- * PBUF_LINK_HLEN: the number of bytes that should be allocated for a
- * link level header. The default is 14, the standard value for
- * Ethernet.
- */
-#if !defined PBUF_LINK_HLEN || defined __DOXYGEN__
-#if defined LWIP_HOOK_VLAN_SET && !defined __DOXYGEN__
-#define PBUF_LINK_HLEN (18 + ETH_PAD_SIZE)
-#else /* LWIP_HOOK_VLAN_SET */
-#define PBUF_LINK_HLEN (14 + ETH_PAD_SIZE)
-#endif /* LWIP_HOOK_VLAN_SET */
-#endif
-
-/**
- * PBUF_LINK_ENCAPSULATION_HLEN: the number of bytes that should be allocated
- * for an additional encapsulation header before ethernet headers (e.g. 802.11)
- */
-#if !defined PBUF_LINK_ENCAPSULATION_HLEN || defined __DOXYGEN__
-#define PBUF_LINK_ENCAPSULATION_HLEN 0u
-#endif
-
-/**
- * PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. The default is
- * designed to accommodate single full size TCP frame in one pbuf, including
- * TCP_MSS, IP header, and link header.
- */
-#if !defined PBUF_POOL_BUFSIZE || defined __DOXYGEN__
-#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN)
-#endif
-/**
- * @}
- */
-
-/*
- ------------------------------------------------
- ---------- Network Interfaces options ----------
- ------------------------------------------------
-*/
-/**
- * @defgroup lwip_opts_netif NETIF
- * @ingroup lwip_opts
- * @{
- */
-/**
- * LWIP_NETIF_HOSTNAME==1: use DHCP_OPTION_HOSTNAME with netif's hostname
- * field.
- */
-#if !defined LWIP_NETIF_HOSTNAME || defined __DOXYGEN__
-#define LWIP_NETIF_HOSTNAME 0
-#endif
-
-/**
- * LWIP_NETIF_API==1: Support netif api (in netifapi.c)
- */
-#if !defined LWIP_NETIF_API || defined __DOXYGEN__
-#define LWIP_NETIF_API 0
-#endif
-
-/**
- * LWIP_NETIF_STATUS_CALLBACK==1: Support a callback function whenever an interface
- * changes its up/down status (i.e., due to DHCP IP acquisition)
- */
-#if !defined LWIP_NETIF_STATUS_CALLBACK || defined __DOXYGEN__
-#define LWIP_NETIF_STATUS_CALLBACK 0
-#endif
-
-/**
- * LWIP_NETIF_LINK_CALLBACK==1: Support a callback function from an interface
- * whenever the link changes (i.e., link down)
- */
-#if !defined LWIP_NETIF_LINK_CALLBACK || defined __DOXYGEN__
-#define LWIP_NETIF_LINK_CALLBACK 0
-#endif
-
-/**
- * LWIP_NETIF_REMOVE_CALLBACK==1: Support a callback function that is called
- * when a netif has been removed
- */
-#if !defined LWIP_NETIF_REMOVE_CALLBACK || defined __DOXYGEN__
-#define LWIP_NETIF_REMOVE_CALLBACK 0
-#endif
-
-/**
- * LWIP_NETIF_HWADDRHINT==1: Cache link-layer-address hints (e.g. table
- * indices) in struct netif. TCP and UDP can make use of this to prevent
- * scanning the ARP table for every sent packet. While this is faster for big
- * ARP tables or many concurrent connections, it might be counterproductive
- * if you have a tiny ARP table or if there never are concurrent connections.
- */
-#if !defined LWIP_NETIF_HWADDRHINT || defined __DOXYGEN__
-#define LWIP_NETIF_HWADDRHINT 0
-#endif
-
-/**
- * LWIP_NETIF_TX_SINGLE_PBUF: if this is set to 1, lwIP tries to put all data
- * to be sent into one single pbuf. This is for compatibility with DMA-enabled
- * MACs that do not support scatter-gather.
- * Beware that this might involve CPU-memcpy before transmitting that would not
- * be needed without this flag! Use this only if you need to!
- *
- * @todo: TCP and IP-frag do not work with this, yet:
- */
-#if !defined LWIP_NETIF_TX_SINGLE_PBUF || defined __DOXYGEN__
-#define LWIP_NETIF_TX_SINGLE_PBUF 0
-#endif /* LWIP_NETIF_TX_SINGLE_PBUF */
-
-/**
- * LWIP_NUM_NETIF_CLIENT_DATA: Number of clients that may store
- * data in client_data member array of struct netif.
- */
-#if !defined LWIP_NUM_NETIF_CLIENT_DATA || defined __DOXYGEN__
-#define LWIP_NUM_NETIF_CLIENT_DATA 0
-#endif
-/**
- * @}
- */
-
-/*
- ------------------------------------
- ---------- LOOPIF options ----------
- ------------------------------------
-*/
-/**
- * @defgroup lwip_opts_loop Loopback interface
- * @ingroup lwip_opts_netif
- * @{
- */
-/**
- * LWIP_HAVE_LOOPIF==1: Support loop interface (127.0.0.1).
- * This is only needed when no real netifs are available. If at least one other
- * netif is available, loopback traffic uses this netif.
- */
-#if !defined LWIP_HAVE_LOOPIF || defined __DOXYGEN__
-#define LWIP_HAVE_LOOPIF LWIP_NETIF_LOOPBACK
-#endif
-
-/**
- * LWIP_LOOPIF_MULTICAST==1: Support multicast/IGMP on loop interface (127.0.0.1).
- */
-#if !defined LWIP_LOOPIF_MULTICAST || defined __DOXYGEN__
-#define LWIP_LOOPIF_MULTICAST 0
-#endif
-
-/**
- * LWIP_NETIF_LOOPBACK==1: Support sending packets with a destination IP
- * address equal to the netif IP address, looping them back up the stack.
- */
-#if !defined LWIP_NETIF_LOOPBACK || defined __DOXYGEN__
-#define LWIP_NETIF_LOOPBACK 0
-#endif
-
-/**
- * LWIP_LOOPBACK_MAX_PBUFS: Maximum number of pbufs on queue for loopback
- * sending for each netif (0 = disabled)
- */
-#if !defined LWIP_LOOPBACK_MAX_PBUFS || defined __DOXYGEN__
-#define LWIP_LOOPBACK_MAX_PBUFS 0
-#endif
-
-/**
- * LWIP_NETIF_LOOPBACK_MULTITHREADING: Indicates whether threading is enabled in
- * the system, as netifs must change how they behave depending on this setting
- * for the LWIP_NETIF_LOOPBACK option to work.
- * Setting this is needed to avoid reentering non-reentrant functions like
- * tcp_input().
- * LWIP_NETIF_LOOPBACK_MULTITHREADING==1: Indicates that the user is using a
- * multithreaded environment like tcpip.c. In this case, netif->input()
- * is called directly.
- * LWIP_NETIF_LOOPBACK_MULTITHREADING==0: Indicates a polling (or NO_SYS) setup.
- * The packets are put on a list and netif_poll() must be called in
- * the main application loop.
- */
-#if !defined LWIP_NETIF_LOOPBACK_MULTITHREADING || defined __DOXYGEN__
-#define LWIP_NETIF_LOOPBACK_MULTITHREADING (!NO_SYS)
-#endif
-/**
- * @}
- */
-
-/*
- ------------------------------------
- ---------- Thread options ----------
- ------------------------------------
-*/
-/**
- * @defgroup lwip_opts_thread Threading
- * @ingroup lwip_opts_infrastructure
- * @{
- */
-/**
- * TCPIP_THREAD_NAME: The name assigned to the main tcpip thread.
- */
-#if !defined TCPIP_THREAD_NAME || defined __DOXYGEN__
-#define TCPIP_THREAD_NAME "tcpip_thread"
-#endif
-
-/**
- * TCPIP_THREAD_STACKSIZE: The stack size used by the main tcpip thread.
- * The stack size value itself is platform-dependent, but is passed to
- * sys_thread_new() when the thread is created.
- */
-#if !defined TCPIP_THREAD_STACKSIZE || defined __DOXYGEN__
-#define TCPIP_THREAD_STACKSIZE 0
-#endif
-
-/**
- * TCPIP_THREAD_PRIO: The priority assigned to the main tcpip thread.
- * The priority value itself is platform-dependent, but is passed to
- * sys_thread_new() when the thread is created.
- */
-#if !defined TCPIP_THREAD_PRIO || defined __DOXYGEN__
-#define TCPIP_THREAD_PRIO 1
-#endif
-
-/**
- * TCPIP_MBOX_SIZE: The mailbox size for the tcpip thread messages
- * The queue size value itself is platform-dependent, but is passed to
- * sys_mbox_new() when tcpip_init is called.
- */
-#if !defined TCPIP_MBOX_SIZE || defined __DOXYGEN__
-#define TCPIP_MBOX_SIZE 0
-#endif
-
-/**
- * Define this to something that triggers a watchdog. This is called from
- * tcpip_thread after processing a message.
- */
-#if !defined LWIP_TCPIP_THREAD_ALIVE || defined __DOXYGEN__
-#define LWIP_TCPIP_THREAD_ALIVE()
-#endif
-
-/**
- * SLIPIF_THREAD_NAME: The name assigned to the slipif_loop thread.
- */
-#if !defined SLIPIF_THREAD_NAME || defined __DOXYGEN__
-#define SLIPIF_THREAD_NAME "slipif_loop"
-#endif
-
-/**
- * SLIP_THREAD_STACKSIZE: The stack size used by the slipif_loop thread.
- * The stack size value itself is platform-dependent, but is passed to
- * sys_thread_new() when the thread is created.
- */
-#if !defined SLIPIF_THREAD_STACKSIZE || defined __DOXYGEN__
-#define SLIPIF_THREAD_STACKSIZE 0
-#endif
-
-/**
- * SLIPIF_THREAD_PRIO: The priority assigned to the slipif_loop thread.
- * The priority value itself is platform-dependent, but is passed to
- * sys_thread_new() when the thread is created.
- */
-#if !defined SLIPIF_THREAD_PRIO || defined __DOXYGEN__
-#define SLIPIF_THREAD_PRIO 1
-#endif
-
-/**
- * DEFAULT_THREAD_NAME: The name assigned to any other lwIP thread.
- */
-#if !defined DEFAULT_THREAD_NAME || defined __DOXYGEN__
-#define DEFAULT_THREAD_NAME "lwIP"
-#endif
-
-/**
- * DEFAULT_THREAD_STACKSIZE: The stack size used by any other lwIP thread.
- * The stack size value itself is platform-dependent, but is passed to
- * sys_thread_new() when the thread is created.
- */
-#if !defined DEFAULT_THREAD_STACKSIZE || defined __DOXYGEN__
-#define DEFAULT_THREAD_STACKSIZE 0
-#endif
-
-/**
- * DEFAULT_THREAD_PRIO: The priority assigned to any other lwIP thread.
- * The priority value itself is platform-dependent, but is passed to
- * sys_thread_new() when the thread is created.
- */
-#if !defined DEFAULT_THREAD_PRIO || defined __DOXYGEN__
-#define DEFAULT_THREAD_PRIO 1
-#endif
-
-/**
- * DEFAULT_RAW_RECVMBOX_SIZE: The mailbox size for the incoming packets on a
- * NETCONN_RAW. The queue size value itself is platform-dependent, but is passed
- * to sys_mbox_new() when the recvmbox is created.
- */
-#if !defined DEFAULT_RAW_RECVMBOX_SIZE || defined __DOXYGEN__
-#define DEFAULT_RAW_RECVMBOX_SIZE 0
-#endif
-
-/**
- * DEFAULT_UDP_RECVMBOX_SIZE: The mailbox size for the incoming packets on a
- * NETCONN_UDP. The queue size value itself is platform-dependent, but is passed
- * to sys_mbox_new() when the recvmbox is created.
- */
-#if !defined DEFAULT_UDP_RECVMBOX_SIZE || defined __DOXYGEN__
-#define DEFAULT_UDP_RECVMBOX_SIZE 0
-#endif
-
-/**
- * DEFAULT_TCP_RECVMBOX_SIZE: The mailbox size for the incoming packets on a
- * NETCONN_TCP. The queue size value itself is platform-dependent, but is passed
- * to sys_mbox_new() when the recvmbox is created.
- */
-#if !defined DEFAULT_TCP_RECVMBOX_SIZE || defined __DOXYGEN__
-#define DEFAULT_TCP_RECVMBOX_SIZE 0
-#endif
-
-/**
- * DEFAULT_ACCEPTMBOX_SIZE: The mailbox size for the incoming connections.
- * The queue size value itself is platform-dependent, but is passed to
- * sys_mbox_new() when the acceptmbox is created.
- */
-#if !defined DEFAULT_ACCEPTMBOX_SIZE || defined __DOXYGEN__
-#define DEFAULT_ACCEPTMBOX_SIZE 0
-#endif
-/**
- * @}
- */
-
-/*
- ----------------------------------------------
- ---------- Sequential layer options ----------
- ----------------------------------------------
-*/
-/**
- * @defgroup lwip_opts_netconn Netconn
- * @ingroup lwip_opts_threadsafe_apis
- * @{
- */
-/**
- * LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c)
- */
-#if !defined LWIP_NETCONN || defined __DOXYGEN__
-#define LWIP_NETCONN 1
-#endif
-
-/** LWIP_TCPIP_TIMEOUT==1: Enable tcpip_timeout/tcpip_untimeout to create
- * timers running in tcpip_thread from another thread.
- */
-#if !defined LWIP_TCPIP_TIMEOUT || defined __DOXYGEN__
-#define LWIP_TCPIP_TIMEOUT 0
-#endif
-
-/** LWIP_NETCONN_SEM_PER_THREAD==1: Use one (thread-local) semaphore per
- * thread calling socket/netconn functions instead of allocating one
- * semaphore per netconn (and per select etc.)
- * ATTENTION: a thread-local semaphore for API calls is needed:
- * - LWIP_NETCONN_THREAD_SEM_GET() returning a sys_sem_t*
- * - LWIP_NETCONN_THREAD_SEM_ALLOC() creating the semaphore
- * - LWIP_NETCONN_THREAD_SEM_FREE() freeing the semaphore
- * The latter 2 can be invoked up by calling netconn_thread_init()/netconn_thread_cleanup().
- * Ports may call these for threads created with sys_thread_new().
- */
-#if !defined LWIP_NETCONN_SEM_PER_THREAD || defined __DOXYGEN__
-#define LWIP_NETCONN_SEM_PER_THREAD 0
-#endif
-
-/** LWIP_NETCONN_FULLDUPLEX==1: Enable code that allows reading from one thread,
- * writing from a 2nd thread and closing from a 3rd thread at the same time.
- * ATTENTION: This is currently really alpha! Some requirements:
- * - LWIP_NETCONN_SEM_PER_THREAD==1 is required to use one socket/netconn from
- * multiple threads at once
- * - sys_mbox_free() has to unblock receive tasks waiting on recvmbox/acceptmbox
- * and prevent a task pending on this during/after deletion
- */
-#if !defined LWIP_NETCONN_FULLDUPLEX || defined __DOXYGEN__
-#define LWIP_NETCONN_FULLDUPLEX 0
-#endif
-/**
- * @}
- */
-
-/*
- ------------------------------------
- ---------- Socket options ----------
- ------------------------------------
-*/
-/**
- * @defgroup lwip_opts_socket Sockets
- * @ingroup lwip_opts_threadsafe_apis
- * @{
- */
-/**
- * LWIP_SOCKET==1: Enable Socket API (require to use sockets.c)
- */
-#if !defined LWIP_SOCKET || defined __DOXYGEN__
-#define LWIP_SOCKET 1
-#endif
-
-/* LWIP_SOCKET_SET_ERRNO==1: Set errno when socket functions cannot complete
- * successfully, as required by POSIX. Default is POSIX-compliant.
- */
-#if !defined LWIP_SOCKET_SET_ERRNO || defined __DOXYGEN__
-#define LWIP_SOCKET_SET_ERRNO 1
-#endif
-
-/**
- * LWIP_COMPAT_SOCKETS==1: Enable BSD-style sockets functions names through defines.
- * LWIP_COMPAT_SOCKETS==2: Same as ==1 but correctly named functions are created.
- * While this helps code completion, it might conflict with existing libraries.
- * (only used if you use sockets.c)
- */
-#if !defined LWIP_COMPAT_SOCKETS || defined __DOXYGEN__
-#define LWIP_COMPAT_SOCKETS 1
-#endif
-
-/**
- * LWIP_POSIX_SOCKETS_IO_NAMES==1: Enable POSIX-style sockets functions names.
- * Disable this option if you use a POSIX operating system that uses the same
- * names (read, write & close). (only used if you use sockets.c)
- */
-#if !defined LWIP_POSIX_SOCKETS_IO_NAMES || defined __DOXYGEN__
-#define LWIP_POSIX_SOCKETS_IO_NAMES 1
-#endif
-
-/**
- * LWIP_SOCKET_OFFSET==n: Increases the file descriptor number created by LwIP with n.
- * This can be useful when there are multiple APIs which create file descriptors.
- * When they all start with a different offset and you won't make them overlap you can
- * re implement read/write/close/ioctl/fnctl to send the requested action to the right
- * library (sharing select will need more work though).
- */
-#if !defined LWIP_SOCKET_OFFSET || defined __DOXYGEN__
-#define LWIP_SOCKET_OFFSET 0
-#endif
-
-/**
- * LWIP_TCP_KEEPALIVE==1: Enable TCP_KEEPIDLE, TCP_KEEPINTVL and TCP_KEEPCNT
- * options processing. Note that TCP_KEEPIDLE and TCP_KEEPINTVL have to be set
- * in seconds. (does not require sockets.c, and will affect tcp.c)
- */
-#if !defined LWIP_TCP_KEEPALIVE || defined __DOXYGEN__
-#define LWIP_TCP_KEEPALIVE 0
-#endif
-
-/**
- * LWIP_SO_SNDTIMEO==1: Enable send timeout for sockets/netconns and
- * SO_SNDTIMEO processing.
- */
-#if !defined LWIP_SO_SNDTIMEO || defined __DOXYGEN__
-#define LWIP_SO_SNDTIMEO 0
-#endif
-
-/**
- * LWIP_SO_RCVTIMEO==1: Enable receive timeout for sockets/netconns and
- * SO_RCVTIMEO processing.
- */
-#if !defined LWIP_SO_RCVTIMEO || defined __DOXYGEN__
-#define LWIP_SO_RCVTIMEO 0
-#endif
-
-/**
- * LWIP_SO_SNDRCVTIMEO_NONSTANDARD==1: SO_RCVTIMEO/SO_SNDTIMEO take an int
- * (milliseconds, much like winsock does) instead of a struct timeval (default).
- */
-#if !defined LWIP_SO_SNDRCVTIMEO_NONSTANDARD || defined __DOXYGEN__
-#define LWIP_SO_SNDRCVTIMEO_NONSTANDARD 0
-#endif
-
-/**
- * LWIP_SO_RCVBUF==1: Enable SO_RCVBUF processing.
- */
-#if !defined LWIP_SO_RCVBUF || defined __DOXYGEN__
-#define LWIP_SO_RCVBUF 0
-#endif
-
-/**
- * LWIP_SO_LINGER==1: Enable SO_LINGER processing.
- */
-#if !defined LWIP_SO_LINGER || defined __DOXYGEN__
-#define LWIP_SO_LINGER 0
-#endif
-
-/**
- * If LWIP_SO_RCVBUF is used, this is the default value for recv_bufsize.
- */
-#if !defined RECV_BUFSIZE_DEFAULT || defined __DOXYGEN__
-#define RECV_BUFSIZE_DEFAULT INT_MAX
-#endif
-
-/**
- * By default, TCP socket/netconn close waits 20 seconds max to send the FIN
- */
-#if !defined LWIP_TCP_CLOSE_TIMEOUT_MS_DEFAULT || defined __DOXYGEN__
-#define LWIP_TCP_CLOSE_TIMEOUT_MS_DEFAULT 20000
-#endif
-
-/**
- * SO_REUSE==1: Enable SO_REUSEADDR option.
- */
-#if !defined SO_REUSE || defined __DOXYGEN__
-#define SO_REUSE 0
-#endif
-
-/**
- * SO_REUSE_RXTOALL==1: Pass a copy of incoming broadcast/multicast packets
- * to all local matches if SO_REUSEADDR is turned on.
- * WARNING: Adds a memcpy for every packet if passing to more than one pcb!
- */
-#if !defined SO_REUSE_RXTOALL || defined __DOXYGEN__
-#define SO_REUSE_RXTOALL 0
-#endif
-
-/**
- * LWIP_FIONREAD_LINUXMODE==0 (default): ioctl/FIONREAD returns the amount of
- * pending data in the network buffer. This is the way windows does it. It's
- * the default for lwIP since it is smaller.
- * LWIP_FIONREAD_LINUXMODE==1: ioctl/FIONREAD returns the size of the next
- * pending datagram in bytes. This is the way linux does it. This code is only
- * here for compatibility.
- */
-#if !defined LWIP_FIONREAD_LINUXMODE || defined __DOXYGEN__
-#define LWIP_FIONREAD_LINUXMODE 0
-#endif
-/**
- * @}
- */
-
-/*
- ----------------------------------------
- ---------- Statistics options ----------
- ----------------------------------------
-*/
-/**
- * @defgroup lwip_opts_stats Statistics
- * @ingroup lwip_opts_debug
- * @{
- */
-/**
- * LWIP_STATS==1: Enable statistics collection in lwip_stats.
- */
-#if !defined LWIP_STATS || defined __DOXYGEN__
-#define LWIP_STATS 1
-#endif
-
-#if LWIP_STATS
-
-/**
- * LWIP_STATS_DISPLAY==1: Compile in the statistics output functions.
- */
-#if !defined LWIP_STATS_DISPLAY || defined __DOXYGEN__
-#define LWIP_STATS_DISPLAY 0
-#endif
-
-/**
- * LINK_STATS==1: Enable link stats.
- */
-#if !defined LINK_STATS || defined __DOXYGEN__
-#define LINK_STATS 1
-#endif
-
-/**
- * ETHARP_STATS==1: Enable etharp stats.
- */
-#if !defined ETHARP_STATS || defined __DOXYGEN__
-#define ETHARP_STATS (LWIP_ARP)
-#endif
-
-/**
- * IP_STATS==1: Enable IP stats.
- */
-#if !defined IP_STATS || defined __DOXYGEN__
-#define IP_STATS 1
-#endif
-
-/**
- * IPFRAG_STATS==1: Enable IP fragmentation stats. Default is
- * on if using either frag or reass.
- */
-#if !defined IPFRAG_STATS || defined __DOXYGEN__
-#define IPFRAG_STATS (IP_REASSEMBLY || IP_FRAG)
-#endif
-
-/**
- * ICMP_STATS==1: Enable ICMP stats.
- */
-#if !defined ICMP_STATS || defined __DOXYGEN__
-#define ICMP_STATS 1
-#endif
-
-/**
- * IGMP_STATS==1: Enable IGMP stats.
- */
-#if !defined IGMP_STATS || defined __DOXYGEN__
-#define IGMP_STATS (LWIP_IGMP)
-#endif
-
-/**
- * UDP_STATS==1: Enable UDP stats. Default is on if
- * UDP enabled, otherwise off.
- */
-#if !defined UDP_STATS || defined __DOXYGEN__
-#define UDP_STATS (LWIP_UDP)
-#endif
-
-/**
- * TCP_STATS==1: Enable TCP stats. Default is on if TCP
- * enabled, otherwise off.
- */
-#if !defined TCP_STATS || defined __DOXYGEN__
-#define TCP_STATS (LWIP_TCP)
-#endif
-
-/**
- * MEM_STATS==1: Enable mem.c stats.
- */
-#if !defined MEM_STATS || defined __DOXYGEN__
-#define MEM_STATS ((MEM_LIBC_MALLOC == 0) && (MEM_USE_POOLS == 0))
-#endif
-
-/**
- * MEMP_STATS==1: Enable memp.c pool stats.
- */
-#if !defined MEMP_STATS || defined __DOXYGEN__
-#define MEMP_STATS (MEMP_MEM_MALLOC == 0)
-#endif
-
-/**
- * SYS_STATS==1: Enable system stats (sem and mbox counts, etc).
- */
-#if !defined SYS_STATS || defined __DOXYGEN__
-#define SYS_STATS (NO_SYS == 0)
-#endif
-
-/**
- * IP6_STATS==1: Enable IPv6 stats.
- */
-#if !defined IP6_STATS || defined __DOXYGEN__
-#define IP6_STATS (LWIP_IPV6)
-#endif
-
-/**
- * ICMP6_STATS==1: Enable ICMP for IPv6 stats.
- */
-#if !defined ICMP6_STATS || defined __DOXYGEN__
-#define ICMP6_STATS (LWIP_IPV6 && LWIP_ICMP6)
-#endif
-
-/**
- * IP6_FRAG_STATS==1: Enable IPv6 fragmentation stats.
- */
-#if !defined IP6_FRAG_STATS || defined __DOXYGEN__
-#define IP6_FRAG_STATS (LWIP_IPV6 && (LWIP_IPV6_FRAG || LWIP_IPV6_REASS))
-#endif
-
-/**
- * MLD6_STATS==1: Enable MLD for IPv6 stats.
- */
-#if !defined MLD6_STATS || defined __DOXYGEN__
-#define MLD6_STATS (LWIP_IPV6 && LWIP_IPV6_MLD)
-#endif
-
-/**
- * ND6_STATS==1: Enable Neighbor discovery for IPv6 stats.
- */
-#if !defined ND6_STATS || defined __DOXYGEN__
-#define ND6_STATS (LWIP_IPV6)
-#endif
-
-/**
- * MIB2_STATS==1: Stats for SNMP MIB2.
- */
-#if !defined MIB2_STATS || defined __DOXYGEN__
-#define MIB2_STATS 0
-#endif
-
-#else
-
-#define LINK_STATS 0
-#define ETHARP_STATS 0
-#define IP_STATS 0
-#define IPFRAG_STATS 0
-#define ICMP_STATS 0
-#define IGMP_STATS 0
-#define UDP_STATS 0
-#define TCP_STATS 0
-#define MEM_STATS 0
-#define MEMP_STATS 0
-#define SYS_STATS 0
-#define LWIP_STATS_DISPLAY 0
-#define IP6_STATS 0
-#define ICMP6_STATS 0
-#define IP6_FRAG_STATS 0
-#define MLD6_STATS 0
-#define ND6_STATS 0
-#define MIB2_STATS 0
-
-#endif /* LWIP_STATS */
-/**
- * @}
- */
-
-/*
- --------------------------------------
- ---------- Checksum options ----------
- --------------------------------------
-*/
-/**
- * @defgroup lwip_opts_checksum Checksum
- * @ingroup lwip_opts_infrastructure
- * @{
- */
-/**
- * LWIP_CHECKSUM_CTRL_PER_NETIF==1: Checksum generation/check can be enabled/disabled
- * per netif.
- * ATTENTION: if enabled, the CHECKSUM_GEN_* and CHECKSUM_CHECK_* defines must be enabled!
- */
-#if !defined LWIP_CHECKSUM_CTRL_PER_NETIF || defined __DOXYGEN__
-#define LWIP_CHECKSUM_CTRL_PER_NETIF 0
-#endif
-
-/**
- * CHECKSUM_GEN_IP==1: Generate checksums in software for outgoing IP packets.
- */
-#if !defined CHECKSUM_GEN_IP || defined __DOXYGEN__
-#define CHECKSUM_GEN_IP 1
-#endif
-
-/**
- * CHECKSUM_GEN_UDP==1: Generate checksums in software for outgoing UDP packets.
- */
-#if !defined CHECKSUM_GEN_UDP || defined __DOXYGEN__
-#define CHECKSUM_GEN_UDP 1
-#endif
-
-/**
- * CHECKSUM_GEN_TCP==1: Generate checksums in software for outgoing TCP packets.
- */
-#if !defined CHECKSUM_GEN_TCP || defined __DOXYGEN__
-#define CHECKSUM_GEN_TCP 1
-#endif
-
-/**
- * CHECKSUM_GEN_ICMP==1: Generate checksums in software for outgoing ICMP packets.
- */
-#if !defined CHECKSUM_GEN_ICMP || defined __DOXYGEN__
-#define CHECKSUM_GEN_ICMP 1
-#endif
-
-/**
- * CHECKSUM_GEN_ICMP6==1: Generate checksums in software for outgoing ICMP6 packets.
- */
-#if !defined CHECKSUM_GEN_ICMP6 || defined __DOXYGEN__
-#define CHECKSUM_GEN_ICMP6 1
-#endif
-
-/**
- * CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets.
- */
-#if !defined CHECKSUM_CHECK_IP || defined __DOXYGEN__
-#define CHECKSUM_CHECK_IP 1
-#endif
-
-/**
- * CHECKSUM_CHECK_UDP==1: Check checksums in software for incoming UDP packets.
- */
-#if !defined CHECKSUM_CHECK_UDP || defined __DOXYGEN__
-#define CHECKSUM_CHECK_UDP 1
-#endif
-
-/**
- * CHECKSUM_CHECK_TCP==1: Check checksums in software for incoming TCP packets.
- */
-#if !defined CHECKSUM_CHECK_TCP || defined __DOXYGEN__
-#define CHECKSUM_CHECK_TCP 1
-#endif
-
-/**
- * CHECKSUM_CHECK_ICMP==1: Check checksums in software for incoming ICMP packets.
- */
-#if !defined CHECKSUM_CHECK_ICMP || defined __DOXYGEN__
-#define CHECKSUM_CHECK_ICMP 1
-#endif
-
-/**
- * CHECKSUM_CHECK_ICMP6==1: Check checksums in software for incoming ICMPv6 packets
- */
-#if !defined CHECKSUM_CHECK_ICMP6 || defined __DOXYGEN__
-#define CHECKSUM_CHECK_ICMP6 1
-#endif
-
-/**
- * LWIP_CHECKSUM_ON_COPY==1: Calculate checksum when copying data from
- * application buffers to pbufs.
- */
-#if !defined LWIP_CHECKSUM_ON_COPY || defined __DOXYGEN__
-#define LWIP_CHECKSUM_ON_COPY 0
-#endif
-/**
- * @}
- */
-
-/*
- ---------------------------------------
- ---------- IPv6 options ---------------
- ---------------------------------------
-*/
-/**
- * @defgroup lwip_opts_ipv6 IPv6
- * @ingroup lwip_opts
- * @{
- */
-/**
- * LWIP_IPV6==1: Enable IPv6
- */
-#if !defined LWIP_IPV6 || defined __DOXYGEN__
-#define LWIP_IPV6 0
-#endif
-
-/**
- * LWIP_IPV6_NUM_ADDRESSES: Number of IPv6 addresses per netif.
- */
-#if !defined LWIP_IPV6_NUM_ADDRESSES || defined __DOXYGEN__
-#define LWIP_IPV6_NUM_ADDRESSES 3
-#endif
-
-/**
- * LWIP_IPV6_FORWARD==1: Forward IPv6 packets across netifs
- */
-#if !defined LWIP_IPV6_FORWARD || defined __DOXYGEN__
-#define LWIP_IPV6_FORWARD 0
-#endif
-
-/**
- * LWIP_IPV6_FRAG==1: Fragment outgoing IPv6 packets that are too big.
- */
-#if !defined LWIP_IPV6_FRAG || defined __DOXYGEN__
-#define LWIP_IPV6_FRAG 0
-#endif
-
-/**
- * LWIP_IPV6_REASS==1: reassemble incoming IPv6 packets that fragmented
- */
-#if !defined LWIP_IPV6_REASS || defined __DOXYGEN__
-#define LWIP_IPV6_REASS (LWIP_IPV6)
-#endif
-
-/**
- * LWIP_IPV6_SEND_ROUTER_SOLICIT==1: Send router solicitation messages during
- * network startup.
- */
-#if !defined LWIP_IPV6_SEND_ROUTER_SOLICIT || defined __DOXYGEN__
-#define LWIP_IPV6_SEND_ROUTER_SOLICIT 1
-#endif
-
-/**
- * LWIP_IPV6_AUTOCONFIG==1: Enable stateless address autoconfiguration as per RFC 4862.
- */
-#if !defined LWIP_IPV6_AUTOCONFIG || defined __DOXYGEN__
-#define LWIP_IPV6_AUTOCONFIG (LWIP_IPV6)
-#endif
-
-/**
- * LWIP_IPV6_DUP_DETECT_ATTEMPTS=[0..7]: Number of duplicate address detection attempts.
- */
-#if !defined LWIP_IPV6_DUP_DETECT_ATTEMPTS || defined __DOXYGEN__
-#define LWIP_IPV6_DUP_DETECT_ATTEMPTS 1
-#endif
-/**
- * @}
- */
-
-/**
- * @defgroup lwip_opts_icmp6 ICMP6
- * @ingroup lwip_opts_ipv6
- * @{
- */
-/**
- * LWIP_ICMP6==1: Enable ICMPv6 (mandatory per RFC)
- */
-#if !defined LWIP_ICMP6 || defined __DOXYGEN__
-#define LWIP_ICMP6 (LWIP_IPV6)
-#endif
-
-/**
- * LWIP_ICMP6_DATASIZE: bytes from original packet to send back in
- * ICMPv6 error messages.
- */
-#if !defined LWIP_ICMP6_DATASIZE || defined __DOXYGEN__
-#define LWIP_ICMP6_DATASIZE 8
-#endif
-
-/**
- * LWIP_ICMP6_HL: default hop limit for ICMPv6 messages
- */
-#if !defined LWIP_ICMP6_HL || defined __DOXYGEN__
-#define LWIP_ICMP6_HL 255
-#endif
-/**
- * @}
- */
-
-/**
- * @defgroup lwip_opts_mld6 Multicast listener discovery
- * @ingroup lwip_opts_ipv6
- * @{
- */
-/**
- * LWIP_IPV6_MLD==1: Enable multicast listener discovery protocol.
- * If LWIP_IPV6 is enabled but this setting is disabled, the MAC layer must
- * indiscriminately pass all inbound IPv6 multicast traffic to lwIP.
- */
-#if !defined LWIP_IPV6_MLD || defined __DOXYGEN__
-#define LWIP_IPV6_MLD (LWIP_IPV6)
-#endif
-
-/**
- * MEMP_NUM_MLD6_GROUP: Max number of IPv6 multicast groups that can be joined.
- * There must be enough groups so that each netif can join the solicited-node
- * multicast group for each of its local addresses, plus one for MDNS if
- * applicable, plus any number of groups to be joined on UDP sockets.
- */
-#if !defined MEMP_NUM_MLD6_GROUP || defined __DOXYGEN__
-#define MEMP_NUM_MLD6_GROUP 4
-#endif
-/**
- * @}
- */
-
-/**
- * @defgroup lwip_opts_nd6 Neighbor discovery
- * @ingroup lwip_opts_ipv6
- * @{
- */
-/**
- * LWIP_ND6_QUEUEING==1: queue outgoing IPv6 packets while MAC address
- * is being resolved.
- */
-#if !defined LWIP_ND6_QUEUEING || defined __DOXYGEN__
-#define LWIP_ND6_QUEUEING (LWIP_IPV6)
-#endif
-
-/**
- * MEMP_NUM_ND6_QUEUE: Max number of IPv6 packets to queue during MAC resolution.
- */
-#if !defined MEMP_NUM_ND6_QUEUE || defined __DOXYGEN__
-#define MEMP_NUM_ND6_QUEUE 20
-#endif
-
-/**
- * LWIP_ND6_NUM_NEIGHBORS: Number of entries in IPv6 neighbor cache
- */
-#if !defined LWIP_ND6_NUM_NEIGHBORS || defined __DOXYGEN__
-#define LWIP_ND6_NUM_NEIGHBORS 10
-#endif
-
-/**
- * LWIP_ND6_NUM_DESTINATIONS: number of entries in IPv6 destination cache
- */
-#if !defined LWIP_ND6_NUM_DESTINATIONS || defined __DOXYGEN__
-#define LWIP_ND6_NUM_DESTINATIONS 10
-#endif
-
-/**
- * LWIP_ND6_NUM_PREFIXES: number of entries in IPv6 on-link prefixes cache
- */
-#if !defined LWIP_ND6_NUM_PREFIXES || defined __DOXYGEN__
-#define LWIP_ND6_NUM_PREFIXES 5
-#endif
-
-/**
- * LWIP_ND6_NUM_ROUTERS: number of entries in IPv6 default router cache
- */
-#if !defined LWIP_ND6_NUM_ROUTERS || defined __DOXYGEN__
-#define LWIP_ND6_NUM_ROUTERS 3
-#endif
-
-/**
- * LWIP_ND6_MAX_MULTICAST_SOLICIT: max number of multicast solicit messages to send
- * (neighbor solicit and router solicit)
- */
-#if !defined LWIP_ND6_MAX_MULTICAST_SOLICIT || defined __DOXYGEN__
-#define LWIP_ND6_MAX_MULTICAST_SOLICIT 3
-#endif
-
-/**
- * LWIP_ND6_MAX_UNICAST_SOLICIT: max number of unicast neighbor solicitation messages
- * to send during neighbor reachability detection.
- */
-#if !defined LWIP_ND6_MAX_UNICAST_SOLICIT || defined __DOXYGEN__
-#define LWIP_ND6_MAX_UNICAST_SOLICIT 3
-#endif
-
-/**
- * Unused: See ND RFC (time in milliseconds).
- */
-#if !defined LWIP_ND6_MAX_ANYCAST_DELAY_TIME || defined __DOXYGEN__
-#define LWIP_ND6_MAX_ANYCAST_DELAY_TIME 1000
-#endif
-
-/**
- * Unused: See ND RFC
- */
-#if !defined LWIP_ND6_MAX_NEIGHBOR_ADVERTISEMENT || defined __DOXYGEN__
-#define LWIP_ND6_MAX_NEIGHBOR_ADVERTISEMENT 3
-#endif
-
-/**
- * LWIP_ND6_REACHABLE_TIME: default neighbor reachable time (in milliseconds).
- * May be updated by router advertisement messages.
- */
-#if !defined LWIP_ND6_REACHABLE_TIME || defined __DOXYGEN__
-#define LWIP_ND6_REACHABLE_TIME 30000
-#endif
-
-/**
- * LWIP_ND6_RETRANS_TIMER: default retransmission timer for solicitation messages
- */
-#if !defined LWIP_ND6_RETRANS_TIMER || defined __DOXYGEN__
-#define LWIP_ND6_RETRANS_TIMER 1000
-#endif
-
-/**
- * LWIP_ND6_DELAY_FIRST_PROBE_TIME: Delay before first unicast neighbor solicitation
- * message is sent, during neighbor reachability detection.
- */
-#if !defined LWIP_ND6_DELAY_FIRST_PROBE_TIME || defined __DOXYGEN__
-#define LWIP_ND6_DELAY_FIRST_PROBE_TIME 5000
-#endif
-
-/**
- * LWIP_ND6_ALLOW_RA_UPDATES==1: Allow Router Advertisement messages to update
- * Reachable time and retransmission timers, and netif MTU.
- */
-#if !defined LWIP_ND6_ALLOW_RA_UPDATES || defined __DOXYGEN__
-#define LWIP_ND6_ALLOW_RA_UPDATES 1
-#endif
-
-/**
- * LWIP_ND6_TCP_REACHABILITY_HINTS==1: Allow TCP to provide Neighbor Discovery
- * with reachability hints for connected destinations. This helps avoid sending
- * unicast neighbor solicitation messages.
- */
-#if !defined LWIP_ND6_TCP_REACHABILITY_HINTS || defined __DOXYGEN__
-#define LWIP_ND6_TCP_REACHABILITY_HINTS 1
-#endif
-
-/**
- * LWIP_ND6_RDNSS_MAX_DNS_SERVERS > 0: Use IPv6 Router Advertisement Recursive
- * DNS Server Option (as per RFC 6106) to copy a defined maximum number of DNS
- * servers to the DNS module.
- */
-#if !defined LWIP_ND6_RDNSS_MAX_DNS_SERVERS || defined __DOXYGEN__
-#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS 0
-#endif
-/**
- * @}
- */
-
-/**
- * LWIP_IPV6_DHCP6==1: enable DHCPv6 stateful address autoconfiguration.
- */
-#if !defined LWIP_IPV6_DHCP6 || defined __DOXYGEN__
-#define LWIP_IPV6_DHCP6 0
-#endif
-
-/*
- ---------------------------------------
- ---------- Hook options ---------------
- ---------------------------------------
-*/
-
-/**
- * @defgroup lwip_opts_hooks Hooks
- * @ingroup lwip_opts_infrastructure
- * Hooks are undefined by default, define them to a function if you need them.
- * @{
- */
-
-/**
- * LWIP_HOOK_FILENAME: Custom filename to #include in files that provide hooks.
- * Declare your hook function prototypes in there, you may also #include all headers
- * providing data types that are need in this file.
- */
-#ifdef __DOXYGEN__
-#define LWIP_HOOK_FILENAME "path/to/my/lwip_hooks.h"
-#endif
-
-/**
- * LWIP_HOOK_TCP_ISN:
- * Hook for generation of the Initial Sequence Number (ISN) for a new TCP
- * connection. The default lwIP ISN generation algorithm is very basic and may
- * allow for TCP spoofing attacks. This hook provides the means to implement
- * the standardized ISN generation algorithm from RFC 6528 (see contrib/adons/tcp_isn),
- * or any other desired algorithm as a replacement.
- * Called from tcp_connect() and tcp_listen_input() when an ISN is needed for
- * a new TCP connection, if TCP support (@ref LWIP_TCP) is enabled.\n
- * Signature: u32_t my_hook_tcp_isn(const ip_addr_t* local_ip, u16_t local_port, const ip_addr_t* remote_ip, u16_t remote_port);
- * - it may be necessary to use "struct ip_addr" (ip4_addr, ip6_addr) instead of "ip_addr_t" in function declarations\n
- * Arguments:
- * - local_ip: pointer to the local IP address of the connection
- * - local_port: local port number of the connection (host-byte order)
- * - remote_ip: pointer to the remote IP address of the connection
- * - remote_port: remote port number of the connection (host-byte order)\n
- * Return value:
- * - the 32-bit Initial Sequence Number to use for the new TCP connection.
- */
-#ifdef __DOXYGEN__
-#define LWIP_HOOK_TCP_ISN(local_ip, local_port, remote_ip, remote_port)
-#endif
-
-/**
- * LWIP_HOOK_IP4_INPUT(pbuf, input_netif):
- * - called from ip_input() (IPv4)
- * - pbuf: received struct pbuf passed to ip_input()
- * - input_netif: struct netif on which the packet has been received
- * Return values:
- * - 0: Hook has not consumed the packet, packet is processed as normal
- * - != 0: Hook has consumed the packet.
- * If the hook consumed the packet, 'pbuf' is in the responsibility of the hook
- * (i.e. free it when done).
- */
-#ifdef __DOXYGEN__
-#define LWIP_HOOK_IP4_INPUT(pbuf, input_netif)
-#endif
-
-/**
- * LWIP_HOOK_IP4_ROUTE(dest):
- * - called from ip_route() (IPv4)
- * - dest: destination IPv4 address
- * Returns the destination netif or NULL if no destination netif is found. In
- * that case, ip_route() continues as normal.
- */
-#ifdef __DOXYGEN__
-#define LWIP_HOOK_IP4_ROUTE()
-#endif
-
-/**
- * LWIP_HOOK_IP4_ROUTE_SRC(dest, src):
- * - source-based routing for IPv4 (see LWIP_HOOK_IP4_ROUTE(), src may be NULL)
- */
-#ifdef __DOXYGEN__
-#define LWIP_HOOK_IP4_ROUTE_SRC(dest, src)
-#endif
-
-/**
- * LWIP_HOOK_ETHARP_GET_GW(netif, dest):
- * - called from etharp_output() (IPv4)
- * - netif: the netif used for sending
- * - dest: the destination IPv4 address
- * Returns the IPv4 address of the gateway to handle the specified destination
- * IPv4 address. If NULL is returned, the netif's default gateway is used.
- * The returned address MUST be directly reachable on the specified netif!
- * This function is meant to implement advanced IPv4 routing together with
- * LWIP_HOOK_IP4_ROUTE(). The actual routing/gateway table implementation is
- * not part of lwIP but can e.g. be hidden in the netif's state argument.
-*/
-#ifdef __DOXYGEN__
-#define LWIP_HOOK_ETHARP_GET_GW(netif, dest)
-#endif
-
-/**
- * LWIP_HOOK_IP6_INPUT(pbuf, input_netif):
- * - called from ip6_input() (IPv6)
- * - pbuf: received struct pbuf passed to ip6_input()
- * - input_netif: struct netif on which the packet has been received
- * Return values:
- * - 0: Hook has not consumed the packet, packet is processed as normal
- * - != 0: Hook has consumed the packet.
- * If the hook consumed the packet, 'pbuf' is in the responsibility of the hook
- * (i.e. free it when done).
- */
-#ifdef __DOXYGEN__
-#define LWIP_HOOK_IP6_INPUT(pbuf, input_netif)
-#endif
-
-/**
- * LWIP_HOOK_IP6_ROUTE(src, dest):
- * - called from ip6_route() (IPv6)
- * - src: sourc IPv6 address
- * - dest: destination IPv6 address
- * Returns the destination netif or NULL if no destination netif is found. In
- * that case, ip6_route() continues as normal.
- */
-#ifdef __DOXYGEN__
-#define LWIP_HOOK_IP6_ROUTE(src, dest)
-#endif
-
-/**
- * LWIP_HOOK_ND6_GET_GW(netif, dest):
- * - called from nd6_get_next_hop_entry() (IPv6)
- * - netif: the netif used for sending
- * - dest: the destination IPv6 address
- * Returns the IPv6 address of the next hop to handle the specified destination
- * IPv6 address. If NULL is returned, a NDP-discovered router is used instead.
- * The returned address MUST be directly reachable on the specified netif!
- * This function is meant to implement advanced IPv6 routing together with
- * LWIP_HOOK_IP6_ROUTE(). The actual routing/gateway table implementation is
- * not part of lwIP but can e.g. be hidden in the netif's state argument.
-*/
-#ifdef __DOXYGEN__
-#define LWIP_HOOK_ND6_GET_GW(netif, dest)
-#endif
-
-/**
- * LWIP_HOOK_VLAN_CHECK(netif, eth_hdr, vlan_hdr):
- * - called from ethernet_input() if VLAN support is enabled
- * - netif: struct netif on which the packet has been received
- * - eth_hdr: struct eth_hdr of the packet
- * - vlan_hdr: struct eth_vlan_hdr of the packet
- * Return values:
- * - 0: Packet must be dropped.
- * - != 0: Packet must be accepted.
- */
-#ifdef __DOXYGEN__
-#define LWIP_HOOK_VLAN_CHECK(netif, eth_hdr, vlan_hdr)
-#endif
-
-/**
- * LWIP_HOOK_VLAN_SET:
- * Hook can be used to set prio_vid field of vlan_hdr. If you need to store data
- * on per-netif basis to implement this callback, see @ref netif_cd.
- * Called from ethernet_output() if VLAN support (@ref ETHARP_SUPPORT_VLAN) is enabled.\n
- * Signature: s32_t my_hook_vlan_set(struct netif* netif, struct pbuf* pbuf, const struct eth_addr* src, const struct eth_addr* dst, u16_t eth_type);\n
- * Arguments:
- * - netif: struct netif that the packet will be sent through
- * - p: struct pbuf packet to be sent
- * - src: source eth address
- * - dst: destination eth address
- * - eth_type: ethernet type to packet to be sent\n
- *
- *
- * Return values:
- * - &lt;0: Packet shall not contain VLAN header.
- * - 0 &lt;= return value &lt;= 0xFFFF: Packet shall contain VLAN header. Return value is prio_vid in host byte order.
- */
-#ifdef __DOXYGEN__
-#define LWIP_HOOK_VLAN_SET(netif, p, src, dst, eth_type)
-#endif
-
-/**
- * LWIP_HOOK_MEMP_AVAILABLE(memp_t_type):
- * - called from memp_free() when a memp pool was empty and an item is now available
- */
-#ifdef __DOXYGEN__
-#define LWIP_HOOK_MEMP_AVAILABLE(memp_t_type)
-#endif
-
-/**
- * LWIP_HOOK_UNKNOWN_ETH_PROTOCOL(pbuf, netif):
- * Called from ethernet_input() when an unknown eth type is encountered.
- * Return ERR_OK if packet is accepted, any error code otherwise.
- * Payload points to ethernet header!
- */
-#ifdef __DOXYGEN__
-#define LWIP_HOOK_UNKNOWN_ETH_PROTOCOL(pbuf, netif)
-#endif
-/**
- * @}
- */
-
-/*
- ---------------------------------------
- ---------- Debugging options ----------
- ---------------------------------------
-*/
-/**
- * @defgroup lwip_opts_debugmsg Debug messages
- * @ingroup lwip_opts_debug
- * @{
- */
-/**
- * LWIP_DBG_MIN_LEVEL: After masking, the value of the debug is
- * compared against this value. If it is smaller, then debugging
- * messages are written.
- * @see debugging_levels
- */
-#if !defined LWIP_DBG_MIN_LEVEL || defined __DOXYGEN__
-#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL
-#endif
-
-/**
- * LWIP_DBG_TYPES_ON: A mask that can be used to globally enable/disable
- * debug messages of certain types.
- * @see debugging_levels
- */
-#if !defined LWIP_DBG_TYPES_ON || defined __DOXYGEN__
-#define LWIP_DBG_TYPES_ON LWIP_DBG_ON
-#endif
-
-/**
- * ETHARP_DEBUG: Enable debugging in etharp.c.
- */
-#if !defined ETHARP_DEBUG || defined __DOXYGEN__
-#define ETHARP_DEBUG LWIP_DBG_OFF
-#endif
-
-/**
- * NETIF_DEBUG: Enable debugging in netif.c.
- */
-#if !defined NETIF_DEBUG || defined __DOXYGEN__
-#define NETIF_DEBUG LWIP_DBG_OFF
-#endif
-
-/**
- * PBUF_DEBUG: Enable debugging in pbuf.c.
- */
-#if !defined PBUF_DEBUG || defined __DOXYGEN__
-#define PBUF_DEBUG LWIP_DBG_OFF
-#endif
-
-/**
- * API_LIB_DEBUG: Enable debugging in api_lib.c.
- */
-#if !defined API_LIB_DEBUG || defined __DOXYGEN__
-#define API_LIB_DEBUG LWIP_DBG_OFF
-#endif
-
-/**
- * API_MSG_DEBUG: Enable debugging in api_msg.c.
- */
-#if !defined API_MSG_DEBUG || defined __DOXYGEN__
-#define API_MSG_DEBUG LWIP_DBG_OFF
-#endif
-
-/**
- * SOCKETS_DEBUG: Enable debugging in sockets.c.
- */
-#if !defined SOCKETS_DEBUG || defined __DOXYGEN__
-#define SOCKETS_DEBUG LWIP_DBG_OFF
-#endif
-
-/**
- * ICMP_DEBUG: Enable debugging in icmp.c.
- */
-#if !defined ICMP_DEBUG || defined __DOXYGEN__
-#define ICMP_DEBUG LWIP_DBG_OFF
-#endif
-
-/**
- * IGMP_DEBUG: Enable debugging in igmp.c.
- */
-#if !defined IGMP_DEBUG || defined __DOXYGEN__
-#define IGMP_DEBUG LWIP_DBG_OFF
-#endif
-
-/**
- * INET_DEBUG: Enable debugging in inet.c.
- */
-#if !defined INET_DEBUG || defined __DOXYGEN__
-#define INET_DEBUG LWIP_DBG_OFF
-#endif
-
-/**
- * IP_DEBUG: Enable debugging for IP.
- */
-#if !defined IP_DEBUG || defined __DOXYGEN__
-#define IP_DEBUG LWIP_DBG_OFF
-#endif
-
-/**
- * IP_REASS_DEBUG: Enable debugging in ip_frag.c for both frag & reass.
- */
-#if !defined IP_REASS_DEBUG || defined __DOXYGEN__
-#define IP_REASS_DEBUG LWIP_DBG_OFF
-#endif
-
-/**
- * RAW_DEBUG: Enable debugging in raw.c.
- */
-#if !defined RAW_DEBUG || defined __DOXYGEN__
-#define RAW_DEBUG LWIP_DBG_OFF
-#endif
-
-/**
- * MEM_DEBUG: Enable debugging in mem.c.
- */
-#if !defined MEM_DEBUG || defined __DOXYGEN__
-#define MEM_DEBUG LWIP_DBG_OFF
-#endif
-
-/**
- * MEMP_DEBUG: Enable debugging in memp.c.
- */
-#if !defined MEMP_DEBUG || defined __DOXYGEN__
-#define MEMP_DEBUG LWIP_DBG_OFF
-#endif
-
-/**
- * SYS_DEBUG: Enable debugging in sys.c.
- */
-#if !defined SYS_DEBUG || defined __DOXYGEN__
-#define SYS_DEBUG LWIP_DBG_OFF
-#endif
-
-/**
- * TIMERS_DEBUG: Enable debugging in timers.c.
- */
-#if !defined TIMERS_DEBUG || defined __DOXYGEN__
-#define TIMERS_DEBUG LWIP_DBG_OFF
-#endif
-
-/**
- * TCP_DEBUG: Enable debugging for TCP.
- */
-#if !defined TCP_DEBUG || defined __DOXYGEN__
-#define TCP_DEBUG LWIP_DBG_OFF
-#endif
-
-/**
- * TCP_INPUT_DEBUG: Enable debugging in tcp_in.c for incoming debug.
- */
-#if !defined TCP_INPUT_DEBUG || defined __DOXYGEN__
-#define TCP_INPUT_DEBUG LWIP_DBG_OFF
-#endif
-
-/**
- * TCP_FR_DEBUG: Enable debugging in tcp_in.c for fast retransmit.
- */
-#if !defined TCP_FR_DEBUG || defined __DOXYGEN__
-#define TCP_FR_DEBUG LWIP_DBG_OFF
-#endif
-
-/**
- * TCP_RTO_DEBUG: Enable debugging in TCP for retransmit
- * timeout.
- */
-#if !defined TCP_RTO_DEBUG || defined __DOXYGEN__
-#define TCP_RTO_DEBUG LWIP_DBG_OFF
-#endif
-
-/**
- * TCP_CWND_DEBUG: Enable debugging for TCP congestion window.
- */
-#if !defined TCP_CWND_DEBUG || defined __DOXYGEN__
-#define TCP_CWND_DEBUG LWIP_DBG_OFF
-#endif
-
-/**
- * TCP_WND_DEBUG: Enable debugging in tcp_in.c for window updating.
- */
-#if !defined TCP_WND_DEBUG || defined __DOXYGEN__
-#define TCP_WND_DEBUG LWIP_DBG_OFF
-#endif
-
-/**
- * TCP_OUTPUT_DEBUG: Enable debugging in tcp_out.c output functions.
- */
-#if !defined TCP_OUTPUT_DEBUG || defined __DOXYGEN__
-#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF
-#endif
-
-/**
- * TCP_RST_DEBUG: Enable debugging for TCP with the RST message.
- */
-#if !defined TCP_RST_DEBUG || defined __DOXYGEN__
-#define TCP_RST_DEBUG LWIP_DBG_OFF
-#endif
-
-/**
- * TCP_QLEN_DEBUG: Enable debugging for TCP queue lengths.
- */
-#if !defined TCP_QLEN_DEBUG || defined __DOXYGEN__
-#define TCP_QLEN_DEBUG LWIP_DBG_OFF
-#endif
-
-/**
- * UDP_DEBUG: Enable debugging in UDP.
- */
-#if !defined UDP_DEBUG || defined __DOXYGEN__
-#define UDP_DEBUG LWIP_DBG_OFF
-#endif
-
-/**
- * TCPIP_DEBUG: Enable debugging in tcpip.c.
- */
-#if !defined TCPIP_DEBUG || defined __DOXYGEN__
-#define TCPIP_DEBUG LWIP_DBG_OFF
-#endif
-
-/**
- * SLIP_DEBUG: Enable debugging in slipif.c.
- */
-#if !defined SLIP_DEBUG || defined __DOXYGEN__
-#define SLIP_DEBUG LWIP_DBG_OFF
-#endif
-
-/**
- * DHCP_DEBUG: Enable debugging in dhcp.c.
- */
-#if !defined DHCP_DEBUG || defined __DOXYGEN__
-#define DHCP_DEBUG LWIP_DBG_OFF
-#endif
-
-/**
- * AUTOIP_DEBUG: Enable debugging in autoip.c.
- */
-#if !defined AUTOIP_DEBUG || defined __DOXYGEN__
-#define AUTOIP_DEBUG LWIP_DBG_OFF
-#endif
-
-/**
- * DNS_DEBUG: Enable debugging for DNS.
- */
-#if !defined DNS_DEBUG || defined __DOXYGEN__
-#define DNS_DEBUG LWIP_DBG_OFF
-#endif
-
-/**
- * IP6_DEBUG: Enable debugging for IPv6.
- */
-#if !defined IP6_DEBUG || defined __DOXYGEN__
-#define IP6_DEBUG LWIP_DBG_OFF
-#endif
-/**
- * @}
- */
-
-/*
- --------------------------------------------------
- ---------- Performance tracking options ----------
- --------------------------------------------------
-*/
-/**
- * @defgroup lwip_opts_perf Performance
- * @ingroup lwip_opts_debug
- * @{
- */
-/**
- * LWIP_PERF: Enable performance testing for lwIP
- * (if enabled, arch/perf.h is included)
- */
-#if !defined LWIP_PERF || defined __DOXYGEN__
-#define LWIP_PERF 0
-#endif
-/**
- * @}
- */
-
-#endif /* LWIP_HDR_OPT_H */
diff --git a/stacks/lwip_stack/release/lwip_helper_files/include/sys.h b/stacks/lwip_stack/release/lwip_helper_files/include/sys.h
deleted file mode 100644
index 8eed041..0000000
--- a/stacks/lwip_stack/release/lwip_helper_files/include/sys.h
+++ /dev/null
@@ -1,455 +0,0 @@
-/**
- * @file
- * OS abstraction layer
- */
-
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * 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. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
- *
- * This file is part of the lwIP TCP/IP stack.
- *
- * Author: Adam Dunkels <adam@sics.se>
- */
-
-#ifndef LWIP_HDR_SYS_H
-#define LWIP_HDR_SYS_H
-
-#include "lwip/opt.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#if NO_SYS
-
-/* For a totally minimal and standalone system, we provide null
- definitions of the sys_ functions. */
- typedef u8_t sys_sem_t;
- typedef u8_t sys_mutex_t;
- typedef u8_t sys_mbox_t;
-
-#define sys_sem_new(s, c) ERR_OK
-#define sys_sem_signal(s)
-#define sys_sem_wait(s)
-#define sys_arch_sem_wait(s,t)
-#define sys_sem_free(s)
-#define sys_sem_valid(s) 0
-#define sys_sem_valid_val(s) 0
-#define sys_sem_set_invalid(s)
-#define sys_sem_set_invalid_val(s)
-#define sys_mutex_new(mu) ERR_OK
-#define sys_mutex_lock(mu)
-#define sys_mutex_unlock(mu)
-#define sys_mutex_free(mu)
-#define sys_mutex_valid(mu) 0
-#define sys_mutex_set_invalid(mu)
-#define sys_mbox_new(m, s) ERR_OK
-#define sys_mbox_fetch(m,d)
-#define sys_mbox_tryfetch(m,d)
-#define sys_mbox_post(m,d)
-#define sys_mbox_trypost(m,d)
-#define sys_mbox_free(m)
-#define sys_mbox_valid(m)
-#define sys_mbox_valid_val(m)
-#define sys_mbox_set_invalid(m)
-#define sys_mbox_set_invalid_val(m)
-
-#define sys_thread_new(n,t,a,s,p)
-
-#define sys_msleep(t)
-
-#else /* NO_SYS */
-
-/** Return code for timeouts from sys_arch_mbox_fetch and sys_arch_sem_wait */
-#define SYS_ARCH_TIMEOUT 0xffffffffUL
-
-/** sys_mbox_tryfetch() returns SYS_MBOX_EMPTY if appropriate.
- * For now we use the same magic value, but we allow this to change in future.
- */
-#define SYS_MBOX_EMPTY SYS_ARCH_TIMEOUT
-
-#include "lwip/err.h"
-#include "arch/sys_arch.h"
-
-/** Function prototype for thread functions */
- typedef void (*lwip_thread_fn) (void *arg);
-
-/* Function prototypes for functions to be implemented by platform ports
- (in sys_arch.c) */
-
-/* Mutex functions: */
-
-/** Define LWIP_COMPAT_MUTEX if the port has no mutexes and binary semaphores
- should be used instead */
-#ifndef LWIP_COMPAT_MUTEX
-#define LWIP_COMPAT_MUTEX 0
-#endif
-
-#if LWIP_COMPAT_MUTEX
-/* for old ports that don't have mutexes: define them to binary semaphores */
-#define sys_mutex_t sys_sem_t
-#define sys_mutex_new(mutex) sys_sem_new(mutex, 1)
-#define sys_mutex_lock(mutex) sys_sem_wait(mutex)
-#define sys_mutex_unlock(mutex) sys_sem_signal(mutex)
-#define sys_mutex_free(mutex) sys_sem_free(mutex)
-#define sys_mutex_valid(mutex) sys_sem_valid(mutex)
-#define sys_mutex_set_invalid(mutex) sys_sem_set_invalid(mutex)
-
-#else /* LWIP_COMPAT_MUTEX */
-
-/**
- * @ingroup sys_mutex
- * Create a new mutex.
- * Note that mutexes are expected to not be taken recursively by the lwIP code,
- * so both implementation types (recursive or non-recursive) should work.
- * @param mutex pointer to the mutex to create
- * @return ERR_OK if successful, another err_t otherwise
- */
- err_t sys_mutex_new (sys_mutex_t * mutex);
-/**
- * @ingroup sys_mutex
- * Lock a mutex
- * @param mutex the mutex to lock
- */
- void sys_mutex_lock (sys_mutex_t * mutex);
-/**
- * @ingroup sys_mutex
- * Unlock a mutex
- * @param mutex the mutex to unlock
- */
- void sys_mutex_unlock (sys_mutex_t * mutex);
-/**
- * @ingroup sys_mutex
- * Delete a semaphore
- * @param mutex the mutex to delete
- */
- void sys_mutex_free (sys_mutex_t * mutex);
-#ifndef sys_mutex_valid
-/**
- * @ingroup sys_mutex
- * Check if a mutex is valid/allocated: return 1 for valid, 0 for invalid
- */
- int sys_mutex_valid (sys_mutex_t * mutex);
-#endif
-#ifndef sys_mutex_set_invalid
-/**
- * @ingroup sys_mutex
- * Set a mutex invalid so that sys_mutex_valid returns 0
- */
- void sys_mutex_set_invalid (sys_mutex_t * mutex);
-#endif
-#endif /* LWIP_COMPAT_MUTEX */
-
-/* Semaphore functions: */
-
-/**
- * @ingroup sys_sem
- * Create a new semaphore
- * @param sem pointer to the semaphore to create
- * @param count initial count of the semaphore
- * @return ERR_OK if successful, another err_t otherwise
- */
- err_t sys_sem_new (sys_sem_t * sem, u8_t count);
-/**
- * @ingroup sys_sem
- * Signals a semaphore
- * @param sem the semaphore to signal
- */
- void sys_sem_signal (sys_sem_t * sem);
-/**
- * @ingroup sys_sem
- * Wait for a semaphore for the specified timeout
- * @param sem the semaphore to wait for
- * @param timeout timeout in milliseconds to wait (0 = wait forever)
- * @return time (in milliseconds) waited for the semaphore
- * or SYS_ARCH_TIMEOUT on timeout
- */
- u32_t sys_arch_sem_wait (sys_sem_t * sem, u32_t timeout);
-/**
- * @ingroup sys_sem
- * Delete a semaphore
- * @param sem semaphore to delete
- */
- void sys_sem_free (sys_sem_t * sem);
-/** Wait for a semaphore - forever/no timeout */
-#define sys_sem_wait(sem) sys_arch_sem_wait(sem, 0)
-#ifndef sys_sem_valid
-/**
- * @ingroup sys_sem
- * Check if a semaphore is valid/allocated: return 1 for valid, 0 for invalid
- */
- int sys_sem_valid (sys_sem_t * sem);
-#endif
-#ifndef sys_sem_set_invalid
-/**
- * @ingroup sys_sem
- * Set a semaphore invalid so that sys_sem_valid returns 0
- */
- void sys_sem_set_invalid (sys_sem_t * sem);
-#endif
-#ifndef sys_sem_valid_val
-/**
- * Same as sys_sem_valid() but taking a value, not a pointer
- */
-#define sys_sem_valid_val(sem) sys_sem_valid(&(sem))
-#endif
-#ifndef sys_sem_set_invalid_val
-/**
- * Same as sys_sem_set_invalid() but taking a value, not a pointer
- */
-#define sys_sem_set_invalid_val(sem) sys_sem_set_invalid(&(sem))
-#endif
-
-#ifndef sys_msleep
-/**
- * @ingroup sys_misc
- * Sleep for specified number of ms
- */
- void sys_msleep (u32_t ms); /* only has a (close to) 1 ms resolution. */
-#endif
-
-/* Mailbox functions. */
-
-/**
- * @ingroup sys_mbox
- * Create a new mbox of specified size
- * @param mbox pointer to the mbox to create
- * @param size (minimum) number of messages in this mbox
- * @return ERR_OK if successful, another err_t otherwise
- */
- err_t sys_mbox_new (sys_mbox_t * mbox, int size);
-/**
- * @ingroup sys_mbox
- * Post a message to an mbox - may not fail
- * -> blocks if full, only used from tasks not from ISR
- * @param mbox mbox to posts the message
- * @param msg message to post (ATTENTION: can be NULL)
- */
- void sys_mbox_post (sys_mbox_t * mbox, void *msg);
-/**
- * @ingroup sys_mbox
- * Try to post a message to an mbox - may fail if full or ISR
- * @param mbox mbox to posts the message
- * @param msg message to post (ATTENTION: can be NULL)
- */
- err_t sys_mbox_trypost (sys_mbox_t * mbox, void *msg);
-/**
- * @ingroup sys_mbox
- * Wait for a new message to arrive in the mbox
- * @param mbox mbox to get a message from
- * @param msg pointer where the message is stored
- * @param timeout maximum time (in milliseconds) to wait for a message (0 = wait forever)
- * @return time (in milliseconds) waited for a message, may be 0 if not waited
- or SYS_ARCH_TIMEOUT on timeout
- * The returned time has to be accurate to prevent timer jitter!
- */
- u32_t sys_arch_mbox_fetch (sys_mbox_t * mbox, void **msg, u32_t timeout);
-/* Allow port to override with a macro, e.g. special timeout for sys_arch_mbox_fetch() */
-#ifndef sys_arch_mbox_tryfetch
-/**
- * @ingroup sys_mbox
- * Wait for a new message to arrive in the mbox
- * @param mbox mbox to get a message from
- * @param msg pointer where the message is stored
- * @return 0 (milliseconds) if a message has been received
- * or SYS_MBOX_EMPTY if the mailbox is empty
- */
- u32_t sys_arch_mbox_tryfetch (sys_mbox_t * mbox, void **msg);
-#endif
-/**
- * For now, we map straight to sys_arch implementation.
- */
-#define sys_mbox_tryfetch(mbox, msg) sys_arch_mbox_tryfetch(mbox, msg)
-/**
- * @ingroup sys_mbox
- * Delete an mbox
- * @param mbox mbox to delete
- */
- void sys_mbox_free (sys_mbox_t * mbox);
-#define sys_mbox_fetch(mbox, msg) sys_arch_mbox_fetch(mbox, msg, 0)
-#ifndef sys_mbox_valid
-/**
- * @ingroup sys_mbox
- * Check if an mbox is valid/allocated: return 1 for valid, 0 for invalid
- */
- int sys_mbox_valid (sys_mbox_t * mbox);
-#endif
-#ifndef sys_mbox_set_invalid
-/**
- * @ingroup sys_mbox
- * Set an mbox invalid so that sys_mbox_valid returns 0
- */
- void sys_mbox_set_invalid (sys_mbox_t * mbox);
-#endif
-#ifndef sys_mbox_valid_val
-/**
- * Same as sys_mbox_valid() but taking a value, not a pointer
- */
-#define sys_mbox_valid_val(mbox) sys_mbox_valid(&(mbox))
-#endif
-#ifndef sys_mbox_set_invalid_val
-/**
- * Same as sys_mbox_set_invalid() but taking a value, not a pointer
- */
-#define sys_mbox_set_invalid_val(mbox) sys_mbox_set_invalid(&(mbox))
-#endif
-
-/**
- * @ingroup sys_misc
- * The only thread function:
- * Creates a new thread
- * ATTENTION: although this function returns a value, it MUST NOT FAIL (ports have to assert this!)
- * @param name human-readable name for the thread (used for debugging purposes)
- * @param thread thread-function
- * @param arg parameter passed to 'thread'
- * @param stacksize stack size in bytes for the new thread (may be ignored by ports)
- * @param prio priority of the new thread (may be ignored by ports) */
- sys_thread_t sys_thread_new (const char *name, lwip_thread_fn thread,
- void *arg, int stacksize, int prio);
-
-#endif /* NO_SYS */
-
-/* sys_init() must be called before anything else. */
- void sys_init (void);
-
-#ifndef sys_jiffies
-/**
- * Ticks/jiffies since power up.
- */
- u32_t sys_jiffies (void);
-#endif
-
-/**
- * @ingroup sys_time
- * Returns the current time in milliseconds,
- * may be the same as sys_jiffies or at least based on it.
- */
- u32_t sys_now (void);
-
-/* Critical Region Protection */
-/* These functions must be implemented in the sys_arch.c file.
- In some implementations they can provide a more light-weight protection
- mechanism than using semaphores. Otherwise semaphores can be used for
- implementation */
-#ifndef SYS_ARCH_PROTECT
-/** SYS_LIGHTWEIGHT_PROT
- * define SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection
- * for certain critical regions during buffer allocation, deallocation and memory
- * allocation and deallocation.
- */
-#if SYS_LIGHTWEIGHT_PROT
-
-/**
- * @ingroup sys_prot
- * SYS_ARCH_DECL_PROTECT
- * declare a protection variable. This macro will default to defining a variable of
- * type sys_prot_t. If a particular port needs a different implementation, then
- * this macro may be defined in sys_arch.h.
- */
-#define SYS_ARCH_DECL_PROTECT(lev) sys_prot_t lev
-/**
- * @ingroup sys_prot
- * SYS_ARCH_PROTECT
- * Perform a "fast" protect. This could be implemented by
- * disabling interrupts for an embedded system or by using a semaphore or
- * mutex. The implementation should allow calling SYS_ARCH_PROTECT when
- * already protected. The old protection level is returned in the variable
- * "lev". This macro will default to calling the sys_arch_protect() function
- * which should be implemented in sys_arch.c. If a particular port needs a
- * different implementation, then this macro may be defined in sys_arch.h
- */
-#define SYS_ARCH_PROTECT(lev) lev = sys_arch_protect()
-/**
- * @ingroup sys_prot
- * SYS_ARCH_UNPROTECT
- * Perform a "fast" set of the protection level to "lev". This could be
- * implemented by setting the interrupt level to "lev" within the MACRO or by
- * using a semaphore or mutex. This macro will default to calling the
- * sys_arch_unprotect() function which should be implemented in
- * sys_arch.c. If a particular port needs a different implementation, then
- * this macro may be defined in sys_arch.h
- */
-#define SYS_ARCH_UNPROTECT(lev) sys_arch_unprotect(lev)
- sys_prot_t sys_arch_protect (void);
- void sys_arch_unprotect (sys_prot_t pval);
-
-#else
-
-#define SYS_ARCH_DECL_PROTECT(lev)
-#define SYS_ARCH_PROTECT(lev)
-#define SYS_ARCH_UNPROTECT(lev)
-
-#endif /* SYS_LIGHTWEIGHT_PROT */
-
-#endif /* SYS_ARCH_PROTECT */
-
-/*
- * Macros to set/get and increase/decrease variables in a thread-safe way.
- * Use these for accessing variable that are used from more than one thread.
- */
-
-#ifndef SYS_ARCH_INC
-#define SYS_ARCH_INC(var, val) do { \
- SYS_ARCH_DECL_PROTECT(old_level); \
- SYS_ARCH_PROTECT(old_level); \
- var += val; \
- SYS_ARCH_UNPROTECT(old_level); \
- } while(0)
-#endif /* SYS_ARCH_INC */
-
-#ifndef SYS_ARCH_DEC
-#define SYS_ARCH_DEC(var, val) do { \
- SYS_ARCH_DECL_PROTECT(old_level); \
- SYS_ARCH_PROTECT(old_level); \
- var -= val; \
- SYS_ARCH_UNPROTECT(old_level); \
- } while(0)
-#endif /* SYS_ARCH_DEC */
-
-#ifndef SYS_ARCH_GET
-#define SYS_ARCH_GET(var, ret) do { \
- SYS_ARCH_DECL_PROTECT(old_level); \
- SYS_ARCH_PROTECT(old_level); \
- ret = var; \
- SYS_ARCH_UNPROTECT(old_level); \
- } while(0)
-#endif /* SYS_ARCH_GET */
-
-#ifndef SYS_ARCH_SET
-#define SYS_ARCH_SET(var, val) do { \
- SYS_ARCH_DECL_PROTECT(old_level); \
- SYS_ARCH_PROTECT(old_level); \
- var = val; \
- SYS_ARCH_UNPROTECT(old_level); \
- } while(0)
-#endif /* SYS_ARCH_SET */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LWIP_HDR_SYS_H */
diff --git a/stacks/lwip_stack/release/lwip_helper_files/include/timeouts.h b/stacks/lwip_stack/release/lwip_helper_files/include/timeouts.h
deleted file mode 100644
index 005db52..0000000
--- a/stacks/lwip_stack/release/lwip_helper_files/include/timeouts.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/**
- * @file
- * Timer implementations
- */
-
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * 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. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
- *
- * This file is part of the lwIP TCP/IP stack.
- *
- * Author: Adam Dunkels <adam@sics.se>
- * Simon Goldschmidt
- *
- */
-#ifndef LWIP_HDR_TIMEOUTS_H
-#define LWIP_HDR_TIMEOUTS_H
-
-#include "lwip/opt.h"
-#include "lwip/err.h"
-#if !NO_SYS
-#include "lwip/sys.h"
-#endif
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#ifndef LWIP_DEBUG_TIMERNAMES
-#ifdef LWIP_DEBUG
-#define LWIP_DEBUG_TIMERNAMES SYS_DEBUG
-#else /* LWIP_DEBUG */
-#define LWIP_DEBUG_TIMERNAMES 0
-#endif /* LWIP_DEBUG */
-#endif
-
-/** Function prototype for a stack-internal timer function that has to be
- * called at a defined interval */
- typedef void (*lwip_cyclic_timer_handler) (void);
-
-/** This struct contains information about a stack-internal timer function
- that has to be called at a defined interval */
- struct lwip_cyclic_timer
- {
- u32_t interval_ms;
- lwip_cyclic_timer_handler handler;
-#if LWIP_DEBUG_TIMERNAMES
- const char *handler_name;
-#endif /* LWIP_DEBUG_TIMERNAMES */
- };
-
-/** This array contains all stack-internal cyclic timers. To get the number of
- * timers, use LWIP_ARRAYSIZE() */
- extern const struct lwip_cyclic_timer lwip_cyclic_timers[];
-
-#if LWIP_TIMERS
-
-/** Function prototype for a timeout callback function. Register such a function
- * using sys_timeout().
- *
- * @param arg Additional argument to pass to the function - set up by sys_timeout()
- */
- typedef void (*sys_timeout_handler) (void *arg);
-
- struct sys_timeo
- {
- struct sys_timeo *next;
- u32_t time;
- sys_timeout_handler h;
- void *arg;
-#if LWIP_DEBUG_TIMERNAMES
- const char *handler_name;
-#endif /* LWIP_DEBUG_TIMERNAMES */
- };
-
- void sys_timeouts_init (void);
-
-#if LWIP_DEBUG_TIMERNAMES
- void sys_timeout_debug (u32_t msecs, sys_timeout_handler handler, void *arg,
- const char *handler_name);
-#define sys_timeout(msecs, handler, arg) sys_timeout_debug(msecs, handler, arg, #handler)
-#else /* LWIP_DEBUG_TIMERNAMES */
- void sys_timeout (u32_t msecs, sys_timeout_handler handler, void *arg);
-#endif /* LWIP_DEBUG_TIMERNAMES */
-
- void sys_untimeout (sys_timeout_handler handler, void *arg);
- void sys_restart_timeouts (void);
-#if NO_SYS
- void sys_check_timeouts (void);
- u32_t sys_timeouts_sleeptime (void);
-#else /* NO_SYS */
- void sys_timeouts_mbox_fetch (sys_mbox_t * mbox, void **msg);
-#endif /* NO_SYS */
-
-#else /* LWIP_TIMERS */
- typedef void (*sys_timeout_handler) (void *arg);
-
- void sys_timeouts_init (void);
- void sys_timeout (u32_t msecs, sys_timeout_handler handler, void *arg);
- void sys_untimeout (sys_timeout_handler handler, void *arg);
- void sys_timeouts_mbox_fetch (sys_mbox_t * mbox, void **msg);
- void cyclic_timer (void *arg);
- void tcpip_tcp_timer (void *arg);
- void tcp_timer_needed (void);
-
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LWIP_HDR_TIMEOUTS_H */
diff --git a/stacks/lwip_stack/release/lwip_helper_files/lwip/arch/atomic_32.h b/stacks/lwip_stack/release/lwip_helper_files/lwip/arch/atomic_32.h
deleted file mode 100644
index 15a058b..0000000
--- a/stacks/lwip_stack/release/lwip_helper_files/lwip/arch/atomic_32.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * atomic_32.h
- *
- */
-
-#ifndef ATOMIC_32_H_
-#define ATOMIC_32_H_
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- typedef struct
- {
- volatile int counter;
- } atomic_t;
-
-#define ATOMIC_INIT(i) {(i)}
-#define atomic_read(v) (*(volatile int *)&(v)->counter)
-#define atomic_set(v, i) (((v)->counter) = (i))
-
- static inline void atomic_add (int i, atomic_t * v)
- {
- __asm__ __volatile__ (
- /*LOCK_PREFIX "addl %1,%0" */
- "addl %1,%0":"+m" (v->counter):"ir" (i));
- }
-
- static inline void atomic_sub (int i, atomic_t * v)
- {
- __asm__ __volatile__ (
- /*LOCK_PREFIX "subl %1,%0" */
- "subl %1,%0":"+m" (v->counter):"ir" (i));
- }
-
- static __inline__ void atomic_inc (atomic_t * v)
- {
- __asm__ __volatile__ (
- /*LOCK_PREFIX "incl %0" */
- "incl %0":"+m" (v->counter));
- }
-
- static __inline__ void atomic_dec (atomic_t * v)
- {
- __asm__ __volatile__ (
- /*LOCK_PREFIX "decl %0" */
- "decl %0":"+m" (v->counter));
- }
-#ifdef __cplusplus
-}
-#endif
-#endif /* ATOMIC_32_H_ */
diff --git a/stacks/lwip_stack/release/lwip_helper_files/lwip/arch/cc.h b/stacks/lwip_stack/release/lwip_helper_files/lwip/arch/cc.h
deleted file mode 100644
index 4e21a75..0000000
--- a/stacks/lwip_stack/release/lwip_helper_files/lwip/arch/cc.h
+++ /dev/null
@@ -1,82 +0,0 @@
-#ifndef LWIP_ARCH_CC_H
-#define LWIP_ARCH_CC_H
-
-#include <sys/time.h>
-#include <sys/types.h>
-#include <stdint.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#ifndef LWIP_MAX_S16_NUM
-#define LWIP_MAX_S16_NUM ((s16_t)0x7fff)
-#endif
-
-#ifndef LWIP_MAX_U16_NUM
-#define LWIP_MAX_U16_NUM ((u16_t)0xFfff)
-#endif
-
-#ifndef LWIP_MAX_U32_NUM
-#define LWIP_MAX_U32_NUM ((u32_t)0xffffffff)
-#endif
-
-#ifndef LWIP_MAX_S32_NUM
-#define LWIP_MAX_S32_NUM ((s32_t)0x7fffffff)
-#endif
-
-#ifndef LWIP_MAX_U64_NUM
-#define LWIP_MAX_U64_NUM ((u64_t)0xffffffffffffffff)
-#endif
-
-#ifndef LWIP_MAX_S64_NUM
-#define LWIP_MAX_S64_NUM ((s64_t)0x7fffffffffffffff)
-#endif
-
-#define NONBLOCK_MODE_FOR_ALG 2 /* it is possible to get fail */
-#define BLOCK_MODE_FOR_ALG 1 /* will block till success */
-#define NONBLOCK_MODE_NOT_FOR_ALG 0
-
-typedef uint64_t u64_t;
-typedef int64_t s64_t;
-
-typedef uint32_t u32_t;
-typedef int32_t s32_t;
-
-typedef uint16_t u16_t;
-typedef int16_t s16_t;
-
-typedef uint8_t u8_t;
-typedef int8_t s8_t;
-
-typedef uintptr_t mem_ptr_t;
-
-#define PACK_STRUCT_FIELD(x) x
-#define PACK_STRUCT_STRUCT
-#define PACK_STRUCT_BEGIN
-#define PACK_STRUCT_END
-
-#define S16_F "d"
-#define U16_F "u"
-#define X16_F "x"
-
-#define S32_F "d"
-#define U32_F "u"
-#define X32_F "x"
-
-#define S64_F "ld"
-#define U64_F "lu"
-#define X64_F "x"
-
-#ifndef BYTE_ORDER
-#define BYTE_ORDER LITTLE_ENDIAN
-#endif
-
-//#define LWIP_PROVIDE_ERRNO
-
-#ifndef LWIP_PLATFORM_DIAG
-#define LWIP_PLATFORM_DIAG(x) do {printf x;} while(0)
-#endif
-#ifndef LWIP_DEBUG
-#define LWIP_DEBUG 1
-#endif
-#endif
diff --git a/stacks/lwip_stack/release/lwip_helper_files/lwip/arch/queue.h b/stacks/lwip_stack/release/lwip_helper_files/lwip/arch/queue.h
deleted file mode 100644
index 238ef05..0000000
--- a/stacks/lwip_stack/release/lwip_helper_files/lwip/arch/queue.h
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef __QUEUE_H__
-#define __QUEUE_H__
-#ifdef __cplusplus
-extern "C"
-{
-
-#endif
-#include "common_mem_base_type.h"
-#ifdef HAL_LIB
-#else
-#include "rte_ring.h"
-#endif
-#include "nsfw_mem_api.h"
-//#include "stackx_dfx_api.h"
-
-#include "sys.h"
-
- typedef struct queue
- {
- PRIMARY_ADDR mring_handle llring;
- } queue_t;
-
- err_t queue_push (queue_t * q, void *msg, int isTrypush);
- void *queue_pop (queue_t * q, u32_t * timeout, int isTryPop);
-
-#ifdef __cplusplus
-
-}
-#endif
-#endif
diff --git a/stacks/lwip_stack/release/lwip_helper_files/lwip/arch/sys_arch.h b/stacks/lwip_stack/release/lwip_helper_files/lwip/arch/sys_arch.h
deleted file mode 100644
index 92ff049..0000000
--- a/stacks/lwip_stack/release/lwip_helper_files/lwip/arch/sys_arch.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef STACKX_ARCH_SYS_ARCH_H
-#define STACKX_ARCH_SYS_ARCH_H
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include <sys/types.h>
-#include <semaphore.h>
-
-#include "cc.h"
-
-/*add by daifen 2012.7.27*/
- typedef uint64_t sys_thread_t;
-
- extern u64_t hz_per_ms;
-
- void stackx_global_lock (void);
- void stackx_global_unlock (void);
-
-#define SYS_ARCH_PROTECT(lev) stackx_global_lock()
-#define SYS_ARCH_UNPROTECT(lev) stackx_global_unlock()
-#define SYS_ARCH_DECL_PROTECT(lev)
-
-#ifdef __cplusplus
-
-}
-#endif
-#endif
diff --git a/stacks/lwip_stack/release/lwip_helper_files/lwip/arch/win_minmax.h b/stacks/lwip_stack/release/lwip_helper_files/lwip/arch/win_minmax.h
deleted file mode 100644
index e1e64ac..0000000
--- a/stacks/lwip_stack/release/lwip_helper_files/lwip/arch/win_minmax.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/**
- * lib/minmax.c: windowed min/max tracker by Kathleen Nichols.
- *
- */
-#ifndef MINMAX_H
-#define MINMAX_H
-
-#include "types.h"
-#include "rtp_branch_prediction.h"
-
-/* A single data point for our parameterized min-max tracker */
-struct minmax_sample
-{
- u32_t t; /* time measurement was taken */
- u32_t v; /* value measured */
-};
-
-/* State for the parameterized min-max tracker */
-struct minmax
-{
- struct minmax_sample s[3];
-};
-
-static inline u32_t
-minmax_get (const struct minmax *m)
-{
- return m->s[0].v;
-}
-
-static inline u32_t
-minmax_reset (struct minmax *m, u32_t t, u32_t meas)
-{
- struct minmax_sample val = {.t = t,.v = meas };
-
- m->s[2] = m->s[1] = m->s[0] = val;
- return m->s[0].v;
-}
-
-/* As time advances, update the 1st, 2nd, and 3rd choices. */
-static u32_t
-minmax_subwin_update (struct minmax *m, u32_t win,
- const struct minmax_sample *val)
-{
- u32_t dt = val->t - m->s[0].t;
-
- if (unlikely (dt > win))
- {
- /*
- * Passed entire window without a new val so make 2nd
- * choice the new val & 3rd choice the new 2nd choice.
- * we may have to iterate this since our 2nd choice
- * may also be outside the window (we checked on entry
- * that the third choice was in the window).
- */
- m->s[0] = m->s[1];
- m->s[1] = m->s[2];
- m->s[2] = *val;
- if (unlikely (val->t - m->s[0].t > win))
- {
- m->s[0] = m->s[1];
- m->s[1] = m->s[2];
- m->s[2] = *val;
- }
- }
- else if (unlikely (m->s[1].t == m->s[0].t) && dt > win / 4)
- {
- /*
- * We've passed a quarter of the window without a new val
- * so take a 2nd choice from the 2nd quarter of the window.
- */
- m->s[2] = m->s[1] = *val;
- }
- else if (unlikely (m->s[2].t == m->s[1].t) && dt > win / 2)
- {
- /*
- * We've passed half the window without finding a new val
- * so take a 3rd choice from the last half of the window
- */
- m->s[2] = *val;
- }
- return m->s[0].v;
-}
-
-/* Check if new measurement updates the 1st, 2nd or 3rd choice max. */
-static inline u32_t
-minmax_running_max (struct minmax *m, u32_t win, u32_t t, u32_t meas)
-{
- struct minmax_sample val = {.t = t,.v = meas };
-
- if (unlikely (val.v >= m->s[0].v) || /* found new max? */
- unlikely (val.t - m->s[2].t > win)) /* nothing left in window? */
- return minmax_reset (m, t, meas); /* forget earlier samples */
-
- if (unlikely (val.v >= m->s[1].v))
- m->s[2] = m->s[1] = val;
- else if (unlikely (val.v >= m->s[2].v))
- m->s[2] = val;
-
- return minmax_subwin_update (m, win, &val);
-}
-
-/* Check if new measurement updates the 1st, 2nd or 3rd choice min. */
-static inline u32_t
-minmax_running_min (struct minmax *m, u32_t win, u32_t t, u32_t meas)
-{
- struct minmax_sample val = {.t = t,.v = meas };
-
- if (unlikely (val.v <= m->s[0].v) || /* found new min? */
- unlikely (val.t - m->s[2].t > win)) /* nothing left in window? */
- return minmax_reset (m, t, meas); /* forget earlier samples */
-
- if (unlikely (val.v <= m->s[1].v))
- m->s[2] = m->s[1] = val;
- else if (unlikely (val.v <= m->s[2].v))
- m->s[2] = val;
-
- return minmax_subwin_update (m, win, &val);
-}
-
-#endif
diff --git a/stacks/lwip_stack/release/script/nstack_fun.sh b/stacks/lwip_stack/release/script/nstack_fun.sh
deleted file mode 100755
index df62e1e..0000000
--- a/stacks/lwip_stack/release/script/nstack_fun.sh
+++ /dev/null
@@ -1,596 +0,0 @@
-#!/bin/bash
-
-check_file_size()
-{
- if [ -n "$1" ]&&[ -f "$1" ]
- then
- local log_size=`stat -c %s $1`
- if [ ${log_size} -gt $MAX_LOG_FILE_SIZE ]
- then
- mv $1 $1.bk
- fi
- fi
-}
-
-log()
-{
- check_file_size $LOG_FILE
-
- #1 line number
- local printStr="$2"
- cur_date=`date +'%m%d %H:%M:%S.%6N' -u`
- pid=$$
- file=$0
- local log_head="I${cur_date} ${file##*/}:$1 ${pid}]"
-
- printf "${log_head} $printStr\n" >> $LOG_FILE 2>/dev/null
-}
-
-get_call_stack()
-{
- local proc_name="$1"
- log $LINENO "gdb info in call stack:"
- gdb -batch -ex "t a a bt" -p `pidof $proc_name`>> $LOG_FILE 2>/dev/null
- log $LINENO "top in call stack:"
- top -H -p `pidof $proc_name` -n 1 -b >> $LOG_FILE 2>/dev/null
- log $LINENO "mpstat in call stack:"
- mpstat -A >> $LOG_FILE 2>/dev/null
-}
-
-gdb_set()
-{
- local mod="$1"
- if [ "$mod" = "stop" ];then
- gdb -batch -ex "set g_hbt_switch=0" -p `pidof nStackMain`
- gdb -batch -ex "set g_hbt_switch=0" -p `pidof nStackMaster`
- log $LINENO "gdb stop"
- else
- gdb -batch -ex "set g_hbt_switch=1" -p `pidof nStackMain`
- gdb -batch -ex "set g_hbt_switch=1" -p `pidof nStackMaster`
- log $LINENO "gdb start"
- fi
-}
-
-get_core_mask()
-{
- local sys_core=`cat /proc/cpuinfo | grep processor | wc -l`
- log $LINENO "system has ${sys_core} cores"
- #if sys_core too large 2^$sys_core will overflow; so reset sys_core; z00203440 20170323
- if [ $sys_core -gt 8 ]
- then
- sys_core=8
- log $LINENO "sys_core too large reset to ${sys_core}"
- fi
-
- base=`echo | awk -v ex=$sys_core 'BEGIN{a=2^ex; print a}'`
- local temp=`expr $base - 1`
- printf %X $temp
- return $sys_core
-}
-
-init_log_file()
-{
- if [ -n $LOG_FILE_DIR ]&&[ ! -f $LOG_FILE_DIR ]
- then
- sudo mkdir -p $LOG_FILE_DIR
- fi
-
- check_file_size $LOG_FILE
-
- if [ -n $DPDK_FILE_DIR ]&&[ ! -f $DPDK_FILE_DIR ]
- then
- sudo mkdir -p $DPDK_FILE_DIR
- fi
-
- check_file_size $DPDK_FILE
-
- #must create the directory under the current user account
- if [ -n $RUNTIME_DIR ]&&[ ! -f $RUNTIME_DIR ]
- then
- mkdir -p $RUNTIME_DIR
- fi
-}
-
-delete_log_file() {
- if [ -n $RUNNING_FILE_DIR ]&&[ -d $RUNNING_FILE_DIR ]&&[ -n $RUNNING_FILE_NAME ]; then
- rm -rf $RUNNING_FILE_DIR/*${RUNNING_FILE_NAME}*
- fi
- if [ -n $RUNNING_FILE_DIR ]&&[ -d $RUNNING_FILE_DIR ]&&[ -n $OPERATION_FILE_NAME ]; then
- rm -rf $RUNNING_FILE_DIR/*${OPERATION_FILE_NAME}*
- fi
- if [ -n $RUNNING_FILE_DIR ]&&[ -d $RUNNING_FILE_DIR ]&&[ -n $GLOG_FAILURE_FILE_NAME ]; then
- rm -rf $RUNNING_FILE_DIR/*${GLOG_FAILURE_FILE_NAME}*
- fi
- if [ -n $RUNNING_FILE_DIR ]&&[ -d $RUNNING_FILE_DIR ]&&[ -n $NSTACK_FAILURE_FILE_NAME ]; then
- rm -rf $RUNNING_FILE_DIR/*${NSTACK_FAILURE_FILE_NAME}*
- fi
- if [ -n $MASTER_FILE_DIR ]&&[ -d $MASTER_FILE_DIR ]&&[ -n $MASTER_FILE_NAME ]; then
- rm -rf $MASTER_FILE_DIR/*${MASTER_FILE_NAME}*
- fi
- if [ -n $MASTER_FILE_DIR ]&&[ -d $MASTER_FILE_DIR ]&&[ -n $GLOG_FAILURE_FILE_NAME ]; then
- rm -rf $MASTER_FILE_DIR/*${GLOG_FAILURE_FILE_NAME}*
- fi
- if [ -n $MASTER_FILE_DIR ]&&[ -d $MASTER_FILE_DIR ]&&[ -n $NSTACK_FAILURE_FILE_NAME ]; then
- rm -rf $MASTER_FILE_DIR/*${NSTACK_FAILURE_FILE_NAME}*
- fi
- if [ -n $LOG_FILE_DIR ]&&[ -d $LOG_FILE_DIR ]&&[ -n $LOG_FILE_NAME ]; then
- rm -rf $LOG_FILE_DIR/*${LOG_FILE_NAME}*
- fi
- if [ -n $DPDK_FILE_DIR ]&&[ -d $DPDK_FILE_DIR ]&&[ -n $DPDK_FILE_NAME ]; then
- rm -rf $DPDK_FILE_DIR/*${DPDK_FILE_NAME}*
- fi
- if [ -n $RUNTIME_DIR ]&&[ -d $RUNTIME_DIR ]; then
- rm -rf $RUNTIME_DIR
- fi
- if [ -n ${MASTER_EXEC_PATH} ]&&[ -d $MASTER_EXEC_PATH ]; then
- rm -rf $MASTER_EXEC_PATH
- fi
-}
-
-init_hugepage()
-{
- log $LINENO "init hugepage..."
-##############################################################
-#
-# TO DO:
-# verify the free pages carefully, but not with 1G pagesize
-#
-#############################################################
-
- #for 1G hugepage
-
- # check total hugepage number
-# local nr_pagedir=/sys/devices/system/node/node0/hugepages/hugepages-1048576kB/nr_hugepages
-# if [ ! -f ${nr_pagedir} ]
-# then
-# log $LINENO "system not support 1G huge pages, exit!"
-# exit 1
-# fi
-
- # local nr_huge_pages=`cat ${nr_pagedir}`
- # if [ ${nr_huge_pages} -lt 3 ]
- # then
- # log $LINENO "total huge pages is not set correctly, current ${nr_huge_pages}, exit!"
- # exit 1
- # fi
-
- # check free hugepage number
- # local fr_pagedir=/sys/devices/system/node/node0/hugepages/hugepages-1048576kB/free_hugepages
- # if [ ! -f ${fr_pagedir} ]
- # then
- # log $LINENO "system not support 1G huge pages, exit!"
- # exit 1
- # fi
-
- # local fr_huge_pages=`cat ${fr_pagedir}`
- # if [ ${fr_huge_pages} -lt 3 ]
- # then
- # log $LINENO "free huge pages is not set correctly, current ${fr_huge_pages}, exit!"
- # lsof $HUGE_DIR >> $LOG_FILE 2>/dev/null
- # exit 1
- # fi
-
- # mount | grep $HUGE_DIR >> $LOG_FILE 2>/dev/null
- # if [ $? -eq 0 ] ; then
- # log $LINENO "$HUGE_DIR dir exist"
- # if test $(pgrep -f $1 | wc -l) -eq 0 ; then
- # log $LINENO "proccess $1 not exist and clean huge files"
- # if [ -n $HUGE_DIR ]&&[ -d $HUGE_DIR ]; then
- # rm -rf $HUGE_DIR/*
- # fi
- # else
- # log $LINENO "proccess $1 exist"
- # fi
- # else
- # log $LINENO "$HUGE_DIR not exist and create"
- # sudo mkdir -p $HUGE_DIR
- #directory right can't larger than 750
-
- # cur_user=`whoami`
- # if [ "root" != "$cur_user" ]
- # then
- # non_root_uid=`id -u $cur_user`
- # non_root_gid=`id -g $cur_user`
- # sudo mount -t hugetlbfs -o pagesize=1G,uid=$non_root_uid,gid=$non_root_gid none $HUGE_DIR >> $LOG_FILE 2>/dev/null
- # else
- # mount -t hugetlbfs -o pagesize=1G none $HUGE_DIR >> $LOG_FILE 2>/dev/null
- # fi
- # fi
-}
-
-recover_hugepage()
-{
- log $LINENO "recover hugepage..."
-
- if [ -n "$HUGE_DIR" ]&&[ -d "$HUGE_DIR" ]; then
- rm -rf $HUGE_DIR/*
- fi
-}
-
-init_network()
-{
- log $LINENO "init network..."
-
- recover_network
-
- sudo modprobe uio
-
- local script_path=$(cd "$(dirname "$0")"; pwd)
- local is_igb_uio_loaded=`lsmod | grep igb_uio | wc -l`
- if [ ${is_igb_uio_loaded} -eq 0 ]
- then
- log $LINENO "igb_uio is not installed. install it now."
- sudo insmod $DPDK_MOD_PATH/igb_uio.ko
- fi
-
- # check if there is un-recognized nic
- sudo $DPDK_TOOL_DIR/dpdk-devbind.py -s | grep -A32 "Other network" | \
- grep unused | awk -F"'" '{print $1, $2}' | while read NIC_BFS BIND_DRIVER_NAME
- do
- local TYPE_CHECK_ixgbe=`echo $BIND_DRIVER_NAME |grep "82599ES 10-Gigabit SFI/SFP+ Network Connection"|wc -l`
- local TYPE_CHECK_ixgbevf=`echo $BIND_DRIVER_NAME |grep "82599 Ethernet Controller Virtual Function"|wc -l`
- local TYPE_CHECK_vmxnet3=`echo $BIND_DRIVER_NAME |grep "VMXNET3 Ethernet Controller"|wc -l`
- local TYPE_CHECK_virtio=`echo $BIND_DRIVER_NAME |grep "Virtio network device"|wc -l`
-
- if [ $TYPE_CHECK_ixgbe -gt 0 ]; then
- sudo $DPDK_TOOL_DIR/dpdk-devbind.py --bind=ixgbe $NIC_BFS
- elif [ $TYPE_CHECK_ixgbevf -gt 0 ]; then
- sudo $DPDK_TOOL_DIR/dpdk-devbind.py --bind=ixgbevf $NIC_BFS
- elif [ $TYPE_CHECK_vmxnet3 -gt 0 ]; then
- sudo $DPDK_TOOL_DIR/dpdk-devbind.py --bind=vmxnet3 $NIC_BFS
- elif [ $TYPE_CHECK_virtio -gt 0 ]; then
- sudo $DPDK_TOOL_DIR/dpdk-devbind.py --bind=virtio-pci $NIC_BFS
- fi
-
- done
-}
-
-recover_network()
-{
- log $LINENO "recover network..."
-
- if [ -z "$DPDK_NIC_LIST_FILE" ]||[ ! -f "$DPDK_NIC_LIST_FILE" ]
- then
- log $LINENO "$DPDK_NIC_LIST_FILE is not exist. There is no nic used by nstack to unbind."
- else
- log $LINENO "The NIC(s) to unbind: "
- cat $DPDK_NIC_LIST_FILE | awk -F" '|' | drv=| unused=" '{print $1,$4}' >> $LOG_FILE 2>/dev/null
- cat $DPDK_NIC_LIST_FILE | awk -F" '|' | drv=| unused=" '{print $1,$4}' | while read NIC_BFS BIND_DRIVER_TYPE
- do
- sudo $DPDK_TOOL_DIR/dpdk-devbind.py --bind=$BIND_DRIVER_TYPE $NIC_BFS >> $LOG_FILE 2>/dev/null
- done
- rm $DPDK_NIC_LIST_FILE
- fi
-
- touch $DPDK_NIC_LIST_FILE
- chmod 600 $DPDK_NIC_LIST_FILE
-}
-
-
-check_args_main()
-{
-if [ -z $HUGE_DIR ]||[ -z $MEM_SIZE ]||[ -z $RTP_CORE_MASK ]||[ -z $SLEEP_INTERVAL ]||\
- [ -z $BIND_CPU ]||[ -z $START_TYPE ]
-then
- log $LINENO "nStackMain Args is null"
- return 1
-fi
-
-# check CORE_MASK -- see in get_core_mask()
-# check HUGE_DIR
-if [ -z $HUGE_DIR ]||[ ! -d $HUGE_DIR ]; then
- log $LINENO "HUGE_DIR="$HUGE_DIR" is invalid"
- return 1
-fi
-
-# check MEM_SIZE
-if [ $MEM_SIZE -lt 2048 ]||[ $MEM_SIZE -gt 32768 ]; then
- log $LINENO "MEM_SIZE="$MEM_SIZE" is invalid"
- return 1
-fi
-
-# check RTP_CORE_MASK
-if [ $RTP_CORE_MASK -lt 1 ]; then
- log $LINENO "RTP_CORE_MASK="$RTP_CORE_MASK" is invalid"
- return 1
-fi
-
-# check SLEEP_INTERVAL
-if [ $SLEEP_INTERVAL -lt 0 ]; then
- log $LINENO "SLEEP_INTERVAL="$SLEEP_INTERVAL" is invalid"
- return 1
-fi
-
-# check BIND_CPU
-if [ $BIND_CPU -lt 0 ]; then
- log $LINENO "BIND_CPU="$BIND_CPU" is invalid"
- return 1
-fi
-
-# check START_TYPE
-if [ $START_TYPE -lt 0 ]||[ $START_TYPE -gt 5 ]; then
- log $LINENO "START_TYPE="$START_TYPE" is invalid"
- return 1
-fi
-
-return 0
-}
-
-run_nStackMain()
-{
-
- log $LINENO "run nstack main..."
-
- sudo setcap CAP_IPC_OWNER,CAP_FOWNER,CAP_NET_ADMIN,CAP_IPC_LOCK,CAP_NET_RAW,CAP_SYS_RAWIO,CAP_SYS_ADMIN,CAP_CHOWN,CAP_SYS_NICE=eip ./bin/nStackMain 2>/dev/null
-
- local script_path=$(cd "$(dirname "$0")"; pwd)
- export NSTACK_CONFIG_PATH=${script_path}/../configure
- export LD_LIBRARY_PATH=${script_path}/lib64/:$LD_LIBRARY_PATH
- if [ "$NSTACK_LOG_ON" = "PERF" ]
- then
- export NSTACK_LOG_ON=PERF
- else
- export NSTACK_LOG_ON=INF
- fi
-
- log $LINENO "$env NSTACK_CONFIG_PATH=$NSTACK_CONFIG_PATH"
- log $LINENO "$env DPDK_TOOL_DIR=$DPDK_TOOL_DIR"
- log $LINENO "$env LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
- log $LINENO "$env DPDK_LIB_PATH=$DPDK_LIB_PATH"
- log $LINENO "./nStackMain -c $1 -n 4 --huge-dir=$2 --proc-type=primary --file-prefix nStackMain -m $3 $7 $8 stack -c $4 -sleep $5 -bind_cpu $6"
- check_file_size $DPDK_FILE
- cd ..; cd bin/
- ./nStackMain -c $1 -n 4 --huge-dir=$2 --proc-type=primary --file-prefix nStackMain -m $3 $7 $8 stack -c $4 -sleep $5 -bind_cpu $6 >> $DPDK_FILE &
-}
-
-
-stop_nStackProcess()
-{
- log $LINENO "$1 exiting..."
-
- local i=0
-
- while [ ${i} -lt $2 ]
- do
- #pid=`ps aux | grep $1 |grep -v grep| awk '{print $2}'`
- pid=`pidof $1`
- if [ "x${pid}" != "x" ]
- then
- kill -9 $pid 2>/dev/null
- else
- break
- fi
- i=`expr ${i} + 1`
- sleep 1
- done
-}
-
-stop_nStackApps()
-{
- log $LINENO "stop the apps that use the shared nstackhuge memory..."
-
- app_pid=`lsof $HUGE_DIR | awk '{print $2}'`
- if [ "x${app_pid}" != "x" ]
- then
- kill -9 ${app_pid} 2>/dev/null
- fi
-}
-
-get_nstack_bin()
-{
- local app=$1
- master_pid=`pidof $app | head -n 1`
- if [ "x${master_pid}" != "x" ];then
- sudo readlink -f "/proc/${master_pid}/exe" | sed "s/$app$//g" 2>/dev/null
- fi
-}
-
-
-
-get_abs_path()
-{
- local input_path=$1
- if [ -d "$input_path" -o -f "$input_path" ]; then
- echo "$(dirname $(readlink -e $input_path))/$(basename $input_path)"
- return 0
- fi
- echo $input_path
- return 1
-}
-
-
-
-CONFIG_FILE="nStackConfig.json"
-VAR_FILE="nstack_var.sh"
-
-modify_nstack_log_path()
-{
- if echo $1 |grep -Eq '^((/[a-zA-Z_]+[a-zA-Z0-9_-]+(/[a-zA-Z0-9_-]+)*/?)|/)$' > /dev/null
- then
- local parameter=$1
- else
- log $LINENO "the path is invalid, use the default config path!"
- return
- fi
-
- if [ ! -d $1 ]; then
- log $LINENO "the folder is not existed, use the default config!"
- return
- fi
-
- if [ ! -w $1 ]; then
- log $LINENO "the folder has no permission, use the default config!"
- return
- fi
-
- local script_path=$(cd "$(dirname "$0")"; pwd)
- local config_name=${script_path}/configure/$CONFIG_FILE
-
- if [ ! -f $config_name ]; then
- log $LINENO "$CONFIG_FILE no exit! use default config in code."
- return
- fi
-
- sed -i 's#\("stackpool_log_path": "\).*#\1'"$1"'",#g' ${config_name}
- sed -i 's#\("master_log_path": "\).*#\1'"$1"'",#g' ${config_name}
- sed -i 's#\("nstack_log_path": "\).*#\1'"$1"'",#g' ${config_name}
- sed -i 's#\("dpdk_log_path": "\).*#\1'"$1"'"#g' ${config_name}
-}
-
-modify_log_var()
-{
- local script_path=$(cd "$(dirname "$0")"; pwd)
- local config_name=${script_path}/configure/$CONFIG_FILE
-
- if [ ! -f $config_name ]; then
- log $LINENO "$CONFIG_FILE no exit! use default config in code."
- return
- fi
-
- local running_log_path=`grep -Po '"stackpool_log_path": ".*?"' $config_name | sed -n -e 's/"//gp' | awk -F' ' '{print $2}'`
- local master_log_path=`grep -Po '"master_log_path": ".*?"' $config_name | sed -n -e 's/"//gp' | awk -F' ' '{print $2}'`
- local nstack_log_path=`grep -Po '"nstack_log_path": ".*?"' $config_name | sed -n -e 's/"//gp' | awk -F' ' '{print $2}'`
- local dpdk_log_path=`grep -Po '"dpdk_log_path": ".*?"' $config_name | sed -n -e 's/"//gp' | awk -F' ' '{print $2}'`
-
-#modify the nstack_var.sh
- local var_config_name=${script_path}/script/$VAR_FILE
-
- if [ ! -f $var_config_name ]; then
- log $LINENO "$VAR_FILE not exist , exit!"
- exit 1
- fi
-
-#check the path from json if it is OK.
- if [ -n "$running_log_path" ]&&[ -w "$running_log_path" ]; then
- sed -i "s:RUNNING_FILE_DIR=.*:RUNNING_FILE_DIR=${running_log_path}:g" $var_config_name
- else
- log $LINENO "stackpool_log_path:$running_log_path in $CONFIG_FILE is invalid, use the default config!"
- fi
-
- if [ -n "$master_log_path" ]&&[ -w "$master_log_path" ]; then
- sed -i "s:MASTER_FILE_DIR=.*:MASTER_FILE_DIR=${master_log_path}:g" $var_config_name
- else
- log $LINENO "master_log_path:$master_log_path in $CONFIG_FILE is invalid, use the default config!"
- fi
-
- if [ -n "$nstack_log_path" ]&&[ -w "$nstack_log_path" ]; then
- sed -i "s:LOG_FILE_DIR=.*:LOG_FILE_DIR=${nstack_log_path}:g" $var_config_name
- else
- log $LINENO "nstack_log_path:$nstack_log_path in $CONFIG_FILE is invalid, use the default config!"
- fi
-
- if [ -n "$dpdk_log_path" ]&&[ -w "$dpdk_log_path" ]; then
- sed -i "s:DPDK_FILE_DIR=.*:DPDK_FILE_DIR=${dpdk_log_path}:g" $var_config_name
- else
- log $LINENO "dpdk_log_path:$dpdk_log_path in $CONFIG_FILE is invalid, use the default config!"
- fi
-}
-
-
-modify_local_ip_env()
-{
-
-#modify the nstack_var.sh
- local var_config_name=${script_path}/script/$VAR_FILE
-
- if [ ! -f $var_config_name ]; then
- log $LINENO "$VAR_FILE not exist , exit!"
- exit 1
- fi
-
- sed -i "s:VM_ID=.*:VM_ID=${nstack_alarm_local_ip}:g" $var_config_name 2>/dev/null
-}
-
-
-delete_pid_file()
-{
- if [ -n "$PID_FILE" ]&&[ -f "$PID_FILE" ]
- then
- rm -rf ${PID_FILE}
- fi
-}
-
-save_pid_file()
-{
- if [ ! -d ${PID_FILE_DIR} ];
- then
- sudo mkdir -p ${PID_FILE_DIR}
- chmod 750 ${PID_FILE_DIR}
- fi
-
- if [ -f ${PID_FILE} ];
- then
- cur_pid=`cat ${PID_FILE}`
- if [ ${cur_pid} != $1 ];
- then
- rm -rf ${PID_FILE}
- else
- return
- fi
- fi
-
- touch ${PID_FILE}
- echo $1 > $PID_FILE
-
- chown paas:paas $PID_FILE
- chmod 640 $PID_FILE
-}
-
-write_pid_to_file()
-{
- retry=3
- i=0
- fail=1
-
- while [ ${i} -lt ${retry} ]
- do
- PID=`pidof nStackMaster`
- if [ ${PID} ]
- then
- fail=0
- break
- fi
-
- i=`expr ${i} + 1`
-
- sleep 1
- done
-
- if [ ${fail} -ne 0 ]
- then
- return 1
- fi
-
- if [ ! -d ${PID_FILE_DIR} ];
- then
- sudo mkdir -p ${PID_FILE_DIR}
- chmod 750 ${PID_FILE_DIR}
- fi
-
- touch ${PID_FILE}
- echo $PID > $PID_FILE
- #check log file right
- chown paas:paas $PID_FILE
- chmod 640 $PID_FILE
- return 0
-}
-
-
-
-install_config()
-{
- # set nStackConfig values
- if [ -n "$DEF_SOCK_NUM" ] ;then
- sed -i "s/\"socket_num\":[ \t0-9]*,/\"socket_num\":$DEF_SOCK_NUM,/g" ./configure/nStackConfig.json
- fi
-}
-
-copy_config()
-{
- # $1 for src nStackServer path
- # $2 for dst nStackServer path
-
- # NOTE: set src socket_num value into dst path config file, this is for copying old configuration from old version to new version path when upgrading.
- SRC_SOCK_NUM=`grep 'socket_num' $1/configure/nStackConfig.json | awk -F"," '{for (i=1;i<=NF;++i) print $i}' | awk 'gsub("\"socket_num\":","") {sub("^[ \t]*","");sub("[ \t]*$",""); print $0}'`
- sed -i "s/\"socket_num\":[ \t0-9]*,/\"socket_num\":$SRC_SOCK_NUM,/g" $2/configure/nStackConfig.json
-}
diff --git a/stacks/lwip_stack/release/script/nstack_var.sh b/stacks/lwip_stack/release/script/nstack_var.sh
deleted file mode 100755
index a654d34..0000000
--- a/stacks/lwip_stack/release/script/nstack_var.sh
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/bin/bash
-
-PID_FILE_DIR=/var/ICTS_BASE/run
-PID_FILE=${PID_FILE_DIR}/nstack.pid
-
-RUNNING_FILE_DIR=/var/log/nStack
-RUNNING_FILE_NAME=running.log
-
-OPERATION_FILE_NAME=operation.log
-NSTACK_CTRL_LOG_FILE_NAME=omc_ctrl.log
-GLOG_FAILURE_FILE_NAME=fail_dump.log
-NSTACK_FAILURE_FILE_NAME=nstack_error.log
-
-MASTER_FILE_DIR=/var/log/nStack
-MASTER_FILE_NAME=master.log
-
-LOG_FILE_DIR=/var/log/nStack
-LOG_FILE=${LOG_FILE_DIR}/nstack.log
-LOG_FILE_NAME=nstack.log
-
-DPDK_FILE_DIR=/var/log/nstack-dpdk
-DPDK_FILE=${DPDK_FILE_DIR}/nstack_dpdk.log
-DPDK_FILE_NAME=nstack_dpdk.log
-
-#this is env variable, it is for nstack usage, it will be modified from ./start_nstack -i hostinfo.ini
-
-export VM_ID=agent-node-x
-
-export DPDK_INSTALL_PATH="/usr/share/dpdk/"
-export DPDK_LIB_PATH=${DPDK_INSTALL_PATH}/x86_64-native-linuxapp-gcc/lib
-export DPDK_TOOL_DIR=${DPDK_INSTALL_PATH}/usertools
-export DPDK_MOD_PATH=/usr/lib/modules/`uname -r`/extra/dpdk
-
-cur_user=`whoami`
-if [ "root" != "${cur_user}" ]
-then
- HOME_DIR=$HOME
- if [ -z "${HOME}" ]
- then
- HOME_DIR=/var/run
- fi
-else
- HOME_DIR=/var/run
-fi
-RUNTIME_DIR=$HOME_DIR/ip_module
-
-DPDK_NIC_LIST_FILE=$RUNTIME_DIR/.nstack_dpdk_nic_list
-
-#single file is 50M=50*1024*1024
-MAX_LOG_FILE_SIZE=52428800
-HUGE_PAGES=2048
-HUGE_DIR=/mnt/nstackhuge
-
-SLEEP_INTERVAL=100 # tcpip thread sleep time, unit: us
-BIND_CPU=1
-
-MEM_SIZE=3072
-RTP_CORE_MASK=2
-
-MASTER_EXEC_PATH="/product/gpaas/nStackMaster/bin"
-RUN_NSTACK_FILE=run_nstack.sh
-
-
-#default config definitions
-DEF_SOCK_NUM=8192
diff --git a/stacks/lwip_stack/release/script/run_nstack_main.sh b/stacks/lwip_stack/release/script/run_nstack_main.sh
deleted file mode 100755
index 9d6049a..0000000
--- a/stacks/lwip_stack/release/script/run_nstack_main.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/bash
-
-DIR=`S=\`readlink "$0"\`; [ -z "$S" ] && S=$0; dirname $S`
-cd $DIR
-
-. ./nstack_var.sh
-. ./nstack_fun.sh
-
-########################################################
-# check parameter
-
-log $LINENO "dir=$DIR"
-
-########################################################
-# init netrork:unbind->/* modprobe uio->insmod igb_uio */->bind
-init_network
-
-########################################################
-# start nstack main
-CORE_MASK=1
-log $LINENO "start run nstackmain"
-log $LINENO "COREMASK=$CORE_MASK, HUGE_DIR=$1, MEM_SIZE=$2, RTP_CORE_MASK=$RTP_CORE_MASK, SLEEP_INTERVAL=$SLEEP_INTERVAL, BIND_CPU=$BIND_CPU"
-log $LINENO "VDEV=$VDEV, NO_PCI=$NO_PCI"
-
-run_nStackMain $CORE_MASK $1 $2 $RTP_CORE_MASK $SLEEP_INTERVAL $BIND_CPU $3 $4
-
-exit 0
diff --git a/stacks/lwip_stack/release/script/run_nstack_master.sh b/stacks/lwip_stack/release/script/run_nstack_master.sh
deleted file mode 100755
index 8da0d49..0000000
--- a/stacks/lwip_stack/release/script/run_nstack_master.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/sh
-
-DIR=`S=\`readlink "$0"\`; [ -z "$S" ] && S=$0; dirname $S`
-cd $DIR
-. ./nstack_var.sh
-
-
-if [ -n "${MASTER_EXEC_PATH}" ]; then
- mkdir -p $MASTER_EXEC_PATH
- chown -R paas: $MASTER_EXEC_PATH
- chmod 750 $MASTER_EXEC_PATH
- cp ../bin/nStackMaster $MASTER_EXEC_PATH -rf
- cp ../configure/nStackConfig.json $MASTER_EXEC_PATH -rf
- ln -s -f $(cd "$(dirname "$0")"; pwd)/run_nstack_main.sh $MASTER_EXEC_PATH/${RUN_NSTACK_FILE}
- cd $MASTER_EXEC_PATH
-fi
-
-runnStackMaster(){
- sudo setcap CAP_IPC_OWNER,CAP_NET_ADMIN,CAP_DAC_OVERRIDE=eip ./nStackMaster
-
- script_path=$(cd "$(dirname "$0")"; pwd)
- export NSTACK_CONFIG_PATH=${script_path}
-
- ./nStackMaster -c $1 -n 4 --huge-dir=$2 -m $3 --proc-type=$4 >> ${DPDK_FILE}
-}
-
-runnStackMaster $1 $2 $3 $4 &
-
-exit 0
diff --git a/stacks/lwip_stack/release/send_alarm.sh b/stacks/lwip_stack/release/send_alarm.sh
deleted file mode 100755
index 46ea413..0000000
--- a/stacks/lwip_stack/release/send_alarm.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/bash
-
-cur_dir=$(cd "$(dirname "$0")"; pwd)
-alarm_history=${cur_dir}/.nstack_fault_alarm
-
-. ./script/nstack_var.sh
-. ./script/nstack_fun.sh
-
-if [ ! -f ${alarm_history} ]; then
- ./nStackCtrl --module alm -n nsMain -t abnormal
- log $LINENO "nstack is not running ok, send fault alarm"
- touch ${alarm_history}
-else
- log $LINENO "nstack is not running ok, send fault alarm already"
-fi
-
-exit 0 \ No newline at end of file
diff --git a/stacks/lwip_stack/release/start_nstack.sh b/stacks/lwip_stack/release/start_nstack.sh
deleted file mode 100755
index 35fe9df..0000000
--- a/stacks/lwip_stack/release/start_nstack.sh
+++ /dev/null
@@ -1,149 +0,0 @@
-#!/bin/bash
-
-
-script_path=$(cd "$(dirname "$0")"; pwd)
-
-. ${script_path}/script/nstack_var.sh
-. ${script_path}/script/nstack_fun.sh
-
-config_name=${script_path}/script/nstack_var.sh
-if [ ! -e $config_name ]; then
- log $LINENO "nstack_var.sh not exit, plz check!"
- exit 1
-fi
-
-########################################################
-##get the log info from the parameter of ./start -l XXX -a XXX ###
-nstack_log_path=""
-hostinfo_path=""
-ARGS=`getopt -o "l:i:a:" -l "vdev:,file-prefix:,no-pci" -n "start_nstack.sh" -- "$@"`
-eval set -- "${ARGS}"
-while true
-do
- case "$1" in
- -l)
- nstack_log_path="$2"
- shift 2
- ;;
- -i)
- hostinfo_path="$2"
- shift 2
- ;;
- --vdev)
- VDEV="--vdev=$2"
- shift 2
- ;;
- --file-prefix)
- FILE_PREFIX="--file-prefix=$2"
- shift 2
- ;;
- --no-pci)
- NO_PCI="--no-pci"
- shift 1
- ;;
- --)
- shift
- break
- ;;
- *)
- echo "Option illegal, please check input!"
- exit 1
- ;;
- esac
-done
-
-hostinfo_stat=0
-
-(
-flock -e -n 200
-if [ $? -eq 1 ]
-then
- log $LINENO "another process is running now, exit"
- exit 1
-fi
-
-########################################################
-# modify the nstack & dpdk log path config: nStackConfig.json
-if [ -n "$nstack_log_path" ]; then
- modify_nstack_log_path $nstack_log_path
-fi
-
-if [ -n "$hostinfo_path" -a -e "$hostinfo_path" -a -r "$hostinfo_path" ]; then
- nstack_alarm_local_ip=($(awk -F '=' '/\['AGENT'\]/{a=1}a==1&&$1"="~/^(\s*)(VM_ID)(\s*)(=)/{print $2 ;exit}' $hostinfo_path))
- modify_local_ip_env
-else
- hostinfo_stat=1
-fi
-
-
-########################################################
-#set the log path in nstack_var.sh#####
-modify_log_var
-) 200>>./lockfile
-
-if [ -f "lockfile" ]; then
- rm lockfile
-fi
-
-. ${script_path}/script/nstack_var.sh
-
-
-########################################################
-# init_log_file:nstack.log and dpdk.log
-# if need print log, the messgae need add after init_log_file
-init_log_file
-
-if [ "$hostinfo_stat" -ne 0 ]; then
- log $LINENO "please use correct -i parameter for start_nstack.sh"
- log $LINENO "host info path:$hostinfo_path"
- hostinfo_stat=0
-fi
-
-log $LINENO "######################start nstack######################"
-
-########################################################
-# check application running
-process_nstack_main=nStackMain
-
-pid_nstack=`pidof $process_nstack_main`
-
-nstack_ctrl_path=${script_path}/bin
-
-pgrep nStackMain
-main_run_status=$?
-if [ ${main_run_status} -eq 0 ]; then
- log $LINENO "nStackMain is running ok, please stop it first!"
- save_pid_file ${pid_master}
- exit 0
-fi
-
-huge_files=`ls /mnt/nstackhuge`
-if [ "x${huge_files}" != "x" ]
-then
- if [ "x${pid_nstack}" = "x" ]
- then
- log $LINENO "huge page file exist and nStackMain not exist"
- exit 1
- fi
-fi
-
-
-########################################################
-# set hugepage
-init_hugepage $process_nstack_main
-
-
-########################################################
-# install config
-install_config
-
-########################################################
-core_mask=1
-START_TYPE="primary"
-log $LINENO "./script/run_nstack_main.sh ${core_mask} $HUGE_DIR $MEM_SIZE $START_TYPE $VDEV $NO_PCI"
-${script_path}/script/run_nstack_main.sh $HUGE_DIR $MEM_SIZE $VDEV $NO_PCI
-
-print_pid=$(ps -ux | grep nStackMain | awk '{print $2}' | awk 'NR == 2')
-echo "nStackMain PID:$print_pid"
-log $LINENO "nstack start success"
-exit 0
diff --git a/stacks/lwip_stack/release/stop_nstack.sh b/stacks/lwip_stack/release/stop_nstack.sh
deleted file mode 100755
index 48d1af7..0000000
--- a/stacks/lwip_stack/release/stop_nstack.sh
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/bin/bash
-
-
-script_path=$(cd "$(dirname "$0")"; pwd)
-
-. ${script_path}/script/nstack_var.sh
-. ${script_path}/script/nstack_fun.sh
-
-config_name=${script_path}/script/nstack_var.sh
-if [ ! -e $config_name ]; then
- log $LINENO "$config_name not exit, plz pay attention and add back!,or it has resourcce leak."
-fi
-
-cur_user=`whoami`
-
-########################################################
-# init_log_file:nstack.log and dpdk.log
-init_log_file
-log $LINENO "#######################stop nstack#######################"
-
-#############################################
-# step1 stop nstack master
-retry=3
-stop_nStackProcess nStackMaster $retry
-
-#############################################
-# step2 stop nstack
-stop_nStackProcess nStackMain $retry
-
-
-#############################################
-# step3 stop all apps that usg the nstack hugepage
-if [ ${cur_user} = "root" ]; then
- stop_nStackApps
-else
- log $LINENO "not root, app not stopped"
-fi
-
-#############################################
-# step4 delete the huge page files created by nstack
-recover_hugepage
-
-#############################################
-# step5 recover the nic configuration
-recover_network
-
-#############################################
-# step6 delete pid file
-delete_pid_file
-
-exit 0
diff --git a/stacks/lwip_stack/release/uninstall.sh b/stacks/lwip_stack/release/uninstall.sh
deleted file mode 100755
index 92ae5fe..0000000
--- a/stacks/lwip_stack/release/uninstall.sh
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/bin/bash
-
-. ./script/nstack_var.sh
-. ./script/nstack_fun.sh
-
-########################################################
-# init_log_file:nstack.log and dpdk.log
-init_log_file
-log $LINENO "#######################uninstall nstack#######################"
-
-
-#############################################
-# step1 stop the applications that use the shared huge memory of nstack
-stop_nStackApps
-
-#############################################
-# step2 delete the huge page files created by nstack
-recover_hugepage
-
-
-#############################################
-# step3 recover the nic configuration
-recover_network
-
-
-#############################################
-# step4 delete nstack log files
-delete_log_file
-
-
-# log file has been deleted, should print on screen now
-echo "uninstall nStack successfully!"
-
-exit 0
diff --git a/stacks/lwip_stack/release_tar.sh b/stacks/lwip_stack/release_tar.sh
deleted file mode 100644
index d3cfa68..0000000
--- a/stacks/lwip_stack/release_tar.sh
+++ /dev/null
@@ -1,86 +0,0 @@
-if [ ! -d "./nStackServer" ]; then
- mkdir ./nStackServer
-else
- rm -rf ./nStackServer/*
-fi
-
-if [ ! -d "./nStackClient" ]; then
- mkdir ./nStackClient
-else
- rm -rf ./nStackClient/*
-fi
-
-if [ ! -d "./nStackTools" ]; then
- mkdir ./nStackTools
-else
- rm -rf ./nStackTools/*
-fi
-
-if [ -f "./nStackServer.tar.gz" ]; then
- rm -rf ./nStackServer.tar.gz
-fi
-
-if [ -f "./nStackClient.tar.gz" ]; then
- rm -rf ./nStackClient.tar.gz
-fi
-
-if [ -f "./nStackTools.tar.gz" ]; then
- rm -rf ./nStackTools.tar.gz
-fi
-
-mkdir ./nStackServer/lib64
-cp ./release/lib64/liblwip_dpdk.so ./release/lib64/libnStackAPI.so ./release/lib64/libnstackcmd.so ./release/lib64/libsecurec.so ./nStackServer/lib64
-mkdir ./nStackServer/bin
-cp ./release/bin/nStackCtrl ./release/bin/nStackMain ./release/bin/nStackMaster ./release/bin/set_permission.sh ./nStackServer/bin
-mkdir ./nStackServer/conf
-cp ./release/conf/nstack.monitrc ./release/conf/nstack_ctl ./release/conf/srvnstack ./nStackServer/conf
-mkdir ./nStackServer/configure
-cp ./release/configure/ip_data.json ./release/configure/network_data_tonStack.json ./release/configure/nStackConfig.json ./nStackServer/configure
-mkdir ./nStackServer/script
-cp -d ./release/script/nstack_fun.sh ./release/script/nstack_var.sh ./release/script/run_nstack_main.sh ./release/script/run_nstack_master.sh ./nStackServer/script
-mkdir ./nStackServer/tools
-cp ./release/tools/nping ./nStackServer/tools/
-
-cp ./release/check_status.sh ./release/send_alarm.sh ./release/start_nstack.sh ./release/stop_nstack.sh ./release/graceful_stop_nstack.sh ./release/uninstall.sh ./release/upgrade_nstack.sh ./nStackServer/
-
-dos2unix ./nStackServer/*.sh
-find ./nStackServer -type f | grep -E "*.sh|*.py" | xargs chmod +x
-
-mkdir ./nStackClient/lib64
-cp ./release/lib64/liblwip_dpdk.so ./release/lib64/libnStackAPI.so ./release/lib64/libsecurec.so ./nStackClient/lib64
-mkdir ./nStackClient/include
-cp ./release/include/nstack_custom_api.h ./nStackClient/include
-
-cp ./release/tools/nping ./release/tools/ntcpdump ./nStackTools/
-
-# set permission
-chown -R paas: ./nStackServer/
-chown -R paas: ./nStackClient/
-chown -R paas: ./nStackTools/
-
-chmod 750 ./nStackServer
-chmod 550 ./nStackServer/bin/
-chmod 750 ./nStackServer/configure
-chmod 750 ./nStackServer/script
-chmod 750 ./nStackServer/conf
-chmod 750 ./nStackServer/lib64
-chmod 750 ./nStackServer/tools
-chmod 750 ./nStackClient
-chmod 750 ./nStackClient/include
-chmod 750 ./nStackClient/lib64
-chmod 750 ./nStackTools
-
-chmod 750 ./nStackServer/bin/nStack*
-chmod 750 ./nStackServer/*.sh
-chmod 750 ./nStackServer/bin/*.sh
-chmod 750 ./nStackServer/conf/*
-chmod 750 ./nStackServer/script/*.sh
-chmod 640 ./nStackServer/lib64/*
-chmod 640 ./nStackServer/configure/*
-chmod 500 ./nStackServer/bin/set_permission.sh
-chmod 750 ./nStackTools/*
-
-
-tar -zcvf nStackServer.tar.gz nStackServer
-tar -zcvf nStackClient.tar.gz nStackClient
-tar -zcvf nStackTools.tar.gz nStackTools
diff --git a/stacks/lwip_stack/run_stackx.txt b/stacks/lwip_stack/run_stackx.txt
deleted file mode 100644
index dbc936e..0000000
--- a/stacks/lwip_stack/run_stackx.txt
+++ /dev/null
@@ -1,52 +0,0 @@
-#########################################################################
-#
-# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-# 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.
-#########################################################################
-
-#build DPDK, DMM, lwip stack by calling build script:
-====================================================
- cd dmm/stacks/lwip_stack/vagrant
- build.sh
-
-#update interface name if required(default enp0s8) in dmm/stacks/lwip_stack/vagrant/start_nstackMain.sh
-#Start nStackMain:
-=================
- 1.for the first time (to configure json files and start nStackMain)
- cd dmm/stacks/lwip_stack/vagrant
- ./start_nstackMain.sh
-
- 2.from secod time:
- cd dmm/stacks/lwip_stack/release
- ./start_nstack.sh
-
-#get configured client/server ip from dmm/stacks/lwip_stack/release/bin/ip_data.json
-#can get the log path details from dmm/stacks/lwip_stack/release/bin/nStackConfig.json
-
-#run app:
-========
- cd dmm/stacks/lwip_stack/app_test
-
- #server
- ./vs_epoll -p 20000 -d {client_ip} -a 10000 -s {ser_ip} -l 200 -t 5000000 -i 0 -f 1 -r 20000 -n 1 -w 10 -u 10000 -e 10 -x 1
-
- #client
- ./vc_epoll -p 20000 -d {ser_ip} -a 10000 -s {client_ip} -l 200 -t 50000 -i 1000 -f 1 -r 20000 -n 1 -w 10 -u 10000 -e 10 -x 1
-
- #perf
- for better performance set environment variable NSTACK_LOG_ON=PERF before running nStakMain and app
-
-#stop nStackMain:
-================
- cd dmm/stacks/lwip_stack/release
- ./stop_nstack.sh
diff --git a/stacks/lwip_stack/src/CMakeLists.txt b/stacks/lwip_stack/src/CMakeLists.txt
deleted file mode 100644
index 6aacf07..0000000
--- a/stacks/lwip_stack/src/CMakeLists.txt
+++ /dev/null
@@ -1,62 +0,0 @@
-#########################################################################
-#
-# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-# 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.
-#########################################################################
-
-SET(RTP_DIRECTORIES "${PROJECT_SOURCE_DIR}/src/include/")
-
-INCLUDE_DIRECTORIES(
- framework/log/
- framework/include/
- framework/common/include/
- framework/common/base/include/
- ${RTP_DIRECTORIES}
- ${RTP_DIRECTORIES}/generic
- ../../SecureC/include/
- ../../../thirdparty/glog/glog-0.3.4/src/
-)
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g -fPIC -m64 -mssse3 -std=gnu89")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -Wshadow -Wfloat-equal -Wformat=2")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector -fstack-protector-all")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-z,relro,-z,now -Wl,--disable-new-dtags,--rpath,../lib64")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-z,noexecstack -mcmodel=medium")
-
-if(WITH_HAL_LIB)
-SET(RTP_CONFIG ${PROJECT_SOURCE_DIR}/src/include/rtp_config.h)
-else()
- SET(RTP_CONFIG ${CMAKE_CURRENT_LIST_DIR}/../../../src/framework/common/base/include/common/common_sys_config.h)
-endif()
-SET(COMPLE_CONFIG ${PROJECT_SOURCE_DIR}/src/include/compile_config.h)
-ADD_DEFINITIONS(-include ${RTP_CONFIG})
-ADD_DEFINITIONS(-include ${COMPLE_CONFIG})
-ADD_DEFINITIONS(-D_GNU_SOURCE)
-ADD_DEFINITIONS(-DDPDK_MODULE=0)
-#ADD_DEFINITIONS(-DNSTACK_RSRDMA)
-LINK_DIRECTORIES(${LIB_PATH_SHARED} ${LIB_PATH_STATIC})
-
-if(WITH_SECUREC_LIB)
-LINK_LIBRARIES(pthread dl securec)
-else()
-LINK_LIBRARIES(pthread dl)
-endif()
-
-ADD_SUBDIRECTORY(maintain)
-ADD_SUBDIRECTORY(io_adpt)
-ADD_SUBDIRECTORY(sbr)
-#ADD_SUBDIRECTORY(nStackCtrl)
-ADD_SUBDIRECTORY(nStackMain)
-ADD_SUBDIRECTORY(tools)
-ADD_SUBDIRECTORY(alarm)
-#ADD_SUBDIRECTORY(nstackcmd)
diff --git a/stacks/lwip_stack/src/alarm/CMakeLists.txt b/stacks/lwip_stack/src/alarm/CMakeLists.txt
deleted file mode 100644
index 3de07b0..0000000
--- a/stacks/lwip_stack/src/alarm/CMakeLists.txt
+++ /dev/null
@@ -1,34 +0,0 @@
-#########################################################################
-#
-# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-# 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.
-#########################################################################
-
-FILE(GLOB_RECURSE ALARM *.c)
-
-LINK_LIBRARIES(m dl rt dmm_api)
-if(WITH_SECUREC_LIB)
-INCLUDE_DIRECTORIES(
- ./
- ${JSON_C_SRC}
- ${SECUREC_SRC}
- ${CMAKE_CURRENT_LIST_DIR}/../include/
-)
-else()
-INCLUDE_DIRECTORIES(
- ./
- ${JSON_C_SRC}
- ${CMAKE_CURRENT_LIST_DIR}/../include/
-)
-endif()
-ADD_LIBRARY(nStackAlarm STATIC ${ALARM})
diff --git a/stacks/lwip_stack/src/alarm/alarm.c b/stacks/lwip_stack/src/alarm/alarm.c
deleted file mode 100644
index c158144..0000000
--- a/stacks/lwip_stack/src/alarm/alarm.c
+++ /dev/null
@@ -1,861 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "types.h"
-#include "nsfw_mgr_com_api.h"
-#include "nsfw_fd_timer_api.h"
-#include "alarm.h"
-#include "alarm_api.h"
-#include<time.h>
-#include<sys/time.h>
-#include "nsfw_init.h"
-#include "nstack_log.h"
-#include "json.h"
-#include "nstack_securec.h"
-#include <stdlib.h>
-#include "nstack_dmm_adpt.h"
-
-char g_vmid[MAX_VMID_LEN + 1] = "agent-node-x";
-
-extern nsfw_timer_info *nsfw_timer_reg_timer (u32 timer_type, void *data,
- nsfw_timer_proc_fun fun,
- struct timespec time_left);
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif /* __cplusplus */
-
-// note:the first element is reserved
-alarm_data g_alarm_data[ALARM_EVENT_MAX] = { };
-
-alarm_result
-ms_alarm_check_func (void *para)
-{
- alarm_result ret_alarm;
- int para_value = (long) para;
-
- ret_alarm.alarm_id_get = ALARM_EVENT_NSTACK_MAIN_ABNORMAL;
-
- if (para_value == ALARM_PRODUCT)
- {
- ret_alarm.alarm_flag_get = ALARM_PRODUCT;
- }
- else if (para_value == ALARM_CLEAN)
- {
- ret_alarm.alarm_flag_get = ALARM_CLEAN;
- }
- else
- {
- ret_alarm.alarm_id_get = ALARM_EVENT_MAX;
- }
-
- ret_alarm.alarm_reason_get = ALARM_REASON_NSMAIN;
-
- return ret_alarm;
-
-}
-
-/*******************************************************************
-* Copyright 2017, Huawei Tech. Co., Ltd.
-* ALL RIGHTS RESERVED
-*Description : period check alarm expire handle function
-********************************************************************/
-
-int
-ns_alarm_timer_resend_fun (u32 timer_type, void *argv)
-{
- int i;
- struct timespec time_left;
- alarm_data *alarm_value;
-
- for (i = ALARM_EVENT_BASE; i < ALARM_EVENT_MAX; i++)
- {
- alarm_value = &g_alarm_data[i];
-
- if ((alarm_value->valid_flag == 1)
- && (alarm_value->send_succ_flag == ALARM_SEND_FAIL))
- {
- /* nStack only send nsMain normal alarm */
- ns_send_alarm_inner (alarm_value->_alarm_id,
- (void *) (alarm_value->_alarm_flag), 1, 0);
- }
- }
-
- time_left.tv_sec = ALARM_RESEND_TIMER_LENGTH;
- time_left.tv_nsec = 0;
- nsfw_timer_info *timer_info =
- nsfw_timer_reg_timer (0, NULL, ns_alarm_timer_resend_fun, time_left);
- if (NULL == timer_info)
- {
- NSAM_LOGERR ("nsfw_timer_reg_timer fail");
- }
-
- return 0;
-}
-
-void
-ns_alarm_set_sendFlag (enum_alarm_id alarmId, int flag)
-{
- if ((alarmId <= 0) || (alarmId >= ALARM_EVENT_MAX)
- || (0 == g_alarm_data[alarmId].valid_flag) || ((flag != ALARM_SEND_FAIL)
- && (flag !=
- ALARM_SEND_SUCC)))
- {
- NSAM_LOGERR ("alarm_id is invalid or not reg or flag invalid");
- return;
- }
- g_alarm_data[alarmId].send_succ_flag = flag;
-}
-
-/*******************************************************************
-* Copyright 2017, Huawei Tech. Co., Ltd.
-* ALL RIGHTS RESERVED
-*Description : alarm module init
-********************************************************************/
-int
-ns_alarm_module_init (void *param)
-{
- u32 proc_type = (u32) ((long long) param);
- enum_alarm_id i = ALARM_EVENT_BASE;
- alarm_reason j = ALARM_REASON_BEGIN;
- const char *pst_vm_id = NULL;
- alarm_para tcp_alarm_para;
- struct timespec time_left;
-
- for (i = ALARM_EVENT_BASE; i < ALARM_EVENT_MAX; i++)
- {
- g_alarm_data[i]._alarm_type = ALARM_SEND_ONCE;
-
- for (j = ALARM_REASON_BEGIN; j < ALARM_REASON_MAX; j++)
- {
- g_alarm_data[i]._alarm_para.func_alarm_check[j] = NULL;
- g_alarm_data[i]._alarm_para.alarm_reason_set[j] = ALARM_REASON_MAX;
- g_alarm_data[i].alarm_time_laps[j] = 0;
- }
- g_alarm_data[i]._alarm_para.period_alarm.time_length = 0;
- g_alarm_data[i]._alarm_id = i;
- g_alarm_data[i].valid_flag = 0;
- g_alarm_data[i]._alarm_flag = ALARM_CLEAN;
- g_alarm_data[i].alarm_reason_cnt = 0;
- g_alarm_data[i].send_succ_flag = ALARM_SEND_SUCC;
- }
-
- switch (proc_type)
- {
- case NSFW_PROC_MAIN:
- case NSFW_PROC_CTRL:
-
- /* modify ip address to vm id */
- pst_vm_id = getenv ("VM_ID");
-
- if (INVALID_STR_LEN (pst_vm_id, MIN_VM_ID_LEN, MAX_VM_ID_LEN))
- {
- NSAM_LOGWAR
- ("invalid VM_ID,please check env VM_ID]vm_id=%s, proc_type=%u",
- pst_vm_id, proc_type);
- }
- else
- {
- int retVal = STRNCPY_S (g_vmid, MAX_VMID_LEN + 1, pst_vm_id,
- strlen (pst_vm_id));
-
- if (EOK != retVal)
- {
- NSAM_LOGERR ("STRNCPY_S failed]ret=%d", retVal);
- }
- }
-
- tcp_alarm_para.period_alarm.time_length = 0; /* 5 second period */
- tcp_alarm_para.alarm_reason_count = 1; /*both resource */
-
- tcp_alarm_para.func_alarm_check[0] = ms_alarm_check_func;
- tcp_alarm_para.alarm_reason_set[0] = ALARM_REASON_NSMAIN;
- (void) ns_reg_alarm (ALARM_EVENT_NSTACK_MAIN_ABNORMAL, ALARM_SEND_ONCE,
- &tcp_alarm_para);
-
- time_left.tv_sec = ALARM_INIT_RESEND_TIMER_LENGTH;
- time_left.tv_nsec = 0;
- nsfw_timer_info *timer_info =
- nsfw_timer_reg_timer (0, NULL, ns_alarm_timer_resend_fun, time_left);
- if (NULL == timer_info)
- {
- NSAM_LOGERR ("nsfw_timer_reg_timer fail");
- }
-
- break;
- default:
- break;
- }
-
- return 0;
-}
-
-#define JSON_NEW_OBJ(obj, cb, para1, para2)\
- {\
- obj = json_object_new_object();\
- if (obj == NULL)\
- {\
- (void)cb(para1);\
- (void)cb(para2);\
- return -1;\
- }\
- }
-
-#define JSON_NEW_STRING_OBJ(str, obj, cb, para1, para2)\
- {\
- obj = json_object_new_string((str));\
- if (obj == NULL)\
- {\
- (void)cb(para1);\
- (void)cb(para2);\
- return -1;\
- }\
- }
-
-#define JSON_NEW_STRING_OBJ_1(val, obj, cb, para1, para2,para3)\
- {\
- obj = json_object_new_string((val));\
- if (obj == NULL)\
- {\
- (void)cb(para1);\
- (void)cb(para2);\
- (void)cb(para3);\
- return -1;\
- }\
- }
-
-#define JSON_NEW_INT_OBJ(val, obj, cb, para1, para2)\
- {\
- obj = json_object_new_int((val));\
- if (obj == NULL)\
- {\
- (void)cb(para1);\
- (void)cb(para2);\
- return -1;\
- }\
- }
-
-/*****************************************************************************
-* Prototype : ns_get_alarm_body
-* Description : get body by alarm parameter
-* Input : char *buf
-* int buf_len
-* alarm_result alarm_res
-* Output : None
-* Return Value : int
-*****************************************************************************/
-int
-ns_get_alarm_body (char *buf, int buf_len, alarm_result alarm_res)
-{
-#define ALARM_NAME_LENGTH 100
-#define COMPONENT_NAME "nStack"
- int retVal;
- size_t str_len;
- int alarm_id = alarm_res.alarm_id_get + 27000;
- struct timeval t_val;
- struct tm now_time;
- char *alarm_string = NULL, *alarm_reason_info = NULL, *alarm_desc = NULL;
- json_object *temp_jso = NULL, *alarm_info = NULL;
- alarm_info_s_out *alarmpara_out = NULL;
- int perceivedSeverity_value = 0;
- char *action_string = NULL;
- if (buf == NULL || (buf_len < (int) sizeof (alarm_info_s_out)))
- {
- NSAM_LOGERR ("input para invalid");
- return -1;
- }
- alarmpara_out = (alarm_info_s_out *) buf;
-
- /*use sizeof(alarmpara_out->alarmId) instead of devil figure 16 */
- retVal =
- SPRINTF_S (alarmpara_out->alarmId, sizeof (alarmpara_out->alarmId), "%d",
- alarm_id);
- if (-1 == retVal)
- {
- NSAM_LOGERR ("SPRINTF_S failed]ret=%d", retVal);
- return -1;
- }
-
- (void) gettimeofday (&t_val, NULL);
- time_t t_sec = (time_t) t_val.tv_sec;
- /*return value check */
- if (NULL == localtime_r (&t_sec, &now_time))
- {
- NSAM_LOGERR ("localtime_r failed]");
- return -1;
- }
-
- /*use sizeof(alarmpara_out->alarmtime) instead of devil figure 32 */
- retVal =
- SPRINTF_S (alarmpara_out->alarmtime, sizeof (alarmpara_out->alarmtime),
- "%4d%02d%02d%02d%02d%02d%06ld", now_time.tm_year + 1900,
- now_time.tm_mon + 1, now_time.tm_mday, now_time.tm_hour,
- now_time.tm_min, now_time.tm_sec, (long) t_val.tv_usec);
- if (-1 == retVal)
- {
- NSAM_LOGERR ("SPRINTF_S failed]ret=%d", retVal);
- return -1;
- }
-
- retVal =
- STRNCPY_S (alarmpara_out->comptentname,
- sizeof (alarmpara_out->comptentname), COMPONENT_NAME,
- strlen (COMPONENT_NAME));
- if (EOK != retVal)
- {
- NSAM_LOGERR ("STRNCPY_S failed]ret=%d", retVal);
- return -1;
- }
-
- switch (alarm_res.alarm_reason_get)
- {
- case ALARM_REASON_SOCKET:
- /* alarmName and reason info is incorrect */
- alarm_reason_info = "socketResource";
- if (alarm_res.alarm_flag_get == ALARM_PRODUCT)
- {
- alarm_string = "networkResourceOverload";
- alarm_desc = "more than 80 percent used";
- perceivedSeverity_value = 2;
- action_string = "alarm";
- }
- else
- {
- alarm_string = "networkResourceNormal";
- alarm_desc = "less than 60 percent used";
- perceivedSeverity_value = 5;
- action_string = "clear";
- }
-
- break;
- case ALARM_REASON_MSG_BUF:
- alarm_reason_info = "SendBufResource";
- if (alarm_res.alarm_flag_get == ALARM_PRODUCT)
- {
- alarm_string = "networkResourceOverload";
- alarm_desc = "more than 80 percent used";
- perceivedSeverity_value = 2;
- action_string = "alarm";
- }
- else
- {
- alarm_string = "networkResourceNormal";
- alarm_desc = "less than 60 percent used";
- perceivedSeverity_value = 5;
- action_string = "clear";
- }
-
- break;
- case ALARM_REASON_NSMAIN:
- /* process status alarm change from event to alarm/clear */
- alarm_reason_info = "networkProcStatus";
- if (alarm_res.alarm_flag_get == ALARM_PRODUCT)
- {
- alarm_string = "network-data-down";
- alarm_desc = "networkProcDown";
- perceivedSeverity_value = 2;
- action_string = "alarm";
- }
- else
- {
- alarm_string = "network-data-up";
- alarm_desc = "networkProcUp";
- perceivedSeverity_value = 5;
- action_string = "clear";
- }
-
- break;
- default:
- NSAM_LOGERR ("alarm_reason incorrect]ret=%d",
- alarm_res.alarm_reason_get);
- return -1;
- }
-
- str_len = 0;
-
- json_object *alarmlist = json_object_new_object ();
- if (NULL == alarmlist)
- {
- NSAM_LOGERR ("alarmlist is NULL");
- return -1;
- }
-
- json_object *alarmItem = json_object_new_object ();
-
- if (NULL == alarmItem)
- {
- NSAM_LOGERR ("alarmItem is NULL");
- (void) json_object_put (alarmlist);
- return -1;
- }
-
- JSON_NEW_STRING_OBJ ("ICTS_BASE=1", temp_jso, json_object_put, alarmlist,
- alarmItem);
- json_object_object_add (alarmItem, "neDN", temp_jso);
- JSON_NEW_STRING_OBJ ("service", temp_jso, json_object_put, alarmlist,
- alarmItem);
- json_object_object_add (alarmItem, "neType", temp_jso);
- JSON_NEW_STRING_OBJ ("ICTS_BASE", temp_jso, json_object_put, alarmlist,
- alarmItem);
- json_object_object_add (alarmItem, "neName", temp_jso);
- JSON_NEW_STRING_OBJ ("service", temp_jso, json_object_put, alarmlist,
- alarmItem);
- json_object_object_add (alarmItem, "objectClass", temp_jso);
- JSON_NEW_STRING_OBJ ("nStack", temp_jso, json_object_put, alarmlist,
- alarmItem);
- json_object_object_add (alarmItem, "moDN", temp_jso);
- JSON_NEW_STRING_OBJ ("nStack", temp_jso, json_object_put, alarmlist,
- alarmItem);
- json_object_object_add (alarmItem, "moName", temp_jso);
- JSON_NEW_STRING_OBJ ("default", temp_jso, json_object_put, alarmlist,
- alarmItem);
- json_object_object_add (alarmItem, "userId", temp_jso);
-
- JSON_NEW_INT_OBJ (alarm_id, temp_jso, json_object_put, alarmlist,
- alarmItem);
- json_object_object_add (alarmItem, "alarmId", temp_jso);
-
- JSON_NEW_INT_OBJ (10001, temp_jso, json_object_put, alarmlist, alarmItem);
- json_object_object_add (alarmItem, "groupId", temp_jso);
-
- JSON_NEW_STRING_OBJ (g_vmid, temp_jso, json_object_put, alarmlist,
- alarmItem);
- json_object_object_add (alarmItem, "objectInstance", temp_jso);
- JSON_NEW_INT_OBJ (8, temp_jso, json_object_put, alarmlist, alarmItem);
- json_object_object_add (alarmItem, "eventType", temp_jso);
-
- JSON_NEW_STRING_OBJ (alarm_string, temp_jso, json_object_put, alarmlist,
- alarmItem);
- json_object_object_add (alarmItem, "alarmName", temp_jso);
-
- JSON_NEW_INT_OBJ (perceivedSeverity_value, temp_jso, json_object_put,
- alarmlist, alarmItem);
-
- json_object_object_add (alarmItem, "perceivedSeverity", temp_jso);
-
- JSON_NEW_OBJ (alarm_info, json_object_put, alarmlist, alarmItem);
- JSON_NEW_STRING_OBJ_1 (alarm_reason_info, temp_jso, json_object_put,
- alarmlist, alarmItem, alarm_info);
- json_object_object_add (alarm_info, "reason", temp_jso);
- JSON_NEW_STRING_OBJ_1 (alarm_desc, temp_jso, json_object_put, alarmlist,
- alarmItem, alarm_info);
- json_object_object_add (alarm_info, "desc", temp_jso);
- json_object_object_add (alarmItem, "alarmInfo", alarm_info);
-
- JSON_NEW_STRING_OBJ (action_string, temp_jso, json_object_put, alarmlist,
- alarmItem);
-
- json_object_object_add (alarmlist, "data", alarmItem);
-
- json_object_object_add (alarmlist, "action", temp_jso);
-
- const char *str = json_object_to_json_string (alarmlist);
- if (str == NULL)
- {
- NSMON_LOGERR ("json_object_to_json_string fail");
- (void) json_object_put (alarmlist);
- return -1;
- }
-
- str_len = strlen (str);
-
- if (str_len >= ALARM_PARA_LENGTH_OUTER)
- {
- NSAM_LOGERR ("str_len >= ALARM_PARA_LENGTH_OUTER");
- (void) json_object_put (alarmlist);
- return -1;
- }
-
- retVal =
- STRNCPY_S (alarmpara_out->alarmcontent, ALARM_PARA_LENGTH_OUTER, str,
- str_len + 1);
-
- if (EOK != retVal)
- {
- NSAM_LOGERR ("STRNCPY_S failed]ret=%d", retVal);
- (void) json_object_put (alarmlist);
- return -1;
- }
-
- (void) json_object_put (alarmlist);
-
- return 0;
-
-}
-
-/*******************************************************************
-* Copyright 2017, Huawei Tech. Co., Ltd.
-* ALL RIGHTS RESERVED
-*Description : send alarm to thirdparty alarm module, now only log
-********************************************************************/
-int
-ns_send_alarm_to_alarm_module (alarm_result alarm_res)
-{
- int retVal = -1;
-
- nsfw_mgr_msg *req_msg =
- nsfw_mgr_msg_alloc (MGR_MSG_LARGE_ALARM_RSP, NSFW_PROC_ALARM);
-
- if (NULL == req_msg)
- {
- NSAM_LOGERR ("mgr_msg_alloc fail]alarm_id=%d", alarm_res.alarm_id_get);
- return -1;
- }
-
- if (req_msg->msg_len < (NSFW_MGR_MSG_HDR_LEN + sizeof (alarm_info_s_out)))
- {
- NSAM_LOGERR ("mgr_msg_alloc length fail]alarm_id=%d",
- alarm_res.alarm_id_get);
- nsfw_mgr_msg_free (req_msg);
- return -1;
- }
- /* husky agent receive alarm info using fixed length */
- req_msg->msg_len = (NSFW_MGR_MSG_HDR_LEN + sizeof (alarm_info_s_out));
-
- retVal =
- ns_get_alarm_body ((char *) req_msg->msg_body,
- NSFW_MGR_LARGE_MSG_BODY_LEN, alarm_res);
-
- if (-1 == retVal)
- {
- NSAM_LOGERR ("ns_get_alarm_body fail]alarm_id=%d",
- alarm_res.alarm_id_get);
- nsfw_mgr_msg_free (req_msg);
- return -1;
- }
-
- u8 ret = nsfw_mgr_send_msg (req_msg);
-
- if (FALSE == ret)
- {
- NSAM_LOGERR ("nsfw_mgr_send_msg fail]alarm_id=%d,reason=%d,flag=%d",
- alarm_res.alarm_id_get, alarm_res.alarm_reason_get,
- alarm_res.alarm_flag_get);
- ns_alarm_set_sendFlag (alarm_res.alarm_id_get, ALARM_SEND_FAIL);
- nsfw_mgr_msg_free (req_msg);
- return -1;
- }
-
- NSAM_LOGINF ("nsfw_mgr_send_msg succ]alarm_id=%d,reason=%d,flag=%d",
- alarm_res.alarm_id_get, alarm_res.alarm_reason_get,
- alarm_res.alarm_flag_get);
- ns_alarm_set_sendFlag (alarm_res.alarm_id_get, ALARM_SEND_SUCC);
-
- nsfw_mgr_msg_free (req_msg);
-
- return 0;
-}
-
-/*******************************************************************
-* Copyright 2017, Huawei Tech. Co., Ltd.
-* ALL RIGHTS RESERVED
-*Description : alarm product common func
-********************************************************************/
-void
-ns_send_alarm_inner (enum_alarm_id alarm_id, void *para, int check_times,
- int check_state_flag)
-{
- alarm_data *alarm_value = NULL;
- alarm_result alarm_id_report;
- int alarm_idx;
- int alarm_loop;
- int temp_alarm_time_laps;
- int abnormal_alarm_flag = 0, normal_alarm_flag =
- 0, total_abnormal_alarm_flag = 0;
- int need_check_flag = check_state_flag;
- int ret = 0;
-
- if ((alarm_id <= 0) || (alarm_id >= ALARM_EVENT_MAX)
- || (0 == g_alarm_data[alarm_id].valid_flag))
- {
- NSAM_LOGERR ("alarm_id is invalid or not reg");
- return;
- }
-
- alarm_id_report.alarm_id_get = ALARM_EVENT_MAX;
-
- alarm_idx = alarm_id;
-
- alarm_value = &g_alarm_data[alarm_idx];
-
- for (alarm_loop = 0; alarm_loop < alarm_value->alarm_reason_cnt;
- alarm_loop++)
- {
- abnormal_alarm_flag = 0;
- if (ALARM_PERIOD_CHECK == alarm_value->_alarm_type)
- {
- if (NULL ==
- alarm_value->_alarm_para.func_alarm_check_period[alarm_loop])
- {
- NSAM_LOGERR ("alarm id func_alarm_check is invalid]alarm_id=%d",
- alarm_id);
- return;
- }
- alarm_id_report =
- alarm_value->_alarm_para.func_alarm_check_period[alarm_loop] ();
- }
- else if (ALARM_SEND_ONCE == alarm_value->_alarm_type)
- {
- if (NULL == alarm_value->_alarm_para.func_alarm_check[alarm_loop])
- {
- NSAM_LOGERR ("alarm id func_alarm_check is invalid]alarm_id=%d",
- alarm_id);
- return;
- }
- alarm_id_report =
- alarm_value->_alarm_para.func_alarm_check[alarm_loop] (para);
- }
-
- if ((alarm_id_report.alarm_id_get <= ALARM_EVENT_BASE)
- || alarm_id_report.alarm_id_get >= ALARM_EVENT_MAX)
- {
- NSAM_LOGDBG ("don't satisfy alarm condition");
- return;
- }
-
- alarm_idx = alarm_id_report.alarm_id_get;
-
- if (ALARM_EVENT_NSTACK_MAIN_ABNORMAL == alarm_idx)
- {
- need_check_flag = 0;
- }
- /* for send current status alarm, needn't check count also status. */
- /* for sending current state alarm, needn't check current state */
- if ((alarm_id_report.alarm_flag_get == ALARM_PRODUCT)
- && (((alarm_value->alarm_time_laps[alarm_loop] < check_times)
- && (alarm_value->_alarm_flag != ALARM_PRODUCT))
- || (need_check_flag == 0)))
- {
- if ((0 == check_state_flag)
- || ++(alarm_value->alarm_time_laps[alarm_loop]) >= check_times)
- {
- alarm_value->_alarm_flag = ALARM_PRODUCT;
- abnormal_alarm_flag = 1;
- total_abnormal_alarm_flag++;
- }
-
- }
- else if ((alarm_id_report.alarm_flag_get == ALARM_CLEAN)
- && ((alarm_value->_alarm_flag == ALARM_PRODUCT)
- || (need_check_flag == 0)))
- {
- if ((1 == check_state_flag)
- && (alarm_value->alarm_time_laps[alarm_loop] > 0))
- {
- --alarm_value->alarm_time_laps[alarm_loop];
- }
- if ((alarm_value->alarm_time_laps[alarm_loop] <= 0)
- || (0 == check_state_flag))
- {
- normal_alarm_flag++;
- }
- }
-
- temp_alarm_time_laps = alarm_value->alarm_time_laps[alarm_loop];
-
- /* can't product same alarm multi times */
- /* only overload alarm can send */
- if (abnormal_alarm_flag != 1)
- {
- NSAM_LOGDBG
- ("don't satisfy alarm condition]alarm_idx=%d,alarm_time_laps=%d",
- alarm_idx, temp_alarm_time_laps);
- continue;
- }
-
- ret = ns_send_alarm_to_alarm_module (alarm_id_report);
-
- if (-1 == ret)
- {
- ns_alarm_set_sendFlag (alarm_id, ALARM_SEND_FAIL);
- }
- else
- {
- ns_alarm_set_sendFlag (alarm_id, ALARM_SEND_SUCC);
- }
- /* for alarm current status, only can send one */
- /* if it have multi-scearo, only can send a overload alarm */
- if (0 == need_check_flag)
- {
- break;
- }
-
- }
-
- if ((total_abnormal_alarm_flag == 0)
- && (alarm_value->alarm_reason_cnt == normal_alarm_flag))
- {
- alarm_value->_alarm_flag = ALARM_CLEAN;
- ret = ns_send_alarm_to_alarm_module (alarm_id_report);
- if (-1 == ret)
- {
- ns_alarm_set_sendFlag (alarm_id, ALARM_SEND_FAIL);
- }
- else
- {
- ns_alarm_set_sendFlag (alarm_id, ALARM_SEND_SUCC);
- }
- }
-
- return;
-
-}
-
-/*******************************************************************
-* Copyright 2017, Huawei Tech. Co., Ltd.
-* ALL RIGHTS RESERVED
-*Description : API, any app want to product alarm,need call this function
-********************************************************************/
-void
-ns_send_alarm (enum_alarm_id alarm_id, void *para)
-{
- ns_send_alarm_inner (alarm_id, para, 1, 1);
-}
-
-/*******************************************************************
-* Copyright 2017, Huawei Tech. Co., Ltd.
-* ALL RIGHTS RESERVED
-*Description : period check alarm expire handle function
-********************************************************************/
-int
-ns_alarm_timer_proc_fun (u32 timer_type, void *argv)
-{
- struct timespec time_left;
- if (NULL == argv)
- {
- NSAM_LOGERR ("abnormal: argv is NULL ");
- return -1;
- }
-
- alarm_data *alarm_value = (alarm_data *) argv;
-
- if (alarm_value->_alarm_type == ALARM_PERIOD_CHECK)
- {
- ns_send_alarm_inner (alarm_value->_alarm_id, NULL,
- ALARM_PERIOD_CHECK_TIMES, 1);
- time_left.tv_sec = alarm_value->_alarm_para.period_alarm.time_length;
- time_left.tv_nsec = 0;
- nsfw_timer_info *timer_info =
- nsfw_timer_reg_timer (0, (void *) (u64) alarm_value,
- ns_alarm_timer_proc_fun, time_left);
- if (NULL == timer_info)
- {
- NSAM_LOGERR ("nsfw_timer_reg_timer fail");
- return -1;
- }
- }
- NSAM_LOGDBG ("abnormal: alarm is not period ");
-
- return 0;
-
-}
-
-/*******************************************************************
-* Copyright 2017, Huawei Tech. Co., Ltd.
-* ALL RIGHTS RESERVED
-*Description : app reg alarm info to alarm module
-********************************************************************/
-int
-ns_reg_alarm (enum_alarm_id alarm_id, alarm_type alarmType,
- alarm_para * alarmPara)
-{
- alarm_data *alarm_value = NULL;
- alarm_reason loop = ALARM_REASON_BEGIN;
- struct timespec time_left;
-
- if ((alarm_id <= ALARM_EVENT_BASE) || (alarm_id >= ALARM_EVENT_MAX)
- || (NULL == alarmPara)
- || (alarmPara->alarm_reason_count > ALARM_REASON_MAX))
- {
- NSAM_LOGERR ("para invalid]alarm_id=%d ", alarm_id);
- return -1;
- }
-
- for (loop = ALARM_REASON_BEGIN; loop < alarmPara->alarm_reason_count;
- loop++)
- {
- if (NULL == alarmPara->func_alarm_check[loop])
- {
- NSAM_LOGERR ("para invalid]func_alarm_check=NULL,loop=%d", loop);
- return -1;
- }
- }
-
- alarm_value = &g_alarm_data[alarm_id];
- alarm_value->_alarm_type = alarmType;
- alarm_value->_alarm_para.period_alarm.time_length =
- alarmPara->period_alarm.time_length;
- alarm_value->_alarm_id = alarm_id;
- alarm_value->alarm_reason_cnt = alarmPara->alarm_reason_count;
- alarm_value->_alarm_flag = ALARM_CLEAN;
-
- for (loop = ALARM_REASON_BEGIN; loop < alarmPara->alarm_reason_count;
- loop++)
- {
- alarm_value->alarm_time_laps[loop] = alarmPara->alarm_reason_set[loop];
- alarm_value->_alarm_para.func_alarm_check[loop] =
- alarmPara->func_alarm_check[loop];
- alarm_value->_alarm_para.func_alarm_check_period[loop] =
- alarmPara->func_alarm_check_period[loop];
- alarm_value->alarm_time_laps[loop] = 0;
- }
-
- alarm_value->valid_flag = 1;
-
- if (ALARM_PERIOD_CHECK == alarmType)
- {
- time_left.tv_sec = alarm_value->_alarm_para.period_alarm.time_length;
- time_left.tv_nsec = 0;
- nsfw_timer_info *timer_info =
- nsfw_timer_reg_timer (0, (void *) (u64) alarm_value,
- ns_alarm_timer_proc_fun, time_left);
- if (NULL == timer_info)
- {
- NSAM_LOGERR ("nsfw_timer_reg_timer fail");
- }
- }
-
- return 0;
-}
-
-/*******************************************************************
-* Copyright 2017, Huawei Tech. Co., Ltd.
-* ALL RIGHTS RESERVED
-*Description : send alarm as per current state
-********************************************************************/
-void
-ns_send_init_alarm (enum_alarm_id alarm_id)
-{
- if ((alarm_id <= 0) || (alarm_id >= ALARM_EVENT_MAX))
- {
- NSAM_LOGDBG ("alarm_id is invalid");
- return;
- }
- ns_send_alarm_inner (alarm_id,
- (void *) (g_alarm_data[alarm_id]._alarm_flag), 1, 0);
-}
-
-NSFW_MODULE_NAME (NSFW_ALARM_MODULE)
-NSFW_MODULE_PRIORITY (10)
-NSFW_MODULE_DEPENDS (NSTACK_DMM_MODULE)
-NSFW_MODULE_INIT (ns_alarm_module_init)
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif /* __cplusplus */
diff --git a/stacks/lwip_stack/src/alarm/alarm.h b/stacks/lwip_stack/src/alarm/alarm.h
deleted file mode 100644
index 4c5f692..0000000
--- a/stacks/lwip_stack/src/alarm/alarm.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _ALARM_H_
-#define _ALARM_H_
-
-#include <stdint.h>
-#include "alarm_api.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-/* alarm clean time = 1*3 */
-
-#define ALARM_RESEND_TIMER_LENGTH 60
-#define ALARM_INIT_RESEND_TIMER_LENGTH 40
-
-#define ALARM_SEND_SUCC 1
-#define ALARM_SEND_FAIL 0
-
-#define ALARM_PARA_LENGTH_OUTER 2048
-
-#define ALARM_PERIOD_CHECK_TIMES 3
-
-#define MAX_VMID_LEN 256
-
-#define MIN_VM_ID_LEN 1
-#define MAX_VM_ID_LEN 256
-
-#define INVALID_STR_LEN(_str, _min_len, _maxlen) (NULL == _str || strlen(_str) < _min_len || strlen(_str) > _maxlen)
-
-typedef struct _alarm_data
-{
- alarm_para _alarm_para;
- alarm_type _alarm_type;
- enum_alarm_id _alarm_id;
- int alarm_time_laps[ALARM_REASON_MAX];
- alarm_flag _alarm_flag;
- int alarm_reason_cnt;
- int valid_flag;
- int send_succ_flag;
-
-} alarm_data;
-
-typedef struct _alarm_info_s_out
-{
- char alarmId[16];
- char comptentname[32];
- char alarmtime[32];
- char alarmcontent[ALARM_PARA_LENGTH_OUTER];
-} alarm_info_s_out;
-
-int ns_send_alarm_to_alarm_module (alarm_result alarm_res);
-
-void ns_send_alarm_inner (enum_alarm_id alarm_id, void *para, int check_times,
- int check_state_flag);
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif
diff --git a/stacks/lwip_stack/src/alarm/alarm_api.h b/stacks/lwip_stack/src/alarm/alarm_api.h
deleted file mode 100644
index 8c7aca1..0000000
--- a/stacks/lwip_stack/src/alarm/alarm_api.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _ALARM_API_H_
-#define _ALARM_API_H_
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-#define NSFW_ALARM_MODULE "nstack_alarm"
-
-/* alarm ID for every event, when need add new alarm, here add a alarm_id define */
-typedef enum _alarm_id
-{
- ALARM_EVENT_BASE,
- ALARM_EVENT_NSTACK_RESOURCE_ALARM,
- ALARM_EVENT_NSTACK_NO_USE,
- ALARM_EVENT_NSTACK_MAIN_ABNORMAL,
- ALARM_EVENT_MAX
-} enum_alarm_id;
-
-/* support both type alarm:
- 1. support other module call func:ns_send_alarm to product alarm;
- 2. alarm module call function periodly to check whether need product alarm */
-typedef enum _alarm_type
-{
- ALARM_PERIOD_CHECK,
- ALARM_SEND_ONCE
-} alarm_type;
-
-typedef enum _alarm_flag
-{
- ALARM_PRODUCT,
- ALARM_CLEAN,
- ALARM_MAX
-} alarm_flag;
-
-typedef enum _alarm_reason
-{
- ALARM_REASON_BEGIN,
- ALARM_REASON_SOCKET = 0,
- ALARM_REASON_MSG_BUF,
- ALARM_REASON_NSMAIN,
- ALARM_REASON_MAX
-} alarm_reason;
-
-typedef struct _alarm_result
-{
- enum_alarm_id alarm_id_get;
- alarm_reason alarm_reason_get;
- alarm_flag alarm_flag_get;
-} alarm_result;
-
-/* check whether need product alarm,if return 0, then product alarm */
-typedef alarm_result (*alarm_check_func) (void *para);
-typedef alarm_result (*alarm_check_func_period) (void);
-
-typedef struct _alarm_para
-{
- union
- {
- int time_length;
- } period_alarm;
- union
- {
- alarm_check_func func_alarm_check[ALARM_REASON_MAX];
- alarm_check_func_period func_alarm_check_period[ALARM_REASON_MAX];
- };
-
- alarm_reason alarm_reason_set[ALARM_REASON_MAX];
- int alarm_reason_count;
-
-} alarm_para;
-
-/* for any alarm added, firstly call following function to reg */
-int ns_reg_alarm (enum_alarm_id alarm_id, alarm_type _alarm_type,
- alarm_para * _alarm_para);
-
-void ns_send_init_alarm (enum_alarm_id alarm_id);
-
-/* other module call this func to product alarm, here para is same as alarm_check_func's para */
-void ns_send_alarm (enum_alarm_id alarm_id, void *para);
-int ns_alarm_module_init (void *param);
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif
diff --git a/stacks/lwip_stack/src/include/nsfw_msg.h b/stacks/lwip_stack/src/include/nsfw_msg.h
deleted file mode 100644
index e5254d3..0000000
--- a/stacks/lwip_stack/src/include/nsfw_msg.h
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef MSG_H
-#define MSG_H
-#include "types.h"
-#include "common_mem_api.h"
-#include "nsfw_rti.h"
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-#define MAX_MSG_SIZE 512
-COMPAT_PROTECT (MAX_MSG_SIZE, 512);
-#define MAX_MSG_PARAM_SIZE 128
-COMPAT_PROTECT (MAX_MSG_PARAM_SIZE, 128);
-
-#define MSG_ASYN_POST 0
-#define MSG_SYN_POST 1
-
-typedef struct
-{
- u16 module_type;
- u16 major_type;
- u16 minor_type;
- u16 op_type; /* MSG_SYN_POST or MSG_ASYN_POST */
- sys_sem_st op_completed;
- i32 err;
- PRIMARY_ADDR void *msg_from; /* use it to free msg */
- i64 receiver;
- i64 comm_receiver;
- nsfw_res res_chk;
- u32 src_pid;
- u32 recycle_pid; /* use it in recycle */
- u64 span_pid;
- i64 extend_member_bit;
-} msg_param;
-
-typedef struct msg_t
-{
- msg_param param;
- i8 msg_param_pad[MAX_MSG_PARAM_SIZE - sizeof (msg_param)]; /* sizeof(msg_param) + sizeof(msg_param_pad) = MAX_MSG_PARAM_SIZE */
- i64 buffer[(MAX_MSG_SIZE - MAX_MSG_PARAM_SIZE) / 8];
-}
-data_com_msg;
-
-#define MAX_MODULE_TYPE 64
-#define MAX_MAJOR_TYPE 256
-#define MAX_MINOR_TYPE 256
-
-struct rti_queue
-{
- /* corresponding to enum spl_tcpip_msg_type */
- volatile u64 tcpip_msg_enq[MAX_MAJOR_TYPE];
- volatile u64 tcpip_msg_enq_fail[MAX_MAJOR_TYPE];
- u64 tcpip_msg_deq[MAX_MAJOR_TYPE];
-
- /* corresponding to enum api_msg_type, this is sub-type of SPL_TCPIP_NEW_MSG_API */
- volatile u64 api_msg_enq[MAX_MINOR_TYPE];
- volatile u64 api_msg_enq_fail[MAX_MINOR_TYPE];
- u64 api_msg_deq[MAX_MINOR_TYPE];
-
- u64 extend_member_bit;
-};
-
-enum MSG_MODULE_TYPE
-{
- MSG_MODULE_IP,
- MSG_MODULE_SBR,
- MSG_MODULE_HAL,
- MSG_MODULE_SPL,
- MSG_MODULE_TIMER,
- MSG_MODULE_MT,
- MSG_MODULE_DFX,
- MSG_MODULE_MAX = MAX_MODULE_TYPE
-};
-
-typedef int (*msg_fun) (data_com_msg * m);
-
-/* *INDENT-OFF* */
-extern msg_fun g_msg_module_fun_array[MAX_MODULE_TYPE];
-extern msg_fun g_msg_module_major_fun_array[MAX_MODULE_TYPE][MAX_MAJOR_TYPE];
-extern msg_fun g_msg_module_major_minor_fun_array[MAX_MODULE_TYPE][MAX_MAJOR_TYPE][MAX_MINOR_TYPE];
-extern msg_fun g_msg_unsupport_fun;
-/* *INDENT-ON* */
-
-#define REGIST_MSG_MODULE_FUN(module, fun) \
- static void regist_ ## module ## _function (void) \
- __attribute__((__constructor__)); \
- static void regist_ ## module ## _function (void) \
- { \
- g_msg_module_fun_array[module] = fun; \
- } \
-
-#define REGIST_MSG_MODULE_MAJOR_FUN(module, major, fun) \
- static void regist_ ## module ## major ## _function (void) \
- __attribute__((__constructor__)); \
- static void regist_ ## module ## major ## _function (void) \
- { \
- g_msg_module_major_fun_array[module][major] = fun; \
- } \
-
-#define REGIST_MSG_MODULE_MAJOR_MINOR_FUN(module, major, minor, fun) \
- static void regist_ ## module ## major ## minor ## _function (void) \
- __attribute__((__constructor__)); \
- static void regist_ ## module ## major ## minor ## _function (void) \
- { \
- g_msg_module_major_minor_fun_array[module][major][minor] = fun; \
- } \
-
-#define REGIST_MSG_UNSUPPORT_FUN(fun) \
- static void regist_msg_unsupport_function (void) \
- __attribute__((__constructor__)); \
- static void regist_msg_unsupport_function (void) \
- { \
- g_msg_unsupport_fun = fun; \
- }
-
-static inline int
-unsupport_msg (data_com_msg * m)
-{
- if (g_msg_unsupport_fun)
- {
- return g_msg_unsupport_fun (m);
- }
-
- return -1;
-}
-
-/*****************************************************************************
-* Prototype : call_msg_fun
-* Description : call msg fun
-* Input : data_com_msg* m
-* Output : None
-* Return Value : static inline int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline int
-call_msg_fun (data_com_msg * m)
-{
- u16 module = m->param.module_type;
- u16 major = m->param.major_type;
- u16 minor = m->param.minor_type;
-
- if ((module >= MAX_MODULE_TYPE) || (major >= MAX_MAJOR_TYPE)
- || (minor >= MAX_MINOR_TYPE))
- {
- return unsupport_msg (m);
- }
-
- nsfw_rti_stat_macro (NSFW_STAT_PRIMARY_DEQ, m);
-
- if (g_msg_module_fun_array[module]
- && (g_msg_module_fun_array[module] (m) != 0))
- {
- return -1;
- }
-
- if (g_msg_module_major_fun_array[module][major]
- && (g_msg_module_major_fun_array[module][major] (m) != 0))
- {
- return -1;
- }
-
- if (g_msg_module_major_minor_fun_array[module][major][minor])
- {
- return g_msg_module_major_minor_fun_array[module][major][minor] (m);
- }
-
- if (!g_msg_module_fun_array[module]
- && !g_msg_module_major_fun_array[module][major]
- && !g_msg_module_major_minor_fun_array[module][major][minor])
- {
- return unsupport_msg (m);
- }
-
- return 0;
-}
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif
diff --git a/stacks/lwip_stack/src/include/nsfw_msg_api.h b/stacks/lwip_stack/src/include/nsfw_msg_api.h
deleted file mode 100644
index 85dca49..0000000
--- a/stacks/lwip_stack/src/include/nsfw_msg_api.h
+++ /dev/null
@@ -1,309 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef MSG_API_H
-#define MSG_API_H
-#include "nsfw_msg.h"
-#include "nsfw_mem_api.h"
-#include "nstack_log.h"
-#include "nsfw_rti.h"
-#include "common_mem_api.h"
-#include "nsfw_recycle_api.h"
-#include "common_pal_bitwide_adjust.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-#define SET_MSG_ERR(m, error) ((m)->param.err = (error))
-#define GET_MSG_ERR(m) ((m)->param.err)
-
-/* for sync message from sbr we should signal sem */
-#define SYNC_MSG_ACK(m) sys_sem_s_signal(&((m)->param.op_completed))
-
-/* for async message from sbr we should free the message */
-#define ASYNC_MSG_FREE(m) msg_free(m)
-
-#define MSG_ENTRY(_ptr, _type, _member) container_of((void *)_ptr, _type, _member)
-
-#ifndef NSTACK_STATIC_CHECK
-/*****************************************************************************
-* Prototype : msg_malloc
-* Description : malloc msg
-* Input : mring_handle mhandle
-* Output : None
-* Return Value : static inline data_com_msg*
-* Calls :
-* Called By :
-*****************************************************************************/
-static inline data_com_msg *
-msg_malloc (mring_handle mhandle)
-{
- if (!mhandle)
- {
- NSFW_LOGERR ("mhandle is null");
- return NULL;
- }
-
- data_com_msg *m = NULL;
- if (nsfw_mem_ring_dequeue (mhandle, (void **) &m) != 1)
- {
- return NULL;
- }
-
- m->param.recycle_pid = get_sys_pid ();
- res_alloc (&m->param.res_chk);
- return m;
-}
-
-/*****************************************************************************
-* Prototype : msg_free
-* Description : free msg
-* Input : data_com_msg* m
-* mring_handle mhandle
-* Output : None
-* Return Value : static inline void
-* Calls :
-* Called By :
-*****************************************************************************/
-static inline void
-msg_free (data_com_msg * m)
-{
- if (!m)
- {
- NSFW_LOGERR ("m is NULL");
- return;
- }
-
- mring_handle mhandle = ADDR_SHTOL (m->param.msg_from);
- if (!mhandle)
- {
- return;
- }
-
- if (res_free (&m->param.res_chk))
- {
- NSFW_LOGERR ("m refree!]m=%p", m);
- return;
- }
-
- m->param.recycle_pid = 0;
-
- if (nsfw_mem_ring_enqueue (mhandle, (void *) m) != 1)
- {
- NSFW_LOGERR ("nsfw_mem_ring_enqueue failed,this can not happen");
- }
-}
-
-/*****************************************************************************
-* Prototype : msg_post
-* Description : post msg
-* Input : data_com_msg* m
-* mring_handle mhandle
-* Output : None
-* Return Value : static inline int
-* Calls :
-* Called By :
-*****************************************************************************/
-static inline int
-msg_post (data_com_msg * m, mring_handle mhandle)
-{
- int ret;
- if (!m || !mhandle)
- {
- NSFW_LOGERR ("param is not ok]m=%p,mhandle=%p", m, mhandle);
- return -1;
- }
-
- while (1)
- {
- ret = nsfw_mem_ring_enqueue (mhandle, (void *) m);
- switch (ret)
- {
- case 1:
- if (MSG_SYN_POST == m->param.op_type)
- {
- sys_arch_sem_s_wait (&m->param.op_completed, 0);
- }
-
- return 0;
- case 0:
- continue;
- default:
- nsfw_rti_stat_macro (NSFW_STAT_PRIMARY_ENQ_FAIL, m);
- return -1;
- }
- }
-}
-
-#define MSG_POST_FAILED 50
-/*****************************************************************************
-* Prototype : msg_post_with_lock_rel
-* Description : post msg to tcpip thread in mgrcom thread
-* Input : data_com_msg* m
-* mring_handle mhandle
-* Output : None
-* Return Value : static inline int
-* Calls :
-* Called By :
-*****************************************************************************/
-static inline int
-msg_post_with_lock_rel (data_com_msg * m, mring_handle mhandle)
-{
- int ret;
- int try_count = 0;
- if (!m || !mhandle)
- {
- NSFW_LOGERR ("param is not ok]m=%p,mhandle=%p", m, mhandle);
- return -1;
- }
-
- while (1)
- {
- ret = nsfw_mem_ring_enqueue (mhandle, (void *) m);
- switch (ret)
- {
- case 1:
- if (MSG_SYN_POST == m->param.op_type)
- {
- sys_arch_sem_s_wait (&m->param.op_completed, 0);
- }
-
- return 0;
- case 0:
- try_count++;
- if (try_count > MSG_POST_FAILED)
- {
- try_count = 0;
- nsfw_recycle_rechk_lock ();
- }
- sys_sleep_ns (0, 1000000);
- continue;
- default:
- nsfw_rti_stat_macro (NSFW_STAT_PRIMARY_ENQ_FAIL, m);
- return -1;
- }
- }
-}
-
-/*****************************************************************************
-* Prototype : msg_try_post
-* Description : try post msg
-* Input : data_com_msg* m
-* mring_handle mhandle
-* Output : None
-* Return Value : static inline int
-* Calls :
-* Called By :
-*****************************************************************************/
-static inline int
-msg_try_post (data_com_msg * m, mring_handle mhandle)
-{
- if (!m || !mhandle)
- {
- NSFW_LOGERR ("param is not ok]m=%p,mhandle=%p", m, mhandle);
- return -1;
- }
-
- int ret = nsfw_mem_ring_enqueue (mhandle, (void *) m);
- if (1 == ret)
- {
- if (MSG_SYN_POST == m->param.op_type)
- {
- sys_arch_sem_s_wait (&m->param.op_completed, 0);
- }
-
- return 0;
- }
-
- return -1;
-}
-
-/*****************************************************************************
-* Prototype : msg_fetch
-* Description : fetch msg
-* Input : mring_handle mhandle
-* data_com_msg** m
-* u32 num
-* Output : None
-* Return Value : static inline int
-* Calls :
-* Called By :
-*****************************************************************************/
-static inline int
-msg_fetch (mring_handle mhandle, data_com_msg ** m, u32 num)
-{
- if (!m || !mhandle)
- {
- NSFW_LOGERR ("param is not ok]m=%p,mhandle=%p", m, mhandle);
- return -1;
- }
-
- int ret;
- while (1)
- {
- ret = nsfw_mem_ring_dequeuev (mhandle, (void *) m, num);
- if (ret > 0)
- {
- break;
- }
- }
-
- return ret;
-}
-
-/*****************************************************************************
-* Prototype : msg_try_fetch
-* Description : try fetch msg
-* Input : mring_handle mhandle
-* data_com_msg** m
-* u32 num
-* Output : None
-* Return Value : static inline int
-* Calls :
-* Called By :
-*****************************************************************************/
-static inline int
-msg_try_fetch (mring_handle mhandle, data_com_msg ** m, u32 num)
-{
- if (!m || !mhandle)
- {
- NSFW_LOGERR ("param is not ok]m=%p,mhandle=%p", m, mhandle);
- return -1;
- }
-
- return nsfw_mem_ring_dequeuev (mhandle, (void *) m, num);
-}
-
-#else
-data_com_msg *msg_malloc (mring_handle mhandle);
-void msg_free (data_com_msg * m);
-int msg_post (data_com_msg * m, mring_handle mhandle);
-int msg_try_post (data_com_msg * m, mring_handle mhandle);
-int msg_fetch (mring_handle mhandle, data_com_msg ** m, u32 num);
-int msg_try_fetch (mring_handle mhandle, data_com_msg ** m, u32 num);
-int msg_post_with_lock_rel (data_com_msg * m, mring_handle mhandle);
-#endif
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif
diff --git a/stacks/lwip_stack/src/include/nsfw_mt_config.h b/stacks/lwip_stack/src/include/nsfw_mt_config.h
deleted file mode 100644
index e1a7899..0000000
--- a/stacks/lwip_stack/src/include/nsfw_mt_config.h
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _FW_MT_CONFIG_H
-#define _FW_MT_CONFIG_H
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-#define NSFW_CONFIG_MODULE "nsfw_config"
-#define NSTACK_SHARE_CONFIG "nstack_share_config"
-
-#define CFG_PATH "NSTACK_CONFIG_PATH"
-#define CFG_FILE_NAME "nStackConfig.json"
-#define MAX_FILE_NAME_LEN 512
-#define CFG_BUFFER_LEN 2048
-#define MAX_CFG_ITEM 128
-#define CFG_ITEM_LENGTH 64
-
-enum NSTACK_BASE_CFG
-{
- CFG_BASE_SOCKET_NUM = 0,
- CFG_BASE_RING_SIZE,
- CFG_BASE_HAL_PORT_NUM,
- CFG_BASE_ARP_STALE_TIME,
- CFG_BASE_ARP_BC_RETRANS_NUM,
- MAX_BASE_CFG
-};
-COMPAT_PROTECT (MAX_BASE_CFG, 5);
-
-enum NSTACK_CUSTOM_CFG
-{
- /* mBuf config */
- CFG_MBUF_DATA_SIZE,
- CFG_TX_MBUF_NUM,
- CFG_RX_MBUF_NUM,
-
- /* memory pool config */
- CFG_MP_TCPSEG_NUM,
- CFG_MP_MSG_NUM,
-
- /* RING config */
- CFG_HAL_TX_RING_SIZE,
- CFG_HAL_RX_RING_SIZE,
- CFG_MBOX_RING_SIZE,
- CFG_SPL_MAX_RING_SIZE,
-
- /* PCB config */
- CFG_TCP_PCB_NUM,
- CFG_UDP_PCB_NUM,
- CFG_RAW_PCB_NUM,
-
- CFG_ARP_QUEUE_NUM,
-
- MAX_CUSTOM_CFG
-};
-COMPAT_PROTECT (CFG_SPL_MAX_RING_SIZE, 8);
-
-enum EN_CFG_SEG
-{
- CFG_SEG_BASE = 0,
- CFG_SEG_LOG,
- CFG_SEG_PATH,
- CFG_SEG_PRI,
- CFG_SEG_MAX
-};
-
-enum EN_CFG_ITEM_TYPE
-{
- CFG_ITEM_TYPE_INT = 0,
- CFG_ITEM_TYPE_STRING
-};
-
-enum EN_SEG_BASE_ITEM
-{
- CFG_SEG_BASE_SOCKET_NUM = 0,
- CFG_SEG_BASE_ARP_STALE_TIME,
- CFG_SEG_BASE_ARP_BC_RETRANS_NUM,
- CFG_SEG_BASE_MAX
-};
-
-enum EN_SEG_THREAD_PRI_ITEM
-{
- CFG_SEG_THREAD_PRI_POLICY = 0,
- CFG_SEG_THREAD_PRI_PRI,
- CFG_SEG_THREAD_PRI_MAX
-};
-
-typedef void (*custom_check_fn) (void *pitem);
-
-// pack size?
-struct cfg_item_info
-{
- char *name;
- int type;
- int min_value;
- int max_value;
- int default_value;
- char *default_str;
- custom_check_fn custom_check;
- union
- {
- int value;
- char *pvalue;
- };
-};
-
-typedef struct _cfg_module_param
-{
- u32 proc_type;
- i32 argc;
- u8 **argv;
-} cfg_module_param;
-
-extern u32 g_custom_cfg_items[MAX_CUSTOM_CFG];
-extern u32 g_base_cfg_items[MAX_BASE_CFG];
-
-#define get_base_cfg(tag) g_base_cfg_items[(tag)]
-#define get_custom_cfg(tag) g_custom_cfg_items[(tag)]
-#define set_custom_cfg_item(tag, value) g_custom_cfg_items[(tag)] = (value)
-
-/* stackx config data definition */
-
-/* app socket num */
-#define DEF_APP_SOCKET_NUM 1024
-
-/* socket num config */
-#define SOCKET_NUM_PER_THREAD 1024 /* socket number per thread */
-COMPAT_PROTECT (SOCKET_NUM_PER_THREAD, 1024);
-
-/*
- MAX_SOCKET_NUM: max socket fd number one app can use, it should equal the max socket
- number nstack support(CUR_CFG_SOCKET_NUM)
-*/
-
-#define DEF_SOCKET_NUM 1024 /* default socket number */
-COMPAT_PROTECT (DEF_SOCKET_NUM, 1024);
-#define MIN_SOCKET_NUM 1024 /* min socket number */
-
-#define MAX_SOCKET_NUM 8192 /* default: 8K sockets */
-
-#define CUR_CFG_SOCKET_NUM get_base_cfg(CFG_BASE_SOCKET_NUM) /* max socket numbere nstack support */
-
-#define DEF_ARP_STACLE_TIME 300 /* default arp stale time: second */
-#define MIN_ARP_STACLE_TIME 30 /* min arp stale time: second */
-#define MAX_ARP_STACLE_TIME 1200 /* max arp stale time: second */
-#define ARP_STALE_TIME get_base_cfg(CFG_BASE_ARP_STALE_TIME)
-
-#define DEF_ARP_BC_RETRANS_NUM 5 /* default arp broadcast retransmission times */
-#define MIN_ARP_BC_RETRANS_NUM 1 /* min arp broadcast retransmission times */
-#define MAX_ARP_BC_RETRANS_NUM 20 /* max arp broadcast retransmission times */
-#define ARP_BC_RETRANS_NUM get_base_cfg(CFG_BASE_ARP_BC_RETRANS_NUM)
-
-/* application mumber config */
-#define APP_POOL_NUM 32 /* max application number */
-COMPAT_PROTECT (APP_POOL_NUM, 32);
-
-/* thread number config */
-#define DEF_THREAD_NUM 1 /* default stackx thread number */
-#define MIN_THREAD_NUM 1 /* min thread number */
-#define MAX_THREAD_NUM 1 /* max thread number */
-COMPAT_PROTECT (MAX_THREAD_NUM, 1);
-
-/* hash size */
-#define MAX_TCP_HASH_SIZE 4096
-
-/* hal port number config */
-#define DEF_HAL_PORT_NUM 20 /* port number */
-COMPAT_PROTECT (DEF_HAL_PORT_NUM, 20);
-#define MIN_HAL_PORT_NUM 1
-#define MAX_HAL_PORT_NUM 255
-#define CUR_CFG_HAL_PORT_NUM get_base_cfg(CFG_BASE_HAL_PORT_NUM)
-
-/* vm number config */
-#define MAX_VF_NUM 4 /* max vf number */
-COMPAT_PROTECT (MAX_VF_NUM, 4);
-
-/* base ring size config */
-#define DEF_RING_BASE_SIZE 2048 /* base ring size */
-COMPAT_PROTECT (DEF_RING_BASE_SIZE, 2048);
-#define MIN_RING_BASE_SIZE 1024
-#define MAX_RING_BASE_SIZE 4096
-#define POOL_RING_BASE_SIZE get_base_cfg(CFG_BASE_RING_SIZE)
-
-/* mbuf data size config */
-#define DEF_MBUF_DATA_SIZE 2048 /* mbuf data size */
-COMPAT_PROTECT (DEF_MBUF_DATA_SIZE, 2048);
-#define TX_MBUF_MAX_LEN get_custom_cfg(CFG_MBUF_DATA_SIZE)
-
-/* tx mbuf pool size config */
-#define DEF_TX_MBUF_POOL_SIZE (4*POOL_RING_BASE_SIZE) /* tx mbuf pool size */
-
-#define TX_MBUF_POOL_SIZE get_custom_cfg(CFG_TX_MBUF_NUM)
-
-/* rx mbuf pool size config */
-#define DEF_RX_MBUF_POOL_SIZE (8*POOL_RING_BASE_SIZE) /* rx mbuf pool size */
-
-#define RX_MBUF_POOL_SIZE get_custom_cfg(CFG_RX_MBUF_NUM)
-
-/* hal netif rx/tx ring size config */
-#define DEF_HAL_RX_RING_SIZE 2048 /* hal rx ring size */
-
-#define DEF_HAL_TX_RING_SIZE 2048 /* hal tx ring size */
-#define HAL_RX_RING_SIZE get_custom_cfg(CFG_HAL_RX_RING_SIZE)
-#define HAL_TX_RING_SIZE get_custom_cfg(CFG_HAL_TX_RING_SIZE)
-
-/* stackx recv ring size config */
-#define DEF_SPL_MAX_RING_SIZE 1024
-COMPAT_PROTECT (DEF_SPL_MAX_RING_SIZE, 1024);
-
-#define SPL_MAX_RING_SIZE get_custom_cfg(CFG_SPL_MAX_RING_SIZE) /* ring size config, used in recv ring(per socket) */
-
-/* pcb number config */
-#define DEF_TCP_PCB_NUM 4096 /* tcp pcb number, per thread */
-COMPAT_PROTECT (DEF_TCP_PCB_NUM, 4096);
-#define DEF_UDP_PCB_NUM 512 /* udp pcb number, per thread */
-COMPAT_PROTECT (DEF_UDP_PCB_NUM, 512);
-#define DEF_RAW_PCB_NUM 600 /* raw pcb number, per thread */
-COMPAT_PROTECT (DEF_RAW_PCB_NUM, 600);
-
-#define DEF_ARP_QUEUE_NUM 300
-#define LARGE_ARP_QUEUE_NUM (512*1024)
-
-#define SPL_MEMP_NUM_TCP_PCB get_custom_cfg(CFG_TCP_PCB_NUM)
-
-#define SPL_MEMP_NUM_UDP_PCB get_custom_cfg(CFG_UDP_PCB_NUM)
-#define SPL_MEMP_NUM_RAW_PCB get_custom_cfg(CFG_RAW_PCB_NUM)
-
-#define SPL_MEMP_NUM_ARP_QUEUE get_custom_cfg(CFG_ARP_QUEUE_NUM)
-
-/* tcp seg number config */
-#define DEF_MEMP_NUM_TCP_SEG (2*APP_POOL_NUM*DEF_TX_MBUF_POOL_SIZE)
-#define SPL_MEMP_NUM_TCP_SEG get_custom_cfg(CFG_MP_TCPSEG_NUM) /* tcp segment number, per thread */
-
-/* stackx internal msg number config */
-#define DEF_TX_MSG_POOL_SIZE (DEF_TX_MBUF_POOL_SIZE*APP_POOL_NUM + MAX_VF_NUM*DEF_RX_MBUF_POOL_SIZE + DEF_RING_BASE_SIZE)
-
-#define TX_MSG_POOL_SIZE get_custom_cfg(CFG_MP_MSG_NUM) /* msg number, used by stackx internal, per thread */
-
-/* mbox ring size config */
-#define DEF_MBOX_RING_SIZE (DEF_RING_BASE_SIZE/4)
-COMPAT_PROTECT (DEF_MBOX_RING_SIZE, 512);
-
-#define MBOX_RING_SIZE get_custom_cfg(CFG_MBOX_RING_SIZE) /* mbox ring size config, per thread */
-
-/*some probem if CUSOTM_RECV_RING_SIZE more than 4096*/
-#define CUSOTM_RECV_RING_SIZE 4096
-COMPAT_PROTECT (CUSOTM_RECV_RING_SIZE, 4096);
-
-/*==============================================*
- * constants or macros define *
- *----------------------------------------------*/
-#define set_cfg_info(tag, item, min, max, def) { \
- g_cfg_item_info[tag][item].min_value = (min); \
- g_cfg_item_info[tag][item].max_value = (max); \
- g_cfg_item_info[tag][item].default_value = (def);\
- g_cfg_item_info[tag][item].value = (def);\
-}
-
-#define get_cfg_info(tag, item) g_cfg_item_info[tag][item].value
-
-u32 get_cfg_share_mem_size ();
-
-int get_share_cfg_from_mem (void *mem);
-
-int set_share_cfg_to_mem (void *mem);
-
-void config_module_init (cfg_module_param * param);
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif
diff --git a/stacks/lwip_stack/src/include/nsfw_rti.h b/stacks/lwip_stack/src/include/nsfw_rti.h
deleted file mode 100644
index 6b81942..0000000
--- a/stacks/lwip_stack/src/include/nsfw_rti.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef RTI_H
-#define RTI_H
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-#define nsfw_rti_stat_macro(type, m) if (1 == g_dfx_switch) { nsfw_rti_stat(type, m); }
-
-typedef enum nsfw_rti_stat_type
-{
- NSFW_STAT_PRIMARY_ENQ,
- NSFW_STAT_PRIMARY_ENQ_FAIL,
- NSFW_STAT_PRIMARY_DEQ,
-} nsfw_rti_stat_type_t;
-
-typedef struct nsfw_app_info
-{
- int nsocket_fd;
- int sbr_fd;
-
- int hostpid;
- int pid;
- int ppid;
-
- u64 reserve1;
- u64 reserve2;
- u64 reserve3;
- u64 reserve4;
-
- u64 extend_member_bit;
-} nsfw_app_info_t;
-
-struct rti_queue;
-struct msg_t;
-
-extern char g_dfx_switch;
-extern struct rti_queue *g_nsfw_rti_primary_stat;
-
-void nsfw_rti_stat (nsfw_rti_stat_type_t statType, const struct msg_t *m);
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif
diff --git a/stacks/lwip_stack/src/io_adpt/CMakeLists.txt b/stacks/lwip_stack/src/io_adpt/CMakeLists.txt
deleted file mode 100644
index ae18116..0000000
--- a/stacks/lwip_stack/src/io_adpt/CMakeLists.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-#########################################################################
-#
-# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-# 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.
-#########################################################################
-
-FILE(GLOB_RECURSE HAL *.c)
-
-if(WITH_HAL_LIB)
-else()
-endif()
-
-
-INCLUDE_DIRECTORIES(
- ./
- ${PROJECT_SOURCE_DIR}/src/include/
- ${PROJECT_SOURCE_DIR}/src/include/generic/
- /usr/include/dpdk/
-)
-LINK_LIBRARIES(m dl rt dmm_api)
-ADD_LIBRARY(nStackHal STATIC ${HAL})
diff --git a/stacks/lwip_stack/src/io_adpt/dpdk.c b/stacks/lwip_stack/src/io_adpt/dpdk.c
deleted file mode 100644
index 8518112..0000000
--- a/stacks/lwip_stack/src/io_adpt/dpdk.c
+++ /dev/null
@@ -1,2476 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include <stdint.h>
-#include <sched.h>
-#include <dlfcn.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <net/if.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-#include <sys/file.h>
-#include <pwd.h>
-#include <dirent.h>
-#include <sys/stat.h>
-#include <fnmatch.h>
-#include <linux/ethtool.h>
-#include <linux/sockios.h>
-
-#include <rte_config.h>
-#include <rte_ethdev.h>
-#include <rte_mbuf.h>
-#include <rte_eth_bond.h>
-#include "nsfw_init.h"
-#include "common_mem_mbuf.h"
-#include "common_mem_mempool.h"
-#include "common_func.h"
-#include "hal.h"
-#include "nstack_securec.h"
-#include <rte_ethdev_driver.h>
-
-#define DPDK_NON_ROOT_USER_NAME "paas"
-#define DPDK_TOOL_ENV "DPDK_TOOL_DIR"
-#define DPDK_NIC_LIST_FILE "%s/ip_module/.nstack_dpdk_nic_list"
-#define SOCKET_ID_0 0
-
-NSTACK_STATIC struct passwd *dpdk_non_root_user;
-NSTACK_STATIC char dpdk_tool_path[HAL_MAX_PATH_LEN] = { 0 };
-
-/* Default configuration for rx and tx thresholds etc. */
-NSTACK_STATIC const struct rte_eth_rxconf rx_conf_default_igb = {
- .rx_thresh = {
- .pthresh = 8,
- .hthresh = 8,
- .wthresh = 1, //not bigger than 1
- },
-};
-
-/*
- * These default values are optimized for use with the Intel(R) 82576 1 GbE
- * Controller and the DPDK e1000 PMD. Consider using other values for other
- * network controllers and/or network drivers.
- */
-NSTACK_STATIC const struct rte_eth_txconf tx_conf_default_igb = {
- .tx_thresh = {
- .pthresh = 8,
- .hthresh = 1,
- .wthresh = 16,
- },
- .tx_free_thresh = 0, /* Use PMD default values */
- .tx_rs_thresh = 0, /* Use PMD default values */
-};
-
-/*
- * RX and TX Prefetch, Host, and Write-back threshold values should be
- * carefully set for optimal performance. Consult the network
- * controller's datasheet and supporting DPDK documentation for guidance
- * on how these parameters should be set.
- */
-
-/* Default configuration for rx and tx thresholds etc. */
-NSTACK_STATIC const struct rte_eth_rxconf rx_conf_default_ixgbe = {
- .rx_thresh = {
- .pthresh = 8,
- .hthresh = 8,
- .wthresh = 4,
- },
- .rx_free_thresh = 0,
-};
-
-/*
- * These default values are optimized for use with the Intel(R) 82599 10 GbE
- * Controller and the DPDK ixgbe PMD. Consider using other values for other
- * network controllers and/or network drivers.
- */
-NSTACK_STATIC const struct rte_eth_txconf tx_conf_default_ixgbe = {
- .tx_thresh = {
- .pthresh = 36,
- .hthresh = 0,
- .wthresh = 0,
- },
- .tx_free_thresh = 0, /* Use PMD default values */
- .tx_rs_thresh = 0, /* Use PMD default values */
- .txq_flags = 0,
-};
-
-/* the port configuration of normal port */
-NSTACK_STATIC struct rte_eth_conf port_conf_default_normal = {
- .rxmode = {
- .mq_mode = ETH_RSS,
- .max_rx_pkt_len = ETHER_MAX_LEN,
- .split_hdr_size = 0,
- .header_split = 0,
- .hw_ip_checksum = 1,
- .hw_vlan_filter = 1,
- .hw_vlan_strip = 1,
- .jumbo_frame = 0,
- .hw_strip_crc = 0,
- },
- .rx_adv_conf = {
- .rss_conf = {
- .rss_key = NULL,
- .rss_hf = (ETH_RSS_IPV4 | ETH_RSS_NONFRAG_IPV4_TCP | ETH_RSS_NONFRAG_IPV4_UDP), //rss hash key
- },
- },
- .txmode = {
- .mq_mode = ETH_DCB_NONE,
- },
- .intr_conf = {
- .lsc = 0,
- },
-};
-
-/* the port configuration of virtio port */
-NSTACK_STATIC struct rte_eth_conf port_conf_default_virtio = {
- .rxmode = {
- .mq_mode = ETH_RSS,
- .max_rx_pkt_len = ETHER_MAX_LEN,
- .split_hdr_size = 0,
- .header_split = 0,
- .hw_ip_checksum = 0, /* Virtio NIC doesn't support HW IP CheckSUM */
- .hw_vlan_filter = 1,
- .hw_vlan_strip = 1,
- .jumbo_frame = 0,
- .hw_strip_crc = 0,
- },
- .rx_adv_conf = {
- .rss_conf = {
- .rss_key = NULL,
- .rss_hf = (ETH_RSS_IPV4 | ETH_RSS_NONFRAG_IPV4_TCP | ETH_RSS_NONFRAG_IPV4_UDP), //rss hash key
- },
- },
- .txmode = {
- .mq_mode = ETH_DCB_NONE,
- },
- .intr_conf = {
- .lsc = 0,
- },
-};
-
-/* the port configuration of bond port */
-NSTACK_STATIC struct rte_eth_conf port_conf_default_bond = {
- .rxmode = {
- .mq_mode = ETH_MQ_RX_NONE,
- .max_rx_pkt_len = ETHER_MAX_LEN,
- .split_hdr_size = 0,
- .header_split = 0,
- /**< Header Split disabled */
- .hw_ip_checksum = 0,
- /**< IP checksum offload enabled */
- .hw_vlan_filter = 1,
- /**< VLAN filtering enabled */
- .hw_vlan_strip = 1,
- .jumbo_frame = 0,
- /**< Jumbo Frame Support disabled */
- .hw_strip_crc = 0,
- /**< CRC stripped by hardware */
- },
- .rx_adv_conf = {
- .rss_conf = {
- .rss_key = NULL,
- .rss_hf = ETH_RSS_IP,
- },
- },
- .txmode = {
- .mq_mode = ETH_MQ_TX_NONE,
- },
-};
-
-NSTACK_STATIC struct rte_eth_conf port_conf_default_vhost = {
- .rxmode = {
- .hw_ip_checksum = 0, /* vhost nic doesn't support hw_ip_checksum and hw_vlan_filter */
- .hw_vlan_filter = 0,
- }
-};
-
-/*****************************************************************************
-* Prototype : dpdk_mbuf_to_file
-* Description : write the packet data into a file
-* Input : uint16_t pkt_number
-* struct rte_mbuf **pkts
-* Output : None
-* Return Value :
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-NSTACK_STATIC void
-dpdk_mbuf_to_file (uint16_t pkt_number, struct rte_mbuf **pkts)
-{
- char line[100] = { 0 };
- FILE *f = NULL;
- struct rte_mbuf *p = NULL;
- uint16_t len = 0, offset, i;
- uint16_t pktlen = 0;
- uint16_t start = 0;
- uint16_t number = 0;
- unsigned char *data = NULL;
-
- f = fopen ("/var/log/nStack/packet.txt", "a+");
- if (f == NULL)
- {
- NSHAL_LOGERR ("can not open the file:%s", "packet.txt");
- return;
- }
-
- for (i = 0; i < pkt_number; i++)
- {
- pktlen = 0;
- p = pkts[i];
- while (p)
- {
- len = 0;
- data = rte_pktmbuf_mtod (p, unsigned char *);
- while (len < p->data_len)
- {
- start = pktlen % 16; /* start of the line */
- if (start == 0)
- {
- number = SNPRINTF_S (line, sizeof (line), sizeof (line) - 1,
- "%08X", len);
- }
-
- for (offset = 0;
- ((offset + start) < 16) && ((len + offset) < p->data_len);
- offset++)
- {
- number +=
- SNPRINTF_S (line + number, sizeof (line),
- sizeof (line) - 1, " %02X",
- data[len + offset]);
- }
-
- fprintf (f, "%s", line);
- if ((offset + start) == 16)
- fprintf (f, "\n");
-
- len += offset;
- pktlen += offset;
- (void) MEMSET_S (line, sizeof (line), 0, sizeof (line));
- }
-
- p = p->next;
-
- }
- fprintf (f, "\n");
- }
-
- fclose (f);
- return;
-}
-
-/*****************************************************************************
-* Prototype : hal_rte_eth_rx_burst
-* Description : a copy of rte_eth_rx_burst, because this function invokes
- a global(rte_eth_devices), which cannt be access by dlsym
- symbols
-* Input : uint8_t port_id
-* uint16_t queue_id
-* struct rte_mbuf **rx_pkts
-* const uint16_t nb_pkts
-* Output : None
-* Return Value :
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-NSTACK_STATIC inline uint16_t
-hal_rte_eth_rx_burst (uint8_t port_id, uint16_t queue_id,
- struct rte_mbuf ** rx_pkts, const uint16_t nb_pkts)
-{
-#ifdef RTE_ETHDEV_RXTX_CALLBACKS
- struct rte_eth_rxtx_callback *cb;
-#endif
- int16_t nb_rx;
- char *pst_capture_packet = NULL;
- struct rte_eth_dev *dev = &rte_eth_devices[port_id];
-
- if (NULL == dev->rx_pkt_burst)
- {
- NSHAL_LOGERR ("dev->rx_pkt_burst is NULL,dev=%p", dev);
- return 0;
- }
-
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
- RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, 0);
- RTE_FUNC_PTR_OR_ERR_RET (*dev->rx_pkt_burst, 0);
-
- if (queue_id >= dev->data->nb_rx_queues)
- {
- RTE_PMD_DEBUG_TRACE ("Invalid RX queue_id=%d\n", queue_id);
- return 0;
- }
-#endif
- nb_rx = (*dev->rx_pkt_burst) (dev->data->rx_queues[queue_id],
- rx_pkts, nb_pkts);
-
-#ifdef RTE_ETHDEV_RXTX_CALLBACKS
- cb = dev->post_rx_burst_cbs[queue_id];
-
- if (unlikely (cb != NULL))
- {
- do
- {
- nb_rx = cb->fn.rx (port_id, queue_id, rx_pkts, nb_rx,
- nb_pkts, cb->param);
- cb = cb->next;
- }
- while (cb != NULL);
- }
-#endif
-
- //pst_capture_packet = getenv ("NSTACK_CAPTURE_PACKET");
- if (pst_capture_packet && strcmp (pst_capture_packet, "1") == 0)
- {
- dpdk_mbuf_to_file (nb_rx, rx_pkts);
- }
- return (uint16_t) nb_rx;
-}
-
-/*****************************************************************************
-* Prototype : hal_rte_eth_tx_burst
-* Description : a copy of rte_eth_tx_burst, because this function invokes
-
-* Input : uint8_t port_id
-* uint16_t queue_id
-* struct rte_mbuf **tx_pkts
-* uint16_t nb_pkts
-* Output : None
-* Return Value :
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-NSTACK_STATIC inline uint16_t
-hal_rte_eth_tx_burst (uint8_t port_id, uint16_t queue_id,
- struct rte_mbuf ** tx_pkts, uint16_t nb_pkts)
-{
-#ifdef RTE_ETHDEV_RXTX_CALLBACKS
- struct rte_eth_rxtx_callback *cb;
-#endif
- int16_t nb_tx = 0;
- char *pst_capture_packet = NULL;
- struct rte_eth_dev *dev = &rte_eth_devices[port_id];
-
- if (NULL == dev->tx_pkt_burst)
- {
- NSHAL_LOGERR ("dev->tx_pkt_burst is NULL");
- return 0;
- }
-
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
- RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, 0);
- RTE_FUNC_PTR_OR_ERR_RET (*dev->tx_pkt_burst, 0);
-
- if (queue_id >= dev->data->nb_tx_queues)
- {
- RTE_PMD_DEBUG_TRACE ("Invalid TX queue_id=%d\n", queue_id);
- return 0;
- }
-#endif
-
-#ifdef RTE_ETHDEV_RXTX_CALLBACKS
- cb = dev->pre_tx_burst_cbs[queue_id];
-
- if (unlikely (cb != NULL))
- {
- do
- {
- nb_pkts = cb->fn.tx (port_id, queue_id, tx_pkts, nb_pkts,
- cb->param);
- cb = cb->next;
- }
- while (cb != NULL);
- }
-#endif
-
- nb_tx = (*dev->tx_pkt_burst) (dev->data->tx_queues[queue_id], tx_pkts,
- nb_pkts);
-
- //pst_capture_packet = getenv ("NSTACK_CAPTURE_PACKET");
- if (pst_capture_packet && strcmp (pst_capture_packet, "1") == 0)
- {
- dpdk_mbuf_to_file (nb_tx, tx_pkts);
- }
-
- return nb_tx;
-}
-
-/*****************************************************************************
- Prototype : dpdk_get_hugepage_size
- Description : get the free hugepage size
- Input : the dir of the nstack hugepage
- Output : free hugepage size
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-int
-dpdk_read_hugepage_size (int *freehuge)
-{
- int fd_huge;
- int len;
- char buf[5] = { '\0' };
- fd_huge =
- open ("/sys/kernel/mm/hugepages/hugepages-1048576kB/free_hugepages",
- O_RDONLY);
- if (fd_huge < 0)
- {
- NSHAL_LOGERR ("errno=%d", errno);
- return -1;
- }
-
- len = read (fd_huge, buf, sizeof (buf));
- if (len < 0)
- {
- NSHAL_LOGERR ("errno=%d", errno);
- close (fd_huge); //fix codeDEX 124547
- return -1;
- }
- *freehuge = buf[0] - '0';
- NSHAL_LOGINF ("hugepage size=%d", *freehuge);
- close (fd_huge);
-
- return 0;
-}
-
-/*****************************************************************************
- Prototype : dpdk_clear_hugedir
- Description : clear the hugepage which is used by dpdk
- Input : the dir of the nstack hugepage
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC int
-dpdk_clear_hugedir (const char *hugedir)
-{
- DIR *dir;
- struct dirent *dirent_dpdk;
- int dir_fd, fd, lck_result, lk_result;
- const char filter[] = "*mapns*"; /* matches hugepage files */
-
- /* open directory */
- dir = opendir (hugedir);
- if (!dir)
- {
- NSHAL_LOGERR ("the path %s is not exist, errno = %d", hugedir, errno);
- goto error;
- }
- dir_fd = dirfd (dir);
-
- dirent_dpdk = readdir (dir);
- if (!dirent_dpdk)
- {
- NSHAL_LOGERR ("the dir %s can not read, errno = %d", hugedir, errno);
- goto error;
- }
-
- while (dirent_dpdk != NULL)
- {
- /* skip files that don't match the hugepage pattern */
- if (fnmatch (filter, dirent_dpdk->d_name, 0) > 0)
- {
- NSHAL_LOGWAR ("the file name %s is not match mapns, errno = %d",
- dirent_dpdk->d_name, errno);
- dirent_dpdk = readdir (dir);
- continue;
- }
-
- /* try and lock the file */
- fd = openat (dir_fd, dirent_dpdk->d_name, O_RDONLY);
-
- /* skip to next file */
- if (fd == -1)
- {
- NSHAL_LOGERR ("the file name %s can not be lock, errno = %d",
- dirent_dpdk->d_name, errno);
- dirent_dpdk = readdir (dir);
- continue;
- }
-
- /* non-blocking lock */
- lck_result = flock (fd, LOCK_EX | LOCK_NB);
-
- /* if lock succeeds, unlock and remove the file */
- if (lck_result != -1)
- {
- NSHAL_LOGWAR
- ("the file name %s can be lock and will delete, errno = %d",
- dirent_dpdk->d_name, errno);
- lck_result = flock (fd, LOCK_UN);
- if (-1 == lck_result)
- NSHAL_LOGERR ("the file name %s unlock fail, errno = %d",
- dirent_dpdk->d_name, errno);
- lk_result = unlinkat (dir_fd, dirent_dpdk->d_name, 0);
- if (-1 == lk_result)
- NSHAL_LOGERR ("the file name %s is unlinkat fail, errno = %d",
- dirent_dpdk->d_name, errno);
- }
- close (fd);
- dirent_dpdk = readdir (dir);
- }
-
- (void) closedir (dir);
- return 0;
-
-error:
- if (dir)
- (void) closedir (dir);
-
- return -1;
-}
-
-/*****************************************************************************
- Prototype : dpdk_init_global
- Description : DPDK global init
- Input : int argc
- char** argv
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC int
-dpdk_init_global (int argc, char **argv)
-{
- //int ret;
- const char hugepath[] = "/mnt/nstackhuge";
- //int freeHuge = 0;
- //int retryCount = 10;
-
- if (-1 == dpdk_clear_hugedir (hugepath))
- {
- NSHAL_LOGERR ("clear hugedir fail, try again!");
- sys_sleep_ns (0, 100000000);
- (void) dpdk_clear_hugedir (hugepath);
- }
- NSHAL_LOGINF ("init global succ");
-
- return 0;
-}
-
-/*****************************************************************************
- Prototype : dpdk_init_env
- Description : init dpdk run env
- Input : void
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC int
-dpdk_init_env (void)
-{
- int ret;
- size_t len_size;
- char *dpdk_env;
- char *dpdk_path;
-
- /* Get dpdk_tool_path */
- dpdk_env = getenv (DPDK_TOOL_ENV);
- if (NULL == dpdk_env)
- {
- NSHAL_LOGERR ("please set enviroment:%s before start this stack"
- "\nthe value of the %s must be the path of dpdk tools",
- DPDK_TOOL_ENV, DPDK_TOOL_ENV);
- return -1;
- }
-
- /* modify ugly len_size judgement and strcpy */
- /* check len_size for malloc */
- len_size = strlen (dpdk_env);
- if (0 == len_size || len_size >= HAL_MAX_PATH_LEN)
- {
- NSHAL_LOGERR ("fail to dpdk_env strlen(DPDK_TOOL_ENV)");
- return -1;
- }
-
- /* DPDK_TOOL_ENV's value will be use as popen's paramter,we need check's validity */
- dpdk_path = realpath (dpdk_env, NULL);
- if (NULL == dpdk_path)
- {
- NSHAL_LOGERR ("env:%s value incorrect]value=%s,errno=%d", DPDK_TOOL_ENV,
- dpdk_env, errno);
- return -1;
- }
-
- len_size = strlen (dpdk_path);
- if (0 == len_size || len_size >= HAL_MAX_PATH_LEN)
- {
- NSHAL_LOGERR ("fail to dpdk_path strlen(DPDK_TOOL_ENV)");
- return -1;
- }
-
- ret = STRCPY_S (dpdk_tool_path, HAL_MAX_PATH_LEN, dpdk_path);
- if (EOK != ret)
- {
- NSHAL_LOGERR ("STRCPY_S failed]ret=%d", ret);
- return -1;
- }
-
- if (!hal_is_script_valid (dpdk_tool_path))
- {
- NSHAL_LOGERR ("dpdk_tool_path is invalid]dpdk_tool_path=%s",
- dpdk_tool_path);
- return -1;
- }
-
- /* get non-root user's id */
- dpdk_non_root_user = getpwnam (DPDK_NON_ROOT_USER_NAME);
- if (dpdk_non_root_user)
- {
- NSHAL_LOGINF ("non-root]name=%s,uid=%u,gid=%u,errno=%d",
- dpdk_non_root_user->pw_name, dpdk_non_root_user->pw_uid,
- dpdk_non_root_user->pw_gid, errno);
- }
- else
- {
- NSHAL_LOGERR ("non-root]cannot find user %s", DPDK_NON_ROOT_USER_NAME);
- }
-
- return 0;
-}
-
-/*****************************************************************************
- Prototype : dpdk_init_local
- Description : DPDK local init
- Input : void
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC int
-dpdk_init_local (void)
-{
- int ret;
-
- ret = dpdk_init_env ();
-
- if (ret < 0)
- {
- NSHAL_LOGERR ("dpdk_init_env failed");
- return -1;
- }
-
- NSHAL_LOGINF ("init local succ");
-
- return 0;
-}
-
-/*****************************************************************************
- Prototype : dpdk_set_port
- Description : check and save the port num
- Input : netif_inst_t* inst
- int port
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC int
-dpdk_set_port (netif_inst_t * inst, uint8_t port)
-{
- if (port >= rte_eth_dev_count ())
- {
- NSHAL_LOGERR ("the number of port=%d is more than rte_eth_dev_count=%d",
- port, rte_eth_dev_count ());
- return -1;
- }
-
- inst->data.dpdk_if.port_id = port;
-
- return 0;
-
-}
-
-/*****************************************************************************
- Prototype : dpdk_set_nic_type
- Description : check and save nic type
- Input : netif_inst_t* inst
- const char* type
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC int
-dpdk_set_nic_type (netif_inst_t * inst, const char *type)
-{
- int ret;
-
- ret =
- STRCPY_S (inst->data.dpdk_if.nic_type,
- sizeof (inst->data.dpdk_if.nic_type), type);
- if (EOK != ret)
- {
- NSHAL_LOGERR ("strcpy_s set nic_type failed]ret=%d", ret);
- return -1;
- }
-
- /*
- * *nic_type is first checked at read_ipmoduleoperateadd_configuration,
- * *thus here we dont boring validating it once more and just return.
- * */
-
- return 0;
-}
-
-/*****************************************************************************
- Prototype : dpdk_set_nic_name
- Description : check and save nic name
- Input : netif_inst_t* inst
- const char* name
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC int
-dpdk_set_nic_name (netif_inst_t * inst, const char *name)
-{
- int ret;
-
- /* sizeof(pointer) always = 8 in 64 bit system */
- ret =
- STRCPY_S (inst->data.dpdk_if.nic_name,
- sizeof (inst->data.dpdk_if.nic_name), name);
- if (EOK != ret)
- {
- NSHAL_LOGERR ("STRCPY_S set nic_name failed]ret=%d", ret);
- return -1;
- }
-
- if (!hal_is_script_valid (inst->data.dpdk_if.nic_name))
- {
- NSHAL_LOGERR ("nic_name is invalid");
- return -1;
- }
-
- return 0;
-}
-
-/*****************************************************************************
- Prototype : dpdk_get_driver_name
- Description : get and save driver name
- Input : netif_inst_t* inst
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC int
-dpdk_get_driver_name (netif_inst_t * inst)
-{
- int ret_len, ret;
- char script_cmmd[HAL_SCRIPT_LENGTH];
- char driver_name[HAL_SCRIPT_LENGTH] = { 0 };
-
- ret = hal_snprintf (script_cmmd, sizeof (script_cmmd),
- "readlink -f /sys/class/net/" "%s"
- "/device/driver| awk -F'/' '{print $6}'",
- inst->data.dpdk_if.nic_name);
- if (-1 == ret)
- {
- NSHAL_LOGERR ("hal_snprintf failed");
- return -1;
- }
-
- ret_len =
- hal_run_script (script_cmmd, driver_name, sizeof (driver_name) - 1);
-
- if (ret_len > HAL_MAX_DRIVER_NAME_LEN)
- {
- ret_len = HAL_MAX_DRIVER_NAME_LEN;
- }
-
- if (ret_len <= 0)
- {
- NSHAL_LOGERR ("%s does't have a driver", driver_name);
-
- ret =
- STRNCPY_S (inst->data.dpdk_if.driver_name,
- sizeof (inst->data.dpdk_if.driver_name), "NULL",
- sizeof ("NULL"));
-
- if (EOK != ret)
- {
- NSHAL_LOGERR ("STRNCPY_S failed]ret=%d.", ret);
- return -1;
- }
-
- return -1;
- }
- else
- {
- ret =
- STRNCPY_S (inst->data.dpdk_if.driver_name,
- sizeof (inst->data.dpdk_if.driver_name), driver_name,
- ret_len);
-
- if (EOK != ret)
- {
- NSHAL_LOGERR ("STRNCPY_S failed]ret=%d.", ret);
- return -1;
- }
-
- inst->data.dpdk_if.driver_name[(ret_len - 1)] = '\0';
-
- return 0;
- }
-}
-
-/*****************************************************************************
- Prototype : dpdk_set_pci_permission
- Description : set pci permission
- Input : char *pci_addr
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC int
-dpdk_set_pci_permission (char *pci_addr)
-{
- DIR *dir_desc;
- char file_path[HAL_SCRIPT_LENGTH] = { 0 }, dir_path[HAL_SCRIPT_LENGTH] =
- {
- 0};
- struct dirent *ent;
- struct stat statbuf;
- int ret;
-
- ret =
- SNPRINTF_S (dir_path, sizeof (dir_path), sizeof (dir_path) - 1,
- "/sys/bus/pci/devices/%s", pci_addr);
- if (ret < 0)
- {
- NSHAL_LOGERR ("SNPRINTF_S fail");
- return -1;
- }
-
- if ((dir_desc = opendir (dir_path)) == NULL)
- {
- NSHAL_LOGERR ("opendir fail:errno=%d", errno);
- return -1;
- }
-
- while ((ent = readdir (dir_desc)) != NULL)
- {
- if (strstr (ent->d_name, "resource"))
- {
- ret =
- SNPRINTF_S (file_path, sizeof (file_path), sizeof (file_path) - 1,
- "%s/%s", dir_path, ent->d_name);
- if (ret < 0)
- {
- NSHAL_LOGERR ("SNPRINTF_S fail");
- (void) closedir (dir_desc);
- return -1;
- }
-
- if (!lstat (file_path, &statbuf) && !S_ISDIR (statbuf.st_mode))
- {
- ret =
- chown (file_path, dpdk_non_root_user->pw_uid,
- dpdk_non_root_user->pw_gid);
- if (ret < 0)
- {
- NSHAL_LOGERR ("chown fail]file_path=%s,ret=%d,errno=%d",
- file_path, ret, errno);
- (void) closedir (dir_desc);
- return -1;
- }
- NSHAL_LOGWAR ("chown succ]file_path=%s,ret=%d", file_path, ret);
- ret = chmod (file_path, 0640);
- if (ret < 0)
- {
- NSHAL_LOGERR ("chmod fail]file_path=%s,ret=%d,errno=%d",
- file_path, ret, errno);
- (void) closedir (dir_desc);
- return -1;
- }
- NSHAL_LOGWAR ("chmod succ]file_path=%s,ret=%d", file_path, ret);
- }
- }
- }
-
- (void) closedir (dir_desc);
- return 0;
-}
-
-/*****************************************************************************
- Prototype : dpdk_get_pci_addr
- Description : get and save pci addr
- Input : netif_inst_t* inst
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC int
-dpdk_get_pci_addr (netif_inst_t * inst)
-{
- int ret, pci_len;
- struct ethtool_drvinfo edata = { 0 };
- struct ifreq ifr;
- int fd = -1;
-
- /* use ioctl to get pci address instead of call dpdk-devbind.py to reduce time cost */
- ret = MEMSET_S (&ifr, sizeof (ifr), 0, sizeof (ifr));
- if (EOK != ret)
- {
- NSHAL_LOGERR ("MEMSET_S fail");
- return -1;
- }
- edata.cmd = ETHTOOL_GDRVINFO;
- ret =
- STRCPY_S (ifr.ifr_name, sizeof (ifr.ifr_name),
- inst->data.dpdk_if.nic_name);
- if (EOK != ret)
- {
- NSHAL_LOGERR ("STRCPY_S fail");
- return -1;
- }
-
- ifr.ifr_data = (char *) (&edata);
- if ((fd = socket (AF_INET, SOCK_DGRAM, 0)) < 0)
- {
- NSHAL_LOGERR ("cannot init socket, errno=%d", errno);
- return -1;
- }
- if (ioctl (fd, SIOCETHTOOL, &ifr) < 0)
- {
- NSHAL_LOGERR ("ioctl to the device %s err, errno=%d",
- inst->data.dpdk_if.nic_name, errno);
- close (fd);
- return -1;
- }
- close (fd);
-
- pci_len = strlen (edata.bus_info);
- if (pci_len == 0
- || pci_len > (int) sizeof (inst->data.dpdk_if.pci_addr) - 1)
- {
- NSHAL_LOGERR ("does't have a pci_addr");
- inst->data.dpdk_if.pci_addr[0] = '\0';
- return -1;
- }
-
- NSHAL_LOGINF ("nic_name=%s,nic_pci_addr=%s", inst->data.dpdk_if.nic_name,
- edata.bus_info);
-
- ret =
- STRNCPY_S (inst->data.dpdk_if.pci_addr,
- sizeof (inst->data.dpdk_if.pci_addr), edata.bus_info, pci_len);
- if (EOK != ret)
- {
- NSHAL_LOGERR ("STRNCPY_S failed]ret=%d.", ret);
- return -1;
- }
-
- if (!hal_is_script_valid (inst->data.dpdk_if.pci_addr))
- {
- NSHAL_LOGERR ("pci_addr is invalid]pci_addr=%s",
- inst->data.dpdk_if.pci_addr);
- return -1;
- }
-
- if (dpdk_non_root_user && getuid ())
- {
- ret = dpdk_set_pci_permission (inst->data.dpdk_if.pci_addr);
- if (ret < 0)
- {
- NSHAL_LOGERR ("dpdk_set_pci_permission fail");
- return -1;
- }
- }
-
- return 0;
-}
-
-/*****************************************************************************
- Prototype : dpdk_mlx_linkup
- Description : linkup the port for mlx
- In bonding mode, mlx4 NICs should be set up manually,
- in order to make bond port up
- Input : char* name
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC int
-dpdk_mlx_linkup (char *name)
-{
- struct ifreq st_ifreq;
- int sock;
- int retVal;
-
- if ((sock = socket (AF_INET, SOCK_STREAM, 0)) < 0)
- {
- NSHAL_LOGERR ("socket fail]errno=%d", errno);
- return 2;
- }
-
- retVal = STRCPY_S (st_ifreq.ifr_name, sizeof (st_ifreq.ifr_name), name);
-
- if (EOK != retVal)
- {
- NSHAL_LOGERR ("STRCPY_S fail]");
- close (sock);
- return 1;
- }
-
- if (ioctl (sock, (uint64_t) SIOCGIFFLAGS, &st_ifreq) < 0)
- {
- NSHAL_LOGERR ("ioctl SIOCGIFFLAGS fail]errno=%d", errno);
- close (sock);
- return 3;
- }
-
- st_ifreq.ifr_flags |= IFF_UP;
- st_ifreq.ifr_flags |= IFF_RUNNING;
-
- if (ioctl (sock, (uint64_t) SIOCSIFFLAGS, &st_ifreq) < 0)
- {
- NSHAL_LOGERR ("ioctl SIOCSIFFLAGS fail]errno=%d", errno);
- close (sock);
- return 3;
- }
-
- close (sock);
- return 0;
-}
-
-/*****************************************************************************
- Prototype : dpdk_nonmlx_linkdown
- Description : linkdown the port for nonmlx
- Input : char* name
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC int
-dpdk_nonmlx_linkdown (char *name)
-{
- int ret, ret_len;
- char script_cmmd[HAL_SCRIPT_LENGTH];
- char result_buf[HAL_SCRIPT_LENGTH];
-
- ret =
- hal_snprintf (script_cmmd, sizeof (script_cmmd), "sudo ifconfig %s down",
- name);
- if (-1 == ret)
- {
- NSHAL_LOGERR ("spl_snprintf failed]");
- return -1;
- }
-
- ret_len = hal_run_script (script_cmmd, result_buf, sizeof (result_buf));
- NSHAL_LOGINF ("ifconfig]script_cmmd=%s,ret_len=%d", script_cmmd, ret_len);
- if (0 > ret_len)
- {
- NSHAL_LOGERR ("cannot able to ifconfig %s down", name);
- return -1;
- }
-
- return 0;
-}
-
-/*****************************************************************************
- Prototype : dpdk_get_uio_by_pci_addr
- Description : get uio
- Input : char *pci_addr
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC int
-dpdk_get_uio_by_pci_addr (char *pci_addr)
-{
- int i, ret, ret_len;
- char script_cmmd[HAL_SCRIPT_LENGTH];
- char result_buf[HAL_SCRIPT_LENGTH];
-
- for (i = 0; i < RTE_MAX_ETHPORTS; i++)
- {
- ret = hal_snprintf (script_cmmd, sizeof (script_cmmd),
- "readlink ls /sys/class/uio/uio%d/device | awk -F '/' '{print $4}'",
- i);
- if (-1 == ret)
- {
- NSHAL_LOGERR ("hal_snprintf fail]pci=%s,i=%d", pci_addr, i);
- return -1;
- }
-
- ret_len = hal_run_script (script_cmmd, result_buf, sizeof (result_buf));
- if (0 > ret_len)
- {
- NSHAL_LOGERR ("hal_run_script fail]pci=%s,i=%d", pci_addr, i);
- return -1;
- }
- if (strcmp (result_buf, pci_addr) == 0)
- return i;
- }
-
- return -1;
-}
-
-/*****************************************************************************
- Prototype : dpdk_set_uio_permission
- Description : set uio permission
- Input : char *pci_addr
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC int
-dpdk_set_uio_permission (char *pci_addr)
-{
- int ret, uio_idx;
- char file_path[HAL_SCRIPT_LENGTH / 2] = { 0 };
-
- /* get /dev/uio by pci addr */
- uio_idx = dpdk_get_uio_by_pci_addr (pci_addr);
- if (uio_idx < 0)
- {
- NSHAL_LOGERR ("dpdk_get_uio_by_pci_addr fail]pci_addr=%s", pci_addr);
- return -1;
- }
-
- NSHAL_LOGINF ("uio_idx]pci=%s,uio%d", pci_addr, uio_idx);
-
- /* change /dev/uio%u permission */
- if (SNPRINTF_S
- (file_path, sizeof (file_path), sizeof (file_path) - 1, "/dev/uio%d",
- uio_idx) < 0)
- {
- NSHAL_LOGERR ("SNPRINTF_S failed]uio%d", uio_idx);
- return -1;
- }
- sys_sleep_ns (0, 500000000);
- ret =
- chown (file_path, dpdk_non_root_user->pw_uid, dpdk_non_root_user->pw_gid);
- if (ret < 0)
- {
- NSHAL_LOGERR ("chown fail]file_path=%s,ret=%d,errno=%d", file_path, ret,
- errno);
- return -1;
- }
- NSHAL_LOGWAR ("chown succ]file_path=%s,ret=%d", file_path, ret);
-
- ret = chmod (file_path, 0640);
- if (ret < 0)
- {
- NSHAL_LOGERR ("chmod fail]file_path=%s,ret=%d,errno=%d", file_path, ret,
- errno);
- return -1;
- }
- NSHAL_LOGWAR ("chmod succ]file_path=%s,ret=%d", file_path, ret);
-
- /* change /sys/class/uio/uio%u/device/config permission */
- if (SNPRINTF_S
- (file_path, sizeof (file_path), sizeof (file_path) - 1,
- "/sys/class/uio/uio%d/device/config", uio_idx) < 0)
- {
- NSHAL_LOGERR ("SNPRINTF_S failed]uio%d", uio_idx);
- return -1;
- }
-
- ret =
- chown (file_path, dpdk_non_root_user->pw_uid, dpdk_non_root_user->pw_gid);
- if (ret < 0)
- {
- NSHAL_LOGERR ("chown fail]file_path=%s,ret=%d,errno=%d", file_path, ret,
- errno);
- return -1;
- }
- NSHAL_LOGWAR ("chown succ]file_path=%s,ret=%d", file_path, ret);
-
- ret = chmod (file_path, 0640);
- if (ret < 0)
- {
- NSHAL_LOGERR ("chmod fail]file_path=%s,ret=%d,errno=%d", file_path, ret,
- errno);
- return -1;
- }
- NSHAL_LOGWAR ("chmod succ]file_path=%s,ret=%d", file_path, ret);
-
- return 0;
-}
-
-/*****************************************************************************
- Prototype : dpdk_get_nic_list_file
- Description : get dpdk bind nic list file
- Input : void
- Output : char*
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC char *
-dpdk_get_nic_list_file (void)
-{
- int ret;
- static char buffer[HAL_MAX_PATH_LEN]; /* static so auto-zeroed */
- const char *directory = "/var/run";
- const char *home_dir = getenv ("HOME");
-
- if (getuid () != 0 && home_dir != NULL)
- directory = home_dir;
-
- ret =
- SNPRINTF_S (buffer, sizeof (buffer), sizeof (buffer) - 1,
- DPDK_NIC_LIST_FILE, directory);
- if (-1 == ret)
- {
- NSCOMM_LOGERR ("SNPRINTF_S failed]ret=%d", ret);
- return NULL;
- }
-
- return buffer;
-}
-
-/*****************************************************************************
- Prototype : dpdk_bind_uio
- Description : bind uio
- Input : netif_inst_t* inst
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC int
-dpdk_bind_uio (netif_inst_t * inst)
-{
- char script_cmmd[HAL_SCRIPT_LENGTH];
- char result_buf[HAL_SCRIPT_LENGTH];
- int ret, ret_len;
-
- result_buf[0] = '\0';
-
- if (strncmp ("mlx4_co", inst->data.dpdk_if.driver_name, (size_t) 7) == 0)
- {
- /*For MLX4: NIC should be set link up before rte_eth_dev_start() is called. */
- ret = dpdk_mlx_linkup (inst->data.dpdk_if.nic_name);
- if (0 != ret)
- {
- NSHAL_LOGERR ("set mlx linkup fail]nic_name=%s,ret=%d",
- inst->data.dpdk_if.nic_name, ret);
-
- return -1;
- }
- }
- else
- {
- /*For other drivers: NIC should be set link down before bind uio. */
- ret = dpdk_nonmlx_linkdown (inst->data.dpdk_if.nic_name);
- if (-1 == ret)
- {
- NSHAL_LOGERR ("dpdk_nonmlx_linkdown fail]nic_name=%s",
- inst->data.dpdk_if.nic_name);
- return -1;
- }
-
- /* save binded VF list to file /var/run/ip_module/.nstack_dpdk_nic_list */
- ret = hal_snprintf (script_cmmd, sizeof (script_cmmd),
- "sudo %s"
- "/dpdk-devbind.py -s | grep `ethtool -i %s| grep bus-info |awk '{print $2}'` >> %s 2>&1",
- dpdk_tool_path, inst->data.dpdk_if.nic_name,
- dpdk_get_nic_list_file ());
-
- if (-1 == ret)
- {
- NSHAL_LOGERR ("hal_snprintf fail]nic_name=%s",
- inst->data.dpdk_if.nic_name);
- return -1;
- }
-
- ret_len =
- hal_run_script (script_cmmd, result_buf, sizeof (result_buf) - 1);
- NSHAL_LOGINF ("bind]script_cmmd=%s,ret_len=%d", script_cmmd, ret_len);
- if (0 > ret_len)
- {
- NSHAL_LOGERR ("hal_run_script fail]script_cmmd=%s", script_cmmd);
- return -1;
- }
-
- if (strncmp ("virtio", inst->data.dpdk_if.driver_name, (size_t) 6) == 0)
- {
- /* For Virtio NIC, should call "./devbind.sh ethX" to bind the VF */
- ret = hal_snprintf (script_cmmd, sizeof (script_cmmd),
- "sudo %s"
- "/dpdk-devbind.py --bind=igb_uio `ethtool -i %s| grep bus-info |awk '{print $2}'`",
- dpdk_tool_path, inst->data.dpdk_if.nic_name);
- //"sudo %s" "/devbind.sh " "%s", dpdk_tool_path, inst->data.dpdk_if.nic_name);
-
- }
- else
- {
- ret = hal_snprintf (script_cmmd, sizeof (script_cmmd),
- "sudo %s" "/dpdk-devbind.py --bind=igb_uio "
- "%s", dpdk_tool_path,
- inst->data.dpdk_if.nic_name);
- }
-
- if (-1 == ret)
- {
- NSHAL_LOGERR ("hal_snprintf failed");
- return -1;
- }
-
- ret_len =
- hal_run_script (script_cmmd, result_buf, sizeof (result_buf) - 1);
- NSHAL_LOGINF ("bind]script_cmmd=%s,retlen=%d", script_cmmd, ret_len);
- if (0 > ret_len)
- {
- NSHAL_LOGERR ("hal_run_script fail]script_cmmd=%s", script_cmmd);
- return -1;
- }
-
- if (dpdk_non_root_user && getuid ())
- {
- ret = dpdk_set_uio_permission (inst->data.dpdk_if.pci_addr);
-
- if (ret < 0)
- {
- NSHAL_LOGERR ("set_uio_permission fail]nic_name=%s",
- inst->data.dpdk_if.nic_name);
- return -1;
- }
- }
- }
-
- return 0;
-}
-
-/*****************************************************************************
- Prototype : dpdk_probe_pci
- Description : probe pci
- Input : netif_inst_t* inst
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC int
-dpdk_probe_pci (netif_inst_t * inst)
-{
- int ret;
- uint16_t port_id;
- struct rte_eth_dev *eth_dev;
- char *pci_addr = inst->data.dpdk_if.pci_addr;
-
- ret = rte_eal_iopl_init ();
- if (0 != ret)
- {
- NSHAL_LOGERR ("rte_eal_iopl_init fail]pci_addr=%s,ret=%d", pci_addr,
- ret);
- return -1;
- }
-
- ret = rte_eth_dev_attach (pci_addr, &port_id);
- if (0 != ret)
- {
- NSHAL_LOGWAR
- ("pci attach to DPDK fail, the pci may have attached, try to get port id]pci_addr=%s,ret=%d",
- pci_addr, ret);
-
- eth_dev = rte_eth_dev_allocated (inst->data.dpdk_if.nic_name);
- if (NULL != eth_dev && NULL != eth_dev->data)
- {
- port_id = eth_dev->data->port_id;
- ret = 0;
- }
- }
-
- if (!ret)
- {
- ret = dpdk_set_port (inst, port_id);
-
- if (0 == ret)
- {
- NSHAL_LOGINF ("set port success]pci_addr=%s,port_id=%u", pci_addr,
- port_id);
- }
- else
- {
- NSHAL_LOGERR ("set port fail]pci_addr=%s,port_id=%u", pci_addr,
- port_id);
- return -1;
- }
- }
- else
- {
- NSHAL_LOGERR ("get port fail]pci_addr=%s,ret=%d", pci_addr, ret);
- return -1;
- }
-
- /*[TA33635][2017-04-24][l00408818] Start: support bond mode */
- ret = rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI, pci_addr);
- if (!ret)
- {
- NSHAL_LOGINF ("pci attach to whitelist success]pci_addr=%s", pci_addr);
- }
- else
- {
- NSHAL_LOGERR ("pci attach to whitelist fail]pci_addr=%s", pci_addr);
- return -1;
- }
- /*[TA33635][2017-04-24][l00408818] End */
-
- return 0;
-}
-
-/*nic_name->driver_name->pci_addr->get port*/
-/*****************************************************************************
- Prototype : dpdk_open
- Description : open the port
- Input : netif_inst_t* inst
- const char* name
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC int
-dpdk_open (netif_inst_t * inst, const char *name, const char *type)
-{
- int ret;
-
- if ((inst == NULL) || (name == NULL) || (type == NULL))
- {
- NSHAL_LOGERR
- ("invaliad arguments]inst==NULL, nic_type==NULL or type==NULL");
- return -1;
- }
-
- ret = dpdk_set_nic_type (inst, type);
-
- if (0 != ret)
- {
- NSHAL_LOGERR ("dpdk_set_nic_type fail]nic_type=%s, ret=%d", type, ret);
- return -1;
- }
-
- ret = dpdk_set_nic_name (inst, name);
-
- if (0 != ret)
- {
- NSHAL_LOGERR ("dpdk_set_nic_name fail]nic_name=%s, ret=%d", name, ret);
- return -1;
- }
-
- if (!strncmp (type, "vhost", strlen ("vhost")))
- {
- /*for vhost-user device, the remaining steps is unnecessary, y0413485 */
- NSHAL_LOGERR ("initting vhost device]nic_name=%s type=%s", name, type);
- return 0;
- }
-
- ret = dpdk_get_driver_name (inst);
-
- if (0 != ret)
- {
- NSHAL_LOGERR ("dpdk_get_driver_name fail]nic_name=%s, ret=%d", name,
- ret);
- return -1;
- }
-
- ret = dpdk_get_pci_addr (inst);
-
- if (0 != ret)
- {
- NSHAL_LOGERR ("dpdk_get_pci_addr fail]nic_name=%s, ret=%d", name, ret);
- return -1;
- }
-
- ret = dpdk_bind_uio (inst);
-
- if (0 != ret)
- {
- NSHAL_LOGERR ("dpdk_bind_uio fail]nic_name=%s, ret=%d", name, ret);
- return -1;
- }
-
- ret = dpdk_probe_pci (inst);
-
- if (0 != ret)
- {
- NSHAL_LOGERR ("dpdk_probe_pci fail]nic_name=%s, ret=%d", name, ret);
- return -1;
- }
-
- NSHAL_LOGINF ("open port succ]port_id=%u, nic_name=%s",
- inst->data.dpdk_if.port_id, inst->data.dpdk_if.nic_name);
-
- return 0;
-}
-
-/*****************************************************************************
- Prototype : dpdk_close
- Description : close the port
- Input : netif_inst_t* inst
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC int
-dpdk_close (netif_inst_t * inst)
-{
- int i;
-
- /* close slave NIC first */
- for (i = 0; i < inst->data.dpdk_if.slave_num; i++)
- {
- rte_eth_dev_close (inst->data.dpdk_if.slave_port[i]);
- NSHAL_LOGINF ("close slave port succ]port_id=%u, nic_name=%s",
- inst->data.dpdk_if.slave_port[i],
- inst->data.dpdk_if.nic_name);
- }
-
- rte_eth_dev_close (inst->data.dpdk_if.port_id);
- NSHAL_LOGINF ("close port succ]port_id=%u, nic_name=%s",
- inst->data.dpdk_if.port_id, inst->data.dpdk_if.nic_name);
- return 0;
-}
-
-/*****************************************************************************
- Prototype : dpdk_get_queue_conf
- Description : get the port queue configure
- Input : netif_inst_t* inst
- struct rte_eth_rxconf** rx_conf
- struct rte_eth_txconf** tx_conf
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC int
-dpdk_get_queue_conf (netif_inst_t * inst,
- struct rte_eth_rxconf **rx_conf,
- struct rte_eth_txconf **tx_conf)
-{
- static struct rte_eth_dev_info slave_dev_info;
-
- if (strncmp ("igb", inst->data.dpdk_if.driver_name, (size_t) 3) == 0)
- {
- *rx_conf = (struct rte_eth_rxconf *) &rx_conf_default_igb;
- *tx_conf = (struct rte_eth_txconf *) &tx_conf_default_igb;
- NSHAL_LOGINF ("igb config is enable]port_id=%u",
- inst->data.dpdk_if.port_id);
- }
- else if (strncmp ("ixgbe", inst->data.dpdk_if.driver_name, (size_t) 5) == 0)
- {
- *rx_conf = (struct rte_eth_rxconf *) &rx_conf_default_ixgbe;
- *tx_conf = (struct rte_eth_txconf *) &tx_conf_default_ixgbe;
- NSHAL_LOGINF ("igxbe config is enable]port_id=%u",
- inst->data.dpdk_if.port_id);
- }
- else if (strncmp ("bond", inst->data.dpdk_if.driver_name, (size_t) 4) == 0)
- {
- *rx_conf = NULL;
- rte_eth_dev_info_get (inst->data.dpdk_if.slave_port[0],
- &slave_dev_info);
- *tx_conf = &(slave_dev_info.default_txconf);
- NSHAL_LOGINF ("bond config is enable]port_id=%u",
- inst->data.dpdk_if.port_id);
- }
- else
- {
- *rx_conf = NULL;
- *tx_conf = NULL;
- NSHAL_LOGINF ("default config is enable]port_id=%u",
- inst->data.dpdk_if.port_id);
- }
- return 0;
-}
-
-/*****************************************************************************
- Prototype : dpdk_get_port_conf
- Description : get the port configure
- Input : netif_inst_t* inst
- struct rte_eth_conf** port_conf
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC void
-dpdk_get_port_conf (netif_inst_t * inst, struct rte_eth_conf **port_conf)
-{
- if (strncmp ("virtio", inst->data.dpdk_if.driver_name, (size_t) 6) == 0)
- {
- *port_conf = &port_conf_default_virtio;
- }
- else if (strncmp ("bond", inst->data.dpdk_if.driver_name, (size_t) 4) == 0)
- {
- *port_conf = &port_conf_default_bond;
- }
- else if (strncmp ("vhost", inst->data.dpdk_if.nic_type, (size_t) 5) == 0)
- {
- *port_conf = &port_conf_default_vhost;
- return;
- }
- else
- {
- *port_conf = &port_conf_default_normal;
- }
-
- (*port_conf)->rxmode.hw_vlan_filter = inst->data.dpdk_if.hw_vlan_filter;
- (*port_conf)->rxmode.hw_vlan_strip = inst->data.dpdk_if.hw_vlan_strip;
-}
-
-/*****************************************************************************
- Prototype : dpdk_setup_port
- Description : setup the port
- Input : netif_inst_t* inst
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC int
-dpdk_setup_port (netif_inst_t * inst)
-{
- int ret;
- uint32_t i;
- struct rte_eth_conf *port_conf;
- struct rte_eth_rxconf *rx_conf;
- struct rte_eth_txconf *tx_conf;
-
- uint8_t port_id = inst->data.dpdk_if.port_id;
- struct rte_mempool **mp =
- (struct rte_mempool **) inst->data.dpdk_if.rx_pool;
- uint32_t *rx_ring_size = inst->data.dpdk_if.rx_ring_size;
- uint32_t *tx_ring_size = inst->data.dpdk_if.tx_ring_size;
- uint32_t rx_queue_num = inst->data.dpdk_if.rx_queue_num;
- uint32_t tx_queue_num = inst->data.dpdk_if.tx_queue_num;
-
- dpdk_get_port_conf (inst, &port_conf);
-
- ret =
- rte_eth_dev_configure (port_id, rx_queue_num, tx_queue_num, port_conf);
- if (ret < 0)
- {
- NSHAL_LOGERR ("rte_eth_dev_configure]port_id=%u,ret=%d", port_id, ret);
- return ret;
- }
-
- if (dpdk_get_queue_conf (inst, &rx_conf, &tx_conf) < 0)
- {
- NSHAL_LOGERR ("dpdk_get_queue_conf failed]inst=%p,rx_conf=%p", inst,
- rx_conf);
- return -1;
- }
- /* fix "FORTIFY.Out-of-Bounds_Read" type codedex issue CID 33436 */
- if (rx_queue_num > HAL_ETH_MAX_QUEUE_NUM
- || tx_queue_num > HAL_ETH_MAX_QUEUE_NUM)
- {
- NSHAL_LOGERR
- ("queue num error]rx_queue_num=%u, tx_queue_num=%u, HAL_ETH_MAX_QUEUE_NUM=%d",
- rx_queue_num, tx_queue_num, HAL_ETH_MAX_QUEUE_NUM);
-
- return -1;
- }
-
- for (i = 0; i < rx_queue_num; i++)
- {
- ret =
- rte_eth_rx_queue_setup (port_id, i, rx_ring_size[i], SOCKET_ID_ANY,
- rx_conf, mp[i]);
- if (ret < 0)
- {
- NSHAL_LOGERR ("rx queue setup fail]index=%u,port_id=%u,ret=%d", i,
- port_id, ret);
- return ret;
- }
- }
-
- for (i = 0; i < tx_queue_num; i++)
- {
- ret =
- rte_eth_tx_queue_setup (port_id, i, tx_ring_size[i], SOCKET_ID_ANY,
- tx_conf);
-
- if (ret < 0)
- {
- NSHAL_LOGERR ("tx queue setup fail]q=%u,ret=%d", i, ret);
- return ret;
- }
- }
-
- rte_eth_promiscuous_enable (port_id);
-
- return 0;
-}
-
-/*****************************************************************************
- Prototype : dpdk_start
- Description : start the port
- Input : netif_inst_t* inst
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC int
-dpdk_start (netif_inst_t * inst)
-{
- int ret;
- struct ether_addr eth_addr;
-
- ret = dpdk_setup_port (inst);
-
- if (ret < 0)
- {
- NSHAL_LOGERR ("call dpdk_setup_port fail]ret=%d", ret);
- return ret;
- }
-
- ret = rte_eth_dev_start (inst->data.dpdk_if.port_id);
- if (ret < 0)
- {
- NSHAL_LOGERR ("rte_eth_dev_start fail]ret=%d", ret);
- return ret;
- }
-
- rte_eth_macaddr_get (inst->data.dpdk_if.port_id, &eth_addr);
- NSHAL_LOGINF ("port_id=%u,nic_name=%s,mac=%02X:%02X:%02X:%02X:%02X:%02X",
- inst->data.dpdk_if.port_id,
- inst->data.dpdk_if.nic_name,
- eth_addr.addr_bytes[0],
- eth_addr.addr_bytes[1],
- eth_addr.addr_bytes[2],
- eth_addr.addr_bytes[3],
- eth_addr.addr_bytes[4], eth_addr.addr_bytes[5]);
-
- return 0;
-}
-
-/*****************************************************************************
- Prototype : dpdk_stop
- Description : stop the port
- Input : netif_inst_t* inst
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC int
-dpdk_stop (netif_inst_t * inst)
-{
- int i;
-
- /* stop slave NIC first */
- for (i = 0; i < inst->data.dpdk_if.slave_num; i++)
- {
- rte_eth_dev_stop (inst->data.dpdk_if.slave_port[i]);
- NSHAL_LOGINF ("stop slave port succ]port_id=%u, nic_name=%s",
- inst->data.dpdk_if.slave_port[i],
- inst->data.dpdk_if.nic_name);
- }
- rte_eth_dev_stop (inst->data.dpdk_if.port_id);
-
- NSHAL_LOGINF ("stop port succ]port_id=%u, nic_name=%s",
- inst->data.dpdk_if.port_id, inst->data.dpdk_if.nic_name);
- return 0;
-}
-
-/*****************************************************************************
- Prototype : dpdk_get_mtu
- Description : get the port mtu
- Input : netif_inst_t* inst
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC uint32_t
-dpdk_get_mtu (netif_inst_t * inst)
-{
- uint32_t mtu;
-
- if (rte_eth_dev_get_mtu (inst->data.dpdk_if.port_id, (uint16_t *) & mtu))
- {
- return 0;
- }
-
- return mtu;
-}
-
-/*****************************************************************************
- Prototype : dpdk_get_macaddr
- Description : get the port mac addr
- Input : netif_inst_t* inst
- void* mac_addr
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC int
-dpdk_get_macaddr (netif_inst_t * inst, void *mac_addr)
-{
- /*bond port */
- int primary_port = rte_eth_bond_primary_get (inst->data.dpdk_if.port_id);
- if (0 <= primary_port)
- {
- rte_eth_macaddr_get ((uint8_t) primary_port,
- (struct ether_addr *) mac_addr);
-
- NSHAL_LOGDBG
- ("primary_port_id=%u,nic_name=%s,mac=%02X:%02X:%02X:%02X:%02X:%02X",
- primary_port, inst->data.dpdk_if.nic_name,
- ((struct ether_addr *) mac_addr)->addr_bytes[0],
- ((struct ether_addr *) mac_addr)->addr_bytes[1],
- ((struct ether_addr *) mac_addr)->addr_bytes[2],
- ((struct ether_addr *) mac_addr)->addr_bytes[3],
- ((struct ether_addr *) mac_addr)->addr_bytes[4],
- ((struct ether_addr *) mac_addr)->addr_bytes[5]);
- }
- /*normal port */
- else
- {
- rte_eth_macaddr_get (inst->data.dpdk_if.port_id,
- (struct ether_addr *) mac_addr);
-
- NSHAL_LOGDBG
- ("normal_port_id=%u,nic_name=%s,mac=%02X:%02X:%02X:%02X:%02X:%02X",
- inst->data.dpdk_if.port_id, inst->data.dpdk_if.nic_name,
- ((struct ether_addr *) mac_addr)->addr_bytes[0],
- ((struct ether_addr *) mac_addr)->addr_bytes[1],
- ((struct ether_addr *) mac_addr)->addr_bytes[2],
- ((struct ether_addr *) mac_addr)->addr_bytes[3],
- ((struct ether_addr *) mac_addr)->addr_bytes[4],
- ((struct ether_addr *) mac_addr)->addr_bytes[5]);
- }
-
- return 0;
-}
-
-/*****************************************************************************
- Prototype : dpdk_capa_convert
- Description : convert format from dpdk to hal
- Input : const struct rte_eth_dev_info* dev_info
- hal_netif_capa_t* capa
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC inline void
-dpdk_capa_convert (const struct rte_eth_dev_info *dev_info,
- hal_netif_capa_t * capa)
-{
- int retVal =
- MEMSET_S (capa, sizeof (hal_netif_capa_t), 0, sizeof (hal_netif_capa_t));
- if (EOK != retVal)
- {
- NSHAL_LOGERR ("MEMSET_S fail]retVal=%d", retVal);
- }
-
- capa->tx_offload_capa = dev_info->tx_offload_capa;
-}
-
-/*****************************************************************************
- Prototype : dpdk_get_capability
- Description : get the port capability
- Input : netif_inst_t* inst
- hal_netif_capa_t* capa
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC int
-dpdk_get_capability (netif_inst_t * inst, hal_netif_capa_t * capa)
-{
- struct rte_eth_dev_info dev_info;
-
- rte_eth_dev_info_get (inst->data.dpdk_if.port_id, &dev_info);
- dpdk_capa_convert (&dev_info, capa);
- return 0;
-}
-
-/*****************************************************************************
- Prototype : dpdk_recv
- Description : recv packet from the port
- Input : netif_inst_t* inst
- uint16_t queue_id
- struct common_mem_mbuf** rx_pkts
- uint16_t nb_pkts
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC uint16_t
-dpdk_recv (netif_inst_t * inst, uint16_t queue_id,
- hal_mbuf_t ** rx_pkts, uint16_t nb_pkts)
-{
- return hal_rte_eth_rx_burst (inst->data.dpdk_if.port_id, queue_id,
- (struct rte_mbuf **) rx_pkts, nb_pkts);
-}
-
-/*****************************************************************************
- Prototype : dpdk_send
- Description : send packet to the port
- Input : netif_inst_t* inst
- uint16_t queue_id
- struct common_mem_mbuf** tx_pkts
- uint16_t nb_pkts
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC uint16_t
-dpdk_send (netif_inst_t * inst, uint16_t queue_id,
- hal_mbuf_t ** tx_pkts, uint16_t nb_pkts)
-{
- return hal_rte_eth_tx_burst (inst->data.dpdk_if.port_id, queue_id,
- (struct rte_mbuf **) tx_pkts, nb_pkts);
-}
-
-/*****************************************************************************
- Prototype : dpdk_link_status
- Description : get link status form the port
- Input : netif_inst_t* inst
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC uint32_t
-dpdk_link_status (netif_inst_t * inst)
-{
- struct rte_eth_link eth_link;
-
- /* add log output when failed */
- int retVal = MEMSET_S (&eth_link, sizeof (struct rte_eth_link), 0,
- sizeof (struct rte_eth_link));
- if (EOK != retVal)
- {
- NSHAL_LOGERR ("MEMSET_S fail]retVal=%d", retVal);
- }
-
- rte_eth_link_get (inst->data.dpdk_if.port_id, &eth_link);
-
- return eth_link.link_status;
-}
-
-/*****************************************************************************
- Prototype : dpdk_stats_convert
- Description : convert format from dpdk to hal
- Input : const struct rte_eth_stats* rte_stats
- hal_netif_stats_t* stats
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC inline void
-dpdk_stats_convert (const struct rte_eth_stats *rte_stats,
- hal_netif_stats_t * stats)
-{
- int i;
-
- /* give fail error number when failed */
- int retVal = MEMSET_S (stats, sizeof (hal_netif_stats_t), 0,
- sizeof (hal_netif_stats_t));
- if (EOK != retVal)
- {
- NSHAL_LOGERR ("MEMSET_S fail]retVal=%d", retVal);
- }
-
- stats->ipackets = rte_stats->ipackets;
- stats->opackets = rte_stats->opackets;
- stats->ibytes = rte_stats->ibytes;
- stats->obytes = rte_stats->obytes;
- stats->imissed = rte_stats->imissed;
- stats->ierrors = rte_stats->ierrors;
- stats->oerrors = rte_stats->oerrors;
- stats->rx_nombuf = rte_stats->rx_nombuf;
-
- for (i = 0; i < HAL_ETH_QUEUE_STAT_CNTRS; i++)
- {
- stats->q_ipackets[i] = rte_stats->q_ipackets[i];
- stats->q_opackets[i] = rte_stats->q_opackets[i];
- stats->q_ibytes[i] = rte_stats->q_ibytes[i];
- stats->q_obytes[i] = rte_stats->q_obytes[i];
- stats->q_errors[i] = rte_stats->q_errors[i];
- }
-}
-
-/*****************************************************************************
- Prototype : dpdk_stats
- Description : get stats form the port
- Input : netif_inst_t* inst
- hal_netif_stats_t* stats
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC int
-dpdk_stats (netif_inst_t * inst, hal_netif_stats_t * stats)
-{
- int ret;
- struct rte_eth_stats rte_stats;
-
- ret = rte_eth_stats_get (inst->data.dpdk_if.port_id, &rte_stats);
- if (ret == 0)
- {
- dpdk_stats_convert (&rte_stats, stats);
- return 0;
- }
-
- return -1;
-}
-
-/*****************************************************************************
- Prototype : dpdk_stats_reset
- Description : reset stats to the port
- Input : netif_inst_t* inst
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC int
-dpdk_stats_reset (netif_inst_t * inst)
-{
- rte_eth_stats_reset (inst->data.dpdk_if.port_id);
- return 0;
-}
-
-/*****************************************************************************
- Prototype : dpdk_config
- Description : config the port queue and ring
- Input : netif_inst_t* inst
- hal_netif_config_t* conf
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC int
-dpdk_config (netif_inst_t * inst, hal_netif_config_t * conf)
-{
- uint32_t i;
-
- inst->data.dpdk_if.hw_vlan_filter = conf->bit.hw_vlan_filter;
- inst->data.dpdk_if.hw_vlan_strip = conf->bit.hw_vlan_strip;
-
- inst->data.dpdk_if.rx_queue_num = conf->rx.queue_num;
- /* fix Buffer Overflow type code-dex issue */
- if (inst->data.dpdk_if.rx_queue_num > HAL_ETH_MAX_QUEUE_NUM)
- {
- NSHAL_LOGERR
- ("rx queue num error]rx_queue_num=%u, HAL_ETH_MAX_QUEUE_NUM=%d",
- inst->data.dpdk_if.rx_queue_num, HAL_ETH_MAX_QUEUE_NUM);
-
- return -1;
- }
-
- for (i = 0; i < inst->data.dpdk_if.rx_queue_num; i++)
- {
- inst->data.dpdk_if.rx_ring_size[i] = conf->rx.ring_size[i];
- inst->data.dpdk_if.rx_pool[i] =
- (struct rte_mempool *) conf->rx.ring_pool[i];
- }
-
- inst->data.dpdk_if.tx_queue_num = conf->tx.queue_num;
- /* fix "FORTIFY.Out-of-Bounds_Read--Off-by-One" type codedex issue */
- if (inst->data.dpdk_if.tx_queue_num > HAL_ETH_MAX_QUEUE_NUM)
- {
- NSHAL_LOGERR
- ("tx queue num error]rx_queue_num=%u, HAL_ETH_MAX_QUEUE_NUM=%d",
- inst->data.dpdk_if.tx_queue_num, HAL_ETH_MAX_QUEUE_NUM);
-
- return -1;
- }
- for (i = 0; i < inst->data.dpdk_if.tx_queue_num; i++)
- {
- inst->data.dpdk_if.tx_ring_size[i] = conf->tx.ring_size[i];
- }
-
- return 0;
-}
-
-/*****************************************************************************
- Prototype : dpdk_bond_config
- Description : config the port for bond mode
- Input : netif_inst_t* inst
- uint8_t slave_num
- netif_inst_t* slave_inst[]
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC int
-dpdk_bond_config (netif_inst_t * inst, uint8_t slave_num,
- netif_inst_t * slave_inst[])
-{
- int ret;
- uint32_t i, queue;
-
- inst->data.dpdk_if.slave_num = slave_num;
-
- for (i = 0; i < slave_num; i++)
- {
- inst->data.dpdk_if.slave_port[i] = slave_inst[i]->data.dpdk_if.port_id;
-
- if (0 == i)
- {
- inst->data.dpdk_if.hw_vlan_filter =
- slave_inst[i]->data.dpdk_if.hw_vlan_filter;
- inst->data.dpdk_if.hw_vlan_strip =
- slave_inst[i]->data.dpdk_if.hw_vlan_strip;
- inst->data.dpdk_if.rx_queue_num =
- slave_inst[i]->data.dpdk_if.rx_queue_num;
- inst->data.dpdk_if.tx_queue_num =
- slave_inst[i]->data.dpdk_if.tx_queue_num;
-
- /*will be used in function dpdk_get_queue_conf and dpdk_get_port_conf */
- ret =
- STRCPY_S (inst->data.dpdk_if.driver_name,
- sizeof (inst->data.dpdk_if.driver_name), "bond");
-
- if (EOK != ret)
- {
- NSHAL_LOGERR ("STRCPY_S failed]ret=%d.", ret);
- return -1;
- }
-
- for (queue = 0; queue < HAL_ETH_MAX_QUEUE_NUM; queue++)
- {
- inst->data.dpdk_if.rx_pool[queue] =
- slave_inst[i]->data.dpdk_if.rx_pool[queue];
- inst->data.dpdk_if.rx_ring_size[queue] =
- slave_inst[i]->data.dpdk_if.rx_ring_size[queue];
- inst->data.dpdk_if.tx_ring_size[queue] =
- slave_inst[i]->data.dpdk_if.tx_ring_size[queue];
- }
- }
- }
-
- return 0;
-
-}
-
-/*****************************************************************************
- Prototype : dpdk_bond
- Description : bond port
- Input : netif_inst_t* inst
- const char* bond_name
- uint8_t slave_num
- netif_inst_t* slave_inst[]
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC int
-dpdk_bond (netif_inst_t * inst, const char *bond_name, uint8_t slave_num,
- netif_inst_t * slave_inst[])
-{
- int i, ret;
- int port;
- struct ether_addr eth_addr;
-
- /* check if all the slaves' drivers are same, not support different drivers */
- for (i = 1; i < slave_num; i++)
- {
- if (strncmp
- (slave_inst[0]->data.dpdk_if.driver_name,
- slave_inst[i]->data.dpdk_if.driver_name,
- strlen (slave_inst[0]->data.dpdk_if.driver_name)))
- {
- NSHAL_LOGERR
- ("dpdk does not support different types of network card]slave[0]=%s, slave[%i]=%s",
- slave_inst[0]->data.dpdk_if.driver_name, i,
- slave_inst[i]->data.dpdk_if.driver_name);
- return -1;
- }
- }
-
- ret = dpdk_set_nic_name (inst, bond_name);
-
- if (0 != ret)
- {
- NSHAL_LOGERR ("dpdk_set_nic_name fail]ret=%d", ret);
- return -1;
- }
-
- port =
- rte_eth_bond_create (bond_name, BONDING_MODE_ACTIVE_BACKUP, SOCKET_ID_0);
- if (port < 0)
- {
- NSHAL_LOGERR ("rte_eth_bond_create fail]ret=%i", ret);
- return -1;
- }
-
- ret = dpdk_set_port (inst, (uint8_t) port);
-
- if (ret < 0)
- {
- NSHAL_LOGERR ("dpdk_set_port fail]ret=%i", ret);
- return ret;
- }
-
- ret = dpdk_bond_config (inst, slave_num, slave_inst);
-
- if (ret < 0)
- {
- NSHAL_LOGERR ("dpdk_bond_config fail]ret=%i", ret);
- return ret;
- }
-
- ret = dpdk_setup_port (inst);
-
- if (ret < 0)
- {
- NSHAL_LOGERR ("dpdk_setup_port fail]ret=%i", ret);
- return ret;
- }
-
- for (i = 0; i < slave_num; i++)
- {
- NSHAL_LOGINF ("add slave port_id=%u, nic_name=%s",
- slave_inst[i]->data.dpdk_if.port_id,
- slave_inst[i]->data.dpdk_if.nic_name);
-
- if (rte_eth_bond_slave_add
- ((uint8_t) port, slave_inst[i]->data.dpdk_if.port_id) == -1)
- {
- NSHAL_LOGERR ("adding slave (%u) to bond (%u) failed]",
- slave_inst[i]->data.dpdk_if.port_id, port);
- return -1;
- }
- }
-
- rte_eth_macaddr_get (slave_inst[0]->data.dpdk_if.port_id, &eth_addr);
-
- ret = rte_eth_bond_mac_address_set ((uint8_t) port, &eth_addr);
- if (ret < 0)
- {
- NSHAL_LOGERR ("rte_eth_bond_mac_address_set fail]ret=%i", ret);
- return ret;
- }
-
- ret = rte_eth_dev_start (inst->data.dpdk_if.port_id);
- if (ret < 0)
- {
- NSHAL_LOGERR ("rte_eth_dev_start fail]ret=%i, port_id=%d", ret,
- inst->data.dpdk_if.port_id);
- return ret;
- }
-
- NSHAL_LOGINF ("port_id=%d,nic_name=%s,mac=%02X:%02X:%02X:%02X:%02X:%02X",
- port,
- inst->data.dpdk_if.nic_name,
- eth_addr.addr_bytes[0],
- eth_addr.addr_bytes[1],
- eth_addr.addr_bytes[2],
- eth_addr.addr_bytes[3],
- eth_addr.addr_bytes[4], eth_addr.addr_bytes[5]);
- return 0;
-}
-
-/*****************************************************************************
- Prototype : dpdk_add_mcastaddr
- Description : add mcastaddr to the port
- Input : netif_inst_t* inst
- void* mc_addr_set
- void* mc_addr
- uint32_t nb_mc_addr
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC int
-dpdk_set_mcastaddr (netif_inst_t * inst, void *mc_addr_set,
- void *mc_addr, uint32_t nb_mc_addr)
-{
- uint8_t port = inst->data.dpdk_if.port_id;
- int iRetVal;
-
- NSHAL_LOGINF ("mc_addr_set number=%u", nb_mc_addr);
- iRetVal = rte_eth_dev_set_mc_addr_list (port, mc_addr_set, nb_mc_addr);
- if (iRetVal != 0)
- {
- NSHAL_LOGWAR ("fail to set_mc_addr_list]port=%u,ret=%d", port, iRetVal);
- }
-
- return iRetVal;
-}
-
-/*****************************************************************************
- Prototype : dpdk_add_mac_addr
- Description : add mcastaddr to the port
- Input : netif_inst_t* inst
- void* mc_addr
- Output : None
- Return Value : NSTACK_STATIC int
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC int
-dpdk_add_mac_addr (netif_inst_t * inst, void *mc_addr)
-{
- uint8_t port = inst->data.dpdk_if.port_id;
- int iRetVal;
-
- /* for MLX: set_mc_addr_list() is not callback, so call mac_addr_add() instead */
- iRetVal = rte_eth_dev_mac_addr_add (port, mc_addr, 0);
- if (0 != iRetVal)
- {
- NSHAL_LOGWAR ("fail to add_mac_addr]port=%u,ret=%d", port, iRetVal);
- }
-
- return iRetVal;
-}
-
-/*****************************************************************************
- Prototype : dpdk_rmv_mac_addr
- Description : remove mcastaddr to the port
- Input : netif_inst_t* inst
- void* mc_addr
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC int
-dpdk_rmv_mac_addr (netif_inst_t * inst, void *mc_addr)
-{
- uint8_t port = inst->data.dpdk_if.port_id;
- int iRetVal;
-
- /* for MLX: set_mc_addr_list() is not callback, so call mac_addr_remove() instead */
- iRetVal = rte_eth_dev_mac_addr_remove (port, mc_addr);
- if (0 != iRetVal)
- {
- NSHAL_LOGWAR ("fail to rmv_mac_addr]port=%u,ret=%d", port, iRetVal);
- }
-
- return iRetVal;
-}
-
-/*****************************************************************************
- Prototype : dpdk_allmcast
- Description : set allmcast mode to the port
- Input : netif_inst_t* inst
- uint8_t enable
- Output : None
- Return Value : NSTACK_STATIC
- Calls :
- Called By :
-
-*****************************************************************************/
-NSTACK_STATIC int
-dpdk_allmcast (netif_inst_t * inst, uint8_t enable)
-{
- if (enable)
- {
- rte_eth_allmulticast_enable (inst->data.dpdk_if.port_id);
- }
- else
- {
- rte_eth_allmulticast_disable (inst->data.dpdk_if.port_id);
- }
-
- return 0;
-}
-
-const netif_ops_t dpdk_netif_ops = {
- .name = "dpdk",
- .init_global = dpdk_init_global,
- .init_local = dpdk_init_local,
- .open = dpdk_open,
- .close = dpdk_close,
- .start = dpdk_start,
- .stop = dpdk_stop,
- .bond = dpdk_bond,
- .mtu = dpdk_get_mtu,
- .macaddr = dpdk_get_macaddr,
- .capability = dpdk_get_capability,
- .recv = dpdk_recv,
- .send = dpdk_send,
- .link_status = dpdk_link_status,
- .stats = dpdk_stats,
- .stats_reset = dpdk_stats_reset,
- .config = dpdk_config,
- .mcastaddr = dpdk_set_mcastaddr,
- .add_mac = dpdk_add_mac_addr,
- .rmv_mac = dpdk_rmv_mac_addr,
- .allmcast = dpdk_allmcast
-};
-
-HAL_IO_REGISTER (dpdk, &dpdk_netif_ops);
diff --git a/stacks/lwip_stack/src/maintain/CMakeLists.txt b/stacks/lwip_stack/src/maintain/CMakeLists.txt
deleted file mode 100644
index 05c5117..0000000
--- a/stacks/lwip_stack/src/maintain/CMakeLists.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-#########################################################################
-#
-# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-# 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.
-#########################################################################
-
-if(WITH_HAL_LIB)
-else()
- SET(PAL_H_DIRECTORIES "/usr/include/dpdk/")
- SET(PAL_BITWIDE_ADJUST ${PROJECT_SOURCE_DIR}/../../src/framework/common/base/include/common_pal_bitwide_adjust.h)
- ADD_DEFINITIONS(-include ${PAL_BITWIDE_ADJUST})
- INCLUDE_DIRECTORIES(
- ${PAL_H_DIRECTORIES}
- )
-endif()
-
-FILE(GLOB_RECURSE NSTACKMAINTAIN *.c)
-
-LINK_LIBRARIES(m dl rt dmm_api)
-if(WITH_SECUREC_LIB)
-INCLUDE_DIRECTORIES(
- ./
- ${JSON_C_SRC}
- ${SECUREC_SRC}
- ${CMAKE_CURRENT_LIST_DIR}/../include/
-)
-else()
-INCLUDE_DIRECTORIES(
- ./
- ${JSON_C_SRC}
- ${CMAKE_CURRENT_LIST_DIR}/../include/
-)
-endif()
-ADD_LIBRARY(nStackMaintain STATIC ${NSTACKMAINTAIN})
diff --git a/stacks/lwip_stack/src/maintain/fw_mt_config.c b/stacks/lwip_stack/src/maintain/fw_mt_config.c
deleted file mode 100644
index 403a46e..0000000
--- a/stacks/lwip_stack/src/maintain/fw_mt_config.c
+++ /dev/null
@@ -1,807 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-/*==============================================*
- * include header files *
- *----------------------------------------------*/
-
-#include "types.h"
-#include "nsfw_mt_config.h"
-#include <stdlib.h>
-#include <pthread.h>
-#include "nstack_log.h"
-#include "nstack_securec.h"
-#include "json.h"
-#include "nsfw_init.h"
-#include "nsfw_mgr_com_api.h"
-
-/*==============================================*
- * project-wide global variables *
- *----------------------------------------------*/
-
-// can be read from config file
-u32 g_base_cfg_items[MAX_BASE_CFG] = { 0 };
-
-// calculated according to base config
-u32 g_custom_cfg_items[MAX_CUSTOM_CFG] = { 0 };
-
-// note: if seg number greater than 16, such buffer should use malloc
-// or it will be exceed 2K
-struct cfg_item_info g_cfg_item_info[CFG_SEG_MAX][MAX_CFG_ITEM];
-
-NSTACK_STATIC int g_cfg_item_count[CFG_SEG_MAX] = { 0 };
-
-NSTACK_STATIC char *g_cfg_seg_name[CFG_SEG_MAX];
-
-/*==============================================*
- * routines' or functions' implementations *
- *----------------------------------------------*/
-
-/* nStackCtrl cannot get the env path info, no start by shell script, need get
- the path info ,and legal check , add a input parameter proc_type*/
-
-NSTACK_STATIC int
-get_ctrl_dir_info (char *current_path, unsigned path_len)
-{
- char ctrl_dir[MAX_FILE_NAME_LEN] = { 0 };
- int count = 0;
- unsigned int dir_len = 0;
-
- //nStackCtrl cannot get the path from the env, so need get from current pwd.
- count = readlink ("/proc/self/exe", ctrl_dir, MAX_FILE_NAME_LEN);
- if ((count < 0) || (count >= MAX_FILE_NAME_LEN))
- {
- save_pre_init_log (NSLOG_ERR,
- "readlink get nStackCtrl path failed, write nothing!");
- return -1;
- }
- ctrl_dir[count] = '\0';
-
- dir_len = strlen (ctrl_dir);
- if ((dir_len > strlen ("nStackCtrl")) && (dir_len < MAX_FILE_NAME_LEN))
- {
- ctrl_dir[dir_len - strlen ("nStackCtrl")] = '\0';
- }
- else
- {
- save_pre_init_log (NSLOG_ERR, "path strlen is illegal, write nothing!");
- return -1;
- }
-
- if (NULL == strstr (ctrl_dir, "bin"))
- {
- /* Exit before nstack_log_init, use printf */
- printf
- ("the nStackServer content change, plz keep same with nStack release, exit!\n");
-#ifdef FOR_NSTACK_UT
- return -1;
-#else
- exit (1);
-#endif
- }
- if (EOK !=
- STRNCAT_S (ctrl_dir, sizeof (ctrl_dir), "/../configure",
- strlen ("/../configure")))
- {
- save_pre_init_log (NSLOG_ERR, "STRNCAT_S failed, current_dir = %s",
- ctrl_dir);
- return -1;
- }
-
- if (-1 == SNPRINTF_S (current_path, path_len, path_len - 1, "%s", ctrl_dir))
- {
- save_pre_init_log (NSLOG_ERR,
- "SNPRINTF_S path name failed, ctrl_dir %s.",
- ctrl_dir);
- return -1;
- }
-
- return 0;
-
-}
-
-NSTACK_STATIC int
-get_cfg_buf (u32 proc_type, char *cfg_buf, unsigned buf_size)
-{
- char current_dir[MAX_FILE_NAME_LEN] = { 0 };
- char cfg_file_name[MAX_FILE_NAME_LEN] = { 0 };
- char *cfg_resolved_path = NULL;
- char *cfg_path = NULL;
- FILE *fp = NULL;
- int cfg_buf_len = 0;
-
- cfg_path = getenv (CFG_PATH);
- if ((NULL == cfg_path) && (NSFW_PROC_CTRL == proc_type))
- {
- if (-1 == get_ctrl_dir_info (current_dir, sizeof (current_dir)))
- {
- save_pre_init_log (NSLOG_ERR, "get_ctrl_dir_info failed.");
- return -1;
- }
- cfg_path = current_dir;
- }
- else if ((NULL == cfg_path) && (NSFW_PROC_CTRL != proc_type))
- {
- save_pre_init_log (NSLOG_ERR,
- "main or master process get nstack config path failed, will use default config!");
- return -1;
- }
-
- if (-1 ==
- SPRINTF_S (cfg_file_name, sizeof (cfg_file_name), "%s/%s", cfg_path,
- CFG_FILE_NAME))
- {
- save_pre_init_log (NSLOG_ERR,
- "format config file name failed, path %s, name %s.",
- cfg_path, CFG_FILE_NAME);
- return -1;
- }
-
- cfg_resolved_path = realpath (cfg_file_name, NULL);
- if (NULL == cfg_resolved_path)
- {
- save_pre_init_log (NSLOG_ERR, "config file path invalid, cfg name %s.",
- cfg_file_name);
- return -1;
- }
-
- fp = fopen (cfg_resolved_path, "r");
- if (NULL == fp)
- {
- free (cfg_resolved_path);
- save_pre_init_log (NSLOG_ERR, "config file path invalid, cfg name %s.",
- cfg_file_name);
- return -1;
- }
-
- free (cfg_resolved_path);
- // read config file to json buffer
- cfg_buf_len = fread (cfg_buf, 1, buf_size, fp);
-
- fclose (fp);
-
- return cfg_buf_len;
-}
-
-NSTACK_STATIC inline int
-get_value_from_json_obj (struct json_object *obj, struct cfg_item_info *pitem)
-{
- switch (pitem->type)
- {
- case CFG_ITEM_TYPE_INT:
- pitem->value = json_object_get_int (obj);
- break;
- case CFG_ITEM_TYPE_STRING:
- pitem->pvalue = (char *) json_object_get_string (obj);
- break;
- default:
- // print log here?
- return -1;
- }
- return 0;
-}
-
-NSTACK_STATIC inline void
-get_cfg_item (struct json_object *obj, int seg_index)
-{
- struct json_object *cfg_seg_obj = NULL;
- struct json_object *cfg_seg = NULL;
- struct json_object *cfg_item_obj[MAX_CFG_ITEM] = { 0 };
- int i = 0;
- int cfg_num = 0;
-
- (void) json_object_object_get_ex (obj, g_cfg_seg_name[seg_index],
- &cfg_seg_obj);
- if (NULL == cfg_seg_obj)
- {
- save_pre_init_log (NSLOG_ERR, "get config segment obj failed, seg:%s.",
- g_cfg_seg_name[seg_index]);
- return;
- }
-
- cfg_num = json_object_array_length (cfg_seg_obj);
- if (cfg_num < 1)
- {
- save_pre_init_log (NSLOG_ERR,
- "config segment count invalid, config segment %s, count %d.",
- g_cfg_seg_name[seg_index], cfg_num);
- return;
- }
-
- // each config segment just has 1 array element
- cfg_seg = (struct json_object *) json_object_array_get_idx (cfg_seg_obj, 0);
- if (NULL == cfg_seg)
- {
- save_pre_init_log (NSLOG_ERR, "no config item in seg %s.",
- g_cfg_seg_name[seg_index]);
- return;
- }
-
- for (; i < g_cfg_item_count[seg_index]; i++)
- {
- (void) json_object_object_get_ex (cfg_seg,
- g_cfg_item_info[seg_index][i].name,
- &cfg_item_obj[i]);
-
- if (NULL == cfg_item_obj[i])
- {
- save_pre_init_log (NSLOG_ERR,
- "get config item failed, config item %s.",
- g_cfg_item_info[seg_index][i].name);
- return;
- }
-
- // note: should specify the config item type if not only int item exist
- if (get_value_from_json_obj
- (cfg_item_obj[i], &g_cfg_item_info[seg_index][i]) != 0)
- {
- return;
- }
- }
-
- return;
-}
-
-NSTACK_STATIC inline void
-parse_cfg (char *cfg_buf)
-{
- if (NULL == cfg_buf)
- {
- return;
- }
-
- struct json_object *obj =
- (struct json_object *) json_tokener_parse (cfg_buf);
- int i = 0;
-
- for (; i < CFG_SEG_MAX; i++)
- {
- if (0 == g_cfg_item_count[i])
- {
- continue;
- }
-
- get_cfg_item (obj, i);
- }
-}
-
-NSTACK_STATIC inline int
-is_valid (int value, int min_value, int max_value)
-{
- if ((value < min_value) || (value > max_value))
- {
- return 0;
- }
-
- return 1;
-}
-
-NSTACK_STATIC inline void
-check_cfg_item_int (struct cfg_item_info *pitem)
-{
- if (!is_valid (pitem->value, pitem->min_value, pitem->max_value))
- {
- pitem->value = pitem->default_value;
- }
-}
-
-NSTACK_STATIC inline void
-check_cfg_item_string (struct cfg_item_info *pitem)
-{
- if ((NULL == pitem->pvalue) || ((pitem->pvalue) && (0 == pitem->pvalue[0])))
- {
- pitem->pvalue = pitem->default_str;
- }
-}
-
-NSTACK_STATIC inline void
-check_cfg_item (struct cfg_item_info *pitem)
-{
- switch (pitem->type)
- {
- case CFG_ITEM_TYPE_INT:
- check_cfg_item_int (pitem);
- if (pitem->custom_check)
- pitem->custom_check (pitem);
- break;
- case CFG_ITEM_TYPE_STRING:
- check_cfg_item_string (pitem);
- if (pitem->custom_check)
- pitem->custom_check (pitem);
- break;
- default:
- break;
- }
-}
-
-NSTACK_STATIC inline void
-check_cfg ()
-{
- int i = 0;
- int j = 0;
- for (i = 0; i < CFG_SEG_MAX; i++)
- {
- for (j = 0; j < g_cfg_item_count[i]; j++)
- {
- check_cfg_item (&g_cfg_item_info[i][j]);
- }
- }
-}
-
-NSTACK_STATIC inline void
-print_item_info (char *seg_name, struct cfg_item_info *pitem)
-{
- switch (pitem->type)
- {
- case CFG_ITEM_TYPE_INT:
- save_pre_init_log (NSLOG_INF, "config read seg:%s, name:%s, value:%d.",
- seg_name, pitem->name, pitem->value);
- break;
- case CFG_ITEM_TYPE_STRING:
- save_pre_init_log (NSLOG_INF, "config read seg:%s, name:%s, pvalue:%s.",
- seg_name, pitem->name, pitem->pvalue);
- break;
- default:
- break;
- }
-}
-
-NSTACK_STATIC inline void
-print_config_item_info ()
-{
- int i = 0;
- int j = 0;
- for (; i < CFG_SEG_MAX; i++)
- {
- for (j = 0; j < g_cfg_item_count[i]; j++)
- {
- print_item_info (g_cfg_seg_name[i], &g_cfg_item_info[i][j]);
- }
- }
-}
-
-void
-check_socket_config (void *pitem)
-{
- struct cfg_item_info *item = (struct cfg_item_info *) pitem;
- if (item->value > 0 && !(item->value & (item->value - 1)))
- return;
- save_pre_init_log (NSLOG_WAR,
- "warning: config socket_num (%u) is not 2^n, will use the default value:%u",
- item->value, item->default_value);
- item->value = item->default_value;
-}
-
-/* thread schedule mode and thread priority should be matched */
-void
-check_thread_config (void *pitem)
-{
- struct cfg_item_info *pri_cfg = (struct cfg_item_info *) pitem;
- struct cfg_item_info *policy_cfg =
- &g_cfg_item_info[CFG_SEG_PRI][CFG_SEG_THREAD_PRI_POLICY];
-
- int max_pri = sched_get_priority_max (policy_cfg->value);
- int min_pri = sched_get_priority_min (policy_cfg->value);
- if ((pri_cfg->value > max_pri) || (pri_cfg->value < min_pri))
- {
- save_pre_init_log (NSLOG_INF,
- "detect invalid thread priority configuration, use default value] policy=%d, pri=%d, def policy=%d, def pri=%d",
- policy_cfg->value, pri_cfg->value,
- policy_cfg->default_value, pri_cfg->default_value);
-
- policy_cfg->value = policy_cfg->default_value;
- pri_cfg->value = pri_cfg->default_value;
- }
-}
-
-#define SET_CFG_ITEM(seg, item, field, value) g_cfg_item_info[seg][item].field = (value)
-#define SET_THREAD_CFG_ITEM(item, field, value) SET_CFG_ITEM(CFG_SEG_PRI, item, field, value)
-
-NSTACK_STATIC void
-init_main_def_config_items ()
-{
- /* base config */
- g_cfg_seg_name[CFG_SEG_BASE] = "cfg_seg_socket";
- g_cfg_item_count[CFG_SEG_BASE] = CFG_SEG_BASE_MAX;
- /* -- socket number */
- g_cfg_item_info[CFG_SEG_BASE][CFG_SEG_BASE_SOCKET_NUM].name = "socket_num";
- g_cfg_item_info[CFG_SEG_BASE][CFG_SEG_BASE_SOCKET_NUM].type =
- CFG_ITEM_TYPE_INT;
- g_cfg_item_info[CFG_SEG_BASE][CFG_SEG_BASE_SOCKET_NUM].custom_check =
- check_socket_config;
- set_cfg_info (CFG_SEG_BASE, CFG_SEG_BASE_SOCKET_NUM, MIN_SOCKET_NUM,
- MAX_SOCKET_NUM, DEF_SOCKET_NUM);
- /* -- arp stale time */
- g_cfg_item_info[CFG_SEG_BASE][CFG_SEG_BASE_ARP_STALE_TIME].name =
- "arp_stale_time";
- g_cfg_item_info[CFG_SEG_BASE][CFG_SEG_BASE_ARP_STALE_TIME].type =
- CFG_ITEM_TYPE_INT;
- g_cfg_item_info[CFG_SEG_BASE][CFG_SEG_BASE_ARP_STALE_TIME].custom_check =
- NULL;
- set_cfg_info (CFG_SEG_BASE, CFG_SEG_BASE_ARP_STALE_TIME,
- MIN_ARP_STACLE_TIME, MAX_ARP_STACLE_TIME,
- DEF_ARP_STACLE_TIME);
- /* -- arp braodcast retransmission times */
- g_cfg_item_info[CFG_SEG_BASE][CFG_SEG_BASE_ARP_BC_RETRANS_NUM].name =
- "arp_bc_retrans_num";
- g_cfg_item_info[CFG_SEG_BASE][CFG_SEG_BASE_ARP_BC_RETRANS_NUM].type =
- CFG_ITEM_TYPE_INT;
- g_cfg_item_info[CFG_SEG_BASE][CFG_SEG_BASE_ARP_BC_RETRANS_NUM].custom_check
- = NULL;
- set_cfg_info (CFG_SEG_BASE, CFG_SEG_BASE_ARP_BC_RETRANS_NUM,
- MIN_ARP_BC_RETRANS_NUM, MAX_ARP_BC_RETRANS_NUM,
- DEF_ARP_BC_RETRANS_NUM);
-
- /* support thread priority configuration */
- g_cfg_seg_name[CFG_SEG_PRI] = "cfg_seg_thread_pri";
- g_cfg_item_count[CFG_SEG_PRI] = CFG_SEG_THREAD_PRI_MAX;
- SET_THREAD_CFG_ITEM (CFG_SEG_THREAD_PRI_POLICY, name, "sched_policy");
- SET_THREAD_CFG_ITEM (CFG_SEG_THREAD_PRI_POLICY, type, CFG_ITEM_TYPE_INT);
- SET_THREAD_CFG_ITEM (CFG_SEG_THREAD_PRI_POLICY, custom_check, NULL);
- set_cfg_info (CFG_SEG_PRI, CFG_SEG_THREAD_PRI_POLICY, 0, 2, 0);
-
- SET_THREAD_CFG_ITEM (CFG_SEG_THREAD_PRI_PRI, name, "thread_pri");
- SET_THREAD_CFG_ITEM (CFG_SEG_THREAD_PRI_PRI, type, CFG_ITEM_TYPE_INT);
- SET_THREAD_CFG_ITEM (CFG_SEG_THREAD_PRI_PRI, custom_check,
- check_thread_config);
- set_cfg_info (CFG_SEG_PRI, CFG_SEG_THREAD_PRI_PRI, 0, 99, 0);
-
- /* remove unsed operation config set */
- /* log config */
- g_cfg_seg_name[CFG_SEG_LOG] = "cfg_seg_log";
- g_cfg_item_count[CFG_SEG_LOG] = 2;
- g_cfg_item_info[CFG_SEG_LOG][0].name = "run_log_size";
- g_cfg_item_info[CFG_SEG_LOG][0].type = CFG_ITEM_TYPE_INT;
- g_cfg_item_info[CFG_SEG_LOG][0].custom_check = NULL;
- g_cfg_item_info[CFG_SEG_LOG][1].name = "run_log_count";
- g_cfg_item_info[CFG_SEG_LOG][1].type = CFG_ITEM_TYPE_INT;
- g_cfg_item_info[CFG_SEG_LOG][1].custom_check = NULL;
- set_cfg_info (CFG_SEG_LOG, 0, 10, 100, 50);
- set_cfg_info (CFG_SEG_LOG, 1, 2, 20, 10);
-
- /* path config */
- /* set the path string and default str */
- g_cfg_seg_name[CFG_SEG_PATH] = "cfg_seg_path";
- g_cfg_item_count[CFG_SEG_PATH] = 1;
- g_cfg_item_info[CFG_SEG_PATH][0].name = "stackx_log_path";
- g_cfg_item_info[CFG_SEG_PATH][0].type = CFG_ITEM_TYPE_STRING;
- g_cfg_item_info[CFG_SEG_PATH][0].default_str = NSTACK_LOG_NAME;
- g_cfg_item_info[CFG_SEG_PATH][0].custom_check = NULL;
-}
-
-/* master and ctrl both use the function to reduce the redundancy,
-* as the parameter and operation all same.
-*/
-NSTACK_STATIC void
-init_master_def_config_items ()
-{
- int i = 0;
- for (; i < CFG_SEG_MAX; i++)
- {
- if (i != CFG_SEG_LOG)
- {
- g_cfg_item_count[i] = 0;
- }
- }
-
- g_cfg_seg_name[CFG_SEG_LOG] = "cfg_seg_log";
- g_cfg_item_count[CFG_SEG_LOG] = 2;
- g_cfg_item_info[CFG_SEG_LOG][0].name = "mon_log_size";
- g_cfg_item_info[CFG_SEG_LOG][0].type = CFG_ITEM_TYPE_INT;
- g_cfg_item_info[CFG_SEG_LOG][0].custom_check = NULL;
- g_cfg_item_info[CFG_SEG_LOG][1].name = "mon_log_count";
- g_cfg_item_info[CFG_SEG_LOG][1].type = CFG_ITEM_TYPE_INT;
- g_cfg_item_info[CFG_SEG_LOG][1].custom_check = NULL;
-
- set_cfg_info (CFG_SEG_LOG, 0, 2, 20, 10);
- set_cfg_info (CFG_SEG_LOG, 1, 2, 20, 10);
-
- g_cfg_seg_name[CFG_SEG_PATH] = "cfg_seg_path";
- g_cfg_item_count[CFG_SEG_PATH] = 1;
- g_cfg_item_info[CFG_SEG_PATH][0].name = "master_log_path";
- g_cfg_item_info[CFG_SEG_PATH][0].type = CFG_ITEM_TYPE_STRING;
- g_cfg_item_info[CFG_SEG_PATH][0].default_str = NSTACK_LOG_NAME;
- g_cfg_item_info[CFG_SEG_PATH][0].custom_check = NULL;
-}
-
-NSTACK_STATIC void
-read_init_config (u32 proc_type)
-{
- int cfg_buf_len = 0;
- char cfg_json_buf[CFG_BUFFER_LEN] = { 0 };
-
- cfg_buf_len = get_cfg_buf (proc_type, cfg_json_buf, sizeof (cfg_json_buf));
- if (cfg_buf_len < 0)
- {
- save_pre_init_log (NSLOG_WAR,
- "warning:file not exist, use default config.");
- return;
- }
- else
- {
- /* parse json buffer */
- parse_cfg (cfg_json_buf);
- }
- save_pre_init_log (NSLOG_INF, "read configuration finished.");
-}
-
-/* =========== set config items ========= */
-NSTACK_STATIC inline void
-set_base_config ()
-{
- g_base_cfg_items[CFG_BASE_RING_SIZE] = DEF_RING_BASE_SIZE;
- g_base_cfg_items[CFG_BASE_HAL_PORT_NUM] = DEF_HAL_PORT_NUM;
-
- g_base_cfg_items[CFG_BASE_SOCKET_NUM] =
- (u32) get_cfg_info (CFG_SEG_BASE, CFG_SEG_BASE_SOCKET_NUM);
- g_base_cfg_items[CFG_BASE_ARP_STALE_TIME] =
- (u32) get_cfg_info (CFG_SEG_BASE, CFG_SEG_BASE_ARP_STALE_TIME);
- g_base_cfg_items[CFG_BASE_ARP_BC_RETRANS_NUM] =
- (u32) get_cfg_info (CFG_SEG_BASE, CFG_SEG_BASE_ARP_BC_RETRANS_NUM);
-}
-
-NSTACK_STATIC void
-init_base_config (cfg_module_param * param)
-{
- /* initial default config */
- /* omc_ctrl single log file should be 10M */
- if (param->proc_type == NSFW_PROC_CTRL)
- {
- init_master_def_config_items ();
- }
- else
- {
- init_main_def_config_items ();
- }
-
- /* read base config from file */
- read_init_config (param->proc_type);
- /* check config and reset value */
- check_cfg ();
-
- /* print config info */
- print_config_item_info ();
-
- set_base_config ();
-}
-
-NSTACK_STATIC void
-init_stackx_config ()
-{
- u32 socket_num_per_thread = CUR_CFG_SOCKET_NUM;
- u32 factor = socket_num_per_thread / SOCKET_NUM_PER_THREAD;
-
- if (factor == 0 || socket_num_per_thread % SOCKET_NUM_PER_THREAD > 0)
- {
- factor += 1;
- }
-
- save_pre_init_log (NSLOG_INF, "socket num:%d, factor:%d",
- CUR_CFG_SOCKET_NUM, factor);
-
- /* MBUF config */
- set_custom_cfg_item (CFG_MBUF_DATA_SIZE, DEF_MBUF_DATA_SIZE);
- set_custom_cfg_item (CFG_TX_MBUF_NUM, DEF_TX_MBUF_POOL_SIZE);
- set_custom_cfg_item (CFG_RX_MBUF_NUM, DEF_RX_MBUF_POOL_SIZE);
- set_custom_cfg_item (CFG_MP_TCPSEG_NUM, DEF_MEMP_NUM_TCP_SEG); /* tcp segment number */
- set_custom_cfg_item (CFG_MP_MSG_NUM, DEF_TX_MSG_POOL_SIZE); /* msg number */
-
- /* ring config */
- set_custom_cfg_item (CFG_HAL_RX_RING_SIZE, DEF_HAL_RX_RING_SIZE); /* netif ring size not changed */
- set_custom_cfg_item (CFG_HAL_TX_RING_SIZE, DEF_HAL_TX_RING_SIZE); /* netif ring size not changed */
- set_custom_cfg_item (CFG_MBOX_RING_SIZE, DEF_MBOX_RING_SIZE);
- set_custom_cfg_item (CFG_SPL_MAX_RING_SIZE, DEF_SPL_MAX_RING_SIZE); /* stackx ring size */
-
- /* pcb config */
- set_custom_cfg_item (CFG_TCP_PCB_NUM, DEF_TCP_PCB_NUM * factor);
- set_custom_cfg_item (CFG_UDP_PCB_NUM, DEF_UDP_PCB_NUM * factor);
- set_custom_cfg_item (CFG_RAW_PCB_NUM, DEF_RAW_PCB_NUM * factor);
- set_custom_cfg_item (CFG_ARP_QUEUE_NUM,
- CUR_CFG_SOCKET_NUM >
- DEF_SOCKET_NUM ? LARGE_ARP_QUEUE_NUM :
- DEF_ARP_QUEUE_NUM);
-}
-
-void
-print_final_config_para ()
-{
- save_pre_init_log (NSLOG_INF, "socket_num :%u",
- get_base_cfg (CFG_BASE_SOCKET_NUM));
- save_pre_init_log (NSLOG_INF, "base_ring_size :%u",
- get_base_cfg (CFG_BASE_RING_SIZE));
- save_pre_init_log (NSLOG_INF, "hal_port_num :%u",
- get_base_cfg (CFG_BASE_HAL_PORT_NUM));
- save_pre_init_log (NSLOG_INF, "arp_stale_num :%u",
- get_base_cfg (CFG_BASE_ARP_STALE_TIME));
- save_pre_init_log (NSLOG_INF, "arp_bc_retrans_num :%u",
- get_base_cfg (CFG_BASE_ARP_BC_RETRANS_NUM));
-
- save_pre_init_log (NSLOG_INF, "mbuf_data_size :%u",
- get_custom_cfg (CFG_MBUF_DATA_SIZE));
- save_pre_init_log (NSLOG_INF, "tx_mbuf_num :%u",
- get_custom_cfg (CFG_TX_MBUF_NUM));
- save_pre_init_log (NSLOG_INF, "rx_mbuf_num :%u",
- get_custom_cfg (CFG_RX_MBUF_NUM));
- save_pre_init_log (NSLOG_INF, "tcp_seg_mp_num :%u",
- get_custom_cfg (CFG_MP_TCPSEG_NUM));
- save_pre_init_log (NSLOG_INF, "msg_mp_num :%u",
- get_custom_cfg (CFG_MP_MSG_NUM));
- save_pre_init_log (NSLOG_INF, "hal_tx_ring_size :%u",
- get_custom_cfg (CFG_HAL_TX_RING_SIZE));
- save_pre_init_log (NSLOG_INF, "hal_rx_ring_size :%u",
- get_custom_cfg (CFG_HAL_RX_RING_SIZE));
- save_pre_init_log (NSLOG_INF, "mbox_ring_size :%u",
- get_custom_cfg (CFG_MBOX_RING_SIZE));
- save_pre_init_log (NSLOG_INF, "spl_ring_size :%u",
- get_custom_cfg (CFG_SPL_MAX_RING_SIZE));
- save_pre_init_log (NSLOG_INF, "tcp_pcb_num :%u",
- get_custom_cfg (CFG_TCP_PCB_NUM));
- save_pre_init_log (NSLOG_INF, "udp_pcb_num :%u",
- get_custom_cfg (CFG_UDP_PCB_NUM));
- save_pre_init_log (NSLOG_INF, "raw_pcb_num :%u",
- get_custom_cfg (CFG_RAW_PCB_NUM));
-}
-
-NSTACK_STATIC void
-init_module_cfg_default ()
-{
- init_stackx_config ();
-
- print_final_config_para ();
-}
-
-NSTACK_STATIC void
-init_main_log_cfg_para ()
-{
- struct log_init_para log_para;
- log_para.run_log_size = g_cfg_item_info[CFG_SEG_LOG][0].value;
- log_para.run_log_count = g_cfg_item_info[CFG_SEG_LOG][1].value;
-
- /* log path valid check */
- if (0 == access (g_cfg_item_info[CFG_SEG_PATH][0].pvalue, W_OK))
- {
- log_para.run_log_path = g_cfg_item_info[CFG_SEG_PATH][0].pvalue;
- }
- else
- {
- log_para.run_log_path = g_cfg_item_info[CFG_SEG_PATH][0].default_str;
- }
-
- set_log_init_para (&log_para);
-}
-
-/* nStackCtrl is the diff process with main, cannot use main process info,
- need get the configure info respectively */
-/* omc_ctrl single log file should be 10M */
-NSTACK_STATIC void
-init_ctrl_log_cfg_para ()
-{
- struct log_init_para log_para;
- log_para.mon_log_size = g_cfg_item_info[CFG_SEG_LOG][0].value;
- log_para.mon_log_count = g_cfg_item_info[CFG_SEG_LOG][1].value;
-
- /* log path valid check */
- if (0 == access (g_cfg_item_info[CFG_SEG_PATH][0].pvalue, W_OK))
- {
- log_para.mon_log_path = g_cfg_item_info[CFG_SEG_PATH][0].pvalue;
- }
- else
- {
- log_para.mon_log_path = g_cfg_item_info[CFG_SEG_PATH][0].default_str;
- }
-
- set_log_init_para (&log_para);
-}
-
-/*===========config init for nstack main=============*/
-
-NSTACK_STATIC void
-init_module_cfg_nstackmain ()
-{
- /* init config data */
- init_module_cfg_default ();
-
- /* init log para */
- init_main_log_cfg_para ();
-}
-
-/*===========config init for nstack ctrl=============*/
-
-/* nStackCtrl is the diff process with main,
- cannot use main process info, need get the configure info respectively */
-
-NSTACK_STATIC void
-init_module_cfg_nstackctrl ()
-{
- init_ctrl_log_cfg_para ();
-}
-
-/*===========init config module=============*/
-void
-config_module_init (cfg_module_param * param)
-{
- save_pre_init_log (NSLOG_INF, "config module init begin] proc type=%d",
- param->proc_type);
-
- init_base_config (param);
-
- switch (param->proc_type)
- {
- case NSFW_PROC_MAIN:
- init_module_cfg_nstackmain ();
- break;
-
- case NSFW_PROC_CTRL:
- init_module_cfg_nstackctrl ();
- break;
-
- default:
- init_module_cfg_default ();
- break;
- }
-
- save_pre_init_log (NSLOG_INF, "config module init end.");
-}
-
-u32
-get_cfg_share_mem_size ()
-{
- return sizeof (g_base_cfg_items) + sizeof (g_custom_cfg_items);
-}
-
-int
-get_share_cfg_from_mem (void *mem)
-{
- if (EOK !=
- MEMCPY_S (g_base_cfg_items, sizeof (g_base_cfg_items), mem,
- sizeof (g_base_cfg_items)))
- {
- return -1;
- }
-
- char *custom_cfg_mem = (char *) mem + sizeof (g_base_cfg_items);
-
- if (EOK !=
- MEMCPY_S (g_custom_cfg_items, sizeof (g_custom_cfg_items),
- custom_cfg_mem, sizeof (g_custom_cfg_items)))
- {
- return -1;
- }
-
- return 0;
-}
-
-int
-set_share_cfg_to_mem (void *mem)
-{
- if (EOK !=
- MEMCPY_S (mem, sizeof (g_base_cfg_items), g_base_cfg_items,
- sizeof (g_base_cfg_items)))
- {
- return -1;
- }
-
- char *custom_cfg_mem = (char *) mem + sizeof (g_base_cfg_items);
-
- if (EOK !=
- MEMCPY_S (custom_cfg_mem, sizeof (g_custom_cfg_items),
- g_custom_cfg_items, sizeof (g_custom_cfg_items)))
- {
- return -1;
- }
-
- return 0;
-}
diff --git a/stacks/lwip_stack/src/maintain/nsfw_msg.c b/stacks/lwip_stack/src/maintain/nsfw_msg.c
deleted file mode 100644
index 338f803..0000000
--- a/stacks/lwip_stack/src/maintain/nsfw_msg.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "nsfw_msg.h"
-/* *INDENT-OFF* */
-msg_fun g_msg_module_fun_array[MAX_MODULE_TYPE] = {NULL};
-msg_fun g_msg_module_major_fun_array[MAX_MODULE_TYPE][MAX_MAJOR_TYPE] = {{NULL}};
-msg_fun g_msg_module_major_minor_fun_array[MAX_MODULE_TYPE][MAX_MAJOR_TYPE][MAX_MINOR_TYPE] = {{{NULL}}};
-msg_fun g_msg_unsupport_fun = NULL;
-/* *INDENT-ON* */
diff --git a/stacks/lwip_stack/src/maintain/nsfw_rti.c b/stacks/lwip_stack/src/maintain/nsfw_rti.c
deleted file mode 100644
index e5a1d3c..0000000
--- a/stacks/lwip_stack/src/maintain/nsfw_rti.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include <stdlib.h>
-#include "types.h"
-#include "nstack_securec.h"
-#include "nsfw_init.h"
-#include "nstack_log.h"
-#include "nsfw_maintain_api.h"
-#include "nsfw_mem_api.h"
-#include "nsfw_rti.h"
-#include "nsfw_msg.h"
-#ifdef HAL_LIB
-#else
-#include "common_pal_bitwide_adjust.h"
-#endif
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C"{
-/* *INDENT-ON* */
-#endif /* __cplusplus */
-
-char g_dfx_switch = 1;
-
-struct rti_queue *g_nsfw_rti_primary_stat = NULL;
-
-void
-nsfw_rti_stat (nsfw_rti_stat_type_t statType, const data_com_msg * m)
-{
- if (!g_nsfw_rti_primary_stat || !m)
- {
- return;
- }
-
- struct rti_queue *primary_stat = ADDR_SHTOL (g_nsfw_rti_primary_stat);
-
- switch (statType)
- {
- case NSFW_STAT_PRIMARY_DEQ:
- if ((m->param.major_type >= MAX_MAJOR_TYPE)
- || (m->param.minor_type >= MAX_MINOR_TYPE))
- {
- return;
- }
- /*call_msg_fun() is only called in nStackMain, no reentrance risk, ++ operation is ok */
- primary_stat->tcpip_msg_deq[m->param.major_type]++;
- if (0 == m->param.major_type) //SPL_TCPIP_NEW_MSG_API
- {
- primary_stat->api_msg_deq[m->param.minor_type]++;
- }
- break;
- case NSFW_STAT_PRIMARY_ENQ_FAIL:
- if ((m->param.major_type >= MAX_MAJOR_TYPE)
- || (m->param.minor_type >= MAX_MINOR_TYPE))
- {
- return;
- }
- __sync_fetch_and_add (&primary_stat->tcpip_msg_enq_fail
- [m->param.major_type], 1);
- if (0 == m->param.major_type) //SPL_TCPIP_NEW_MSG_API
- {
- __sync_fetch_and_add (&primary_stat->api_msg_enq_fail
- [m->param.minor_type], 1);
- }
- break;
- case NSFW_STAT_PRIMARY_ENQ:
- //not use
- break;
- default:
- break;
- }
-}
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif /* __cplusplus */
diff --git a/stacks/lwip_stack/src/nStackMain/CMakeLists.txt b/stacks/lwip_stack/src/nStackMain/CMakeLists.txt
deleted file mode 100644
index 24f6c9d..0000000
--- a/stacks/lwip_stack/src/nStackMain/CMakeLists.txt
+++ /dev/null
@@ -1,60 +0,0 @@
-#########################################################################
-#
-# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-# 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.
-#########################################################################
-
-FILE(GLOB_RECURSE MAIN *.c)
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIE -pie")
-
-ADD_DEFINITIONS(-rdynamic -D__NSTACK_MAIN__)
-ADD_EXECUTABLE(nStackMain ${MAIN})
-TARGET_LINK_LIBRARIES(
- nStackMain
- -Wl,--whole-archive
- ${LIB_PATH_STATIC}/libjson-c.a
- ${LIB_PATH_STATIC}/libglog.a
- dmm_api
- nStackMaintain
- stacklwip
- nStackHal
- nStackAlarm
- nTcpdump
- -Wl,--no-whole-archive,-lstdc++ -ldl
- -Wl,--no-as-needed
- rte_eal
- rte_ethdev
- rte_mempool
- rte_ring
- rte_mbuf
- rte_pmd_ixgbe
- rte_pmd_virtio
- rte_pmd_e1000
- rte_pmd_vmxnet3_uio
- rte_pmd_bond
- rte_kvargs
- rte_cmdline
-)
-
-if(WITH_SECUREC_LIB)
-ADD_DEPENDENCIES(nStackMain nStackHal nStackMaintain nStackAlarm stacklwip SECUREC)
-else()
-ADD_DEPENDENCIES(nStackMain nStackHal nStackMaintain nStackAlarm stacklwip)
-endif()
-
-INCLUDE_DIRECTORIES(
- ${CMAKE_CURRENT_LIST_DIR}/../alarm/
- ${CMAKE_CURRENT_LIST_DIR}/../maintain/
- ${CMAKE_CURRENT_LIST_DIR}/../include/
-)
diff --git a/stacks/lwip_stack/src/nStackMain/main.c b/stacks/lwip_stack/src/nStackMain/main.c
deleted file mode 100644
index 3bc0a3b..0000000
--- a/stacks/lwip_stack/src/nStackMain/main.c
+++ /dev/null
@@ -1,429 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include <signal.h>
-#include <stdio.h>
-#include <pthread.h>
-#include <unistd.h>
-#include <sched.h>
-#include <fcntl.h>
-#include <malloc.h>
-#include "nstack_securec.h"
-#include "nstack_log.h"
-#include "types.h"
-#include "nsfw_init.h"
-#include "alarm_api.h"
-
-#include "nsfw_mgr_com_api.h"
-#include "nsfw_ps_mem_api.h"
-#include "nsfw_ps_api.h"
-#include "nsfw_recycle_api.h"
-#include "nsfw_fd_timer_api.h"
-#include "nsfw_maintain_api.h"
-#include "nstack_dmm_adpt.h"
-
-#include "nsfw_mem_api.h"
-#include "nsfw_mt_config.h"
-
-#define GLOBAL_Stack_ARG "stack"
-#define GlOBAL_HELP "--help"
-#define GLOBAL_Dpdk_ARG "dpdk"
-#define GLOBAL_STACK_PORT "-port"
-#define NSTACK_MAIN_MAX_PARA 32
-#define NSTACK_MAIN_MIN_PARA 1
-
-#define MAX_MASTER_OPEN_FD 1024
-
-extern int uStackArgIndex;
-extern void spl_tcpip_thread (void *arg);
-extern int globalArgc;
-extern char **gArgv;
-extern int g_dpdk_argc;
-extern char **g_dpdk_argv;
-extern void print_call_stack ();
-extern int adjust_mem_arg (int argc, char *argv[]);
-extern struct cfg_item_info g_cfg_item_info[CFG_SEG_MAX][MAX_CFG_ITEM];
-extern int get_network_json_data ();
-extern int get_ip_json_data ();
-
-#ifdef SYS_MEM_RES_STAT
-extern void get_resource_stat ();
-#endif
-
-extern alarm_result ms_alarm_check_func (void *para);
-int g_tcpip_thread_stat = 0; //this variable will be used at health check feature
-
-#if (DPDK_MODULE)
-extern void pal_common_usage (void);
-#endif
-
-typedef void (*pSignalFunc) (int);
-int app_init (void);
-
-void
-helpInfo ()
-{
- NSPOL_LOGERR
- ("-----------------------------------------------------------------"
- "\nThe format of arg" "\nbash:./nStackMain RTE-ARGS stack STACK-ARGS"
- "\n RTE-ARGS=-c COREMASK -n NUM [-b <domain:bus:devid.func>] [--socket-mem=MB,...] [-m MB] [-r NUM] [-v] [--file-prefix] [--proc-type <primary|secondary|auto>] [-- xen-dom0]"
- "\n STACK-ARGS=-port PORTMASK [-c COREMASK] [-thread NUM]"
- "\nUser examples:"
- "\nTo make the DPDK run on core mask:0xf,Number of memory channels per processor socket in DPDK is 3 "
- "\nTo make the stack run on eth coremask:f"
- "\nbash: ./nStackMain -c 0xf -n 3 stack -port f"
- "\nTo get more help info for stack:" "\n ./nStackMain --help stack"
- "\nTo get more help info for dpdk:" "\n ./nStackMain --help dpdk"
- "\n-----------------------------------------------------------------");
-
-#ifndef FOR_NSTACK_UT
- exit (0);
-#endif
-
-}
-
-#define SIG_PTRACE __SIGRTMIN + 5
-
-void
-signal_handler (int s)
-{
- NSPOL_LOGERR ("Received signal exiting.]s=%d", s);
- if (s == SIGSEGV) /* add for gdb attach work */
- {
- print_call_stack ();
- }
-
- nstack_segment_error (s);
- if ((SIG_PTRACE != s) && (SIG_PTRACE + 2 != s))
- {
-#ifndef FOR_NSTACK_UT
- exit (0);
-#endif
- }
-
- int i;
- for (i = 0; i < MAX_THREAD; i++)
- {
- if (g_all_thread[i] != pthread_self () && 0 != g_all_thread[i])
- {
- NSFW_LOGERR ("send sig thread %d", g_all_thread[i]);
- if (0 == pthread_kill (g_all_thread[i], SIG_PTRACE + 2))
- {
- return;
- }
- }
- g_all_thread[i] = 0;
- }
-
- for (i = 0; i < MAX_THREAD; i++)
- {
- if (0 != g_all_thread[i])
- {
- return;
- }
- }
-
-#ifndef FOR_NSTACK_UT
- exit (0);
-#endif
-
- //dpdk_signal_handler();
-}
-
-void
-register_signal_handler ()
-{
-/* donot catch SIGHUP SIGTERM */
- static const int s_need_handle_signals[] = {
- SIGABRT,
- SIGBUS,
- SIGFPE,
- SIGILL,
- SIGIOT,
- SIGQUIT,
- SIGSEGV,
- //SIGTRAP,
- SIGXCPU,
- SIGXFSZ,
- //SIGALRM,
- //SIGHUP,
- SIGINT,
- //SIGKILL,
- SIGPIPE,
- SIGPROF,
- SIGSYS,
- //SIGTERM,
- SIGUSR1,
- SIGUSR2,
- //SIGVTALRM,
- //SIGSTOP,
- //SIGTSTP,
- //SIGTTIN,
- //SIGTTOU
- };
-
- /* here mask signal that will use in sigwait() */
- sigset_t waitset, oset;
-
- if (0 != sigemptyset (&waitset))
- {
- NSPOL_LOGERR ("sigemptyset failed.");
- }
- sigaddset (&waitset, SIGRTMIN); /* for timer */
- sigaddset (&waitset, SIGRTMIN + 2);
- pthread_sigmask (SIG_BLOCK, &waitset, &oset);
- unsigned int i = 0;
-
- struct sigaction s;
- s.sa_handler = signal_handler;
- if (0 != sigemptyset (&s.sa_mask))
- {
- NSPOL_LOGERR ("sigemptyset failed.");
- }
-
- s.sa_flags = (int) SA_RESETHAND;
-
- /* register sig handler for more signals */
- for (i = 0; i < sizeof (s_need_handle_signals) / sizeof (int); i++)
- {
- if (sigaction (s_need_handle_signals[i], &s, NULL) != 0)
- {
- NSPOL_LOGERR ("Could not register %d signal handler.",
- s_need_handle_signals[i]);
- }
-
- }
-
-}
-
-void
-checkArgs (int argc, char **argv)
-{
- int uStackArg = 0; //mark the status whether need helpinfo and return
- int i;
- const unsigned int global_para_length = 5; //GLOBAL_Stack_ARG "stack" and GLOBAL_STACK_PORT "-port" string length, both are 5
- const unsigned int global_help_length = 6; //GlOBAL_HELP "--help" string length is 6
- const unsigned int global_dpdk_length = 4; //GLOBAL_Dpdk_ARG "dpdk" string length is 4
-
- for (i = 0; i < argc; i++)
- {
- if (argc > 1)
- {
- if (strncmp (argv[i], GLOBAL_Stack_ARG, global_para_length) == 0)
- {
- if (i < 5)
- {
- NSPOL_LOGERR ("Too less args");
- helpInfo ();
- return;
- }
-
- uStackArg = 1;
- uStackArgIndex = i;
- continue;
- }
-
- if (strncmp (argv[i], GLOBAL_STACK_PORT, global_para_length) == 0)
- {
- continue;
- }
-
- if (strncmp (argv[i], GlOBAL_HELP, global_help_length) == 0)
- {
- if (i == (argc - 1))
- {
- helpInfo ();
- return;
- }
- else if ((++i < argc)
- &&
- (strncmp (argv[i], GLOBAL_Dpdk_ARG, global_dpdk_length)
- == 0))
- {
-#if (DPDK_MODULE != 1)
- //eal_common_usage();
-#else
- pal_common_usage ();
-#endif
- return;
- }
- else
- {
- helpInfo ();
- return;
- }
- }
- }
- else
- {
- NSPOL_LOGERR ("Too less args");
- helpInfo ();
- return;
- }
- }
-
- if (!uStackArg)
- {
- helpInfo ();
- return;
- }
-}
-
-extern u64 timer_get_threadid ();
-
-#ifdef FOR_NSTACK_UT
-int
-nstack_main (void)
-{
- int argc;
-
- char *argv[NSTACK_MAIN_MAX_PARA];
- argv[0] = "nStackMain";
- argv[1] = "-c";;
- argv[2] = "0xffffffff";
- argv[3] = "-n";
- argv[4] = "3";
- argv[5] = "stack";
- argv[6] = "-port";
- argv[7] = "288";
- argv[8] = "-c";
- argv[9] = "2";
- argc = 10;
-
-#else
-int
-main (int argc, char *argv[])
-{
-#endif
- fw_poc_type proc_type = NSFW_PROC_MAIN;
-
- /* although nStackMaster has set close on exec, here can't be removed.
- * in upgrade senario, if Master is old which has not set close on exec, here,
- * if new version Main not close, problem will reappear. Add Begin*/
- int i;
- for (i = 4; i < MAX_MASTER_OPEN_FD; i++)
- {
- close (i);
- }
-
- cfg_module_param config_para;
- config_para.proc_type = proc_type;
- config_para.argc = argc;
- config_para.argv = (unsigned char **) argv;
- config_module_init (&config_para);
-
- set_log_proc_type (LOG_PRO_NSTACK);
- (void) nstack_log_init ();
-
-// nstack_tracing_enable();
- if (0 != nsfw_proc_start_with_lock (NSFW_PROC_MAIN))
- {
- NSFW_LOGERR ("another process is running!!");
- return 0;
- }
-
- if (1 != mallopt (M_ARENA_MAX, 1))
- {
- NSPOL_LOGERR ("Error: mallopt fail, continue init");
- }
-
- /* Set different mem args to PAL and EAL */
- INITPOL_LOGINF ("main_thread", "adjust_mem_arg init", NULL_STRING,
- LOG_INVALID_VALUE, MODULE_INIT_START);
- if (adjust_mem_arg (argc, argv))
- {
- INITPOL_LOGERR ("main_thread", "adjust_mem_arg init", NULL_STRING,
- LOG_INVALID_VALUE, MODULE_INIT_FAIL);
- return -1;
- }
- INITPOL_LOGINF ("main_thread", "adjust_mem_arg init", NULL_STRING,
- LOG_INVALID_VALUE, MODULE_INIT_SUCCESS);
-
- checkArgs (globalArgc, gArgv);
- register_signal_handler ();
-
- (void) signal (SIG_PTRACE, signal_handler);
- (void) signal (SIG_PTRACE + 2, signal_handler);
-
- if (nsfw_mgr_comm_fd_init (NSFW_PROC_MAIN) < 0)
- {
- NSFW_LOGERR ("nsfw_mgr_comm_fd_init failed");
- }
-
- (void) nsfw_reg_trace_thread (pthread_self ());
-
- (void) nstack_framework_setModuleParam (NSFW_ALARM_MODULE,
- (void *) ((u64) proc_type));
- (void) nstack_framework_setModuleParam (TCPDUMP_MODULE,
- (void *) ((u64) proc_type));
-
- nstack_dmm_para stpara;
- stpara.argc = uStackArgIndex;
- stpara.argv = gArgv;
- stpara.deploy_type = NSTACK_MODEL_TYPE3;
- stpara.proc_type = NSFW_PROC_MAIN;
- stpara.attr.policy = get_cfg_info (CFG_SEG_PRI, CFG_SEG_THREAD_PRI_POLICY);
- stpara.attr.pri = get_cfg_info (CFG_SEG_PRI, CFG_SEG_THREAD_PRI_PRI);
-
- if (nstack_adpt_init (&stpara) != 0)
- {
- NSFW_LOGERR ("nstack adpt init fail");
- return -1;
- }
-
- ns_send_init_alarm (ALARM_EVENT_NSTACK_MAIN_ABNORMAL);
-
- while (!timer_get_threadid ())
- {
- (void) nsfw_thread_chk ();
- sys_sleep_ns (0, 500000000);
- }
- (void) nsfw_thread_chk_unreg ();
- NSFW_LOGINF ("tcpip thread start!");
- (void) sleep (2);
-
- NSFW_LOGINF ("read configuration!");
- if (0 != get_network_json_data ())
- {
- NSFW_LOGINF ("get_network_json_data error");
- return -1;
- }
-
- if (0 != get_ip_json_data ())
- {
- NSFW_LOGINF ("get_ip_json_data error");
- return -1;
- }
-
- int ep_thread = 0;
- while (1)
- {
-#ifdef SYS_MEM_RES_STAT
- get_resource_stat ();
-#endif
- (void) sleep (3);
- ep_thread = nsfw_mgr_com_chk_hbt (1);
- if (ep_thread > 0)
- {
- NSFW_LOGINF ("force release lock");
- (void) nsfw_recycle_rechk_lock ();
- }
-#ifdef FOR_NSTACK_UT
- return 0;
-#endif
-
- }
-}
diff --git a/stacks/lwip_stack/src/sbr/CMakeLists.txt b/stacks/lwip_stack/src/sbr/CMakeLists.txt
deleted file mode 100644
index f324e5f..0000000
--- a/stacks/lwip_stack/src/sbr/CMakeLists.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-#########################################################################
-#
-# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-# 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.
-#########################################################################
-
-if(WITH_HAL_LIB)
-else()
- SET(PAL_H_DIRECTORIES "/usr/include/dpdk/")
-endif()
-
-
-FILE(GLOB SBR *.c)
-ADD_LIBRARY(lwip_dpdk SHARED ${SBR})
-TARGET_LINK_LIBRARIES(lwip_dpdk -Wl,--whole-archive socket -Wl,--no-whole-archive dmm_api nStackMaintain)
-ADD_DEPENDENCIES(lwip_dpdk socket DPDK)
-INCLUDE_DIRECTORIES(
- ${CMAKE_CURRENT_LIST_DIR}/../include
- ${PAL_H_DIRECTORIES}
-)
diff --git a/stacks/lwip_stack/src/sbr/sbr_err.h b/stacks/lwip_stack/src/sbr/sbr_err.h
deleted file mode 100644
index be3bc3b..0000000
--- a/stacks/lwip_stack/src/sbr/sbr_err.h
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef SBR_ERR_H
-#define SBR_ERR_H
-#include <errno.h>
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-#ifdef SBR_PROVIDE_ERRNO
-#define EPERM 1 /* Operation not permitted */
-#define ENOENT 2 /* No such file or directory */
-#define ESRCH 3 /* No such process */
-#define EINTR 4 /* Interrupted system call */
-#define EIO 5 /* I/O error */
-#define ENXIO 6 /* No such device or address */
-#define E2BIG 7 /* Arg list too long */
-#define ENOEXEC 8 /* Exec format error */
-#define EBADF 9 /* Bad file number */
-#define ECHILD 10 /* No child processes */
-#define EAGAIN 11 /* Try again */
-#define ENOMEM 12 /* Out of memory */
-#define EACCES 13 /* Permission denied */
-#define EFAULT 14 /* Bad address */
-#define ENOTBLK 15 /* Block device required */
-#define EBUSY 16 /* Device or resource busy */
-#define EEXIST 17 /* File exists */
-#define EXDEV 18 /* Cross-device link */
-#define ENODEV 19 /* No such device */
-#define ENOTDIR 20 /* Not a directory */
-#define EISDIR 21 /* Is a directory */
-#define EINVAL 22 /* Invalid argument */
-#define ENFILE 23 /* File table overflow */
-#define EMFILE 24 /* Too many open files */
-#define ENOTTY 25 /* Not a typewriter */
-#define ETXTBSY 26 /* Text file busy */
-#define EFBIG 27 /* File too large */
-#define ENOSPC 28 /* No space left on device */
-#define ESPIPE 29 /* Illegal seek */
-#define EROFS 30 /* Read-only file system */
-#define EMLINK 31 /* Too many links */
-#define EPIPE 32 /* Broken pipe */
-#define EDOM 33 /* Math argument out of domain of func */
-#define ERANGE 34 /* Math result not representable */
-#define EDEADLK 35 /* Resource deadlock would occur */
-#define ENAMETOOLONG 36 /* File name too long */
-#define ENOLCK 37 /* No stored locks available */
-#define ENOSYS 38 /* Function not implemented */
-#define ENOTEMPTY 39 /* Directory not empty */
-#define ELOOP 40 /* Too many symbolic links encountered */
-#define EWOULDBLOCK EAGAIN /* Operation would block */
-#define ENOMSG 42 /* No message of desired type */
-#define EIDRM 43 /* Identifier removed */
-#define ECHRNG 44 /* Channel number out of range */
-#define EL2NSYNC 45 /* Level 2 not synchronized */
-#define EL3HLT 46 /* Level 3 halted */
-#define EL3RST 47 /* Level 3 reset */
-#define ELNRNG 48 /* Link number out of range */
-#define EUNATCH 49 /* Protocol driver not attached */
-#define ENOCSI 50 /* No CSI structure available */
-#define EL2HLT 51 /* Level 2 halted */
-#define EBADE 52 /* Invalid exchange */
-#define EBADR 53 /* Invalid request descriptor */
-#define EXFULL 54 /* Exchange full */
-#define ENOANO 55 /* No anode */
-#define EBADRQC 56 /* Invalid request code */
-#define EBADSLT 57 /* Invalid slot */
-
-#define EDEADLOCK EDEADLK
-
-#define EBFONT 59 /* Bad font file format */
-#define ENOSTR 60 /* Device not a stream */
-#define ENODATA 61 /* No data available */
-#define ETIME 62 /* Timer expired */
-#define ENOSR 63 /* Out of streams resources */
-#define ENONET 64 /* Machine is not on the network */
-#define ENOPKG 65 /* Package not installed */
-#define EREMOTE 66 /* Object is remote */
-#define ENOLINK 67 /* Link has been severed */
-#define EADV 68 /* Advertise error */
-#define ESRMNT 69 /* Srmount error */
-#define ECOMM 70 /* Communication error on send */
-#define EPROTO 71 /* Protocol error */
-#define EMULTIHOP 72 /* Multihop attempted */
-#define EDOTDOT 73 /* RFS specific error */
-#define EBADMSG 74 /* Not a data message */
-#define EOVERFLOW 75 /* Value too large for defined data type */
-#define ENOTUNIQ 76 /* Name not unique on network */
-#define EBADFD 77 /* File descriptor in bad state */
-#define EREMCHG 78 /* Remote address changed */
-#define ELIBACC 79 /* Can not access a needed shared library */
-#define ELIBBAD 80 /* Accessing a corrupted shared library */
-#define ELIBSCN 81 /* .lib section in a.out corrupted */
-#define ELIBMAX 82 /* Attempting to link in too many shared libraries */
-#define ELIBEXEC 83 /* Cannot exec a shared library directly */
-#define EILSEQ 84 /* Illegal byte sequence */
-#define ERESTART 85 /* Interrupted system call should be restarted */
-#define ESTRPIPE 86 /* Streams pipe error */
-#define EUSERS 87 /* Too many users */
-#define ENOTSOCK 88 /* Socket operation on non-socket */
-#define EDESTADDRREQ 89 /* Destination address required */
-#define EMSGSIZE 90 /* Message too long */
-#define EPROTOTYPE 91 /* Protocol wrong type for socket */
-#define ENOPROTOOPT 92 /* Protocol not available */
-#define EPROTONOSUPPORT 93 /* Protocol not supported */
-#define ESOCKTNOSUPPORT 94 /* Socket type not supported */
-#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
-#define EPFNOSUPPORT 96 /* Protocol family not supported */
-#define EAFNOSUPPORT 97 /* Address family not supported by protocol */
-#define EADDRINUSE 98 /* Address already in use */
-#define EADDRNOTAVAIL 99 /* Cannot assign requested address */
-#define ENETDOWN 100 /* Network is down */
-#define ENETUNREACH 101 /* Network is unreachable */
-#define ENETRESET 102 /* Network dropped connection because of reset */
-#define ECONNABORTED 103 /* Software caused connection abort */
-#define ECONNRESET 104 /* Connection reset by peer */
-#define ENOBUFS 105 /* No buffer space available */
-#define EISCONN 106 /* Transport endpoint is already connected */
-#define ENOTCONN 107 /* Transport endpoint is not connected */
-#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */
-#define ETOOMANYREFS 109 /* Too many references: cannot splice */
-#define ETIMEDOUT 110 /* Connection timed out */
-#define ECONNREFUSED 111 /* Connection refused */
-#define EHOSTDOWN 112 /* Host is down */
-#define EHOSTUNREACH 113 /* No route to host */
-#define EALREADY 114 /* Operation already in progress */
-#define EINPROGRESS 115 /* Operation now in progress */
-#define ESTALE 116 /* Stale NFS file handle */
-#define EUCLEAN 117 /* Structure needs cleaning */
-#define ENOTNAM 118 /* Not a XENIX named type file */
-#define ENAVAIL 119 /* No XENIX semaphores available */
-#define EISNAM 120 /* Is a named type file */
-#define EREMOTEIO 121 /* Remote I/O error */
-#define EDQUOT 122 /* Quota exceeded */
-
-#define ENOMEDIUM 123 /* No medium found */
-#define EMEDIUMTYPE 124 /* Wrong medium type */
-
-#define ENSROK 0
-#define ENSRNODATA 160
-#define ENSRFORMERR 161
-#define ENSRSERVFAIL 162
-#define ENSRNOTFOUND 163
-#define ENSRNOTIMP 164
-#define ENSRREFUSED 165
-#define ENSRBADQUERY 166
-#define ENSRBADNAME 167
-#define ENSRBADFAMILY 168
-#define ENSRBADRESP 169
-#define ENSRCONNREFUSED 170
-#define ENSRTIMEOUT 171
-#define ENSROF 172
-#define ENSRFILE 173
-#define ENSRNOMEM 174
-#define ENSRDESTRUCTION 175
-#define ENSRQUERYDOMAINTOOLONG 176
-#define ENSRCNAMELOOP 177
-#define OPTION_DEG 200
-
-#endif
-
-static inline void
-sbr_set_errno (int err)
-{
- errno = err;
-}
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif
diff --git a/stacks/lwip_stack/src/sbr/sbr_index_ring.c b/stacks/lwip_stack/src/sbr/sbr_index_ring.c
deleted file mode 100644
index 0daa465..0000000
--- a/stacks/lwip_stack/src/sbr/sbr_index_ring.c
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include <string.h>
-#include "sbr_index_ring.h"
-#include "nstack_securec.h"
-#include "common_mem_common.h"
-#include "common_func.h"
-
-/*****************************************************************************
-* Prototype : sbr_init_index_ring
-* Description : init index ring
-* Input : sbr_index_ring* ring
-* u32 num
-* Output : None
-* Return Value : static inline void
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline void
-sbr_init_index_ring (sbr_index_ring * ring, u32 num)
-{
- u32 loop;
-
- ring->head = 0;
- ring->tail = 0;
- ring->num = num;
- ring->mask = num - 1;
-
- for (loop = 0; loop < num; loop++)
- {
- ring->nodes[loop].ver = (loop - num);
- ring->nodes[loop].val = 0;
- }
-}
-
-/*****************************************************************************
-* Prototype : sbr_create_index_ring
-* Description : create index ring
-* Input : u32 num
-* Output : None
-* Return Value : sbr_index_ring*
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-sbr_index_ring *
-sbr_create_index_ring (u32 num)
-{
- num = common_mem_align32pow2 (num + 1);
- sbr_index_ring *ring =
- (sbr_index_ring *) malloc (sizeof (sbr_index_ring) +
- num * sizeof (sbr_index_node));
- if (!ring)
- {
- return NULL;
- }
-
- sbr_init_index_ring (ring, num);
- return ring;
-}
-
-/*****************************************************************************
-* Prototype : sbr_index_ring_enqueue
-* Description : enqueue data,val != 0
-* Input : sbr_index_ring* ring
-* i32 val
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_index_ring_enqueue (sbr_index_ring * ring, i32 val)
-{
- if (0 == val)
- {
- return -1;
- }
-
- sbr_index_node expect_node;
- sbr_index_node cur_node;
- u32 tmp_head;
- u32 tmp_tail;
- u32 cur_head = ring->head;
- u32 mask = ring->mask;
- u32 size = ring->num;
-
- do
- {
- tmp_tail = ring->tail;
- if (tmp_tail + size - cur_head == 0)
- {
- if (ring->nodes[tmp_tail & mask].val == 0)
- {
- (void) __sync_bool_compare_and_swap (&ring->tail, tmp_tail,
- tmp_tail + 1);
- }
- else
- {
- return 0;
- }
- }
-
- expect_node.ver = cur_head - size;
- expect_node.val = 0;
-
- cur_node.ver = cur_head;
- cur_node.val = val;
-
- if ((ring->nodes[cur_head & mask].ver == expect_node.ver)
- && __sync_bool_compare_and_swap (&ring->nodes[cur_head & mask].data,
- expect_node.data, cur_node.data))
- {
- tmp_head = ring->head;
- if ((tmp_head - cur_head > 0x80000000) && (0 == (cur_head & 0x11)))
- {
- (void) __sync_bool_compare_and_swap (&ring->head, tmp_head,
- cur_head);
- }
-
- break;
- }
-
- tmp_head = ring->head;
- cur_head = cur_head - tmp_head < mask - 1 ? cur_head + 1 : tmp_head;
- }
- while (1);
-
- return 1;
-}
-
-/*****************************************************************************
-* Prototype : sbr_index_ring_dequeue
-* Description : dequeue
-* Input : sbr_index_ring* ring
-* i32* val
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_index_ring_dequeue (sbr_index_ring * ring, i32 * val)
-{
- u32 cur_tail;
- u32 tmp_tail;
- u32 tmp_head;
- u32 mask = ring->mask;
- sbr_index_node null_node;
- sbr_index_node expect_node;
-
- cur_tail = ring->tail;
- do
- {
- tmp_head = ring->head;
- if (cur_tail == tmp_head)
- {
- if (0 != (ring->nodes[tmp_head & mask].val))
- {
- (void) __sync_bool_compare_and_swap (&ring->head, tmp_head,
- tmp_head + 1);
- }
- else
- {
- return 0;
- }
- }
-
- null_node.ver = cur_tail;
- null_node.val = 0;
- expect_node = ring->nodes[cur_tail & mask];
-
- if ((null_node.ver == expect_node.ver) && (expect_node.val)
- && __sync_bool_compare_and_swap (&ring->nodes[cur_tail & mask].data,
- expect_node.data, null_node.data))
-
- {
- *val = expect_node.val;
- tmp_tail = ring->tail;
- if ((tmp_tail - cur_tail > 0x80000000) && (0 == (cur_tail & 0x11)))
- {
- (void) __sync_bool_compare_and_swap (&ring->tail, tmp_tail,
- cur_tail);
- }
-
- break;
- }
-
- tmp_tail = ring->tail;
- cur_tail = cur_tail - tmp_tail < mask - 1 ? cur_tail + 1 : tmp_tail;
- }
- while (1);
-
- return 1;
-}
diff --git a/stacks/lwip_stack/src/sbr/sbr_index_ring.h b/stacks/lwip_stack/src/sbr/sbr_index_ring.h
deleted file mode 100644
index 86e8345..0000000
--- a/stacks/lwip_stack/src/sbr/sbr_index_ring.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _SBR_INDEX_RING_H_
-#define _SBR_INDEX_RING_H_
-
-#include "types.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-typedef struct
-{
- union
- {
- struct
- {
- volatile u32 ver;
- volatile u32 val;
- };
- u64 data;
- };
-} sbr_index_node;
-
-typedef struct
-{
- volatile u32 head;
- i8 cache_space[124];
- volatile u32 tail;
- u32 num;
- u32 mask;
- sbr_index_node nodes[0];
-} sbr_index_ring;
-
-sbr_index_ring *sbr_create_index_ring (u32 num);
-int sbr_index_ring_enqueue (sbr_index_ring * ring, i32 val);
-int sbr_index_ring_dequeue (sbr_index_ring * ring, i32 * val);
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif
diff --git a/stacks/lwip_stack/src/sbr/sbr_protocol_api.h b/stacks/lwip_stack/src/sbr/sbr_protocol_api.h
deleted file mode 100644
index 95ca565..0000000
--- a/stacks/lwip_stack/src/sbr/sbr_protocol_api.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef SBR_PROTOCOL_API_H
-#define SBR_PROTOCOL_API_H
-#include <sys/uio.h>
-#include <sys/epoll.h>
-#include <netinet/in.h>
-#include "sbr_err.h"
-#include "nsfw_msg_api.h"
-#include "nsfw_mt_config.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-#ifndef SBR_MAX_INTEGER
-#define SBR_MAX_INTEGER 0x7FFFFFFF
-#endif
-
-#ifndef socklen_t
-#define socklen_t u32
-#endif
-
-#define SBR_MAX_FD_NUM MAX_SOCKET_NUM
-
-typedef struct sbr_socket_s sbr_socket_t;
-typedef struct
-{
- int (*socket) (sbr_socket_t *, int, int, int);
- int (*bind) (sbr_socket_t *, const struct sockaddr *, socklen_t);
- int (*listen) (sbr_socket_t *, int);
- int (*accept) (sbr_socket_t *, sbr_socket_t *, struct sockaddr *,
- socklen_t *);
- int (*accept4) (sbr_socket_t *, sbr_socket_t *, struct sockaddr *,
- socklen_t *, int);
- int (*connect) (sbr_socket_t *, const struct sockaddr *, socklen_t);
- int (*shutdown) (sbr_socket_t *, int);
- int (*getsockname) (sbr_socket_t *, struct sockaddr *, socklen_t *);
- int (*getpeername) (sbr_socket_t *, struct sockaddr *, socklen_t *);
- int (*getsockopt) (sbr_socket_t *, int, int, void *, socklen_t *);
- int (*setsockopt) (sbr_socket_t *, int, int, const void *, socklen_t);
- int (*recvfrom) (sbr_socket_t *, void *, size_t, int, struct sockaddr *,
- socklen_t *);
- int (*readv) (sbr_socket_t *, const struct iovec *, int);
- int (*recvmsg) (sbr_socket_t *, struct msghdr *, int);
- int (*send) (sbr_socket_t *, const void *, size_t, int);
- int (*sendto) (sbr_socket_t *, const void *, size_t, int,
- const struct sockaddr *, socklen_t);
- int (*sendmsg) (sbr_socket_t *, const struct msghdr *, int);
- int (*writev) (sbr_socket_t *, const struct iovec *, int);
- int (*fcntl) (sbr_socket_t *, int, long);
- int (*ioctl) (sbr_socket_t *, unsigned long, void *);
- int (*close) (sbr_socket_t *);
- int (*peak) (sbr_socket_t *);
- void (*lock_common) (sbr_socket_t *);
- void (*unlock_common) (sbr_socket_t *);
- void (*fork_parent) (sbr_socket_t *, pid_t);
- void (*fork_child) (sbr_socket_t *, pid_t, pid_t);
- unsigned int (*ep_ctl) (sbr_socket_t *, int triggle_ops,
- struct epoll_event * event, void *pdata);
- unsigned int (*ep_getevt) (sbr_socket_t *, unsigned int events);
- void (*set_app_info) (sbr_socket_t *, void *appinfo);
- void (*set_close_stat) (sbr_socket_t *, int flag);
-} sbr_fdopt;
-
-struct sbr_socket_s
-{
- int fd;
- sbr_fdopt *fdopt;
- void *stack_obj;
- void *sk_obj;
-};
-
-int sbr_init_protocol ();
-int sbr_fork_protocol ();
-sbr_fdopt *sbr_get_fdopt (int domain, int type, int protocol);
-void sbr_app_touch_in (void); /*app send its version info to nStackMain */
-int lwip_try_select (int fdsize, fd_set * fdread, fd_set * fdwrite,
- fd_set * fderr, struct timeval *timeout);
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif
diff --git a/stacks/lwip_stack/src/sbr/sbr_res_mgr.c b/stacks/lwip_stack/src/sbr/sbr_res_mgr.c
deleted file mode 100644
index f40f101..0000000
--- a/stacks/lwip_stack/src/sbr/sbr_res_mgr.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include "nstack_securec.h"
-#include "sbr_res_mgr.h"
-
-sbr_res_group g_res_group = { };
-
-/*****************************************************************************
-* Prototype : sbr_init_sk
-* Description : init sock pool
-* Input : None
-* Output : None
-* Return Value : static int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-NSTACK_STATIC int
-sbr_init_sk ()
-{
- sbr_index_ring *ring = sbr_create_index_ring (SBR_MAX_FD_NUM - 1);
-
- if (!ring)
- {
- NSSBR_LOGERR ("init ring failed");
- return -1;
- }
-
- int i;
- /*the queue can't accept value=0, so i begin with 1 */
- for (i = 1; i <= SBR_MAX_FD_NUM; ++i)
- {
- g_res_group.sk[i].fd = i;
- if (sbr_index_ring_enqueue (ring, i) != 1)
- {
- NSSBR_LOGERR ("sbr_index_ring_enqueue failed, this can not happen");
- free (ring);
- return -1;
- }
- }
-
- g_res_group.sk_ring = ring;
- return 0;
-}
-
-/*****************************************************************************
-* Prototype : sbr_init_res
-* Description : init sbr res
-* Input : None
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-sbr_init_res ()
-{
- if (sbr_init_sk () != 0)
- {
- return -1;
- }
-
- NSSBR_LOGDBG ("init socket ok");
-
- if (sbr_init_protocol () != 0)
- {
- return -1;
- }
-
- NSSBR_LOGDBG ("init protocol ok");
-
- return 0;
-}
diff --git a/stacks/lwip_stack/src/sbr/sbr_res_mgr.h b/stacks/lwip_stack/src/sbr/sbr_res_mgr.h
deleted file mode 100644
index e731314..0000000
--- a/stacks/lwip_stack/src/sbr/sbr_res_mgr.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef SBR_RES_MGR_H
-#define SBR_RES_MGR_H
-#include "sbr_protocol_api.h"
-#include "sbr_index_ring.h"
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-typedef struct
-{
- sbr_index_ring *sk_ring;
- sbr_socket_t sk[SBR_MAX_FD_NUM + 1]; /* unuse index 0 */
-} sbr_res_group;
-
-extern sbr_res_group g_res_group;
-
-/*****************************************************************************
-* Prototype : sbr_malloc_sk
-* Description : malloc sock
-* Input : None
-* Output : None
-* Return Value : static inline sbr_socket_t *
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline sbr_socket_t *
-sbr_malloc_sk ()
-{
- int fd;
-
- if (sbr_index_ring_dequeue (g_res_group.sk_ring, &fd) != 1)
- {
- NSSBR_LOGERR ("malloc sk failed]");
- sbr_set_errno (EMFILE);
- return NULL;
- }
-
- NSSBR_LOGDBG ("malloc sk ok]fd=%d", fd);
- return &g_res_group.sk[fd];
-}
-
-/*****************************************************************************
-* Prototype : sbr_free_sk
-* Description : free sock
-* Input : sbr_socket_t * sk
-* Output : None
-* Return Value : static inline void
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline void
-sbr_free_sk (sbr_socket_t * sk)
-{
- sk->fdopt = NULL;
- sk->sk_obj = NULL;
- sk->stack_obj = NULL;
-
- if (sbr_index_ring_enqueue (g_res_group.sk_ring, sk->fd) != 1)
- {
- NSSBR_LOGERR ("sbr_index_ring_enqueue failed, this can not happen");
- }
-
- NSSBR_LOGDBG ("free sk ok]fd=%d", sk->fd);
-}
-
-/*****************************************************************************
-* Prototype : sbr_lookup_sk
-* Description : lookup socket
-* Input : int fd
-* Output : None
-* Return Value : static inline sbr_socket_t *
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline sbr_socket_t *
-sbr_lookup_sk (int fd)
-{
- if ((fd < 1) || (fd > SBR_MAX_FD_NUM))
- {
- NSSBR_LOGERR ("fd is not ok]fd=%d", fd);
- sbr_set_errno (EBADF);
- return NULL;
- }
-
- sbr_socket_t *sk = &g_res_group.sk[fd];
- if (!sk->sk_obj || !sk->stack_obj)
- {
- NSSBR_LOGERR
- ("data in sk is error, this can not happen]fd=%d,sk_obj=%p,stack_obj=%p",
- fd, sk->sk_obj, sk->stack_obj);
- sbr_set_errno (EBADF);
- return NULL;
- }
-
- return sk;
-}
-
-/*****************************************************************************
-* Prototype : sbr_free_sk
-* Description : free sock
-* Input : sbr_socket_t * sk
-* Output : None
-* Return Value : static inline void
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline void
-sbr_free_fd (int fd)
-{
- if ((fd < 1) || (fd > SBR_MAX_FD_NUM))
- {
- NSSBR_LOGERR ("fd is not ok]fd=%d", fd);
- sbr_set_errno (EBADF);
- return;
- }
-
- sbr_socket_t *sk = &g_res_group.sk[fd];
- if (!sk->fdopt && !sk->sk_obj && !sk->stack_obj)
- {
- NSSBR_LOGERR
- ("can't free empty fd] fd=%d, fdopt=%p, sk_obj=%p, stack_obj=%p", fd,
- sk->fdopt, sk->sk_obj, sk->stack_obj);
- return;
- }
- sbr_free_sk (sk);
-}
-
-int sbr_init_res ();
-
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-#endif
diff --git a/stacks/lwip_stack/src/sbr/sbr_socket.c b/stacks/lwip_stack/src/sbr/sbr_socket.c
deleted file mode 100644
index 69481b5..0000000
--- a/stacks/lwip_stack/src/sbr/sbr_socket.c
+++ /dev/null
@@ -1,1274 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include <dlfcn.h>
-#include "sbr_protocol_api.h"
-#include "sbr_res_mgr.h"
-#include "nstack_log.h"
-#include "nstack_dmm_api.h"
-
-#define SBR_INTERCEPT(ret, name, args) ret sbr_ ## name args
-#define CALL_SBR_INTERCEPT(name, args) sbr_ ## name args
-#define GET_SBR_INTERCEPT(name) sbr_ ## name
-
-/*****************************************************************************
-* Prototype : SBR_INTERCEPT
-* Description : create socket
-* Input : int
-* socket
-* (int domain
-* int type
-* int protocol)
-* Output : None
-* Return Value :
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-SBR_INTERCEPT (int, socket, (int domain, int type, int protocol))
-{
- NSSBR_LOGDBG ("socket]domain=%d,type=%d,protocol=%d", domain, type,
- protocol);
- sbr_fdopt *fdopt = sbr_get_fdopt (domain, type, protocol);
-
- if (!fdopt)
- {
- return -1;
- }
-
- sbr_socket_t *sk = sbr_malloc_sk ();
-
- if (!sk)
- {
- return -1;
- }
-
- sk->fdopt = fdopt;
-
- int ret = sk->fdopt->socket (sk, domain, type, protocol);
-
- if (ret != 0)
- {
- sbr_free_sk (sk);
- return ret;
- }
-
- return sk->fd;
-}
-
-/*****************************************************************************
-* Prototype : sbr_check_addr
-* Description : check addr
-* Input : int s
-* struct sockaddr * addr
-* socklen_t * addrlen
-* Output : None
-* Return Value : static inline int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline int
-sbr_check_addr (int s, struct sockaddr *addr, socklen_t * addrlen)
-{
- if (addr)
- {
- if (!addrlen)
- {
- NSSBR_LOGERR ("addrlen is null]fd=%d", s);
- sbr_set_errno (EFAULT);
- return -1;
- }
-
- if (0 > (int) (*addrlen))
- {
- NSSBR_LOGERR ("addrlen is negative]fd=%d,addrlen=%d", s, *addrlen);
- sbr_set_errno (EINVAL);
- return -1;
- }
- }
-
- return 0;
-}
-
-/*****************************************************************************
-* Prototype : SBR_INTERCEPT
-* Description : accept4
-* Input : int
-* accept4
-* (int s
-* struct sockaddr * addr
-* socklen_t * addrlen
-* int flags)
-* Output : None
-* Return Value :
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-SBR_INTERCEPT (int, accept4,
- (int s, struct sockaddr * addr, socklen_t * addrlen,
- int flags))
-{
- NSSBR_LOGDBG ("accept4]fd=%d,addr=%p,addrlen=%p,flags=%d", s, addr, addrlen,
- flags);
- int ret = sbr_check_addr (s, addr, addrlen);
-
- if (ret != 0)
- {
- return ret;
- }
-
- sbr_socket_t *sk = sbr_lookup_sk (s);
-
- if (!sk)
- {
- return -1;
- }
-
- sbr_socket_t *new_sk = sbr_malloc_sk ();
- if (!new_sk)
- {
- return -1;
- }
-
- new_sk->fdopt = sk->fdopt;
-
- ret = sk->fdopt->accept4 (sk, new_sk, addr, addrlen, flags);
- if (-1 == ret)
- {
- sbr_free_sk (new_sk);
- }
-
- return ret;
-}
-
-/*****************************************************************************
-* Prototype : SBR_INTERCEPT
-* Description : accept
-* Input : int
-* accept
-* (int s
-* struct sockaddr * addr
-* socklen_t * addrlen)
-* Output : None
-* Return Value :
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-SBR_INTERCEPT (int, accept,
- (int s, struct sockaddr * addr, socklen_t * addrlen))
-{
- NSSBR_LOGDBG ("accept]fd=%d,addr=%p,addrlen=%p", s, addr, addrlen);
- int ret = sbr_check_addr (s, addr, addrlen);
-
- if (ret != 0)
- {
- return ret;
- }
-
- sbr_socket_t *sk = sbr_lookup_sk (s);
-
- if (!sk)
- {
- return -1;
- }
-
- sbr_socket_t *new_sk = sbr_malloc_sk ();
- if (!new_sk)
- {
- return -1;
- }
-
- new_sk->fdopt = sk->fdopt;
-
- ret = sk->fdopt->accept (sk, new_sk, addr, addrlen);
- if (-1 == ret)
- {
- sbr_free_sk (new_sk);
- }
-
- return ret;
-}
-
-/*****************************************************************************
-* Prototype : SBR_INTERCEPT
-* Description : bind
-* Input : int
-* bind
-* (int s
-* const struct sockaddr * name
-* socklen_t namelen)
-* Output : None
-* Return Value :
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-SBR_INTERCEPT (int, bind,
- (int s, const struct sockaddr * name, socklen_t namelen))
-{
- NSSBR_LOGDBG ("bind]fd=%d,name=%p,namelen=%d", s, name, namelen);
- if (!name)
- {
- NSSBR_LOGERR ("name is not ok]fd=%d,name=%p", s, name);
- sbr_set_errno (EFAULT);
- return -1;
- }
-
- if ((name->sa_family) != AF_INET)
- {
- NSSBR_LOGERR ("domain is not AF_INET]fd=%d,name->sa_family=%u", s,
- name->sa_family);
- sbr_set_errno (EAFNOSUPPORT);
- return -1;
- }
-
- if (namelen != sizeof (struct sockaddr_in))
- {
- NSSBR_LOGERR ("namelen is invalid]fd=%d,namelen=%d", s, namelen);
- sbr_set_errno (EINVAL);
- return -1;
- }
-
- sbr_socket_t *sk = sbr_lookup_sk (s);
-
- if (!sk)
- {
- return -1;
- }
-
- return sk->fdopt->bind (sk, name, namelen);
-}
-
-/*****************************************************************************
-* Prototype : SBR_INTERCEPT
-* Description : listen
-* Input : int
-* listen
-* (int s
-* int backlog)
-* Output : None
-* Return Value :
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-SBR_INTERCEPT (int, listen, (int s, int backlog))
-{
- NSSBR_LOGDBG ("listen]fd=%d,backlog=%d", s, backlog);
- sbr_socket_t *sk = sbr_lookup_sk (s);
-
- if (!sk)
- {
- return -1;
- }
-
- /* limit the "backlog" parameter to fit in an u8_t */
- if (backlog < 0)
- {
- backlog = 0;
- }
-
- if (backlog > 0xff)
- {
- backlog = 0xff;
- }
-
- return sk->fdopt->listen (sk, backlog);
-}
-
-/*****************************************************************************
-* Prototype : SBR_INTERCEPT
-* Description : connect
-* Input : int
-* connect
-* (int s
-* const struct sockaddr * name
-* socklen_t namelen)
-* Output : None
-* Return Value :
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-SBR_INTERCEPT (int, connect,
- (int s, const struct sockaddr * name, socklen_t namelen))
-{
- NSSBR_LOGDBG ("connect]fd=%d,name=%p,namelen=%d", s, name, namelen);
- if (!name)
- {
- NSSBR_LOGERR ("name is null]fd=%d", s);
- sbr_set_errno (EFAULT);
- return -1;
- }
-
- if (!
- (namelen == sizeof (struct sockaddr_in)
- && (name->sa_family == AF_INET)))
- {
- NSSBR_LOGERR ("parameter invalid]fd=%d,domain=%u,namelen=%d", s,
- name->sa_family, namelen);
- sbr_set_errno (EINVAL);
- return -1;
- }
-
- sbr_socket_t *sk = sbr_lookup_sk (s);
-
- if (!sk)
- {
- NSSBR_LOGERR ("get socket failed]fd=%d", s);
- return -1;
- }
-
- return sk->fdopt->connect (sk, name, namelen);
-}
-
-/*****************************************************************************
-* Prototype : sbr_check_sock_name
-* Description : check name
-* Input : int s
-* struct sockaddr * name
-* socklen_t * namelen
-* Output : None
-* Return Value : static inline int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline int
-sbr_check_sock_name (int s, struct sockaddr *name, socklen_t * namelen)
-{
- if (!name || !namelen)
- {
- NSSBR_LOGERR ("name or namelen is null]fd=%d", s);
- sbr_set_errno (EINVAL);
- return -1;
- }
-
- if (*namelen & 0x80000000)
- {
- NSSBR_LOGERR ("namelen is not ok]fd=%d,namelen=%d", s, *namelen);
- sbr_set_errno (EINVAL);
- return -1;
- }
-
- return 0;
-}
-
-/*****************************************************************************
-* Prototype : SBR_INTERCEPT
-* Description : getpeername
-* Input : int
-* getpeername
-* (int s
-* struct sockaddr * name
-* socklen_t * namelen)
-* Output : None
-* Return Value :
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-SBR_INTERCEPT (int, getpeername,
- (int s, struct sockaddr * name, socklen_t * namelen))
-{
- NSSBR_LOGDBG ("getpeername]fd=%d", s);
- int ret = sbr_check_sock_name (s, name, namelen);
-
- if (ret != 0)
- {
- return ret;
- }
-
- sbr_socket_t *sk = sbr_lookup_sk (s);
-
- if (!sk)
- {
- return -1;
- }
-
- sk->fdopt->lock_common (sk);
- ret = sk->fdopt->getpeername (sk, name, namelen);
- sk->fdopt->unlock_common (sk);
- return ret;
-}
-
-/*****************************************************************************
-* Prototype : SBR_INTERCEPT
-* Description : getsockname
-* Input : int
-* getsockname
-* (int s
-* struct sockaddr * name
-* socklen_t * namelen)
-* Output : None
-* Return Value :
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-SBR_INTERCEPT (int, getsockname,
- (int s, struct sockaddr * name, socklen_t * namelen))
-{
- NSSBR_LOGDBG ("getsockname]fd=%d", s);
- int ret = sbr_check_sock_name (s, name, namelen);
-
- if (ret != 0)
- {
- return ret;
- }
-
- sbr_socket_t *sk = sbr_lookup_sk (s);
-
- if (!sk)
- {
- return -1;
- }
-
- sk->fdopt->lock_common (sk);
- ret = sk->fdopt->getsockname (sk, name, namelen);
- sk->fdopt->unlock_common (sk);
- return ret;
-}
-
-/*****************************************************************************
-* Prototype : SBR_INTERCEPT
-* Description : setsockopt
-* Input : int
-* setsockopt
-* (int s
-* int level
-* int optname
-* const void * optval
-* socklen_t optlen)
-* Output : None
-* Return Value :
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-SBR_INTERCEPT (int, setsockopt,
- (int s, int level, int optname, const void *optval,
- socklen_t optlen))
-{
- NSSBR_LOGDBG ("setsockopt]fd=%d,level=%d,optname=%d,optval=%p,optlen=%d", s,
- level, optname, optval, optlen);
- if (!optval)
- {
- NSSBR_LOGERR ("optval is null]fd=%d", s);
- sbr_set_errno (EFAULT);
- return -1;
- }
-
- sbr_socket_t *sk = sbr_lookup_sk (s);
-
- if (!sk)
- {
- return -1;
- }
-
- sk->fdopt->lock_common (sk);
- int ret = sk->fdopt->setsockopt (sk, level, optname, optval, optlen);
- sk->fdopt->unlock_common (sk);
- return ret;
-}
-
-/*****************************************************************************
-* Prototype : SBR_INTERCEPT
-* Description : getsockopt
-* Input : int
-* getsockopt
-* (int s
-* int level
-* int optname
-* void * optval
-* socklen_t * optlen)
-* Output : None
-* Return Value :
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-SBR_INTERCEPT (int, getsockopt,
- (int s, int level, int optname, void *optval,
- socklen_t * optlen))
-{
- NSSBR_LOGDBG ("getsockopt]fd=%d,level=%d,optname=%d,optval=%p,optlen=%p", s,
- level, optname, optval, optlen);
- if (!optval || !optlen)
- {
- NSSBR_LOGERR ("optval or optlen is NULL]fd=%d", s);
- sbr_set_errno (EFAULT);
- return -1;
- }
-
- sbr_socket_t *sk = sbr_lookup_sk (s);
-
- if (!sk)
- {
- return -1;
- }
-
- sk->fdopt->lock_common (sk);
- int ret = sk->fdopt->getsockopt (sk, level, optname, optval, optlen);
- sk->fdopt->unlock_common (sk);
- return ret;
-}
-
-/*****************************************************************************
-* Prototype : SBR_INTERCEPT
-* Description : ioctl
-* Input : int
-* ioctl
-* (int s
-* unsigned long cmd
-* ...)
-* Output : None
-* Return Value :
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-SBR_INTERCEPT (int, ioctl, (int s, unsigned long cmd, ...))
-{
- NSSBR_LOGDBG ("ioctl]fd=%d,cmd=%lu", s, cmd);
- va_list va;
- va_start (va, cmd);
- void *arg = va_arg (va, void *);
- va_end (va);
-
- if (!arg)
- {
- NSSBR_LOGERR ("parameter is not ok]fd=%d", s);
- sbr_set_errno (EINVAL);
- return -1;
- }
-
- sbr_socket_t *sk = sbr_lookup_sk (s);
-
- if (!sk)
- {
- return -1;
- }
-
- sk->fdopt->lock_common (sk);
- int ret = sk->fdopt->ioctl (sk, cmd, arg);
- sk->fdopt->unlock_common (sk);
- return ret;
-}
-
-/*****************************************************************************
-* Prototype : SBR_INTERCEPT
-* Description : fcntl
-* Input : int
-* fcntl
-* (int s
-* int cmd
-* ...)
-* Output : None
-* Return Value :
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-SBR_INTERCEPT (int, fcntl, (int s, int cmd, ...))
-{
- NSSBR_LOGDBG ("fcntl]fd=%d,cmd=%d", s, cmd);
- sbr_socket_t *sk = sbr_lookup_sk (s);
-
- if (!sk)
- {
- return -1;
- }
-
- va_list va;
- va_start (va, cmd);
- long arg = va_arg (va, long);
- va_end (va);
-
- sk->fdopt->lock_common (sk);
- int ret = sk->fdopt->fcntl (sk, cmd, arg);
- sk->fdopt->unlock_common (sk);
- return ret;
-}
-
-/*****************************************************************************
-* Prototype : SBR_INTERCEPT
-* Description : recvfrom
-* Input : int
-* recvfrom
-* (int s
-* void * mem
-* size_t len
-* int flags
-* struct sockaddr * from
-* socklen_t * fromlen)
-* Output : None
-* Return Value :
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-SBR_INTERCEPT (int, recvfrom,
- (int s, void *mem, size_t len, int flags,
- struct sockaddr * from, socklen_t * fromlen))
-{
- NSSBR_LOGDBG ("recvfrom]fd=%d,mem=%p,len=%d,flags=%d,from=%p,fromlen=%p", s,
- mem, len, flags, from, fromlen);
-
- if (0 == len)
- {
- NSSBR_LOGDBG ("len is zero]fd=%d,len=%u", s, (u32) len);
- return 0; //return directly, don't change the last errno.
- }
-
- if (!mem)
- {
- NSSBR_LOGERR ("mem is NULL]fd=%d", s);
- sbr_set_errno (EFAULT);
- return -1;
- }
-
- if (fromlen && (*((int *) fromlen) < 0))
- {
- NSSBR_LOGERR ("fromlen is not ok]fd=%d,fromlen=%d", s, *fromlen);
- sbr_set_errno (EINVAL);
- return -1;
- }
-
- sbr_socket_t *sk = sbr_lookup_sk (s);
-
- if (!sk)
- {
- return -1;
- }
-
- return sk->fdopt->recvfrom (sk, mem, len, flags, from, fromlen);
-}
-
-/*****************************************************************************
-* Prototype : SBR_INTERCEPT
-* Description : read
-* Input : int
-* read
-* (int s
-* void * mem
-* size_t len)
-* Output : None
-* Return Value :
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-SBR_INTERCEPT (int, read, (int s, void *mem, size_t len))
-{
- NSSBR_LOGDBG ("read]fd=%d,mem=%p,len=%d", s, mem, len);
- return CALL_SBR_INTERCEPT (recvfrom, (s, mem, len, 0, NULL, NULL));
-}
-
-/*****************************************************************************
-* Prototype : sbr_check_iov
-* Description : check iov
-* Input : int s
-* const struct iovec * iov
-* int iovcnt
-* Output : None
-* Return Value : static inline int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline int
-sbr_check_iov (int s, const struct iovec *iov, int iovcnt)
-{
- if ((!iov) || (iovcnt <= 0))
- {
- NSSBR_LOGERR ("iov is NULL or iovcn <=0]fd=%d", s);
- sbr_set_errno (EFAULT);
- return -1;
- }
-
- int i;
- for (i = 0; i < iovcnt; ++i)
- {
- if (!iov[i].iov_base && (iov[i].iov_len != 0))
- {
- NSSBR_LOGERR ("iov is not ok]fd=%d,iov_base=%p,iov_len=%d", s,
- iov[i].iov_base, iov[i].iov_len);
- sbr_set_errno (EFAULT);
- return -1;
- }
- }
-
- return 0;
-}
-
-/*****************************************************************************
-* Prototype : SBR_INTERCEPT
-* Description : readv
-* Input : int
-* readv
-* (int s
-* const struct iovec * iov
-* int iovcnt)
-* Output : None
-* Return Value :
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-SBR_INTERCEPT (int, readv, (int s, const struct iovec * iov, int iovcnt))
-{
- NSSBR_LOGDBG ("readv]fd=%d,iov=%p,iovcnt=%d", s, iov, iovcnt);
-
- if (sbr_check_iov (s, iov, iovcnt) != 0)
- {
- return -1;
- }
-
- sbr_socket_t *sk = sbr_lookup_sk (s);
-
- if (!sk)
- {
- return -1;
- }
-
- return sk->fdopt->readv (sk, iov, iovcnt);
-}
-
-/*****************************************************************************
-* Prototype : SBR_INTERCEPT
-* Description : recv
-* Input : int
-* recv
-* (int s
-* void * mem
-* size_t len
-* int flags)
-* Output : None
-* Return Value :
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-SBR_INTERCEPT (int, recv, (int s, void *mem, size_t len, int flags))
-{
- NSSBR_LOGDBG ("recv]fd=%d,mem=%p,len=%d,flags=%d", s, mem, len, flags);
- return CALL_SBR_INTERCEPT (recvfrom, (s, mem, len, flags, NULL, NULL));
-}
-
-/*****************************************************************************
-* Prototype : sbr_check_msg
-* Description : check msg
-* Input : int s
-* const struct msghdr * msg
-* Output : None
-* Return Value : static inline int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-static inline int
-sbr_check_msg (int s, const struct msghdr *msg)
-{
- if (!msg)
- {
- NSSBR_LOGERR ("msg is NULL]fd=%d", s);
- sbr_set_errno (EFAULT);
- return -1;
- }
-
- if (msg->msg_name && ((int) msg->msg_namelen < 0))
- {
- NSSBR_LOGERR ("msg_namelen is not ok]fd=%d,msg_namelen=%d", s,
- msg->msg_namelen);
- sbr_set_errno (EINVAL);
- return -1;
- }
-
- return sbr_check_iov (s, msg->msg_iov, msg->msg_iovlen);
-}
-
-/*****************************************************************************
-* Prototype : SBR_INTERCEPT
-* Description : recvmsg
-* Input : int
-* recvmsg
-* (int s
-* struct msghdr * msg
-* int flags)
-* Output : None
-* Return Value :
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-SBR_INTERCEPT (int, recvmsg, (int s, struct msghdr * msg, int flags))
-{
- NSSBR_LOGDBG ("recvmsg]fd=%d,msg=%p,flags=%d", s, msg, flags);
-
- if (sbr_check_msg (s, msg) != 0)
- {
- return -1;
- }
-
- sbr_socket_t *sk = sbr_lookup_sk (s);
-
- if (!sk)
- {
- return -1;
- }
-
- return sk->fdopt->recvmsg (sk, msg, flags);
-}
-
-/*****************************************************************************
-* Prototype : SBR_INTERCEPT
-* Description : send
-* Input : int
-* send
-* (int s
-* const void * data
-* size_t size
-* int flags)
-* Output : None
-* Return Value :
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-SBR_INTERCEPT (int, send, (int s, const void *data, size_t size, int flags))
-{
- NSSBR_LOGDBG ("send]fd=%d,data=%p,size=%zu,flags=%d", s, data, size, flags);
- if (!data)
- {
- NSSBR_LOGERR ("data is NULL]fd=%d", s);
- sbr_set_errno (EFAULT);
- return -1;
- }
-
- sbr_socket_t *sk = sbr_lookup_sk (s);
-
- if (!sk)
- {
- return -1;
- }
-
- return sk->fdopt->send (sk, data, size, flags);
-}
-
-/*****************************************************************************
-* Prototype : SBR_INTERCEPT
-* Description : sendmsg
-* Input : int
-* sendmsg
-* (int s
-* const struct msghdr * msg
-* int flags)
-* Output : None
-* Return Value :
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-SBR_INTERCEPT (int, sendmsg, (int s, const struct msghdr * msg, int flags))
-{
- NSSBR_LOGDBG ("sendmsg]fd=%d,msg=%p,flags=%d", s, msg, flags);
-
- if (sbr_check_msg (s, msg) != 0)
- {
- return -1;
- }
-
- sbr_socket_t *sk = sbr_lookup_sk (s);
-
- if (!sk)
- {
- return -1;
- }
-
- return sk->fdopt->sendmsg (sk, msg, flags);
-}
-
-/*****************************************************************************
-* Prototype : SBR_INTERCEPT
-* Description : sendto
-* Input : int
-* sendto
-* (int s
-* const void * data
-* size_t size
-* int flags
-* const struct sockaddr * to
-* socklen_t tolen)
-* Output : None
-* Return Value :
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-SBR_INTERCEPT (int, sendto,
- (int s, const void *data, size_t size, int flags,
- const struct sockaddr * to, socklen_t tolen))
-{
- NSSBR_LOGDBG ("sendto]fd=%d,data=%p,size=%zu,flags=%d,to=%p,tolen=%d", s,
- data, size, flags, to, tolen);
- if ((data == NULL) || (flags < 0))
- {
- NSSBR_LOGERR ("parameter is not ok]fd=%d,data=%p,size=%zu,flags=%d", s,
- data, size, flags);
- sbr_set_errno (EINVAL);
- return -1;
- }
-
- sbr_socket_t *sk = sbr_lookup_sk (s);
-
- if (!sk)
- {
- return -1;
- }
-
- return sk->fdopt->sendto (sk, data, size, flags, to, tolen);
-}
-
-/*****************************************************************************
-* Prototype : SBR_INTERCEPT
-* Description : write
-* Input : int
-* write
-* (int s
-* const void * data
-* size_t size)
-* Output : None
-* Return Value :
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-SBR_INTERCEPT (int, write, (int s, const void *data, size_t size))
-{
- NSSBR_LOGDBG ("write]fd=%d,data=%p,size=%zu", s, data, size);
- return CALL_SBR_INTERCEPT (send, (s, data, size, 0));
-}
-
-/*****************************************************************************
-* Prototype : SBR_INTERCEPT
-* Description : writev
-* Input : int
-* writev
-* (int s
-* const struct iovec * iov
-* int iovcnt)
-* Output : None
-* Return Value :
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-SBR_INTERCEPT (int, writev, (int s, const struct iovec * iov, int iovcnt))
-{
- NSSBR_LOGDBG ("writev]fd=%d,iov=%p,iovcnt=%d", s, iov, iovcnt);
-
- if (sbr_check_iov (s, iov, iovcnt) != 0)
- {
- return -1;
- }
-
- sbr_socket_t *sk = sbr_lookup_sk (s);
-
- if (!sk)
- {
- return -1;
- }
-
- return sk->fdopt->writev (sk, iov, iovcnt);
-}
-
-/*****************************************************************************
-* Prototype : SBR_INTERCEPT
-* Description : shutdown
-* Input : int
-* shutdown
-* (int s
-* int how)
-* Output : None
-* Return Value :
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-SBR_INTERCEPT (int, shutdown, (int s, int how))
-{
- NSSBR_LOGDBG ("shutdown]fd=%d,how=%d", s, how);
- if ((how != SHUT_RD) && (how != SHUT_WR) && (how != SHUT_RDWR))
- {
- sbr_set_errno (EINVAL);
- return -1;
- }
-
- sbr_socket_t *sk = sbr_lookup_sk (s);
-
- if (!sk)
- {
- return -1;
- }
-
- sk->fdopt->lock_common (sk);
- int ret = sk->fdopt->shutdown (sk, how);
- sk->fdopt->unlock_common (sk);
- return ret;
-}
-
-/*****************************************************************************
-* Prototype : SBR_INTERCEPT
-* Description : close
-* Input : int
-* close
-* (int s)
-* Output : None
-* Return Value :
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-SBR_INTERCEPT (int, close, (int s))
-{
- NSSBR_LOGDBG ("close]fd=%d", s);
- sbr_socket_t *sk = sbr_lookup_sk (s);
-
- if (!sk)
- {
- return -1;
- }
-
- int ret = sk->fdopt->close (sk);
- sbr_free_sk (sk);
- return ret;
-}
-
-SBR_INTERCEPT (int, select,
- (int nfds, fd_set * readfd, fd_set * writefd,
- fd_set * exceptfd, struct timeval * timeout))
-{
- return lwip_try_select (nfds, readfd, writefd, exceptfd, timeout);
-}
-
-SBR_INTERCEPT (unsigned int, ep_getevt,
- (int epfd, int profd, unsigned int events))
-{
- NSSBR_LOGDBG ("epfd= %d, proFD=%d,epi=0x%x", epfd, profd, events);
- sbr_socket_t *sk = sbr_lookup_sk (profd);
-
- if (!sk)
- {
- return -1;
- }
-
- return sk->fdopt->ep_getevt (sk, events);
-}
-
-SBR_INTERCEPT (unsigned int, ep_ctl,
- (int epfd, int profd, int triggle_ops,
- struct epoll_event * event, void *pdata))
-{
- NSSBR_LOGDBG ("epfd = %d, proFD=%d,triggle_ops=%d,pdata=%p", epfd, profd,
- triggle_ops, pdata);
- sbr_socket_t *sk = sbr_lookup_sk (profd);
-
- if (!sk)
- {
- return -1;
- }
-
- return sk->fdopt->ep_ctl (sk, triggle_ops, event, pdata);
-}
-
-SBR_INTERCEPT (int, peak, (int s))
-{
- NSSBR_LOGDBG ("]fd=%d", s);
- sbr_socket_t *sk = sbr_lookup_sk (s);
-
- if (!sk)
- {
- return -1;
- }
-
- return sk->fdopt->peak (sk);
-}
-
-/*****************************************************************************
-* Prototype : SBR_INTERCEPT
-* Description : set_app_info
-* Input : int
-* set_app_info
-* (int s
-* void* app_info)
-* Output : None
-* Return Value :
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-SBR_INTERCEPT (void, set_app_info, (int s, void *app_info))
-{
- NSSBR_LOGDBG ("set_app_info]fd=%d", s);
-
- if (!app_info)
- {
- NSSBR_LOGERR ("invalid param, app_info is NULL]");
- return;
- }
-
- sbr_socket_t *sk = sbr_lookup_sk (s);
- if (!sk)
- {
- return;
- }
-
- sk->fdopt->set_app_info (sk, app_info);
-}
-
-/* app send its version info to nStackMain */
-/*****************************************************************************
-* Prototype : SBR_INTERCEPT
-* Description : sbr_app_touch
-* Input : int
-* sbr_app_touch
-* ()
-* Output : None
-* Return Value :
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-SBR_INTERCEPT (void, app_touch, (void))
-{
- NSSBR_LOGDBG ("sbr_app_touch() is called]");
-
- sbr_app_touch_in ();
-}
-
-/*****************************************************************************
-* Prototype : SBR_INTERCEPT
-* Description : set_close_status
-* Input : void
-* set_close_stat
-* (int s
-* int flag)
-* Output : None
-* Return Value :
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-SBR_INTERCEPT (void, set_close_stat, (int s, int flag))
-{
- NSSBR_LOGDBG ("]fd=%d", s);
- sbr_socket_t *sk = sbr_lookup_sk (s);
-
- if (!sk)
- {
- return;
- }
- if (sk->fdopt->set_close_stat)
- {
- sk->fdopt->set_close_stat (sk, flag);
- }
-
-}
-
-SBR_INTERCEPT (int, fd_alloc, ())
-{
- return sbr_socket (AF_INET, SOCK_STREAM, 0);
-}
-
-SBR_INTERCEPT (int, fork_init_child, (pid_t p, pid_t c))
-{
- NSSBR_LOGDBG ("fork_init_child() is called]");
- return sbr_fork_protocol ();
-}
-
-SBR_INTERCEPT (void, fork_parent_fd, (int s, pid_t p))
-{
- NSSBR_LOGDBG ("fork_parent_fd() is called]");
- sbr_socket_t *sk = sbr_lookup_sk (s);
-
- if (!sk)
- {
- return;
- }
-
- sk->fdopt->fork_parent (sk, p);
-}
-
-SBR_INTERCEPT (void, fork_child_fd, (int s, pid_t p, pid_t c))
-{
- NSSBR_LOGDBG ("fork_child_fd() is called]");
- sbr_socket_t *sk = sbr_lookup_sk (s);
-
- if (!sk)
- {
- return;
- }
-
- sk->fdopt->fork_child (sk, p, c);
-
-}
-
-SBR_INTERCEPT (void, fork_free_fd, (int s, pid_t p, pid_t c))
-{
- NSSBR_LOGDBG ("fork_free_fd() is called]");
- sbr_free_fd (s);
-}
-
-/*****************************************************************************
-* Prototype : nstack_stack_register
-* Description : reg api to nsocket
-* Input : nstack_socket_ops* ops
-* nstack_event_ops *val
-* nstack_proc_ops *deal
-* Output : None
-* Return Value : int
-* Calls :
-* Called By :
-*
-*****************************************************************************/
-int
-lwip_stack_register (nstack_proc_cb * ops, nstack_event_cb * val)
-{
- if (!ops || !val || !val->handle)
- {
- return -1;
- }
-
-#undef NSTACK_MK_DECL
-#define NSTACK_MK_DECL(ret, fn, args) \
- (ops->socket_ops).pf ## fn = (typeof(((nstack_socket_ops*)0)->pf ## fn))dlsym(val->handle, "sbr_" # fn);
-#include "declare_syscalls.h"
-
- (ops->extern_ops).module_init = sbr_init_res;
- (ops->extern_ops).ep_getevt = GET_SBR_INTERCEPT (ep_getevt);
- (ops->extern_ops).ep_ctl = GET_SBR_INTERCEPT (ep_ctl);
- (ops->extern_ops).peak = GET_SBR_INTERCEPT (peak);
- (ops->extern_ops).stack_alloc_fd = GET_SBR_INTERCEPT (fd_alloc); /*alloc a fd id for epoll */
- (ops->extern_ops).fork_init_child = GET_SBR_INTERCEPT (fork_init_child);
- (ops->extern_ops).fork_parent_fd = GET_SBR_INTERCEPT (fork_parent_fd);
- (ops->extern_ops).fork_child_fd = GET_SBR_INTERCEPT (fork_child_fd);
- (ops->extern_ops).fork_free_fd = GET_SBR_INTERCEPT (fork_free_fd);
- return 0;
-}
diff --git a/stacks/lwip_stack/src/tools/CMakeLists.txt b/stacks/lwip_stack/src/tools/CMakeLists.txt
deleted file mode 100644
index bd485b8..0000000
--- a/stacks/lwip_stack/src/tools/CMakeLists.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-#########################################################################
-#
-# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-# 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.
-#########################################################################
-
-FILE(GLOB_RECURSE Tcpdump *.c)
-ADD_LIBRARY(nTcpdump STATIC ${Tcpdump})
-INCLUDE_DIRECTORIES(
- ${CMAKE_CURRENT_LIST_DIR}/../include
-)
-TARGET_LINK_LIBRARIES(nTcpdump dmm_api) \ No newline at end of file
diff --git a/stacks/lwip_stack/src/tools/dump_tool.c b/stacks/lwip_stack/src/tools/dump_tool.c
deleted file mode 100644
index 53f0e44..0000000
--- a/stacks/lwip_stack/src/tools/dump_tool.c
+++ /dev/null
@@ -1,622 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include <arpa/inet.h>
-
-#include "nsfw_init.h"
-#include "nsfw_maintain_api.h"
-#include "nsfw_mem_api.h"
-#include "nsfw_fd_timer_api.h"
-#include "nstack_log.h"
-#include "nstack_securec.h"
-
-#include "dump_tool.h"
-#include "nstack_dmm_adpt.h"
-
-NSTACK_STATIC u32 g_dump_task_mask = 0;
-NSTACK_STATIC dump_task_info g_dump_task[MAX_DUMP_TASK];
-static dump_timer_info g_dump_timer;
-
-static nsfw_mem_name g_dump_mem_ring_info =
- { NSFW_SHMEM, NSFW_PROC_MAIN, DUMP_SHMEM_RIGN_NAME };
-static nsfw_mem_name g_dump_mem_pool_info =
- { NSFW_SHMEM, NSFW_PROC_MAIN, DUMP_SHMEM_POOL_NAME };
-
-NSTACK_STATIC inline void
-dump_task_init (dump_task_info * task)
-{
- task->task_state = 0;
- task->task_id = -1;
- task->task_keep_time = 0;
- task->task_pool = NULL;
- task->task_queue = NULL;
-}
-
-NSTACK_STATIC inline void
-clear_dump_task ()
-{
- int i = 0;
- for (; i < MAX_DUMP_TASK; i++)
- {
- dump_task_init (&g_dump_task[i]);
- }
-}
-
-NSTACK_STATIC i16
-get_dump_task (nsfw_tool_dump_msg * req)
-{
- // base version just support 1 dump task
- if (req->task_keep_time > MAX_DUMP_TIME
- || req->task_keep_time < MIN_DUMP_TIME)
- {
- NSPOL_DUMP_LOGERR ("task keep time invalid] time=%u.",
- req->task_keep_time);
- return -1;
- }
-
- if (1 == g_dump_task[0].task_state)
- {
- NSPOL_DUMP_LOGERR
- ("start tcpdump task failed, task still in work state] task id=%d.",
- 0);
- return -1;
- }
-
- struct timespec cur_time;
- GET_CUR_TIME (&cur_time); /*do not need return value */
- g_dump_task[0].task_start_sec = cur_time.tv_sec;
- g_dump_task[0].last_hbt_sec = cur_time.tv_sec;
-
- g_dump_task[0].task_state = 1;
- g_dump_task[0].task_id = 0;
- g_dump_task[0].task_keep_time = req->task_keep_time;
-
- g_dump_task_mask |= (1 << g_dump_task[0].task_id);
- NSPOL_DUMP_LOGINF ("start tcpdump task success] task id=%d.", 0);
- return 0;
-}
-
-NSTACK_STATIC i16
-close_dump_task (i16 task_id)
-{
- if (task_id < 0 || task_id >= MAX_DUMP_TASK)
- {
- NSPOL_DUMP_LOGERR
- ("receive invalid task id in close dump task req] task id=%d.",
- task_id);
- return -1;
- }
-
- g_dump_task[task_id].task_state = 0;
-
- g_dump_task_mask &= ~(1 << task_id);
-
- NSPOL_DUMP_LOGINF ("stop tcpdump task success] task id=%d.", 0);
-
- return task_id;
-}
-
-NSTACK_STATIC void
-stop_expired_task (int idx, u32 now_sec)
-{
- dump_task_info *ptask = &g_dump_task[idx];
- if (0 == ptask->task_state)
- {
- return;
- }
-
- if (now_sec - ptask->task_start_sec > ptask->task_keep_time)
- {
- NSPOL_DUMP_LOGERR
- ("stop dump task because task time expired] task id=%d, now_sec=%u, task start time=%u, dump time=%u.",
- ptask->task_id, now_sec, ptask->task_start_sec,
- ptask->task_keep_time);
- close_dump_task (ptask->task_id);
- return;
- }
-
- if (now_sec - ptask->last_hbt_sec > DUMP_TASK_HBT_TIME_OUT)
- {
- NSPOL_DUMP_LOGERR
- ("stop dump task because heart beat time out] task id=%d, now_sec=%u, last hbt time=%u, hbt timeout=%u.",
- ptask->task_id, now_sec, ptask->last_hbt_sec,
- DUMP_TASK_HBT_TIME_OUT);
- close_dump_task (ptask->task_id);
- }
-
- return;
-}
-
-NSTACK_STATIC inline bool
-check_dump_alive (u32 timer_type, void *data)
-{
- dump_timer_info *ptimer_info = (dump_timer_info *) data;
-
- struct timespec cur_time;
- GET_CUR_TIME (&cur_time); /*do not need return value */
-
- int i = 0;
- for (; i < MAX_DUMP_TASK; i++)
- {
- stop_expired_task (i, cur_time.tv_sec);
- }
-
- ptimer_info->ptimer =
- nsfw_timer_reg_timer (1, ptimer_info, check_dump_alive,
- *(struct timespec *) (ptimer_info->interval));
-
- return true;
-}
-
-NSTACK_STATIC bool
-dump_init_timer (dump_timer_info * ptimer_info)
-{
- struct timespec *trigger_time =
- (struct timespec *) malloc (sizeof (struct timespec));
- if (NULL == trigger_time)
- {
- NSPOL_DUMP_LOGERR ("alloc memory for timer failed.");
- return false;
- }
-
- trigger_time->tv_sec = DUMP_HBT_CHK_INTERVAL;
- trigger_time->tv_nsec = 0;
-
- ptimer_info->interval = trigger_time;
- ptimer_info->ptimer =
- nsfw_timer_reg_timer (1, ptimer_info, check_dump_alive, *trigger_time);
- return true;
-}
-
-NSTACK_STATIC inline u32
-copy_limit_buf (char *dst_buf, int dst_buf_len, char *src_buf,
- u32 src_buf_len, u32 limit_len)
-{
- if (src_buf_len < limit_len)
- {
- NSPOL_DUMP_LOGERR ("message too short] len=%d", src_buf_len);
- return 0;
- }
-
- if (EOK != MEMCPY_S (dst_buf, dst_buf_len, src_buf, limit_len))
- {
- NSPOL_DUMP_LOGERR ("MEMCPY_S failed");
- return 0;
- }
-
- return limit_len;
-}
-
-NSTACK_STATIC inline u32
-get_packet_buf (char *dst_buf, int dst_buf_len, char *src_buf,
- u32 src_buf_len, u32 eth_head_len)
-{
-#define TCP_BUF_LEN (eth_head_len + IP_HEAD_LEN + TCP_HEAD_LEN)
-#define UDP_BUF_LEN (eth_head_len + IP_HEAD_LEN + UDP_HEAD_LEN)
-#define ICMP_BUF_LEN (eth_head_len + IP_HEAD_LEN + ICMP_HEAD_LEN)
-
- if (NULL == dst_buf || NULL == src_buf)
- {
- return 0;
- }
-
- struct ip_hdr *ip_head = (struct ip_hdr *) (src_buf + eth_head_len);
- if (ip_head->_proto == IP_PROTO_TCP)
- {
- return copy_limit_buf (dst_buf, dst_buf_len, src_buf, src_buf_len,
- TCP_BUF_LEN);
- }
-
- if (ip_head->_proto == IP_PROTO_UDP)
- {
- return copy_limit_buf (dst_buf, dst_buf_len, src_buf, src_buf_len,
- UDP_BUF_LEN);
- }
-
- if (ip_head->_proto == IP_PROTO_ICMP)
- {
- return copy_limit_buf (dst_buf, dst_buf_len, src_buf, src_buf_len,
- ICMP_BUF_LEN);
- }
-
- if (EOK != MEMCPY_S (dst_buf, dst_buf_len, src_buf, src_buf_len))
- {
- NSPOL_DUMP_LOGERR ("MEMCPY_S failed");
- return 0;
- }
-
- return src_buf_len;
-}
-
-NSTACK_STATIC int
-pack_msg_inout (void *dump_buf, char *msg_buf, u32 len, u16 direction,
- void *para)
-{
- (void) para;
- dump_msg_info *pmsg = (dump_msg_info *) dump_buf;
- if (!pmsg)
- {
- return 0;
- }
-
- pmsg->direction = direction;
- struct timeval cur_time;
- gettimeofday (&cur_time, NULL);
- pmsg->dump_sec = cur_time.tv_sec;
- pmsg->dump_usec = cur_time.tv_usec;
-
- /* msg content can not be captured */
- u32 real_len =
- get_packet_buf (pmsg->buf, DUMP_MSG_SIZE, msg_buf, len, ETH_HEAD_LEN);
- if (0 == real_len)
- {
- return 0;
- }
-
- pmsg->len = real_len;
-
- return 1;
-}
-
-NSTACK_STATIC int
-pack_msg_loop (void *dump_buf, char *msg_buf, u32 len, u16 direction,
- void *para)
-{
- dump_msg_info *pmsg = (dump_msg_info *) dump_buf;
- if (!pmsg)
- {
- return 0;
- }
- pmsg->direction = direction;
- struct timeval cur_time;
- gettimeofday (&cur_time, NULL);
- pmsg->dump_sec = cur_time.tv_sec;
- pmsg->dump_usec = cur_time.tv_usec;
-
- eth_head pack_eth_head;
- int retVal =
- MEMCPY_S (pack_eth_head.dest_mac, MAC_ADDR_LEN, para, MAC_ADDR_LEN);
- if (EOK != retVal)
- {
- NSPOL_DUMP_LOGERR ("MEMCPY_S failed]retVal=%d", retVal);
- return 0;
- }
- retVal = MEMCPY_S (pack_eth_head.src_mac, MAC_ADDR_LEN, para, MAC_ADDR_LEN);
- if (EOK != retVal)
- {
- NSPOL_DUMP_LOGERR ("MEMCPY_S failed]retVal=%d", retVal);
- return 0;
- }
- pack_eth_head.eth_type = htons (PROTOCOL_IP);
-
- retVal =
- MEMCPY_S (pmsg->buf, DUMP_MSG_SIZE, &pack_eth_head, sizeof (eth_head));
- if (EOK != retVal)
- {
- NSPOL_DUMP_LOGERR ("MEMCPY_S failed]retVal=%d", retVal);
- return 0;
- }
-
- u32 buf_len = DUMP_MSG_SIZE - ETH_HEAD_LEN;
-
- /* msg content can not be captured- Begin */
- u32 real_len =
- get_packet_buf (pmsg->buf + ETH_HEAD_LEN, buf_len, msg_buf, len, 0);
- if (0 == real_len)
- {
- return 0;
- }
-
- pmsg->len = real_len + ETH_HEAD_LEN;
-
- return 1;
-}
-
-NSTACK_STATIC void
-dump_enqueue (int task_idx, void *buf, u32 len, u16 direction,
- pack_msg_fun pack_msg, void *para)
-{
- mring_handle queue = (mring_handle *) g_dump_task[task_idx].task_queue;
- mring_handle pool = (mring_handle *) g_dump_task[task_idx].task_pool;
-
- void *msg = NULL;
-
- if (nsfw_mem_ring_dequeue (pool, &msg) <= 0)
- {
- // such log may be too much if queue is empty
- NSPOL_DUMP_LOGDBG ("get msg node from mem pool failed] pool=%p.", pool);
- return;
- }
-
- if (NULL == msg)
- {
- NSPOL_DUMP_LOGWAR ("get NULL msg node from mem pool] pool=%p.", pool);
- return;
- }
-
- if (!pack_msg (msg, buf, len, direction, para))
- {
- NSPOL_DUMP_LOGWAR ("get dump msg failed");
- return;
- }
-
- if (nsfw_mem_ring_enqueue (queue, msg) < 0)
- {
- NSPOL_DUMP_LOGWAR ("dump mem ring enqueue failed] ring=%p.", queue);
- }
-
- return;
-}
-
-NSTACK_STATIC inline bool
-dump_enabled ()
-{
- return (0 != g_dump_task_mask);
-}
-
-void
-ntcpdump (void *buf, u32 buf_len, u16 direction)
-{
- u32 i;
- if (!dump_enabled ())
- {
- return;
- }
-
- /* fix Dead-code type Codedex issue here */
- for (i = 0; i < MAX_DUMP_TASK; i++)
- {
- if (g_dump_task[i].task_state)
- {
- dump_enqueue (i, buf, buf_len, direction, pack_msg_inout, NULL);
- }
- }
-}
-
-void
-ntcpdump_loop (void *buf, u32 buf_len, u16 direction, void *eth_addr)
-{
- u32 i;
-
- if (!dump_enabled ())
- {
- return;
- }
-
- /* fix Dead-code type Codedex issue here */
- for (i = 0; i < MAX_DUMP_TASK; i++)
- {
- if (g_dump_task[i].task_state)
- {
- dump_enqueue (i, buf, buf_len, direction, pack_msg_loop, eth_addr);
- }
- }
-}
-
-// called by nStackMain
-bool
-dump_create_pool ()
-{
- nsfw_mem_sppool pool_info;
- if (EOK !=
- MEMCPY_S (&pool_info.stname, sizeof (nsfw_mem_name),
- &g_dump_mem_pool_info, sizeof (nsfw_mem_name)))
- {
- NSPOL_DUMP_LOGERR ("create dump mem pool failed, MEMCPY_S failed.");
- return false;
- }
-
- pool_info.usnum = DUMP_MSG_NUM;
- pool_info.useltsize = DUMP_MSG_SIZE + sizeof (dump_msg_info);
- pool_info.isocket_id = NSFW_SOCKET_ANY;
- pool_info.enmptype = NSFW_MRING_MPSC;
-
- mring_handle pool = nsfw_mem_sp_create (&pool_info);
- if (NULL == pool)
- {
- NSPOL_DUMP_LOGERR ("create dump mem pool failed, pool create failed.");
- return false;
- }
-
- g_dump_task[0].task_pool = pool;
-
- NSPOL_DUMP_LOGINF ("dump pool create success] pool=%p.", pool);
-
- return true;
-}
-
-bool
-dump_create_ring ()
-{
- nsfw_mem_mring ring_info;
- if (EOK !=
- MEMCPY_S (&ring_info.stname, sizeof (nsfw_mem_name),
- &g_dump_mem_ring_info, sizeof (nsfw_mem_name)))
- {
- NSPOL_DUMP_LOGERR ("create dump mem ring failed, MEMCPY_S failed.");
- return false;
- }
-
- ring_info.usnum = DUMP_MSG_NUM;
- ring_info.isocket_id = NSFW_SOCKET_ANY;
- ring_info.enmptype = NSFW_MRING_MPSC;
-
- mring_handle ring = nsfw_mem_ring_create (&ring_info);
- if (NULL == ring)
- {
- NSPOL_DUMP_LOGERR ("create dump mem ring failed, ring create failed.");
- return false;
- }
-
- g_dump_task[0].task_queue = ring;
-
- NSPOL_DUMP_LOGINF ("dump ring create success] ring=%p.", ring);
-
- return true;
-}
-
-NSTACK_STATIC int
-on_dump_tool_req (nsfw_mgr_msg * req)
-{
- i16 task_id = 0;
- if (!req)
- {
- return -1;
- }
- if (req->src_proc_type != NSFW_PROC_TOOLS)
- {
- NSPOL_DUMP_LOGDBG
- ("dump module receive invaild message] module type=%u.",
- req->src_proc_type);
- return -1;
- }
-
- if (req->msg_type != MGR_MSG_TOOL_TCPDUMP_REQ)
- {
- NSPOL_DUMP_LOGDBG ("dump module receive invaild message] msg type=%u.",
- req->msg_type);
- return -1;
- }
-
- nsfw_tool_dump_msg *dump_msg_req = GET_USER_MSG (nsfw_tool_dump_msg, req);
-
- switch (dump_msg_req->op_type)
- {
- case START_DUMP_REQ:
- task_id = get_dump_task (dump_msg_req);
- break;
-
- case STOP_DUMP_REQ:
- task_id = close_dump_task (dump_msg_req->task_id);
- break;
-
- default:
- task_id = -1;
- }
-
- nsfw_mgr_msg *rsp = nsfw_mgr_rsp_msg_alloc (req);
- if (NULL == rsp)
- {
- NSPOL_DUMP_LOGDBG ("alloc response for dump request failed.");
- return -1;
- }
-
- nsfw_tool_dump_msg *dump_msg_rsp = GET_USER_MSG (nsfw_tool_dump_msg, rsp);
- dump_msg_rsp->op_type = dump_msg_req->op_type + DUMP_MSG_TYPE_RSP;
- dump_msg_rsp->task_id = task_id;
-
- nsfw_mgr_send_msg (rsp);
- nsfw_mgr_msg_free (rsp);
- return 0;
-
-}
-
-NSTACK_STATIC int
-on_dump_hbt_req (nsfw_mgr_msg * req)
-{
- if (!req)
- {
- return -1;
- }
- if (req->src_proc_type != NSFW_PROC_TOOLS)
- {
- NSPOL_DUMP_LOGDBG
- ("dump module receive invaild message] module type=%u.",
- req->src_proc_type);
- return -1;
- }
-
- if (req->msg_type != MGR_MSG_TOOL_HEART_BEAT)
- {
- NSPOL_DUMP_LOGDBG ("dump module receive invaild message] msg type=%u.",
- req->msg_type);
- return -1;
- }
-
- nsfw_tool_hbt *dump_hbt_req = GET_USER_MSG (nsfw_tool_hbt, req);
-
- i16 task_id = dump_hbt_req->task_id;
- if (task_id < 0 || task_id >= MAX_DUMP_TASK)
- {
- NSPOL_DUMP_LOGERR ("dump heart beat with invalid task id] task id=%d.",
- task_id);
- return -1;
- }
-
- if (0 == g_dump_task[task_id].task_state)
- {
- NSPOL_DUMP_LOGDBG
- ("dump module receive heart beat but task not enabled] task id=%d.",
- task_id);
- return 0;
- }
-
- struct timespec cur_time;
- GET_CUR_TIME (&cur_time); /*no need return value */
-
- // update task alive time
- g_dump_task[task_id].last_hbt_seq = dump_hbt_req->seq;
- g_dump_task[task_id].last_hbt_sec = cur_time.tv_sec;
-
- return 0;
-}
-
-NSTACK_STATIC int dump_tool_init (void *param);
-NSTACK_STATIC int
-dump_tool_init (void *param)
-{
- u32 proc_type = (u32) ((long long) param);
- NSPOL_DUMP_LOGINF ("dump module init] proc type=%d", proc_type);
-
- switch (proc_type)
- {
- case NSFW_PROC_MAIN:
- nsfw_mgr_reg_msg_fun (MGR_MSG_TOOL_TCPDUMP_REQ, on_dump_tool_req);
- nsfw_mgr_reg_msg_fun (MGR_MSG_TOOL_HEART_BEAT, on_dump_hbt_req);
- break;
- default:
- NSPOL_DUMP_LOGERR ("dump init with unknow module] proc type=%d",
- proc_type);
- return -1;
- }
-
- clear_dump_task ();
-
- if (!dump_create_ring ())
- {
- return -1;
- }
-
- if (!dump_create_pool ())
- {
- return -1;
- }
-
- if (!dump_init_timer (&g_dump_timer))
- {
- return -1;
- }
-
- NSPOL_DUMP_LOGINF ("dump module init success.");
- return 0;
-}
-
-/* *INDENT-OFF* */
-NSFW_MODULE_NAME (TCPDUMP_MODULE)
-NSFW_MODULE_PRIORITY (10)
-NSFW_MODULE_DEPENDS (NSTACK_DMM_MODULE)
-NSFW_MODULE_INIT (dump_tool_init)
-/* *INDENT-ON* */
diff --git a/stacks/lwip_stack/src/tools/dump_tool.h b/stacks/lwip_stack/src/tools/dump_tool.h
deleted file mode 100644
index 8c32523..0000000
--- a/stacks/lwip_stack/src/tools/dump_tool.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _DUMP_TOOL_H_
-#define _DUMP_TOOL_H_
-
-#define IP_PROTO_ICMP 1
-#define IP_PROTO_IGMP 2
-#define IP_PROTO_UDP 17
-#define IP_PROTO_UDPLITE 136
-#define IP_PROTO_TCP 6
-
-#ifndef MAC_ADDR_LEN
-#define MAC_ADDR_LEN 6
-#endif
-
-#ifndef IP_HEAD_LEN
-#define IP_HEAD_LEN 20
-#endif
-#ifndef TCP_HEAD_LEN
-#define TCP_HEAD_LEN 20
-#endif
-#ifndef UDP_HEAD_LEN
-#define UDP_HEAD_LEN 8
-#endif
-
-#ifndef ICMP_HEAD_LEN
-#define ICMP_HEAD_LEN 8
-#endif
-
-typedef struct _dump_task_info
-{
- u16 task_state; // 0:off, 1:on
- i16 task_id;
- u32 task_keep_time;
- u32 task_start_sec;
- u32 last_hbt_seq;
- u32 last_hbt_sec;
- void *task_queue;
- void *task_pool;
-} dump_task_info;
-
-typedef struct _dump_eth_head
-{
- u8 dest_mac[MAC_ADDR_LEN];
- u8 src_mac[MAC_ADDR_LEN];
- u16 eth_type;
-} eth_head;
-
-#define ETH_HEAD_LEN sizeof(eth_head)
-
-struct ip_hdr
-{
- u16 _v_hl_tos;
- u16 _len;
- u16 _id;
- u16 _offset;
- u8 _ttl;
- u8 _proto;
- u16 _chksum;
- u32 src;
- u32 dest;
-};
-
-typedef int (*pack_msg_fun) (void *dump_buf, char *msg_buf, u32 len,
- u16 direction, void *para);
-
-#endif
diff --git a/stacks/lwip_stack/tools/CMakeLists.txt b/stacks/lwip_stack/tools/CMakeLists.txt
deleted file mode 100644
index cfb5615..0000000
--- a/stacks/lwip_stack/tools/CMakeLists.txt
+++ /dev/null
@@ -1,91 +0,0 @@
-#########################################################################
-#
-# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-# 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.
-#########################################################################
-
-if(WITH_HAL_LIB)
-else()
-endif()
-SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${NSTACKTOOLS_PATH})
-LINK_DIRECTORIES(${LIB_PATH_SHARED} ${LIB_PATH_STATIC})
-INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/platform/SecureC/include/)
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g -fPIC -fPIE -pie -m64 -mssse3 -std=gnu89")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -Wshadow -Wfloat-equal -Wformat=2")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector -fstack-protector-all")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-z,relro,-z,now -Wl,--disable-new-dtags,--rpath,.")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-z,noexecstack -mcmodel=medium")
-
-INCLUDE_DIRECTORIES(
- ../src/include/
- ../../../thirdparty/glog/glog-0.3.4/src/
- ../../SecureC/include/
-)
-
-#ADD_EXECUTABLE(narp narp.c)
-#ADD_EXECUTABLE(nnetstat nnetstat.c)
-
-ADD_EXECUTABLE(ntcpdump ntcpdump.c)
-if(WITH_SECUREC_LIB)
-TARGET_LINK_LIBRARIES(
- ntcpdump
- pthread
- rt
- securec
- -Wl,--whole-archive
- libjson-c.a
- libglog.a
- dmm_api
- -Wl,--no-whole-archive,-lstdc++ -ldl
- rte_eal
- rte_mempool
- rte_mbuf
- rte_ring
-)
-else()
-TARGET_LINK_LIBRARIES(
- ntcpdump
- pthread
- rt
- -Wl,--whole-archive
- libjson-c.a
- libglog.a
- dmm_api
- -Wl,--no-whole-archive,-lstdc++ -ldl
- rte_eal
- rte_mempool
- rte_mbuf
- rte_ring
-)
-endif()
-
-if(WITH_SECUREC_LIB)
-ADD_DEPENDENCIES(ntcpdump JSON GLOG SECUREC DPDK)
-else()
-ADD_DEPENDENCIES(ntcpdump JSON GLOG DPDK)
-endif()
-
-
-ADD_EXECUTABLE(nping nping.c)
-
-if(WITH_SECUREC_LIB)
-ADD_DEPENDENCIES(nping SECUREC DPDK)
-else()
-ADD_DEPENDENCIES(nping DPDK)
-endif()
-
-if(WITH_SECUREC_LIB)
-TARGET_LINK_LIBRARIES(nping libnStackAPI.so securec -Wl,-rpath=. -lpthread -lrt -ldl)
-else()
-TARGET_LINK_LIBRARIES(nping libnStackAPI.so -Wl,-rpath=. -lpthread -lrt -ldl)
-endif()
diff --git a/stacks/lwip_stack/tools/nping.c b/stacks/lwip_stack/tools/nping.c
deleted file mode 100644
index 09e604f..0000000
--- a/stacks/lwip_stack/tools/nping.c
+++ /dev/null
@@ -1,627 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <arpa/inet.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <sys/ioctl.h>
-#include <unistd.h>
-#include <netinet/in.h>
-#include <netinet/ip.h>
-#include <errno.h>
-#include <time.h>
-#include <fcntl.h>
-#include <memory.h>
-#include <strings.h>
-#include <limits.h>
-#include <getopt.h>
-#include "nstack_securec.h"
-#include "tool_common.h"
-
-/*======== for global variables =======*/
-
-NSTACK_STATIC input_info g_input_info = { 0 };
-static stat_info g_stat_info = { 0 };
-
-static char *g_nping_short_options = "c:r:I:";
-
-int g_exit = 0;
-void
-user_exit (int sig)
-{
- g_exit = 1;
-}
-
-NSTACK_STATIC inline double
-get_cost_time (struct timespec *pstart, struct timespec *pend)
-{
- double sec = (double) (pend->tv_sec - pstart->tv_sec);
- double nsec = (double) (pend->tv_nsec - pstart->tv_nsec);
-
- return (sec * 1000 + (nsec / 1000000));
-}
-
-NSTACK_STATIC inline double
-get_lost_rate (unsigned int lost_count, unsigned int send_count)
-{
- if (0 == send_count)
- {
- return 0;
- }
-
- return ((double) lost_count / send_count);
-}
-
-void
-print_stat (stat_info * info, const char *remote_ip)
-{
- unsigned int send_count = info->send_seq;
- unsigned int recv_count = info->recv_ok;
- unsigned int lost_count = send_count - recv_count;
- double lost_rate = 100 * get_lost_rate (lost_count, send_count);
- double cost_time = get_cost_time (&info->start_time, &info->end_time);
-
- printf ("\n------ %s ping statistics ------\n", remote_ip);
-
- printf
- ("%u packets transmitted, %u received, %.2f%% packet loss, time %.2fms\n",
- send_count, recv_count, lost_rate, cost_time);
-
- if (0 != recv_count)
- {
- double min_interval = info->min_interval;
- double max_interval = info->max_interval;
- double avg_interval = info->all_interval / recv_count;
- printf ("rtt min/avg/max = %.3f/%.3f/%.3f ms\n", min_interval,
- avg_interval, max_interval);
- }
-}
-
-NSTACK_STATIC inline u16
-get_chksum (icmp_head * pmsg)
-{
- int len = sizeof (icmp_head);
- u32 sum = 0;
- u16 *msg_stream = (u16 *) pmsg;
- u16 check_sum = 0;
-
- while (len > 1)
- {
- sum += *msg_stream;
- len -= 2;
- msg_stream++;
- }
-
- sum = (sum >> 16) + (sum & 0xFFFF);
- sum += (sum >> 16);
- check_sum = ~sum;
-
- return check_sum;
-}
-
-#ifndef MAX_SHORT
-#define MAX_SHORT 0xFFFF
-#endif
-
-NSTACK_STATIC inline void
-code_icmp_req (icmp_head * pmsg, u32 send_seq, pid_t my_pid)
-{
- struct timespec cur_time;
-
- pmsg->icmp_type = ICMP_ECHO;
- pmsg->icmp_code = 0;
- pmsg->icmp_cksum = 0;
- pmsg->icmp_seq = send_seq % (MAX_SHORT + 1);
- pmsg->icmp_id = my_pid;
- pmsg->timestamp = 0;
-
- if (0 != clock_gettime (CLOCK_MONOTONIC, &cur_time))
- {
- printf ("Failed to get time, errno = %d\n", errno);
- }
-
- pmsg->icmp_sec = cur_time.tv_sec;
- pmsg->icmp_nsec = cur_time.tv_nsec;
-
- pmsg->icmp_cksum = get_chksum (pmsg);
- return;
-}
-
-NSTACK_STATIC int
-send_icmp_req (int socket, pid_t my_pid, stat_info * stat,
- struct sockaddr_in *remote_addr)
-{
- int send_ret;
- icmp_head icmp_req;
-
- stat->send_seq++;
- code_icmp_req (&icmp_req, stat->send_seq, my_pid);
-
- send_ret = sendto (socket, &icmp_req, sizeof (icmp_head), 0,
- (struct sockaddr *) remote_addr,
- sizeof (struct sockaddr_in));
-
- if (send_ret < 0)
- {
- printf ("send icmp request failed.\n");
- return -1;
- }
-
- return send_ret;
-}
-
-NSTACK_STATIC inline double
-cal_interval (struct timespec *psend, struct timespec *precv,
- stat_info * stat)
-{
- double interval = get_cost_time (psend, precv);
-
- stat->all_interval += interval;
-
- if (interval < stat->min_interval)
- {
- stat->min_interval = interval;
- }
-
- if (interval > stat->max_interval)
- {
- stat->max_interval = interval;
- }
-
- return interval;
-}
-
-NSTACK_STATIC inline void
-print_info_on_reply (long send_sec, long send_usec, u32 send_seq,
- stat_info * stat, struct sockaddr_in *dst_addr)
-{
- struct timespec send_time;
- struct timespec recv_time;
- if (0 != clock_gettime (CLOCK_MONOTONIC, &recv_time))
- {
- printf ("Failed to get time, errno = %d\n", errno);
- }
-
- send_time.tv_sec = send_sec;
- send_time.tv_nsec = send_usec;
-
- double interval = cal_interval (&send_time, &recv_time, stat);
- const char *remote_ip = inet_ntoa (dst_addr->sin_addr);
- printf ("%lu bytes from %s: icmp_seq=%u, time=%.3f ms\n",
- sizeof (icmp_head), remote_ip, send_seq % (MAX_SHORT + 1),
- interval);
-}
-
-NSTACK_STATIC inline void
-print_info_on_no_reply (u32 send_seq, const char *remote_ip)
-{
- printf ("No data from %s, icmp_seq=%u, Destination Host Unreachable\n",
- remote_ip, send_seq);
-}
-
-static inline int
-expect_addr (int expect, int addr)
-{
- return (expect == addr);
-}
-
-NSTACK_STATIC inline int
-parse_icmp_reply (char *buf, unsigned int buf_len, u32 my_pid, u32 send_seq,
- stat_info * stat, struct sockaddr_in *dst_addr)
-{
- unsigned int ip_head_len;
- ip_head *recv_ip_head;
- icmp_head *recv_icmp_head;
-
- // parse all received ip package
- while (buf_len > sizeof (ip_head))
- {
- recv_ip_head = (ip_head *) buf;
-
- ip_head_len = recv_ip_head->ihl << 2;
- recv_icmp_head = (icmp_head *) (buf + ip_head_len);
- buf_len -= htons (recv_ip_head->tot_len);
-
- if (!expect_addr (dst_addr->sin_addr.s_addr, recv_ip_head->local_ip))
- {
- return 0;
- }
-
- if ((recv_icmp_head->icmp_type == ICMP_REPLY)
- && (recv_icmp_head->icmp_id == my_pid)
- && (recv_icmp_head->icmp_seq == send_seq % (MAX_SHORT + 1)))
- {
- print_info_on_reply (recv_icmp_head->icmp_sec,
- recv_icmp_head->icmp_nsec, send_seq, stat,
- dst_addr);
-
- return 1;
- }
-
- buf += ip_head_len;
- }
-
- return 0;
-}
-
-NSTACK_STATIC inline int
-recv_icmp_reply_ok (int socket, int my_pid, u32 send_seq, stat_info * stat,
- struct sockaddr_in *dst_addr)
-{
-#define MAX_RECV_BUFF_SIZE (200 * sizeof(icmp_head))
-
- struct sockaddr_in remote_addr;
- unsigned int addr_len = sizeof (remote_addr);
- char recv_buf[MAX_RECV_BUFF_SIZE];
-
- int recv_ret = recvfrom (socket, recv_buf, MAX_RECV_BUFF_SIZE, 0,
- (struct sockaddr *) &remote_addr, &addr_len);
-
- if (recv_ret < 0)
- {
- return 0;
- }
-
- if (!parse_icmp_reply
- (recv_buf, (unsigned int) recv_ret, my_pid, send_seq, stat, dst_addr))
- {
- return 0;
- }
-
- return 1;
-}
-
-// check recv msg in 2 us
-/* BEGIN: Added for PN:CODEDEX by l00351127, 2017/11/14 CID:50811*/
-NSTACK_STATIC void
-recv_icmp_reply (int socket, pid_t my_pid, input_info * input,
- stat_info * stat, struct sockaddr_in *dst_addr)
-/* END: Added for PN:CODEDEX by l00351127, 2017/11/14 */
-{
-#define MAX_SLEEP_TIME (2 * US_TO_NS)
-#define MAX_WAIT_TIME (1000 * MS_TO_NS)
-
- int recv_ok = 0;
- int retry = 0;
- long sleep_all = 0;
- long sleep_time = 0;
-
- u32 expect_seq = stat->send_seq;
-
- while (retry < input->retry_count)
- {
- if (recv_icmp_reply_ok (socket, my_pid, expect_seq, stat, dst_addr))
- {
- recv_ok = 1;
- stat->recv_ok++;
- break;
- }
-
- sleep_all += MAX_SLEEP_TIME;
- sys_sleep_ns (0, MAX_SLEEP_TIME);
- retry++;
- }
-
- if (!recv_ok)
- {
- print_info_on_no_reply (expect_seq, input->dst_ip);
- }
-
- if (sleep_all < MAX_WAIT_TIME)
- {
- sleep_time = MAX_WAIT_TIME - sleep_all;
- sys_sleep_ns (0, sleep_time);
- }
-}
-
-NSTACK_STATIC inline int
-is_digit_nping (char *str)
-{
- if (NULL == str || '\0' == str[0])
- {
- return 0;
- }
-
- while (*str)
- {
- if (*str > '9' || *str < '0')
- {
- return 0;
- }
-
- str++;
- }
-
- return 1;
-}
-
-#define MIN_IP_LEN_NPING 7 //the length of string ip addr x.x.x.x is 7, 4 numbers + 3 dots = 7
-#define MAX_IP_LEN_NPING 15 //the length of string ip addr xxx.xxx.xxx.xxx is 15, 12 numbers + 3 dots = 15
-
-NSTACK_STATIC inline int
-is_ip_addr_nping (char *param_addr)
-{
- int ipseg1;
- int ipseg2;
- int ipseg3;
- int ipseg4;
-
- if (NULL == param_addr)
- {
- return 0;
- }
-
- size_t len = strlen (param_addr);
- if (len < MIN_IP_LEN_NPING || len > MAX_IP_LEN_NPING) // valid ip MIN_IP_LEN=7, MAX_IP_LEN=15
- {
- printf ("Input IP format error.\n");
- return 0;
- }
-
- if (SSCANF_S (param_addr, "%d.%d.%d.%d", &ipseg1, &ipseg2, &ipseg3, &ipseg4)
- != 4)
- {
- return 0;
- }
-
- if ((ipseg1 & 0xffffff00)
- || (ipseg2 & 0xffffff00)
- || (ipseg3 & 0xffffff00) || (ipseg4 & 0xffffff00))
- {
- return 0;
- }
-
- return 1;
-}
-
-NSTACK_STATIC inline bool
-check_nping_input_para (input_info * input)
-{
- if (input->send_count < 1)
- {
- return false;
- }
-
- if (input->retry_count < NPING_RETRY_COUNT
- || input->retry_count > MAX_NPING_RETRY_COUNT)
- {
- return false;
- }
-
- if (0 == input->src_ip[0] || 0 == input->dst_ip[0])
- {
- return false;
- }
-
- return true;
-}
-
-NSTACK_STATIC inline bool
-get_nping_input_para (int argc, char **argv, input_info * input)
-{
- int opt = 0;
- bool arg_invalid = false;
-
- if (argc < 2)
- {
- return false;
- }
-
- if (!is_ip_addr_nping (argv[1]))
- {
- return false;
- }
-
- /* CID 36687 (#1 of 2): Unchecked return value (CHECKED_RETURN) */
- if (EOK != STRCPY_S (input->dst_ip, sizeof (input->dst_ip), argv[1]))
- {
- printf ("STRCPY_S failed.\n");
- return false;
- }
-
- while (1)
- {
- opt = getopt (argc - 1, &argv[1], g_nping_short_options);
- if (-1 == opt)
- {
- break;
- }
-
- switch (opt)
- {
- // for short options
- case 'c':
- input->send_count = atoi (optarg);
- break;
- case 'r':
- input->retry_count = atoi (optarg);
- break;
- case 'I':
- /* CID 36687 (#2 of 2): Unchecked return value (CHECKED_RETURN) */
- if (!is_ip_addr_nping (optarg))
- {
- return false;
- }
- if (EOK != STRCPY_S (input->src_ip, sizeof (input->src_ip), optarg))
- {
- printf ("STRCPY_S failed.\n");
- return false;
- }
- break;
- default:
- arg_invalid = true;
- break;
- }
-
- if (arg_invalid)
- {
- return false;
- }
- }
-
- if (!check_nping_input_para (input))
- {
- return false;
- }
-
- return true;
-}
-
-void
-print_help_nping ()
-{
- printf
- ("usage:nping destination [-c send_count -I src_addr -r retry_count]\n");
- printf ("send count range:1-2147483647\n");
- printf ("retry count range:1000-20000\n");
-}
-
-NSTACK_STATIC inline void
-init_input_info (input_info * input)
-{
- if (EOK != MEMSET_S (input, sizeof (input_info), 0, sizeof (input_info)))
- {
- printf ("MEMSET_S failed.\n");
- return;
- }
-
- input->send_count = 100000;
- input->retry_count = NPING_RETRY_COUNT;
-}
-
-NSTACK_STATIC inline void
-init_stat_info (stat_info * stat)
-{
- stat->max_interval = 0;
- stat->min_interval = 0xFFFFFFFF;
-}
-
-#ifndef NSTACK_STATIC_CHECK
-int
-main (int argc, char *argv[])
-#else
-int
-nping_main (int argc, char *argv[])
-#endif
-{
- struct sockaddr_in local_addr;
- struct sockaddr_in remote_addr;
- int send_ret;
- int ret = -1;
- int icmp_sock;
-
- pid_t my_pid;
-
- if (EOK !=
- MEMSET_S (&local_addr, sizeof (local_addr), 0, sizeof (local_addr)))
- {
- printf ("MEMSET_S failed.\n");
- return 0;
- }
- local_addr.sin_family = AF_INET;
-
- init_input_info (&g_input_info);
- init_stat_info (&g_stat_info);
-
- if (!get_nping_input_para (argc, argv, &g_input_info))
- {
- print_help_nping ();
- return 0;
- }
-
- if ((icmp_sock = socket (AF_INET, CUSTOM_SOCK_TYPE, IPPROTO_ICMP)) < 0)
- {
- printf ("create socket failed.\n");
- return 0;
- }
-
- local_addr.sin_addr.s_addr = inet_addr (g_input_info.src_ip);
-
- if (0 !=
- bind (icmp_sock, (struct sockaddr *) &local_addr,
- sizeof (struct sockaddr)))
- {
- printf ("bind failed, src ip %s\n", g_input_info.src_ip);
- close (icmp_sock);
- return 0;
- }
-
- int opt = 1;
- ret = ioctl (icmp_sock, FIONBIO, &opt);
- if (-1 == ret)
- {
- printf ("fcntl O_NONBLOCK fail\n");
- close (icmp_sock);
- return 0;
- }
-
- if (EOK !=
- MEMSET_S (&remote_addr, sizeof (remote_addr), 0, sizeof (remote_addr)))
- {
- printf ("MEMSET_S failed.\n");
- close (icmp_sock);
- return 0;
- }
-
- remote_addr.sin_family = AF_INET;
- remote_addr.sin_addr.s_addr = inet_addr (g_input_info.dst_ip);
-
- my_pid = getpid ();
- printf ("nping %s %lu bytes of data, pid:%d.\n", g_input_info.dst_ip,
- sizeof (icmp_head), my_pid);
-
- signal (SIGINT, user_exit);
-
- int loop_count = 0;
- if (0 != clock_gettime (CLOCK_MONOTONIC, &g_stat_info.start_time))
- {
- printf ("Failed to get time, errno = %d\n", errno);
- }
-
-/* BEGIN: Added for PN:CODEDEX by l00351127, 2017/11/14 CID:50811*/
- i32 send_count = g_input_info.send_count;
-/* END: Added for PN:CODEDEX by l00351127, 2017/11/14 */
-
- while (!g_exit && (loop_count < send_count))
- {
- send_ret =
- send_icmp_req (icmp_sock, my_pid, &g_stat_info, &remote_addr);
- if (send_ret < 0)
- {
- break;
- }
-
- recv_icmp_reply (icmp_sock, my_pid, &g_input_info, &g_stat_info,
- &remote_addr);
-
- loop_count++;
- }
-
- close (icmp_sock);
-
- if (0 != clock_gettime (CLOCK_MONOTONIC, &g_stat_info.end_time))
- {
- printf ("Failed to get time, errno = %d\n", errno);
- }
-
- print_stat (&g_stat_info, g_input_info.dst_ip);
-
- return 0;
-}
diff --git a/stacks/lwip_stack/tools/ntcpdump.c b/stacks/lwip_stack/tools/ntcpdump.c
deleted file mode 100644
index 31a96bc..0000000
--- a/stacks/lwip_stack/tools/ntcpdump.c
+++ /dev/null
@@ -1,1368 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#include <arpa/inet.h>
-#include <unistd.h>
-#include <signal.h>
-#include <time.h>
-#include <malloc.h>
-#include <stdio.h>
-#include <getopt.h>
-#include <unistd.h>
-#include "types.h"
-#include "nsfw_init.h"
-#include "nsfw_mem_api.h"
-#include "nsfw_fd_timer_api.h"
-#include "nsfw_maintain_api.h"
-#include "nstack_securec.h"
-
-#include "tool_common.h"
-
-NSTACK_STATIC struct option g_dump_long_options[] = {
- {"host", 1, NULL, OPT_ARG_HOST},
- {"lhost", 1, NULL, OPT_ARG_LOCAL_HOST},
- {"rhost", 1, NULL, OPT_ARG_REMOTE_HOST},
- {"port", 1, NULL, OPT_ARG_PORT},
- {"lport", 1, NULL, OPT_ARG_LOCAL_PORT},
- {"rport", 1, NULL, OPT_ARG_REMOTE_PORT},
- {"mac", 1, NULL, OPT_ARG_MAC},
- {"lmac", 1, NULL, OPT_ARG_LOCAL_MAC},
- {"rmac", 1, NULL, OPT_ARG_REMOTE_MAC},
- {0, 0, 0, 0}
-};
-
-static char *g_dump_short_options = "c:s:w:y:G:P:T:";
-
-NSTACK_STATIC FILE *g_dump_fp = NULL;
-static u32 g_dumped_packet = 0;
-NSTACK_STATIC u32 g_captured_packet = 0;
-static u32 g_filtered_packet = 0;
-
-NSTACK_STATIC bool g_dump_exit = 0;
-
-static dump_timer_info g_dump_hbt_timer;
-NSTACK_STATIC dump_condition g_dump_condition;
-static nsfw_mem_name g_dump_mem_ring_info =
- { NSFW_SHMEM, NSFW_PROC_MAIN, DUMP_SHMEM_RIGN_NAME };
-static nsfw_mem_name g_dump_mem_pool_info =
- { NSFW_SHMEM, NSFW_PROC_MAIN, DUMP_SHMEM_POOL_NAME };
-
-void
-dump_exit ()
-{
- g_dump_exit = 1;
-}
-
-void
-print_help_ntcpdump ()
-{
- printf ("usage:ntcpdump \n\
- -c count \n\
- -s len \n\
- -w file \n\
- -y l2_protocol \n\
- -T l3_protocol \n\
- -G dump_seconds \n\
- -P in/out/inout \n\
- --host/rhost/lhost ip_addr \n\
- --port/rport/lport port \n\
- --mac/rmac/lmac mac_addr\n");
-}
-
-bool
-is_digit_ntcpdump (char *str, size_t src_len)
-{
- size_t count = 0;
-
- if (NULL == str || 0 == *str)
- {
- return FALSE;
- }
-
- while (*str)
- {
- if (*str > '9' || *str < '0')
- {
- return false;
- }
-
- str++;
- count++;
- }
-
- if (count > src_len)
- {
- return false;
- }
-
- return true;
-}
-
-NSTACK_STATIC inline bool
-is_ip_addr (const char *addr, ip_addr_bits * addr_info)
-{
- u32 ip1;
- u32 ip2;
- u32 ip3;
- u32 ip4;
-
- if (SSCANF_S (addr, "%d.%d.%d.%d", &ip1, &ip2, &ip3, &ip4) != 4)
- {
- return false;
- }
-
- if ((ip1 & 0xffffff00) || (ip2 & 0xffffff00) || (ip3 & 0xffffff00)
- || (ip4 & 0xffffff00))
- {
- return false;
- }
-
- addr_info->addr_bits1 = ip1;
- addr_info->addr_bits2 = ip2;
- addr_info->addr_bits3 = ip3;
- addr_info->addr_bits4 = ip4;
-
- return true;
-}
-
-NSTACK_STATIC inline bool
-get_ip_addr (const char *addr, u32 * ip_addr)
-{
- ip_addr_bits addr_info;
- if (!is_ip_addr (addr, &addr_info))
- {
- return false;
- }
-
- *ip_addr = ((addr_info.addr_bits1 & 0xFF)
- | (addr_info.addr_bits2 & 0xFF) << 8
- | (addr_info.addr_bits3 & 0xFF) << 16
- | (addr_info.addr_bits4 & 0xFF) << 24);
-
- return true;
-}
-
-NSTACK_STATIC inline bool
-get_dump_port (const char *pport, u16 * port)
-{
- int user_port;
-
- if (!is_digit_ntcpdump ((char *) pport, MAX_PORT_STR_LEN))
- {
- return false;
- }
-
- user_port = atoi (pport);
- if (user_port < 1024 || user_port > 65535)
- {
- return false;
- }
-
- *port = (unsigned short) user_port;
- return true;
-}
-
-NSTACK_STATIC inline bool
-get_dump_len (char *plen, u32 * limit_len)
-{
- if (!is_digit_ntcpdump (plen, MAX_INTEGER_STR_LEN))
- {
- return false;
- }
-
- *limit_len = atoi (plen);
- return true;
-}
-
-NSTACK_STATIC inline bool
-get_mac_addr (const char *opt_value, char *mac_addr)
-{
- /* avoid coredump when opt_value is NULL */
- if (NULL == opt_value)
- {
- return false;
- }
-
- size_t org_len = strlen (opt_value);
- if (org_len != MAC_ADDR_STR_LEN)
- {
- return false;
- }
-
- u32 tmp_mac[MAC_ADDR_LEN];
-
- if (6 != SSCANF_S (opt_value, "%x:%x:%x:%x:%x:%x",
- &tmp_mac[0],
- &tmp_mac[1],
- &tmp_mac[2], &tmp_mac[3], &tmp_mac[4], &tmp_mac[5]))
- {
- return false;
- }
-
- int i = 0;
- for (; i < MAC_ADDR_LEN; i++)
- {
- if (tmp_mac[i] > 0xFF)
- {
- // 01:02:03:04:5:1FF
- return false;
- }
-
- mac_addr[i] = tmp_mac[i];
- }
-
- return true;
-}
-
-NSTACK_STATIC inline bool
-check_file_name (const char *file_name)
-{
- if (0 == access (file_name, F_OK))
- {
- printf ("dump file exist, file name=%s.\n", file_name);
- return false;
- }
- return true;
-}
-
-NSTACK_STATIC inline u16
-get_para_direction (const char *para)
-{
- if (0 == strcasecmp (para, "out"))
- {
- return DUMP_SEND;
- }
-
- if (0 == strcasecmp (para, "in"))
- {
- return DUMP_RECV;
- }
-
- if (0 == strcasecmp (para, "inout"))
- {
- return DUMP_SEND_RECV;
- }
-
- return INVALID_DIRECTION;
-}
-
-NSTACK_STATIC inline u16
-get_para_l2_protocol (const char *para)
-{
- if (0 == strcasecmp (para, "arp"))
- {
- return PROTOCOL_ARP;
- }
-
- if (0 == strcasecmp (para, "rarp"))
- {
- return PROTOCOL_RARP;
- }
-
- if (0 == strcasecmp (para, "ip"))
- {
- return PROTOCOL_IP;
- }
-
- if (0 == strcasecmp (para, "oam"))
- {
- return PROTOCOL_OAM_LACP;
- }
-
- if (0 == strcasecmp (para, "lacp"))
- {
- return PROTOCOL_OAM_LACP;
- }
-
- return INVALID_L2_PROTOCOL;
-}
-
-NSTACK_STATIC inline u16
-get_para_l3_protocol (const char *para)
-{
- if (0 == strcasecmp (para, "tcp"))
- {
- return PROTOCOL_TCP;
- }
-
- if (0 == strcasecmp (para, "udp"))
- {
- return PROTOCOL_UDP;
- }
-
- if (0 == strcasecmp (para, "icmp"))
- {
- return PROTOCOL_ICMP;
- }
-
- return INVALID_L3_PROTOCOL;
-}
-
-NSTACK_STATIC bool
-parse_long_options (int opt, const char *long_opt_arg, int optindex,
- dump_condition * filter_info)
-{
- switch (opt)
- {
- case OPT_ARG_HOST:
- if (!get_ip_addr (long_opt_arg, &filter_info->ip_addr))
- {
- printf ("invalid ip addr, optindex=%d, port=%s.\n", optindex,
- long_opt_arg);
- return false;
- }
- filter_info->ip_set_flag |= COND_OR_SET;
- break;
- case OPT_ARG_LOCAL_HOST:
- if (!get_ip_addr (long_opt_arg, &filter_info->local_ip))
- {
- printf ("invalid ip addr, optindex=%d, port=%s.\n", optindex,
- long_opt_arg);
- return false;
- }
- filter_info->ip_set_flag |= COND_LOCAL_SET;
- break;
- case OPT_ARG_REMOTE_HOST:
- if (!get_ip_addr (long_opt_arg, &filter_info->remote_ip))
- {
- printf ("invalid ip addr, optindex=%d, port=%s.\n", optindex,
- long_opt_arg);
- return false;
- }
- filter_info->ip_set_flag |= COND_REMOTE_SET;
- break;
- case OPT_ARG_PORT:
- if (!get_dump_port (long_opt_arg, &filter_info->port))
- {
- printf ("invalid port, optindex=%d, port=%s.\n", optindex,
- long_opt_arg);
- return false;
- }
- filter_info->port_set_flag |= COND_OR_SET;
- break;
- case OPT_ARG_LOCAL_PORT:
- if (!get_dump_port (long_opt_arg, &filter_info->local_port))
- {
- printf ("invalid port, optindex=%d, port=%s.\n", optindex,
- long_opt_arg);
- return false;
- }
- filter_info->port_set_flag |= COND_LOCAL_SET;
- break;
- case OPT_ARG_REMOTE_PORT:
- if (!get_dump_port (long_opt_arg, &filter_info->remote_port))
- {
- printf ("invalid port, optindex=%d, port=%s.\n", optindex,
- long_opt_arg);
- return false;
- }
- filter_info->port_set_flag |= COND_REMOTE_SET;
- break;
- case OPT_ARG_MAC:
- if (!get_mac_addr (long_opt_arg, filter_info->mac_addr))
- {
- printf ("invalid mac addr, optindex=%d, mac=%s.\n", optindex,
- long_opt_arg);
- return false;
- }
- filter_info->mac_set_flag |= COND_OR_SET;
- break;
- case OPT_ARG_LOCAL_MAC:
- if (!get_mac_addr (long_opt_arg, filter_info->local_mac))
- {
- printf ("invalid mac addr, optindex=%d, mac=%s.\n", optindex,
- long_opt_arg);
- return false;
- }
- filter_info->mac_set_flag |= COND_LOCAL_SET;
- break;
- case OPT_ARG_REMOTE_MAC:
- if (!get_mac_addr (long_opt_arg, filter_info->remote_mac))
- {
- printf ("invalid mac addr, optindex=%d, mac=%s.\n", optindex,
- long_opt_arg);
- return false;
- }
- filter_info->mac_set_flag |= COND_REMOTE_SET;
- break;
- default:
- printf ("unknow arg, optindex=%d, arg=%s.\n", optindex, long_opt_arg);
- return false;
- }
-
- return true;
-}
-
-NSTACK_STATIC inline bool
-condition_valid (dump_condition * condition)
-{
- // check direction
- if (INVALID_DIRECTION == condition->direction)
- {
- printf ("direction invalid.\n");
- return false;
- }
-
- // check l2 protocol
- if (INVALID_L2_PROTOCOL == condition->l2_protocol)
- {
- printf ("L2 protocol invalid.\n");
- return false;
- }
-
- // check l3 protocol
- if (INVALID_L3_PROTOCOL == condition->l3_protocol)
- {
- printf ("L3 protocol invalid.\n");
- return false;
- }
-
- // check ip
- if (condition->ip_set_flag > 0x4)
- {
- printf ("IP options invalid.\n");
- return false;
- }
-
- // check port
- if (condition->port_set_flag > 0x4)
- {
- printf ("Port options invalid.\n");
- return false;
- }
-
- // check mac
- if (condition->mac_set_flag > 0x4)
- {
- printf ("MAC options invalid.\n");
- return false;
- }
-
- if (condition->dump_time > MAX_DUMP_TIME
- || condition->dump_time < MIN_DUMP_TIME)
- {
- printf ("dump time invalid.\n");
- return false;
- }
-
- return true;
-}
-
-NSTACK_STATIC inline bool
-get_dump_condition (int argc, char **argv, dump_condition * filter_info)
-{
- int opt = 0;
- int opt_index = 0;
- bool arg_invalid = false;
- filter_info->has_condition = 0;
-
- if (argc < 2)
- {
- // dump all package
- return true;
- }
-
- while (1)
- {
- opt =
- getopt_long (argc, argv, g_dump_short_options, g_dump_long_options,
- &opt_index);
- if (-1 == opt)
- {
- break;
- }
-
- switch (opt)
- {
- // for short options
- case 'c':
- filter_info->dump_count = atoi (optarg);
- break;
- case 's':
- if (!get_dump_len (optarg, &filter_info->limit_len))
- {
- printf ("length invalid, optindex=%d, arg=%s.\n", opt_index,
- optarg);
- arg_invalid = true;
- }
- break;
- case 'w':
- if (!check_file_name (optarg))
- {
- printf ("invalid file name, optindex=%d, arg=%s.\n", opt_index,
- optarg);
- arg_invalid = true;
- }
- else
- {
- filter_info->dump_file_name = optarg;
- }
- break;
- case 'y':
- filter_info->l2_protocol = get_para_l2_protocol (optarg);
- break;
- case 'G':
- filter_info->dump_time = atoi (optarg);
- break;
- case 'P':
- filter_info->direction = get_para_direction (optarg);
- break;
- case 'T':
- filter_info->l3_protocol = get_para_l3_protocol (optarg);
- break;
- case '?':
- arg_invalid = true;
- break;
- // for long options
- default:
- if (!parse_long_options (opt, optarg, opt_index, filter_info))
- {
- arg_invalid = true;
- }
- break;
- }
-
- if (arg_invalid)
- {
- print_help_ntcpdump ();
- return false;
- }
-
- filter_info->has_condition = 1;
- }
-
- if (!condition_valid (filter_info))
- {
- filter_info->has_condition = 0;
- return false;
- }
-
- return true;
-}
-
-NSTACK_STATIC inline void
-open_file ()
-{
- if (NULL == g_dump_condition.dump_file_name)
- {
- return;
- }
-
- g_dump_fp = fopen (g_dump_condition.dump_file_name, "w+");
- if (NULL == g_dump_fp)
- {
- printf ("open file %s failed\n", g_dump_condition.dump_file_name);
- }
-}
-
-NSTACK_STATIC inline void
-close_file ()
-{
- if (NULL != g_dump_fp)
- {
- fclose (g_dump_fp);
- g_dump_fp = NULL;
- }
-}
-
-NSTACK_STATIC inline void
-write_file_head (FILE * fp)
-{
- dump_file_head file_head;
- file_head.magic = 0xA1B2C3D4;
- file_head.major_ver = 2; // 0x0200;
- file_head.minor_ver = 4; // 0x0400;
- file_head.area = 0;
- file_head.time_stamp = 0;
- file_head.max_pack_size = 0x0000FFFF; // 0xFFFF0000;
- file_head.link_type = 1; //0x01000000;
-
- if (fwrite (&file_head, sizeof (dump_file_head), 1, fp) != 1)
- {
- return;
- }
-
- fflush (fp);
-}
-
-NSTACK_STATIC inline void
-write_packet (parse_msg_info * pmsg, FILE * fp)
-{
- packet_head pack_head;
- dump_msg_info *org_msg = (dump_msg_info *) pmsg->org_msg;
- pack_head.sec = org_msg->dump_sec;
- pack_head.usec = org_msg->dump_usec;
- pack_head.save_len =
- (u32) nstack_min (org_msg->len, g_dump_condition.limit_len);
- pack_head.org_len = org_msg->len;
-
- if (fwrite (&pack_head, sizeof (packet_head), 1, fp) != 1)
- {
- // log error
- return;
- }
-
- if (fwrite (org_msg->buf, pack_head.save_len, 1, fp) != 1)
- {
- // log error
- return;
- }
-
- fflush (fp);
- return;
-}
-
-#define EMPTY(x) (0 == (x))
-#define EQUAL(x, y) ((x) == (y))
-
-#define STR_EMPTY(str) (0 == str[0])
-#define STR_EQUAL(str1, str2, len) (0 == memcmp(str1, str2, len))
-
-#define MATCH(cond, info, field) \
- (EQUAL(cond->field, info->field))
-
-#define MATCH_MORE(cond, field, info, field1, field2) \
- (EQUAL(cond->field, info->field1) || EQUAL(cond->field, info->field2))
-
-#define MATCH_STR(cond, info, field, len) \
- (STR_EQUAL(cond->field, info->field, len))
-
-#define MATCH_STR_MORE(cond, field, info, field1, field2, len) \
- (STR_EQUAL(cond->field, info->field1, len) || STR_EQUAL(cond->field, info->field2, len))
-
-NSTACK_STATIC inline bool
-ip_match (dump_condition * condition, parse_msg_info * msg_info)
-{
- bool ret = false;
- switch (condition->ip_set_flag)
- {
- case COND_NOT_SET:
- ret = true;
- break;
- case COND_LOCAL_SET:
- if (MATCH (condition, msg_info, local_ip))
- {
- ret = true;
- }
- break;
- case COND_REMOTE_SET:
- if (MATCH (condition, msg_info, remote_ip))
- {
- ret = true;
- }
- break;
- case COND_AND_SET:
- if (MATCH_MORE (condition, local_ip, msg_info, local_ip, remote_ip)
- && MATCH_MORE (condition, remote_ip, msg_info, local_ip, remote_ip))
- {
- ret = true;
- }
- break;
- case COND_OR_SET:
- if (MATCH_MORE (condition, ip_addr, msg_info, local_ip, remote_ip))
- {
- ret = true;
- }
- break;
- default:
- break;
- }
-
- return ret;
-}
-
-NSTACK_STATIC inline bool
-port_match (dump_condition * condition, parse_msg_info * msg_info)
-{
- bool ret = false;
- switch (condition->port_set_flag)
- {
- case COND_NOT_SET:
- ret = true;
- break;
- case COND_LOCAL_SET:
- if (MATCH (condition, msg_info, local_port))
- {
- ret = true;
- }
- break;
- case COND_REMOTE_SET:
- if (MATCH (condition, msg_info, remote_port))
- {
- ret = true;
- }
- break;
- case COND_AND_SET:
- if (MATCH (condition, msg_info, local_port)
- && MATCH (condition, msg_info, remote_port))
- {
- ret = true;
- }
- break;
- case COND_OR_SET:
- if (MATCH_MORE (condition, port, msg_info, local_port, remote_port))
- {
- ret = true;
- }
- break;
- default:
- break;
- }
-
- return ret;
-}
-
-NSTACK_STATIC inline bool
-mac_match (dump_condition * condition, parse_msg_info * msg_info)
-{
- bool ret = false;
- switch (condition->mac_set_flag)
- {
- case COND_NOT_SET:
- ret = true;
- break;
- case COND_LOCAL_SET:
- if (MATCH_STR (condition, msg_info, local_mac, MAC_ADDR_LEN))
- {
- ret = true;
- }
- break;
- case COND_REMOTE_SET:
- if (MATCH_STR (condition, msg_info, remote_mac, MAC_ADDR_LEN))
- {
- ret = true;
- }
- break;
- case COND_AND_SET:
- if ((MATCH_STR_MORE
- (condition, local_mac, msg_info, local_mac, remote_mac,
- MAC_ADDR_LEN)
- && MATCH_STR_MORE (condition, remote_mac, msg_info, local_mac,
- remote_mac, MAC_ADDR_LEN)))
- {
- ret = true;
- }
- break;
- case COND_OR_SET:
- if (MATCH_STR_MORE
- (condition, mac_addr, msg_info, local_mac, remote_mac,
- MAC_ADDR_LEN))
- {
- ret = true;
- }
- break;
- default:
- break;
- }
-
- return ret;
-}
-
-NSTACK_STATIC inline bool
-filter_by_condition (dump_condition * condition, parse_msg_info * msg_info)
-{
- dump_msg_info *org_msg = (dump_msg_info *) msg_info->org_msg;
- if (0 == condition->has_condition)
- {
- return false;
- }
-
- // direction
- if (!(condition->direction & org_msg->direction))
- {
- return true;
- }
-
- // l2_protocol
- if ((0 != condition->l2_protocol)
- && !MATCH (condition, msg_info, l2_protocol))
- {
- return true;
- }
-
- // l3_protocol
- if ((0 != condition->l3_protocol)
- && !MATCH (condition, msg_info, l3_protocol))
- {
- return true;
- }
-
- // ip
- if (!ip_match (condition, msg_info))
- {
- return true;
- }
-
- // port
- if (!port_match (condition, msg_info))
- {
- return true;
- }
-
- // mac
- if (!mac_match (condition, msg_info))
- {
- return true;
- }
-
- return false;
-}
-
-NSTACK_STATIC inline char *
-get_l2_protocol_desc (u16 l2_protocol)
-{
- switch (l2_protocol)
- {
- case PROTOCOL_IP:
- return "IP";
- case PROTOCOL_ARP:
- return "ARP";
- case PROTOCOL_RARP:
- return "RARP";
- case PROTOCOL_OAM_LACP:
- return "OAM/LACP";
- default:
- return "unknown";
- }
-}
-
-NSTACK_STATIC inline char *
-get_l3_protocol_desc (u16 l3_protocol)
-{
- switch (l3_protocol)
- {
- case PROTOCOL_ICMP:
- return "ICMP";
- case PROTOCOL_TCP:
- return "TCP";
- case PROTOCOL_UDP:
- return "UDP";
- default:
- return "unknown";
- }
-}
-
-NSTACK_STATIC inline void
-get_ip_str (char *pip_addr, u32 ip_addr_len, u32 ip)
-{
- int retVal;
- retVal = SPRINTF_S (pip_addr, ip_addr_len, "%d.%d.%d.%d",
- ip & 0x000000FF,
- (ip & 0x0000FF00) >> 8,
- (ip & 0x00FF0000) >> 16, (ip & 0xFF000000) >> 24);
- if (-1 == retVal)
- {
- printf ("get_ip_str:SPRINTF_S failed %d.\n", retVal);
- }
-}
-
-NSTACK_STATIC inline void
-print_packet (parse_msg_info * msg_info, u32 seq)
-{
- char str_local_ip[IP_ADDR_LEN];
- char str_remote_ip[IP_ADDR_LEN];
- get_ip_str (str_local_ip, sizeof (str_local_ip), msg_info->local_ip);
- get_ip_str (str_remote_ip, sizeof (str_remote_ip), msg_info->remote_ip);
-
- dump_msg_info *org_msg = (dump_msg_info *) msg_info->org_msg;
-
- printf ("%-6d %-6d:%6d %-8s %-8s %-16s %-16s %-10d %-10d %-8d\n",
- seq,
- org_msg->dump_sec, org_msg->dump_usec,
- get_l2_protocol_desc (msg_info->l2_protocol),
- get_l3_protocol_desc (msg_info->l3_protocol),
- str_local_ip,
- str_remote_ip,
- msg_info->local_port, msg_info->remote_port, org_msg->len);
-}
-
-void
-print_head ()
-{
- if (NULL != g_dump_fp)
- {
- write_file_head (g_dump_fp);
- }
- else
- {
- printf ("ntcpdump start listening:\n");
- printf ("%-6s %-18s %-8s %-8s %-16s %-16s %-10s %-10s %-8s\n",
- "Frame", "sec:usec", "L2", "L3", "Src IP", "Dest IP",
- "Src Port", "Dest Port", "Length");
- }
-}
-
-void
-register_dump_signal ()
-{
- signal (SIGINT, dump_exit);
-}
-
-NSTACK_STATIC inline void
-init_parse_msg_info (parse_msg_info * info)
-{
- int retVal =
- MEMSET_S (info, sizeof (parse_msg_info), 0, sizeof (parse_msg_info));
- if (EOK != retVal)
- {
- printf ("MEMSET_S failed.\n");
- }
-}
-
-NSTACK_STATIC inline void
-parse_msg (dump_msg_info * msg, parse_msg_info * info)
-{
- init_parse_msg_info (info);
-
- info->org_msg = msg;
-
- char *pmsg = msg->buf;
- u32 len = msg->len;
- /* BEGIN: Added for PN:CODEDEX by l00351127, 2017/11/14 CID:50886 */
- if (len < MAC_ADDR_LEN + MAC_ADDR_LEN + sizeof (u16))
- {
- return;
- }
- /* END: Added for PN:CODEDEX by l00351127, 2017/11/14 */
-
- // get mac addr
- if (EOK !=
- MEMCPY_S (info->remote_mac, sizeof (info->remote_mac), pmsg,
- MAC_ADDR_LEN))
- {
- return;
- }
-
- pmsg += MAC_ADDR_LEN;
- len -= MAC_ADDR_LEN;
-
- if (EOK !=
- MEMCPY_S (info->local_mac, sizeof (info->local_mac), pmsg,
- MAC_ADDR_LEN))
- {
- return;
- }
-
- pmsg += MAC_ADDR_LEN;
- len -= MAC_ADDR_LEN;
-
- info->l2_protocol = htons (*(u16 *) pmsg);
- pmsg += sizeof (u16);
- len -= sizeof (u16);
-
- if (PROTOCOL_IP != info->l2_protocol)
- {
- return;
- }
-
- ip_head *p_ip_head = (ip_head *) pmsg;
- if (len < p_ip_head->ihl)
- {
- return;
- }
-
- info->local_ip = p_ip_head->local_ip;
- info->remote_ip = p_ip_head->remote_ip;
- info->l3_protocol = p_ip_head->protocol;
-
- pmsg += p_ip_head->ihl * sizeof (u32);
-
- if (PROTOCOL_TCP == info->l3_protocol)
- {
- tcp_head *p_tcp_head = (tcp_head *) pmsg;
- info->local_port = htons (p_tcp_head->src_port);
- info->remote_port = htons (p_tcp_head->dst_port);
- return;
- }
-
- if (PROTOCOL_UDP == info->l3_protocol)
- {
- udp_head *p_udp_head = (udp_head *) pmsg;
- info->local_port = htons (p_udp_head->src_port);
- info->remote_port = htons (p_udp_head->dst_port);
- return;
- }
-
- return;
-}
-
-NSTACK_STATIC inline bool
-time_expired (struct timespec * start_time, u32 work_sec)
-{
-#define TIME_EXPIRE_CHECK_COUNT 1000
-
- static u32 loop_count = 0;
- loop_count++;
-
- if (0 != loop_count % TIME_EXPIRE_CHECK_COUNT)
- {
- return false;
- }
-
- struct timespec cur_time;
- GET_CUR_TIME (&cur_time);
-
- if (cur_time.tv_sec - start_time->tv_sec > work_sec)
- {
- return true;
- }
-
- return false;
-}
-
-NSTACK_STATIC void
-dump_packet (parse_msg_info * msg)
-{
- g_dumped_packet++;
- if (!g_dump_fp)
- {
- print_packet (msg, g_dumped_packet);
- return;
- }
-
- write_packet (msg, g_dump_fp);
-}
-
-NSTACK_STATIC void
-dump_msg (mring_handle dump_ring, mring_handle dump_pool,
- dump_condition * condition, struct timespec *start_time)
-{
- u32 dump_count = 0;
- open_file ();
-
- print_head ();
-
- void *msg = NULL;
- while (!g_dump_exit
- && (dump_count < condition->dump_count)
- && !time_expired (start_time, condition->dump_time))
- {
- if (nsfw_mem_ring_dequeue (dump_ring, &msg) <= 0)
- {
- sys_sleep_ns (0, 10000);
- continue;
- }
-
- if (NULL == msg)
- {
- continue;
- }
-
- parse_msg_info msg_info;
- parse_msg (msg, &msg_info);
-
- g_captured_packet++;
- if (!condition->has_condition)
- {
- dump_packet (&msg_info);
- dump_count++;
- nsfw_mem_ring_enqueue (dump_pool, msg);
- continue;
- }
-
- if (filter_by_condition (condition, &msg_info))
- {
- g_filtered_packet++;
- nsfw_mem_ring_enqueue (dump_pool, msg);
- continue;
- }
-
- dump_packet (&msg_info);
- dump_count++;
- nsfw_mem_ring_enqueue (dump_pool, msg);
- }
-
- close_file ();
-}
-
-mring_handle
-dump_get_mem_ring ()
-{
- return nsfw_mem_ring_lookup (&g_dump_mem_ring_info);
-}
-
-mring_handle
-dump_get_mem_pool ()
-{
- return nsfw_mem_sp_lookup (&g_dump_mem_pool_info);
-}
-
-NSTACK_STATIC void
-dump_clear_mem (mring_handle ring, mring_handle pool)
-{
- void *msg = NULL;
- while (nsfw_mem_ring_dequeue (ring, &msg) > 0)
- {
- nsfw_mem_ring_enqueue (pool, msg);
- sys_sleep_ns (0, 1000);
- }
-}
-
-/* BEGIN: Added for PN:CODEDEX by l00351127, 2017/11/14 CID:50859*/
-i16
-dump_send_req (u16 op_type, i16 task_id, u32 task_keep_time)
-/* END: Added for PN:CODEDEX by l00351127, 2017/11/14 */
-{
- nsfw_mgr_msg *req =
- (nsfw_mgr_msg *) nsfw_mgr_msg_alloc (MGR_MSG_TOOL_TCPDUMP_REQ,
- NSFW_PROC_MAIN);
- if (NULL == req)
- {
- printf ("all message for getting instance id failed.\n");
- return -1;
- }
-
- nsfw_tool_dump_msg *req_body = GET_USER_MSG (nsfw_tool_dump_msg, req);
- req_body->op_type = op_type;
- req_body->task_id = task_id;
- req_body->task_keep_time = task_keep_time;
-
- nsfw_mgr_msg *rsp = nsfw_mgr_null_rspmsg_alloc ();
- if (NULL == rsp)
- {
- printf ("alloc rsp message for getting memory failed.\n");
- nsfw_mgr_msg_free (req);
- return -1;
- }
-
- if (!nsfw_mgr_send_req_wait_rsp (req, rsp))
- {
- printf ("request memory can not get response.\n");
- nsfw_mgr_msg_free (req);
- nsfw_mgr_msg_free (rsp);
- return -1;
- }
-
- if (rsp->src_proc_type != NSFW_PROC_MAIN
- || rsp->dst_proc_type != NSFW_PROC_TOOLS)
- {
- printf
- ("dump get wrong response, src or dst proc type error,src proc type=%u, dst proc type=%u.\n",
- rsp->src_proc_type, rsp->dst_proc_type);
- nsfw_mgr_msg_free (req);
- nsfw_mgr_msg_free (rsp);
- return -1;
- }
-
- if (rsp->msg_type != MGR_MSG_TOOL_TCPDUMP_RSP)
- {
- printf ("dump get wrong response, msg type error, msg type=%d.\n",
- rsp->msg_type);
- nsfw_mgr_msg_free (req);
- nsfw_mgr_msg_free (rsp);
- return -1;
- }
-
- nsfw_tool_dump_msg *rsp_body = GET_USER_MSG (nsfw_tool_dump_msg, rsp);
-
-/* BEGIN: Added for PN:CODEDEX by l00351127, 2017/11/14 CID:50859*/
- i16 new_task_id = rsp_body->task_id;
-/* END: Added for PN:CODEDEX by l00351127, 2017/11/14 */
-
- nsfw_mgr_msg_free (req);
- nsfw_mgr_msg_free (rsp);
-
- return new_task_id;
-}
-
-i16
-start_dump_task (u32 task_keep_time)
-{
- return dump_send_req (START_DUMP_REQ, -1, task_keep_time);
-}
-
-i16
-stop_dump_task (i16 task_id)
-{
- return dump_send_req (STOP_DUMP_REQ, task_id, 0);
-}
-
-NSTACK_STATIC void
-init_dump_condition (dump_condition * condition)
-{
- if (EOK !=
- MEMSET_S (condition, sizeof (dump_condition), 0,
- sizeof (dump_condition)))
- {
- printf ("MEMSET_S failed.\n");
- }
- condition->limit_len = DUMP_MSG_SIZE;
- condition->dump_time = DEFAULT_DUMP_TIME;
- condition->direction = 3;
- condition->dump_count = DEFAULT_DUMP_COUNT;
-}
-
-NSTACK_STATIC inline bool
-send_hbt_req (u32 seq, i16 task_id)
-{
- nsfw_mgr_msg *req =
- (nsfw_mgr_msg *) nsfw_mgr_msg_alloc (MGR_MSG_TOOL_HEART_BEAT,
- NSFW_PROC_MAIN);
- if (NULL == req)
- {
- printf ("all message for getting instance id failed.\n");
- return false;
- }
-
- nsfw_tool_hbt *req_body = GET_USER_MSG (nsfw_tool_hbt, req);
- req_body->seq = seq;
- req_body->task_id = task_id;
-
- if (!nsfw_mgr_send_msg (req))
- {
- printf ("request memory can not get response.\n");
- }
-
- nsfw_mgr_msg_free (req);
-
- return true;
-}
-
-NSTACK_STATIC bool
-on_send_hbt_req (u32 timer_type, void *data)
-{
- dump_timer_info *ptimer_info = (dump_timer_info *) data;
- // send heartbeat
-
- send_hbt_req (ptimer_info->seq, ptimer_info->task_id);
- ptimer_info->seq++;
-
- ptimer_info->ptimer =
- nsfw_timer_reg_timer (DUMP_HBT_TIMER, ptimer_info, on_send_hbt_req,
- *(struct timespec *) (ptimer_info->interval));
- return true;
-}
-
-NSTACK_STATIC bool
-start_dump_hbt (dump_timer_info * ptimer_info, i16 task_id)
-{
- struct timespec *time_interval =
- (struct timespec *) malloc (sizeof (struct timespec));
- if (NULL == time_interval)
- {
- return false;
- }
-
- time_interval->tv_sec = DUMP_HBT_INTERVAL;
- time_interval->tv_nsec = 0;
-
- ptimer_info->interval = time_interval;
- ptimer_info->seq = 1;
- ptimer_info->task_id = task_id;
-
- ptimer_info->ptimer =
- nsfw_timer_reg_timer (DUMP_HBT_TIMER, ptimer_info, on_send_hbt_req,
- *time_interval);
-
- return true;
-}
-
-NSTACK_STATIC bool
-stop_dump_hbt (dump_timer_info * ptimer_info)
-{
- free (ptimer_info->interval);
- /* fix "SET_NULL_AFTER_FREE" type codedex issue */
- ptimer_info->interval = NULL;
- nsfw_timer_rmv_timer (ptimer_info->ptimer);
- return true;
-}
-
-#ifndef NSTACK_STATIC_CHECK
-int
-main (int argc, char *argv[])
-#else
-int
-ntcpdump_main (int argc, char *argv[])
-#endif
-{
- register_dump_signal ();
-
- init_dump_condition (&g_dump_condition);
- if (!get_dump_condition (argc, argv, &g_dump_condition))
- {
- printf ("dump exit because of input invalid.\n");
- return INPUT_INVALID;
- }
-
- printf ("parse filter condition ok.\n");
-
- fw_poc_type proc_type = NSFW_PROC_TOOLS;
- nsfw_mem_para stinfo = { 0 };
- stinfo.iargsnum = 0;
- stinfo.pargs = NULL;
- stinfo.enflag = proc_type;
- nstack_framework_setModuleParam (NSFW_MEM_MGR_MODULE, &stinfo);
- nstack_framework_setModuleParam (NSFW_MGR_COM_MODULE,
- (void *) ((u64) proc_type));
- nstack_framework_setModuleParam (NSFW_TIMER_MODULE,
- (void *) ((u64) proc_type));
-
- if (0 != nstack_framework_init ())
- {
- printf ("dump init failed.\n");
- return FRAMEWORK_INIT_FAILED;
- }
-
- mring_handle dump_mem_pool = dump_get_mem_pool ();
- if (NULL == dump_mem_pool)
- {
- printf ("dump init mem pool failed.\n");
- return MEMPOOL_INIT_FAILED;
- }
-
- mring_handle dump_mem_ring = dump_get_mem_ring ();
- if (NULL == dump_mem_ring)
- {
- printf ("dump init mem ring failed.\n");
- return MEMRING_INIT_FAILED;
- }
-
- // initialize queue first
- dump_clear_mem (dump_mem_ring, dump_mem_pool);
-
- i16 task_id = start_dump_task (g_dump_condition.dump_time);
- if (task_id < 0 || task_id > MAX_DUMP_TASK)
- {
- printf ("start dump task failed.\n");
- return START_TASK_FAILED;
- }
-
- if (!start_dump_hbt (&g_dump_hbt_timer, task_id))
- {
- printf ("start dump heart beat timer failed.\n");
- return START_TIMER_FAILED;
- }
-
- struct timespec dump_start_time;
- GET_CUR_TIME (&dump_start_time);
- dump_msg (dump_mem_ring, dump_mem_pool, &g_dump_condition,
- &dump_start_time);
-
- i16 new_task_id = stop_dump_task (task_id);
- if (new_task_id != task_id)
- {
- printf ("stop dump task failed.\n");
- }
- /* modify deadcode type codedex issue */
- (void) stop_dump_hbt (&g_dump_hbt_timer);
-
- printf ("dump complete.\n");
- printf ("captured packets=%u.\n", g_captured_packet);
- printf ("dumped packets=%u.\n", g_dumped_packet);
- printf ("filtered packets=%u.\n", g_filtered_packet);
-
- return 0;
-}
diff --git a/stacks/lwip_stack/tools/tool_common.h b/stacks/lwip_stack/tools/tool_common.h
deleted file mode 100644
index 6d3526b..0000000
--- a/stacks/lwip_stack/tools/tool_common.h
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
-*
-* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-* 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.
-*/
-
-#ifndef _TOOL_COMMON_H_
-#define _TOOL_COMMON_H_
-
-#include <time.h>
-#include "types.h"
-
-#ifndef NSTACK_STATIC
-#ifndef NSTACK_STATIC_CHECK
-#define NSTACK_STATIC static
-#else
-#define NSTACK_STATIC
-#endif
-#endif
-
-#ifndef IP_ADDR_LEN
-#define IP_ADDR_LEN 16
-#endif
-
-#ifndef MAC_ADDR_LEN
-#define MAC_ADDR_LEN 6
-#endif
-
-#ifndef MAC_ADDR_STR_LEN
-#define MAC_ADDR_STR_LEN 17
-#endif
-
-#define ICMP_ECHO 8
-#define ICMP_REPLY 0
-#define MS_TO_NS 1000000
-#define US_TO_NS 1000
-#define NPING_RETRY_COUNT 1000
-#define MAX_NPING_RETRY_COUNT 20000
-
-#define MAX_PORT_STR_LEN 5
-#define MAX_IP_STR_LEN 15
-#define MAX_INTEGER_STR_LEN 10
-
-#define DUMP_HBT_TIMER 1
-
-#define INVALID_DIRECTION 0xFFFF
-#define DEFAULT_DUMP_COUNT 1000
-
-#ifndef CUSTOM_SOCK_TYPE
-#define CUSTOM_SOCK_TYPE 0xF001
-#endif
-
-enum DUMP_ERR_CODE
-{
- RET_OK = 0,
- INPUT_INVALID = 1,
- FRAMEWORK_INIT_FAILED = 2,
- MEMPOOL_INIT_FAILED = 3,
- MEMRING_INIT_FAILED = 4,
- START_TASK_FAILED = 5,
- START_TIMER_FAILED = 6,
- UNKNOW_ERR
-};
-
-enum COND_LOCAL_REMOTE_SET
-{
- COND_NOT_SET = 0,
- COND_REMOTE_SET = 0x1,
- COND_LOCAL_SET = 0x2,
- COND_AND_SET = 0x3,
- COND_OR_SET = 0x4
-};
-
-enum DUMP_OPT_ARG
-{
- OPT_ARG_HOST = 256,
- OPT_ARG_LOCAL_HOST,
- OPT_ARG_REMOTE_HOST,
- OPT_ARG_PORT,
- OPT_ARG_LOCAL_PORT,
- OPT_ARG_REMOTE_PORT,
- OPT_ARG_MAC,
- OPT_ARG_LOCAL_MAC,
- OPT_ARG_REMOTE_MAC,
- OPT_ARG_INVALID
-};
-
-typedef struct _ip_head
-{
- u8 ihl:4;
- u8 version:4;
- u8 tos;
- u16 tot_len;
- u16 id;
- u16 frag_off;
- u8 ttl;
- u8 protocol;
- u16 chk_sum;
- u32 local_ip;
- u32 remote_ip;
-} ip_head;
-
-typedef struct _tcp_head
-{
- u16 src_port;
- u16 dst_port;
- u32 seq_no;
- u32 ack_no;
-} tcp_head;
-
-typedef struct _udp_head
-{
- u16 src_port;
- u16 dst_port;
- u16 uhl;
- u16 chk_sum;
-} udp_head;
-
-typedef struct _dump_file_head
-{
- u32 magic;
- u16 major_ver;
- u16 minor_ver;
- u32 area;
- u32 time_stamp;
- u32 max_pack_size;
- u32 link_type;
-} dump_file_head;
-
-typedef struct _packet_head
-{
- u32 sec;
- u32 usec;
- u32 save_len;
- u32 org_len;
-} packet_head;
-
-typedef struct _ip_addr_bits
-{
- u32 addr_bits1;
- u32 addr_bits2;
- u32 addr_bits3;
- u32 addr_bits4;
-} ip_addr_bits;
-
-typedef struct _parse_msg_info
-{
- u16 l2_protocol; // ARP/IP/OAM/LACP
- u16 l3_protocol; // TCP/UDP/ICMP
- u16 local_port;
- u16 remote_port;
- u32 local_ip;
- u32 remote_ip;
- char local_mac[MAC_ADDR_LEN + 1];
- char remote_mac[MAC_ADDR_LEN + 1];
-
- void *org_msg;
-} parse_msg_info;
-
-typedef struct _dump_condition
-{
- bool has_condition;
- u32 dump_count;
- u32 dump_time;
- u32 limit_len;
- u16 direction; //1:send 2:recv 3:send-recv
- u16 l2_protocol; // ARP/IP/OAM/LACP
- u16 l3_protocol; // TCP/UDP/ICMP
- u16 port_set_flag;
- u16 port;
- u16 local_port;
- u16 remote_port;
- u16 ip_set_flag;
- u32 ip_addr;
- u32 local_ip;
- u32 remote_ip;
- u16 mac_set_flag;
- char mac_addr[MAC_ADDR_LEN + 1];
- char local_mac[MAC_ADDR_LEN + 1];
- char remote_mac[MAC_ADDR_LEN + 1];
-
- char *dump_file_name;
-} dump_condition;
-
-typedef struct _icmp_head
-{
- u8 icmp_type;
- u8 icmp_code;
- u16 icmp_cksum;
- u16 icmp_id;
- u16 icmp_seq;
- u32 timestamp;
-
- long icmp_sec;
- long icmp_nsec;
-} icmp_head;
-
-typedef struct _ning_input_info
-{
- i32 send_count; // total send req
- i32 retry_count; // retry count for 1 req
- char src_ip[IP_ADDR_LEN];
- char dst_ip[IP_ADDR_LEN];
-} input_info;
-
-typedef struct _nping_stat_info
-{
- u32 send_seq;
- u32 recv_ok;
- double all_interval;
- double min_interval;
- double max_interval;
- struct timespec start_time;
- struct timespec end_time;
-} stat_info;
-
-#ifndef sys_sleep_ns
-#define sys_sleep_ns(_s, _ns)\
-{ \
- if (_s >= 0 && _ns >= 0) \
- { \
- struct timespec delay, remain; \
- delay.tv_sec = _s; \
- delay.tv_nsec = _ns; \
- while (nanosleep(&delay, &remain) < 0) \
- { \
- delay = remain; \
- } \
- } \
-}
-#endif
-
-#endif
diff --git a/stacks/lwip_stack/vagrant/Vagrantfile b/stacks/lwip_stack/vagrant/Vagrantfile
deleted file mode 100644
index b3a31c1..0000000
--- a/stacks/lwip_stack/vagrant/Vagrantfile
+++ /dev/null
@@ -1,65 +0,0 @@
-# -*- mode: ruby -*-
-# vi: set ft=ruby :
-
-Vagrant.configure(2) do |config|
-
- # Pick the right distro and bootstrap, default is ubuntu1604
- distro = ( ENV['DMM_VAGRANT_DISTRO'] || "ubuntu")
- if distro == 'centos7'
- config.vm.box = "puppetlabs/centos-7.2-64-nocm"
- else
- config.vm.box = "puppetlabs/ubuntu-16.04-64-nocm"
- end
- config.vm.box_check_update = false
-
- # Create DMM client and server VM's
- config.vm.define "dmm-stackx-server" do |server|
- server.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"../../../scripts/install_prereq.sh")
- server.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"build.sh"), :args => "/DMM vagrant"
- server.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"start_nstackMain.sh"), :args => "/DMM vagrant"
- end
- config.vm.define "dmm-stackx-client" do |client|
- client.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"../../../scripts/install_prereq.sh")
- client.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"build.sh"), :args => "/DMM vagrant"
- client.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"start_nstackMain.sh"), :args => "/DMM vagrant"
- end
-
-
- # vagrant-cachier caches apt/yum etc to speed subsequent
- # vagrant up
- # to enable, run
- # vagrant plugin install vagrant-cachier
- #
- if Vagrant.has_plugin?("vagrant-cachier")
- config.cache.scope = :box
- end
-
- # Define some physical ports for your VMs to be used by DPDK
- nics = (ENV['DMM_VAGRANT_NICS'] || "2").to_i(10)
- for i in 1..nics
- config.vm.network "private_network", type: "dhcp"
- # config.vm.network "private_network", ip: "172.28.128.200"
- # config.vm.network "private_network", ip: "172.28.128.201"
- end
-
- # use http proxy if avaiable
- if ENV['http_proxy'] && Vagrant.has_plugin?("vagrant-proxyconf")
- config.proxy.http = ENV['http_proxy']
- config.proxy.https = ENV['https_proxy']
- config.proxy.no_proxy = "localhost,127.0.0.1"
- end
-
- vmcpu=(ENV['DMM_VAGRANT_VMCPU'] || 4)
- vmram=(ENV['DMM_VAGRANT_VMRAM'] || 5120)
-
- config.ssh.forward_agent = true
- config.ssh.forward_x11 = true
-
- config.vm.provider "virtualbox" do |vb|
- vb.customize ["modifyvm", :id, "--ioapic", "on"]
- vb.memory = "#{vmram}"
- vb.cpus = "#{vmcpu}"
-
- config.vm.synced_folder "../../../", "/DMM", type: "rsync"
- end
-end
diff --git a/stacks/lwip_stack/vagrant/build.sh b/stacks/lwip_stack/vagrant/build.sh
deleted file mode 100755
index a934eef..0000000
--- a/stacks/lwip_stack/vagrant/build.sh
+++ /dev/null
@@ -1,59 +0,0 @@
-#########################################################################
-# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-# 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.
-#########################################################################
-#!/bin/bash -x
-
-set -x
-
-TIMESTAMP=$(date +%Y-%m-%d_%H-%M-%S)
-log_file="/tmp/build_log.txt-$TIMESTAMP"
-exec 1> >(tee -a "$log_file") 2>&1
-
-# Get Command Line arguements if present
-if [ "$1" == "from-base-build" ]; then
- WAS_DMM_BUILT="YES"
-fi
-
-if [ "x$1" != "x" ] && [ "$1" != "from-base-build" ]; then
- TEMP_DIR=$1
- DMM_BUILD_SCRIPT_DIR=${TEMP_DIR}/scripts
- LWIP_BUILD_DIR=${TEMP_DIR}/stacks/lwip_stack/build/
-else
- TEMP_DIR=`dirname $(readlink -f $0)`/..
- DMM_BUILD_SCRIPT_DIR=${TEMP_DIR}/../../scripts
- LWIP_BUILD_DIR=${TEMP_DIR}/build/
-fi
-
-echo 0:$0
-echo 1:$1
-echo 2:$2
-echo TEMP_DIR: $TEMP_DIR
-echo DMM_BUILD_SCRIPT_DIR: $DMM_BUILD_SCRIPT_DIR
-echo LWIP_BUILD_DIR: $LWIP_BUILD_DIR
-
-if [ 'x$WAS_DMM_BUILT' != "xYES" ]; then
- bash -x $DMM_BUILD_SCRIPT_DIR/build.sh
-fi
-
-#===========build LWIP===========
-echo "LWIP build started....."
-cd $LWIP_BUILD_DIR
-cmake ..
-make -j 8
-if [ $? -eq 0 ]; then
- echo "LWIP build is SUCCESS"
-else
- echo "LWIP build has FAILED"
- exit 1
-fi
diff --git a/stacks/lwip_stack/vagrant/env.sh b/stacks/lwip_stack/vagrant/env.sh
deleted file mode 100755
index 96ad346..0000000
--- a/stacks/lwip_stack/vagrant/env.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/env bash
-
-#export DMM_VAGRANT_DISTRO="ubuntu1604"
-export DMM_VAGRANT_DISTRO="centos7"
-export DMM_VAGRANT_NICS=2
-export DMM_VAGRANT_VMCPU=4
-export DMM_VAGRANT_VMRAM=8192
diff --git a/stacks/lwip_stack/vagrant/start_nstackMain.sh b/stacks/lwip_stack/vagrant/start_nstackMain.sh
deleted file mode 100755
index fb25b6f..0000000
--- a/stacks/lwip_stack/vagrant/start_nstackMain.sh
+++ /dev/null
@@ -1,110 +0,0 @@
-#########################################################################
-# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-# 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.
-#########################################################################
-#!/bin/bash -x
-
-set -x
-
-DPDK_DOWNLOAD_PATH=/tmp/dpdk
-ifname=enp0s8
-
-if [ "x$1" != "x" ] && [ "$1" != "from-base-build" ]; then
- TEMP_DIR=$1
- DMM_BUILD_SCRIPT_DIR=${TEMP_DIR}/scripts
- LWIP_BUILD_DIR=${TEMP_DIR}/stacks/lwip_stack/build/
-else
- TEMP_DIR=`dirname $(readlink -f $0)`/..
- DMM_BUILD_SCRIPT_DIR=${TEMP_DIR}/../../scripts
- LWIP_BUILD_DIR=${TEMP_DIR}/build/
-fi
-
-LIB_PATH=$LWIP_BUILD_DIR/../release/lib64/
-
-echo 0:$0
-echo 1:$1
-echo 2:$2
-echo TEMP_DIR: $TEMP_DIR
-echo DMM_BUILD_SCRIPT_DIR: $DMM_BUILD_SCRIPT_DIR
-echo LWIP_BUILD_DIR: $LWIP_BUILD_DIR
-echo LIB_PATH: $LIB_PATH
-
-#===========check hugepages=================
-source $DMM_BUILD_SCRIPT_DIR/check_hugepage.sh
-
-OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
-if [ "$OS_ID" == "centos" ]; then
- ifaddress1=$(ifconfig $ifname | grep 'inet' | cut -d: -f2 | awk '{print $2}')
- echo $ifaddress1
- ifaddresscut=$(ifconfig $ifname | grep 'inet' | head -n 1 | awk -F " " '{print $2}' | awk -F "." '{print $1"."$2"."$3}')
- echo $ifaddresscut
- ifmac=$(ifconfig $ifname | grep 'ether' | awk -F " " '{print $2}')
- echo $ifmac
-elif [ "$OS_ID" == "ubuntu" ]; then
- ifaddress1=$(ifconfig $ifname | grep 'inet' | head -n 1 | cut -d: -f2 | awk '{print $1}')
- echo $ifaddress1
- ifaddresscut=$(ifconfig $ifname | grep 'inet' | head -n 1 | cut -d: -f2 | awk '{print $1}' | awk -F "." '{print $1"."$2"."$3}')
- echo $ifaddresscut
- ifmac=$(ifconfig $ifname | grep 'HWaddr' | awk -F " " '{print $5}')
- echo $ifmac
-fi
-
-cd $LWIP_BUILD_DIR/../
-cd release/script
-sed -i 's!DPDK_INSTALL_PATH=.*!DPDK_INSTALL_PATH='$DPDK_DOWNLOAD_PATH'/dpdk-18.02!1' nstack_var.sh
-
-cd ../
-chmod 775 *
-cp ./configure/*.json bin/
-cd bin
-
-sed -i 's!192.168.1.207!'$ifaddress1'!1' ip_data.json
-
-sed -i 's!192.168.1.1!'$ifaddresscut'.0!1' network_data_tonStack.json
-
-if [ "$OS_ID" == "centos" ]; then
- sed -i 's!eth7!'$ifname'!1' network_data_tonStack.json
-elif [ "$OS_ID" == "ubuntu" ]; then
- sed -i 's!eth7!'$ifname'!1' network_data_tonStack.json
-fi
-sed -i 's!eth7!'$ifname'!1' network_data_tonStack.json
-
-cd $DMM_BUILD_SCRIPT_DIR/../release/bin
-cp -r . ../../stacks/lwip_stack/app_test
-cd $DMM_BUILD_SCRIPT_DIR/../stacks/lwip_stack/app_test
-cp -r ../configure/*.json .
-
-sed -i 's!192.168.1.1!'$ifaddresscut'.0!1' rd_config.json
-
-sudo mkdir -p /var/run/ip_module/
-sudo mkdir -p /var/log/nStack/ip_module/
-
-export LD_LIBRARY_PATH=$LIB_PATH
-if [ "$NSTACK_LOG_ON" = "PERF" ]
-then
- export NSTACK_LOG_ON=PERF
-else
- export NSTACK_LOG_ON=DBG
-fi
-
-cd $LWIP_BUILD_DIR/../release
-bash -x ./stop_nstack.sh
-bash -x ./start_nstack.sh
-check_result=$(pgrep nStackMain)
-if [ -z "$check_result" ]; then
- echo "nStackMain execute failed"
- exit 1
-else
- echo "nStackMain execute successful"
- exit 0
-fi
diff --git a/stacks/readme.txt b/stacks/readme.txt
new file mode 100644
index 0000000..9c32a95
--- /dev/null
+++ b/stacks/readme.txt
@@ -0,0 +1 @@
+1.´ËĿ¼ÓÃÓÚ·ÅЭÒéÕ»£¬Ã¿¸öЭÒéʹÓõ¥¶ÀÒ»¸öĿ¼ \ No newline at end of file
diff --git a/stacks/rsocket/CMakeLists.txt b/stacks/rsocket/CMakeLists.txt
index 6ba868b..6516961 100644
--- a/stacks/rsocket/CMakeLists.txt
+++ b/stacks/rsocket/CMakeLists.txt
@@ -13,40 +13,62 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#########################################################################
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11)
+#PROJECT(nStack)
+SET(CMAKE_SKIP_RPATH TRUE)
+SET(CMAKE_C_COMPILER "gcc")
+SET(OS_RELEASE "" CACHE STRING "User-specified OS release.")
+SET(EXECUTABLE_PATH ${CMAKE_CURRENT_LIST_DIR}/../../release/bin)
+SET(LIB_PATH_STATIC ${CMAKE_SOURCE_DIR}/build)
+SET(LIB_PATH_SHARED ${CMAKE_CURRENT_LIST_DIR}/../../release/lib64)
+SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIB_PATH_STATIC})
+SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_PATH})
+SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIB_PATH_SHARED})
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g -fPIE -pie -fPIC -m64 -mssse3 -std=gnu89")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wshadow -Wfloat-equal -Wformat=2")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector -fstack-protector-all")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-z,relro,-z,now -Wl,--disable-new-dtags")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-z,noexecstack -mcmodel=medium")
SET(rdmacm_dir librdmacm-1.1.0)
-SET(dmm_inc_dir ${DMM_REL_INC_DIR})
+SET(dmm_inc_dir ${CMAKE_CURRENT_LIST_DIR}/../../release/include/)
+SET(DMM_REL_INC_DIR ${dmm_inc_dir})
+SET(dmm_src_inc_dir ${CMAKE_SOURCE_DIR}/src/include/)
SET(RSOCKET_DEBUG 1)
########################
-
SET(rdmacm_url https://github.com/ofiwg/librdmacm/archive/v1.1.0.tar.gz)
-
+if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/v1.1.0.tar.gz")
+ SET(RDMA_DOWNLOAD_CMD tar -xvf ${CMAKE_CURRENT_LIST_DIR}/v1.1.0.tar.gz)
+else()
+ SET(RDMA_DOWNLOAD_CMD wget --no-check-certificate ${rdmacm_url} && tar -xvf ${CMAKE_CURRENT_LIST_DIR}/v1.1.0.tar.gz)
+endif()
INCLUDE(ExternalProject)
ExternalProject_Add(
rdmacm
- URL ${rdmacm_url}
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/${rdmacm_dir}
DOWNLOAD_DIR ${CMAKE_CURRENT_LIST_DIR}
+ DOWNLOAD_COMMAND ${RDMA_DOWNLOAD_CMD}
PATCH_COMMAND patch -p1 -i ../rsocket.patch
CONFIGURE_COMMAND ./autogen.sh && ./configure dmm_inc_dir=${DMM_REL_INC_DIR} RSOCKET_DEBUG=${RSOCKET_DEBUG}
BUILD_IN_SOURCE 1
BUILD_COMMAND make
INSTALL_COMMAND cp -f libdmm_rdmacm.a ${LIB_PATH_STATIC}/
- DEPENDS DPDK
)
-set_target_properties(rdmacm PROPERTIES EXCLUDE_FROM_ALL TRUE)
########################
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -g -fPIC -m64 -pthread")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g -fPIC -m64 -pthread")
ADD_LIBRARY(dmm_rsocket SHARED src/rsocket_adpt.c)
ADD_DEFINITIONS(-D_GNU_SOURCE -DRSOCKET_DEBUG=${RSOCKET_DEBUG})
-INCLUDE_DIRECTORIES(${DMM_REL_INC_DIR})
+INCLUDE_DIRECTORIES(
+ ${DMM_REL_INC_DIR} ${dmm_src_inc_dir}
+)
INCLUDE_DIRECTORIES(./src ${rdmacm_dir} ${rdmacm_dir}/include ${rdmacm_dir}/src)
TARGET_LINK_LIBRARIES(dmm_rsocket
@@ -56,6 +78,4 @@ TARGET_LINK_LIBRARIES(dmm_rsocket
ibverbs pthread dl rt
)
-ADD_DEPENDENCIES(dmm_rsocket rdmacm DPDK)
-
-set_target_properties(dmm_rsocket PROPERTIES EXCLUDE_FROM_ALL TRUE)
+ADD_DEPENDENCIES(dmm_rsocket rdmacm)
diff --git a/stacks/lwip_stack/patch/.gitkeep b/stacks/rsocket/build/.gitkeep
index e69de29..e69de29 100644
--- a/stacks/lwip_stack/patch/.gitkeep
+++ b/stacks/rsocket/build/.gitkeep
diff --git a/stacks/rsocket/configure/module_config.json b/stacks/rsocket/configure/module_config.json
index 736de24..2df82cd 100644
--- a/stacks/rsocket/configure/module_config.json
+++ b/stacks/rsocket/configure/module_config.json
@@ -3,17 +3,27 @@
"module_list": [
{
"stack_name": "kernel", /*stack name*/
+ "function_name": "kernel_stack_register", /*function name*/
"libname": "./", /*library name, if loadtype is static, this maybe
null, else must give a library name*/
+ "loadtype": "static", /*library load type: static or dynamic*/
"deploytype": "1", /*deploy model type:model type1, model type2,
model type3. Indicating single or multi process
deployment. Used during shared memory initialization.*/
+ "maxfd": "1024", /*the max fd supported*/
+ "minfd": "0", /*the min fd supported*/
+ "priorty": "1", /*priorty when executing, reserv*/
"stackid": "0", /*stack id, this must be ordered and not be repeated*/
},
{
"stack_name": "rsocket",
+ "function_name": "rsocket_stack_register",
"libname": "libdmm_rsocket.so",
+ "loadtype": "dynmic",
"deploytype": "1",
+ "maxfd": "1024",
+ "minfd": "0",
+ "priorty": "1",
"stackid": "1",
},
]
diff --git a/stacks/rsocket/configure/rd_config.json b/stacks/rsocket/configure/rd_config.json
index 5c6f861..d89afcf 100644
--- a/stacks/rsocket/configure/rd_config.json
+++ b/stacks/rsocket/configure/rd_config.json
@@ -1,10 +1,25 @@
{
- "ip_route": [
- {
- "subnet": "192.168.1.1/24",
- "stack_name": "rsocket",
- },
- ],
- "prot_route": [
- ],
+ "modules": [
+ {
+ "name": "kernel",
+ "ip_route": [
+ "127.0.0.1/24"
+ ],
+ "protocol_route": [
+ ],
+ "type_route": [
+ ]
+ },
+ {
+ "name": "rsocket",
+ "ip_route": [
+ "192.168.21.1/24"
+
+ ],
+ "protocol_route": [
+ ],
+ "type_route": [
+ ]
+ }
+ ]
}
diff --git a/stacks/rsocket/doc/README.md b/stacks/rsocket/doc/README.md
index 6cdacfb..237db68 100644
--- a/stacks/rsocket/doc/README.md
+++ b/stacks/rsocket/doc/README.md
@@ -34,10 +34,10 @@ dmm/release/lib64/libdmm_rsocket.so
```sh
#export LD_LIBRARY_PATH=${dmm}/release/lib64
#export LD_PRELOAD=${dmm}/release/lib64/libnStackAPI.so
- #export NSTACK_MOD_CFG_FILE=${dmm}/stacks/rsocket/configure/module_config.json
- #export NSTACK_MOD_CFG_RD=${dmm}/stacks/rsocket/configure/rd_config.json
+ #export NSTACK_MOD_CFG_FILE=${dmm}/stacks/rsocket/config/module_config.json
+ #export NSTACK_MOD_CFG_RD=${dmm}/stacks/rsocket/config/rd_config.json
```
-- Steps 2: Modify rd_config.json(located at dmm/stacks/rsocket/configure/)
+- Steps 2: Modify rd_config.json(located at dmm/stacks/rsocket/config/)
```sh
#vim rd_config.json
//set "subnet": "192.168.21.1/24"
@@ -107,4 +107,4 @@ all using GSAPI macro control.
https://wiki.fd.io/view/DMM
https://github.com/ofiwg/librdmacm/blob/master/docs/rsocket
https://github.com/rsocket/rsocket
-http://www.mellanox.com/page/products_dyn?product_family=26
+http://www.mellanox.com/page/products_dyn?product_family=26 \ No newline at end of file
diff --git a/stacks/rsocket/src/rsocket_adpt.c b/stacks/rsocket/src/rsocket_adpt.c
index 2839909..9496e96 100644
--- a/stacks/rsocket/src/rsocket_adpt.c
+++ b/stacks/rsocket/src/rsocket_adpt.c
@@ -19,10 +19,11 @@
#include <errno.h>
#include <dlfcn.h>
-#include "nstack_dmm_api.h"
-
+#include "nstack_callback_ops.h"
#include "rsocket_adpt.h"
#include "rdma/rsocket.h"
+#include "nstack_epoll_api.h"
+#include "nstack_rd_api.h"
#define RR_EVFD(u64) ((int)((u64) >> 32))
#define RR_RSFD(u64) ((int)((u64) & 0xFFFFFFFF))
@@ -36,77 +37,69 @@ rr_sapi_t g_sapi = { 0 };
int g_rr_log_level = -1;
-int
-rr_notify_event (void *pdata, int events)
-{
- int ret;
-
- ret = g_rr_var.event_cb (pdata, events);
-
- RR_DBG ("event_cb(%p, 0x%x)=%d,%d\n", pdata, events, ret, errno);
+void *rrd_table = NULL;
- return ret;
+void rr_notify_event(void *pdata, int events)
+{
+ g_rr_var.event_cb(pdata, events, EVENT_INFORM_APP);
}
-int
-rr_epoll_ctl (int op, int evfd, uint32_t events, int rsfd)
+int rr_epoll_ctl(int op, int evfd, uint32_t events, int rsfd)
{
- int ret;
- struct epoll_event event;
- event.events = events;
- event.data.u64 = RR_DATA (evfd, rsfd);
- ret = GSAPI (epoll_ctl) (g_rr_var.epfd, op, evfd, &event);
- return ret;
+ int ret;
+ struct epoll_event event;
+ event.events = events;
+ event.data.u64 = RR_DATA(evfd, rsfd);
+ ret = GSAPI(epoll_ctl) (g_rr_var.epfd, op, evfd, &event);
+ return ret;
}
-static void *
-rr_epoll_thread (void *arg)
+static void *rr_epoll_thread(void *arg)
{
- int i, ret, e;
- struct epoll_event events[RR_EV_NUM];
+ int i, ret, e;
+ struct epoll_event events[RR_EV_NUM];
- while (1)
+ while (1)
{
- ret = GSAPI (epoll_wait) (g_rr_var.epfd, events, RR_EV_NUM, 100);
- e = errno;
+ ret = GSAPI(epoll_wait) (g_rr_var.epfd, events, RR_EV_NUM, 100);
+ e = errno;
- for (i = 0; i < ret; ++i)
+ for (i = 0; i < ret; ++i)
{
- if (rr_rs_handle (RR_RSFD (events[i].data.u64), events[i].events))
+ if (rr_rs_handle(RR_RSFD(events[i].data.u64), events[i].events))
{
- (void) rr_ep_del (RR_EVFD (events[i].data.u64));
+ (void) rr_ep_del(RR_EVFD(events[i].data.u64));
}
}
- if (ret < 0)
+ if (ret < 0)
{
- RR_STAT_INC (RR_STAT_EPW_ERR);
- if (e == EINTR)
+ RR_STAT_INC(RR_STAT_EPW_ERR);
+ if (e == EINTR)
{
- RR_STAT_INC (RR_STAT_EPW_EINTR);
+ RR_STAT_INC(RR_STAT_EPW_EINTR);
}
- else if (e == ETIMEDOUT)
+ else if (e == ETIMEDOUT)
{
- RR_STAT_INC (RR_STAT_EPW_ETIMEOUT);
+ RR_STAT_INC(RR_STAT_EPW_ETIMEOUT);
}
- else
+ else
{
- RR_ERR ("epoll_wait()=%d:%d\n", ret, errno);
+ RR_ERR("epoll_wait()=%d:%d\n", ret, errno);
}
}
}
- return NULL;
+ return NULL;
}
-static int
-rr_init_sapi ()
+static int rr_init_sapi()
{
- void *handle = dlopen ("libc.so.6", RTLD_NOW | RTLD_GLOBAL);
- if (!handle)
+ void *handle = dlopen("libc.so.6", RTLD_NOW | RTLD_GLOBAL);
+ if (!handle)
{
- RR_ERR ("dlopen(libc.so.6):NULL\n");
- return -1;
+ RR_ERR("dlopen(libc.so.6):NULL\n");
+ return -1;
}
#define RR_SAPI(name) \
@@ -116,129 +109,148 @@ rr_init_sapi ()
#include "rsocket_sapi.h"
#undef RR_SAPI
- return 0;
+ return 0;
}
-static void
-rr_init_log ()
+static void rr_init_log()
{
- int level;
- char *log;
+ int level;
+ char *log;
- if (g_rr_log_level >= 0)
- return;
+ if (g_rr_log_level >= 0)
+ return;
- log = getenv ("RSOCKET_LOG");
- if (!log || !log[0])
+ log = getenv("RSOCKET_LOG");
+ if (!log || !log[0])
{
- g_rr_log_level = RR_LOG_OFF;
- return;
+ g_rr_log_level = RR_LOG_OFF;
+ return;
}
- level = atoi (log);
- if (level < 0 || level > 99999)
+ level = atoi(log);
+ if (level < 0 || level > 99999)
{
- g_rr_log_level = RR_LOG_OFF;
- return;
+ g_rr_log_level = RR_LOG_OFF;
+ return;
}
- g_rr_log_level = level;
+ g_rr_log_level = level;
}
-static int
-rsocket_init ()
+void *rsocket_get_ip_shmem()
{
- int ret;
+ return rrd_table;
+}
- rr_init_log ();
+static int rsocket_init()
+{
+ int ret;
+ rrd_table = nstack_local_rd_malloc();
+ if (!rrd_table)
+ {
+ RR_ERR("rsocket rd table create failed!");
+ return -1;
+ }
- if (rr_init_sapi ())
+ if (nstack_rd_parse("rsocket", rrd_table))
{
- return -1;
+ RR_WRN("no rd data got!");
+ RR_WRN("rsocket parse rd data failed");
+ nstack_rd_table_clear(rrd_table);
+ return -1;
}
- g_rr_var.epfd = GSAPI (epoll_create) (1);
- if (g_rr_var.epfd < 0)
- return g_rr_var.epfd;
+ rr_init_log();
- ret =
- pthread_create (&g_rr_var.epoll_threadid, NULL, rr_epoll_thread, NULL);
- if (ret)
+ if (rr_init_sapi())
{
- GSAPI (close) (g_rr_var.epfd);
- g_rr_var.epfd = -1;
- return ret;
+ return -1;
}
- (void) pthread_setname_np (g_rr_var.epoll_threadid, "rsocket_epoll");
- return 0;
-}
+ g_rr_var.epfd = GSAPI(epoll_create) (1);
-int
-rsocket_exit ()
-{
- if (g_rr_var.epfd >= 0)
+ if (g_rr_var.epfd < 0)
{
- (void) GSAPI (close) (g_rr_var.epfd);
- g_rr_var.epfd = -1;
+ return g_rr_var.epfd;
}
- return 0;
+ ret =
+ pthread_create(&g_rr_var.epoll_threadid, NULL, rr_epoll_thread, NULL);
+ if (ret)
+ {
+ GSAPI(close) (g_rr_var.epfd);
+ g_rr_var.epfd = -1;
+ return ret;
+ }
+ (void) pthread_setname_np(g_rr_var.epoll_threadid, "rsocket_epoll");
+
+ return 0;
}
-unsigned int
-rsocket_ep_ctl (int epFD, int proFD, int ctl_ops, struct epoll_event *event,
- void *pdata)
+int rsocket_exit()
{
- int ret;
- struct eventpoll *ep;
- unsigned int revents = 0;
+ if (g_rr_var.epfd >= 0)
+ {
+ (void) GSAPI(close) (g_rr_var.epfd);
+ g_rr_var.epfd = -1;
+ }
- RR_DBG ("(%d, %d, %d, 0x%x, %p)\n", epFD, proFD, ctl_ops, event->events,
- pdata);
+ return 0;
+}
- switch (ctl_ops)
+void *rsocket_ep_ctl(int proFD, int ctl_ops, void *pdata, void *event)
+{
+ int ret;
+ unsigned int revents = 0;
+ switch (ctl_ops)
{
- case nstack_ep_triggle_add:
- ret = rr_rs_ep_add (proFD, pdata, &revents);
- if (ret)
- return -1;
- return revents;
-
- case nstack_ep_triggle_mod:
- ret = rr_rs_ep_mod (proFD, pdata, &revents);
- if (ret)
- return -1;
- return revents;
- case nstack_ep_triggle_del:
- return rr_rs_ep_del (proFD);
+ case nstack_ep_triggle_add:
+ ret = rr_rs_ep_add(proFD, pdata, &revents);
+ if (ret)
+ return NULL;
+ *(int *) event = revents;
+ return pdata;
+ case nstack_ep_triggle_mod:
+ ret = rr_rs_ep_mod(proFD, pdata, &revents);
+ if (ret)
+ return NULL;
+ *(int *) event = revents;
+ return pdata;
+ case nstack_ep_triggle_del:
+ rr_rs_ep_del(proFD);
}
- return _err (EPERM);
+ return pdata;
+
}
-int
-rsocket_stack_register (nstack_proc_cb * proc_fun,
- nstack_event_cb * event_ops)
+int rsocket_getEvt(int fd)
{
- rr_init_log ();
+ return rr_getEvt(fd);
+}
+
+int rsocket_stack_register(nstack_socket_ops * ops,
+ nstack_event_ops * event_ops,
+ nstack_proc_ops * proc_fun)
+{
+ rr_init_log();
#define NSTACK_MK_DECL(ret, fn, args) \
do { \
- proc_fun->socket_ops.pf##fn = dlsym(event_ops->handle, "r"#fn); \
- if (!proc_fun->socket_ops.pf##fn) \
+ ops->pf##fn = dlsym(event_ops->handle, "r"#fn); \
+ if (!ops->pf##fn) \
RR_LOG("socket API '" #fn "' not found\n"); \
} while (0)
-#include "declare_syscalls.h"
+#include "declare_syscalls.h.tmpl"
#undef NSTACK_MK_DECL
- proc_fun->extern_ops.module_init = rsocket_init;
- proc_fun->extern_ops.ep_ctl = rsocket_ep_ctl;
- proc_fun->extern_ops.ep_getevt = NULL;
- proc_fun->extern_ops.module_init_child = rsocket_init;
-
- g_rr_var.type = event_ops->type;
- g_rr_var.event_cb = event_ops->event_cb;
+ proc_fun->module_init = rsocket_init;
+ proc_fun->ep_triggle = rsocket_ep_ctl;
+ proc_fun->ep_getEvt = rsocket_getEvt;
+ proc_fun->get_ip_shmem = rsocket_get_ip_shmem;
+ proc_fun->fork_init_child = rsocket_init;
+ g_rr_var.type = event_ops->type;
+ g_rr_var.event_cb = event_ops->event_cb;
- return 0;
+ return 0;
}
diff --git a/stacks/rsocket/src/rsocket_adpt.h b/stacks/rsocket/src/rsocket_adpt.h
index 9c53330..37a2e88 100644
--- a/stacks/rsocket/src/rsocket_adpt.h
+++ b/stacks/rsocket/src/rsocket_adpt.h
@@ -22,11 +22,11 @@
enum
{
- RR_STAT_EPW_ERR,
- RR_STAT_EPW_EINTR,
- RR_STAT_EPW_ETIMEOUT,
+ RR_STAT_EPW_ERR,
+ RR_STAT_EPW_EINTR,
+ RR_STAT_EPW_ETIMEOUT,
- RR_STAT_NUM
+ RR_STAT_NUM
};
#define RR_STAT_ADD(id, num) __sync_add_and_fetch(&g_rr_var.stat[(id)], num)
@@ -38,17 +38,16 @@ enum
typedef struct rsocket_var
{
- pthread_t epoll_threadid;
+ pthread_t epoll_threadid;
- int epfd;
- int type;
- int (*event_cb) (void *pdata, int events);
+ int epfd;
+ int type;
+ void (*event_cb) (void *pdata, int events, int postFlag);
- uint64_t stat[RR_STAT_NUM];
+ uint64_t stat[RR_STAT_NUM];
} rsocket_var_t;
extern rsocket_var_t g_rr_var;
-
-int rr_rs_handle (int fd, uint32_t events);
-
+int rsocket_getEvt(int fd);
+int rr_rs_handle(int fd, uint32_t events);
#endif /* #ifndef _RSOCKET_ADPT_H_ */
diff --git a/stacks/rsocket/src/rsocket_rdma.h b/stacks/rsocket/src/rsocket_rdma.h
index 75f4268..af66285 100644
--- a/stacks/rsocket/src/rsocket_rdma.h
+++ b/stacks/rsocket/src/rsocket_rdma.h
@@ -31,11 +31,11 @@
enum
{
- RR_LOG_OFF = 0x00,
- RR_LOG_ERR = 0x01,
- RR_LOG_WRN = 0x02,
- RR_LOG_LOG = 0x03,
- RR_LOG_DBG = 0x04,
+ RR_LOG_OFF = 0x00,
+ RR_LOG_ERR = 0x01,
+ RR_LOG_WRN = 0x02,
+ RR_LOG_LOG = 0x03,
+ RR_LOG_DBG = 0x04,
};
#define RR_OUT(level, name, fmt, arg...) do { \
@@ -57,13 +57,13 @@ enum
#define _err(err_no) ((errno = (err_no)), -1)
-int rr_rs_ep_add (int fd, void *pdata, uint32_t * revent);
-int rr_rs_ep_mod (int fd, void *pdata, uint32_t * revent);
-int rr_rs_ep_del (int fd);
+int rr_rs_ep_add(int fd, void *pdata, uint32_t * revent);
+int rr_rs_ep_mod(int fd, void *pdata, uint32_t * revent);
+int rr_rs_ep_del(int fd);
-uint32_t rr_rs_poll (int fd, uint32_t revents);
-
-int rr_notify_event (void *pdata, int events);
+uint32_t rr_rs_poll(int fd, uint32_t revents);
+int rr_getEvt(int fd);
+void rr_notify_event(void *pdata, int events);
typedef struct rr_socket_api
{
@@ -76,21 +76,19 @@ extern rr_sapi_t g_sapi;
#define GSAPI(name) g_sapi.n_##name
-int rr_epoll_ctl (int op, int evfd, uint32_t events, int rsfd);
+int rr_epoll_ctl(int op, int evfd, uint32_t events, int rsfd);
-inline static int
-rr_ep_add (int evfd, int rsfd)
+inline static int rr_ep_add(int evfd, int rsfd)
{
- return rr_epoll_ctl (EPOLL_CTL_ADD, evfd, EPOLLET | EPOLLIN | EPOLLOUT,
- rsfd);
+ return rr_epoll_ctl(EPOLL_CTL_ADD, evfd, EPOLLET | EPOLLIN | EPOLLOUT,
+ rsfd);
}
-inline static int
-rr_ep_del (int evfd)
+inline static int rr_ep_del(int evfd)
{
- if (evfd < 0)
- return 0;
- return rr_epoll_ctl (EPOLL_CTL_DEL, evfd, 0, 0);
+ if (evfd < 0)
+ return 0;
+ return rr_epoll_ctl(EPOLL_CTL_DEL, evfd, 0, 0);
}
#endif /* #ifndef _RSOCKET_RDMA_H_ */
diff --git a/stacks/rsocket/src/rsocket_rs.c b/stacks/rsocket/src/rsocket_rs.c
index 0f4e73f..79c4914 100644
--- a/stacks/rsocket/src/rsocket_rs.c
+++ b/stacks/rsocket/src/rsocket_rs.c
@@ -17,221 +17,222 @@
#ifndef _RSOCKET_RS_C_
#define _RSOCKET_RS_C_
-inline static void
-rr_rs_init (struct rsocket *rs)
+inline static void rr_rs_init(struct rsocket *rs)
{
- RR_DBG ("(rs:%p{index:%d})\n", rs, rs->index);
- rs->rr_epoll_ref = 0;
- rs->rr_epoll_fd = -1;
- rs->rr_epoll_pdata = NULL;
+ RR_DBG("(rs:%p{index:%d})\n", rs, rs->index);
+ rs->rr_epoll_ref = 0;
+ rs->rr_epoll_fd = -1;
+ rs->rr_epoll_pdata = NULL;
}
-inline static void
-rr_rs_dest (struct rsocket *rs)
+inline static void rr_rs_dest(struct rsocket *rs)
{
- RR_DBG ("(rs:%p{index:%d})\n", rs, rs->index);
+ RR_DBG("(rs:%p{index:%d})\n", rs, rs->index);
- if (rs->rr_epoll_ref)
+ if (rs->rr_epoll_ref)
{
- (void) rr_ep_del (rs->rr_epoll_fd);
- rs->rr_epoll_ref = 0;
- rs->rr_epoll_fd = -1;
- rs->rr_epoll_pdata = NULL;
+ (void) rr_ep_del(rs->rr_epoll_fd);
+ rs->rr_epoll_ref = 0;
+ rs->rr_epoll_fd = -1;
+ rs->rr_epoll_pdata = NULL;
}
}
#ifndef POLL__RSOCKET_RS_H_
#define POLL__RSOCKET_RS_H_
-static inline uint32_t
-rr_rs_poll_tcp (struct rsocket *rs)
+static inline uint32_t rr_rs_poll_tcp(struct rsocket *rs)
{
- uint32_t events = 0;
- if (rs->state & rs_connected)
+ uint32_t events = 0;
+ if (rs->state & rs_connected)
{
- if (rs_have_rdata (rs))
- events |= EPOLLIN;
- if (rs_can_send (rs))
- events |= EPOLLOUT;
+ if (rs_have_rdata(rs))
+ events |= EPOLLIN;
+ if (rs_can_send(rs))
+ events |= EPOLLOUT;
}
- if (rs->state & (rs_error | rs_connect_error))
- events |= EPOLLERR;
- if (rs->state & rs_disconnected)
- events |= EPOLLHUP;
- return events;
+ if (rs->state & (rs_error | rs_connect_error))
+ events |= EPOLLERR;
+ if (rs->state & rs_disconnected)
+ events |= EPOLLHUP;
+ return events;
}
-static inline uint32_t
-rr_rs_poll_udp (struct rsocket *rs)
+static inline uint32_t rr_rs_poll_udp(struct rsocket *rs)
{
- uint32_t events = 0;
- if (rs_have_rdata (rs))
- events |= EPOLLIN;
- if (ds_can_send (rs))
- events |= EPOLLOUT;
- if (rs->state & rs_error)
- events |= EPOLLERR;
- return events;
+ uint32_t events = 0;
+ if (rs_have_rdata(rs))
+ events |= EPOLLIN;
+ if (ds_can_send(rs))
+ events |= EPOLLOUT;
+ if (rs->state & rs_error)
+ events |= EPOLLERR;
+ return events;
}
-static inline uint32_t
-rr_rs_poll_both (struct rsocket *rs)
+static inline uint32_t rr_rs_poll_both(struct rsocket *rs)
{
- if (rs->type == SOCK_STREAM)
- return rr_rs_poll_tcp (rs);
+ if (rs->type == SOCK_STREAM)
+ return rr_rs_poll_tcp(rs);
- if (rs->type == SOCK_DGRAM)
- return rr_rs_poll_udp (rs);
+ if (rs->type == SOCK_DGRAM)
+ return rr_rs_poll_udp(rs);
- return 0;
+ return 0;
}
-uint32_t
-rr_rs_poll (int fd, uint32_t revents)
+uint32_t rr_rs_poll(int fd, uint32_t revents)
{
- struct rsocket *rs = (struct rsocket *) idm_lookup (&idm, fd);
+ struct rsocket *rs = (struct rsocket *) idm_lookup(&idm, fd);
- if (!rs)
- return 0;
+ if (!rs)
+ return 0;
- if (rs->state == rs_listening)
- return revents;
+ if (rs->state == rs_listening)
+ return revents;
- return rr_rs_poll_both (rs);
+ return rr_rs_poll_both(rs);
}
+int rr_getEvt(int fd)
+{
+ struct rsocket *rs = (struct rsocket *) idm_lookup(&idm, fd);
+ if (rs->state == rs_listening)
+ {
+ return EPOLLIN;
+ }
+ if (!rs)
+ {
+ return 0;
+ }
+ return rr_rs_poll_both(rs);
+}
#endif /* #ifndef POLL__RSOCKET_RS_H_ */
-static inline void
-rr_rs_notify_tcp (struct rsocket *rs)
+static inline void rr_rs_notify_tcp(struct rsocket *rs)
{
- if (rs->rr_epoll_ref)
+ if (rs->rr_epoll_ref)
{
- uint32_t events = rr_rs_poll_tcp (rs);
- if (events)
- (void) rr_notify_event (rs->rr_epoll_pdata, events);
+ uint32_t events = rr_rs_poll_tcp(rs);
+ if (events)
+ (void) rr_notify_event(rs->rr_epoll_pdata, events);
}
}
-static inline void
-rr_rs_notify_udp (struct rsocket *rs)
+static inline void rr_rs_notify_udp(struct rsocket *rs)
{
- if (rs->rr_epoll_ref)
+ if (rs->rr_epoll_ref)
{
- uint32_t events = rr_rs_poll_udp (rs);
- if (events)
- (void) rr_notify_event (rs->rr_epoll_pdata, events);
+ uint32_t events = rr_rs_poll_udp(rs);
+ if (events)
+ (void) rr_notify_event(rs->rr_epoll_pdata, events);
}
}
#ifndef HANDLE__RSOCKET_RS_H_
#define HANDLE__RSOCKET_RS_H_
-inline static void
-rr_rs_handle_tcp (struct rsocket *rs)
+inline static void rr_rs_handle_tcp(struct rsocket *rs)
{
- int ret;
+ int ret;
- RR_DBG ("(%d)@ state:0x%x\n", rs->index, rs->state);
+ RR_DBG("(%d)@ state:0x%x\n", rs->index, rs->state);
- if (!(rs->state & (rs_connected | rs_opening)))
- return;
+ if (!(rs->state & (rs_connected | rs_opening)))
+ return;
- fastlock_acquire (&rs->cq_wait_lock);
- ret = rs_get_cq_event (rs);
- RR_DBG ("rs_get_cq_event({%d})=%d,%d\n", rs->index, ret, errno);
- fastlock_release (&rs->cq_wait_lock);
+ fastlock_acquire(&rs->cq_wait_lock);
+ ret = rs_get_cq_event(rs);
+ RR_DBG("rs_get_cq_event({%d})=%d,%d\n", rs->index, ret, errno);
+ fastlock_release(&rs->cq_wait_lock);
- fastlock_acquire (&rs->cq_lock);
+ fastlock_acquire(&rs->cq_lock);
- if (rs->state & rs_connected)
+ if (rs->state & rs_connected)
{
- rs_update_credits (rs);
- ret = rs_poll_cq (rs);
- RR_DBG ("rs_poll_cq({%d})=%d,%d {ref:%d, armed:%d}\n",
- rs->index, ret, errno, rs->rr_epoll_ref, rs->cq_armed);
+ rs_update_credits(rs);
+ ret = rs_poll_cq(rs);
+ RR_DBG("rs_poll_cq({%d})=%d,%d {ref:%d, armed:%d}\n",
+ rs->index, ret, errno, rs->rr_epoll_ref, rs->cq_armed);
}
- if (rs->rr_epoll_ref && rs->cq_armed < 1)
+ if (rs->rr_epoll_ref && rs->cq_armed < 1)
{
- ret = ibv_req_notify_cq (rs->cm_id->recv_cq, 0);
- RR_DBG ("ibv_req_notify_cq({%d})=%d,%d\n", rs->index, ret, errno);
- if (0 == ret)
- __sync_fetch_and_add (&rs->cq_armed, 1);
+ ret = ibv_req_notify_cq(rs->cm_id->recv_cq, 0);
+ RR_DBG("ibv_req_notify_cq({%d})=%d,%d\n", rs->index, ret, errno);
+ if (0 == ret)
+ __sync_fetch_and_add(&rs->cq_armed, 1);
}
- if (rs->state & rs_connected)
+ if (rs->state & rs_connected)
{
- ret = rs_poll_cq (rs);
- RR_DBG ("rs_poll_cq({%d})=%d,%d\n", rs->index, ret, errno);
- rs_update_credits (rs);
+ ret = rs_poll_cq(rs);
+ RR_DBG("rs_poll_cq({%d})=%d,%d\n", rs->index, ret, errno);
+ rs_update_credits(rs);
}
- fastlock_release (&rs->cq_lock);
+ fastlock_release(&rs->cq_lock);
- RR_DBG ("(%d)=\n", rs->index);
+ RR_DBG("(%d)=\n", rs->index);
}
-inline static void
-rr_rs_handle_udp (struct rsocket *rs)
+inline static void rr_rs_handle_udp(struct rsocket *rs)
{
- fastlock_acquire (&rs->cq_wait_lock);
- ds_get_cq_event (rs);
- fastlock_release (&rs->cq_wait_lock);
+ fastlock_acquire(&rs->cq_wait_lock);
+ ds_get_cq_event(rs);
+ fastlock_release(&rs->cq_wait_lock);
- fastlock_acquire (&rs->cq_lock);
- ds_poll_cqs (rs);
- if (rs->rr_epoll_ref && !rs->cq_armed)
+ fastlock_acquire(&rs->cq_lock);
+ ds_poll_cqs(rs);
+ if (rs->rr_epoll_ref && !rs->cq_armed)
{
- ds_req_notify_cqs (rs);
- rs->cq_armed = 1;
+ ds_req_notify_cqs(rs);
+ rs->cq_armed = 1;
}
- fastlock_release (&rs->cq_lock);
+ fastlock_release(&rs->cq_lock);
}
-inline static void
-rr_rs_handle_rs (struct rsocket *rs)
+inline static void rr_rs_handle_rs(struct rsocket *rs)
{
- if (rs->state & rs_opening)
+ if (rs->state & rs_opening)
{
- int ret = rs_do_connect (rs);
- RR_DBG ("rs_do_connect(%p{%d}):%d:%d\n", rs, rs->index, ret, errno);
- return;
+ int ret = rs_do_connect(rs);
+ RR_DBG("rs_do_connect(%p{%d}):%d:%d\n", rs, rs->index, ret, errno);
+ return;
}
- if (rs->type == SOCK_STREAM)
+ if (rs->type == SOCK_STREAM)
{
- rr_rs_handle_tcp (rs);
+ rr_rs_handle_tcp(rs);
}
- if (rs->type == SOCK_DGRAM)
+ if (rs->type == SOCK_DGRAM)
{
- rr_rs_handle_udp (rs);
+ rr_rs_handle_udp(rs);
}
}
-int
-rr_rs_handle (int fd, uint32_t events)
+int rr_rs_handle(int fd, uint32_t events)
{
- struct rsocket *rs = (struct rsocket *) idm_lookup (&idm, fd);
+ struct rsocket *rs = (struct rsocket *) idm_lookup(&idm, fd);
- RR_DBG ("(fd:%d, events:0x%x):rs:%p\n", fd, events, rs);
+ RR_DBG("(fd:%d, events:0x%x):rs:%p\n", fd, events, rs);
- if (!rs)
- return _err (EBADF);
+ if (!rs)
+ return _err(EBADF);
- if (rs->state == rs_listening)
+ if (rs->state == rs_listening)
{
- if (events & EPOLLIN)
+ if (events & EPOLLIN)
{
- (void) rr_notify_event (rs->rr_epoll_pdata, events);
+ (void) rr_notify_event(rs->rr_epoll_pdata, events);
}
- return 0;
+ return 0;
}
- rr_rs_handle_rs (rs);
+ rr_rs_handle_rs(rs);
- return 0;
+ return 0;
}
#endif /* #ifndef HANDLE__RSOCKET_RS_H_ */
@@ -239,155 +240,150 @@ rr_rs_handle (int fd, uint32_t events)
#ifndef ADPT__RSOCKET_RS_H_
#define ADPT__RSOCKET_RS_H_
-inline static int
-rr_rs_evfd (struct rsocket *rs)
+inline static int rr_rs_evfd(struct rsocket *rs)
{
- if (rs->type == SOCK_STREAM)
+ if (rs->type == SOCK_STREAM)
{
- if (rs->state >= rs_connected)
- return rs->cm_id->recv_cq_channel->fd;
- else
- return rs->cm_id->channel->fd;
+ if (rs->state >= rs_connected)
+ return rs->cm_id->recv_cq_channel->fd;
+ else
+ return rs->cm_id->channel->fd;
}
- else
+ else
{
- return rs->epfd;
+ return rs->epfd;
}
- return -1;
+ return -1;
}
-int
-rr_rs_ep_add (int fd, void *pdata, uint32_t * revent)
+int rr_rs_ep_add(int fd, void *pdata, uint32_t * revent)
{
- int ref;
- struct rsocket *rs = (struct rsocket *) idm_lookup (&idm, fd);
- RR_DBG ("(%d(%p),)\n", fd, rs);
- if (!rs)
- return _err (EBADF);
-
- ref = __sync_add_and_fetch (&rs->rr_epoll_ref, 1);
- if (1 == ref)
+ int ref;
+ struct rsocket *rs = (struct rsocket *) idm_lookup(&idm, fd);
+ RR_DBG("(%d(%p),)\n", fd, rs);
+ if (!rs)
+ return _err(EBADF);
+
+ ref = __sync_add_and_fetch(&rs->rr_epoll_ref, 1);
+ if (1 == ref)
{
- rs->rr_epoll_fd = rr_rs_evfd (rs);
- (void) rr_ep_add (rs->rr_epoll_fd, rs->index);
+ rs->rr_epoll_fd = rr_rs_evfd(rs);
+ (void) rr_ep_add(rs->rr_epoll_fd, rs->index);
}
- (void) rr_rs_handle_rs (rs);
- *revent = rs->state == rs_listening ? 0 : rr_rs_poll_both (rs);
+ (void) rr_rs_handle_rs(rs);
+ *revent = rs->state == rs_listening ? 0 : rr_rs_poll_both(rs);
- rs->rr_epoll_pdata = pdata;
+ rs->rr_epoll_pdata = pdata;
- RR_DBG ("*revent=0x%x\n", *revent);
- return 0;
+ RR_DBG("*revent=0x%x\n", *revent);
+ return 0;
}
-int
-rr_rs_ep_mod (int fd, void *pdata, uint32_t * revent)
+int rr_rs_ep_mod(int fd, void *pdata, uint32_t * revent)
{
- struct rsocket *rs = (struct rsocket *) idm_lookup (&idm, fd);
- RR_DBG ("(%d(%p),)\n", fd, rs);
- if (!rs)
- return _err (EBADF);
+ struct rsocket *rs = (struct rsocket *) idm_lookup(&idm, fd);
+ RR_DBG("(%d(%p),)\n", fd, rs);
+ if (!rs)
+ return _err(EBADF);
- if (rs->rr_epoll_ref <= 0)
- return _err (ENOENT);
+ if (rs->rr_epoll_ref <= 0)
+ return _err(ENOENT);
- (void) rr_rs_handle_rs (rs);
- *revent = rs->state == rs_listening ? 0 : rr_rs_poll_both (rs);
+ (void) rr_rs_handle_rs(rs);
+ *revent = rs->state == rs_listening ? 0 : rr_rs_poll_both(rs);
- rs->rr_epoll_pdata = pdata;
+ rs->rr_epoll_pdata = pdata;
- RR_DBG ("*revent=0x%x\n", *revent);
- return 0;
+ RR_DBG("*revent=0x%x\n", *revent);
+ return 0;
}
-int
-rr_rs_ep_del (int fd)
+int rr_rs_ep_del(int fd)
{
- int ref;
- struct rsocket *rs = (struct rsocket *) idm_lookup (&idm, fd);
- RR_DBG ("(%d(%p))\n", fd, rs);
+ int ref;
+ struct rsocket *rs = (struct rsocket *) idm_lookup(&idm, fd);
+ RR_DBG("(%d(%p))\n", fd, rs);
- if (!rs)
- return _err (EBADF);
+ if (!rs)
+ return _err(EBADF);
- ref = __sync_sub_and_fetch (&rs->rr_epoll_ref, 1);
- if (0 == ref)
+ ref = __sync_sub_and_fetch(&rs->rr_epoll_ref, 1);
+ if (0 == ref)
{
- (void) rr_ep_del (rs->rr_epoll_fd);
- rs->rr_epoll_fd = -1;
+ (void) rr_ep_del(rs->rr_epoll_fd);
+ rs->rr_epoll_fd = -1;
}
- return 0;
+ return 0;
}
#endif /* #ifndef ADPT__RSOCKET_RS_H_ */
-inline static void
-rr_rs_connected (struct rsocket *rs)
+inline static void rr_rs_connected(struct rsocket *rs)
{
- RR_DBG ("rsfd:%d ref:%d evfd:%d->%d state:0x%x\n", rs->index,
- rs->rr_epoll_ref, rs->rr_epoll_fd, rr_rs_evfd (rs), rs->state);
+ RR_DBG("rsfd:%d ref:%d evfd:%d->%d state:0x%x\n", rs->index,
+ rs->rr_epoll_ref, rs->rr_epoll_fd, rr_rs_evfd(rs), rs->state);
- if (!(rs->state & rs_connected))
+ if (!(rs->state & rs_connected))
{
- rr_rs_notify_tcp (rs);
- return;
+ rr_rs_notify_tcp(rs);
+ return;
}
- if (rs->rr_epoll_ref)
+ if (rs->rr_epoll_ref)
{
- int evfd = rr_rs_evfd (rs);
+ int evfd = rr_rs_evfd(rs);
- if (evfd != rs->rr_epoll_fd)
+ if (evfd != rs->rr_epoll_fd)
{
- (void) rr_ep_del (rs->rr_epoll_fd);
- rs->rr_epoll_fd = evfd;
- (void) rr_ep_add (evfd, rs->index);
+ (void) rr_ep_del(rs->rr_epoll_fd);
+ rs->rr_epoll_fd = evfd;
+ (void) rr_ep_add(evfd, rs->index);
}
- rr_rs_handle_tcp (rs);
+ rr_rs_handle_tcp(rs);
}
}
-int
-raccept4 (int socket, struct sockaddr *addr, socklen_t * addrlen, int flags)
+int raccept4(int socket, struct sockaddr *addr, socklen_t * addrlen,
+ int flags)
{
- int ret, fd;
- struct rsocket *rs;
+ int ret, fd;
+ struct rsocket *rs;
- RR_DBG ("(%d, %p, %p, %d)@\n", socket, addr, addrlen, flags);
- fd = raccept (socket, addr, addrlen);
- RR_DBG ("(%d, , , %d):%d:%d\n", socket, flags, fd, errno);
- if (fd < 0)
- return fd;
+ RR_DBG("(%d, %p, %p, %d)@\n", socket, addr, addrlen, flags);
+ fd = raccept(socket, addr, addrlen);
+ RR_DBG("(%d, , , %d):%d:%d\n", socket, flags, fd, errno);
+ if (fd < 0)
+ return fd;
- rs = (struct rsocket *) idm_lookup (&idm, fd);
- if (!rs)
+ rs = (struct rsocket *) idm_lookup(&idm, fd);
+ if (!rs)
{
- RR_ERR ("panic\n");
- return -1;
+ RR_ERR("panic\n");
+ return -1;
}
- if (flags & SOCK_NONBLOCK)
+ if (flags & SOCK_NONBLOCK)
{
- if (0 == (rs->fd_flags & O_NONBLOCK))
+ if (0 == (rs->fd_flags & O_NONBLOCK))
{
- RR_DBG ("orig flag:%x\n",
- GSAPI (fcntl) (rs->cm_id->channel->fd, F_GETFL));
- ret = GSAPI (fcntl) (rs->cm_id->channel->fd, F_SETFL, O_NONBLOCK);
- if (0 == ret)
- rs->fd_flags |= O_NONBLOCK;
+ RR_DBG("orig flag:%x\n",
+ GSAPI(fcntl) (rs->cm_id->channel->fd, F_GETFL));
+ ret = GSAPI(fcntl) (rs->cm_id->channel->fd, F_SETFL, O_NONBLOCK);
+ if (0 == ret)
+ rs->fd_flags |= O_NONBLOCK;
}
}
- if (flags & SOCK_CLOEXEC)
+ if (flags & SOCK_CLOEXEC)
{
- RR_LOG ("ignore flag:SOCK_CLOEXEC\n");
+ RR_LOG("ignore flag:SOCK_CLOEXEC\n");
}
- return fd;
+ return fd;
}
#endif /* #ifndef _RSOCKET_RS_C_ */
diff --git a/stacks/vpp/adapt/dmm_vcl.h b/stacks/vpp/adapt/dmm_vcl.h
deleted file mode 100644
index f0d8c85..0000000
--- a/stacks/vpp/adapt/dmm_vcl.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2018 Huawei Technologies Co.,Ltd.
- * 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.
- */
-
-#ifndef included_dmm_vcl_h
-#define included_dmm_vcl_h
-
-#include "nstack_dmm_api.h"
-
-#define DMM_VCL_ENV_DEBUG "DMM_VCL_DEBUG"
-
-typedef struct dmm_vcl
-{
- int epfd;
- long unsigned int epoll_threadid;
- nstack_event_cb regVal;
- int (*p_epoll_create) (int size);
- unsigned int (*p_epoll_ctl) (int epFD, int proFD, int ctl_ops,
- struct epoll_event * events);
- unsigned int (*p_epoll_wait) (int epfd, struct epoll_event * events,
- int maxevents, int timeout);
- int (*p_close) (int fd);
-} dmm_vcl_t;
-
-#endif /* included_dmm_vcl_h */
diff --git a/stacks/vpp/adapt/dmm_vcl_adpt.c b/stacks/vpp/adapt/dmm_vcl_adpt.c
deleted file mode 100644
index 56f9033..0000000
--- a/stacks/vpp/adapt/dmm_vcl_adpt.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright (c) 2018 Huawei Technologies Co.,Ltd.
- * 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.
- */
-
-#define _GNU_SOURCE
-#include <pthread.h>
-#include <dlfcn.h>
-#include <sys/epoll.h>
-#include "dmm_vcl.h"
-#include "nstack_dmm_api.h" // nstack_socket_ops*
-#include <vppinfra/error.h> // clib_warning()
-
-#define DMM_VCL_ADPT_DEBUG dmm_vcl_debug
-static unsigned int dmm_vcl_debug;
-dmm_vcl_t g_dmm_vcl;
-
-unsigned int
-vpphs_ep_ctl_ops (int epFD, int proFD, int ctl_ops,
- struct epoll_event *events, void *pdata)
-{
- struct epoll_event tmpEvt;
- int ret = 0;
- int dmm_epfd;
-
- tmpEvt.data.ptr = pdata;
- tmpEvt.events = events->events;
- tmpEvt.events |= (EPOLLIN | EPOLLOUT);
-
- if (DMM_VCL_ADPT_DEBUG > 0)
- clib_warning ("DMM VCL ADPT<%d>: epfd=%d,fd=%d,ops=%d, events=%u",
- getpid (), epFD, proFD, ctl_ops, events->events);
-
- dmm_epfd = g_dmm_vcl.epfd;
- switch (ctl_ops)
- {
- case nstack_ep_triggle_add:
- ret = g_dmm_vcl.p_epoll_ctl (dmm_epfd, EPOLL_CTL_ADD, proFD, &tmpEvt);
- break;
- case nstack_ep_triggle_mod:
- ret = g_dmm_vcl.p_epoll_ctl (dmm_epfd, EPOLL_CTL_MOD, proFD, &tmpEvt);
- break;
- case nstack_ep_triggle_del:
- ret = g_dmm_vcl.p_epoll_ctl (dmm_epfd, EPOLL_CTL_DEL, proFD, &tmpEvt);
- break;
- default:
- ret = -1;
- break;
- }
- return ret;
-}
-
-#define DMM_VCL_MAX_EP_EVENT 1024
-
-static void *
-dmm_vcl_epoll_thread (void *arg)
-{
- int num, i;
-
- struct epoll_event events[DMM_VCL_MAX_EP_EVENT];
-
- while (1)
- {
- num =
- g_dmm_vcl.p_epoll_wait (g_dmm_vcl.epfd, events, DMM_VCL_MAX_EP_EVENT,
- 100);
-
- for (i = 0; i < num; ++i)
- {
- if (DMM_VCL_ADPT_DEBUG > 0)
- clib_warning
- ("DMM_VCL_ADPT<%d>: dmm_vcl_epoll i[%d] events=%u, epfd=%d, ptr=%d",
- getpid (), i, events[i].events, events[i].data.fd,
- events[i].data.ptr);
-
- g_dmm_vcl.regVal.event_cb (events[i].data.ptr, events[i].events);
-
- }
- }
-
- return NULL;
-}
-
-int
-dmm_vpphs_init ()
-{
- char *env_var_str;
- int rv = 0;
-
- env_var_str = getenv (DMM_VCL_ENV_DEBUG);
- if (env_var_str)
- {
- u32 tmp;
- if (sscanf (env_var_str, "%u", &tmp) != 1)
- clib_warning
- ("DMM_VCL_ADPT<%d>: WARNING: Invalid debug level specified "
- "in the environment variable " DMM_VCL_ENV_DEBUG " (%s)!\n",
- getpid (), env_var_str);
- else
- {
- dmm_vcl_debug = tmp;
- if (DMM_VCL_ADPT_DEBUG > 0)
- clib_warning
- ("DMM_VCL_ADPT<%d>: configured DMM VCL ADPT debug (%u) from "
- "DMM_VCL_ENV_DEBUG ", getpid (), dmm_vcl_debug);
- }
- }
-
- g_dmm_vcl.epfd = g_dmm_vcl.p_epoll_create (1000);
- if (g_dmm_vcl.epfd < 0)
- return g_dmm_vcl.epfd;
-
- rv =
- pthread_create (&g_dmm_vcl.epoll_threadid, NULL, dmm_vcl_epoll_thread,
- NULL);
- if (rv != 0)
- {
- clib_warning ("dmm vcl epoll thread create fail, errno:%d!", errno);
- g_dmm_vcl.p_close (g_dmm_vcl.epfd);
- g_dmm_vcl.epfd = -1;
- return rv;
- }
-
- rv = pthread_setname_np (g_dmm_vcl.epoll_threadid, "dmm_vcl_epoll");
- if (rv != 0)
- {
- clib_warning
- ("pthread_setname_np failed for dmm_vcl_epoll, rv=%d, errno:%d",
- rv, errno);
- }
-
- return rv;
-}
-
-int
-vpp_hoststack_stack_register (nstack_proc_cb * ops, nstack_event_cb * val)
-{
-
-#undef NSTACK_MK_DECL
-#define NSTACK_MK_DECL(ret, fn, args) \
- (ops->socket_ops).pf ## fn = (typeof(((nstack_socket_ops*)0)->pf ## fn))dlsym(val->handle, # fn);
-#include "declare_syscalls.h"
- (ops->socket_ops).pfepoll_create = NULL;
-
- g_dmm_vcl.p_epoll_ctl = dlsym (val->handle, "epoll_ctl");
- g_dmm_vcl.p_epoll_create = dlsym (val->handle, "epoll_create1");
- g_dmm_vcl.p_epoll_wait = dlsym (val->handle, "epoll_wait");
- g_dmm_vcl.p_close = dlsym (val->handle, "close");
- g_dmm_vcl.regVal = *val;
-
- ops->extern_ops.module_init = dmm_vpphs_init;
- ops->extern_ops.fork_init_child = NULL;
- ops->extern_ops.fork_parent_fd = NULL;
- ops->extern_ops.fork_child_fd = NULL;
- ops->extern_ops.fork_free_fd = NULL;
- ops->extern_ops.ep_ctl = vpphs_ep_ctl_ops;
- ops->extern_ops.ep_prewait_proc = NULL;
- ops->extern_ops.stack_fd_check = NULL;
- ops->extern_ops.stack_alloc_fd = NULL;
- ops->extern_ops.peak = NULL;
-
- return 0;
-}
diff --git a/stacks/vpp/configure/module_config.json b/stacks/vpp/configure/module_config.json
deleted file mode 100644
index fb73574..0000000
--- a/stacks/vpp/configure/module_config.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "default_stack_name": "kernel", /*when rd can't be find maybe choose the defualt one*/
- "module_list": [
- {
- "stack_name": "kernel", /*stack name*/
- "libname": "./", /*library name, if loadtype is static, this maybe
- null, else must give a library name*/
- "deploytype": "1", /*deploy model type:model type1, model type2,
- model type3. Indicating single or multi process
- deployment. Used during shared memory initialization.*/
- "stackid": "0", /*stack id, this must be ordered and not be repeated*/
- },
- {
- "stack_name": "vpp_hoststack",
- "libname": "../lib64/libdmm_vcl.so",
- "deploytype": "4",
- "stackid": "1",
- },
- ]
-}
diff --git a/stacks/vpp/configure/rd_config.json b/stacks/vpp/configure/rd_config.json
deleted file mode 100644
index 166fbec..0000000
--- a/stacks/vpp/configure/rd_config.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "ip_route": [
- {
- "subnet": "192.168.1.1/24",
- "stack_name": "vpp_hoststack",
- },
- {
- "subnet": "10.145.240.1/24",
- "stack_name": "kernel",
- },
- {
- "subnet": "192.166.1.1/24",
- "stack_name": "kernel",
- }
- ],
- "prot_route": [
- {
- "proto_type": "1",
- "stack_name": "vpp_hoststack",
- },
- {
- "proto_type": "2",
- "stack_name": "kernel",
- }
- ],
-}
diff --git a/stacks/vpp/configure/startup.conf b/stacks/vpp/configure/startup.conf
deleted file mode 100644
index ada7fdf..0000000
--- a/stacks/vpp/configure/startup.conf
+++ /dev/null
@@ -1,21 +0,0 @@
-unix {
- interactive
- log /var/log/vpp/vpp.log
- cli-listen localhost:5002
- full-coredump
- exec /etc/vpp/vpp_config
-}
-
-api-trace {
- on
-}
-
-cpu {
- main-core 2
-}
-
-dpdk {
- socket-mem 1024
- uio-driver igb_uio
- dev 0000:00:09.0
-}
diff --git a/stacks/vpp/configure/vpp_config b/stacks/vpp/configure/vpp_config
deleted file mode 100644
index 56d80b5..0000000
--- a/stacks/vpp/configure/vpp_config
+++ /dev/null
@@ -1,6 +0,0 @@
-set int state GigabitEthernet0/9/0 up
-set int ip addr GigabitEthernet0/9/0 192.168.1.1/24
-show version
-show version verbose
-show cpu
-show int
diff --git a/stacks/vpp/doc/README.md b/stacks/vpp/doc/README.md
deleted file mode 100644
index e09aefe..0000000
--- a/stacks/vpp/doc/README.md
+++ /dev/null
@@ -1,115 +0,0 @@
-# 1. What is VPP Host Stack
-VPP's host stack is a user space implementation of a number of transport,
-session and application layer protocols that leverages VPP's existing
-protocol stack.
-
-# 2. How to use VPP Host Stack
-
-## How to integrate VPP Host Stack into DMM
-The file CMakeList.txt defined the compiling process, including downloading
-the vpp code and patch it. The patch will modify the makefile to adapt dmm.
-
-Target 'libdmm_vcl' could not be get automatically unless you run
-'make vpp-stack' manually. It will compile the adaption code and link the
-libraries of vpp and finally generate the library of "libdmm_vcl.so".
-
-
-## Compile
-```sh
- #cd dmm/build && cmake ..
- #make vpp-statck
-```
-Note:
- After these processes, libdmm_vcl.so library would be generated in
-vpp/build-root/install-vpp_debug-native/vpp/lib64/.
-
-##Start VPP Host Stack
-- Steps 1: copy the plugins to /usr/lib/.
-```sh
- #cp -r vpp/build-root/install-vpp_debug-native/vpp/lib64/vpp_plugins /usr/lib/
-```
-
-- Steps 2: load dpdk network card driver manually.
-```sh
- #cd dpdk-18.02/x86_64-native-linuxapp-gcc/kmod/
- #modprobe uio
- #insmod igb_uio.ko
-```
-
-- Steps 3: choose a network card that is not in use and down it.
-```sh
- #ifconfig eth1 down
-```
-- Steps 4: copy the config file and start vpp
-```sh
- #cp dmm/stacks/vpp/configure/startup.conf /etc/vpp/
- #cp dmm/stacks/vpp/configure/vpp_config /etc/vpp/
- #cd vpp/build-root/install-vpp_debug-native/vpp/bin
- #./vpp -c /etc/vpp/startup.conf
-```
-Note:
- 1.modify the dev of dpdk in startup.conf.
- 2.modify the interface name and ip in vpp_config.
-
-## Test app
-Note:
- Before testing, we should anotation the dmm code that "close (listenFd);" in
- function process_server_accept_thread for server. Otherwize the app can
- not send and recieve packets.
-
-- Steps 1: copy the libdmm_vcl.so to dmm/release/lib64/
-- Steps 2: copy the config file from dmm/stacks/vpp/configure/*.json to
- dmm/release/bin and modify the rd_config.json.
-```sh
- #vim rd_config.json
- //set "subnet": "192.168.21.1/24"
-```
-Note:
- Means dmm will hijack data from subnet 192.168.21.*
-
-- Steps 3: Communication test between machine A(as server) with machine B
- (as client)
-
-##### Run in machine A
-```sh
- #cd dmm/release/bin/
- #./vs_epoll -p 20000 -d 192.168.21.180 -a 10000 -s 192.168.21.181 -l 1000 -t 500000 -i 0 -f 1 -r 20000 -n 1 -w 10 -u 50000 -e 10 -x 1
-```
-Note:
- Means the current machine would be server, and it's
-destination address is 192.168.21.180 (client address),
-source address is 192.168.21.181(server address)
-
-##### Run in machine B
-```
- #cd dmm/release/bin/
- #./vc_common -p 20000 -d 192.168.21.181 -a 10000 -s 192.168.21.180 -l 1000 -t 500000 -i 0 -f 1 -r 20000 -n 1 -w 10 -u 50000 -e 10 -x 1
-```
-Note:
- Means the current machine would be client, and it's
-destination address is 192.168.21.181 (server address),
-source address is 192.168.21.180(client address)
-
-# 3. Document description
-
-(dmm/stacks/vpp/)
-
-## configure folder
-##### module_config.json
-- module_config.json is for configuring dmm protocol stack module
-
-##### rd_config.json
-- rd_config.json is to choose which module is better to go through. It will go
- through vpp host protocol stack when RD type is nstack-vpp
-
-## patch folder
-- modify the makefile to compile the adapt code.
-
-## adapt folder
-##### dmm_vcl_adpt.c && dmm_vcl.h
-- vpp host stack adaptation code, including initialization and adaptation functions.
-
-# 4. More Information
-- https://wiki.fd.io/view/DMM
-- https://wiki.fd.io/view/VPP
-- https://wiki.fd.io/view/VPP/HostStack
diff --git a/stacks/vpp/patch/0001-Fix-modify-makefile-to-adapt-dmm.patch b/stacks/vpp/patch/0001-Fix-modify-makefile-to-adapt-dmm.patch
deleted file mode 100644
index bb3eca7..0000000
--- a/stacks/vpp/patch/0001-Fix-modify-makefile-to-adapt-dmm.patch
+++ /dev/null
@@ -1,72 +0,0 @@
-From deb61897f0505a82bd26e7fa35b6923c1455732d Mon Sep 17 00:00:00 2001
-From: Jiang Wenjiang <jiangwenjiang@huawei.com>
-Date: Thu, 9 Aug 2018 08:22:24 +0800
-Subject: [PATCH] Fix: modify makefile to adapt dmm
-
----
- src/vcl.am | 17 +++++++++++++++--
- src/vcl/ldp.c | 2 +-
- 2 files changed, 16 insertions(+), 3 deletions(-)
-
-diff --git a/src/vcl.am b/src/vcl.am
-index 89e1841..b09cacb 100644
---- a/src/vcl.am
-+++ b/src/vcl.am
-@@ -11,13 +11,18 @@
- # See the License for the specific language governing permissions and
- # limitations under the License.
-
--lib_LTLIBRARIES += libvppcom.la libvcl_ldpreload.la
-+lib_LTLIBRARIES += libvppcom.la libvcl_ldpreload.la libdmm_vcl.la
-
- libvppcom_la_SOURCES =
- libvcl_ldpreload_la_SOURCES =
-+libdmm_vcl_la_SOURCES =
- libvppcom_la_DEPENDENCIES = \
- libsvm.la \
- libvlibmemoryclient.la
-+libdmm_vcl_la_DEPENDENCIES = \
-+ libsvm.la \
-+ libvlibmemoryclient.la \
-+ libvcl_ldpreload.la
-
- libvppcom_la_LIBADD = $(libvppcom_la_DEPENDENCIES) -lpthread -lrt -ldl
-
-@@ -40,12 +45,20 @@ libvcl_ldpreload_la_SOURCES += \
- vcl/ldp.c \
- $(libvppcom_la_SOURCES)
-
-+libdmm_vcl_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/../../../../release/include
-+
-+libdmm_vcl_la_LIBADD = $(libdmm_vcl_la_DEPENDENCIES) -lpthread -lrt -ldl
-+
-+libdmm_vcl_la_SOURCES += \
-+ vcl/dmm_vcl_adpt.c \
-+ $(libvcl_ldpreload_la_SOURCES)
-+
- nobase_include_HEADERS += \
- vcl/ldp_socket_wrapper.h \
- vcl/ldp_glibc_socket.h \
- vcl/ldp.h
-
--noinst_PROGRAMS += \
-+bin_PROGRAMS += \
- vcl_test_server \
- vcl_test_client \
- sock_test_server \
-diff --git a/src/vcl/ldp.c b/src/vcl/ldp.c
-index d31cd2c..e386855 100644
---- a/src/vcl/ldp.c
-+++ b/src/vcl/ldp.c
-@@ -1669,7 +1669,7 @@ send (int fd, const void *buf, size_t n, int flags)
- getpid (), fd, fd, func_str, sid, sid, buf, n, flags);
-
- size = vppcom_session_sendto (sid, (void *) buf, n, flags, NULL);
-- if (size != VPPCOM_OK)
-+ if (size <= VPPCOM_OK)
- {
- errno = -size;
- size = -1;
---
-1.8.3.1
-
diff --git a/stacks/vpp/patch/0002-Fix-fix-epoll-problem.patch b/stacks/vpp/patch/0002-Fix-fix-epoll-problem.patch
deleted file mode 100644
index 7975e27..0000000
--- a/stacks/vpp/patch/0002-Fix-fix-epoll-problem.patch
+++ /dev/null
@@ -1,62 +0,0 @@
-From bdb9568fe64c6bdfde17f61dac57a7f54214912c Mon Sep 17 00:00:00 2001
-From: Jiang Wenjiang <jiangwenjiang@huawei.com>
-Date: Mon, 10 Sep 2018 03:01:41 +0800
-Subject: [PATCH] Fix: fix epoll problem
-
-The same fd can add to different epoll.
----
- src/vcl/vppcom.c | 10 ++++++++++
- 1 file changed, 10 insertions(+)
-
-diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c
-index cab2f60..9cb52cb 100644
---- a/src/vcl/vppcom.c
-+++ b/src/vcl/vppcom.c
-@@ -162,6 +162,7 @@ typedef struct
- u64 options[16];
- elog_track_t elog_track;
- vce_event_handler_reg_t *poll_reg;
-+ u32 ep_count; //the count that add to epoll
- } session_t;
-
- typedef struct vppcom_cfg_t_
-@@ -3430,6 +3431,7 @@ vppcom_session_write_ready (session_t * session, u32 session_index)
-
- if (PREDICT_FALSE (session->state & STATE_LISTEN))
- {
-+ return 0;
- clib_warning ("VCL<%d>: ERROR: vpp handle 0x%llx, sid %u: "
- "cannot write to a listen session!",
- getpid (), session->vpp_handle, session_index);
-@@ -3802,6 +3804,7 @@ vppcom_epoll_ctl (uint32_t vep_idx, int op, uint32_t session_index,
- session_t *vep_session;
- session_t *session;
- int rv;
-+ int ep_cnt = 0;
-
- if (vep_idx == session_index)
- {
-@@ -3846,6 +3849,9 @@ vppcom_epoll_ctl (uint32_t vep_idx, int op, uint32_t session_index,
- switch (op)
- {
- case EPOLL_CTL_ADD:
-+ ep_cnt = __sync_add_and_fetch (&(session->ep_count), 1);
-+ if (ep_cnt != 1)
-+ break;
- if (PREDICT_FALSE (!event))
- {
- clib_warning ("VCL<%d>: ERROR: EPOLL_CTL_ADD: NULL pointer to "
-@@ -3950,6 +3956,10 @@ vppcom_epoll_ctl (uint32_t vep_idx, int op, uint32_t session_index,
- break;
-
- case EPOLL_CTL_DEL:
-+ ep_cnt = __sync_sub_and_fetch (&(session->ep_count), 1);
-+ if (ep_cnt != 0)
-+ break;
-+
- if (PREDICT_FALSE (!session->is_vep_session))
- {
- clib_warning ("VCL<%d>: ERROR: sid %u EPOLL_CTL_DEL: "
---
-1.8.3.1
-
diff --git a/stacks/vpp/vagrant/Vagrantfile b/stacks/vpp/vagrant/Vagrantfile
deleted file mode 100644
index 5cf102c..0000000
--- a/stacks/vpp/vagrant/Vagrantfile
+++ /dev/null
@@ -1,63 +0,0 @@
-# -*- mode: ruby -*-
-# vi: set ft=ruby :
-
-Vagrant.configure(2) do |config|
-
- # Pick the right distro and bootstrap, default is ubuntu1604
- distro = ( ENV['DMM_VAGRANT_DISTRO'] || "ubuntu")
- if distro == 'centos7'
- config.vm.box = "puppetlabs/centos-7.2-64-nocm"
- else
- config.vm.box = "puppetlabs/ubuntu-16.04-64-nocm"
- end
- config.vm.box_check_update = false
-
- # Create DMM client and server VM's
- config.vm.define "dmm-vpp-server" do |server|
- server.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"install_prereq.sh")
- server.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"build.sh"), :args => "/dmm vagrant"
- end
- config.vm.define "dmm-vpp-client" do |client|
- client.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"install_prereq.sh")
- client.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"build.sh"), :args => "/dmm vagrant"
- end
-
-
- # vagrant-cachier caches apt/yum etc to speed subsequent
- # vagrant up
- # to enable, run
- # vagrant plugin install vagrant-cachier
- #
- if Vagrant.has_plugin?("vagrant-cachier")
- config.cache.scope = :box
- end
-
- # Define some physical ports for your VMs to be used by DPDK
- nics = (ENV['DMM_VAGRANT_NICS'] || "2").to_i(10)
- for i in 1..nics
- config.vm.network "private_network", type: "dhcp"
- # config.vm.network "private_network", ip: "172.28.128.200"
- # config.vm.network "private_network", ip: "172.28.128.201"
- end
-
- # use http proxy if avaiable
- if ENV['http_proxy'] && Vagrant.has_plugin?("vagrant-proxyconf")
- config.proxy.http = ENV['http_proxy']
- config.proxy.https = ENV['https_proxy']
- config.proxy.no_proxy = "localhost,127.0.0.1"
- end
-
- vmcpu=(ENV['DMM_VAGRANT_VMCPU'] || 4)
- vmram=(ENV['DMM_VAGRANT_VMRAM'] || 5120)
-
- config.ssh.forward_agent = true
- config.ssh.forward_x11 = true
-
- config.vm.provider "virtualbox" do |vb|
- vb.customize ["modifyvm", :id, "--ioapic", "on"]
- vb.memory = "#{vmram}"
- vb.cpus = "#{vmcpu}"
-
- config.vm.synced_folder "../../../", "/dmm", type: "rsync"
- end
-end
diff --git a/stacks/vpp/vagrant/build.sh b/stacks/vpp/vagrant/build.sh
deleted file mode 100644
index 1ed343b..0000000
--- a/stacks/vpp/vagrant/build.sh
+++ /dev/null
@@ -1,224 +0,0 @@
-#!/bin/bash -x
-#########################################################################
-# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
-# 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.
-#########################################################################
-
-set -x
-
-TIMESTAMP=$(date +%Y-%m-%d_%H-%M-%S)
-log_file="/tmp/build_log.txt-$TIMESTAMP"
-exec 1> >(tee -a "$log_file") 2>&1
-
-# Get Command Line arguements if present
-TEMP_DIR=$1
-if [ "x$1" != "x" ]; then
- TEMP_DIR=$1
- DMM_BUILD_DIR=${TEMP_DIR}/build
- DPDK_BUILD_SCRIPT_DIR=${DMM_BUILD_DIR}/../scripts
- VPP_BUILD_DIR=${TEMP_DIR}/stacks/vpp/vpp/
-else
- TEMP_DIR=`dirname $(readlink -f $0)`/..
- DMM_BUILD_DIR=${TEMP_DIR}/../../build
- DPDK_BUILD_SCRIPT_DIR=${DMM_BUILD_DIR}/../scripts
- VPP_BUILD_DIR=${TEMP_DIR}
-fi
-
-echo 0:$0
-echo 1:$1
-echo 2:$2
-echo TEMP_DIR: $TEMP_DIR
-echo DMM_BUILD_DIR: $DMM_BUILD_DIR
-echo DPDK_BUILD_SCRIPT_DIR: $DPDK_BUILD_SCRIPT_DIR
-echo VPP_BUILD_DIR: $VPP_BUILD_DIR
-
-OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
-OS_VERSION_ID=$(grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
-KERNEL_OS=`uname -o`
-KERNEL_MACHINE=`uname -m`
-KERNEL_RELEASE=`uname -r`
-KERNEL_VERSION=`uname -v`
-
-echo KERNEL_OS: $KERNEL_OS
-echo KERNEL_MACHINE: $KERNEL_MACHINE
-echo KERNEL_RELEASE: $KERNEL_RELEASE
-echo KERNEL_VERSION: $KERNEL_VERSION
-echo OS_ID: $OS_ID
-echo OS_VERSION_ID: $OS_ID
-
-#DPDK download path
-DPDK_DOWNLOAD_PATH=/tmp/dpdk
-
-#dpdk installation path
-DPDK_INSTALL_PATH=/usr
-
-#set and check the environment for Linux
-if [ "$OS_ID" == "ubuntu" ]; then
- export DEBIAN_FRONTEND=noninteractive
- export DEBCONF_NONINTERACTIVE_SEEN=true
-
- APT_OPTS="--assume-yes --no-install-suggests --no-install-recommends -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\""
- sudo apt-get update ${APT_OPTS}
- sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump libpcre3 libpcre3-dev zlibc zlib1g zlib1g-dev vim ethtool unzip
-elif [ "$OS_ID" == "debian" ]; then
- echo "not tested for debian and exit"
- exit 1
- export DEBIAN_FRONTEND=noninteractive
- export DEBCONF_NONINTERACTIVE_SEEN=true
-
- APT_OPTS="--assume-yes --no-install-suggests --no-install-recommends -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\""
- sudo apt-get update ${APT_OPTS}
- sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump libpcre3 libpcre3-dev zlibc zlib1g zlib1g-dev vim
-elif [ "$OS_ID" == "centos" ]; then
- sudo yum install -y git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump vim sudo yum-utils pcre-devel zlib-devel
-elif [ "$OS_ID" == "opensuse" ]; then
- echo "not tested for opensuse and exit"
- exit 1
- sudo yum install -y git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump vim sudo yum-utils pcre-devel zlib-devel
-fi
-
-#DPDK will be having dependancy on linux headers
-if [ "$OS_ID" == "ubuntu" ]; then
- sudo apt-get -y install git build-essential linux-headers-`uname -r`
- sudo apt-get -y install libnuma-dev
-elif [ "$OS_ID" == "debian" ]; then
- sudo apt-get -y install git build-essential linux-headers-`uname -r`
-elif [ "$OS_ID" == "centos" ]; then
- sudo yum groupinstall -y "Development Tools"
- sudo yum install -y kernel-headers
- sudo yum install -y numactl-devel
-elif [ "$OS_ID" == "opensuse" ]; then
- sudo yum groupinstall -y "Development Tools"
- sudo yum install -y kernel-headers
-fi
-#===========build DPDK================
-
-if [ ! -d /usr/include/dpdk ] || [ ! -d /usr/share/dpdk ] || [ ! -d /usr/lib/modules/4.4.0-31-generic/extra/dpdk ]; then
- mkdir -p $DPDK_DOWNLOAD_PATH
-
- cd $DPDK_DOWNLOAD_PATH
- wget -N https://fast.dpdk.org/rel/dpdk-18.02.tar.xz --no-check-certificate
- tar xvf dpdk-18.02.tar.xz
- cd dpdk-18.02/
-
-
- sed -i 's!CONFIG_RTE_EXEC_ENV=.*!CONFIG_RTE_EXEC_ENV=y!1' config/common_base
- sed -i 's!CONFIG_RTE_BUILD_SHARED_LIB=.*!CONFIG_RTE_BUILD_SHARED_LIB=y!1' config/common_base
- sed -i 's!CONFIG_RTE_LIBRTE_EAL=.*!CONFIG_RTE_LIBRTE_EAL=y!1' config/common_base
- sed -i 's!CONFIG_RTE_EAL_PMD_PATH=.*!CONFIG_RTE_EAL_PMD_PATH="/tmp/dpdk/drivers/"!1' config/common_base
-
- sudo make install T=x86_64-native-linuxapp-gcc DESTDIR=${DPDK_INSTALL_PATH} -j 4
-
- mkdir -p /tmp/dpdk/drivers/
- cp -f /usr/lib/librte_mempool_ring.so /tmp/dpdk/drivers/
-fi
-
-#===========check running env =================
-hugepagesize=$(cat /proc/meminfo | grep Hugepagesize | awk -F " " {'print$2'})
-if [ "$hugepagesize" == "2048" ]; then
- pages=2560
-elif [ "$hugepagesize" == "1048576" ]; then
- pages=5
-fi
-sudo sysctl -w vm.nr_hugepages=$pages
-HUGEPAGES=`sysctl -n vm.nr_hugepages`
-if [ $HUGEPAGES != $pages ]; then
- echo "ERROR: Unable to get $pages hugepages, only got $HUGEPAGES. Cannot finish."
- exit
-fi
-
-
-hugepageTotal=$(cat /proc/meminfo | grep -c "HugePages_Total: 0")
-if [ $hugepageTotal -ne 0 ]; then
- echo "HugePages_Total is zero"
- exit
-fi
-
-hugepageFree=$(cat /proc/meminfo | grep -c "HugePages_Free: 0")
-if [ $hugepageFree -ne 0 ]; then
- echo "HugePages_Free is zero"
- exit
-fi
-
-hugepageSize=$(cat /proc/meminfo | grep -c "Hugepagesize: 0 kB")
-if [ $hugepageSize -ne 0 ]; then
- echo "Hugepagesize is zero"
- exit
-fi
-
-
-sudo mkdir /mnt/nstackhuge -p
-if [ "$hugepagesize" == "2048" ]; then
-sudo mount -t hugetlbfs -o pagesize=2M none /mnt/nstackhuge/
-elif [ "$hugepagesize" == "1048576" ]; then
- sudo mount -t hugetlbfs -o pagesize=1G none /mnt/nstackhuge/
-fi
-
-#===========build DMM=================
-echo "DMM build started....."
-
-cd $DMM_BUILD_DIR
-ldconfig
-rm -rf *
-cmake ..
-make -j 8
-if [ $? -eq 0 ]; then
- echo "DMM build is SUCCESS"
-else
- echo "DMM build has FAILED"
- exit 1
-fi
-echo "DMM build finished....."
-
-git config --global http.sslVerify false
-#===========build vpp===========
-echo "vpp build started....."
-make vpp-stack
-if [ $? -eq 0 ]; then
- echo "vpp build is SUCCESS"
-else
- echo "vpp build has FAILED"
- exit 1
-fi
-echo "vpp build finished....."
-
-#===========set environment===========
-sudo mkdir -p /etc/vpp/
-cp /dmm/stacks/vpp/configure/startup.conf /etc/vpp/
-cp /dmm/stacks/vpp/configure/vpp_config /etc/vpp/
-
-sudo cp -r /dmm/stacks/vpp/vpp/build-root/install-vpp_debug-native/vpp/lib64/vpp_plugins/ /usr/lib/
-
-sudo modprobe uio
-sudo insmod ${DPDK_DOWNLOAD_PATH}/dpdk-18.02/x86_64-native-linuxapp-gcc/kmod/igb_uio.ko
-
-sudo ifconfig enp0s9 down
-
-if [ "$OS_ID" == "centos" ]; then
- ifaddress1=$(ifconfig enp0s9 | grep 'inet' | cut -d: -f2 | awk '{print $2}')
- echo $ifaddress1
- ifaddresscut=$(ifconfig enp0s9 | grep 'inet' | head -n 1 | awk -F " " '{print $2}' | awk -F "." '{print $1"."$2"."$3}')
- echo $ifaddresscut
-elif [ "$OS_ID" == "ubuntu" ]; then
- ifaddress1=$(ifconfig enp0s9 | grep 'inet' | head -n 1 | cut -d: -f2 | awk '{print $1}')
- echo $ifaddress1
-fi
-
-cd /etc/vpp/
-
-sudo sed -i 's!192.168.1.1!'$ifaddress1'!1' vpp_config
-
-cd $DMM_BUILD_DIR/../release/bin
-sudo cp ../../stacks/vpp/configure/*.json ./
-sudo cp ../../stacks/vpp/vpp/build-root/install-vpp_debug-native/vpp/lib64/libdmm_vcl.so ../lib64/
-sudo sed -i 's!192.168.1.1!'$ifaddresscut'.0!1' rd_config.json
diff --git a/stacks/vpp/vagrant/env.sh b/stacks/vpp/vagrant/env.sh
deleted file mode 100644
index 96ad346..0000000
--- a/stacks/vpp/vagrant/env.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/env bash
-
-#export DMM_VAGRANT_DISTRO="ubuntu1604"
-export DMM_VAGRANT_DISTRO="centos7"
-export DMM_VAGRANT_NICS=2
-export DMM_VAGRANT_VMCPU=4
-export DMM_VAGRANT_VMRAM=8192
diff --git a/stacks/vpp/vagrant/install_prereq.sh b/stacks/vpp/vagrant/install_prereq.sh
deleted file mode 100644
index 2e636c2..0000000
--- a/stacks/vpp/vagrant/install_prereq.sh
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/bin/bash -x
-log_file="/tmp/pre_install_log.txt-`date +'%Y-%m-%d_%H-%M-%S'`"
-exec 1> >(tee -a "$log_file") 2>&1
-
-if [ "$(uname)" <> "Darwin" ]; then
- OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
- OS_VERSION_ID=$(grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
-fi
-
-if [ "$OS_ID" == "ubuntu" ]; then
- # Standard update + upgrade dance
- cat << EOF >> /etc/apt/sources.list
- deb http://in.archive.ubuntu.com/ubuntu/ trusty main restricted
- deb-src http://in.archive.ubuntu.com/ubuntu/ trusty main restricted
- deb http://in.archive.ubuntu.com/ubuntu/ trusty-updates main restricted
- deb-src http://in.archive.ubuntu.com/ubuntu/ trusty-updates main restricted
- deb http://in.archive.ubuntu.com/ubuntu/ trusty universe
- deb-src http://in.archive.ubuntu.com/ubuntu/ trusty universe
- deb http://in.archive.ubuntu.com/ubuntu/ trusty-updates universe
- deb-src http://in.archive.ubuntu.com/ubuntu/ trusty-updates universe
- deb http://in.archive.ubuntu.com/ubuntu/ trusty multiverse
- deb-src http://in.archive.ubuntu.com/ubuntu/ trusty multiverse
- deb http://in.archive.ubuntu.com/ubuntu/ trusty-updates multiverse
- deb-src http://in.archive.ubuntu.com/ubuntu/ trusty-updates multiverse
- deb http://in.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
- deb-src http://in.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
- deb http://security.ubuntu.com/ubuntu trusty-security main restricted
- deb-src http://security.ubuntu.com/ubuntu trusty-security main restricted
- deb http://security.ubuntu.com/ubuntu trusty-security universe
- deb-src http://security.ubuntu.com/ubuntu trusty-security universe
- deb http://security.ubuntu.com/ubuntu trusty-security multiverse
- deb-src http://security.ubuntu.com/ubuntu trusty-security multiverse
- deb http://extras.ubuntu.com/ubuntu trusty main
- deb-src http://extras.ubuntu.com/ubuntu trusty main
-EOF
-elif [ "$OS_ID" == "centos" ]; then
-
- echo centos
-fi
diff --git a/test/perf/bps.md b/test/perf/bps.md
deleted file mode 100644
index 8599d18..0000000
--- a/test/perf/bps.md
+++ /dev/null
@@ -1,141 +0,0 @@
-# 1. Description
-**Test description:**
-Measure the bps required to run kernel stack with DMM and lwip stack with DMM using bps tool.
-
-**Date:**Monday, 21. January 2019 10:53PM
-
-**Test Environment:**
-Virtual Machines: 172.28.128.3 and 172.28.128.5
-Operating System: Ubuntu 16.04 LTS
-
-**Test App:**
-bps
-
-# 2. Topology Diagram
-![test_topology.png](resources/test_topology.png
-"test_topology.png")
-
-**Physical Machines:**
-Server-------------------------Client
-connected via 82540EM Gigabit Ethernet Controller
-
-# 3. Test Commands
-**Server Command with kernel+DMM:**
-```
-$sudo LD_LIBRARY_PATH=./ LD_PRELOAD=libnStackAPI.so ./bps 172.28.128.3
-```
-
-**Client Command with kernel+DMM:**
-```
-$ sudo LD_LIBRARY_PATH=./ LD_PRELOAD=libnStackAPI.so ./bps -c 172.28.128.3 -l 64
-```
-
-**Server Command with lwip+DMM:**
-```
-$sudo LD_LIBRARY_PATH=../release/lib64/ LD_PRELOAD=../release/lib64/libnStackAPI.so ./bps 172.28.128.3
-```
-
-**Client Command with lwip+DMM:**
-```
-$sudo LD_LIBRARY_PATH=../release/lib64/ LD_PRELOAD=../release/lib64/libnStackAPI.so ./bps -c 172.28.128.3 -l 64
-```
-
-#4. Commit version
-```
-commit 840dc98676773c027e699bd6efc3793118a5f1ef
-Author: charan makkina <charan795m@gmail.com>
-Date: Tue Jan 22 14:18:33 2019 +0530
-
- Test: Testcases for bps, cps, ip6, lp and te.
-
- Change-Id: I17ad8a915c4a9332c11797e7f02c82abbfadfbbc
- Signed-off-by: charan makkina <charan795m@gmail.com>
-
-```
-```
-Download source code: git clone https://gerrit.fd.io/r/dmm
-```
-#5. Result
-
-**Virtual Machines:**
-**Kernel Stack**
-
-**Client:**
-
- | T:mbps | kpps | S:mbps | kpps | R:mbps | kpps | info |
-| ---------- | ------ | ---------- | -------| ---------- | ------- | -----|
- | 206 | 03 | 79 | 156 | 126 | 247 | 00:01|
- | 726 |1,419 | 314 | 614 | 412 | 804 | 00:02|
- | 786 |1,535 | 346 | 677 | 439 | 857 | 00:03|
- | 814 |1,591 | 365 | 713 | 449 | 877 | 00:04|
- | 828 |1,618 | 391 | 765 | 436 | 853 | 00:05|
- | 856 |1,672 | 438 | 856 | 417 | 816 | 00:06|
- | 820 |1,602 | 392 | 767 | 427 | 834 | 00:07|
- | 775 |1,513 | 339 | 662 | 435 | 850 | 00:08|
- | 791 |1,545 | 347 | 678 | 443 | 866 | 00:09|
- | 842 |1,646 | 424 | 829 | 418 | 817 | 00:10|
- | 723 |1,413 | 306 | 598 | 417 | 815 | 00:11|
- | 837 |1,635 | 426 | 832 | 411 | 803 | 00:12|
- | 770 |1,505 | 334 | 654 | 435 | 851 | 00:13|
- | 767 |1,499 | 349 | 682 | 417 | 816 | 00:14|
- | 835 |1,631 | 387 | 757 | 447 | 874 | 00:15|
- | 820 |1,601 | 358 | 699 | 461 | 902 | 00:16|
- | 817 |1,597 | 370 | 723 | 447 | 874 | 00:17|
- | 844 |1,648 | 391 | 763 | 452 | 884 | 00:18|
- | 814 |1,590 | 364 | 711 | 450 | 879 | 00:19|
- | 726 |1,418 | 269 | 526 | 456 | 892 | 00:20|
- | 747 |1,459 | 345 | 674 | 402 | 785 | 00:21|
- | 811 |1,584 | 389 | 760 | 422 | 824 | 00:22|
- | 806 |1,575 | 356 | 696 | 450 | 879 | 00:23|
- | 798 |1,559 | 351 | 685 | 447 | 873 | 00:24|
- | 712 |1,390 | 270 | 528 | 441 | 862 | 00:25|
- | 790 |1,544 | 318 | 622 | 471 | 921 | 00:26|
- | 837 |1,636 | 379 | 741 | 457 | 894 | 00:27|
- | 753 |1,472 | 342 | 669 | 410 | 802 | 00:28|
- | 788 |1,540 | 350 | 685 | 437 | 855 | 00:29|
- | 794 |1,551 | 350 | 685 | 443 | 865 | 00:30|
-
-**LWIP stack:**
-
-
-**Client:**
-
- | T:mbps | kpps | S:mbps | kpps | R:mbps | kpps | info |
-| ---------- | ------ | ---------- | -------| ---------- | ------- | -----|
- |109 | 214 | 53 | 104 | 56 | 109 | 00:01 |
- |123 | 241 | 55 | 108 | 68 | 133 | 00:02 |
- |142 | 277 | 72 | 140 | 70 | 136 | 00:03 |
- |118 | 230 | 51 | 101 | 66 | 129 | 00:04 |
- |135 | 263 | 55 | 107 | 79 | 155 | 00:05 |
- |137 | 269 | 55 | 107 | 82 | 161 | 00:06 |
- |138 | 270 | 53 | 105 | 84 | 165 | 00:07 |
- |122 | 239 | 58 | 113 | 64 | 126 | 00:08 |
- |125 | 244 | 51 | 100 | 73 | 143 | 00:09 |
- |111 | 217 | 53 | 105 | 57 | 112 | 00:10 |
- |125 | 244 | 58 | 115 | 66 | 129 | 00:11 |
- |225 | 440 | 105| 205 | 120| 234 | 00:12|
- |192 | 376 | 91 | 177 | 101 | 198 | 00:13|
- |201 | 393 | 95 | 186 | 106 | 207 | 00:14|
- |210 | 410 | 98 | 192 | 111 | 218 | 00:15|
- |210 | 410 | 93 | 183 | 116 | 226 | 00:16|
- |149 | 292 | 78 | 152 | 71 | 139 | 00:17 |
- |132 | 257 | 59 | 116 | 72 | 140 | 00:18 |
- |138 | 271 | 58 | 114 | 80 | 156 | 00:19 |
- |133 | 260 | 58 | 114 | 74 | 146 | 00:20 |
- |127 | 248 | 58 | 114 | 68 | 133 | 00:21 |
- |114 | 224 | 55 | 107 | 59 | 116 | 00:22 |
- |126 | 247 | 60 | 117 | 66 | 129 | 00:23 |
- |141 | 275 | 71 | 140 | 69 | 135 | 00:24 |
- |158 | 308 | 73 | 144 | 84 | 164 | 00:25 |
- |181 | 354 | 78 | 153 | 102 | 200 | 00:26|
- |156 | 306 | 70 | 138 | 85 | 167 | 00:27 |
- |158 | 310 | 74 | 145 | 84 | 164 | 00:28 |
- |167 | 327 | 79 | 155 | 88 | 172 | 00:29 |
- |161 | 315 | 85 | 166 | 76 | 149 | 00:30 |
-
-#7. Conclusion
-**Virtual Machines:**
-The sender and receiver has values in the range of 357 and 436 mbps for kernel stack.
-The sender and receiver has values in the range of 68 and 80 mbps for lwip stack.
-
-These are the benchmark values for further tests.
diff --git a/test/perf/bps_epoll.md b/test/perf/bps_epoll.md
deleted file mode 100644
index 53d799a..0000000
--- a/test/perf/bps_epoll.md
+++ /dev/null
@@ -1,141 +0,0 @@
-# 1. Description
-**Test description:**
-Measure the bps required to run kernel stack with DMM and lwip stack with DMM using bps tool.
-
-**Date:**Monday, 21. January 2019 10:53PM
-
-**Test Environment:**
-Virtual Machines: 172.28.128.3 and 172.28.128.5
-Operating System: Ubuntu 16.04 LTS
-
-**Test App:**
-bps
-
-# 2. Topology Diagram
-![test_topology.png](resources/test_topology.png
-"test_topology.png")
-
-**Physical Machines:**
-Server-------------------------Client
-connected via 82540EM Gigabit Ethernet Controller
-
-# 3. Test Commands
-**Server Command with kernel+DMM:**
-```
-$sudo LD_LIBRARY_PATH=./ LD_PRELOAD=libnStackAPI.so ./bps 172.28.128.3
-```
-
-**Client Command with kernel+DMM:**
-```
-$ sudo LD_LIBRARY_PATH=./ LD_PRELOAD=libnStackAPI.so ./bps -c 172.28.128.3 -l 64
-```
-
-**Server Command with lwip+DMM:**
-```
-$sudo LD_LIBRARY_PATH=../release/lib64/ LD_PRELOAD=../release/lib64/libnStackAPI.so ./bps 172.28.128.3
-```
-
-**Client Command with lwip+DMM:**
-```
-$sudo LD_LIBRARY_PATH=../release/lib64/ LD_PRELOAD=../release/lib64/libnStackAPI.so ./bps -c 172.28.128.3 -l 64
-```
-
-#4. Commit version
-```
-commit 840dc98676773c027e699bd6efc3793118a5f1ef
-Author: charan makkina <charan795m@gmail.com>
-Date: Tue Jan 22 14:18:33 2019 +0530
-
- Test: Testcases for bps, cps, ip6, lp and te.
-
- Change-Id: I17ad8a915c4a9332c11797e7f02c82abbfadfbbc
- Signed-off-by: charan makkina <charan795m@gmail.com>
-
-```
-```
-Download source code: git clone https://gerrit.fd.io/r/dmm
-```
-#5. Result
-
-**Virtual Machines:**
-**Kernel Stack**
-
-**Client:**
-
- | T:mbps | kpps | S:mbps | kpps | R:mbps | kpps | info |
-| ---------- | ------ | ---------- | -------| ---------- | ------- | -----|
- |369 | 722 | 177 | 347 | 191 | 374 | 00:01|
- |786 |1,535 | 378 | 738 | 407 | 796 | 00:02|
- |829 |1,619 | 416 | 812 | 413 | 806 | 00:03|
- |866 |1,692 | 425 | 831 | 441 | 861 | 00:04|
- |839 |1,639 | 399 | 779 | 440 | 859 | 00:05|
- |774 |1,512 | 377 | 737 | 396 | 774 | 00:06|
- |796 |1,554 | 365 | 713 | 430 | 841 | 00:07|
- |839 |1,640 | 432 | 845 | 406 | 794 | 00:08|
- |820 |1,601 | 383 | 749 | 436 | 851 | 00:09|
- |801 |1,565 | 362 | 708 | 438 | 856 | 00:10|
- |812 |1,586 | 391 | 764 | 421 | 822 | 00:11|
- |860 |1,679 | 414 | 809 | 445 | 869 | 00:12|
- |790 |1,544 | 359 | 702 | 431 | 841 | 00:13|
- |826 |1,614 | 391 | 765 | 435 | 849 | 00:14|
- |868 |1,695 | 430 | 841 | 437 | 853 | 00:15|
- |858 |1,676 | 430 | 841 | 427 | 835 | 00:16|
- |819 |1,599 | 409 | 798 | 410 | 800 | 00:17|
- |817 |1,596 | 416 | 812 | 401 | 783 | 00:18|
- |835 |1,631 | 428 | 837 | 406 | 794 | 00:19|
- |848 |1,657 | 409 | 799 | 439 | 858 | 00:20|
- |835 |1,631 | 413 | 807 | 422 | 824 | 00:21|
- |909 |1,775 | 464 | 908 | 444 | 867 | 00:22|
- |840 |1,641 | 420 | 820 | 420 | 821 | 00:23|
- |794 |1,551 | 347 | 678 | 446 | 872 | 00:24|
- |815 |1,593 | 377 | 737 | 438 | 856 | 00:25|
- |895 |1,748 | 462 | 903 | 432 | 845 | 00:26|
- |848 |1,657 | 401 | 783 | 447 | 874 | 00:27|
- |826 |1,614 | 391 | 765 | 434 | 849 | 00:28|
- |781 |1,527 | 362 | 707 | 419 | 819 | 00:29|
- |853 |1,666 | 436 | 852 | 416 | 813 | 00:30|
-
-**LWIP stack:**
-
-
-**Client:**
-
- | T:mbps | kpps | S:mbps | kpps | R:mbps | kpps | info |
-| ---------- | ------ | ---------- | -------| ---------- | ------- | -----|
- | 126 | 247 | 30 | 58 | 96 | 188 | 00:01|
- | 138 | 271 | 31 | 62 | 106| 208 | 00:02|
- | 125 | 244 | 47 | 93 | 77 | 151 | 00:03|
- | 138 | 270 | 40 | 79 | 97 | 190 | 00:04|
- | 131 | 257 | 39 | 78 | 91 | 179 | 00:05|
- | 115 | 225 | 46 | 91 | 68 | 134 | 00:06|
- | 132 | 257 | 49 | 95 | 82 | 162 | 00:07|
- | 121 | 237 | 49 | 96 | 72 | 141 | 00:08|
- | 116 | 227 | 58 | 114 | 57| 112 | 00:09|
- | 103 | 202 | 51 | 101 | 51| 101 | 00:10|
- | 110 | 216 | 45 | 88 | 65 | 128 | 00:11|
- | 137 | 268 | 52 | 101 | 85| 167 | 00:12|
- | 116 | 227 | 30 | 60 | 85 | 166 | 00:13|
- | 116 | 227 | 47 | 92 | 69 | 135 | 00:14|
- | 124 | 242 | 40 | 79 | 83 | 163 | 00:15|
- | 106 | 207 | 43 | 84 | 62 | 122 | 00:16|
- | 120 | 234 | 51 | 100 | 68| 134 | 00:17|
- | 118 | 232 | 35 | 68 | 83 | 163 | 00:18|
- | 131 | 256 | 30 | 59 | 100| 196 | 00:19|
- | 105 | 205 | 32 | 64 | 72 | 141 | 00:20|
- | 96 |188 | 29 |57 | 67 |131 | 00:21 |
- | 119 | 233 | 33 | 66 | 85 | 167 | 00:22|
- | 110 | 215 | 31 | 61 | 78 | 154 | 00:23|
- | 80 |158 | 28 |55 | 52 |103 | 00:24 |
- | 73 |144 | 26 |51 | 47 | 92 | 00:25 |
- |104 |204 | 34 |67 | 69 |136 | 00:26 |
- | 100 | 196 | 31 | 62 | 68 | 133 | 00:27 |
- | 71 |138 | 27 |54 | 43 | 84 | 00:28 |
- | 88 |171 | 31 |62 | 56 |109 | 00:29 |
- | 82 |161 | 34 |67 | 48 | 93 | 00:30 |
-
-#7. Conclusion
-**Virtual Machines:**
-The sender and receiver has values in the range of 403 and 427 mbps for kernel stack.
-The sender and receiver has values in the range of 38 and 73 mbps for lwip stack.
-
-These are the benchmark values for further tests.
diff --git a/test/perf/bps_select.md b/test/perf/bps_select.md
deleted file mode 100644
index 499fce0..0000000
--- a/test/perf/bps_select.md
+++ /dev/null
@@ -1,141 +0,0 @@
-# 1. Description
-**Test description:**
-Measure the bps required to run kernel stack with DMM and lwip stack with DMM using bps tool.
-
-**Date:**Monday, 21. January 2019 10:53PM
-
-**Test Environment:**
-Virtual Machines: 172.28.128.3 and 172.28.128.5
-Operating System: Ubuntu 16.04 LTS
-
-**Test App:**
-bps
-
-# 2. Topology Diagram
-![test_topology.png](resources/test_topology.png
-"test_topology.png")
-
-**Physical Machines:**
-Server-------------------------Client
-connected via 82540EM Gigabit Ethernet Controller
-
-# 3. Test Commands
-**Server Command with kernel+DMM:**
-```
-$sudo LD_LIBRARY_PATH=./ LD_PRELOAD=libnStackAPI.so ./bps 172.28.128.3
-```
-
-**Client Command with kernel+DMM:**
-```
-$ sudo LD_LIBRARY_PATH=./ LD_PRELOAD=libnStackAPI.so ./bps -c 172.28.128.3 -l 64
-```
-
-**Server Command with lwip+DMM:**
-```
-$sudo LD_LIBRARY_PATH=../release/lib64/ LD_PRELOAD=../release/lib64/libnStackAPI.so ./bps 172.28.128.3
-```
-
-**Client Command with lwip+DMM:**
-```
-$sudo LD_LIBRARY_PATH=../release/lib64/ LD_PRELOAD=../release/lib64/libnStackAPI.so ./bps -c 172.28.128.3 -l 64
-```
-
-#4. Commit version
-```
-commit 840dc98676773c027e699bd6efc3793118a5f1ef
-Author: charan makkina <charan795m@gmail.com>
-Date: Tue Jan 22 14:18:33 2019 +0530
-
- Test: Testcases for bps, cps, ip6, lp and te.
-
- Change-Id: I17ad8a915c4a9332c11797e7f02c82abbfadfbbc
- Signed-off-by: charan makkina <charan795m@gmail.com>
-
-```
-```
-Download source code: git clone https://gerrit.fd.io/r/dmm
-```
-#5. Result
-
-**Virtual Machines:**
-**Kernel Stack**
-
-**Client:**
-
- | T:mbps | kpps | S:mbps | kpps | R:mbps | kpps | info |
-| ---------- | ------ | ---------- | -------| ---------- | ------- | -----|
- |459 | 897 | 182 | 356 | 277 | 541 | 00:01|
- |838 |1,637 | 374 | 731 | 463 | 906 | 00:02|
- |747 |1,459 | 310 | 605 | 437 | 854 | 00:03|
- |749 |1,464 | 302 | 590 | 447 | 874 | 00:04|
- |793 |1,549 | 357 | 697 | 436 | 851 | 00:05|
- |766 |1,497 | 309 | 604 | 457 | 893 | 00:06|
- |821 |1,603 | 361 | 705 | 459 | 898 | 00:07|
- |791 |1,544 | 333 | 650 | 457 | 894 | 00:08|
- |815 |1,592 | 370 | 722 | 445 | 869 | 00:09|
- |800 |1,564 | 326 | 637 | 474 | 927 | 00:10|
- |759 |1,482 | 296 | 579 | 462 | 903 | 00:11|
- |794 |1,551 | 329 | 642 | 465 | 908 | 00:12|
- |804 |1,571 | 343 | 670 | 461 | 900 | 00:13|
- |827 |1,615 | 367 | 717 | 460 | 898 | 00:14|
- |755 |1,475 | 320 | 625 | 435 | 850 | 00:15|
- |840 |1,641 | 363 | 710 | 476 | 930 | 00:16|
- |747 |1,459 | 318 | 621 | 429 | 838 | 00:17|
- |787 |1,537 | 305 | 595 | 482 | 941 | 00:18|
- |798 |1,560 | 320 | 626 | 478 | 933 | 00:19|
- |741 |1,447 | 304 | 594 | 436 | 853 | 00:20|
- |807 |1,577 | 362 | 708 | 444 | 868 | 00:21|
- |826 |1,614 | 381 | 745 | 445 | 869 | 00:22|
- |792 |1,548 | 325 | 636 | 466 | 911 | 00:23|
- |852 |1,665 | 384 | 750 | 468 | 914 | 00:24|
- |787 |1,538 | 332 | 650 | 455 | 888 | 00:25|
- |812 |1,585 | 374 | 731 | 437 | 854 | 00:26|
- |789 |1,541 | 340 | 665 | 448 | 876 | 00:27|
- |799 |1,561 | 341 | 666 | 458 | 894 | 00:28|
- |766 |1,497 | 319 | 624 | 447 | 873 | 00:29|
- |775 |1,514 | 296 | 578 | 479 | 936 | 00:30|
-
-**LWIP stack:**
-
-
-**Client:**
-
- | T:mbps | kpps | S:mbps | kpps | R:mbps | kpps | info |
-| ---------- | ------ | ---------- | -------| ---------- | ------- | -----|
- | 89 |174 | 53 |103 | 36 | 71 | 00:01 |
- | 115 | 225 | 53 | 105 | 61 | 120 | 00:02 |
- | 95 | 185 | 45 | 88 | 49 | 96 | 00:03 |
- | 142 | 279 | 69 | 136 | 73 | 142 | 00:04 |
- | 107 | 209 | 54 | 106 | 52 | 103 | 00:05 |
- | 121 | 237 | 52 | 101 | 69 | 135 | 00:06 |
- | 92 | 180 | 42 | 83 | 49 | 97 | 00:07 |
- | 163 | 318 | 75 | 147 | 87 | 170 | 00:08 |
- | 125 | 245 | 70 | 137 | 54 | 107 | 00:09 |
- | 134 | 262 | 69 | 136 | 64 | 125 | 00:10 |
- | 135 | 264 | 74 | 145 | 61 | 119 | 00:11 |
- | 132 | 259 | 68 | 133 | 64 | 125 | 00:12 |
- | 100 | 197 | 51 | 99 | 49 | 97 | 00:13 |
- | 108 | 212 | 55 | 107 | 53 | 105 | 00:14 |
- | 109 | 213 | 57 | 113 | 51 | 100 | 00:15 |
- | 129 | 253 | 56 | 109 | 73 | 143 | 00:16 |
- | 213 | 417 | 85 | 166 | 128| 250 | 00:17|
- | 180 | 352 | 86 | 168 | 94 | 184 | 00:18 |
- | 177 | 347 | 86 | 168 | 91 | 179 | 00:19 |
- | 192 | 376 | 86 | 169 | 106| 207 | 00:20|
- | 202 | 395 | 89 | 175 | 112| 219 | 00:21|
- | 198 | 388 | 91 | 178 | 107| 209 | 00:22|
- | 181 | 355 | 82 | 161 | 99 | 193 | 00:23 |
- | 192 | 375 | 85 | 167 | 106| 208 | 00:24|
- | 176 | 345 | 86 | 169 | 89 | 175 | 00:25 |
- | 174 | 341 | 82 | 160 | 92 | 180 | 00:26 |
- | 186 | 364 | 81 | 158 | 105| 205 | 00:27|
- | 199 | 389 | 82 | 160 | 117| 228 | 00:28|
- | 173 | 338 | 81 | 160 | 91 | 178 | 00:29 |
- | 191 | 373 | 88 | 172 | 103| 201 | 00:30|
-
-#7. Conclusion
-**Virtual Machines:**
-The sender and receiver has values in the range of 357 and 455 mbps for kernel stack.
-The sender and receiver has values in the range of 71 and 80 mbps for lwip stack.
-
-These are the benchmark values for further tests.
diff --git a/test/perf/iperf.md b/test/perf/iperf.md
deleted file mode 100644
index 97c5442..0000000
--- a/test/perf/iperf.md
+++ /dev/null
@@ -1,136 +0,0 @@
-# 1. Description
-**Test description:**
-Measure the bandwith required to run kernel stack with DMM and without DMM using IPERF tool.
-
-**Date:** Thursday, 17. January 2019 03:57PM
-
-**Test Environment:**
-Physical Machines: 172.16.101.1 and 172.16.103.1
-Operating System: Ubuntu 16.04 LTS
-
-Virtual Machines:172.28.128.4 and 172.28.128.6
-Operating System: Ubuntu 16.04 LTS
-
-**Test App:**
-Iperf : iPerf3 is a tool for active measurements of the maximum achievable bandwidth on IP networks. It supports tuning of various parameters related to timing, buffers and protocols (TCP, UDP, SCTP with IPv4 and IPv6). For each test it reports the bandwidth, loss, and other parameters.
-
-# 2. Topology Diagram
-![test_topology.png](resources/test_topology.png
-"test_topology.png")
-
-**Physical Machines:**
-Server-------------------------Client
-connected via 82599ES 10-Gigabit SFI/SFP+ Network Connection
-
-**Virtual Machines:**
-Server-------------------------Client
-connected via 82540EM Gigabit Ethernet Controller
-# 3. Test Commands
-**Server Command with DMM:**
-```
-$sudo LD_LIBRARY_PATH=/home/root1/dmm/thirdparty/apps/iperf-3.1.3/src/.libs/ LD_PRELOAD=/home/root1/dmm/thirdparty/apps/iperf-3.1.3/src/.libs/libnStackAPI.so ./iperf3 -s -B 172.28.128.3 -4
-```
-
-**Client Command with DMM:**
-```
-$sudo LD_LIBRARY_PATH=/home/root1/dmm/thirdparty/apps/iperf-3.1.3/src/.libs/ LD_PRELOAD=/home/root1/dmm/thirdparty/apps/iperf-3.1.3/src/.libs/libnStackAPI.so ./iperf3 -c 172.18.128.3 -B 172.28.128.5 -4
-```
-
-**Server Command without DMM:**
-```
-$sudo ./iperf3 -s -B 172.28.128.3 -4
-```
-
-**Client Command without DMM:**
-```
-$sudo ./iperf3 -c 172.18.128.3 -B 172.28.128.5 -4
-```
-
-#4. Commit version
-```
-commit fa0dce9d94e9bfbdd9ec877036a101d2fd69f42c
-Merge: b5f1d4b f35c043
-Author: yalei wang <wylandrea@gmail.com>
-Date: Mon Dec 3 12:46:58 2018 +0000
-
- Merge "Fix: removing unwanted json elements"
-```
-```
-Download source code: git clone https://gerrit.fd.io/r/dmm
-```
-#5. Result
-
-**Physical Machines:**
-**DMM+Kernel:**
-
-**Server:**
-
-| ID | Interval | Transfer | Bandwidth | sender/receiver |
-| -- | -------- | --------- | ------------ | ----------------- |
-| 18 | 0.00-10.04 sec | 0.00 Bytes | 0.00 bits/sec | sender |
-| 18 | 0.00-10.04 sec | 11.0 GBytes | 9.38 Gbits/sec | receiver |
-
-**Client:**
-
-| ID | Interval | Transfer | Bandwidth | Retr | sender/receiver |
-| -- | -------- | --------- | ------------ | ------| ---------------- |
-| 17 | 0.00-10.00 sec | 11.0 GBytes | 9.41 Gbits/sec | 14 | sender |
-| 17 | 0.00-10.00 sec | 11.0 GBytes | 9.41 Gbits/sec | | receiver |
-
-**Kernel:**
-
-**Server:**
-
-| ID | Interval | Transfer | Bandwidth | sender/receiver |
-| -- | -------- | --------- | ------------ | ----------------- |
-| 5 | 0.00-10.04 sec | 0.00 Bytes | 0.00 bits/sec | sender |
-| 5 | 0.00-10.04 sec | 11.0 GBytes | 9.38 Gbits/sec | receiver |
-
-**Client:**
-
-| ID | Interval | Transfer | Bandwidth | Retr | sender/receiver |
-| -- | -------- | --------- | ------------ | ------| ---------------- |
-| 4 | 0.00-10.00 sec | 11.0 GBytes | 9.42 Gbits/sec | 15 | sender |
-| 4 | 0.00-10.00 sec | 11.0 GBytes | 9.41 Gbits/sec | | receiver |
-
-**Virtual Machines:**
-**DMM+Kernel:**
-
-**Server:**
-
-| ID | Interval | Transfer | Bandwidth | sender/receiver |
-| -- | -------- | --------- | ------------ | ----------------- |
-| 18 | 0.00-10.04 sec | 0.00 Bytes | 0.00 bits/sec | sender |
-| 18 | 0.00-10.04 sec | 2.94 GBytes | 2.51 Gbits/sec | receiver |
-
-**Client:**
-
-| ID | Interval | Transfer | Bandwidth | Retr | sender/receiver |
-| -- | -------- | --------- | ------------ | ------| ---------------- |
-| 17 | 0.00-10.00 sec | 2.94 GBytes | 2.52 Gbits/sec | 22634 | sender |
-| 17 | 0.00-10.00 sec | 2.94 GBytes | 2.52 Gbits/sec | | receiver |
-
-**Kernel:**
-
-**Server:**
-
-| ID | Interval | Transfer | Bandwidth | sender/receiver |
-| -- | -------- | --------- | ------------ | ----------------- |
-| 5 | 0.00-10.04 sec | 0.00 Bytes | 0.00 bits/sec | sender |
-| 5 | 0.00-10.04 sec | 2.87 GBytes | 2.46 Gbits/sec | receiver |
-
-**Client:**
-
-| ID | Interval | Transfer | Bandwidth | Retr | sender/receiver |
-| -- | -------- | --------- | ------------ | ------| ---------------- |
-| 4 | 0.00-10.00 sec | 2.87 GBytes | 2.47 Gbits/sec | 21104 | sender |
-| 4 | 0.00-10.00 sec | 2.87 GBytes | 2.47 Gbits/sec | | receiver |
-
-#7. Conclusion
-**Physical Machines:**
-The bandwidth while running iperf with kernel and DMM is 9.41 Gbits/sec at both sender and receiver and while running iperf with kernel alone is 9.42 Gbits/sec at sender and 9.41 Gbits/sec at receiver.
-
-**Virtual Machines:**
-The bandwidth while running iperf with kernel and DMM is 2.52 Gbits/sec at both sender and receiver and while running iperf with kernel alone is 2.47 Gbits/sec at both sender and receiver.
-
-These are the benchmark values for further tests. \ No newline at end of file
diff --git a/test/perf/resources/test_topology.png b/test/perf/resources/test_topology.png
deleted file mode 100644
index 26746da..0000000
--- a/test/perf/resources/test_topology.png
+++ /dev/null
Binary files differ
diff --git a/app_example/CMakeLists.txt b/testcode/app_example/CMakeLists.txt
index a82c752..ff25e1f 100644
--- a/app_example/CMakeLists.txt
+++ b/testcode/app_example/CMakeLists.txt
@@ -14,5 +14,18 @@
# limitations under the License.
#########################################################################
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11)
+PROJECT(nStack)
+SET(CMAKE_SKIP_RPATH TRUE)
+SET(CMAKE_C_COMPILER "gcc")
+SET(OS_RELEASE "" CACHE STRING "User-specified OS release.")
+
+SET(EXECUTABLE_PATH ${CMAKE_CURRENT_LIST_DIR}/release/bin)
+SET(LIB_PATH_STATIC ${PROJECT_BINARY_DIR})
+SET(LIB_PATH_SHARED ${CMAKE_CURRENT_LIST_DIR}/../../release/lib64)
+
+SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIB_PATH_STATIC})
+SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_PATH})
+SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIB_PATH_SHARED})
ADD_SUBDIRECTORY(perf-test)
ADD_SUBDIRECTORY(func-test)
diff --git a/stacks/lwip_stack/release/lib64/.gitkeep b/testcode/app_example/build/.gitkeep
index e69de29..e69de29 100644
--- a/stacks/lwip_stack/release/lib64/.gitkeep
+++ b/testcode/app_example/build/.gitkeep
diff --git a/app_example/func-test/CMakeLists.txt b/testcode/app_example/func-test/CMakeLists.txt
index 865eba5..865eba5 100644
--- a/app_example/func-test/CMakeLists.txt
+++ b/testcode/app_example/func-test/CMakeLists.txt
diff --git a/app_example/func-test/file_transfer/CMakeLists.txt b/testcode/app_example/func-test/file_transfer/CMakeLists.txt
index 408fc7a..e4f653a 100644
--- a/app_example/func-test/file_transfer/CMakeLists.txt
+++ b/testcode/app_example/func-test/file_transfer/CMakeLists.txt
@@ -18,15 +18,13 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -g -fPIC -m64 -mssse3 -std=gnu89")
LINK_DIRECTORIES(${LIB_PATH_SHARED} ${LIB_PATH_STATIC})
ADD_EXECUTABLE(vc_serv_file server_filetrans.c)
-ADD_DEPENDENCIES(vc_serv_file nStackAPI)
TARGET_LINK_LIBRARIES(vc_serv_file libnStackAPI.so -lpthread -lrt)
ADD_EXECUTABLE(vc_cli_file client_filetrans.c)
-ADD_DEPENDENCIES(vc_cli_file nStackAPI)
TARGET_LINK_LIBRARIES(vc_cli_file libnStackAPI.so -lpthread -lrt)
ADD_EXECUTABLE(kc_serv_file server_filetrans.c)
TARGET_LINK_LIBRARIES(kc_serv_file pthread)
ADD_EXECUTABLE(kc_cli_file client_filetrans.c)
-TARGET_LINK_LIBRARIES(kc_cli_file pthread) \ No newline at end of file
+TARGET_LINK_LIBRARIES(kc_cli_file pthread)
diff --git a/testcode/app_example/func-test/file_transfer/client_filetrans.c b/testcode/app_example/func-test/file_transfer/client_filetrans.c
new file mode 100644
index 0000000..f0e2a80
--- /dev/null
+++ b/testcode/app_example/func-test/file_transfer/client_filetrans.c
@@ -0,0 +1,276 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <fcntl.h>
+#include <netdb.h>
+#include <ctype.h>
+char *END_FLAG = "=================END";
+#define HEXCONVERT_COLS 8
+#define HEX_CONVERT 1
+//#define DEBUG 1
+#define out(fmt, arg...) (void)printf(fmt, ##arg)
+
+#ifdef DEBUG
+#define DBG(fmt, arg...) do { \
+ out("[Debug] " fmt, ##arg); \
+ } while (0)
+#else
+#define DBG(fmt, arg...) ((void)0)
+#endif
+
+void error(const char *msg)
+{
+ perror(msg);
+ out("./client_tcp [server_ip_address] [port number] [filename] [client_ip_address]\n");
+ exit(1);
+}
+
+#if defined(HEX_CONVERT) && defined(DEBUG)
+void hexconvert(void *mem, unsigned int len)
+{
+ unsigned int i;
+
+ for (i = 0;
+ i <
+ len +
+ ((len % HEXCONVERT_COLS) ? (HEXCONVERT_COLS -
+ len % HEXCONVERT_COLS) : 0); i++)
+ {
+ /* print offset */
+ if (i % HEXCONVERT_COLS == 0)
+ {
+ DBG("\n0x%06x: ", i);
+ }
+
+ /*print hex data */
+ if (i < len)
+ {
+ DBG("%02x ", 0xFF & ((char *) mem)[i]);
+ }
+ else /* end of block, just aligning for ASCII dump */
+ {
+ DBG("\n");
+ }
+ }
+}
+#endif
+
+void tcp(char **pArgv)
+{
+
+ int sockfd, portno;
+ char buff[1024];
+
+ struct sockaddr_in serv_addr, cli_addr;
+ struct hostent *server;
+
+ sockfd = socket(AF_INET, SOCK_STREAM, 0);
+ if (sockfd < 0)
+ {
+ error("error in socket creation\n");
+ }
+ out("socket create successful\n");
+
+ portno = atoi(pArgv[2]);
+ server = gethostbyname(pArgv[1]);
+
+ if (server == NULL)
+ {
+ fprintf(stderr, "error no such host\n");
+ }
+
+ bzero((char *) &serv_addr, sizeof(serv_addr));
+ serv_addr.sin_family = AF_INET;
+ bcopy((char *) server->h_addr, (char *) &serv_addr.sin_addr,
+ server->h_length);
+ serv_addr.sin_port = htons(portno);
+ bzero((char *) &cli_addr, sizeof(serv_addr));
+
+ cli_addr.sin_family = AF_INET;
+ cli_addr.sin_addr.s_addr = inet_addr(pArgv[4]);
+ cli_addr.sin_port = htons(portno);
+ if (bind(sockfd, (struct sockaddr *) &cli_addr, sizeof(cli_addr)) < 0)
+ {
+ error("bind fail");
+ }
+ out("Bind successful\n");
+
+ if (connect(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) <
+ 0)
+ {
+ error("connection fail");
+ }
+ out("connection done\n");
+
+ FILE *file;
+ int filebyte = 0;
+ int lsize, totalsize = 0;
+
+ file = fopen(pArgv[3], "r");
+ fseek(file, 0, SEEK_END);
+ lsize = ftell(file);
+ rewind(file);
+ out("Name of file: %s, Size of file : %d\n", pArgv[3], lsize);
+ if (write(sockfd, &lsize, sizeof(int)) == -1)
+ {
+ out("error executing write\n");
+ }
+ if (write(sockfd, pArgv[3], 255) == -1)
+ {
+ out("error executing write\n");
+ }
+ while (lsize > totalsize)
+ {
+ bzero(buff, 1024);
+ fseek(file, totalsize, SEEK_SET);
+ filebyte = fread(buff, 1, sizeof(buff), file);
+ if (filebyte == 0)
+ {
+ printf("file End of file\n");
+ break;
+ }
+
+ if (filebyte < 0)
+ error("error in reading file. \n");
+#if defined(HEX_CONVERT) && defined(DEBUG)
+ DBG("=========================================\n");
+ hexconvert(buff, filebyte);
+ DBG("=========================================\n");
+#endif
+
+ void *p = buff;
+ totalsize += filebyte;
+
+ while (filebyte > 0)
+ {
+#ifdef DEBUG
+ DBG("=========================================\n");
+ puts((const char *) p);
+ DBG("=========================================\n");
+#endif
+ int bytes_written = write(sockfd, p, filebyte);
+ if (bytes_written <= 0)
+ {
+ error("error in Socket write.\n");
+ }
+
+ filebyte -= bytes_written;
+ p += bytes_written;
+//#if DEBUG
+ DBG("Total size of file = %d, Total Bytes sent to socket = %d, bytes_written in each step = %d\n", lsize, totalsize, bytes_written);
+//#endif
+ }
+ }
+ out("file has been sent successfully\n");
+ out("Final Total size of file = %d, Total Bytes sent to socket = %d\n",
+ lsize, totalsize);
+
+ fclose(file);
+ sleep(60);
+ close(sockfd);
+ return;
+}
+
+void udp(char **pArgv)
+{
+ int sockfd, n, fd, sz, portno, MAXLINE;
+ FILE *fp;
+ struct sockaddr_in servaddr, cliaddr;
+ char *buf;
+ char *target, *path;
+ portno = atoi(pArgv[2]);
+ bzero(&servaddr, sizeof(servaddr));
+ servaddr.sin_family = AF_INET;
+ servaddr.sin_port = htons(portno);
+ servaddr.sin_addr.s_addr = inet_addr(pArgv[1]);
+ bzero(&cliaddr, sizeof(servaddr));
+ cliaddr.sin_family = AF_INET;
+ cliaddr.sin_port = htons(portno);
+ cliaddr.sin_addr.s_addr = inet_addr(pArgv[3]);
+ sockfd = socket(AF_INET, SOCK_DGRAM, 0);
+ if (sockfd < 0)
+ {
+ out("error in socket creation\n");
+ }
+ out("socket create successful\n");
+
+ if (bind(sockfd, (struct sockaddr *) &cliaddr, sizeof(cliaddr)) < 0)
+ {
+ out("bind fail");
+ }
+ out("Bind successful\n");
+
+ path = pArgv[4];
+ target = pArgv[5];
+ MAXLINE = atoi(pArgv[6]);
+ buf = malloc(MAXLINE * sizeof(int));
+ fp = fopen(path, "r");
+ fseek(fp, 0L, SEEK_END);
+ sz = ftell(fp);
+ out("The size of the path file is %d", sz);
+ sendto(sockfd, target, strlen(target), 0,
+ (struct sockaddr *) &servaddr, sizeof(servaddr));
+ n = recvfrom(sockfd, buf, MAXLINE, 0, NULL, NULL);
+ if (!strncmp(buf, "ok", 2))
+ {
+ out("Filename sent.\n");
+ }
+
+ fd = open(path, O_RDONLY);
+ while ((n = read(fd, buf, MAXLINE)) > 0)
+ {
+ sendto(sockfd, buf, n, 0, (struct sockaddr *) &servaddr,
+ sizeof(servaddr));
+ }
+ sendto(sockfd, END_FLAG, strlen(END_FLAG), 0,
+ (struct sockaddr *) &servaddr, sizeof(servaddr));
+ fclose(fp);
+ sleep(60);
+ close(sockfd);
+ return;
+}
+
+int main(int argc, char *argv[])
+{
+ int i;
+ char **pArgv, str[10];
+ pArgv = (char **) malloc(sizeof(char *) * 10);
+ for (i = 0; i < 10; i++)
+ {
+ pArgv[i] = (char *) malloc(sizeof(char) * 20);
+ }
+ printf("%s", argv[1]);
+
+ if (strcmp("tcp", argv[1]) == 0)
+ {
+ strcpy(pArgv[0], "tcp");
+ printf("pArgv[0]=%s", pArgv[0]);
+ /* The arguments of tcp are [server_ip_address] [port number] [filename] [client_ip_address] */
+ for (i = 1; i < 5; i++)
+ {
+ strcpy(pArgv[i], argv[i + 1]);
+ }
+ tcp(pArgv);
+ }
+
+ else
+ {
+ strcpy(str, argv[1]);
+ if (strcmp("udp", str) == 0)
+ {
+ strcpy(pArgv[0], "udp");
+ printf("pArgv[0]=%s", pArgv[0]);
+ /* The arguments of udp are [server_ip_address] [port number] [client_ip_address] [filename] [target_filename] [MAX_BUFFER_LENGTH] */
+ for (i = 1; i < 7; i++)
+ {
+ strcpy(pArgv[i], argv[i + 1]);
+ }
+ udp(pArgv);
+ }
+ }
+ return 0;
+}
diff --git a/testcode/app_example/func-test/file_transfer/server_filetrans.c b/testcode/app_example/func-test/file_transfer/server_filetrans.c
new file mode 100644
index 0000000..8b7e25f
--- /dev/null
+++ b/testcode/app_example/func-test/file_transfer/server_filetrans.c
@@ -0,0 +1,336 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <ctype.h>
+#include <arpa/inet.h>
+#include <fcntl.h>
+char *END_FLAG = "=================END";
+#define HEXCONVERT_COLS 8
+#define HEX_CONVERT 1
+//#define DEBUG 1
+#define out(fmt, arg...) (void)printf(fmt, ##arg)
+
+#ifdef DEBUG
+#define DBG(fmt, arg...) do { \
+ out("[Debug] " fmt, ##arg); \
+ } while (0)
+#else
+#define DBG(fmt, arg...) ((void)0)
+#endif
+
+void error(const char *msg)
+{
+ perror(msg);
+ out("./server_tcp [server_ip_address] [port number]\n");
+ exit(1);
+}
+
+#if defined(HEX_CONVERT) && defined(DEBUG)
+void hexconvert(void *mem, unsigned int len)
+{
+ unsigned int i;
+
+ for (i = 0;
+ i <
+ len +
+ ((len % HEXCONVERT_COLS) ? (HEXCONVERT_COLS -
+ len % HEXCONVERT_COLS) : 0); i++)
+ {
+ /* print offset */
+ if (i % HEXCONVERT_COLS == 0)
+ {
+ DBG("\n0x%06x: ", i);
+ }
+
+ /*print hex data */
+ if (i < len)
+ {
+ DBG("%02x ", 0xFF & ((char *) mem)[i]);
+ }
+ else /* end of block, just aligning for ASCII dump */
+ {
+ DBG("\n");
+ }
+ }
+}
+#endif
+int compareFiles(FILE * fp1, FILE * fp2)
+{
+
+ char ch1 = getc(fp1);
+ char ch2 = getc(fp2);
+ int error = 0, pos = 0, line = 1;
+
+ while (ch1 != EOF && ch2 != EOF)
+ {
+ pos++;
+ if (ch1 == '\n' && ch2 == '\n')
+ {
+ line++;
+ pos = 0;
+ }
+
+ if (ch1 != ch2)
+ {
+ error++;
+ DBG("Line Number : %d \tError" " Position :%d \n", line, pos);
+ }
+
+ ch1 = getc(fp1);
+ ch2 = getc(fp2);
+ }
+
+ //printf("Total Errors : %d\t", error);
+ return error;
+}
+
+void tcp(char **pArgv)
+{
+
+ int sockfd, newsockfd, portno;
+ char buff[1024], filename[255];
+
+ struct sockaddr_in serv_addr, cli_addr;
+ socklen_t clilen;
+
+ sockfd = socket(AF_INET, SOCK_STREAM, 0);
+ if (sockfd < 0)
+ {
+ error("error in socket creation");
+ }
+ out("socket create successful\n");
+
+ bzero((char *) &serv_addr, sizeof(serv_addr));
+ portno = atoi(pArgv[2]);
+
+ serv_addr.sin_family = AF_INET;
+ serv_addr.sin_addr.s_addr = inet_addr(pArgv[1]);
+ serv_addr.sin_port = htons(portno);
+
+ if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0)
+ {
+ error("bind fail");
+ }
+ out("Bind successful\n");
+ listen(sockfd, 5);
+ clilen = sizeof(cli_addr);
+
+ newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
+ if (newsockfd < 0)
+ {
+ error("error in accept");
+ }
+ out("socket accept succesful\n");
+ bzero(buff, 1024);
+
+ FILE *fp;
+ int lSize = 0, totallSize = 0;
+
+ bzero(filename, 255);
+
+ fclose(fopen("receive_file.txt", "w"));
+ if (system("chmod +x *") == -1)
+ {
+ out(" incorrect use of system\n");
+ }
+ fp = fopen("receive_file.txt", "a");
+
+ if (read(newsockfd, &lSize, sizeof(int)) == -1)
+ {
+ out("error executing read\n");
+ }
+ if (read(newsockfd, filename, sizeof(filename)) == -1)
+ {
+ out("error executing read\n");
+ }
+
+ while (lSize > totallSize)
+ {
+ int bytes_read = 0;
+ bzero(buff, 1024);
+
+ bytes_read = read(newsockfd, buff, 1024);
+
+ if (bytes_read == 0)
+ {
+ break;
+ }
+
+ if (bytes_read < 0)
+ {
+ error("error in Socket read.\n");
+ }
+
+#if defined(HEX_CONVERT) && defined(DEBUG)
+ DBG("=========================================\n");
+ hexconvert(buff, bytes_read);
+ DBG("=========================================\n");
+#endif
+#ifdef DEBUG
+ DBG("=========================================\n");
+ puts((const char *) buff);
+ DBG("=========================================\n");
+#endif
+ totallSize += bytes_read;
+
+ if (fwrite(buff, 1, bytes_read, fp) == -1)
+ {
+ error("error in file write\n");
+ }
+//#if DEBUG
+ DBG("Total size of file = %d, Total Bytes sent to socket = %d, bytes_read in each step = %d\n", lSize, totallSize, bytes_read);
+//#endif
+ }
+ out("file name = %s\n", filename);
+ out("Final total size of file = %d, total read from socket = %d\n", lSize,
+ totallSize);
+ out("copy complete\n");
+ fclose(fp);
+
+ FILE *fp1 = fopen("receive_file.txt", "r");
+ FILE *fp2 = fopen(filename, "r");
+
+ fseek(fp2, 0L, SEEK_END);
+ int lfile_size = ftell(fp2);
+ rewind(fp2);
+ if (lfile_size != lSize)
+ {
+ out("Size unmatch...\n");
+ }
+ else
+ {
+ out("Size match...\n");
+ }
+
+ if (compareFiles(fp1, fp2) > 0)
+ {
+ out("file unmatch...\n");
+ }
+ else
+ {
+ out("file match...\n");
+ }
+
+ close(newsockfd);
+ close(sockfd);
+ return;
+}
+
+void
+run(int sockfd, struct sockaddr *cliaddr, socklen_t clilen, char *res_buf,
+ int MAXLINE)
+{
+ int n, fd;
+ socklen_t len;
+ char *buf, *buf2;
+ FILE *fp1, *fp2;
+ buf = malloc(MAXLINE + 1);
+ len = clilen;
+ n = recvfrom(sockfd, buf, MAXLINE, 0, cliaddr, &len);
+ buf[n] = 0;
+ out("Received from client:[%s] \n", buf);
+ buf2 = malloc(MAXLINE);
+ strcpy(buf2, buf);
+ sendto(sockfd, "ok", strlen("ok"), 0, cliaddr, len);
+ fd = open(buf, O_RDWR | O_CREAT, 0666);
+ while ((n = recvfrom(sockfd, buf, MAXLINE, 0, cliaddr, &len)))
+ {
+ buf[n] = 0;
+ //out("%s", buf);
+ if (!(strcmp(buf, END_FLAG)))
+ {
+ break;
+ }
+ if (write(fd, buf, n) == -1)
+ {
+ out("error in executing write\n");
+ }
+ }
+ fp1 = fopen(buf2, "r");
+ fp2 = fopen(res_buf, "r");
+
+ if (compareFiles(fp1, fp2) == 0)
+ {
+ out("\nPass:The contents of the files are same");
+ }
+ else
+ {
+ out("\nFail:The contents of the files are different");
+ }
+ close(fd);
+}
+
+void udp(char **pArgv)
+{
+ int sockfd, portno, MAXLINE;
+ struct sockaddr_in servaddr, cliaddr;
+ char *res_buf;
+ res_buf = pArgv[3];
+
+ portno = atoi(pArgv[2]);
+ MAXLINE = atoi(pArgv[4]);
+ sockfd = socket(AF_INET, SOCK_DGRAM, 0);
+ if (sockfd < 0)
+ {
+ out("error in socket creation\n");
+ }
+ out("socket create successful\n");
+
+ bzero(&servaddr, sizeof(servaddr));
+ servaddr.sin_family = AF_INET;
+ servaddr.sin_addr.s_addr = inet_addr(pArgv[1]);
+ servaddr.sin_port = htons(portno);
+
+ if (bind(sockfd, (struct sockaddr *) &servaddr, sizeof(servaddr)) < 0)
+ {
+ out("bind fail");
+ }
+ out("Binded successfully\n");
+ fd_set read_fds;
+ FD_ZERO(&read_fds);
+ FD_SET(sockfd, &read_fds);
+ int fdmax = sockfd;
+ if (FD_ISSET(sockfd, &read_fds))
+ {
+ run(fdmax, (struct sockaddr *) &cliaddr, sizeof(cliaddr), res_buf,
+ MAXLINE);
+ }
+ return;
+}
+
+int main(int argc, char *argv[])
+{
+ int i, j;
+ char **pArgv;
+ pArgv = (char **) malloc(sizeof(char *) * 10);
+ for (i = 0; i < 10; i++)
+ {
+ pArgv[i] = (char *) malloc(sizeof(char) * 20);
+ }
+ if (strcmp("tcp", argv[1]) == 0)
+ {
+ strcpy(pArgv[0], "tcp");
+ /* The arguments of tcp are [server_ip_address] [port number] */
+ for (i = 1; i < 3; i++)
+ {
+ strcpy(pArgv[i], argv[i + 1]);
+ }
+ tcp(pArgv);
+ }
+ else if (strcmp("udp", argv[1]) == 0)
+ {
+ strcpy(pArgv[0], "udp");
+ /* The arguments of udp are [server_ip_address] [port number] [filename] [MAX_BUFFER_LENGTH] */
+ for (i = 1; i < 5; i++)
+ {
+ strcpy(pArgv[i], argv[i + 1]);
+ }
+ udp(pArgv);
+ }
+
+ return 0;
+}
diff --git a/app_example/func-test/fork/CMakeLists.txt b/testcode/app_example/func-test/fork/CMakeLists.txt
index f37dae7..a78f617 100644
--- a/app_example/func-test/fork/CMakeLists.txt
+++ b/testcode/app_example/func-test/fork/CMakeLists.txt
@@ -18,15 +18,13 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -g -fPIC -m64 -mssse3 -std=gnu89")
LINK_DIRECTORIES(${LIB_PATH_SHARED} ${LIB_PATH_STATIC})
ADD_EXECUTABLE(vtcp_fork_server tcpserver.c)
-ADD_DEPENDENCIES(vtcp_fork_server nStackAPI)
TARGET_LINK_LIBRARIES(vtcp_fork_server libnStackAPI.so -lpthread -lrt)
ADD_EXECUTABLE(vtcp_client tcpclient.c)
-ADD_DEPENDENCIES(vtcp_client nStackAPI)
TARGET_LINK_LIBRARIES(vtcp_client libnStackAPI.so -lpthread -lrt)
ADD_EXECUTABLE(ktcp_fork_server tcpserver.c)
TARGET_LINK_LIBRARIES(ktcp_fork_server pthread)
ADD_EXECUTABLE(ktcp_client tcpclient.c)
-TARGET_LINK_LIBRARIES(ktcp_client pthread) \ No newline at end of file
+TARGET_LINK_LIBRARIES(ktcp_client pthread)
diff --git a/testcode/app_example/func-test/fork/tcpclient.c b/testcode/app_example/func-test/fork/tcpclient.c
new file mode 100644
index 0000000..8023b34
--- /dev/null
+++ b/testcode/app_example/func-test/fork/tcpclient.c
@@ -0,0 +1,170 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <errno.h>
+
+#define DEBUG
+
+#ifdef DEBUG
+#define DBG(fmt, arg...) do { \
+ printf(fmt, ##arg); \
+} while(0)
+#else
+#define DBG(fmt, arg...) ((void)0)
+#endif
+
+static struct sockaddr_in g_dest;
+static struct sockaddr_in g_src;
+int srcPort = 0;
+int destPort = 0;
+int times = 0;
+
+void random_str(char *str, const int len)
+{
+ static const char alphaNum[] =
+ "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "0123456789";
+ int i = 0;
+
+ for (i = 0; i < len; i++)
+ {
+ str[i] = alphaNum[rand() % (sizeof(alphaNum) - 1)];
+ }
+
+ str[len] = 0;
+}
+
+static void setArgsDefault()
+{
+
+ memset(&g_dest, 0, sizeof(g_dest));
+ g_dest.sin_family = AF_INET;
+ g_dest.sin_addr.s_addr = inet_addr("127.0.0.1");
+ g_dest.sin_port = htons(12345);
+ bzero(&(g_dest.sin_zero), 8);
+
+ memset(&g_src, 0, sizeof(g_src));
+ g_src.sin_family = AF_INET;
+ g_src.sin_addr.s_addr = inet_addr("0.0.0.0");
+ g_src.sin_port = htons(7895);
+ bzero(&(g_src.sin_zero), 8);
+
+ times = 1;
+}
+
+static int process_arg(int argc, char *argv[])
+{
+ int opt = 0;
+ int error = 0;
+ const char *optstring = "p:d:s:a:t:";
+
+ if (argc < 5)
+ {
+ DBG("Param info :-p dest_portid; -d dest_serverIP; -a src_portid; -s src_clientIP; -t times; \n");
+ return -1;
+ }
+ setArgsDefault();
+ while ((opt = getopt(argc, argv, optstring)) != -1)
+ {
+ switch (opt)
+ {
+ case 'p':
+ g_dest.sin_port = htons(atoi(optarg));
+ break;
+ case 'd':
+ g_dest.sin_addr.s_addr = inet_addr(optarg);
+ break;
+ case 's':
+ g_src.sin_addr.s_addr = inet_addr(optarg);
+ break;
+ case 'a':
+ g_src.sin_port = htons(atoi(optarg));
+ break;
+ case 't':
+ times = atoi(optarg);
+ break;
+ }
+ }
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+
+ int clientSocket, ret, i;
+ char sndbuffer[1024];
+ char rcvbuffer[1024];
+ int result = 0;
+
+ /*
+ * check command line arguments
+ */
+ if (0 != process_arg(argc, argv))
+ {
+ DBG("Error in argument.%d\n", argc);
+ exit(1);
+ }
+
+ clientSocket = socket(AF_INET, SOCK_STREAM, 0);
+ if (clientSocket < 0)
+ {
+ DBG("Error in connection.\n");
+ exit(1);
+ }
+ DBG("[INFO]Client Socket is created.\n");
+
+ ret = bind(clientSocket, (struct sockaddr *) &g_src, sizeof(g_src));
+ if (ret < 0)
+ {
+ DBG("Error in binding.errno=%d\n", errno);
+ exit(1);
+ }
+
+ DBG("[INFO]Bind to client aaddress port 0\n");
+
+ ret = connect(clientSocket, (struct sockaddr *) &g_dest, sizeof(g_dest));
+ if (ret < 0)
+ {
+ DBG("Error in connection.\n");
+ exit(1);
+ }
+ DBG("[INFO]Connected to Server.\n");
+
+ memset(sndbuffer, '\0', 1024 * sizeof(char));
+ memset(rcvbuffer, '\0', 1024 * sizeof(char));
+
+ for (i = 1; i <= times; i++)
+ {
+ //DBG ("Client: \t");
+ random_str(sndbuffer, 50);
+ send(clientSocket, sndbuffer, strlen(sndbuffer), 0);
+
+ if (recv(clientSocket, rcvbuffer, 1024, 0) < 0)
+ {
+ DBG("Error in receiving data.\n");
+ }
+ else
+ {
+ //DBG ("Server: \t%s\n", rcvbuffer);
+ }
+ if (0 != strcmp(sndbuffer, rcvbuffer))
+ {
+ result = -1;
+ break;
+ }
+ }
+
+ /* Send exit message to server */
+ strcpy(sndbuffer, "#exit");
+ send(clientSocket, sndbuffer, strlen(sndbuffer), 0);
+
+ DBG("Result = %s\n", (result == 0) ? "Success" : "Fail");
+ close(clientSocket);
+ DBG("Disconnecting from server.\n");
+ return 0;
+}
diff --git a/testcode/app_example/func-test/fork/tcpserver.c b/testcode/app_example/func-test/fork/tcpserver.c
new file mode 100644
index 0000000..af11832
--- /dev/null
+++ b/testcode/app_example/func-test/fork/tcpserver.c
@@ -0,0 +1,156 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <sys/wait.h>
+
+static struct sockaddr_in g_src;
+int srcPort = 0;
+int destPort = 0;
+int times = 0;
+
+#ifdef DEBUG
+#define DBG(fmt, arg...) do { \
+ DBG(fmt, ##arg); \
+} while(0)
+#else
+#define DBG(fmt, arg...) ((void)0)
+#endif
+
+static void setArgsDefault()
+{
+ memset(&g_src, 0, sizeof(g_src));
+ g_src.sin_family = AF_INET;
+ g_src.sin_addr.s_addr = inet_addr("0.0.0.0");
+ g_src.sin_port = htons(7895);
+ bzero(&(g_src.sin_zero), 8);
+
+ times = 1;
+}
+
+static int process_arg(int argc, char *argv[])
+{
+ int opt = 0;
+ int error = 0;
+ const char *optstring = "s:a:t:";
+
+ if (argc < 5)
+ {
+ DBG("Param info :-p dest_portid; -d dest_serverIP; -a src_portid; -s src_clientIP; -t times; \n");
+ return -1;
+ }
+ setArgsDefault();
+ while ((opt = getopt(argc, argv, optstring)) != -1)
+ {
+ switch (opt)
+ {
+ case 's':
+ g_src.sin_addr.s_addr = inet_addr(optarg);
+ break;
+ case 'a':
+ g_src.sin_port = htons(atoi(optarg));
+ break;
+ case 't':
+ times = atoi(optarg);
+ break;
+ }
+ }
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+
+ int sockfd, ret;
+ int newSocket;
+ socklen_t addr_size;
+ static struct sockaddr_in accept_addr;
+ char buffer[1024];
+ pid_t childpid;
+
+ /*
+ * check command line arguments
+ */
+ if (0 != process_arg(argc, argv))
+ {
+ DBG("Error in argument.%d\n", argc);
+ exit(1);
+ }
+
+ sockfd = socket(AF_INET, SOCK_STREAM, 0);
+ if (sockfd < 0)
+ {
+ DBG("Error in connection.\n");
+ exit(1);
+ }
+ DBG("Server Socket is created. %d\n", sockfd);
+
+ ret = bind(sockfd, (struct sockaddr *) &g_src, sizeof(g_src));
+ if (ret < 0)
+ {
+ DBG("Error in binding.errno=%d\n", errno);
+ exit(1);
+ }
+
+ DBG("Bind sucess port %d\n", g_src.sin_port);
+
+ if (listen(sockfd, 10) == 0)
+ {
+ DBG("Listening on %s....\n", inet_ntoa(g_src.sin_addr));
+ }
+ else
+ {
+ DBG("Error in binding.\n");
+ }
+
+ while (1)
+ {
+ newSocket =
+ accept(sockfd, (struct sockaddr *) &accept_addr, &addr_size);
+ if (newSocket < 0)
+ {
+ DBG("Error: Exiting here pid %d", getpid());
+ exit(1);
+ }
+
+ DBG("Connection accepted from %s:%d fd %d\n",
+ inet_ntoa(accept_addr.sin_addr),
+ ntohs(accept_addr.sin_port), newSocket);
+ if ((childpid = fork()) == 0)
+ {
+ DBG("[ PID %d] Child process Created. Pid %d \r\n", getpid(),
+ getpid());
+ DBG("[ PID %d] Closing fd %d\n", getpid(), sockfd);
+ close(sockfd);
+
+ while (1)
+ {
+ memset(buffer, '\0', 1024 * sizeof(char));
+ recv(newSocket, buffer, 1024, 0);
+ if (strcmp(buffer, "#exit") == 0)
+ {
+ DBG("Disconnected from %s:%d\n",
+ inet_ntoa(newAddr.sin_addr), ntohs(newAddr.sin_port));
+ break;
+ }
+ else
+ {
+ DBG("[PID %d]Client: %s\n", getpid(), buffer);
+ send(newSocket, buffer, strlen(buffer), 0);
+ bzero(buffer, sizeof(buffer));
+ }
+ }
+
+ DBG("[PID %d]Closing socket %d\r\n", getpid(), newSocket);
+ close(newSocket);
+ }
+
+ }
+
+ DBG("[PID %d]Process exiting... %d\r\n", getpid(), getpid());
+ return 0;
+}
diff --git a/release/configure/module_config.json b/testcode/app_example/module_config.json
index e8e9001..fd4b47a 100644
--- a/release/configure/module_config.json
+++ b/testcode/app_example/module_config.json
@@ -3,6 +3,7 @@
"module_list": [
{
"stack_name": "kernel", /*stack name*/
+ "function_name": "kernel_stack_register",
"libname": "./", /*library name, if loadtype is static, this maybe
null, else must give a library name*/
"deploytype": "1", /*deploy model type:model type1, model type2,
@@ -10,14 +11,5 @@
deployment. Used during shared memory initialization.*/
"stackid": "0", /*stack id, this must be ordered and not be repeated*/
},
- /**************************
- *this is not a real stack, just an example for multiple stack configurations*
- {
- "stack_name": "stackx",
- "libname": "libstackx.so",
- "deploytype": "3",
- "stackid": "1",
- },
- ***************************/
]
}
diff --git a/app_example/perf-test/CMakeLists.txt b/testcode/app_example/perf-test/CMakeLists.txt
index 7f05b84..dbef0f2 100644
--- a/app_example/perf-test/CMakeLists.txt
+++ b/testcode/app_example/perf-test/CMakeLists.txt
@@ -18,15 +18,12 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -g -fPIC -m64 -mssse3 -std=gnu89")
LINK_DIRECTORIES(${LIB_PATH_SHARED} ${LIB_PATH_STATIC})
ADD_EXECUTABLE(vc_common multi_tcp_common_app_Cli.c)
-ADD_DEPENDENCIES(vc_common nStackAPI)
TARGET_LINK_LIBRARIES(vc_common libnStackAPI.so -lpthread -lrt)
ADD_EXECUTABLE(vs_epoll multi_tcp_epoll_app_Ser.c)
-ADD_DEPENDENCIES(vs_epoll nStackAPI)
TARGET_LINK_LIBRARIES(vs_epoll libnStackAPI.so -lpthread -lrt)
ADD_EXECUTABLE(vs_select multi_tcp_select_app_Ser.c)
-ADD_DEPENDENCIES(vs_select nStackAPI)
TARGET_LINK_LIBRARIES(vs_select libnStackAPI.so -lpthread -lrt)
ADD_EXECUTABLE(kc_common multi_tcp_common_app_Cli.c)
@@ -39,7 +36,6 @@ ADD_EXECUTABLE(ks_select multi_tcp_select_app_Ser.c)
TARGET_LINK_LIBRARIES(ks_select pthread)
ADD_EXECUTABLE(vs_common multi_tcp_common_Ser.c)
-ADD_DEPENDENCIES(vs_common nStackAPI)
TARGET_LINK_LIBRARIES(vs_common libnStackAPI.so -lpthread -lrt)
ADD_EXECUTABLE(ks_common multi_tcp_common_Ser.c)
diff --git a/testcode/app_example/perf-test/multi_tcp_common_Ser.c b/testcode/app_example/perf-test/multi_tcp_common_Ser.c
new file mode 100644
index 0000000..27d44ae
--- /dev/null
+++ b/testcode/app_example/perf-test/multi_tcp_common_Ser.c
@@ -0,0 +1,538 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#include <fcntl.h>
+#include <memory.h>
+#include <signal.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <netinet/in.h>
+#include <time.h>
+#include <linux/tcp.h>
+#define __USE_GNU
+#include <sched.h>
+#include <pthread.h>
+#include <arpa/inet.h>
+#include <sys/epoll.h>
+#include <errno.h>
+
+#define _BIND bind
+#define _LISTEN listen
+#define _SOCKET socket
+#define _ACCEPT accept
+#define _SEND send
+#define _RECV recv
+#define _CLOSE close
+#define _CONNECT connect
+#define _PROTOCOL IPPROTO_TCP
+
+#define MAX_TEST_TIME 1000
+#define MSG_LENGTH 256
+#define CORE_NUM 8
+#define START_CPU_ID 2
+#define MAX_CONN_LIMIT 256
+#define MAX_PORT_NUM 65535
+//1:A-B ;0:A-B-A
+#define SEND_RECV_MODE 1
+#define MAX_EVENTS 1000
+#define Default_PortID 12345
+#define Default_SleepCnt 10000
+#define Default_SleepTime 1000000
+#define Flag_Print 1
+#define Fd_Number 1
+
+static struct sockaddr_in g_dest;
+static struct sockaddr_in g_src;
+static struct sockaddr_in g_recv;
+
+int times = MAX_TEST_TIME;
+int msg_length = MSG_LENGTH;
+int coreNum = CORE_NUM;
+int startCPUId = START_CPU_ID;
+int connectNum = MAX_CONN_LIMIT;
+int msgMode = SEND_RECV_MODE;
+int sleepCnt = Default_SleepCnt;
+int sleepTime = Default_SleepTime; //us
+int fdNumber = Fd_Number;
+int flagPrint = Flag_Print;
+int unitPrint = 0;
+int waitTime = 0;
+
+int srcPort = Default_PortID;
+int destPort = 0;
+int recvPort = 0;
+char sendarr[256] = "";
+char recvarr[256] = "";
+char destarr[256] = "";
+
+static void setArgsDefault()
+{
+
+ memset(&g_dest, 0, sizeof(g_dest));
+ g_dest.sin_family = AF_INET;
+ g_dest.sin_addr.s_addr = inet_addr("127.0.0.1");
+ g_dest.sin_port = htons(12345);
+ bzero(&(g_dest.sin_zero), 8);
+
+ memset(&g_src, 0, sizeof(g_src));
+ g_src.sin_family = AF_INET;
+ g_src.sin_addr.s_addr = inet_addr("0.0.0.0");
+ g_src.sin_port = htons(7895);
+ bzero(&(g_src.sin_zero), 8);
+
+ memset(&g_recv, 0, sizeof(g_recv));
+ g_recv.sin_family = AF_INET;
+ g_recv.sin_addr.s_addr = inet_addr("0.0.0.0");
+ g_recv.sin_port = htons(7895);
+ bzero(&(g_recv.sin_zero), 8);
+
+}
+
+static int process_arg(int argc, char *argv[])
+{
+ int opt = 0;
+ int error = 0;
+ const char *optstring = "p:d:s:a:l:t:e:i:f:r:n:w:u:x:";
+ int rw_mark = 0;
+
+ if (argc < 4)
+ {
+ printf
+ ("Param info :-p dest_portid; -d dest_serverIP; -a src_portid; -s src_clientIP; -l msg_length; \n");
+ printf
+ ("\t-t MAX_TEST_TIME; -i msg_interval ; -f client fd number ; -r receive port; -n connectNum(one server vs n client)\n");
+ return 0;
+ }
+ while ((opt = getopt(argc, argv, optstring)) != -1)
+ {
+ switch (opt)
+ {
+ case 'p':
+ destPort = atoi(optarg);
+ g_dest.sin_port = htons(atoi(optarg));
+ break;
+ case 'd':
+ stpcpy(destarr, optarg);
+ g_dest.sin_addr.s_addr = inet_addr(optarg);
+ break;
+ case 's':
+ stpcpy(sendarr, optarg);
+ g_src.sin_addr.s_addr = inet_addr(optarg);
+ g_recv.sin_addr.s_addr = inet_addr(optarg);
+ break;
+ case 'a':
+ //g_src.sin_port = htons(atoi(optarg));
+ srcPort = atoi(optarg);
+ break;
+ case 'l':
+ msg_length = atoi(optarg);
+ break;
+ case 't':
+ times = atoi(optarg);
+ break;
+ case 'e':
+ sleepCnt = atoi(optarg);
+ break;
+ case 'i':
+ sleepTime = atoi(optarg);
+ break;
+ case 'f':
+ fdNumber = atoi(optarg);
+ break;
+ case 'r':
+ recvPort = atoi(optarg);
+ g_recv.sin_port = htons(atoi(optarg));
+ break;
+ case 'n':
+ connectNum = atoi(optarg);
+ break;
+ case 'w':
+ waitTime = atoi(optarg);
+ break;
+ case 'u':
+ unitPrint = atoi(optarg);
+ break;
+ case 'x':
+ flagPrint = atoi(optarg);
+ break;
+
+ }
+ }
+ return 1;
+}
+
+void process_client(void)
+{
+ int sendLen = 0;
+ int i = 0, t = 0, p = 0, optval = 0, ret = 0;
+ char send_buf[1000] = "";
+ int c_socketfd[100] = { 0 };
+ int errbind[1000] = { 0 };
+ int errconn[1000] = { 0 };
+
+ int send_count[1000] = { 0 };
+ int pps = 0;
+ long pps_time = 0;
+
+ struct timespec startTime, endTime;
+ struct timespec countStart;
+ struct timespec countEnd;
+
+ memset(&countStart, 0, sizeof(countStart));
+ memset(&countEnd, 0, sizeof(countEnd));
+
+ for (i = 0; i < fdNumber; i++)
+ {
+ c_socketfd[i] = _SOCKET(PF_INET, SOCK_STREAM, _PROTOCOL);
+ if (0 > c_socketfd[i])
+ {
+ printf("client %d failed,err %d\n", i, errno);
+ }
+ else
+ {
+ printf("client %d created success\n", i);
+ }
+ }
+
+ for (i = 0; i < fdNumber; i++)
+ {
+ optval = 1;
+ ret =
+ setsockopt(c_socketfd[i], SOL_SOCKET, SO_REUSEADDR,
+ (void *) &optval, sizeof(optval));
+ if (ret == -1)
+ {
+ printf("Couldn't setsockopt(SO_REUSEADDR)\n");
+ break;
+ }
+ }
+
+ for (i = 0; i < fdNumber; i++)
+ {
+ g_src.sin_port = htons(srcPort + i);
+ errbind[i] =
+ _BIND(c_socketfd[i], (struct sockaddr *) &g_src, sizeof(g_src));
+ if (errbind[i] < 0)
+ {
+ printf("client %d bind Failed %d\n", i, errno);
+ _CLOSE(c_socketfd[i]);
+ c_socketfd[i] = -1;
+ continue;
+ }
+ else
+ {
+ printf("client %d bind Success port:%d IP:%s\n", i,
+ ntohs(g_src.sin_port),
+ inet_ntoa(*((struct in_addr *) &(g_src.sin_addr.s_addr))));
+ }
+ }
+ for (i = 0; i < fdNumber; i++)
+ {
+ if (errbind[i] >= 0)
+ {
+ errconn[i] =
+ _CONNECT(c_socketfd[i], (struct sockaddr *) &g_dest,
+ sizeof(g_dest));
+ if (errconn[i] < 0)
+ {
+ printf("client %d Connect Failed %d\n", i, errno);
+ _CLOSE(c_socketfd[i]);
+ c_socketfd[i] = -1;
+ continue;
+ }
+ else
+ {
+ printf("client %d Connect Success port:%d, IP:%s\n", i,
+ ntohs(g_dest.sin_port),
+ inet_ntoa(*
+ ((struct in_addr *)
+ &(g_dest.sin_addr.s_addr))));
+ }
+ }
+ }
+
+ sleep(1);
+
+ clock_gettime(CLOCK_MONOTONIC, &startTime);
+ clock_gettime(CLOCK_MONOTONIC, &countStart);
+
+ for (t = 0; t < times; t++)
+ {
+ for (i = 0; i < fdNumber; i++)
+ {
+ if (c_socketfd[i] < 0)
+ {
+ continue;
+ }
+ do
+ {
+ sendLen = _SEND(c_socketfd[i], send_buf, msg_length, 0);
+ }
+ while (sendLen <= 0);
+ send_count[i]++;
+ }
+
+ if (0 != sleepTime)
+ {
+ if ((t % sleepCnt) == 0)
+ {
+ usleep(sleepTime);
+ }
+ }
+
+ if ((send_count[0] % unitPrint) == 0)
+ {
+ clock_gettime(CLOCK_MONOTONIC, &countEnd);
+
+ pps_time =
+ (countEnd.tv_sec - countStart.tv_sec) * 1000000000 +
+ countEnd.tv_nsec - countStart.tv_nsec;
+ pps = ((float) 1000000000 / pps_time) * unitPrint * fdNumber;
+ if ((flagPrint != 0))
+ {
+ printf(" sendcount %d, time: %ld ns\n",
+ send_count[0] * fdNumber, pps_time);
+ }
+ printf("sendcount %d , pps=%d\n", send_count[0] * fdNumber, pps);
+ clock_gettime(CLOCK_MONOTONIC, &countStart);
+ }
+ }
+
+ clock_gettime(CLOCK_MONOTONIC, &endTime);
+
+ for (i = 0; i < fdNumber; i++)
+ {
+ printf("client %d send %d , sendtime :%ld s %ld ns\n", i,
+ send_count[i], endTime.tv_sec - startTime.tv_sec,
+ endTime.tv_nsec - startTime.tv_nsec);
+ }
+
+ for (i = 0; i < fdNumber; i++)
+ {
+ printf("client %d close!\n", i);
+ if (c_socketfd[i] > 0)
+ _CLOSE(c_socketfd[i]);
+ }
+
+ pthread_exit(NULL);
+}
+
+/*
+ using this thread to do recv msg;
+*/
+void *process_server_msg_thread(void *pArgv)
+{
+ int recvLen = 0, recvLen2 = 0;
+ char send_buf[1000];
+ char recv_buf[1000];
+ int recv_count = 0;
+ long recv_ppstime = 0;
+ int recv_pps = 0;
+ int ret;
+ struct timespec recvStart;
+ struct timespec recvEnd;
+ memset(&recvStart, 0, sizeof(recvStart));
+ memset(&recvEnd, 0, sizeof(recvEnd));
+
+ pthread_detach(pthread_self());
+
+ int msgFd = *(int *) pArgv;
+ clock_gettime(CLOCK_MONOTONIC, &recvStart);
+ while (recv_count < times)
+ {
+ recvLen = 0;
+ recvLen2 = 0;
+ while (1)
+ {
+ recvLen2 =
+ recv(msgFd, recv_buf + recvLen, msg_length - recvLen, 0);
+ if (recvLen2 <= 0)
+ {
+ break;
+ }
+ else if (recvLen2 == msg_length - recvLen)
+ {
+ recvLen = 0;
+ recv_count++;
+ if (msg_length != send(msgFd, send_buf, msg_length, 0))
+ {
+ printf("send failed!====, need exit\n");
+ }
+
+ }
+ else if (recvLen2 < msg_length - recvLen)
+ {
+ recvLen += recvLen2;
+ }
+ if ((flagPrint != 0) && ((recv_count % unitPrint) == 0))
+ {
+ clock_gettime(CLOCK_MONOTONIC, &recvEnd);
+ recv_ppstime =
+ (recvEnd.tv_sec - recvStart.tv_sec) * 1000000000 +
+ recvEnd.tv_nsec - recvStart.tv_nsec;
+ recv_pps = ((float) 1000000000 / recv_ppstime) * unitPrint;
+ printf("receive count:%d, receive time: %ld ns\n", recv_count,
+ recv_ppstime);
+ printf("receive pps = %d\n", recv_pps);
+ clock_gettime(CLOCK_MONOTONIC, &recvStart);
+ }
+ }
+ }
+ close(msgFd);
+}
+
+/*
+ using this thread to do accept connect
+*/
+void *process_server_accept_thread(void *pArgv)
+{
+ int listenFd = 0;
+ int x, optval, ret, m = 0;
+ int acpt_socketfd[1000] = { 0 };
+
+ listenFd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if (0 > listenFd)
+ {
+ printf("ERROR:socket failed,errno [%d]\n", errno);
+ return;
+ }
+ else
+ {
+ printf("INFO:Create listen socket Success, listenFd[%d]\n", listenFd);
+ }
+
+ if (0 > fcntl(listenFd, F_SETFL, O_NONBLOCK))
+ {
+ printf("ERROR:fcntl failed. fd[%d], errno[%d]/n", listenFd, errno);
+ close(listenFd);
+ }
+
+ optval = 1;
+ ret =
+ setsockopt(listenFd, SOL_SOCKET, SO_REUSEADDR, (void *) &optval,
+ sizeof(optval));
+ if (ret == -1)
+ {
+ printf("ERROR:setsockopt failed. fd[%d], errno[%d]\n", listenFd,
+ errno);
+ close(listenFd);
+ return;
+ }
+
+ if (0 !=
+ bind(listenFd, (struct sockaddr *) &g_recv, sizeof(struct sockaddr)))
+ {
+ printf("ERROR:bind failed. fd[%d] errno [%d]\n", listenFd, errno);
+ printf("INFO:Bind Failed, port %d IP:%s\n", ntohs(g_recv.sin_port),
+ inet_ntoa(*((struct in_addr *) &(g_recv.sin_addr.s_addr))));
+ close(listenFd);
+ exit(-1);
+ }
+ else
+ {
+ printf("Info Bind Success, port %d IP:%s\n", ntohs(g_recv.sin_port),
+ inet_ntoa(*((struct in_addr *) &(g_recv.sin_addr.s_addr))));
+ }
+
+ if (0 != listen(listenFd, 100))
+ {
+ printf("server socket listen failed. err %d\n", errno);
+ close(listenFd);
+ return;
+ }
+ printf("Listen Success\n");
+
+ int timeout = -1;
+ int accpedNum = 0;
+ while (accpedNum < connectNum)
+ {
+ while (1)
+ {
+ acpt_socketfd[accpedNum] =
+ accept4(listenFd, NULL, NULL, SOCK_NONBLOCK);
+ if (acpt_socketfd[accpedNum] < 0)
+ {
+ break;
+ }
+
+ fcntl(acpt_socketfd[accpedNum], F_SETFL, 0);
+
+ /*add new accptFd to MsgEpFD */
+ pthread_t ser_rcv_thread_id;
+ if (pthread_create
+ (&ser_rcv_thread_id, NULL, process_server_msg_thread,
+ (void *) &acpt_socketfd[accpedNum]) == -1)
+ {
+ printf("create process_server_msg_thread fail\n");
+ break;
+ }
+
+ printf("accept cnt [%d], cur accept fd [%d]\n", accpedNum,
+ acpt_socketfd[accpedNum]);
+ accpedNum++;
+ }
+ }
+ close(listenFd);
+ while (1)
+ {
+ sleep(10);
+ }
+
+ pthread_exit(NULL);
+}
+
+void main(int argc, char *argv[])
+{
+ socklen_t addrlen = sizeof(struct sockaddr);
+ int err = 0, result = 0, ret = 0;
+ int i = 0, j = 0, optval = 0, z = 0, x, listenfd;
+ cpu_set_t mask;
+
+ setArgsDefault();
+ ret = process_arg(argc, argv);
+ if (ret != 1)
+ {
+ printf("The param error\n");
+ return;
+ }
+
+ pthread_t server_thread_id;
+
+ if (pthread_create
+ (&server_thread_id, NULL, process_server_accept_thread, NULL) == -1)
+ {
+ printf("create process_server_accept_thread fail\n");
+ return;
+ }
+
+ printf("create process_server_accept_thread success\n");
+
+ if (server_thread_id != 0)
+ {
+ printf("Server Thread join\n");
+ pthread_join(server_thread_id, NULL);
+ }
+
+ while (1)
+ {
+ sleep(10);
+ }
+
+ return;
+}
diff --git a/testcode/app_example/perf-test/multi_tcp_common_app_Cli.c b/testcode/app_example/perf-test/multi_tcp_common_app_Cli.c
new file mode 100644
index 0000000..02991bd
--- /dev/null
+++ b/testcode/app_example/perf-test/multi_tcp_common_app_Cli.c
@@ -0,0 +1,392 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#define _GNU_SOURCE
+#include <sys/socket.h>
+#include <fcntl.h>
+#include <memory.h>
+#include <signal.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <netinet/in.h>
+#include <time.h>
+#include <linux/tcp.h>
+#include <sched.h>
+#include <pthread.h>
+#include <arpa/inet.h>
+#include <sys/epoll.h>
+#include <errno.h>
+
+#define _BIND bind
+#define _LISTEN listen
+#define _SOCKET socket
+#define _ACCEPT accept
+#define _SEND send
+#define _RECV recv
+#define _CLOSE close
+#define _CONNECT connect
+#define _PROTOCOL IPPROTO_TCP
+
+#define MAX_TEST_TIME 1000
+#define MSG_LENGTH 256
+#define CORE_NUM 8
+#define START_CPU_ID 2
+#define MAX_CONN_LIMIT 256
+#define MAX_PORT_NUM 65535
+//1:A-B ;0:A-B-A
+#define SEND_RECV_MODE 1
+#define MAX_EVENTS 1000
+#define Default_PortID 12345
+#define Default_SleepCnt 10000
+#define Default_SleepTime 1000000
+#define Flag_Print 1
+#define Fd_Number 1
+
+static struct sockaddr_in g_dest;
+static struct sockaddr_in g_src;
+static struct sockaddr_in g_recv;
+
+int times = MAX_TEST_TIME;
+int msg_length = MSG_LENGTH;
+int coreNum = CORE_NUM;
+int startCPUId = START_CPU_ID;
+int connectNum = MAX_CONN_LIMIT;
+int msgMode = SEND_RECV_MODE;
+int sleepCnt = Default_SleepCnt;
+int sleepTime = Default_SleepTime; //us
+int fdNumber = Fd_Number;
+int flagPrint = Flag_Print;
+int unitPrint = 0;
+int waitTime = 0;
+
+int srcPort = Default_PortID;
+int destPort = 0;
+int recvPort = 0;
+char sendarr[256] = "";
+char recvarr[256] = "";
+char destarr[256] = "";
+
+static void setArgsDefault()
+{
+
+ memset(&g_dest, 0, sizeof(g_dest));
+ g_dest.sin_family = AF_INET;
+ g_dest.sin_addr.s_addr = inet_addr("127.0.0.1");
+ g_dest.sin_port = htons(12345);
+ bzero(&(g_dest.sin_zero), 8);
+
+ memset(&g_src, 0, sizeof(g_src));
+ g_src.sin_family = AF_INET;
+ g_src.sin_addr.s_addr = inet_addr("0.0.0.0");
+ g_src.sin_port = htons(7895);
+ bzero(&(g_src.sin_zero), 8);
+
+ memset(&g_recv, 0, sizeof(g_recv));
+ g_recv.sin_family = AF_INET;
+ g_recv.sin_addr.s_addr = inet_addr("0.0.0.0");
+ g_recv.sin_port = htons(7895);
+ bzero(&(g_recv.sin_zero), 8);
+
+}
+
+static int process_arg(int argc, char *argv[])
+{
+ int opt = 0;
+ int error = 0;
+ const char *optstring = "p:d:s:a:l:t:e:i:f:r:n:w:u:x:";
+ int rw_mark = 0;
+
+ if (argc < 4)
+ {
+ printf
+ ("Param info :-p dest_portid; -d dest_serverIP; -a src_portid; -s src_clientIP; -l msg_length; \n");
+ printf
+ ("\t-t MAX_TEST_TIME; -i msg_interval ; -f client fd number ; -r receive port; -n connectNum(one server vs n client)\n");
+ return 0;
+ }
+ while ((opt = getopt(argc, argv, optstring)) != -1)
+ {
+ switch (opt)
+ {
+ case 'p':
+ destPort = atoi(optarg);
+ g_dest.sin_port = htons(atoi(optarg));
+ break;
+ case 'd':
+ stpcpy(destarr, optarg);
+ g_dest.sin_addr.s_addr = inet_addr(optarg);
+ break;
+ case 's':
+ stpcpy(sendarr, optarg);
+ g_src.sin_addr.s_addr = inet_addr(optarg);
+ g_recv.sin_addr.s_addr = inet_addr(optarg);
+ break;
+ case 'a':
+ //g_src.sin_port = htons(atoi(optarg));
+ srcPort = atoi(optarg);
+ break;
+ case 'l':
+ msg_length = atoi(optarg);
+ break;
+ case 't':
+ times = atoi(optarg);
+ break;
+ case 'e':
+ sleepCnt = atoi(optarg);
+ break;
+ case 'i':
+ sleepTime = atoi(optarg);
+ break;
+ case 'f':
+ fdNumber = atoi(optarg);
+ break;
+ case 'r':
+ recvPort = atoi(optarg);
+ g_recv.sin_port = htons(atoi(optarg));
+ break;
+ case 'n':
+ connectNum = atoi(optarg);
+ break;
+ case 'w':
+ waitTime = atoi(optarg);
+ break;
+ case 'u':
+ unitPrint = atoi(optarg);
+ break;
+ case 'x':
+ flagPrint = atoi(optarg);
+ break;
+
+ }
+ }
+ return 1;
+}
+
+void process_client(void)
+{
+ int sendLen = 0;
+ int i = 0, t = 0, p = 0, optval = 0, ret = 0;
+ char send_buf[1000] = "";
+ char recv_buf[1000] = "";
+ int c_socketfd[100] = { 0 };
+ int errbind[1000] = { 0 };
+ int errconn[1000] = { 0 };
+
+ int send_count[1000] = { 0 };
+ int pps = 0;
+ long pps_time = 0;
+
+ struct timespec startTime, endTime;
+ struct timespec countStart;
+ struct timespec countEnd;
+ memset(&countStart, 0, sizeof(countStart));
+ memset(&countEnd, 0, sizeof(countEnd));
+
+ for (i = 0; i < fdNumber; i++)
+ {
+ c_socketfd[i] = _SOCKET(PF_INET, SOCK_STREAM, _PROTOCOL);
+ if (0 > c_socketfd[i])
+ {
+ printf("client %d failed,err %d\n", i, errno);
+ }
+ else
+ {
+ printf("client %d created success\n", i);
+ }
+ }
+
+ for (i = 0; i < fdNumber; i++)
+ {
+ optval = 1;
+ ret =
+ setsockopt(c_socketfd[i], SOL_SOCKET, SO_REUSEADDR,
+ (void *) &optval, sizeof(optval));
+ if (ret == -1)
+ {
+ printf("Couldn't setsockopt(SO_REUSEADDR)\n");
+ break;
+ }
+ }
+
+ for (i = 0; i < fdNumber; i++)
+ {
+ g_src.sin_port = htons(srcPort + i);
+ errbind[i] =
+ _BIND(c_socketfd[i], (struct sockaddr *) &g_src, sizeof(g_src));
+ if (errbind[i] < 0)
+ {
+ printf("client %d bind Failed %d\n", i, errno);
+ _CLOSE(c_socketfd[i]);
+ c_socketfd[i] = -1;
+ continue;
+ }
+ else
+ {
+ printf("client %d bind Success port:%d IP:%s\n", i,
+ ntohs(g_src.sin_port),
+ inet_ntoa(*((struct in_addr *) &(g_src.sin_addr.s_addr))));
+ }
+ }
+ for (i = 0; i < fdNumber; i++)
+ {
+ if (errbind[i] >= 0)
+ {
+ errconn[i] =
+ _CONNECT(c_socketfd[i], (struct sockaddr *) &g_dest,
+ sizeof(g_dest));
+ if (errconn[i] < 0)
+ {
+ printf("client %d Connect Failed %s\n", i, strerror(errno));
+ _CLOSE(c_socketfd[i]);
+ c_socketfd[i] = -1;
+ continue;
+ }
+ else
+ {
+ printf("client %d Connect Success port:%d, IP:%s\n", i,
+ ntohs(g_dest.sin_port),
+ inet_ntoa(*
+ ((struct in_addr *)
+ &(g_dest.sin_addr.s_addr))));
+ }
+ }
+ }
+
+ sleep(1);
+
+ clock_gettime(CLOCK_MONOTONIC, &startTime);
+ clock_gettime(CLOCK_MONOTONIC, &countStart);
+
+ int recvLen2, recvLen;
+ for (t = 0; t < times; t++)
+ {
+ for (i = 0; i < fdNumber; i++)
+ {
+ if (c_socketfd[i] < 0)
+ {
+ continue;
+ }
+ do
+ {
+ sendLen = _SEND(c_socketfd[i], send_buf, msg_length, 0);
+ }
+ while (sendLen <= 0);
+ send_count[i]++;
+ recvLen = 0;
+ do
+ {
+ recvLen2 =
+ recv(c_socketfd[i], recv_buf + recvLen,
+ msg_length - recvLen, 0);
+ if (recvLen2 <= 0)
+ {
+ continue;
+ }
+ else if (recvLen2 == msg_length - recvLen)
+ {
+ recvLen = 0;
+ break;
+ }
+ else if (recvLen2 < msg_length - recvLen)
+ {
+ recvLen += recvLen2;
+ }
+ }
+ while (1);
+ }
+
+ if (0 != sleepTime)
+ {
+ if ((t % sleepCnt) == 0)
+ {
+ usleep(sleepTime);
+ }
+ }
+
+ if ((send_count[0] % unitPrint) == 0 && send_count[0] > 0)
+ {
+ clock_gettime(CLOCK_MONOTONIC, &countEnd);
+
+ pps_time =
+ (countEnd.tv_sec - countStart.tv_sec) * 1000000000 +
+ countEnd.tv_nsec - countStart.tv_nsec;
+ pps = ((float) 1000000000 / pps_time) * unitPrint * fdNumber;
+ if ((flagPrint != 0))
+ {
+ printf(" sendcount %d, time: %ld ns\n",
+ send_count[0] * fdNumber, pps_time);
+ }
+ printf("sendcount %d , pps=%d\n", send_count[0] * fdNumber, pps);
+ clock_gettime(CLOCK_MONOTONIC, &countStart);
+ }
+ }
+
+ clock_gettime(CLOCK_MONOTONIC, &endTime);
+
+ for (i = 0; i < fdNumber; i++)
+ {
+ printf("client %d send %d , sendtime :%ld s %ld ns\n", i,
+ send_count[i], endTime.tv_sec - startTime.tv_sec,
+ endTime.tv_nsec - startTime.tv_nsec);
+ }
+
+ for (i = 0; i < fdNumber; i++)
+ {
+ printf("client %d close!\n", i);
+ if (c_socketfd[i] > 0)
+ _CLOSE(c_socketfd[i]);
+ }
+
+ pthread_exit(NULL);
+}
+
+void main(int argc, char *argv[])
+{
+ socklen_t addrlen = sizeof(struct sockaddr);
+ int err = 0, result = 0, ret = 0;
+ int i = 0, j = 0, optval = 0, z = 0, x, listenfd;
+ cpu_set_t mask;
+
+ setArgsDefault();
+ ret = process_arg(argc, argv);
+ if (ret != 1)
+ {
+ printf("The param error\n");
+ return;
+ }
+
+ pthread_t client_thread_id;
+
+ if (pthread_create
+ (&client_thread_id, NULL, (void *) (&process_client), NULL) == -1)
+ {
+ printf("create client thread fail\n");
+ return;
+ }
+
+ printf("create client thread success\n");
+
+ if (client_thread_id != 0)
+ {
+ printf("Client Thread join\n");
+ pthread_join(client_thread_id, NULL);
+ }
+
+ return;
+}
diff --git a/testcode/app_example/perf-test/multi_tcp_epoll_app_Ser.c b/testcode/app_example/perf-test/multi_tcp_epoll_app_Ser.c
new file mode 100644
index 0000000..b37a9c3
--- /dev/null
+++ b/testcode/app_example/perf-test/multi_tcp_epoll_app_Ser.c
@@ -0,0 +1,627 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#define _GNU_SOURCE
+#include <sys/socket.h>
+#include <fcntl.h>
+#include <memory.h>
+#include <signal.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <netinet/in.h>
+#include <time.h>
+#include <linux/tcp.h>
+#include <sched.h>
+#include <pthread.h>
+#include <arpa/inet.h>
+#include <sys/epoll.h>
+#include <errno.h>
+
+#define _BIND bind
+#define _LISTEN listen
+#define _SOCKET socket
+#define _ACCEPT accept
+#define _SEND send
+#define _RECV recv
+#define _CLOSE close
+#define _CONNECT connect
+#define _PROTOCOL IPPROTO_TCP
+
+#define MAX_TEST_TIME 1000
+#define MSG_LENGTH 256
+#define CORE_NUM 8
+#define START_CPU_ID 2
+#define MAX_CONN_LIMIT 256
+#define MAX_PORT_NUM 65535
+//1:A-B ;0:A-B-A
+#define SEND_RECV_MODE 1
+#define MAX_EVENTS 1000
+#define Default_PortID 12345
+#define Default_SleepCnt 10000
+#define Default_SleepTime 1000000
+#define Flag_Print 1
+#define Fd_Number 1
+
+static struct sockaddr_in g_dest;
+static struct sockaddr_in g_src;
+static struct sockaddr_in g_recv;
+
+int times = MAX_TEST_TIME;
+int msg_length = MSG_LENGTH;
+int coreNum = CORE_NUM;
+int startCPUId = START_CPU_ID;
+int connectNum = MAX_CONN_LIMIT;
+int msgMode = SEND_RECV_MODE;
+int sleepCnt = Default_SleepCnt;
+int sleepTime = Default_SleepTime; //us
+int fdNumber = Fd_Number;
+int flagPrint = Flag_Print;
+int unitPrint = 0;
+int waitTime = 0;
+
+int srcPort = Default_PortID;
+int destPort = 0;
+int recvPort = 0;
+char sendarr[256] = "";
+char recvarr[256] = "";
+char destarr[256] = "";
+
+static void setArgsDefault()
+{
+
+ memset(&g_dest, 0, sizeof(g_dest));
+ g_dest.sin_family = AF_INET;
+ g_dest.sin_addr.s_addr = inet_addr("127.0.0.1");
+ g_dest.sin_port = htons(12345);
+ bzero(&(g_dest.sin_zero), 8);
+
+ memset(&g_src, 0, sizeof(g_src));
+ g_src.sin_family = AF_INET;
+ g_src.sin_addr.s_addr = inet_addr("0.0.0.0");
+ g_src.sin_port = htons(7895);
+ bzero(&(g_src.sin_zero), 8);
+
+ memset(&g_recv, 0, sizeof(g_recv));
+ g_recv.sin_family = AF_INET;
+ g_recv.sin_addr.s_addr = inet_addr("0.0.0.0");
+ g_recv.sin_port = htons(7895);
+ bzero(&(g_recv.sin_zero), 8);
+
+}
+
+static int process_arg(int argc, char *argv[])
+{
+ int opt = 0;
+ int error = 0;
+ const char *optstring = "p:d:s:a:l:t:e:i:f:r:n:w:u:x:";
+ int rw_mark = 0;
+
+ if (argc < 4)
+ {
+ printf
+ ("Param info :-p dest_portid; -d dest_serverIP; -a src_portid; -s src_clientIP; -l msg_length; \n");
+ printf
+ ("\t-t MAX_TEST_TIME; -i msg_interval ; -f client fd number ; -r receive port; -n connectNum(one server vs n client)\n");
+ return 0;
+ }
+ while ((opt = getopt(argc, argv, optstring)) != -1)
+ {
+ switch (opt)
+ {
+ case 'p':
+ destPort = atoi(optarg);
+ g_dest.sin_port = htons(atoi(optarg));
+ break;
+ case 'd':
+ stpcpy(destarr, optarg);
+ g_dest.sin_addr.s_addr = inet_addr(optarg);
+ break;
+ case 's':
+ stpcpy(sendarr, optarg);
+ g_src.sin_addr.s_addr = inet_addr(optarg);
+ g_recv.sin_addr.s_addr = inet_addr(optarg);
+ break;
+ case 'a':
+ //g_src.sin_port = htons(atoi(optarg));
+ srcPort = atoi(optarg);
+ break;
+ case 'l':
+ msg_length = atoi(optarg);
+ break;
+ case 't':
+ times = atoi(optarg);
+ break;
+ case 'e':
+ sleepCnt = atoi(optarg);
+ break;
+ case 'i':
+ sleepTime = atoi(optarg);
+ break;
+ case 'f':
+ fdNumber = atoi(optarg);
+ break;
+ case 'r':
+ recvPort = atoi(optarg);
+ g_recv.sin_port = htons(atoi(optarg));
+ break;
+ case 'n':
+ connectNum = atoi(optarg);
+ break;
+ case 'w':
+ waitTime = atoi(optarg);
+ break;
+ case 'u':
+ unitPrint = atoi(optarg);
+ break;
+ case 'x':
+ flagPrint = atoi(optarg);
+ break;
+
+ }
+ }
+ return 1;
+}
+
+void process_client(void)
+{
+ int sendLen = 0;
+ int i = 0, t = 0, p = 0, optval = 0, ret = 0;
+ char send_buf[1000] = "";
+ int c_socketfd[100] = { 0 };
+ int errbind[1000] = { 0 };
+ int errconn[1000] = { 0 };
+
+ int send_count[1000] = { 0 };
+ int pps = 0;
+ long pps_time = 0;
+
+ struct timespec startTime, endTime;
+ struct timespec countStart;
+ struct timespec countEnd;
+ memset(&countStart, 0, sizeof(countStart));
+ memset(&countEnd, 0, sizeof(countEnd));
+
+ for (i = 0; i < fdNumber; i++)
+ {
+ c_socketfd[i] = _SOCKET(PF_INET, SOCK_STREAM, _PROTOCOL);
+ if (0 > c_socketfd[i])
+ {
+ printf("client %d failed,err %d\n", i, errno);
+ }
+ else
+ {
+ printf("client %d created success\n", i);
+ }
+ }
+
+ for (i = 0; i < fdNumber; i++)
+ {
+ optval = 1;
+ ret =
+ setsockopt(c_socketfd[i], SOL_SOCKET, SO_REUSEADDR,
+ (void *) &optval, sizeof(optval));
+ if (ret == -1)
+ {
+ printf("Couldn't setsockopt(SO_REUSEADDR)\n");
+ break;
+ }
+ }
+
+ for (i = 0; i < fdNumber; i++)
+ {
+ g_src.sin_port = htons(srcPort + i);
+ errbind[i] =
+ _BIND(c_socketfd[i], (struct sockaddr *) &g_src, sizeof(g_src));
+ if (errbind[i] < 0)
+ {
+ printf("client %d bind Failed %d\n", i, errno);
+ _CLOSE(c_socketfd[i]);
+ c_socketfd[i] = -1;
+ continue;
+ }
+ else
+ {
+ printf("client %d bind Success port:%d IP:%s\n", i,
+ ntohs(g_src.sin_port),
+ inet_ntoa(*((struct in_addr *) &(g_src.sin_addr.s_addr))));
+ }
+ }
+ for (i = 0; i < fdNumber; i++)
+ {
+ if (errbind[i] >= 0)
+ {
+ errconn[i] =
+ _CONNECT(c_socketfd[i], (struct sockaddr *) &g_dest,
+ sizeof(g_dest));
+ if (errconn[i] < 0)
+ {
+ printf("client %d Connect Failed %d\n", i, errno);
+ _CLOSE(c_socketfd[i]);
+ c_socketfd[i] = -1;
+ continue;
+ }
+ else
+ {
+ printf("client %d Connect Success port:%d, IP:%s\n", i,
+ ntohs(g_dest.sin_port),
+ inet_ntoa(*
+ ((struct in_addr *)
+ &(g_dest.sin_addr.s_addr))));
+ }
+ }
+ }
+
+ sleep(1);
+
+ clock_gettime(CLOCK_MONOTONIC, &startTime);
+ clock_gettime(CLOCK_MONOTONIC, &countStart);
+
+ for (t = 0; t < times; t++)
+ {
+ for (i = 0; i < fdNumber; i++)
+ {
+ if (c_socketfd[i] < 0)
+ {
+ continue;
+ }
+ do
+ {
+ sendLen = _SEND(c_socketfd[i], send_buf, msg_length, 0);
+ }
+ while (sendLen <= 0);
+ send_count[i]++;
+ }
+
+ if (0 != sleepTime)
+ {
+ if ((t % sleepCnt) == 0)
+ {
+ usleep(sleepTime);
+ }
+ }
+
+ if ((send_count[0] % unitPrint) == 0)
+ {
+ clock_gettime(CLOCK_MONOTONIC, &countEnd);
+
+ pps_time =
+ (countEnd.tv_sec - countStart.tv_sec) * 1000000000 +
+ countEnd.tv_nsec - countStart.tv_nsec;
+ pps = ((float) 1000000000 / pps_time) * unitPrint * fdNumber;
+ if ((flagPrint != 0))
+ {
+ printf(" sendcount %d, time: %ld ns\n",
+ send_count[0] * fdNumber, pps_time);
+ }
+ printf("sendcount %d , pps=%d\n", send_count[0] * fdNumber, pps);
+ clock_gettime(CLOCK_MONOTONIC, &countStart);
+ }
+
+ }
+
+ clock_gettime(CLOCK_MONOTONIC, &endTime);
+
+ for (i = 0; i < fdNumber; i++)
+ {
+ printf("client %d send %d , sendtime :%ld s %ld ns\n", i,
+ send_count[i], endTime.tv_sec - startTime.tv_sec,
+ endTime.tv_nsec - startTime.tv_nsec);
+ }
+
+ for (i = 0; i < fdNumber; i++)
+ {
+ printf("client %d close!\n", i);
+ if (c_socketfd[i] > 0)
+ _CLOSE(c_socketfd[i]);
+ }
+
+ pthread_exit(NULL);
+}
+
+/*
+ using this thread to do recv msg;
+*/
+void *process_server_msg_thread(void *pArgv)
+{
+ int recvLen = 0, recvLen2 = 0;
+ char send_buf[1000];
+ char recv_buf[1000];
+ int recv_count = 0;
+ long recv_ppstime = 0;
+ int recv_pps = 0;
+ int ret;
+ struct epoll_event event;
+
+ struct epoll_event eventList[MAX_EVENTS];
+
+ struct timespec recvStart;
+ struct timespec recvEnd;
+ memset(&recvStart, 0, sizeof(recvStart));
+ memset(&recvEnd, 0, sizeof(recvEnd));
+
+ pthread_detach(pthread_self());
+
+ int msgEpFd = epoll_create(100);
+ int msgFd = *(int *) pArgv;
+
+ event.events = EPOLLIN | EPOLLET;
+ event.data.fd = msgFd;
+ if (epoll_ctl(msgEpFd, EPOLL_CTL_ADD, msgFd, &event) < 0)
+ {
+ printf("epoll add fd[%d] to msgEpfd:[%d] failed\n", msgFd, msgEpFd);
+ close(msgEpFd);
+ close(msgFd);
+ return NULL;
+ }
+
+ clock_gettime(CLOCK_MONOTONIC, &recvStart);
+ while (1)
+ {
+ int timeout = -1;
+ int m;
+ int sock;
+ ret = epoll_wait(msgEpFd, eventList, MAX_EVENTS, timeout);
+ if (ret == 0)
+ continue;
+
+ for (m = 0; m < ret; m++)
+ {
+ if ((eventList[m].events & EPOLLERR)
+ || (eventList[m].events & EPOLLHUP)
+ || !(eventList[m].events & EPOLLIN))
+ {
+ printf("fd %d epoll error event:%d\n", eventList[m].data.fd,
+ eventList[m].events);
+ close(eventList[m].data.fd);
+ continue;
+ }
+ else
+ {
+ recvLen = 0;
+ recvLen2 = 0;
+ sock = eventList[m].data.fd;
+
+ do
+ {
+ recvLen2 =
+ recv(sock, recv_buf + recvLen, msg_length - recvLen,
+ 0);
+ if (recvLen2 <= 0)
+ {
+ break;
+ }
+ else if (recvLen2 == msg_length - recvLen)
+ {
+ recvLen = 0;
+ recv_count++;
+ if (msg_length != send(sock, send_buf, msg_length, 0))
+ {
+ printf("send failed!====, need exit\n");
+ }
+ }
+ else if (recvLen2 < msg_length - recvLen)
+ {
+ recvLen += recvLen2;
+ }
+ if ((flagPrint != 0) && ((recv_count % unitPrint) == 0))
+ {
+ clock_gettime(CLOCK_MONOTONIC, &recvEnd);
+ recv_ppstime =
+ (recvEnd.tv_sec - recvStart.tv_sec) * 1000000000 +
+ recvEnd.tv_nsec - recvStart.tv_nsec;
+ recv_pps =
+ ((float) 1000000000 / recv_ppstime) * unitPrint;
+ printf("receive count:%d, receive time: %ld ns\n",
+ recv_count, recv_ppstime);
+ printf("receive pps = %d\n", recv_pps);
+ clock_gettime(CLOCK_MONOTONIC, &recvStart);
+ }
+ }
+ while (1);
+ }
+
+ }
+
+ if (recv_count == times)
+ {
+ break;
+ }
+ }
+ close(msgFd);
+ close(msgEpFd);
+}
+
+/*
+ using this thread to do accept connect
+*/
+void *process_server_accept_thread(void *pArgv)
+{
+ int listenFd = 0;
+ int x, optval, ret = 0;
+ int acpt_socketfd[1000] = { 0 };
+
+ listenFd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if (0 > listenFd)
+ {
+ printf("ERROR:socket failed,errno [%d]\n", errno);
+ return NULL;
+ }
+ else
+ {
+ printf("INFO:Create listen socket Success, listenFd[%d]\n", listenFd);
+ }
+
+ if (0 > fcntl(listenFd, F_SETFL, O_NONBLOCK))
+ {
+ printf("ERROR:fcntl failed. fd[%d], errno[%d]/n", listenFd, errno);
+ close(listenFd);
+ }
+
+ optval = 1;
+ ret =
+ setsockopt(listenFd, SOL_SOCKET, SO_REUSEADDR, (void *) &optval,
+ sizeof(optval));
+ if (ret == -1)
+ {
+ printf("ERROR:setsockopt failed. fd[%d], errno[%d]\n", listenFd,
+ errno);
+ close(listenFd);
+ return NULL;
+ }
+
+ if (0 !=
+ bind(listenFd, (struct sockaddr *) &g_recv, sizeof(struct sockaddr)))
+ {
+ printf("ERROR:bind failed. fd[%d] errno [%d]\n", listenFd, errno);
+ printf("INFO:Bind Failed, port %d IP:%s\n", ntohs(g_recv.sin_port),
+ inet_ntoa(*((struct in_addr *) &(g_recv.sin_addr.s_addr))));
+ close(listenFd);
+ //return NULL;
+ exit(-1);
+ }
+ else
+ {
+ printf("INFO:Bind Success, port %d IP:%s\n", ntohs(g_recv.sin_port),
+ inet_ntoa(*((struct in_addr *) &(g_recv.sin_addr.s_addr))));
+ }
+
+ if (0 != listen(listenFd, 100))
+ {
+ printf("server socket listen failed. err %d\n", errno);
+ close(listenFd);
+ return NULL;
+ }
+ printf("Listen Success\n");
+
+ int accEpFd;
+ struct epoll_event eventList[100];
+ accEpFd = epoll_create(100);
+ struct epoll_event event;
+ event.events = EPOLLIN | EPOLLET;
+ event.data.fd = listenFd;
+
+ if (epoll_ctl(accEpFd, EPOLL_CTL_ADD, listenFd, &event) < 0)
+ {
+ printf("epoll_ctl add [%d] to epfd:%d failed\n", listenFd, accEpFd);
+ exit(-1);
+ }
+
+ int timeout = -1;
+ int accpedNum = 0;
+ while (accpedNum < connectNum)
+ {
+ ret = epoll_wait(accEpFd, eventList, connectNum, timeout);
+
+ if (ret < 0)
+ {
+ printf("accept_thread epoll_wait error, epfd[%d], errno[%d]\n",
+ accEpFd, errno);
+ continue;
+ }
+ else if (ret == 0)
+ continue;
+
+ /*loop done ever Event */
+ for (x = 0; x < ret; x++)
+ {
+ printf("event:%d; ret:%d\n", eventList[x].events, ret);
+ if ((eventList[x].events & EPOLLERR)
+ || !(eventList[x].events & EPOLLIN))
+ {
+ printf("epoll fd %d error\n", eventList[x].data.fd);
+ close(eventList[x].data.fd);
+ continue;
+ }
+
+ while (1)
+ {
+ acpt_socketfd[accpedNum] =
+ accept4(listenFd, NULL, NULL, SOCK_NONBLOCK);
+ if (acpt_socketfd[accpedNum] < 0)
+ {
+ printf("no more connect\n");
+ break;
+ }
+ /*add new accptFd to MsgEpFD */
+ pthread_t ser_rcv_thread_id;
+ if (pthread_create
+ (&ser_rcv_thread_id, NULL, process_server_msg_thread,
+ (void *) &acpt_socketfd[accpedNum]) == -1)
+ {
+ printf("create process_server_msg_thread fail\n");
+ break;
+ }
+
+ printf("accept cnt [%d], cur accept fd [%d]\n", accpedNum,
+ acpt_socketfd[accpedNum]);
+ accpedNum++;
+ }
+ }
+ }
+
+ close(listenFd);
+ close(accEpFd);
+
+ while (1)
+ {
+ sleep(10);
+ }
+
+ pthread_exit(NULL);
+}
+
+void main(int argc, char *argv[])
+{
+ socklen_t addrlen = sizeof(struct sockaddr);
+ int err = 0, result = 0, ret = 0;
+ int i = 0, j = 0, optval = 0, z = 0, x, listenfd;
+ cpu_set_t mask;
+
+ setArgsDefault();
+ ret = process_arg(argc, argv);
+ if (ret != 1)
+ {
+ printf("The param error\n");
+ return;
+ }
+
+ pthread_t server_thread_id;
+
+ if (pthread_create
+ (&server_thread_id, NULL, process_server_accept_thread, NULL) == -1)
+ {
+ printf("create process_server_accept_thread fail\n");
+ return;
+ }
+
+ printf("create process_server_accept_thread success\n");
+
+ if (server_thread_id != 0)
+ {
+ printf("Server Thread join\n");
+ pthread_join(server_thread_id, NULL);
+ }
+
+ while (1)
+ {
+ sleep(10);
+ }
+
+ return;
+}
diff --git a/testcode/app_example/perf-test/multi_tcp_select_app_Ser.c b/testcode/app_example/perf-test/multi_tcp_select_app_Ser.c
new file mode 100644
index 0000000..56b9c5d
--- /dev/null
+++ b/testcode/app_example/perf-test/multi_tcp_select_app_Ser.c
@@ -0,0 +1,431 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* 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.
+*/
+
+#define _GNU_SOURCE
+#include <sys/socket.h>
+#include <fcntl.h>
+#include <memory.h>
+#include <signal.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <netinet/in.h>
+#include <time.h>
+#include <linux/tcp.h>
+#include <sched.h>
+#include <pthread.h>
+#include <arpa/inet.h>
+#include <sys/epoll.h>
+#include <errno.h>
+
+#define _BIND bind
+#define _LISTEN listen
+#define _SOCKET socket
+#define _ACCEPT accept
+#define _SEND send
+#define _RECV recv
+#define _CLOSE close
+#define _CONNECT connect
+#define _PROTOCOL IPPROTO_TCP
+
+#define MAX_TEST_TIME 1000
+#define MSG_LENGTH 256
+#define CORE_NUM 8
+#define START_CPU_ID 2
+#define MAX_CONN_LIMIT 256
+#define MAX_PORT_NUM 65535
+//1:A-B ;0:A-B-A
+#define SEND_RECV_MODE 1
+#define MAX_EVENTS 1000
+#define Default_PortID 12345
+#define Default_SleepCnt 10000
+#define Default_SleepTime 1000000
+#define Flag_Print 1
+#define Fd_Number 1
+
+static struct sockaddr_in g_dest;
+static struct sockaddr_in g_src;
+static struct sockaddr_in g_recv;
+
+int times = MAX_TEST_TIME;
+int msg_length = MSG_LENGTH;
+int coreNum = CORE_NUM;
+int startCPUId = START_CPU_ID;
+int connectNum = MAX_CONN_LIMIT;
+int msgMode = SEND_RECV_MODE;
+int sleepCnt = Default_SleepCnt;
+int sleepTime = Default_SleepTime; //us
+int fdNumber = Fd_Number;
+int flagPrint = Flag_Print;
+int unitPrint = 0;
+int waitTime = 0;
+
+int srcPort = Default_PortID;
+int destPort = 0;
+int recvPort = 0;
+char sendarr[256] = "";
+char recvarr[256] = "";
+char destarr[256] = "";
+
+static void setArgsDefault()
+{
+
+ memset(&g_dest, 0, sizeof(g_dest));
+ g_dest.sin_family = AF_INET;
+ g_dest.sin_addr.s_addr = inet_addr("127.0.0.1");
+ g_dest.sin_port = htons(12345);
+ bzero(&(g_dest.sin_zero), 8);
+
+ memset(&g_src, 0, sizeof(g_src));
+ g_src.sin_family = AF_INET;
+ g_src.sin_addr.s_addr = inet_addr("0.0.0.0");
+ g_src.sin_port = htons(7895);
+ bzero(&(g_src.sin_zero), 8);
+
+ memset(&g_recv, 0, sizeof(g_recv));
+ g_recv.sin_family = AF_INET;
+ g_recv.sin_addr.s_addr = inet_addr("0.0.0.0");
+ g_recv.sin_port = htons(7895);
+ bzero(&(g_recv.sin_zero), 8);
+
+}
+
+static int process_arg(int argc, char *argv[])
+{
+ int opt = 0;
+ int error = 0;
+ const char *optstring = "p:d:s:a:l:t:e:i:f:r:n:w:u:x:";
+ int rw_mark = 0;
+
+ if (argc < 4)
+ {
+ printf
+ ("Param info :-p dest_portid; -d dest_serverIP; -a src_portid; -s src_clientIP; -l msg_length; \n");
+ printf
+ ("\t-t MAX_TEST_TIME; -i msg_interval ; -f client fd number ; -r receive port; -n connectNum(one server vs n client)\n");
+ return 0;
+ }
+ while ((opt = getopt(argc, argv, optstring)) != -1)
+ {
+ switch (opt)
+ {
+ case 'p':
+ destPort = atoi(optarg);
+ g_dest.sin_port = htons(atoi(optarg));
+ break;
+ case 'd':
+ stpcpy(destarr, optarg);
+ g_dest.sin_addr.s_addr = inet_addr(optarg);
+ break;
+ case 's':
+ stpcpy(sendarr, optarg);
+ g_src.sin_addr.s_addr = inet_addr(optarg);
+ g_recv.sin_addr.s_addr = inet_addr(optarg);
+ break;
+ case 'a':
+ //g_src.sin_port = htons(atoi(optarg));
+ srcPort = atoi(optarg);
+ break;
+ case 'l':
+ msg_length = atoi(optarg);
+ break;
+ case 't':
+ times = atoi(optarg);
+ break;
+ case 'e':
+ sleepCnt = atoi(optarg);
+ break;
+ case 'i':
+ sleepTime = atoi(optarg);
+ break;
+ case 'f':
+ fdNumber = atoi(optarg);
+ break;
+ case 'r':
+ recvPort = atoi(optarg);
+ g_recv.sin_port = htons(atoi(optarg));
+ break;
+ case 'n':
+ connectNum = atoi(optarg);
+ break;
+ case 'w':
+ waitTime = atoi(optarg);
+ break;
+ case 'u':
+ unitPrint = atoi(optarg);
+ break;
+ case 'x':
+ flagPrint = atoi(optarg);
+ break;
+
+ }
+ }
+ return 1;
+}
+
+/*
+ using this thread to do recv msg;
+*/
+void *process_server_msg_thread(void *pArgv)
+{
+ int recvLen = 0, recvLen2 = 0;
+ char send_buf[1000];
+ char recv_buf[1000];
+ int recv_count = 0;
+ long recv_ppstime = 0;
+ int recv_pps = 0;
+ int ret;
+ struct timeval timeout;
+ fd_set rfds;
+ int maxfd;
+
+ struct timespec recvStart;
+ struct timespec recvEnd;
+ memset(&recvStart, 0, sizeof(recvStart));
+ memset(&recvEnd, 0, sizeof(recvEnd));
+
+ pthread_detach(pthread_self());
+
+ int msgFd = *(int *) pArgv;
+
+ clock_gettime(CLOCK_MONOTONIC, &recvStart);
+ while (1)
+ {
+ FD_ZERO(&rfds);
+ FD_SET(msgFd, &rfds);
+ maxfd = msgFd + 1;
+ timeout.tv_sec = 10;
+ timeout.tv_usec = 0;
+ ret = select(maxfd, &rfds, NULL, NULL, &timeout);
+
+ if (ret <= 0)
+ {
+ continue;
+ }
+
+ if (FD_ISSET(msgFd, &rfds) == 0)
+ {
+ continue;
+ }
+
+ recvLen = 0;
+ recvLen2 = 0;
+
+ do
+ {
+ recvLen2 =
+ recv(msgFd, recv_buf + recvLen, msg_length - recvLen, 0);
+ if (recvLen2 <= 0)
+ {
+ break;
+ }
+ else if (recvLen2 == msg_length - recvLen)
+ {
+ recvLen = 0;
+ recv_count++;
+ if (msg_length != send(msgFd, send_buf, msg_length, 0))
+ {
+ printf("send failed!====, need exit\n");
+ }
+ }
+ else if (recvLen2 < msg_length - recvLen)
+ {
+ recvLen += recvLen2;
+ }
+ if ((flagPrint != 0) && ((recv_count % unitPrint) == 0))
+ {
+ clock_gettime(CLOCK_MONOTONIC, &recvEnd);
+ recv_ppstime =
+ (recvEnd.tv_sec - recvStart.tv_sec) * 1000000000 +
+ recvEnd.tv_nsec - recvStart.tv_nsec;
+ recv_pps = ((float) 1000000000 / recv_ppstime) * unitPrint;
+ printf("receive count:%d, receive time: %ld ns\n",
+ recv_count, recv_ppstime);
+ printf("receive pps = %d\n", recv_pps);
+ clock_gettime(CLOCK_MONOTONIC, &recvStart);
+ }
+ }
+ while (1);
+
+ if (recv_count == times)
+ {
+ break;
+ }
+ }
+ close(msgFd);
+}
+
+/*
+ using this thread to do accept connect
+*/
+void *process_server_accept_thread(void *pArgv)
+{
+ int listenFd = 0;
+ int x, optval, ret, m = 0;
+ int acpt_socketfd[1000] = { 0 };
+ struct timeval timeout;
+ fd_set rfds;
+ int maxfd;
+
+ listenFd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if (0 > listenFd)
+ {
+ printf("ERROR:socket failed,errno [%d]\n", errno);
+ return NULL;
+ }
+ else
+ {
+ printf("INFO:Create listen socket Success, listenFd[%d]\n", listenFd);
+ }
+
+ if (0 > fcntl(listenFd, F_SETFL, O_NONBLOCK))
+ {
+ printf("ERROR:fcntl failed. fd[%d], errno[%d]/n", listenFd, errno);
+ close(listenFd);
+ }
+
+ optval = 1;
+ ret =
+ setsockopt(listenFd, SOL_SOCKET, SO_REUSEADDR, (void *) &optval,
+ sizeof(optval));
+ if (ret == -1)
+ {
+ printf("ERROR:setsockopt failed. fd[%d], errno[%d]\n", listenFd,
+ errno);
+ close(listenFd);
+ return NULL;
+ }
+
+ if (0 !=
+ bind(listenFd, (struct sockaddr *) &g_recv, sizeof(struct sockaddr)))
+ {
+ printf("ERROR:bind failed. fd[%d] errno [%d]\n", listenFd, errno);
+ printf("INFO:Bind Failed, port %d IP:%s\n", ntohs(g_recv.sin_port),
+ inet_ntoa(*((struct in_addr *) &(g_recv.sin_addr.s_addr))));
+ close(listenFd);
+ //return NULL;
+ exit(-1);
+ }
+ else
+ {
+ printf("INFO:Bind Success, port %d IP:%s\n", ntohs(g_recv.sin_port),
+ inet_ntoa(*((struct in_addr *) &(g_recv.sin_addr.s_addr))));
+ }
+
+ if (0 != listen(listenFd, 100))
+ {
+ printf("server socket listen failed. err %d\n", errno);
+ close(listenFd);
+ return NULL;
+ }
+ printf("Listen Success\n");
+
+ int accpedNum = 0;
+ while (accpedNum < connectNum)
+ {
+ FD_ZERO(&rfds);
+ FD_SET(listenFd, &rfds);
+ maxfd = listenFd + 1;
+ timeout.tv_sec = 10;
+ timeout.tv_usec = 0;
+ ret = select(maxfd, &rfds, NULL, NULL, &timeout);
+
+ if (ret <= 0)
+ {
+ continue;
+ }
+
+ if (FD_ISSET(listenFd, &rfds) == 0)
+ {
+ continue;
+ }
+
+ while (1)
+ {
+ acpt_socketfd[accpedNum] =
+ accept4(listenFd, NULL, NULL, SOCK_NONBLOCK);
+ if (acpt_socketfd[accpedNum] < 0)
+ {
+ printf("no more connect\n");
+ break;
+ }
+ /*add new accptFd to MsgEpFD */
+ pthread_t ser_rcv_thread_id;
+ if (pthread_create
+ (&ser_rcv_thread_id, NULL, process_server_msg_thread,
+ (void *) &acpt_socketfd[accpedNum]) == -1)
+ {
+ printf("create process_server_msg_thread fail\n");
+ break;
+ }
+
+ printf("accept cnt [%d], cur accept fd [%d]\n", accpedNum,
+ acpt_socketfd[accpedNum]);
+ accpedNum++;
+ }
+ }
+
+ close(listenFd);
+
+ while (1)
+ {
+ sleep(10);
+ }
+
+ pthread_exit(NULL);
+}
+
+void main(int argc, char *argv[])
+{
+ socklen_t addrlen = sizeof(struct sockaddr);
+ int err = 0, result = 0, ret = 0;
+ int i = 0, j = 0, optval = 0, z = 0, x, listenfd;
+ cpu_set_t mask;
+
+ setArgsDefault();
+ ret = process_arg(argc, argv);
+ if (ret != 1)
+ {
+ printf("The param error\n");
+ return;
+ }
+
+ pthread_t server_thread_id;
+
+ if (pthread_create
+ (&server_thread_id, NULL, process_server_accept_thread, NULL) == -1)
+ {
+ printf("create process_server_accept_thread fail\n");
+ return;
+ }
+
+ printf("create process_server_accept_thread success\n");
+
+ if (server_thread_id != 0)
+ {
+ printf("Server Thread join\n");
+ pthread_join(server_thread_id, NULL);
+ }
+
+ while (1)
+ {
+ sleep(10);
+ }
+
+ return;
+}
diff --git a/testcode/app_example/rd_config.json b/testcode/app_example/rd_config.json
new file mode 100644
index 0000000..26abef6
--- /dev/null
+++ b/testcode/app_example/rd_config.json
@@ -0,0 +1,14 @@
+{
+ "modules": [
+ {
+ "name": "kernel",
+ "ip_route": [
+ "127.0.0.1/24"
+ ],
+ "type_route": [
+ ],
+ "protocol_route": [
+ ]
+ }
+ ]
+}
diff --git a/thirdparty/glog/glog-0.3.4/AUTHORS b/thirdparty/glog/glog-0.3.4/AUTHORS
deleted file mode 100644
index ee92be8..0000000
--- a/thirdparty/glog/glog-0.3.4/AUTHORS
+++ /dev/null
@@ -1,2 +0,0 @@
-opensource@google.com
-
diff --git a/thirdparty/glog/glog-0.3.4/.gitignore b/thirdparty/glog/glog-0.3.5/.gitignore
index cf890f6..cf890f6 100644
--- a/thirdparty/glog/glog-0.3.4/.gitignore
+++ b/thirdparty/glog/glog-0.3.5/.gitignore
diff --git a/thirdparty/glog/glog-0.3.5/AUTHORS b/thirdparty/glog/glog-0.3.5/AUTHORS
new file mode 100644
index 0000000..8e65410
--- /dev/null
+++ b/thirdparty/glog/glog-0.3.5/AUTHORS
@@ -0,0 +1,22 @@
+# This is the official list of glog authors for copyright purposes.
+# This file is distinct from the CONTRIBUTORS files.
+# See the latter for an explanation.
+#
+# Names should be added to this file as:
+# Name or Organization <email address>
+# The email address is not required for organizations.
+#
+# Please keep the list sorted.
+
+Abhishek Dasgupta <abhi2743@gmail.com>
+Abhishek Parmar <abhishek@orng.net>
+Andy Ying <andy@trailofbits.com>
+Brian Silverman <bsilver16384@gmail.com>
+Google Inc.
+Guillaume Dumont <dumont.guillaume@gmail.com>
+Michael Tanner <michael@tannertaxpro.com>
+MiniLight <MiniLightAR@Gmail.com>
+romange <romange@users.noreply.github.com>
+Sergiu Deitsch <sergiu.deitsch@gmail.com>
+tbennun <tbennun@gmail.com>
+Teddy Reed <teddy@prosauce.org>
diff --git a/thirdparty/glog/glog-0.3.5/CMakeLists.txt b/thirdparty/glog/glog-0.3.5/CMakeLists.txt
new file mode 100644
index 0000000..7415eab
--- /dev/null
+++ b/thirdparty/glog/glog-0.3.5/CMakeLists.txt
@@ -0,0 +1,583 @@
+cmake_minimum_required (VERSION 3.0)
+
+if (POLICY CMP0042)
+ cmake_policy (SET CMP0042 NEW)
+endif (POLICY CMP0042)
+
+if (POLICY CMP0063)
+ cmake_policy (SET CMP0063 NEW)
+endif (POLICY CMP0063)
+
+project (google-glog)
+
+enable_testing ()
+
+set (GLOG_MAJOR_VERSION 0)
+set (GLOG_MINOR_VERSION 3)
+set (GLOG_PATCH_VERSION 5)
+
+set (GLOG_VERSION
+ ${GLOG_MAJOR_VERSION}.${GLOG_MINOR_VERSION}.${GLOG_PATCH_VERSION})
+
+set (CPACK_PACKAGE_NAME glog)
+set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "")
+set (CPACK_PACKAGE_VERSION_MAJOR ${GLOG_MAJOR_VERSION})
+set (CPACK_PACKAGE_VERSION_MINOR ${GLOG_MINOR_VERSION})
+set (CPACK_PACKAGE_VERSION_PATCH ${GLOG_PATCH_VERSION})
+set (CPACK_PACKAGE_VERSION ${GLOG_VERSION})
+
+option (WITH_GFLAGS "Use gflags" ON)
+option (WITH_THREADS "Enable multithreading support" ON)
+
+list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
+
+include (CheckCSourceCompiles)
+include (CheckCXXCompilerFlag)
+include (CheckCXXSourceCompiles)
+include (CheckFunctionExists)
+include (CheckIncludeFile)
+include (CheckIncludeFileCXX)
+include (CheckLibraryExists)
+include (CheckStructHasMember)
+include (CheckSymbolExists)
+include (CheckTypeSize)
+include (CMakePackageConfigHelpers)
+include (CPack)
+include (CTest)
+include (DetermineGflagsNamespace)
+
+set (CMAKE_THREAD_PREFER_PTHREAD 1)
+
+if (WITH_GFLAGS)
+ find_package (gflags)
+
+ if (gflags_FOUND)
+ set (HAVE_LIB_GFLAGS 1)
+ determine_gflags_namespace (gflags_NAMESPACE)
+ endif (gflags_FOUND)
+endif (WITH_GFLAGS)
+
+if (WITH_THREADS)
+ find_package (Threads)
+endif (WITH_THREADS)
+
+check_include_file (dlfcn.h HAVE_DLFCN_H)
+check_include_file (execinfo.h HAVE_EXECINFO_H)
+check_include_file (glob.h HAVE_GLOB_H)
+check_include_file (inttypes.h HAVE_INTTYPES_H)
+check_include_file (libunwind.h HAVE_LIBUNWIND_H)
+check_include_file (memory.h HAVE_MEMORY_H)
+check_include_file (pwd.h HAVE_PWD_H)
+check_include_file (stdint.h HAVE_STDINT_H)
+check_include_file (stdlib.h HAVE_STDLIB_H)
+check_include_file (string.h HAVE_STRING_H)
+check_include_file (strings.h HAVE_STRINGS_H)
+check_include_file (sys/stat.h HAVE_SYS_STAT_H)
+check_include_file (sys/syscall.h HAVE_SYS_SYSCALL_H)
+check_include_file (sys/time.h HAVE_SYS_TIME_H)
+check_include_file (sys/types.h HAVE_SYS_TYPES_H)
+check_include_file (sys/utsname.h HAVE_SYS_UTSNAME_H)
+check_include_file (syscall.h HAVE_SYSCALL_H)
+check_include_file (syslog.h HAVE_SYSLOG_H)
+check_include_file (ucontext.h HAVE_UCONTEXT_H)
+check_include_file (unistd.h HAVE_UNISTD_H)
+check_include_file (unwind.h HAVE_UNWIND_H)
+
+check_include_file_cxx ("ext/hash_map" HAVE_EXT_HASH_MAP)
+check_include_file_cxx ("ext/hash_set" HAVE_EXT_HASH_SET)
+check_include_file_cxx ("ext/slist" HAVE_EXT_SLIST)
+check_include_file_cxx ("tr1/unordered_map" HAVE_TR1_UNORDERED_MAP)
+check_include_file_cxx ("tr1/unordered_set" HAVE_TR1_UNORDERED_SET)
+check_include_file_cxx ("unordered_map" HAVE_UNORDERED_MAP)
+check_include_file_cxx ("unordered_set" HAVE_UNORDERED_SET)
+
+check_type_size ("unsigned __int16" HAVE___UINT16)
+check_type_size (u_int16_t HAVE_U_INT16_T)
+check_type_size (uint16_t HAVE_UINT16_T)
+
+check_function_exists (dladdr HAVE_DLADDR)
+check_function_exists (fcntl HAVE_FCNTL)
+check_function_exists (pread HAVE_PREAD)
+check_function_exists (pwrite HAVE_PWRITE)
+check_function_exists (sigaction HAVE_SIGACTION)
+check_function_exists (sigaltstack HAVE_SIGALSTACK)
+
+# NOTE gcc does not fail if you pass a non-existent -Wno-* option as an
+# argument. However, it will happily fail if you pass the corresponding -W*
+# option. So, we check whether options that disable warnings exist by testing
+# the availability of the corresponding option that enables the warning. This
+# eliminates the need to check for compiler for several (mainly Clang) options.
+
+check_cxx_compiler_flag (-Wdeprecated HAVE_NO_DEPRECATED)
+check_cxx_compiler_flag (-Wunnamed-type-template-args
+ HAVE_NO_UNNAMED_TYPE_TEMPLATE_ARGS)
+
+# NOTE: Cannot use check_function_exists here since >=vc-14.0 can define
+# snprintf as an inline function
+check_symbol_exists (snprintf stdio.h HAVE_SNPRINTF)
+
+check_library_exists (unwind get_static_proc_name "" HAVE_LIB_UNWIND)
+
+find_library (UNWIND_LIBRARY NAMES unwind DOC "unwind library")
+mark_as_advanced (UNWIND_LIBRARY)
+
+check_c_source_compiles ("
+#include <stdlib.h>
+static void foo(void) __attribute__ ((unused));
+int main(void) { return 0; }
+" HAVE___ATTRIBUTE__)
+
+check_c_source_compiles ("
+#include <stdlib.h>
+static void foo(void) __attribute__ ((visibility(\"default\")));
+int main(void) { return 0; }
+" HAVE___ATTRIBUTE__VISIBILITY_DEFAULT)
+
+check_c_source_compiles ("
+#include <stdlib.h>
+static void foo(void) __attribute__ ((visibility(\"hidden\")));
+int main(void) { return 0; }
+" HAVE___ATTRIBUTE__VISIBILITY_HIDDEN)
+
+check_c_source_compiles ("
+int main(void) { if (__builtin_expect(0, 0)) return 1; return 0; }
+" HAVE___BUILTIN_EXPECT)
+
+check_c_source_compiles ("
+int main(void)
+{
+ int a; if (__sync_val_compare_and_swap(&a, 0, 1)) return 1; return 0;
+}
+" HAVE___SYNC_VAL_COMPARE_AND_SWAP)
+
+check_c_source_compiles ("
+#define _XOPEN_SOURCE 500
+#include <pthread.h>
+int main(void)
+{
+ pthread_rwlock_t l;
+ pthread_rwlock_init(&l, NULL);
+ pthread_rwlock_rdlock(&l);
+ return 0;
+}
+" HAVE_RWLOCK)
+
+check_c_source_compiles ("
+__declspec(selectany) int a;
+int main(void) { return 0; }
+" HAVE___DECLSPEC)
+
+check_cxx_source_compiles ("
+#include <vector>
+vector<int> t; int main() { }
+" STL_NO_NAMESPACE)
+
+check_cxx_source_compiles ("
+#include <vector>
+std::vector<int> t; int main() { }
+" STL_STD_NAMESPACE)
+
+check_cxx_source_compiles ("
+#include <iostream>
+std::ostream& operator<<(std::ostream&, struct s);
+using ::operator<<;
+int main() { }
+" HAVE_USING_OPERATOR)
+
+check_cxx_source_compiles ("
+namespace Outer { namespace Inner { int i = 0; }}
+using namespace Outer::Inner;;
+int main() { return i; }
+" HAVE_NAMESPACES)
+
+set (_PC_FIELDS
+ "gregs[REG_PC]"
+ "gregs[REG_EIP]"
+ "gregs[REG_RIP]"
+ "sc_ip"
+ "uc_regs->gregs[PT_NIP]"
+ "gregs[R15]"
+ "arm_pc"
+ "mc_eip"
+ "mc_rip"
+ "__gregs[REG_EIP]"
+ "__gregs[REG_RIP]"
+ "ss.eip"
+ "__ss.__eip"
+ "ss.rip"
+ "__ss.__rip"
+ "ss.srr0"
+ "__ss.__srr0"
+)
+
+set (_PC_HEADERS ucontext.h signal.h)
+
+if (HAVE_UCONTEXT_H AND NOT PC_FROM_UCONTEXT)
+ foreach (_PC_FIELD ${_PC_FIELDS})
+ foreach (_PC_HEADER ${_PC_HEADERS})
+ set (_TMP
+ ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/uctfield.c)
+ file (WRITE ${_TMP} "
+#define _GNU_SOURCE 1
+#include <${_PC_HEADER}>
+int main(void)
+{
+ ucontext_t u;
+ return u.${_PC_FIELD} == 0;
+}
+")
+ try_compile (HAVE_PC_FROM_UCONTEXT ${CMAKE_CURRENT_BINARY_DIR} ${_TMP}
+ COMPILE_DEFINITIONS _GNU_SOURCE=1)
+
+ if (HAVE_PC_FROM_UCONTEXT)
+ set (PC_FROM_UCONTEXT ${_PC_FIELD} CACHE)
+ endif (HAVE_PC_FROM_UCONTEXT)
+ endforeach (_PC_HEADER)
+ endforeach (_PC_FIELD)
+endif (HAVE_UCONTEXT_H AND NOT PC_FROM_UCONTEXT)
+
+if (STL_STD_NAMESPACE)
+ set (STL_NAMESPACE std)
+else (STL_STD_NAMESPACE)
+ set (STL_NAMESPACE "")
+endif (STL_STD_NAMESPACE)
+
+set (GOOGLE_NAMESPACE google)
+set (_START_GOOGLE_NAMESPACE_ "namespace ${GOOGLE_NAMESPACE} {")
+set (_END_GOOGLE_NAMESPACE_ "}")
+
+if (HAVE___UINT16)
+ set (ac_cv_have___uint16 1)
+else (HAVE___UINT16)
+ set (ac_cv_have___uint16 0)
+endif (HAVE___UINT16)
+
+if (HAVE_INTTYPES_H)
+ set (ac_cv_have_inttypes_h 1)
+else (HAVE_INTTYPES_H)
+ set (ac_cv_have_inttypes_h 0)
+endif (HAVE_INTTYPES_H)
+
+if (HAVE_LIB_GFLAGS)
+ set (ac_cv_have_libgflags 1)
+else (HAVE_LIB_GFLAGS)
+ set (ac_cv_have_libgflags 0)
+endif (HAVE_LIB_GFLAGS)
+
+if (HAVE_STDINT_H)
+ set (ac_cv_have_stdint_h 1)
+else (HAVE_STDINT_H)
+ set (ac_cv_have_stdint_h 0)
+endif (HAVE_STDINT_H)
+
+if (HAVE_SYS_TYPES_H)
+ set (ac_cv_have_systypes_h 1)
+else (HAVE_SYS_TYPES_H)
+ set (ac_cv_have_systypes_h 0)
+endif (HAVE_SYS_TYPES_H)
+
+if (HAVE_U_INT16_T)
+ set (ac_cv_have_u_int16_t 1)
+else (HAVE_U_INT16_T)
+ set (ac_cv_have_u_int16_t 0)
+endif (HAVE_U_INT16_T)
+
+if (HAVE_UINT16_T)
+ set (ac_cv_have_uint16_t 1)
+else (HAVE_UINT16_T)
+ set (ac_cv_have_uint16_t 0)
+endif (HAVE_UINT16_T)
+
+if (HAVE_UNISTD_H)
+ set (ac_cv_have_unistd_h 1)
+else (HAVE_UNISTD_H)
+ set (ac_cv_have_unistd_h 0)
+endif (HAVE_UNISTD_H)
+
+set (ac_google_namespace ${GOOGLE_NAMESPACE})
+set (ac_google_end_namespace ${_END_GOOGLE_NAMESPACE_})
+set (ac_google_start_namespace ${_START_GOOGLE_NAMESPACE_})
+
+if (HAVE___ATTRIBUTE__)
+ set (ac_cv___attribute___noreturn "__attribute__((noreturn))")
+ set (ac_cv___attribute___noinline "__attribute__((noinline))")
+elseif (HAVE___DECLSPEC)
+ set (ac_cv___attribute___noreturn "__declspec(noreturn)")
+ #set (ac_cv___attribute___noinline "__declspec(noinline)")
+endif (HAVE___ATTRIBUTE__)
+
+if (HAVE___BUILTIN_EXPECT)
+ set (ac_cv_have___builtin_expect 1)
+else (HAVE___BUILTIN_EXPECT)
+ set (ac_cv_have___builtin_expect 0)
+endif (HAVE___BUILTIN_EXPECT)
+
+if (HAVE_USING_OPERATOR)
+ set (ac_cv_cxx_using_operator 1)
+else (HAVE_USING_OPERATOR)
+ set (ac_cv_cxx_using_operator 0)
+endif (HAVE_USING_OPERATOR)
+
+set (SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})
+
+if (WITH_THREADS AND Threads_FOUND)
+ if (CMAKE_USE_PTHREADS_INIT)
+ set (HAVE_PTHREAD 1)
+ endif (CMAKE_USE_PTHREADS_INIT)
+else (WITH_THREADS AND Threads_FOUND)
+ set (NO_THREADS 1)
+endif (WITH_THREADS AND Threads_FOUND)
+
+set (TEST_SRC_DIR \"${CMAKE_CURRENT_SOURCE_DIR}\")
+
+configure_file (src/config.h.cmake.in config.h)
+configure_file (src/glog/logging.h.in glog/logging.h @ONLY)
+configure_file (src/glog/raw_logging.h.in glog/raw_logging.h @ONLY)
+configure_file (src/glog/stl_logging.h.in glog/stl_logging.h @ONLY)
+configure_file (src/glog/vlog_is_on.h.in glog/vlog_is_on.h @ONLY)
+
+set (CMAKE_CXX_VISIBILITY_PRESET default)
+set (CMAKE_VISIBILITY_INLINES_HIDDEN 1)
+
+set (GLOG_PUBLIC_H
+ ${CMAKE_CURRENT_BINARY_DIR}/config.h
+ ${CMAKE_CURRENT_BINARY_DIR}/glog/logging.h
+ ${CMAKE_CURRENT_BINARY_DIR}/glog/raw_logging.h
+ ${CMAKE_CURRENT_BINARY_DIR}/glog/stl_logging.h
+ ${CMAKE_CURRENT_BINARY_DIR}/glog/vlog_is_on.h
+ src/glog/log_severity.h
+)
+
+set (GLOG_SRCS
+ ${GLOG_PUBLIC_H}
+ src/base/commandlineflags.h
+ src/base/googleinit.h
+ src/base/mutex.h
+ src/demangle.cc
+ src/demangle.h
+ src/logging.cc
+ src/raw_logging.cc
+ src/symbolize.cc
+ src/symbolize.h
+ src/utilities.cc
+ src/utilities.h
+ src/vlog_is_on.cc
+)
+
+if (HAVE_PTHREAD)
+ list (APPEND GLOG_SRCS src/signalhandler.cc)
+endif (HAVE_PTHREAD)
+
+if (WIN32)
+ list (APPEND GLOG_SRCS
+ src/windows/port.cc
+ src/windows/port.h
+ )
+endif (WIN32)
+
+add_compile_options ($<$<BOOL:${HAVE_NO_UNNAMED_TYPE_TEMPLATE_ARGS}>:-Wno-unnamed-type-template-args>)
+
+add_library (glog
+ ${GLOG_SRCS}
+)
+
+set_target_properties (glog PROPERTIES POSITION_INDEPENDENT_CODE ON)
+
+if (UNWIND_LIBRARY)
+ target_link_libraries (glog PUBLIC ${UNWIND_LIBRARY})
+endif (UNWIND_LIBRARY)
+
+if (HAVE_PTHREAD)
+ target_link_libraries (glog PUBLIC ${CMAKE_THREAD_LIBS_INIT})
+endif (HAVE_PTHREAD)
+
+if (WIN32 AND HAVE_SNPRINTF)
+ set_property (SOURCE src/windows/port.cc APPEND PROPERTY COMPILE_DEFINITIONS
+ HAVE_SNPRINTF)
+endif (WIN32 AND HAVE_SNPRINTF)
+
+if (gflags_FOUND)
+ target_include_directories (glog PUBLIC $<BUILD_INTERFACE:${gflags_INCLUDE_DIR}>)
+ target_link_libraries (glog PUBLIC ${gflags_LIBRARIES})
+
+ if (NOT BUILD_SHARED_LIBS)
+ # Don't use __declspec(dllexport|dllimport) if this is a static build
+ targeT_compile_definitions (glog PUBLIC GFLAGS_DLL_DECLARE_FLAG= GFLAGS_DLL_DEFINE_FLAG=)
+ endif (NOT BUILD_SHARED_LIBS)
+endif (gflags_FOUND)
+
+set_target_properties (glog PROPERTIES VERSION ${GLOG_MAJOR_VERSION})
+set_target_properties (glog PROPERTIES SOVERSION ${GLOG_VERSION})
+
+if (WIN32)
+ target_compile_definitions (glog PUBLIC GLOG_NO_ABBREVIATED_SEVERITIES)
+endif (WIN32)
+
+set_target_properties (glog PROPERTIES PUBLIC_HEADER "${GLOG_PUBLIC_H}")
+
+target_include_directories (glog BEFORE PUBLIC
+ "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
+ "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>"
+ "$<INSTALL_INTERFACE:include>"
+ PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
+
+if (WIN32)
+ target_include_directories (glog PUBLIC
+ "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/windows>"
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/windows)
+endif (WIN32)
+
+set_target_properties (glog PROPERTIES DEFINE_SYMBOL LIBGLOG_EXPORTS)
+
+if (NOT BUILD_SHARED_LIBS)
+ target_compile_definitions (glog PUBLIC GOOGLE_GLOG_DLL_DECL=)
+else (NOT BUILD_SHARED_LIBS)
+ target_compile_definitions (glog PRIVATE GOOGLE_GLOG_IS_A_DLL=1)
+
+ if (HAVE___ATTRIBUTE__VISIBILITY_DEFAULT)
+ set (_EXPORT "__attribute__((visibility(\"default\")))")
+ set (_IMPORT "")
+ elseif (HAVE___DECLSPEC)
+ set (_EXPORT "__declspec(dllexport)")
+ set (_IMPORT "__declspec(dllimport)")
+ endif (HAVE___ATTRIBUTE__VISIBILITY_DEFAULT)
+
+ target_compile_definitions (glog PRIVATE
+ "GOOGLE_GLOG_DLL_DECL=${_EXPORT}")
+ target_compile_definitions (glog INTERFACE
+ "GOOGLE_GLOG_DLL_DECL=${_IMPORT}")
+ target_compile_definitions (glog INTERFACE
+ "GOOGLE_GLOG_DLL_DECL_FOR_UNITTESTS=${_IMPORT}")
+endif (NOT BUILD_SHARED_LIBS)
+
+if (HAVE_EXECINFO_H)
+ set (HAVE_STACKTRACE 1)
+endif (HAVE_EXECINFO_H)
+
+if (UNIX OR (APPLE AND HAVE_DLADDR))
+ set (HAVE_SYMBOLIZE 1)
+endif (UNIX OR (APPLE AND HAVE_DLADDR))
+
+# Unit testing
+
+if (BUILD_TESTING)
+ add_executable (logging_unittest
+ src/logging_unittest.cc
+ )
+
+ target_link_libraries (logging_unittest PRIVATE glog)
+
+ add_executable (stl_logging_unittest
+ src/stl_logging_unittest.cc
+ )
+
+ target_link_libraries (stl_logging_unittest PRIVATE glog)
+
+ if (HAVE_NO_DEPRECATED)
+ set_property (TARGET stl_logging_unittest APPEND PROPERTY COMPILE_OPTIONS
+ -Wno-deprecated)
+ endif (HAVE_NO_DEPRECATED)
+
+ if (HAVE_UNORDERED_MAP AND HAVE_UNORDERED_SET)
+ target_compile_definitions (stl_logging_unittest PRIVATE
+ GLOG_STL_LOGGING_FOR_UNORDERED)
+ endif (HAVE_UNORDERED_MAP AND HAVE_UNORDERED_SET)
+
+ if (HAVE_TR1_UNORDERED_MAP AND HAVE_TR1_UNORDERED_SET)
+ target_compile_definitions (stl_logging_unittest PRIVATE
+ GLOG_STL_LOGGING_FOR_TR1_UNORDERED)
+ endif (HAVE_TR1_UNORDERED_MAP AND HAVE_TR1_UNORDERED_SET)
+
+ if (HAVE_EXT_HASH_MAP AND HAVE_EXT_HASH_SET)
+ target_compile_definitions (stl_logging_unittest PRIVATE
+ GLOG_STL_LOGGING_FOR_EXT_HASH)
+ endif (HAVE_EXT_HASH_MAP AND HAVE_EXT_HASH_SET)
+
+ if (HAVE_EXT_SLIST)
+ target_compile_definitions (stl_logging_unittest PRIVATE
+ GLOG_STL_LOGGING_FOR_EXT_SLIST)
+ endif (HAVE_EXT_SLIST)
+
+ if (HAVE_SYMBOLIZE)
+ add_executable (symbolize_unittest
+ src/symbolize_unittest.cc
+ )
+
+ target_link_libraries (symbolize_unittest PRIVATE glog)
+ endif (HAVE_SYMBOLIZE)
+
+ add_executable (demangle_unittest
+ src/demangle_unittest.cc
+ )
+
+ target_link_libraries (demangle_unittest PRIVATE glog)
+
+ if (HAVE_STACKTRACE)
+ add_executable (stacktrace_unittest
+ src/stacktrace_unittest.cc
+ )
+
+ target_link_libraries (stacktrace_unittest PRIVATE glog)
+ endif (HAVE_STACKTRACE)
+
+ add_executable (utilities_unittest
+ src/utilities_unittest.cc
+ )
+
+ target_link_libraries (utilities_unittest PRIVATE glog)
+
+ if (HAVE_STACKTRACE AND HAVE_SYMBOLIZE)
+ add_executable (signalhandler_unittest
+ src/signalhandler_unittest.cc
+ )
+
+ target_link_libraries (signalhandler_unittest PRIVATE glog)
+ endif (HAVE_STACKTRACE AND HAVE_SYMBOLIZE)
+
+ add_test (NAME demangle COMMAND demangle_unittest)
+ add_test (NAME logging COMMAND logging_unittest)
+
+ if (TARGET signalhandler_unittest)
+ add_test (NAME signalhandler COMMAND signalhandler_unittest)
+ endif (TARGET signalhandler_unittest)
+
+ if (TARGET stacktrace_unittest)
+ add_test (NAME stacktrace COMMAND stacktrace_unittest)
+ endif (TARGET stacktrace_unittest)
+
+ add_test (NAME stl_logging COMMAND stl_logging_unittest)
+
+ if (TARGET symbolize_unittest)
+ add_test (NAME symbolize COMMAND symbolize_unittest)
+ endif (TARGET symbolize_unittest)
+endif (BUILD_TESTING)
+
+install (TARGETS glog
+ EXPORT glog-targets
+ RUNTIME DESTINATION bin
+ PUBLIC_HEADER DESTINATION include/glog
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib)
+
+if (gflags_FOUND)
+ set (gflags_DEPENDENCY "find_dependency (gflags ${gflags_VERSION})")
+endif (gflags_FOUND)
+
+configure_package_config_file (glog-config.cmake.in
+ ${CMAKE_CURRENT_BINARY_DIR}/glog-config.cmake
+ INSTALL_DESTINATION lib/cmake/glog
+ NO_CHECK_REQUIRED_COMPONENTS_MACRO)
+
+write_basic_package_version_file (glog-config-version.cmake VERSION
+ ${GLOG_VERSION} COMPATIBILITY SameMajorVersion)
+
+export (TARGETS glog NAMESPACE glog:: FILE glog-targets.cmake)
+export (PACKAGE glog)
+
+install (FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/glog-config.cmake
+ ${CMAKE_CURRENT_BINARY_DIR}/glog-config-version.cmake
+ DESTINATION lib/cmake/glog)
+
+install (EXPORT glog-targets NAMESPACE glog:: DESTINATION lib/cmake/glog)
diff --git a/thirdparty/glog/glog-0.3.5/CONTRIBUTING.md b/thirdparty/glog/glog-0.3.5/CONTRIBUTING.md
new file mode 100644
index 0000000..43de4c9
--- /dev/null
+++ b/thirdparty/glog/glog-0.3.5/CONTRIBUTING.md
@@ -0,0 +1,58 @@
+# How to contribute #
+
+We'd love to accept your patches and contributions to this project. There are
+a just a few small guidelines you need to follow.
+
+
+## Contributor License Agreement ##
+
+Contributions to any Google project must be accompanied by a Contributor
+License Agreement. This is not a copyright **assignment**, it simply gives
+Google permission to use and redistribute your contributions as part of the
+project.
+
+ * If you are an individual writing original source code and you're sure you
+ own the intellectual property, then you'll need to sign an [individual
+ CLA][].
+
+ * If you work for a company that wants to allow you to contribute your work,
+ then you'll need to sign a [corporate CLA][].
+
+You generally only need to submit a CLA once, so if you've already submitted
+one (even if it was for a different project), you probably don't need to do it
+again.
+
+[individual CLA]: https://developers.google.com/open-source/cla/individual
+[corporate CLA]: https://developers.google.com/open-source/cla/corporate
+
+Once your CLA is submitted (or if you already submitted one for
+another Google project), make a commit adding yourself to the
+[AUTHORS][] and [CONTRIBUTORS][] files. This commit can be part
+of your first [pull request][].
+
+[AUTHORS]: AUTHORS
+[CONTRIBUTORS]: CONTRIBUTORS
+
+
+## Submitting a patch ##
+
+ 1. It's generally best to start by opening a new issue describing the bug or
+ feature you're intending to fix. Even if you think it's relatively minor,
+ it's helpful to know what people are working on. Mention in the initial
+ issue that you are planning to work on that bug or feature so that it can
+ be assigned to you.
+
+ 1. Follow the normal process of [forking][] the project, and setup a new
+ branch to work in. It's important that each group of changes be done in
+ separate branches in order to ensure that a pull request only includes the
+ commits related to that bug or feature.
+
+ 1. Do your best to have [well-formed commit messages][] for each change.
+ This provides consistency throughout the project, and ensures that commit
+ messages are able to be formatted properly by various git tools.
+
+ 1. Finally, push the commits to your fork and submit a [pull request][].
+
+[forking]: https://help.github.com/articles/fork-a-repo
+[well-formed commit messages]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
+[pull request]: https://help.github.com/articles/creating-a-pull-request
diff --git a/thirdparty/glog/glog-0.3.5/CONTRIBUTORS b/thirdparty/glog/glog-0.3.5/CONTRIBUTORS
new file mode 100644
index 0000000..70c0ace
--- /dev/null
+++ b/thirdparty/glog/glog-0.3.5/CONTRIBUTORS
@@ -0,0 +1,40 @@
+# People who have agreed to one of the CLAs and can contribute patches.
+# The AUTHORS file lists the copyright holders; this file
+# lists people. For example, Google employees are listed here
+# but not in AUTHORS, because Google holds the copyright.
+#
+# Names should be added to this file only after verifying that
+# the individual or the individual's organization has agreed to
+# the appropriate Contributor License Agreement, found here:
+#
+# https://developers.google.com/open-source/cla/individual
+# https://developers.google.com/open-source/cla/corporate
+#
+# The agreement for individuals can be filled out on the web.
+#
+# When adding J Random Contributor's name to this file,
+# either J's name or J's organization's name should be
+# added to the AUTHORS file, depending on whether the
+# individual or corporate CLA was used.
+#
+# Names should be added to this file as:
+# Name <email address>
+#
+# Please keep the list sorted.
+
+Abhishek Dasgupta <abhi2743@gmail.com>
+Abhishek Parmar <abhishek@orng.net>
+Andy Ying <andy@trailofbits.com>
+Brian Silverman <bsilver16384@gmail.com>
+Fumitoshi Ukai <ukai@google.com>
+Guillaume Dumont <dumont.guillaume@gmail.com>
+HÃ¥kan L. S. Younes <hyounes@google.com>
+Ivan Penkov <ivanpe@google.com>
+Michael Tanner <michael@tannertaxpro.com>
+MiniLight <MiniLightAR@Gmail.com>
+Peter Collingbourne <pcc@google.com>
+romange <romange@users.noreply.github.com>
+Sergiu Deitsch <sergiu.deitsch@gmail.com>
+Shinichiro Hamaji <hamaji@google.com>
+tbennun <tbennun@gmail.com>
+Teddy Reed <teddy@prosauce.org>
diff --git a/thirdparty/glog/glog-0.3.4/COPYING b/thirdparty/glog/glog-0.3.5/COPYING
index 38396b5..38396b5 100644
--- a/thirdparty/glog/glog-0.3.4/COPYING
+++ b/thirdparty/glog/glog-0.3.5/COPYING
diff --git a/thirdparty/glog/glog-0.3.4/ChangeLog b/thirdparty/glog/glog-0.3.5/ChangeLog
index d1b4248..d1b4248 100644
--- a/thirdparty/glog/glog-0.3.4/ChangeLog
+++ b/thirdparty/glog/glog-0.3.5/ChangeLog
diff --git a/thirdparty/glog/glog-0.3.5/INSTALL b/thirdparty/glog/glog-0.3.5/INSTALL
new file mode 100644
index 0000000..0babe24
--- /dev/null
+++ b/thirdparty/glog/glog-0.3.5/INSTALL
@@ -0,0 +1,297 @@
+Installation Instructions
+*************************
+
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
+2006, 2007 Free Software Foundation, Inc.
+
+This file is free documentation; the Free Software Foundation gives
+unlimited permission to copy, distribute and modify it.
+
+Glog-Specific Install Notes
+================================
+
+*** NOTE FOR 64-BIT LINUX SYSTEMS
+
+The glibc built-in stack-unwinder on 64-bit systems has some problems
+with the glog libraries. (In particular, if you are using
+InstallFailureSignalHandler(), the signal may be raised in the middle
+of malloc, holding some malloc-related locks when they invoke the
+stack unwinder. The built-in stack unwinder may call malloc
+recursively, which may require the thread to acquire a lock it already
+holds: deadlock.)
+
+For that reason, if you use a 64-bit system and you need
+InstallFailureSignalHandler(), we strongly recommend you install
+libunwind before trying to configure or install google glog.
+libunwind can be found at
+
+ http://download.savannah.nongnu.org/releases/libunwind/libunwind-snap-070410.tar.gz
+
+Even if you already have libunwind installed, you will probably still
+need to install from the snapshot to get the latest version.
+
+CAUTION: if you install libunwind from the URL above, be aware that
+you may have trouble if you try to statically link your binary with
+glog: that is, if you link with 'gcc -static -lgcc_eh ...'. This
+is because both libunwind and libgcc implement the same C++ exception
+handling APIs, but they implement them differently on some platforms.
+This is not likely to be a problem on ia64, but may be on x86-64.
+
+Also, if you link binaries statically, make sure that you add
+-Wl,--eh-frame-hdr to your linker options. This is required so that
+libunwind can find the information generated by the compiler required
+for stack unwinding.
+
+Using -static is rare, though, so unless you know this will affect you
+it probably won't.
+
+If you cannot or do not wish to install libunwind, you can still try
+to use two kinds of stack-unwinder: 1. glibc built-in stack-unwinder
+and 2. frame pointer based stack-unwinder.
+
+1. As we already mentioned, glibc's unwinder has a deadlock issue.
+However, if you don't use InstallFailureSignalHandler() or you don't
+worry about the rare possibilities of deadlocks, you can use this
+stack-unwinder. If you specify no options and libunwind isn't
+detected on your system, the configure script chooses this unwinder by
+default.
+
+2. The frame pointer based stack unwinder requires that your
+application, the glog library, and system libraries like libc, all be
+compiled with a frame pointer. This is *not* the default for x86-64.
+
+If you are on x86-64 system, know that you have a set of system
+libraries with frame-pointers enabled, and compile all your
+applications with -fno-omit-frame-pointer, then you can enable the
+frame pointer based stack unwinder by passing the
+--enable-frame-pointers flag to configure.
+
+
+Basic Installation
+==================
+
+Briefly, the shell commands `./configure; make; make install' should
+configure, build, and install this package. The following
+more-detailed instructions are generic; see the `README' file for
+instructions specific to this package.
+
+ The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation. It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions. Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
+
+ It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring. Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.
+
+ If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release. If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+ The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'. You need `configure.ac' if
+you want to change it or regenerate `configure' using a newer version
+of `autoconf'.
+
+The simplest way to compile this package is:
+
+ 1. `cd' to the directory containing the package's source code and type
+ `./configure' to configure the package for your system.
+
+ Running `configure' might take a while. While running, it prints
+ some messages telling which features it is checking for.
+
+ 2. Type `make' to compile the package.
+
+ 3. Optionally, type `make check' to run any self-tests that come with
+ the package.
+
+ 4. Type `make install' to install the programs and any data files and
+ documentation.
+
+ 5. You can remove the program binaries and object files from the
+ source code directory by typing `make clean'. To also remove the
+ files that `configure' created (so you can compile the package for
+ a different kind of computer), type `make distclean'. There is
+ also a `make maintainer-clean' target, but that is intended mainly
+ for the package's developers. If you use it, you may have to get
+ all sorts of other programs in order to regenerate files that came
+ with the distribution.
+
+ 6. Often, you can also type `make uninstall' to remove the installed
+ files again.
+
+Compilers and Options
+=====================
+
+Some systems require unusual options for compilation or linking that the
+`configure' script does not know about. Run `./configure --help' for
+details on some of the pertinent environment variables.
+
+ You can give `configure' initial values for configuration parameters
+by setting variables in the command line or in the environment. Here
+is an example:
+
+ ./configure CC=c99 CFLAGS=-g LIBS=-lposix
+
+ *Note Defining Variables::, for more details.
+
+Compiling For Multiple Architectures
+====================================
+
+You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory. To do this, you can use GNU `make'. `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script. `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.
+
+ With a non-GNU `make', it is safer to compile the package for one
+architecture at a time in the source code directory. After you have
+installed the package for one architecture, use `make distclean' before
+reconfiguring for another architecture.
+
+Installation Names
+==================
+
+By default, `make install' installs the package's commands under
+`/usr/local/bin', include files under `/usr/local/include', etc. You
+can specify an installation prefix other than `/usr/local' by giving
+`configure' the option `--prefix=PREFIX'.
+
+ You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files. If you
+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
+PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files still use the regular prefix.
+
+ In addition, if you use an unusual directory layout you can give
+options like `--bindir=DIR' to specify different values for particular
+kinds of files. Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.
+
+ If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+Optional Features
+=================
+
+Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System). The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+ For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+Specifying the System Type
+==========================
+
+There may be some features `configure' cannot figure out automatically,
+but needs to determine by the type of machine the package will run on.
+Usually, assuming the package is built to be run on the _same_
+architectures, `configure' can figure that out, but if it prints a
+message saying it cannot guess the machine type, give it the
+`--build=TYPE' option. TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
+ CPU-COMPANY-SYSTEM
+
+where SYSTEM can have one of these forms:
+
+ OS KERNEL-OS
+
+ See the file `config.sub' for the possible values of each field. If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the machine type.
+
+ If you are _building_ compiler tools for cross-compiling, you should
+use the option `--target=TYPE' to select the type of system they will
+produce code for.
+
+ If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the
+"host" platform (i.e., that on which the generated programs will
+eventually be run) with `--host=TYPE'.
+
+Sharing Defaults
+================
+
+If you want to set default values for `configure' scripts to share, you
+can create a site shell script called `config.site' that gives default
+values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists. Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Defining Variables
+==================
+
+Variables not defined in a site shell script can be set in the
+environment passed to `configure'. However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost. In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'. For example:
+
+ ./configure CC=/usr/local2/bin/gcc
+
+causes the specified `gcc' to be used as the C compiler (unless it is
+overridden in the site shell script).
+
+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
+an Autoconf bug. Until the bug is fixed you can use this workaround:
+
+ CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
+
+`configure' Invocation
+======================
+
+`configure' recognizes the following options to control how it operates.
+
+`--help'
+`-h'
+ Print a summary of the options to `configure', and exit.
+
+`--version'
+`-V'
+ Print the version of Autoconf used to generate the `configure'
+ script, and exit.
+
+`--cache-file=FILE'
+ Enable the cache: use and save the results of the tests in FILE,
+ traditionally `config.cache'. FILE defaults to `/dev/null' to
+ disable caching.
+
+`--config-cache'
+`-C'
+ Alias for `--cache-file=config.cache'.
+
+`--quiet'
+`--silent'
+`-q'
+ Do not print messages saying which checks are being made. To
+ suppress all normal output, redirect it to `/dev/null' (any error
+ messages will still be shown).
+
+`--srcdir=DIR'
+ Look for the package's source code in directory DIR. Usually
+ `configure' can determine that directory automatically.
+
+`configure' also accepts some other, not widely useful, options. Run
+`configure --help' for more details.
+
diff --git a/thirdparty/glog/glog-0.3.4/Makefile.am b/thirdparty/glog/glog-0.3.5/Makefile.am
index a704a00..e6d9c5d 100644
--- a/thirdparty/glog/glog-0.3.4/Makefile.am
+++ b/thirdparty/glog/glog-0.3.5/Makefile.am
@@ -14,8 +14,8 @@ AM_CXXFLAGS =
# These are good warnings to turn on by default
if GCC
AM_CXXFLAGS += -g -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare -Wno-deprecated \
- -fstack-protector -Wl,-z,relro -Wl,--disable-new-dtags \
- -Wl,-z,noexecstack -fPIC -D_FORTIFY_SOURCE=2 -O2 -z,now -Wformat=2 -Wfloat-equal -Wshadow
+ -fstack-protector-all -Wl,-z,relro,-z,now \
+ -Wl,-z,noexecstack -fPIC -D_FORTIFY_SOURCE=2 -O2 -Wformat=2 -Wfloat-equal -Wshadow
endif
# These are x86-specific, having to do with frame-pointers
diff --git a/thirdparty/glog/glog-0.3.5/Makefile.in b/thirdparty/glog/glog-0.3.5/Makefile.in
new file mode 100644
index 0000000..bf8a82a
--- /dev/null
+++ b/thirdparty/glog/glog-0.3.5/Makefile.in
@@ -0,0 +1,2084 @@
+# Makefile.in generated by automake 1.13.4 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+#
+# This file has been modified by Huawei.
+# Copyright (C) 2018-2019, Huawei.
+#
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+
+
+
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+
+# These are good warnings to turn on by default
+@GCC_TRUE@am__append_1 = -g -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare -Wno-deprecated \
+@GCC_TRUE@ -fstack-protector-all -Wl,-z,relro,-z,now \
+@GCC_TRUE@ -Wl,-z,noexecstack -fPIC -D_FORTIFY_SOURCE=2 -O2 -Wformat=2 -Wfloat-equal -Wshadow
+
+
+# These are x86-specific, having to do with frame-pointers
+@ENABLE_FRAME_POINTERS_TRUE@@X86_64_TRUE@am__append_2 = -fno-omit-frame-pointer
+@ENABLE_FRAME_POINTERS_FALSE@@X86_64_TRUE@am__append_3 = -DNO_FRAME_POINTER
+@DISABLE_RTTI_TRUE@am__append_4 = -fno-rtti
+TESTS = logging_unittest$(EXEEXT) demangle_unittest$(EXEEXT) \
+ stacktrace_unittest$(EXEEXT) symbolize_unittest$(EXEEXT) \
+ stl_logging_unittest$(EXEEXT) utilities_unittest$(EXEEXT) \
+ $(am__EXEEXT_1)
+@HAVE_GMOCK_TRUE@am__append_5 = mock_log_test
+noinst_PROGRAMS = $(am__EXEEXT_2) $(am__EXEEXT_3)
+subdir = .
+DIST_COMMON = INSTALL NEWS README AUTHORS ChangeLog \
+ $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+ $(top_srcdir)/configure $(am__configure_deps) \
+ $(top_srcdir)/src/config.h.in mkinstalldirs \
+ $(top_srcdir)/src/glog/logging.h.in \
+ $(top_srcdir)/src/glog/raw_logging.h.in \
+ $(top_srcdir)/src/glog/vlog_is_on.h.in \
+ $(top_srcdir)/src/glog/stl_logging.h.in \
+ $(srcdir)/libglog.pc.in depcomp $(dist_doc_DATA) \
+ $(gloginclude_HEADERS) $(noinst_HEADERS) test-driver COPYING \
+ compile config.guess config.sub install-sh missing ltmain.sh
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ac_have_attribute.m4 \
+ $(top_srcdir)/m4/ac_have_builtin_expect.m4 \
+ $(top_srcdir)/m4/ac_have_sync_val_compare_and_swap.m4 \
+ $(top_srcdir)/m4/ac_rwlock.m4 $(top_srcdir)/m4/acx_pthread.m4 \
+ $(top_srcdir)/m4/google_namespace.m4 \
+ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/namespaces.m4 \
+ $(top_srcdir)/m4/pc_from_ucontext.m4 \
+ $(top_srcdir)/m4/stl_namespace.m4 \
+ $(top_srcdir)/m4/using_operator.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
+ configure.lineno config.status.lineno
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/src/config.h
+CONFIG_CLEAN_FILES = src/glog/logging.h src/glog/raw_logging.h \
+ src/glog/vlog_is_on.h src/glog/stl_logging.h libglog.pc
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+ test -z "$$files" \
+ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+ $(am__cd) "$$dir" && rm -f $$files; }; \
+ }
+am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(docdir)" \
+ "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(glogincludedir)" \
+ "$(DESTDIR)$(glogincludedir)"
+LTLIBRARIES = $(lib_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
+libglog_la_DEPENDENCIES = $(am__DEPENDENCIES_2)
+am__objects_1 =
+am__dirstamp = $(am__leading_dot)dirstamp
+am_libglog_la_OBJECTS = $(am__objects_1) src/libglog_la-logging.lo \
+ src/libglog_la-raw_logging.lo src/libglog_la-vlog_is_on.lo \
+ src/libglog_la-utilities.lo src/libglog_la-demangle.lo \
+ src/libglog_la-symbolize.lo src/libglog_la-signalhandler.lo \
+ src/libglog_la-nstack_logging.lo
+nodist_libglog_la_OBJECTS = $(am__objects_1)
+libglog_la_OBJECTS = $(am_libglog_la_OBJECTS) \
+ $(nodist_libglog_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 =
+libglog_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(libglog_la_CXXFLAGS) \
+ $(CXXFLAGS) $(libglog_la_LDFLAGS) $(LDFLAGS) -o $@
+@HAVE_GMOCK_TRUE@am__EXEEXT_1 = mock_log_test$(EXEEXT)
+am__EXEEXT_2 = logging_unittest$(EXEEXT) demangle_unittest$(EXEEXT) \
+ stacktrace_unittest$(EXEEXT) symbolize_unittest$(EXEEXT) \
+ stl_logging_unittest$(EXEEXT) utilities_unittest$(EXEEXT) \
+ $(am__EXEEXT_1)
+am__EXEEXT_3 = logging_striptest0$(EXEEXT) logging_striptest2$(EXEEXT) \
+ logging_striptest10$(EXEEXT) signalhandler_unittest$(EXEEXT)
+PROGRAMS = $(noinst_PROGRAMS)
+am_demangle_unittest_OBJECTS = $(am__objects_1) \
+ src/demangle_unittest-demangle_unittest.$(OBJEXT)
+nodist_demangle_unittest_OBJECTS = $(am__objects_1)
+demangle_unittest_OBJECTS = $(am_demangle_unittest_OBJECTS) \
+ $(nodist_demangle_unittest_OBJECTS)
+demangle_unittest_DEPENDENCIES = libglog.la $(am__DEPENDENCIES_2) \
+ $(am__DEPENDENCIES_2)
+demangle_unittest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+ $(demangle_unittest_CXXFLAGS) $(CXXFLAGS) \
+ $(demangle_unittest_LDFLAGS) $(LDFLAGS) -o $@
+am_logging_striptest0_OBJECTS = $(am__objects_1) \
+ src/logging_striptest0-logging_striptest_main.$(OBJEXT)
+nodist_logging_striptest0_OBJECTS = $(am__objects_1)
+logging_striptest0_OBJECTS = $(am_logging_striptest0_OBJECTS) \
+ $(nodist_logging_striptest0_OBJECTS)
+logging_striptest0_DEPENDENCIES = libglog.la $(am__DEPENDENCIES_2)
+logging_striptest0_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+ $(logging_striptest0_CXXFLAGS) $(CXXFLAGS) \
+ $(logging_striptest0_LDFLAGS) $(LDFLAGS) -o $@
+am_logging_striptest10_OBJECTS = $(am__objects_1) \
+ src/logging_striptest10-logging_striptest10.$(OBJEXT)
+nodist_logging_striptest10_OBJECTS = $(am__objects_1)
+logging_striptest10_OBJECTS = $(am_logging_striptest10_OBJECTS) \
+ $(nodist_logging_striptest10_OBJECTS)
+logging_striptest10_DEPENDENCIES = libglog.la $(am__DEPENDENCIES_2)
+logging_striptest10_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+ $(logging_striptest10_CXXFLAGS) $(CXXFLAGS) \
+ $(logging_striptest10_LDFLAGS) $(LDFLAGS) -o $@
+am_logging_striptest2_OBJECTS = $(am__objects_1) \
+ src/logging_striptest2-logging_striptest2.$(OBJEXT)
+nodist_logging_striptest2_OBJECTS = $(am__objects_1)
+logging_striptest2_OBJECTS = $(am_logging_striptest2_OBJECTS) \
+ $(nodist_logging_striptest2_OBJECTS)
+logging_striptest2_DEPENDENCIES = libglog.la $(am__DEPENDENCIES_2)
+logging_striptest2_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+ $(logging_striptest2_CXXFLAGS) $(CXXFLAGS) \
+ $(logging_striptest2_LDFLAGS) $(LDFLAGS) -o $@
+am_logging_unittest_OBJECTS = $(am__objects_1) \
+ src/logging_unittest-logging_unittest.$(OBJEXT)
+nodist_logging_unittest_OBJECTS = $(am__objects_1)
+logging_unittest_OBJECTS = $(am_logging_unittest_OBJECTS) \
+ $(nodist_logging_unittest_OBJECTS)
+logging_unittest_DEPENDENCIES = libglog.la $(am__DEPENDENCIES_2) \
+ $(am__DEPENDENCIES_2)
+logging_unittest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+ $(logging_unittest_CXXFLAGS) $(CXXFLAGS) \
+ $(logging_unittest_LDFLAGS) $(LDFLAGS) -o $@
+am__mock_log_test_SOURCES_DIST = src/glog/log_severity.h \
+ src/mock-log_test.cc
+@HAVE_GMOCK_TRUE@am_mock_log_test_OBJECTS = $(am__objects_1) \
+@HAVE_GMOCK_TRUE@ src/mock_log_test-mock-log_test.$(OBJEXT)
+@HAVE_GMOCK_TRUE@nodist_mock_log_test_OBJECTS = $(am__objects_1)
+mock_log_test_OBJECTS = $(am_mock_log_test_OBJECTS) \
+ $(nodist_mock_log_test_OBJECTS)
+@HAVE_GMOCK_TRUE@mock_log_test_DEPENDENCIES = libglog.la \
+@HAVE_GMOCK_TRUE@ $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_2)
+mock_log_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+ $(mock_log_test_CXXFLAGS) $(CXXFLAGS) $(mock_log_test_LDFLAGS) \
+ $(LDFLAGS) -o $@
+am_signalhandler_unittest_OBJECTS = $(am__objects_1) \
+ src/signalhandler_unittest-signalhandler_unittest.$(OBJEXT)
+nodist_signalhandler_unittest_OBJECTS = $(am__objects_1)
+signalhandler_unittest_OBJECTS = $(am_signalhandler_unittest_OBJECTS) \
+ $(nodist_signalhandler_unittest_OBJECTS)
+signalhandler_unittest_DEPENDENCIES = libglog.la $(am__DEPENDENCIES_2) \
+ $(am__DEPENDENCIES_2)
+signalhandler_unittest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+ $(signalhandler_unittest_CXXFLAGS) $(CXXFLAGS) \
+ $(signalhandler_unittest_LDFLAGS) $(LDFLAGS) -o $@
+am_stacktrace_unittest_OBJECTS = $(am__objects_1) \
+ src/stacktrace_unittest-stacktrace_unittest.$(OBJEXT)
+nodist_stacktrace_unittest_OBJECTS = $(am__objects_1)
+stacktrace_unittest_OBJECTS = $(am_stacktrace_unittest_OBJECTS) \
+ $(nodist_stacktrace_unittest_OBJECTS)
+stacktrace_unittest_DEPENDENCIES = libglog.la $(am__DEPENDENCIES_2)
+stacktrace_unittest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+ $(stacktrace_unittest_CXXFLAGS) $(CXXFLAGS) \
+ $(stacktrace_unittest_LDFLAGS) $(LDFLAGS) -o $@
+am_stl_logging_unittest_OBJECTS = $(am__objects_1) \
+ src/stl_logging_unittest-stl_logging_unittest.$(OBJEXT)
+nodist_stl_logging_unittest_OBJECTS = $(am__objects_1)
+stl_logging_unittest_OBJECTS = $(am_stl_logging_unittest_OBJECTS) \
+ $(nodist_stl_logging_unittest_OBJECTS)
+stl_logging_unittest_DEPENDENCIES = libglog.la $(am__DEPENDENCIES_2) \
+ $(am__DEPENDENCIES_2)
+stl_logging_unittest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+ $(stl_logging_unittest_CXXFLAGS) $(CXXFLAGS) \
+ $(stl_logging_unittest_LDFLAGS) $(LDFLAGS) -o $@
+am_symbolize_unittest_OBJECTS = $(am__objects_1) \
+ src/symbolize_unittest-symbolize_unittest.$(OBJEXT)
+nodist_symbolize_unittest_OBJECTS = $(am__objects_1)
+symbolize_unittest_OBJECTS = $(am_symbolize_unittest_OBJECTS) \
+ $(nodist_symbolize_unittest_OBJECTS)
+symbolize_unittest_DEPENDENCIES = libglog.la $(am__DEPENDENCIES_2) \
+ $(am__DEPENDENCIES_2)
+symbolize_unittest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+ $(symbolize_unittest_CXXFLAGS) $(CXXFLAGS) \
+ $(symbolize_unittest_LDFLAGS) $(LDFLAGS) -o $@
+am_utilities_unittest_OBJECTS = $(am__objects_1) \
+ src/utilities_unittest-utilities_unittest.$(OBJEXT)
+nodist_utilities_unittest_OBJECTS = $(am__objects_1)
+utilities_unittest_OBJECTS = $(am_utilities_unittest_OBJECTS) \
+ $(nodist_utilities_unittest_OBJECTS)
+utilities_unittest_DEPENDENCIES = libglog.la $(am__DEPENDENCIES_2) \
+ $(am__DEPENDENCIES_2)
+utilities_unittest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+ $(utilities_unittest_CXXFLAGS) $(CXXFLAGS) \
+ $(utilities_unittest_LDFLAGS) $(LDFLAGS) -o $@
+SCRIPTS = $(noinst_SCRIPTS)
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_@AM_V@)
+am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@)
+am__v_CXX_0 = @echo " CXX " $@;
+am__v_CXX_1 =
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
+am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
+am__v_CXXLD_0 = @echo " CXXLD " $@;
+am__v_CXXLD_1 =
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo " CC " $@;
+am__v_CC_1 =
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo " CCLD " $@;
+am__v_CCLD_1 =
+SOURCES = $(libglog_la_SOURCES) $(nodist_libglog_la_SOURCES) \
+ $(demangle_unittest_SOURCES) \
+ $(nodist_demangle_unittest_SOURCES) \
+ $(logging_striptest0_SOURCES) \
+ $(nodist_logging_striptest0_SOURCES) \
+ $(logging_striptest10_SOURCES) \
+ $(nodist_logging_striptest10_SOURCES) \
+ $(logging_striptest2_SOURCES) \
+ $(nodist_logging_striptest2_SOURCES) \
+ $(logging_unittest_SOURCES) $(nodist_logging_unittest_SOURCES) \
+ $(mock_log_test_SOURCES) $(nodist_mock_log_test_SOURCES) \
+ $(signalhandler_unittest_SOURCES) \
+ $(nodist_signalhandler_unittest_SOURCES) \
+ $(stacktrace_unittest_SOURCES) \
+ $(nodist_stacktrace_unittest_SOURCES) \
+ $(stl_logging_unittest_SOURCES) \
+ $(nodist_stl_logging_unittest_SOURCES) \
+ $(symbolize_unittest_SOURCES) \
+ $(nodist_symbolize_unittest_SOURCES) \
+ $(utilities_unittest_SOURCES) \
+ $(nodist_utilities_unittest_SOURCES)
+DIST_SOURCES = $(libglog_la_SOURCES) $(demangle_unittest_SOURCES) \
+ $(logging_striptest0_SOURCES) $(logging_striptest10_SOURCES) \
+ $(logging_striptest2_SOURCES) $(logging_unittest_SOURCES) \
+ $(am__mock_log_test_SOURCES_DIST) \
+ $(signalhandler_unittest_SOURCES) \
+ $(stacktrace_unittest_SOURCES) $(stl_logging_unittest_SOURCES) \
+ $(symbolize_unittest_SOURCES) $(utilities_unittest_SOURCES)
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+DATA = $(dist_doc_DATA) $(pkgconfig_DATA)
+HEADERS = $(gloginclude_HEADERS) $(nodist_gloginclude_HEADERS) \
+ $(noinst_HEADERS)
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+CSCOPE = cscope
+AM_RECURSIVE_TARGETS = cscope check recheck
+am__tty_colors_dummy = \
+ mgn= red= grn= lgn= blu= brg= std=; \
+ am__color_tests=no
+am__tty_colors = { \
+ $(am__tty_colors_dummy); \
+ if test "X$(AM_COLOR_TESTS)" = Xno; then \
+ am__color_tests=no; \
+ elif test "X$(AM_COLOR_TESTS)" = Xalways; then \
+ am__color_tests=yes; \
+ elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \
+ am__color_tests=yes; \
+ fi; \
+ if test $$am__color_tests = yes; then \
+ red=''; \
+ grn=''; \
+ lgn=''; \
+ blu=''; \
+ mgn=''; \
+ brg=''; \
+ std=''; \
+ fi; \
+}
+am__recheck_rx = ^[ ]*:recheck:[ ]*
+am__global_test_result_rx = ^[ ]*:global-test-result:[ ]*
+am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]*
+# A command that, given a newline-separated list of test names on the
+# standard input, print the name of the tests that are to be re-run
+# upon "make recheck".
+am__list_recheck_tests = $(AWK) '{ \
+ recheck = 1; \
+ while ((rc = (getline line < ($$0 ".trs"))) != 0) \
+ { \
+ if (rc < 0) \
+ { \
+ if ((getline line2 < ($$0 ".log")) < 0) \
+ recheck = 0; \
+ break; \
+ } \
+ else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \
+ { \
+ recheck = 0; \
+ break; \
+ } \
+ else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \
+ { \
+ break; \
+ } \
+ }; \
+ if (recheck) \
+ print $$0; \
+ close ($$0 ".trs"); \
+ close ($$0 ".log"); \
+}'
+# A command that, given a newline-separated list of test names on the
+# standard input, create the global log from their .trs and .log files.
+am__create_global_log = $(AWK) ' \
+function fatal(msg) \
+{ \
+ print "fatal: making $@: " msg | "cat >&2"; \
+ exit 1; \
+} \
+function rst_section(header) \
+{ \
+ print header; \
+ len = length(header); \
+ for (i = 1; i <= len; i = i + 1) \
+ printf "="; \
+ printf "\n\n"; \
+} \
+{ \
+ copy_in_global_log = 1; \
+ global_test_result = "RUN"; \
+ while ((rc = (getline line < ($$0 ".trs"))) != 0) \
+ { \
+ if (rc < 0) \
+ fatal("failed to read from " $$0 ".trs"); \
+ if (line ~ /$(am__global_test_result_rx)/) \
+ { \
+ sub("$(am__global_test_result_rx)", "", line); \
+ sub("[ ]*$$", "", line); \
+ global_test_result = line; \
+ } \
+ else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \
+ copy_in_global_log = 0; \
+ }; \
+ if (copy_in_global_log) \
+ { \
+ rst_section(global_test_result ": " $$0); \
+ while ((rc = (getline line < ($$0 ".log"))) != 0) \
+ { \
+ if (rc < 0) \
+ fatal("failed to read from " $$0 ".log"); \
+ print line; \
+ }; \
+ printf "\n"; \
+ }; \
+ close ($$0 ".trs"); \
+ close ($$0 ".log"); \
+}'
+# Restructured Text title.
+am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; }
+# Solaris 10 'make', and several other traditional 'make' implementations,
+# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it
+# by disabling -e (using the XSI extension "set +e") if it's set.
+am__sh_e_setup = case $$- in *e*) set +e;; esac
+# Default flags passed to test drivers.
+am__common_driver_flags = \
+ --color-tests "$$am__color_tests" \
+ --enable-hard-errors "$$am__enable_hard_errors" \
+ --expect-failure "$$am__expect_failure"
+# To be inserted before the command running the test. Creates the
+# directory for the log if needed. Stores in $dir the directory
+# containing $f, in $tst the test, in $log the log. Executes the
+# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and
+# passes TESTS_ENVIRONMENT. Set up options for the wrapper that
+# will run the test scripts (or their associated LOG_COMPILER, if
+# thy have one).
+am__check_pre = \
+$(am__sh_e_setup); \
+$(am__vpath_adj_setup) $(am__vpath_adj) \
+$(am__tty_colors); \
+srcdir=$(srcdir); export srcdir; \
+case "$@" in \
+ */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \
+ *) am__odir=.;; \
+esac; \
+test "x$$am__odir" = x"." || test -d "$$am__odir" \
+ || $(MKDIR_P) "$$am__odir" || exit $$?; \
+if test -f "./$$f"; then dir=./; \
+elif test -f "$$f"; then dir=; \
+else dir="$(srcdir)/"; fi; \
+tst=$$dir$$f; log='$@'; \
+if test -n '$(DISABLE_HARD_ERRORS)'; then \
+ am__enable_hard_errors=no; \
+else \
+ am__enable_hard_errors=yes; \
+fi; \
+case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \
+ am__expect_failure=yes;; \
+ *) \
+ am__expect_failure=no;; \
+esac; \
+$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT)
+# A shell command to get the names of the tests scripts with any registered
+# extension removed (i.e., equivalently, the names of the test logs, with
+# the '.log' extension removed). The result is saved in the shell variable
+# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly,
+# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)",
+# since that might cause problem with VPATH rewrites for suffix-less tests.
+# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'.
+am__set_TESTS_bases = \
+ bases='$(TEST_LOGS)'; \
+ bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \
+ bases=`echo $$bases`
+RECHECK_LOGS = $(TEST_LOGS)
+TEST_SUITE_LOG = test-suite.log
+TEST_EXTENSIONS = @EXEEXT@ .test
+LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver
+LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS)
+am__set_b = \
+ case '$@' in \
+ */*) \
+ case '$*' in \
+ */*) b='$*';; \
+ *) b=`echo '$@' | sed 's/\.log$$//'`; \
+ esac;; \
+ *) \
+ b='$*';; \
+ esac
+am__test_logs1 = $(TESTS:=.log)
+am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log)
+TEST_LOGS = $(am__test_logs2:.test.log=.log)
+TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver
+TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \
+ $(TEST_LOG_FLAGS)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+distdir = $(PACKAGE)-$(VERSION)
+top_distdir = $(distdir)
+am__remove_distdir = \
+ if test -d "$(distdir)"; then \
+ find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
+ && rm -rf "$(distdir)" \
+ || { sleep 5 && rm -rf "$(distdir)"; }; \
+ else :; fi
+am__post_remove_distdir = $(am__remove_distdir)
+DIST_ARCHIVES = $(distdir).tar.gz
+GZIP_ENV = --best
+DIST_TARGETS = dist-gzip
+distuninstallcheck_listfiles = find . -type f -print
+am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
+ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
+distcleancheck_listfiles = find . -type f -print
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GFLAGS_CFLAGS = @GFLAGS_CFLAGS@
+GFLAGS_LIBS = @GFLAGS_LIBS@
+GMOCK_CFLAGS = @GMOCK_CFLAGS@
+GMOCK_CONFIG = @GMOCK_CONFIG@
+GMOCK_LIBS = @GMOCK_LIBS@
+GREP = @GREP@
+GTEST_CFLAGS = @GTEST_CFLAGS@
+GTEST_CONFIG = @GTEST_CONFIG@
+GTEST_LIBS = @GTEST_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBTOOL_DEPS = @LIBTOOL_DEPS@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MINGW_CFLAGS = @MINGW_CFLAGS@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+UNWIND_LIBS = @UNWIND_LIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_cv___attribute___noinline = @ac_cv___attribute___noinline@
+ac_cv___attribute___noreturn = @ac_cv___attribute___noreturn@
+ac_cv___attribute___printf_4_5 = @ac_cv___attribute___printf_4_5@
+ac_cv_cxx_using_operator = @ac_cv_cxx_using_operator@
+ac_cv_have___builtin_expect = @ac_cv_have___builtin_expect@
+ac_cv_have___uint16 = @ac_cv_have___uint16@
+ac_cv_have_inttypes_h = @ac_cv_have_inttypes_h@
+ac_cv_have_libgflags = @ac_cv_have_libgflags@
+ac_cv_have_stdint_h = @ac_cv_have_stdint_h@
+ac_cv_have_systypes_h = @ac_cv_have_systypes_h@
+ac_cv_have_u_int16_t = @ac_cv_have_u_int16_t@
+ac_cv_have_uint16_t = @ac_cv_have_uint16_t@
+ac_cv_have_unistd_h = @ac_cv_have_unistd_h@
+ac_google_end_namespace = @ac_google_end_namespace@
+ac_google_namespace = @ac_google_namespace@
+ac_google_start_namespace = @ac_google_start_namespace@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = $(prefix)/share/doc/$(PACKAGE)-$(VERSION)
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = subdir-objects
+
+# Make sure that when we re-make ./configure, we get the macros we need
+ACLOCAL_AMFLAGS = -I m4
+
+# This is so we can #include <glog/foo>
+AM_CPPFLAGS = -I$(top_srcdir)/src
+
+# This is mostly based on configure options
+AM_CXXFLAGS = $(am__append_1) $(am__append_2) $(am__append_3) \
+ $(am__append_4)
+glogincludedir = $(includedir)/glog
+gloginclude_HEADERS = src/glog/log_severity.h
+nodist_gloginclude_HEADERS = src/glog/logging.h src/glog/raw_logging.h src/glog/vlog_is_on.h src/glog/stl_logging.h src/glog/nstack_glog_in.h src/glog/nstack_glog.ph src/glog/nstack_adapter.ph
+noinst_HEADERS = src/glog/logging.h.in src/glog/raw_logging.h.in src/glog/vlog_is_on.h.in src/glog/stl_logging.h.in
+dist_doc_DATA = AUTHORS COPYING ChangeLog INSTALL NEWS README README.windows \
+ doc/designstyle.css doc/glog.html
+
+lib_LTLIBRARIES = libglog.la
+
+# The libraries libglog depends on.
+COMMON_LIBS = $(PTHREAD_LIBS) $(GFLAGS_LIBS) $(UNWIND_LIBS)
+# Compile switches for our unittest.
+TEST_CFLAGS = $(GTEST_CFLAGS) $(GMOCK_CFLAGS) $(GFLAGS_CFLAGS) \
+ $(MINGW_CFLAGS) $(AM_CXXFLAGS)
+
+# Libraries for our unittest.
+TEST_LIBS = $(GTEST_LIBS) $(GMOCK_LIBS) $(GFLAGS_LIBS)
+TESTS_ENVIRONMENT =
+check_SCRIPTS = logging_striplog_test_sh demangle_unittest_sh \
+ signalhandler_unittest_sh
+# Every time you add a unittest to check_SCRIPTS, add it here too
+noinst_SCRIPTS = src/logging_striplog_test.sh src/demangle_unittest.sh \
+ src/signalhandler_unittest.sh
+# Binaries used for script-based unittests.
+TEST_BINARIES = logging_striptest0 logging_striptest2 \
+ logging_striptest10 signalhandler_unittest
+logging_unittest_SOURCES = $(gloginclude_HEADERS) \
+ src/logging_unittest.cc \
+ src/config_for_unittests.h \
+ src/mock-log.h
+
+nodist_logging_unittest_SOURCES = $(nodist_gloginclude_HEADERS)
+logging_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
+logging_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
+logging_unittest_LDADD = libglog.la $(COMMON_LIBS) $(TEST_LIBS)
+logging_striptest0_SOURCES = $(gloginclude_HEADERS) \
+ src/logging_striptest_main.cc
+
+nodist_logging_striptest0_SOURCES = $(nodist_gloginclude_HEADERS)
+logging_striptest0_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
+logging_striptest0_LDFLAGS = $(PTHREAD_CFLAGS)
+logging_striptest0_LDADD = libglog.la $(COMMON_LIBS)
+logging_striptest2_SOURCES = $(gloginclude_HEADERS) \
+ src/logging_striptest2.cc
+
+nodist_logging_striptest2_SOURCES = $(nodist_gloginclude_HEADERS)
+logging_striptest2_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
+logging_striptest2_LDFLAGS = $(PTHREAD_CFLAGS)
+logging_striptest2_LDADD = libglog.la $(COMMON_LIBS)
+logging_striptest10_SOURCES = $(gloginclude_HEADERS) \
+ src/logging_striptest10.cc
+
+nodist_logging_striptest10_SOURCES = $(nodist_gloginclude_HEADERS)
+logging_striptest10_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
+logging_striptest10_LDFLAGS = $(PTHREAD_CFLAGS)
+logging_striptest10_LDADD = libglog.la $(COMMON_LIBS)
+demangle_unittest_SOURCES = $(gloginclude_HEADERS) \
+ src/demangle_unittest.cc
+
+nodist_demangle_unittest_SOURCES = $(nodist_gloginclude_HEADERS)
+demangle_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
+demangle_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
+demangle_unittest_LDADD = libglog.la $(COMMON_LIBS) $(TEST_LIBS)
+stacktrace_unittest_SOURCES = $(gloginclude_HEADERS) \
+ src/stacktrace_unittest.cc
+
+nodist_stacktrace_unittest_SOURCES = $(nodist_gloginclude_HEADERS)
+stacktrace_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
+stacktrace_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
+stacktrace_unittest_LDADD = libglog.la $(COMMON_LIBS)
+symbolize_unittest_SOURCES = $(gloginclude_HEADERS) \
+ src/symbolize_unittest.cc
+
+nodist_symbolize_unittest_SOURCES = $(nodist_gloginclude_HEADERS)
+symbolize_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
+symbolize_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
+symbolize_unittest_LDADD = libglog.la $(COMMON_LIBS) $(TEST_LIBS)
+stl_logging_unittest_SOURCES = $(gloginclude_HEADERS) \
+ src/stl_logging_unittest.cc
+
+nodist_stl_logging_unittest_SOURCES = $(nodist_gloginclude_HEADERS)
+stl_logging_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
+stl_logging_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
+stl_logging_unittest_LDADD = libglog.la $(COMMON_LIBS) $(TEST_LIBS)
+signalhandler_unittest_SOURCES = $(gloginclude_HEADERS) \
+ src/signalhandler_unittest.cc
+
+nodist_signalhandler_unittest_SOURCES = $(nodist_gloginclude_HEADERS)
+signalhandler_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
+signalhandler_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
+signalhandler_unittest_LDADD = libglog.la $(COMMON_LIBS) $(TEST_LIBS)
+utilities_unittest_SOURCES = $(gloginclude_HEADERS) \
+ src/utilities_unittest.cc
+
+nodist_utilities_unittest_SOURCES = $(nodist_gloginclude_HEADERS)
+utilities_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
+utilities_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
+utilities_unittest_LDADD = libglog.la $(COMMON_LIBS) $(TEST_LIBS)
+@HAVE_GMOCK_TRUE@mock_log_test_SOURCES = $(gloginclude_HEADERS) \
+@HAVE_GMOCK_TRUE@ src/mock-log_test.cc
+
+@HAVE_GMOCK_TRUE@nodist_mock_log_test_SOURCES = $(nodist_gloginclude_HEADERS)
+@HAVE_GMOCK_TRUE@mock_log_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
+@HAVE_GMOCK_TRUE@mock_log_test_LDFLAGS = $(PTHREAD_CFLAGS)
+@HAVE_GMOCK_TRUE@mock_log_test_LDADD = libglog.la $(COMMON_LIBS) $(TEST_LIBS)
+libglog_la_SOURCES = $(gloginclude_HEADERS) \
+ src/logging.cc src/raw_logging.cc src/vlog_is_on.cc \
+ src/utilities.cc src/utilities.h \
+ src/demangle.cc src/demangle.h \
+ src/stacktrace.h \
+ src/stacktrace_generic-inl.h \
+ src/stacktrace_libunwind-inl.h \
+ src/stacktrace_powerpc-inl.h \
+ src/stacktrace_x86-inl.h \
+ src/stacktrace_x86_64-inl.h \
+ src/symbolize.cc src/symbolize.h \
+ src/signalhandler.cc \
+ src/base/mutex.h src/base/googleinit.h \
+ src/base/commandlineflags.h src/googletest.h \
+ src/nstack_logging.cc src/glog/nstack_glog_in.h src/glog/nstack_glog.ph src/glog/nstack_adapter.ph
+
+nodist_libglog_la_SOURCES = $(nodist_gloginclude_HEADERS)
+libglog_la_CXXFLAGS = $(PTRHEAD_CFLAGS) $(GFLAGS_CFLAGS) $(MINGW_CFLAGS) \
+ $(AM_CXXFLAGS) -DNDEBUG
+
+libglog_la_LDFLAGS = $(PTRHEAD_CFLAGS) $(GFLAGS_LDFLAGS)
+libglog_la_LIBADD = $(COMMON_LIBS)
+WINDOWS_PROJECTS = google-glog.sln vsprojects/libglog/libglog.vcproj \
+ vsprojects/logging_unittest/logging_unittest.vcproj \
+ vsprojects/libglog_static/libglog_static.vcproj \
+ vsprojects/logging_unittest_static/logging_unittest_static.vcproj
+EXTRA_DIST = packages/rpm.sh packages/rpm/rpm.spec \
+ packages/deb.sh packages/deb/* \
+ $(SCRIPTS) src/logging_unittest.err src/demangle_unittest.txt \
+ src/windows/config.h src/windows/port.h src/windows/port.cc \
+ src/windows/preprocess.sh \
+ src/windows/glog/log_severity.h src/windows/glog/logging.h \
+ src/windows/glog/raw_logging.h src/windows/glog/stl_logging.h \
+ src/windows/glog/vlog_is_on.h \
+ src/glog/nstack_glog_in.h src/glog/nstack_glog.ph src/glog/nstack_adapter.ph \
+ $(WINDOWS_PROJECTS)
+
+CLEANFILES = core demangle.dm demangle.nm signalhandler.out* \
+ signalhandler_unittest.*.log.INFO.*
+
+
+# Add pkgconfig file
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = libglog.pc
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cc .lo .log .o .obj .test .test$(EXEEXT) .trs
+am--refresh: Makefile
+ @:
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \
+ $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ echo ' $(SHELL) ./config.status'; \
+ $(SHELL) ./config.status;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ $(SHELL) ./config.status --recheck
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ $(am__cd) $(srcdir) && $(AUTOCONF)
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
+$(am__aclocal_m4_deps):
+
+src/config.h: src/stamp-h1
+ @if test ! -f $@; then rm -f src/stamp-h1; else :; fi
+ @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) src/stamp-h1; else :; fi
+
+src/stamp-h1: $(top_srcdir)/src/config.h.in $(top_builddir)/config.status
+ @rm -f src/stamp-h1
+ cd $(top_builddir) && $(SHELL) ./config.status src/config.h
+$(top_srcdir)/src/config.h.in: $(am__configure_deps)
+ ($(am__cd) $(top_srcdir) && $(AUTOHEADER))
+ rm -f src/stamp-h1
+ touch $@
+
+distclean-hdr:
+ -rm -f src/config.h src/stamp-h1
+src/glog/logging.h: $(top_builddir)/config.status $(top_srcdir)/src/glog/logging.h.in
+ cd $(top_builddir) && $(SHELL) ./config.status $@
+src/glog/raw_logging.h: $(top_builddir)/config.status $(top_srcdir)/src/glog/raw_logging.h.in
+ cd $(top_builddir) && $(SHELL) ./config.status $@
+src/glog/vlog_is_on.h: $(top_builddir)/config.status $(top_srcdir)/src/glog/vlog_is_on.h.in
+ cd $(top_builddir) && $(SHELL) ./config.status $@
+src/glog/stl_logging.h: $(top_builddir)/config.status $(top_srcdir)/src/glog/stl_logging.h.in
+ cd $(top_builddir) && $(SHELL) ./config.status $@
+libglog.pc: $(top_builddir)/config.status $(srcdir)/libglog.pc.in
+ cd $(top_builddir) && $(SHELL) ./config.status $@
+
+install-libLTLIBRARIES: $(lib_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+ list2=; for p in $$list; do \
+ if test -f $$p; then \
+ list2="$$list2 $$p"; \
+ else :; fi; \
+ done; \
+ test -z "$$list2" || { \
+ echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
+ }
+
+uninstall-libLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+ for p in $$list; do \
+ $(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
+ done
+
+clean-libLTLIBRARIES:
+ -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
+ @list='$(lib_LTLIBRARIES)'; \
+ locs=`for p in $$list; do echo $$p; done | \
+ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+ sort -u`; \
+ test -z "$$locs" || { \
+ echo rm -f $${locs}; \
+ rm -f $${locs}; \
+ }
+src/$(am__dirstamp):
+ @$(MKDIR_P) src
+ @: > src/$(am__dirstamp)
+src/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/$(DEPDIR)
+ @: > src/$(DEPDIR)/$(am__dirstamp)
+src/libglog_la-logging.lo: src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+src/libglog_la-raw_logging.lo: src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+src/libglog_la-vlog_is_on.lo: src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+src/libglog_la-utilities.lo: src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+src/libglog_la-demangle.lo: src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+src/libglog_la-symbolize.lo: src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+src/libglog_la-signalhandler.lo: src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+src/libglog_la-nstack_logging.lo: src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+
+libglog.la: $(libglog_la_OBJECTS) $(libglog_la_DEPENDENCIES) $(EXTRA_libglog_la_DEPENDENCIES)
+ $(AM_V_CXXLD)$(libglog_la_LINK) -rpath $(libdir) $(libglog_la_OBJECTS) $(libglog_la_LIBADD) $(LIBS)
+
+clean-noinstPROGRAMS:
+ @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
+ echo " rm -f" $$list; \
+ rm -f $$list || exit $$?; \
+ test -n "$(EXEEXT)" || exit 0; \
+ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f" $$list; \
+ rm -f $$list
+src/demangle_unittest-demangle_unittest.$(OBJEXT): \
+ src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
+
+demangle_unittest$(EXEEXT): $(demangle_unittest_OBJECTS) $(demangle_unittest_DEPENDENCIES) $(EXTRA_demangle_unittest_DEPENDENCIES)
+ @rm -f demangle_unittest$(EXEEXT)
+ $(AM_V_CXXLD)$(demangle_unittest_LINK) $(demangle_unittest_OBJECTS) $(demangle_unittest_LDADD) $(LIBS)
+src/logging_striptest0-logging_striptest_main.$(OBJEXT): \
+ src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
+
+logging_striptest0$(EXEEXT): $(logging_striptest0_OBJECTS) $(logging_striptest0_DEPENDENCIES) $(EXTRA_logging_striptest0_DEPENDENCIES)
+ @rm -f logging_striptest0$(EXEEXT)
+ $(AM_V_CXXLD)$(logging_striptest0_LINK) $(logging_striptest0_OBJECTS) $(logging_striptest0_LDADD) $(LIBS)
+src/logging_striptest10-logging_striptest10.$(OBJEXT): \
+ src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
+
+logging_striptest10$(EXEEXT): $(logging_striptest10_OBJECTS) $(logging_striptest10_DEPENDENCIES) $(EXTRA_logging_striptest10_DEPENDENCIES)
+ @rm -f logging_striptest10$(EXEEXT)
+ $(AM_V_CXXLD)$(logging_striptest10_LINK) $(logging_striptest10_OBJECTS) $(logging_striptest10_LDADD) $(LIBS)
+src/logging_striptest2-logging_striptest2.$(OBJEXT): \
+ src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
+
+logging_striptest2$(EXEEXT): $(logging_striptest2_OBJECTS) $(logging_striptest2_DEPENDENCIES) $(EXTRA_logging_striptest2_DEPENDENCIES)
+ @rm -f logging_striptest2$(EXEEXT)
+ $(AM_V_CXXLD)$(logging_striptest2_LINK) $(logging_striptest2_OBJECTS) $(logging_striptest2_LDADD) $(LIBS)
+src/logging_unittest-logging_unittest.$(OBJEXT): src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+
+logging_unittest$(EXEEXT): $(logging_unittest_OBJECTS) $(logging_unittest_DEPENDENCIES) $(EXTRA_logging_unittest_DEPENDENCIES)
+ @rm -f logging_unittest$(EXEEXT)
+ $(AM_V_CXXLD)$(logging_unittest_LINK) $(logging_unittest_OBJECTS) $(logging_unittest_LDADD) $(LIBS)
+src/mock_log_test-mock-log_test.$(OBJEXT): src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+
+mock_log_test$(EXEEXT): $(mock_log_test_OBJECTS) $(mock_log_test_DEPENDENCIES) $(EXTRA_mock_log_test_DEPENDENCIES)
+ @rm -f mock_log_test$(EXEEXT)
+ $(AM_V_CXXLD)$(mock_log_test_LINK) $(mock_log_test_OBJECTS) $(mock_log_test_LDADD) $(LIBS)
+src/signalhandler_unittest-signalhandler_unittest.$(OBJEXT): \
+ src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
+
+signalhandler_unittest$(EXEEXT): $(signalhandler_unittest_OBJECTS) $(signalhandler_unittest_DEPENDENCIES) $(EXTRA_signalhandler_unittest_DEPENDENCIES)
+ @rm -f signalhandler_unittest$(EXEEXT)
+ $(AM_V_CXXLD)$(signalhandler_unittest_LINK) $(signalhandler_unittest_OBJECTS) $(signalhandler_unittest_LDADD) $(LIBS)
+src/stacktrace_unittest-stacktrace_unittest.$(OBJEXT): \
+ src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
+
+stacktrace_unittest$(EXEEXT): $(stacktrace_unittest_OBJECTS) $(stacktrace_unittest_DEPENDENCIES) $(EXTRA_stacktrace_unittest_DEPENDENCIES)
+ @rm -f stacktrace_unittest$(EXEEXT)
+ $(AM_V_CXXLD)$(stacktrace_unittest_LINK) $(stacktrace_unittest_OBJECTS) $(stacktrace_unittest_LDADD) $(LIBS)
+src/stl_logging_unittest-stl_logging_unittest.$(OBJEXT): \
+ src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
+
+stl_logging_unittest$(EXEEXT): $(stl_logging_unittest_OBJECTS) $(stl_logging_unittest_DEPENDENCIES) $(EXTRA_stl_logging_unittest_DEPENDENCIES)
+ @rm -f stl_logging_unittest$(EXEEXT)
+ $(AM_V_CXXLD)$(stl_logging_unittest_LINK) $(stl_logging_unittest_OBJECTS) $(stl_logging_unittest_LDADD) $(LIBS)
+src/symbolize_unittest-symbolize_unittest.$(OBJEXT): \
+ src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
+
+symbolize_unittest$(EXEEXT): $(symbolize_unittest_OBJECTS) $(symbolize_unittest_DEPENDENCIES) $(EXTRA_symbolize_unittest_DEPENDENCIES)
+ @rm -f symbolize_unittest$(EXEEXT)
+ $(AM_V_CXXLD)$(symbolize_unittest_LINK) $(symbolize_unittest_OBJECTS) $(symbolize_unittest_LDADD) $(LIBS)
+src/utilities_unittest-utilities_unittest.$(OBJEXT): \
+ src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
+
+utilities_unittest$(EXEEXT): $(utilities_unittest_OBJECTS) $(utilities_unittest_DEPENDENCIES) $(EXTRA_utilities_unittest_DEPENDENCIES)
+ @rm -f utilities_unittest$(EXEEXT)
+ $(AM_V_CXXLD)$(utilities_unittest_LINK) $(utilities_unittest_OBJECTS) $(utilities_unittest_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+ -rm -f src/*.$(OBJEXT)
+ -rm -f src/*.lo
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/demangle_unittest-demangle_unittest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libglog_la-demangle.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libglog_la-logging.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libglog_la-nstack_logging.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libglog_la-raw_logging.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libglog_la-signalhandler.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libglog_la-symbolize.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libglog_la-utilities.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libglog_la-vlog_is_on.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/logging_striptest0-logging_striptest_main.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/logging_striptest10-logging_striptest10.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/logging_striptest2-logging_striptest2.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/logging_unittest-logging_unittest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/mock_log_test-mock-log_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/signalhandler_unittest-signalhandler_unittest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/stacktrace_unittest-stacktrace_unittest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/stl_logging_unittest-stl_logging_unittest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/symbolize_unittest-symbolize_unittest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/utilities_unittest-utilities_unittest.Po@am__quote@
+
+.cc.o:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
+@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $<
+
+.cc.obj:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
+@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
+@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cc.lo:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
+@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
+
+src/libglog_la-logging.lo: src/logging.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libglog_la_CXXFLAGS) $(CXXFLAGS) -MT src/libglog_la-logging.lo -MD -MP -MF src/$(DEPDIR)/libglog_la-logging.Tpo -c -o src/libglog_la-logging.lo `test -f 'src/logging.cc' || echo '$(srcdir)/'`src/logging.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libglog_la-logging.Tpo src/$(DEPDIR)/libglog_la-logging.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/logging.cc' object='src/libglog_la-logging.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libglog_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libglog_la-logging.lo `test -f 'src/logging.cc' || echo '$(srcdir)/'`src/logging.cc
+
+src/libglog_la-raw_logging.lo: src/raw_logging.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libglog_la_CXXFLAGS) $(CXXFLAGS) -MT src/libglog_la-raw_logging.lo -MD -MP -MF src/$(DEPDIR)/libglog_la-raw_logging.Tpo -c -o src/libglog_la-raw_logging.lo `test -f 'src/raw_logging.cc' || echo '$(srcdir)/'`src/raw_logging.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libglog_la-raw_logging.Tpo src/$(DEPDIR)/libglog_la-raw_logging.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/raw_logging.cc' object='src/libglog_la-raw_logging.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libglog_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libglog_la-raw_logging.lo `test -f 'src/raw_logging.cc' || echo '$(srcdir)/'`src/raw_logging.cc
+
+src/libglog_la-vlog_is_on.lo: src/vlog_is_on.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libglog_la_CXXFLAGS) $(CXXFLAGS) -MT src/libglog_la-vlog_is_on.lo -MD -MP -MF src/$(DEPDIR)/libglog_la-vlog_is_on.Tpo -c -o src/libglog_la-vlog_is_on.lo `test -f 'src/vlog_is_on.cc' || echo '$(srcdir)/'`src/vlog_is_on.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libglog_la-vlog_is_on.Tpo src/$(DEPDIR)/libglog_la-vlog_is_on.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/vlog_is_on.cc' object='src/libglog_la-vlog_is_on.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libglog_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libglog_la-vlog_is_on.lo `test -f 'src/vlog_is_on.cc' || echo '$(srcdir)/'`src/vlog_is_on.cc
+
+src/libglog_la-utilities.lo: src/utilities.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libglog_la_CXXFLAGS) $(CXXFLAGS) -MT src/libglog_la-utilities.lo -MD -MP -MF src/$(DEPDIR)/libglog_la-utilities.Tpo -c -o src/libglog_la-utilities.lo `test -f 'src/utilities.cc' || echo '$(srcdir)/'`src/utilities.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libglog_la-utilities.Tpo src/$(DEPDIR)/libglog_la-utilities.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/utilities.cc' object='src/libglog_la-utilities.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libglog_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libglog_la-utilities.lo `test -f 'src/utilities.cc' || echo '$(srcdir)/'`src/utilities.cc
+
+src/libglog_la-demangle.lo: src/demangle.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libglog_la_CXXFLAGS) $(CXXFLAGS) -MT src/libglog_la-demangle.lo -MD -MP -MF src/$(DEPDIR)/libglog_la-demangle.Tpo -c -o src/libglog_la-demangle.lo `test -f 'src/demangle.cc' || echo '$(srcdir)/'`src/demangle.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libglog_la-demangle.Tpo src/$(DEPDIR)/libglog_la-demangle.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/demangle.cc' object='src/libglog_la-demangle.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libglog_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libglog_la-demangle.lo `test -f 'src/demangle.cc' || echo '$(srcdir)/'`src/demangle.cc
+
+src/libglog_la-symbolize.lo: src/symbolize.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libglog_la_CXXFLAGS) $(CXXFLAGS) -MT src/libglog_la-symbolize.lo -MD -MP -MF src/$(DEPDIR)/libglog_la-symbolize.Tpo -c -o src/libglog_la-symbolize.lo `test -f 'src/symbolize.cc' || echo '$(srcdir)/'`src/symbolize.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libglog_la-symbolize.Tpo src/$(DEPDIR)/libglog_la-symbolize.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/symbolize.cc' object='src/libglog_la-symbolize.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libglog_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libglog_la-symbolize.lo `test -f 'src/symbolize.cc' || echo '$(srcdir)/'`src/symbolize.cc
+
+src/libglog_la-signalhandler.lo: src/signalhandler.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libglog_la_CXXFLAGS) $(CXXFLAGS) -MT src/libglog_la-signalhandler.lo -MD -MP -MF src/$(DEPDIR)/libglog_la-signalhandler.Tpo -c -o src/libglog_la-signalhandler.lo `test -f 'src/signalhandler.cc' || echo '$(srcdir)/'`src/signalhandler.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libglog_la-signalhandler.Tpo src/$(DEPDIR)/libglog_la-signalhandler.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/signalhandler.cc' object='src/libglog_la-signalhandler.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libglog_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libglog_la-signalhandler.lo `test -f 'src/signalhandler.cc' || echo '$(srcdir)/'`src/signalhandler.cc
+
+src/libglog_la-nstack_logging.lo: src/nstack_logging.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libglog_la_CXXFLAGS) $(CXXFLAGS) -MT src/libglog_la-nstack_logging.lo -MD -MP -MF src/$(DEPDIR)/libglog_la-nstack_logging.Tpo -c -o src/libglog_la-nstack_logging.lo `test -f 'src/nstack_logging.cc' || echo '$(srcdir)/'`src/nstack_logging.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libglog_la-nstack_logging.Tpo src/$(DEPDIR)/libglog_la-nstack_logging.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/nstack_logging.cc' object='src/libglog_la-nstack_logging.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libglog_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libglog_la-nstack_logging.lo `test -f 'src/nstack_logging.cc' || echo '$(srcdir)/'`src/nstack_logging.cc
+
+src/demangle_unittest-demangle_unittest.o: src/demangle_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(demangle_unittest_CXXFLAGS) $(CXXFLAGS) -MT src/demangle_unittest-demangle_unittest.o -MD -MP -MF src/$(DEPDIR)/demangle_unittest-demangle_unittest.Tpo -c -o src/demangle_unittest-demangle_unittest.o `test -f 'src/demangle_unittest.cc' || echo '$(srcdir)/'`src/demangle_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/demangle_unittest-demangle_unittest.Tpo src/$(DEPDIR)/demangle_unittest-demangle_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/demangle_unittest.cc' object='src/demangle_unittest-demangle_unittest.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(demangle_unittest_CXXFLAGS) $(CXXFLAGS) -c -o src/demangle_unittest-demangle_unittest.o `test -f 'src/demangle_unittest.cc' || echo '$(srcdir)/'`src/demangle_unittest.cc
+
+src/demangle_unittest-demangle_unittest.obj: src/demangle_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(demangle_unittest_CXXFLAGS) $(CXXFLAGS) -MT src/demangle_unittest-demangle_unittest.obj -MD -MP -MF src/$(DEPDIR)/demangle_unittest-demangle_unittest.Tpo -c -o src/demangle_unittest-demangle_unittest.obj `if test -f 'src/demangle_unittest.cc'; then $(CYGPATH_W) 'src/demangle_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/src/demangle_unittest.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/demangle_unittest-demangle_unittest.Tpo src/$(DEPDIR)/demangle_unittest-demangle_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/demangle_unittest.cc' object='src/demangle_unittest-demangle_unittest.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(demangle_unittest_CXXFLAGS) $(CXXFLAGS) -c -o src/demangle_unittest-demangle_unittest.obj `if test -f 'src/demangle_unittest.cc'; then $(CYGPATH_W) 'src/demangle_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/src/demangle_unittest.cc'; fi`
+
+src/logging_striptest0-logging_striptest_main.o: src/logging_striptest_main.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(logging_striptest0_CXXFLAGS) $(CXXFLAGS) -MT src/logging_striptest0-logging_striptest_main.o -MD -MP -MF src/$(DEPDIR)/logging_striptest0-logging_striptest_main.Tpo -c -o src/logging_striptest0-logging_striptest_main.o `test -f 'src/logging_striptest_main.cc' || echo '$(srcdir)/'`src/logging_striptest_main.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/logging_striptest0-logging_striptest_main.Tpo src/$(DEPDIR)/logging_striptest0-logging_striptest_main.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/logging_striptest_main.cc' object='src/logging_striptest0-logging_striptest_main.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(logging_striptest0_CXXFLAGS) $(CXXFLAGS) -c -o src/logging_striptest0-logging_striptest_main.o `test -f 'src/logging_striptest_main.cc' || echo '$(srcdir)/'`src/logging_striptest_main.cc
+
+src/logging_striptest0-logging_striptest_main.obj: src/logging_striptest_main.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(logging_striptest0_CXXFLAGS) $(CXXFLAGS) -MT src/logging_striptest0-logging_striptest_main.obj -MD -MP -MF src/$(DEPDIR)/logging_striptest0-logging_striptest_main.Tpo -c -o src/logging_striptest0-logging_striptest_main.obj `if test -f 'src/logging_striptest_main.cc'; then $(CYGPATH_W) 'src/logging_striptest_main.cc'; else $(CYGPATH_W) '$(srcdir)/src/logging_striptest_main.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/logging_striptest0-logging_striptest_main.Tpo src/$(DEPDIR)/logging_striptest0-logging_striptest_main.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/logging_striptest_main.cc' object='src/logging_striptest0-logging_striptest_main.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(logging_striptest0_CXXFLAGS) $(CXXFLAGS) -c -o src/logging_striptest0-logging_striptest_main.obj `if test -f 'src/logging_striptest_main.cc'; then $(CYGPATH_W) 'src/logging_striptest_main.cc'; else $(CYGPATH_W) '$(srcdir)/src/logging_striptest_main.cc'; fi`
+
+src/logging_striptest10-logging_striptest10.o: src/logging_striptest10.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(logging_striptest10_CXXFLAGS) $(CXXFLAGS) -MT src/logging_striptest10-logging_striptest10.o -MD -MP -MF src/$(DEPDIR)/logging_striptest10-logging_striptest10.Tpo -c -o src/logging_striptest10-logging_striptest10.o `test -f 'src/logging_striptest10.cc' || echo '$(srcdir)/'`src/logging_striptest10.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/logging_striptest10-logging_striptest10.Tpo src/$(DEPDIR)/logging_striptest10-logging_striptest10.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/logging_striptest10.cc' object='src/logging_striptest10-logging_striptest10.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(logging_striptest10_CXXFLAGS) $(CXXFLAGS) -c -o src/logging_striptest10-logging_striptest10.o `test -f 'src/logging_striptest10.cc' || echo '$(srcdir)/'`src/logging_striptest10.cc
+
+src/logging_striptest10-logging_striptest10.obj: src/logging_striptest10.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(logging_striptest10_CXXFLAGS) $(CXXFLAGS) -MT src/logging_striptest10-logging_striptest10.obj -MD -MP -MF src/$(DEPDIR)/logging_striptest10-logging_striptest10.Tpo -c -o src/logging_striptest10-logging_striptest10.obj `if test -f 'src/logging_striptest10.cc'; then $(CYGPATH_W) 'src/logging_striptest10.cc'; else $(CYGPATH_W) '$(srcdir)/src/logging_striptest10.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/logging_striptest10-logging_striptest10.Tpo src/$(DEPDIR)/logging_striptest10-logging_striptest10.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/logging_striptest10.cc' object='src/logging_striptest10-logging_striptest10.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(logging_striptest10_CXXFLAGS) $(CXXFLAGS) -c -o src/logging_striptest10-logging_striptest10.obj `if test -f 'src/logging_striptest10.cc'; then $(CYGPATH_W) 'src/logging_striptest10.cc'; else $(CYGPATH_W) '$(srcdir)/src/logging_striptest10.cc'; fi`
+
+src/logging_striptest2-logging_striptest2.o: src/logging_striptest2.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(logging_striptest2_CXXFLAGS) $(CXXFLAGS) -MT src/logging_striptest2-logging_striptest2.o -MD -MP -MF src/$(DEPDIR)/logging_striptest2-logging_striptest2.Tpo -c -o src/logging_striptest2-logging_striptest2.o `test -f 'src/logging_striptest2.cc' || echo '$(srcdir)/'`src/logging_striptest2.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/logging_striptest2-logging_striptest2.Tpo src/$(DEPDIR)/logging_striptest2-logging_striptest2.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/logging_striptest2.cc' object='src/logging_striptest2-logging_striptest2.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(logging_striptest2_CXXFLAGS) $(CXXFLAGS) -c -o src/logging_striptest2-logging_striptest2.o `test -f 'src/logging_striptest2.cc' || echo '$(srcdir)/'`src/logging_striptest2.cc
+
+src/logging_striptest2-logging_striptest2.obj: src/logging_striptest2.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(logging_striptest2_CXXFLAGS) $(CXXFLAGS) -MT src/logging_striptest2-logging_striptest2.obj -MD -MP -MF src/$(DEPDIR)/logging_striptest2-logging_striptest2.Tpo -c -o src/logging_striptest2-logging_striptest2.obj `if test -f 'src/logging_striptest2.cc'; then $(CYGPATH_W) 'src/logging_striptest2.cc'; else $(CYGPATH_W) '$(srcdir)/src/logging_striptest2.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/logging_striptest2-logging_striptest2.Tpo src/$(DEPDIR)/logging_striptest2-logging_striptest2.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/logging_striptest2.cc' object='src/logging_striptest2-logging_striptest2.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(logging_striptest2_CXXFLAGS) $(CXXFLAGS) -c -o src/logging_striptest2-logging_striptest2.obj `if test -f 'src/logging_striptest2.cc'; then $(CYGPATH_W) 'src/logging_striptest2.cc'; else $(CYGPATH_W) '$(srcdir)/src/logging_striptest2.cc'; fi`
+
+src/logging_unittest-logging_unittest.o: src/logging_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(logging_unittest_CXXFLAGS) $(CXXFLAGS) -MT src/logging_unittest-logging_unittest.o -MD -MP -MF src/$(DEPDIR)/logging_unittest-logging_unittest.Tpo -c -o src/logging_unittest-logging_unittest.o `test -f 'src/logging_unittest.cc' || echo '$(srcdir)/'`src/logging_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/logging_unittest-logging_unittest.Tpo src/$(DEPDIR)/logging_unittest-logging_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/logging_unittest.cc' object='src/logging_unittest-logging_unittest.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(logging_unittest_CXXFLAGS) $(CXXFLAGS) -c -o src/logging_unittest-logging_unittest.o `test -f 'src/logging_unittest.cc' || echo '$(srcdir)/'`src/logging_unittest.cc
+
+src/logging_unittest-logging_unittest.obj: src/logging_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(logging_unittest_CXXFLAGS) $(CXXFLAGS) -MT src/logging_unittest-logging_unittest.obj -MD -MP -MF src/$(DEPDIR)/logging_unittest-logging_unittest.Tpo -c -o src/logging_unittest-logging_unittest.obj `if test -f 'src/logging_unittest.cc'; then $(CYGPATH_W) 'src/logging_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/src/logging_unittest.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/logging_unittest-logging_unittest.Tpo src/$(DEPDIR)/logging_unittest-logging_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/logging_unittest.cc' object='src/logging_unittest-logging_unittest.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(logging_unittest_CXXFLAGS) $(CXXFLAGS) -c -o src/logging_unittest-logging_unittest.obj `if test -f 'src/logging_unittest.cc'; then $(CYGPATH_W) 'src/logging_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/src/logging_unittest.cc'; fi`
+
+src/mock_log_test-mock-log_test.o: src/mock-log_test.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mock_log_test_CXXFLAGS) $(CXXFLAGS) -MT src/mock_log_test-mock-log_test.o -MD -MP -MF src/$(DEPDIR)/mock_log_test-mock-log_test.Tpo -c -o src/mock_log_test-mock-log_test.o `test -f 'src/mock-log_test.cc' || echo '$(srcdir)/'`src/mock-log_test.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/mock_log_test-mock-log_test.Tpo src/$(DEPDIR)/mock_log_test-mock-log_test.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/mock-log_test.cc' object='src/mock_log_test-mock-log_test.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mock_log_test_CXXFLAGS) $(CXXFLAGS) -c -o src/mock_log_test-mock-log_test.o `test -f 'src/mock-log_test.cc' || echo '$(srcdir)/'`src/mock-log_test.cc
+
+src/mock_log_test-mock-log_test.obj: src/mock-log_test.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mock_log_test_CXXFLAGS) $(CXXFLAGS) -MT src/mock_log_test-mock-log_test.obj -MD -MP -MF src/$(DEPDIR)/mock_log_test-mock-log_test.Tpo -c -o src/mock_log_test-mock-log_test.obj `if test -f 'src/mock-log_test.cc'; then $(CYGPATH_W) 'src/mock-log_test.cc'; else $(CYGPATH_W) '$(srcdir)/src/mock-log_test.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/mock_log_test-mock-log_test.Tpo src/$(DEPDIR)/mock_log_test-mock-log_test.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/mock-log_test.cc' object='src/mock_log_test-mock-log_test.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(mock_log_test_CXXFLAGS) $(CXXFLAGS) -c -o src/mock_log_test-mock-log_test.obj `if test -f 'src/mock-log_test.cc'; then $(CYGPATH_W) 'src/mock-log_test.cc'; else $(CYGPATH_W) '$(srcdir)/src/mock-log_test.cc'; fi`
+
+src/signalhandler_unittest-signalhandler_unittest.o: src/signalhandler_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(signalhandler_unittest_CXXFLAGS) $(CXXFLAGS) -MT src/signalhandler_unittest-signalhandler_unittest.o -MD -MP -MF src/$(DEPDIR)/signalhandler_unittest-signalhandler_unittest.Tpo -c -o src/signalhandler_unittest-signalhandler_unittest.o `test -f 'src/signalhandler_unittest.cc' || echo '$(srcdir)/'`src/signalhandler_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/signalhandler_unittest-signalhandler_unittest.Tpo src/$(DEPDIR)/signalhandler_unittest-signalhandler_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/signalhandler_unittest.cc' object='src/signalhandler_unittest-signalhandler_unittest.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(signalhandler_unittest_CXXFLAGS) $(CXXFLAGS) -c -o src/signalhandler_unittest-signalhandler_unittest.o `test -f 'src/signalhandler_unittest.cc' || echo '$(srcdir)/'`src/signalhandler_unittest.cc
+
+src/signalhandler_unittest-signalhandler_unittest.obj: src/signalhandler_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(signalhandler_unittest_CXXFLAGS) $(CXXFLAGS) -MT src/signalhandler_unittest-signalhandler_unittest.obj -MD -MP -MF src/$(DEPDIR)/signalhandler_unittest-signalhandler_unittest.Tpo -c -o src/signalhandler_unittest-signalhandler_unittest.obj `if test -f 'src/signalhandler_unittest.cc'; then $(CYGPATH_W) 'src/signalhandler_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/src/signalhandler_unittest.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/signalhandler_unittest-signalhandler_unittest.Tpo src/$(DEPDIR)/signalhandler_unittest-signalhandler_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/signalhandler_unittest.cc' object='src/signalhandler_unittest-signalhandler_unittest.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(signalhandler_unittest_CXXFLAGS) $(CXXFLAGS) -c -o src/signalhandler_unittest-signalhandler_unittest.obj `if test -f 'src/signalhandler_unittest.cc'; then $(CYGPATH_W) 'src/signalhandler_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/src/signalhandler_unittest.cc'; fi`
+
+src/stacktrace_unittest-stacktrace_unittest.o: src/stacktrace_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(stacktrace_unittest_CXXFLAGS) $(CXXFLAGS) -MT src/stacktrace_unittest-stacktrace_unittest.o -MD -MP -MF src/$(DEPDIR)/stacktrace_unittest-stacktrace_unittest.Tpo -c -o src/stacktrace_unittest-stacktrace_unittest.o `test -f 'src/stacktrace_unittest.cc' || echo '$(srcdir)/'`src/stacktrace_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/stacktrace_unittest-stacktrace_unittest.Tpo src/$(DEPDIR)/stacktrace_unittest-stacktrace_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/stacktrace_unittest.cc' object='src/stacktrace_unittest-stacktrace_unittest.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(stacktrace_unittest_CXXFLAGS) $(CXXFLAGS) -c -o src/stacktrace_unittest-stacktrace_unittest.o `test -f 'src/stacktrace_unittest.cc' || echo '$(srcdir)/'`src/stacktrace_unittest.cc
+
+src/stacktrace_unittest-stacktrace_unittest.obj: src/stacktrace_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(stacktrace_unittest_CXXFLAGS) $(CXXFLAGS) -MT src/stacktrace_unittest-stacktrace_unittest.obj -MD -MP -MF src/$(DEPDIR)/stacktrace_unittest-stacktrace_unittest.Tpo -c -o src/stacktrace_unittest-stacktrace_unittest.obj `if test -f 'src/stacktrace_unittest.cc'; then $(CYGPATH_W) 'src/stacktrace_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/src/stacktrace_unittest.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/stacktrace_unittest-stacktrace_unittest.Tpo src/$(DEPDIR)/stacktrace_unittest-stacktrace_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/stacktrace_unittest.cc' object='src/stacktrace_unittest-stacktrace_unittest.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(stacktrace_unittest_CXXFLAGS) $(CXXFLAGS) -c -o src/stacktrace_unittest-stacktrace_unittest.obj `if test -f 'src/stacktrace_unittest.cc'; then $(CYGPATH_W) 'src/stacktrace_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/src/stacktrace_unittest.cc'; fi`
+
+src/stl_logging_unittest-stl_logging_unittest.o: src/stl_logging_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(stl_logging_unittest_CXXFLAGS) $(CXXFLAGS) -MT src/stl_logging_unittest-stl_logging_unittest.o -MD -MP -MF src/$(DEPDIR)/stl_logging_unittest-stl_logging_unittest.Tpo -c -o src/stl_logging_unittest-stl_logging_unittest.o `test -f 'src/stl_logging_unittest.cc' || echo '$(srcdir)/'`src/stl_logging_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/stl_logging_unittest-stl_logging_unittest.Tpo src/$(DEPDIR)/stl_logging_unittest-stl_logging_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/stl_logging_unittest.cc' object='src/stl_logging_unittest-stl_logging_unittest.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(stl_logging_unittest_CXXFLAGS) $(CXXFLAGS) -c -o src/stl_logging_unittest-stl_logging_unittest.o `test -f 'src/stl_logging_unittest.cc' || echo '$(srcdir)/'`src/stl_logging_unittest.cc
+
+src/stl_logging_unittest-stl_logging_unittest.obj: src/stl_logging_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(stl_logging_unittest_CXXFLAGS) $(CXXFLAGS) -MT src/stl_logging_unittest-stl_logging_unittest.obj -MD -MP -MF src/$(DEPDIR)/stl_logging_unittest-stl_logging_unittest.Tpo -c -o src/stl_logging_unittest-stl_logging_unittest.obj `if test -f 'src/stl_logging_unittest.cc'; then $(CYGPATH_W) 'src/stl_logging_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/src/stl_logging_unittest.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/stl_logging_unittest-stl_logging_unittest.Tpo src/$(DEPDIR)/stl_logging_unittest-stl_logging_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/stl_logging_unittest.cc' object='src/stl_logging_unittest-stl_logging_unittest.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(stl_logging_unittest_CXXFLAGS) $(CXXFLAGS) -c -o src/stl_logging_unittest-stl_logging_unittest.obj `if test -f 'src/stl_logging_unittest.cc'; then $(CYGPATH_W) 'src/stl_logging_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/src/stl_logging_unittest.cc'; fi`
+
+src/symbolize_unittest-symbolize_unittest.o: src/symbolize_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(symbolize_unittest_CXXFLAGS) $(CXXFLAGS) -MT src/symbolize_unittest-symbolize_unittest.o -MD -MP -MF src/$(DEPDIR)/symbolize_unittest-symbolize_unittest.Tpo -c -o src/symbolize_unittest-symbolize_unittest.o `test -f 'src/symbolize_unittest.cc' || echo '$(srcdir)/'`src/symbolize_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/symbolize_unittest-symbolize_unittest.Tpo src/$(DEPDIR)/symbolize_unittest-symbolize_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/symbolize_unittest.cc' object='src/symbolize_unittest-symbolize_unittest.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(symbolize_unittest_CXXFLAGS) $(CXXFLAGS) -c -o src/symbolize_unittest-symbolize_unittest.o `test -f 'src/symbolize_unittest.cc' || echo '$(srcdir)/'`src/symbolize_unittest.cc
+
+src/symbolize_unittest-symbolize_unittest.obj: src/symbolize_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(symbolize_unittest_CXXFLAGS) $(CXXFLAGS) -MT src/symbolize_unittest-symbolize_unittest.obj -MD -MP -MF src/$(DEPDIR)/symbolize_unittest-symbolize_unittest.Tpo -c -o src/symbolize_unittest-symbolize_unittest.obj `if test -f 'src/symbolize_unittest.cc'; then $(CYGPATH_W) 'src/symbolize_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/src/symbolize_unittest.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/symbolize_unittest-symbolize_unittest.Tpo src/$(DEPDIR)/symbolize_unittest-symbolize_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/symbolize_unittest.cc' object='src/symbolize_unittest-symbolize_unittest.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(symbolize_unittest_CXXFLAGS) $(CXXFLAGS) -c -o src/symbolize_unittest-symbolize_unittest.obj `if test -f 'src/symbolize_unittest.cc'; then $(CYGPATH_W) 'src/symbolize_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/src/symbolize_unittest.cc'; fi`
+
+src/utilities_unittest-utilities_unittest.o: src/utilities_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(utilities_unittest_CXXFLAGS) $(CXXFLAGS) -MT src/utilities_unittest-utilities_unittest.o -MD -MP -MF src/$(DEPDIR)/utilities_unittest-utilities_unittest.Tpo -c -o src/utilities_unittest-utilities_unittest.o `test -f 'src/utilities_unittest.cc' || echo '$(srcdir)/'`src/utilities_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/utilities_unittest-utilities_unittest.Tpo src/$(DEPDIR)/utilities_unittest-utilities_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/utilities_unittest.cc' object='src/utilities_unittest-utilities_unittest.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(utilities_unittest_CXXFLAGS) $(CXXFLAGS) -c -o src/utilities_unittest-utilities_unittest.o `test -f 'src/utilities_unittest.cc' || echo '$(srcdir)/'`src/utilities_unittest.cc
+
+src/utilities_unittest-utilities_unittest.obj: src/utilities_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(utilities_unittest_CXXFLAGS) $(CXXFLAGS) -MT src/utilities_unittest-utilities_unittest.obj -MD -MP -MF src/$(DEPDIR)/utilities_unittest-utilities_unittest.Tpo -c -o src/utilities_unittest-utilities_unittest.obj `if test -f 'src/utilities_unittest.cc'; then $(CYGPATH_W) 'src/utilities_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/src/utilities_unittest.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/utilities_unittest-utilities_unittest.Tpo src/$(DEPDIR)/utilities_unittest-utilities_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/utilities_unittest.cc' object='src/utilities_unittest-utilities_unittest.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(utilities_unittest_CXXFLAGS) $(CXXFLAGS) -c -o src/utilities_unittest-utilities_unittest.obj `if test -f 'src/utilities_unittest.cc'; then $(CYGPATH_W) 'src/utilities_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/src/utilities_unittest.cc'; fi`
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+ -rm -rf src/.libs src/_libs
+
+distclean-libtool:
+ -rm -f libtool config.lt
+install-dist_docDATA: $(dist_doc_DATA)
+ @$(NORMAL_INSTALL)
+ @list='$(dist_doc_DATA)'; test -n "$(docdir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(docdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(docdir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(docdir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(docdir)" || exit $$?; \
+ done
+
+uninstall-dist_docDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(dist_doc_DATA)'; test -n "$(docdir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ dir='$(DESTDIR)$(docdir)'; $(am__uninstall_files_from_dir)
+install-pkgconfigDATA: $(pkgconfig_DATA)
+ @$(NORMAL_INSTALL)
+ @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(pkgconfigdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \
+ done
+
+uninstall-pkgconfigDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir)
+install-glogincludeHEADERS: $(gloginclude_HEADERS)
+ @$(NORMAL_INSTALL)
+ @list='$(gloginclude_HEADERS)'; test -n "$(glogincludedir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(glogincludedir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(glogincludedir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(glogincludedir)'"; \
+ $(INSTALL_HEADER) $$files "$(DESTDIR)$(glogincludedir)" || exit $$?; \
+ done
+
+uninstall-glogincludeHEADERS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(gloginclude_HEADERS)'; test -n "$(glogincludedir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ dir='$(DESTDIR)$(glogincludedir)'; $(am__uninstall_files_from_dir)
+install-nodist_glogincludeHEADERS: $(nodist_gloginclude_HEADERS)
+ @$(NORMAL_INSTALL)
+ @list='$(nodist_gloginclude_HEADERS)'; test -n "$(glogincludedir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(glogincludedir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(glogincludedir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(glogincludedir)'"; \
+ $(INSTALL_HEADER) $$files "$(DESTDIR)$(glogincludedir)" || exit $$?; \
+ done
+
+uninstall-nodist_glogincludeHEADERS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(nodist_gloginclude_HEADERS)'; test -n "$(glogincludedir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ dir='$(DESTDIR)$(glogincludedir)'; $(am__uninstall_files_from_dir)
+
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ set x; \
+ here=`pwd`; \
+ $(am__define_uniq_tagged_files); \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+cscope: cscope.files
+ test ! -s cscope.files \
+ || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS)
+clean-cscope:
+ -rm -f cscope.files
+cscope.files: clean-cscope cscopelist
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+ -rm -f cscope.out cscope.in.out cscope.po.out cscope.files
+
+# Recover from deleted '.trs' file; this should ensure that
+# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create
+# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells
+# to avoid problems with "make -n".
+.log.trs:
+ rm -f $< $@
+ $(MAKE) $(AM_MAKEFLAGS) $<
+
+# Leading 'am--fnord' is there to ensure the list of targets does not
+# expand to empty, as could happen e.g. with make check TESTS=''.
+am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck)
+am--force-recheck:
+ @:
+
+$(TEST_SUITE_LOG): $(TEST_LOGS)
+ @$(am__set_TESTS_bases); \
+ am__f_ok () { test -f "$$1" && test -r "$$1"; }; \
+ redo_bases=`for i in $$bases; do \
+ am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \
+ done`; \
+ if test -n "$$redo_bases"; then \
+ redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \
+ redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \
+ if $(am__make_dryrun); then :; else \
+ rm -f $$redo_logs && rm -f $$redo_results || exit 1; \
+ fi; \
+ fi; \
+ if test -n "$$am__remaking_logs"; then \
+ echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
+ "recursion detected" >&2; \
+ else \
+ am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
+ fi; \
+ if $(am__make_dryrun); then :; else \
+ st=0; \
+ errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \
+ for i in $$redo_bases; do \
+ test -f $$i.trs && test -r $$i.trs \
+ || { echo "$$errmsg $$i.trs" >&2; st=1; }; \
+ test -f $$i.log && test -r $$i.log \
+ || { echo "$$errmsg $$i.log" >&2; st=1; }; \
+ done; \
+ test $$st -eq 0 || exit 1; \
+ fi
+ @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \
+ ws='[ ]'; \
+ results=`for b in $$bases; do echo $$b.trs; done`; \
+ test -n "$$results" || results=/dev/null; \
+ all=` grep "^$$ws*:test-result:" $$results | wc -l`; \
+ pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \
+ fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \
+ skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \
+ xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \
+ xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \
+ error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \
+ if test `expr $$fail + $$xpass + $$error` -eq 0; then \
+ success=true; \
+ else \
+ success=false; \
+ fi; \
+ br='==================='; br=$$br$$br$$br$$br; \
+ result_count () \
+ { \
+ if test x"$$1" = x"--maybe-color"; then \
+ maybe_colorize=yes; \
+ elif test x"$$1" = x"--no-color"; then \
+ maybe_colorize=no; \
+ else \
+ echo "$@: invalid 'result_count' usage" >&2; exit 4; \
+ fi; \
+ shift; \
+ desc=$$1 count=$$2; \
+ if test $$maybe_colorize = yes && test $$count -gt 0; then \
+ color_start=$$3 color_end=$$std; \
+ else \
+ color_start= color_end=; \
+ fi; \
+ echo "$${color_start}# $$desc $$count$${color_end}"; \
+ }; \
+ create_testsuite_report () \
+ { \
+ result_count $$1 "TOTAL:" $$all "$$brg"; \
+ result_count $$1 "PASS: " $$pass "$$grn"; \
+ result_count $$1 "SKIP: " $$skip "$$blu"; \
+ result_count $$1 "XFAIL:" $$xfail "$$lgn"; \
+ result_count $$1 "FAIL: " $$fail "$$red"; \
+ result_count $$1 "XPASS:" $$xpass "$$red"; \
+ result_count $$1 "ERROR:" $$error "$$mgn"; \
+ }; \
+ { \
+ echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \
+ $(am__rst_title); \
+ create_testsuite_report --no-color; \
+ echo; \
+ echo ".. contents:: :depth: 2"; \
+ echo; \
+ for b in $$bases; do echo $$b; done \
+ | $(am__create_global_log); \
+ } >$(TEST_SUITE_LOG).tmp || exit 1; \
+ mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \
+ if $$success; then \
+ col="$$grn"; \
+ else \
+ col="$$red"; \
+ test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \
+ fi; \
+ echo "$${col}$$br$${std}"; \
+ echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \
+ echo "$${col}$$br$${std}"; \
+ create_testsuite_report --maybe-color; \
+ echo "$$col$$br$$std"; \
+ if $$success; then :; else \
+ echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \
+ if test -n "$(PACKAGE_BUGREPORT)"; then \
+ echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \
+ fi; \
+ echo "$$col$$br$$std"; \
+ fi; \
+ $$success || exit 1
+
+check-TESTS:
+ @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list
+ @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list
+ @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
+ @set +e; $(am__set_TESTS_bases); \
+ log_list=`for i in $$bases; do echo $$i.log; done`; \
+ trs_list=`for i in $$bases; do echo $$i.trs; done`; \
+ log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \
+ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \
+ exit $$?;
+recheck: all $(check_SCRIPTS)
+ @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
+ @set +e; $(am__set_TESTS_bases); \
+ bases=`for i in $$bases; do echo $$i; done \
+ | $(am__list_recheck_tests)` || exit 1; \
+ log_list=`for i in $$bases; do echo $$i.log; done`; \
+ log_list=`echo $$log_list`; \
+ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \
+ am__force_recheck=am--force-recheck \
+ TEST_LOGS="$$log_list"; \
+ exit $$?
+logging_unittest.log: logging_unittest$(EXEEXT)
+ @p='logging_unittest$(EXEEXT)'; \
+ b='logging_unittest'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+demangle_unittest.log: demangle_unittest$(EXEEXT)
+ @p='demangle_unittest$(EXEEXT)'; \
+ b='demangle_unittest'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+stacktrace_unittest.log: stacktrace_unittest$(EXEEXT)
+ @p='stacktrace_unittest$(EXEEXT)'; \
+ b='stacktrace_unittest'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+symbolize_unittest.log: symbolize_unittest$(EXEEXT)
+ @p='symbolize_unittest$(EXEEXT)'; \
+ b='symbolize_unittest'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+stl_logging_unittest.log: stl_logging_unittest$(EXEEXT)
+ @p='stl_logging_unittest$(EXEEXT)'; \
+ b='stl_logging_unittest'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+utilities_unittest.log: utilities_unittest$(EXEEXT)
+ @p='utilities_unittest$(EXEEXT)'; \
+ b='utilities_unittest'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+mock_log_test.log: mock_log_test$(EXEEXT)
+ @p='mock_log_test$(EXEEXT)'; \
+ b='mock_log_test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+.test.log:
+ @p='$<'; \
+ $(am__set_b); \
+ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+@am__EXEEXT_TRUE@.test$(EXEEXT).log:
+@am__EXEEXT_TRUE@ @p='$<'; \
+@am__EXEEXT_TRUE@ $(am__set_b); \
+@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \
+@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \
+@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
+@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT)
+
+distdir: $(DISTFILES)
+ $(am__remove_distdir)
+ test -d "$(distdir)" || mkdir "$(distdir)"
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+ $(MAKE) $(AM_MAKEFLAGS) \
+ top_distdir="$(top_distdir)" distdir="$(distdir)" \
+ dist-hook
+ -test -n "$(am__skip_mode_fix)" \
+ || find "$(distdir)" -type d ! -perm -755 \
+ -exec chmod u+rwx,go+rx {} \; -o \
+ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
+ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
+ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
+ || chmod -R a+r "$(distdir)"
+dist-gzip: distdir
+ tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+ $(am__post_remove_distdir)
+
+dist-bzip2: distdir
+ tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
+ $(am__post_remove_distdir)
+
+dist-lzip: distdir
+ tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
+ $(am__post_remove_distdir)
+
+dist-xz: distdir
+ tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
+ $(am__post_remove_distdir)
+
+dist-tarZ: distdir
+ tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
+ $(am__post_remove_distdir)
+
+dist-shar: distdir
+ shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
+ $(am__post_remove_distdir)
+
+dist-zip: distdir
+ -rm -f $(distdir).zip
+ zip -rq $(distdir).zip $(distdir)
+ $(am__post_remove_distdir)
+
+dist dist-all:
+ $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:'
+ $(am__post_remove_distdir)
+
+# This target untars the dist file and tries a VPATH configuration. Then
+# it guarantees that the distribution is self-contained by making another
+# tarfile.
+distcheck: dist
+ case '$(DIST_ARCHIVES)' in \
+ *.tar.gz*) \
+ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
+ *.tar.bz2*) \
+ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
+ *.tar.lz*) \
+ lzip -dc $(distdir).tar.lz | $(am__untar) ;;\
+ *.tar.xz*) \
+ xz -dc $(distdir).tar.xz | $(am__untar) ;;\
+ *.tar.Z*) \
+ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
+ *.shar.gz*) \
+ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
+ *.zip*) \
+ unzip $(distdir).zip ;;\
+ esac
+ chmod -R a-w $(distdir)
+ chmod u+w $(distdir)
+ mkdir $(distdir)/_build $(distdir)/_inst
+ chmod a-w $(distdir)
+ test -d $(distdir)/_build || exit 0; \
+ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
+ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
+ && am__cwd=`pwd` \
+ && $(am__cd) $(distdir)/_build \
+ && ../configure --srcdir=.. --prefix="$$dc_install_base" \
+ $(AM_DISTCHECK_CONFIGURE_FLAGS) \
+ $(DISTCHECK_CONFIGURE_FLAGS) \
+ && $(MAKE) $(AM_MAKEFLAGS) \
+ && $(MAKE) $(AM_MAKEFLAGS) dvi \
+ && $(MAKE) $(AM_MAKEFLAGS) check \
+ && $(MAKE) $(AM_MAKEFLAGS) install \
+ && $(MAKE) $(AM_MAKEFLAGS) installcheck \
+ && $(MAKE) $(AM_MAKEFLAGS) uninstall \
+ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
+ distuninstallcheck \
+ && chmod -R a-w "$$dc_install_base" \
+ && ({ \
+ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \
+ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
+ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
+ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
+ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
+ } || { rm -rf "$$dc_destdir"; exit 1; }) \
+ && rm -rf "$$dc_destdir" \
+ && $(MAKE) $(AM_MAKEFLAGS) dist \
+ && rm -rf $(DIST_ARCHIVES) \
+ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
+ && cd "$$am__cwd" \
+ || exit 1
+ $(am__post_remove_distdir)
+ @(echo "$(distdir) archives ready for distribution: "; \
+ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
+ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
+distuninstallcheck:
+ @test -n '$(distuninstallcheck_dir)' || { \
+ echo 'ERROR: trying to run $@ with an empty' \
+ '$$(distuninstallcheck_dir)' >&2; \
+ exit 1; \
+ }; \
+ $(am__cd) '$(distuninstallcheck_dir)' || { \
+ echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \
+ exit 1; \
+ }; \
+ test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \
+ || { echo "ERROR: files left after uninstall:" ; \
+ if test -n "$(DESTDIR)"; then \
+ echo " (check DESTDIR support)"; \
+ fi ; \
+ $(distuninstallcheck_listfiles) ; \
+ exit 1; } >&2
+distcleancheck: distclean
+ @if test '$(srcdir)' = . ; then \
+ echo "ERROR: distcleancheck can only run from a VPATH build" ; \
+ exit 1 ; \
+ fi
+ @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
+ || { echo "ERROR: files left in build directory after distclean:" ; \
+ $(distcleancheck_listfiles) ; \
+ exit 1; } >&2
+check-am: all-am
+ $(MAKE) $(AM_MAKEFLAGS) $(check_SCRIPTS)
+ $(MAKE) $(AM_MAKEFLAGS) check-TESTS
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(SCRIPTS) $(DATA) \
+ $(HEADERS)
+installdirs:
+ for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(docdir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(glogincludedir)" "$(DESTDIR)$(glogincludedir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+ -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS)
+ -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs)
+ -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
+
+clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+ -rm -f src/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/$(am__dirstamp)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
+ clean-noinstPROGRAMS mostlyclean-am
+
+distclean: distclean-am
+ -rm -f $(am__CONFIG_DISTCLEAN_FILES)
+ -rm -rf src/$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-hdr distclean-libtool distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-dist_docDATA install-glogincludeHEADERS \
+ install-nodist_glogincludeHEADERS install-pkgconfigDATA
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-libLTLIBRARIES
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f $(am__CONFIG_DISTCLEAN_FILES)
+ -rm -rf $(top_srcdir)/autom4te.cache
+ -rm -rf src/$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-dist_docDATA uninstall-glogincludeHEADERS \
+ uninstall-libLTLIBRARIES uninstall-nodist_glogincludeHEADERS \
+ uninstall-pkgconfigDATA
+
+.MAKE: check-am install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am am--refresh check check-TESTS \
+ check-am clean clean-cscope clean-generic clean-libLTLIBRARIES \
+ clean-libtool clean-noinstPROGRAMS cscope cscopelist-am ctags \
+ ctags-am dist dist-all dist-bzip2 dist-gzip dist-hook \
+ dist-lzip dist-shar dist-tarZ dist-xz dist-zip distcheck \
+ distclean distclean-compile distclean-generic distclean-hdr \
+ distclean-libtool distclean-tags distcleancheck distdir \
+ distuninstallcheck dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am \
+ install-dist_docDATA install-dvi install-dvi-am install-exec \
+ install-exec-am install-glogincludeHEADERS install-html \
+ install-html-am install-info install-info-am \
+ install-libLTLIBRARIES install-man \
+ install-nodist_glogincludeHEADERS install-pdf install-pdf-am \
+ install-pkgconfigDATA install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ recheck tags tags-am uninstall uninstall-am \
+ uninstall-dist_docDATA uninstall-glogincludeHEADERS \
+ uninstall-libLTLIBRARIES uninstall-nodist_glogincludeHEADERS \
+ uninstall-pkgconfigDATA
+
+@ENABLE_FRAME_POINTERS_FALSE@@X86_64_TRUE@ # TODO(csilvers): check if -fomit-frame-pointer might be in $(CXXFLAGS),
+@ENABLE_FRAME_POINTERS_FALSE@@X86_64_TRUE@ # before setting this.
+logging_striplog_test_sh: logging_striptest0 logging_striptest2 logging_striptest10
+ $(top_srcdir)/src/logging_striplog_test.sh
+demangle_unittest_sh: demangle_unittest
+ $(builddir)/demangle_unittest # force to create lt-demangle_unittest
+ $(top_srcdir)/src/demangle_unittest.sh
+signalhandler_unittest_sh: signalhandler_unittest
+ $(builddir)/signalhandler_unittest # force to create lt-signalhandler_unittest
+ $(top_srcdir)/src/signalhandler_unittest.sh
+
+rpm: dist-gzip packages/rpm.sh packages/rpm/rpm.spec
+ @cd packages && ./rpm.sh ${PACKAGE} ${VERSION}
+
+deb: dist-gzip packages/deb.sh packages/deb/*
+ @cd packages && ./deb.sh ${PACKAGE} ${VERSION}
+
+# Windows wants write permission to .vcproj files and maybe even sln files.
+dist-hook:
+ test -e "$(distdir)/vsprojects" \
+ && chmod -R u+w $(distdir)/*.sln $(distdir)/vsprojects/
+
+libtool: $(LIBTOOL_DEPS)
+ $(SHELL) ./config.status --recheck
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/thirdparty/glog/glog-0.3.4/NEWS b/thirdparty/glog/glog-0.3.5/NEWS
index e69de29..e69de29 100644
--- a/thirdparty/glog/glog-0.3.4/NEWS
+++ b/thirdparty/glog/glog-0.3.5/NEWS
diff --git a/thirdparty/glog/glog-0.3.4/README b/thirdparty/glog/glog-0.3.5/README
index 77efd37..77efd37 100644
--- a/thirdparty/glog/glog-0.3.4/README
+++ b/thirdparty/glog/glog-0.3.5/README
diff --git a/thirdparty/glog/glog-0.3.4/README.windows b/thirdparty/glog/glog-0.3.5/README.windows
index dbeef32..dbeef32 100644
--- a/thirdparty/glog/glog-0.3.4/README.windows
+++ b/thirdparty/glog/glog-0.3.5/README.windows
diff --git a/thirdparty/glog/glog-0.3.5/aclocal.m4 b/thirdparty/glog/glog-0.3.5/aclocal.m4
new file mode 100644
index 0000000..c92e644
--- /dev/null
+++ b/thirdparty/glog/glog-0.3.5/aclocal.m4
@@ -0,0 +1,1196 @@
+# generated automatically by aclocal 1.13.4 -*- Autoconf -*-
+
+# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+#
+# This file has been modified by Huawei.
+# Copyright (C) 2018-2019, Huawei.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
+m4_ifndef([AC_AUTOCONF_VERSION],
+ [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],,
+[m4_warning([this file was generated for autoconf 2.69.
+You have another version of autoconf. It may work, but is not guaranteed to.
+If you have problems, you may need to regenerate the build system entirely.
+To do so, use the procedure documented by the package, typically 'autoreconf'.])])
+
+# Copyright (C) 2002-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_AUTOMAKE_VERSION(VERSION)
+# ----------------------------
+# Automake X.Y traces this macro to ensure aclocal.m4 has been
+# generated from the m4 files accompanying Automake X.Y.
+# (This private macro should not be called outside this file.)
+AC_DEFUN([AM_AUTOMAKE_VERSION],
+[am__api_version='1.13'
+dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
+dnl require some minimum version. Point them to the right macro.
+m4_if([$1], [1.13.4], [],
+ [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
+])
+
+# _AM_AUTOCONF_VERSION(VERSION)
+# -----------------------------
+# aclocal traces this macro to find the Autoconf version.
+# This is a private macro too. Using m4_define simplifies
+# the logic in aclocal, which can simply ignore this definition.
+m4_define([_AM_AUTOCONF_VERSION], [])
+
+# AM_SET_CURRENT_AUTOMAKE_VERSION
+# -------------------------------
+# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
+# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
+AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
+[AM_AUTOMAKE_VERSION([1.13.4])dnl
+m4_ifndef([AC_AUTOCONF_VERSION],
+ [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
+
+# AM_AUX_DIR_EXPAND -*- Autoconf -*-
+
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
+# $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to
+# '$srcdir', '$srcdir/..', or '$srcdir/../..'.
+#
+# Of course, Automake must honor this variable whenever it calls a
+# tool from the auxiliary directory. The problem is that $srcdir (and
+# therefore $ac_aux_dir as well) can be either absolute or relative,
+# depending on how configure is run. This is pretty annoying, since
+# it makes $ac_aux_dir quite unusable in subdirectories: in the top
+# source directory, any form will work fine, but in subdirectories a
+# relative path needs to be adjusted first.
+#
+# $ac_aux_dir/missing
+# fails when called from a subdirectory if $ac_aux_dir is relative
+# $top_srcdir/$ac_aux_dir/missing
+# fails if $ac_aux_dir is absolute,
+# fails when called from a subdirectory in a VPATH build with
+# a relative $ac_aux_dir
+#
+# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
+# are both prefixed by $srcdir. In an in-source build this is usually
+# harmless because $srcdir is '.', but things will broke when you
+# start a VPATH build or use an absolute $srcdir.
+#
+# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
+# iff we strip the leading $srcdir from $ac_aux_dir. That would be:
+# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
+# and then we would define $MISSING as
+# MISSING="\${SHELL} $am_aux_dir/missing"
+# This will work as long as MISSING is not called from configure, because
+# unfortunately $(top_srcdir) has no meaning in configure.
+# However there are other variables, like CC, which are often used in
+# configure, and could therefore not use this "fixed" $ac_aux_dir.
+#
+# Another solution, used here, is to always expand $ac_aux_dir to an
+# absolute PATH. The drawback is that using absolute paths prevent a
+# configured tree to be moved without reconfiguration.
+
+AC_DEFUN([AM_AUX_DIR_EXPAND],
+[dnl Rely on autoconf to set up CDPATH properly.
+AC_PREREQ([2.50])dnl
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+])
+
+# AM_CONDITIONAL -*- Autoconf -*-
+
+# Copyright (C) 1997-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_CONDITIONAL(NAME, SHELL-CONDITION)
+# -------------------------------------
+# Define a conditional.
+AC_DEFUN([AM_CONDITIONAL],
+[AC_PREREQ([2.52])dnl
+ m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])],
+ [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
+AC_SUBST([$1_TRUE])dnl
+AC_SUBST([$1_FALSE])dnl
+_AM_SUBST_NOTMAKE([$1_TRUE])dnl
+_AM_SUBST_NOTMAKE([$1_FALSE])dnl
+m4_define([_AM_COND_VALUE_$1], [$2])dnl
+if $2; then
+ $1_TRUE=
+ $1_FALSE='#'
+else
+ $1_TRUE='#'
+ $1_FALSE=
+fi
+AC_CONFIG_COMMANDS_PRE(
+[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
+ AC_MSG_ERROR([[conditional "$1" was never defined.
+Usually this means the macro was only invoked conditionally.]])
+fi])])
+
+# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+
+# There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be
+# written in clear, in which case automake, when reading aclocal.m4,
+# will think it sees a *use*, and therefore will trigger all it's
+# C support machinery. Also note that it means that autoscan, seeing
+# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
+
+
+# _AM_DEPENDENCIES(NAME)
+# ----------------------
+# See how the compiler implements dependency checking.
+# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC".
+# We try a few techniques and use that to set a single cache variable.
+#
+# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
+# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
+# dependency, and given that the user is not expected to run this macro,
+# just rely on AC_PROG_CC.
+AC_DEFUN([_AM_DEPENDENCIES],
+[AC_REQUIRE([AM_SET_DEPDIR])dnl
+AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
+AC_REQUIRE([AM_MAKE_INCLUDE])dnl
+AC_REQUIRE([AM_DEP_TRACK])dnl
+
+m4_if([$1], [CC], [depcc="$CC" am_compiler_list=],
+ [$1], [CXX], [depcc="$CXX" am_compiler_list=],
+ [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
+ [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'],
+ [$1], [UPC], [depcc="$UPC" am_compiler_list=],
+ [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'],
+ [depcc="$$1" am_compiler_list=])
+
+AC_CACHE_CHECK([dependency style of $depcc],
+ [am_cv_$1_dependencies_compiler_type],
+[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+ # We make a subdir and do the tests there. Otherwise we can end up
+ # making bogus files that we don't know about and never remove. For
+ # instance it was reported that on HP-UX the gcc test will end up
+ # making a dummy file named 'D' -- because '-MD' means "put the output
+ # in D".
+ rm -rf conftest.dir
+ mkdir conftest.dir
+ # Copy depcomp to subdir because otherwise we won't find it if we're
+ # using a relative directory.
+ cp "$am_depcomp" conftest.dir
+ cd conftest.dir
+ # We will build objects and dependencies in a subdirectory because
+ # it helps to detect inapplicable dependency modes. For instance
+ # both Tru64's cc and ICC support -MD to output dependencies as a
+ # side effect of compilation, but ICC will put the dependencies in
+ # the current directory while Tru64 will put them in the object
+ # directory.
+ mkdir sub
+
+ am_cv_$1_dependencies_compiler_type=none
+ if test "$am_compiler_list" = ""; then
+ am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
+ fi
+ am__universal=false
+ m4_case([$1], [CC],
+ [case " $depcc " in #(
+ *\ -arch\ *\ -arch\ *) am__universal=true ;;
+ esac],
+ [CXX],
+ [case " $depcc " in #(
+ *\ -arch\ *\ -arch\ *) am__universal=true ;;
+ esac])
+
+ for depmode in $am_compiler_list; do
+ # Setup a source with many dependencies, because some compilers
+ # like to wrap large dependency lists on column 80 (with \), and
+ # we should not choose a depcomp mode which is confused by this.
+ #
+ # We need to recreate these files for each test, as the compiler may
+ # overwrite some of them when testing with obscure command lines.
+ # This happens at least with the AIX C compiler.
+ : > sub/conftest.c
+ for i in 1 2 3 4 5 6; do
+ echo '#include "conftst'$i'.h"' >> sub/conftest.c
+ # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
+ # Solaris 10 /bin/sh.
+ echo '/* dummy */' > sub/conftst$i.h
+ done
+ echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+ # We check with '-c' and '-o' for the sake of the "dashmstdout"
+ # mode. It turns out that the SunPro C++ compiler does not properly
+ # handle '-M -o', and we need to detect this. Also, some Intel
+ # versions had trouble with output in subdirs.
+ am__obj=sub/conftest.${OBJEXT-o}
+ am__minus_obj="-o $am__obj"
+ case $depmode in
+ gcc)
+ # This depmode causes a compiler race in universal mode.
+ test "$am__universal" = false || continue
+ ;;
+ nosideeffect)
+ # After this tag, mechanisms are not by side-effect, so they'll
+ # only be used when explicitly requested.
+ if test "x$enable_dependency_tracking" = xyes; then
+ continue
+ else
+ break
+ fi
+ ;;
+ msvc7 | msvc7msys | msvisualcpp | msvcmsys)
+ # This compiler won't grok '-c -o', but also, the minuso test has
+ # not run yet. These depmodes are late enough in the game, and
+ # so weak that their functioning should not be impacted.
+ am__obj=conftest.${OBJEXT-o}
+ am__minus_obj=
+ ;;
+ none) break ;;
+ esac
+ if depmode=$depmode \
+ source=sub/conftest.c object=$am__obj \
+ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+ >/dev/null 2>conftest.err &&
+ grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+ grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+ grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+ ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+ # icc doesn't choke on unknown options, it will just issue warnings
+ # or remarks (even with -Werror). So we grep stderr for any message
+ # that says an option was ignored or not supported.
+ # When given -MP, icc 7.0 and 7.1 complain thusly:
+ # icc: Command line warning: ignoring option '-M'; no argument required
+ # The diagnosis changed in icc 8.0:
+ # icc: Command line remark: option '-MP' not supported
+ if (grep 'ignoring option' conftest.err ||
+ grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+ am_cv_$1_dependencies_compiler_type=$depmode
+ break
+ fi
+ fi
+ done
+
+ cd ..
+ rm -rf conftest.dir
+else
+ am_cv_$1_dependencies_compiler_type=none
+fi
+])
+AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
+AM_CONDITIONAL([am__fastdep$1], [
+ test "x$enable_dependency_tracking" != xno \
+ && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
+])
+
+
+# AM_SET_DEPDIR
+# -------------
+# Choose a directory name for dependency files.
+# This macro is AC_REQUIREd in _AM_DEPENDENCIES.
+AC_DEFUN([AM_SET_DEPDIR],
+[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
+])
+
+
+# AM_DEP_TRACK
+# ------------
+AC_DEFUN([AM_DEP_TRACK],
+[AC_ARG_ENABLE([dependency-tracking], [dnl
+AS_HELP_STRING(
+ [--enable-dependency-tracking],
+ [do not reject slow dependency extractors])
+AS_HELP_STRING(
+ [--disable-dependency-tracking],
+ [speeds up one-time build])])
+if test "x$enable_dependency_tracking" != xno; then
+ am_depcomp="$ac_aux_dir/depcomp"
+ AMDEPBACKSLASH='\'
+ am__nodep='_no'
+fi
+AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
+AC_SUBST([AMDEPBACKSLASH])dnl
+_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
+AC_SUBST([am__nodep])dnl
+_AM_SUBST_NOTMAKE([am__nodep])dnl
+])
+
+# Generate code to set up dependency tracking. -*- Autoconf -*-
+
+# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+
+# _AM_OUTPUT_DEPENDENCY_COMMANDS
+# ------------------------------
+AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
+[{
+ # Older Autoconf quotes --file arguments for eval, but not when files
+ # are listed without --file. Let's play safe and only enable the eval
+ # if we detect the quoting.
+ case $CONFIG_FILES in
+ *\'*) eval set x "$CONFIG_FILES" ;;
+ *) set x $CONFIG_FILES ;;
+ esac
+ shift
+ for mf
+ do
+ # Strip MF so we end up with the name of the file.
+ mf=`echo "$mf" | sed -e 's/:.*$//'`
+ # Check whether this is an Automake generated Makefile or not.
+ # We used to match only the files named 'Makefile.in', but
+ # some people rename them; so instead we look at the file content.
+ # Grep'ing the first line is not enough: some people post-process
+ # each Makefile.in and add a new line on top of each file to say so.
+ # Grep'ing the whole file is not good either: AIX grep has a line
+ # limit of 2048, but all sed's we know have understand at least 4000.
+ if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
+ dirpart=`AS_DIRNAME("$mf")`
+ else
+ continue
+ fi
+ # Extract the definition of DEPDIR, am__include, and am__quote
+ # from the Makefile without running 'make'.
+ DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
+ test -z "$DEPDIR" && continue
+ am__include=`sed -n 's/^am__include = //p' < "$mf"`
+ test -z "$am__include" && continue
+ am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
+ # Find all dependency output files, they are included files with
+ # $(DEPDIR) in their names. We invoke sed twice because it is the
+ # simplest approach to changing $(DEPDIR) to its actual value in the
+ # expansion.
+ for file in `sed -n "
+ s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
+ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
+ # Make sure the directory exists.
+ test -f "$dirpart/$file" && continue
+ fdir=`AS_DIRNAME(["$file"])`
+ AS_MKDIR_P([$dirpart/$fdir])
+ # echo "creating $dirpart/$file"
+ echo '# dummy' > "$dirpart/$file"
+ done
+ done
+}
+])# _AM_OUTPUT_DEPENDENCY_COMMANDS
+
+
+# AM_OUTPUT_DEPENDENCY_COMMANDS
+# -----------------------------
+# This macro should only be invoked once -- use via AC_REQUIRE.
+#
+# This code is only required when automatic dependency tracking
+# is enabled. FIXME. This creates each '.P' file that we will
+# need in order to bootstrap the dependency handling code.
+AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
+[AC_CONFIG_COMMANDS([depfiles],
+ [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
+ [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
+])
+
+# Do all the work for Automake. -*- Autoconf -*-
+
+# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This macro actually does too much. Some checks are only needed if
+# your package does certain things. But this isn't really a big deal.
+
+dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O.
+m4_define([AC_PROG_CC],
+m4_defn([AC_PROG_CC])
+[_AM_PROG_CC_C_O
+])
+
+# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
+# AM_INIT_AUTOMAKE([OPTIONS])
+# -----------------------------------------------
+# The call with PACKAGE and VERSION arguments is the old style
+# call (pre autoconf-2.50), which is being phased out. PACKAGE
+# and VERSION should now be passed to AC_INIT and removed from
+# the call to AM_INIT_AUTOMAKE.
+# We support both call styles for the transition. After
+# the next Automake release, Autoconf can make the AC_INIT
+# arguments mandatory, and then we can depend on a new Autoconf
+# release and drop the old call support.
+AC_DEFUN([AM_INIT_AUTOMAKE],
+[AC_PREREQ([2.65])dnl
+dnl Autoconf wants to disallow AM_ names. We explicitly allow
+dnl the ones we care about.
+m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
+AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
+AC_REQUIRE([AC_PROG_INSTALL])dnl
+if test "`cd $srcdir && pwd`" != "`pwd`"; then
+ # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
+ # is not polluted with repeated "-I."
+ AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
+ # test to see if srcdir already configured
+ if test -f $srcdir/config.status; then
+ AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
+ fi
+fi
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+ if (cygpath --version) >/dev/null 2>/dev/null; then
+ CYGPATH_W='cygpath -w'
+ else
+ CYGPATH_W=echo
+ fi
+fi
+AC_SUBST([CYGPATH_W])
+
+# Define the identity of the package.
+dnl Distinguish between old-style and new-style calls.
+m4_ifval([$2],
+[AC_DIAGNOSE([obsolete],
+ [$0: two- and three-arguments forms are deprecated.])
+m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
+ AC_SUBST([PACKAGE], [$1])dnl
+ AC_SUBST([VERSION], [$2])],
+[_AM_SET_OPTIONS([$1])dnl
+dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
+m4_if(
+ m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]),
+ [ok:ok],,
+ [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
+ AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
+ AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
+
+_AM_IF_OPTION([no-define],,
+[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package])
+ AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl
+
+# Some tools Automake needs.
+AC_REQUIRE([AM_SANITY_CHECK])dnl
+AC_REQUIRE([AC_ARG_PROGRAM])dnl
+AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}])
+AM_MISSING_PROG([AUTOCONF], [autoconf])
+AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}])
+AM_MISSING_PROG([AUTOHEADER], [autoheader])
+AM_MISSING_PROG([MAKEINFO], [makeinfo])
+AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
+AC_REQUIRE([AC_PROG_MKDIR_P])dnl
+# For better backward compatibility. To be removed once Automake 1.9.x
+# dies out for good. For more background, see:
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
+AC_SUBST([mkdir_p], ['$(MKDIR_P)'])
+# We need awk for the "check" target. The system "awk" is bad on
+# some platforms.
+AC_REQUIRE([AC_PROG_AWK])dnl
+AC_REQUIRE([AC_PROG_MAKE_SET])dnl
+AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
+ [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
+ [_AM_PROG_TAR([v7])])])
+_AM_IF_OPTION([no-dependencies],,
+[AC_PROVIDE_IFELSE([AC_PROG_CC],
+ [_AM_DEPENDENCIES([CC])],
+ [m4_define([AC_PROG_CC],
+ m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_CXX],
+ [_AM_DEPENDENCIES([CXX])],
+ [m4_define([AC_PROG_CXX],
+ m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_OBJC],
+ [_AM_DEPENDENCIES([OBJC])],
+ [m4_define([AC_PROG_OBJC],
+ m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_OBJCXX],
+ [_AM_DEPENDENCIES([OBJCXX])],
+ [m4_define([AC_PROG_OBJCXX],
+ m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl
+])
+AC_REQUIRE([AM_SILENT_RULES])dnl
+dnl The testsuite driver may need to know about EXEEXT, so add the
+dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This
+dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below.
+AC_CONFIG_COMMANDS_PRE(dnl
+[m4_provide_if([_AM_COMPILER_EXEEXT],
+ [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
+
+# POSIX will say in a future version that running "rm -f" with no argument
+# is OK; and we want to be able to make that assumption in our Makefile
+# recipes. So use an aggressive probe to check that the usage we want is
+# actually supported "in the wild" to an acceptable degree.
+# See automake bug#10828.
+# To make any issue more visible, cause the running configure to be aborted
+# by default if the 'rm' program in use doesn't match our expectations; the
+# user can still override this though.
+if rm -f && rm -fr && rm -rf; then : OK; else
+ cat >&2 <<'END'
+Oops!
+
+Your 'rm' program seems unable to run without file operands specified
+on the command line, even when the '-f' option is present. This is contrary
+to the behaviour of most rm programs out there, and not conforming with
+the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542>
+
+Please tell bug-automake@gnu.org about your system, including the value
+of your $PATH and any error possibly output before this message. This
+can help us improve future automake versions.
+
+END
+ if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
+ echo 'Configuration will proceed anyway, since you have set the' >&2
+ echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
+ echo >&2
+ else
+ cat >&2 <<'END'
+Aborting the configuration process, to ensure you take notice of the issue.
+
+You can download and install GNU coreutils to get an 'rm' implementation
+that behaves properly: <http://www.gnu.org/software/coreutils/>.
+
+If you want to complete the configuration process using your problematic
+'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
+to "yes", and re-run configure.
+
+END
+ AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
+ fi
+fi])
+
+dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not
+dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
+dnl mangled by Autoconf and run in a shell conditional statement.
+m4_define([_AC_COMPILER_EXEEXT],
+m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
+
+# When config.status generates a header, we must update the stamp-h file.
+# This file resides in the same directory as the config header
+# that is generated. The stamp files are numbered to have different names.
+
+# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
+# loop where config.status creates the headers, so we can generate
+# our stamp files there.
+AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
+[# Compute $1's index in $config_headers.
+_am_arg=$1
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+ case $_am_header in
+ $_am_arg | $_am_arg:* )
+ break ;;
+ * )
+ _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+ esac
+done
+echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
+
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_PROG_INSTALL_SH
+# ------------------
+# Define $install_sh.
+AC_DEFUN([AM_PROG_INSTALL_SH],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+if test x"${install_sh}" != xset; then
+ case $am_aux_dir in
+ *\ * | *\ *)
+ install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
+ *)
+ install_sh="\${SHELL} $am_aux_dir/install-sh"
+ esac
+fi
+AC_SUBST([install_sh])])
+
+# Copyright (C) 2003-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# Check whether the underlying file-system supports filenames
+# with a leading dot. For instance MS-DOS doesn't.
+AC_DEFUN([AM_SET_LEADING_DOT],
+[rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+ am__leading_dot=.
+else
+ am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+AC_SUBST([am__leading_dot])])
+
+# Check to see how 'make' treats includes. -*- Autoconf -*-
+
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_MAKE_INCLUDE()
+# -----------------
+# Check to see how make treats includes.
+AC_DEFUN([AM_MAKE_INCLUDE],
+[am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+ @echo this is the am__doit target
+.PHONY: am__doit
+END
+# If we don't find an include directive, just comment out the code.
+AC_MSG_CHECKING([for style of include used by $am_make])
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# Ignore all kinds of additional output from 'make'.
+case `$am_make -s -f confmf 2> /dev/null` in #(
+*the\ am__doit\ target*)
+ am__include=include
+ am__quote=
+ _am_result=GNU
+ ;;
+esac
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+ echo '.include "confinc"' > confmf
+ case `$am_make -s -f confmf 2> /dev/null` in #(
+ *the\ am__doit\ target*)
+ am__include=.include
+ am__quote="\""
+ _am_result=BSD
+ ;;
+ esac
+fi
+AC_SUBST([am__include])
+AC_SUBST([am__quote])
+AC_MSG_RESULT([$_am_result])
+rm -f confinc confmf
+])
+
+# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
+
+# Copyright (C) 1997-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_MISSING_PROG(NAME, PROGRAM)
+# ------------------------------
+AC_DEFUN([AM_MISSING_PROG],
+[AC_REQUIRE([AM_MISSING_HAS_RUN])
+$1=${$1-"${am_missing_run}$2"}
+AC_SUBST($1)])
+
+# AM_MISSING_HAS_RUN
+# ------------------
+# Define MISSING if not defined so far and test if it is modern enough.
+# If it is, set am_missing_run to use it, otherwise, to nothing.
+AC_DEFUN([AM_MISSING_HAS_RUN],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+AC_REQUIRE_AUX_FILE([missing])dnl
+if test x"${MISSING+set}" != xset; then
+ case $am_aux_dir in
+ *\ * | *\ *)
+ MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
+ *)
+ MISSING="\${SHELL} $am_aux_dir/missing" ;;
+ esac
+fi
+# Use eval to expand $SHELL
+if eval "$MISSING --is-lightweight"; then
+ am_missing_run="$MISSING "
+else
+ am_missing_run=
+ AC_MSG_WARN(['missing' script is too old or missing])
+fi
+])
+
+# -*- Autoconf -*-
+# Obsolete and "removed" macros, that must however still report explicit
+# error messages when used, to smooth transition.
+#
+# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([AM_CONFIG_HEADER],
+[AC_DIAGNOSE([obsolete],
+['$0': this macro is obsolete.
+You should use the 'AC][_CONFIG_HEADERS' macro instead.])dnl
+AC_CONFIG_HEADERS($@)])
+
+AC_DEFUN([AM_PROG_CC_STDC],
+[AC_PROG_CC
+am_cv_prog_cc_stdc=$ac_cv_prog_cc_stdc
+AC_DIAGNOSE([obsolete],
+['$0': this macro is obsolete.
+You should simply use the 'AC][_PROG_CC' macro instead.
+Also, your code should no longer depend upon 'am_cv_prog_cc_stdc',
+but upon 'ac_cv_prog_cc_stdc'.])])
+
+AC_DEFUN([AM_C_PROTOTYPES],
+ [AC_FATAL([automatic de-ANSI-fication support has been removed])])
+AU_DEFUN([fp_C_PROTOTYPES], [AM_C_PROTOTYPES])
+
+# Helper functions for option handling. -*- Autoconf -*-
+
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# _AM_MANGLE_OPTION(NAME)
+# -----------------------
+AC_DEFUN([_AM_MANGLE_OPTION],
+[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
+
+# _AM_SET_OPTION(NAME)
+# --------------------
+# Set option NAME. Presently that only means defining a flag for this option.
+AC_DEFUN([_AM_SET_OPTION],
+[m4_define(_AM_MANGLE_OPTION([$1]), [1])])
+
+# _AM_SET_OPTIONS(OPTIONS)
+# ------------------------
+# OPTIONS is a space-separated list of Automake options.
+AC_DEFUN([_AM_SET_OPTIONS],
+[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
+
+# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
+# -------------------------------------------
+# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
+AC_DEFUN([_AM_IF_OPTION],
+[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
+
+# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# _AM_PROG_CC_C_O
+# ---------------
+# Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC
+# to automatically call this.
+AC_DEFUN([_AM_PROG_CC_C_O],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+AC_REQUIRE_AUX_FILE([compile])dnl
+AC_LANG_PUSH([C])dnl
+AC_CACHE_CHECK(
+ [whether $CC understands -c and -o together],
+ [am_cv_prog_cc_c_o],
+ [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
+ # Make sure it works both with $CC and with simple cc.
+ # Following AC_PROG_CC_C_O, we do the test twice because some
+ # compilers refuse to overwrite an existing .o file with -o,
+ # though they will create one.
+ am_cv_prog_cc_c_o=yes
+ for am_i in 1 2; do
+ if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \
+ && test -f conftest2.$ac_objext; then
+ : OK
+ else
+ am_cv_prog_cc_c_o=no
+ break
+ fi
+ done
+ rm -f core conftest*
+ unset am_i])
+if test "$am_cv_prog_cc_c_o" != yes; then
+ # Losing compiler, so override with the script.
+ # FIXME: It is wrong to rewrite CC.
+ # But if we don't then we get into trouble of one sort or another.
+ # A longer-term fix would be to have automake use am__CC in this case,
+ # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
+ CC="$am_aux_dir/compile $CC"
+fi
+AC_LANG_POP([C])])
+
+# For backward compatibility.
+AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
+
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_RUN_LOG(COMMAND)
+# -------------------
+# Run COMMAND, save the exit status in ac_status, and log it.
+# (This has been adapted from Autoconf's _AC_RUN_LOG macro.)
+AC_DEFUN([AM_RUN_LOG],
+[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD
+ ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+ (exit $ac_status); }])
+
+# Check to make sure that the build environment is sane. -*- Autoconf -*-
+
+# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_SANITY_CHECK
+# ---------------
+AC_DEFUN([AM_SANITY_CHECK],
+[AC_MSG_CHECKING([whether build environment is sane])
+# Reject unsafe characters in $srcdir or the absolute working directory
+# name. Accept space and tab only in the latter.
+am_lf='
+'
+case `pwd` in
+ *[[\\\"\#\$\&\'\`$am_lf]]*)
+ AC_MSG_ERROR([unsafe absolute working directory name]);;
+esac
+case $srcdir in
+ *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*)
+ AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);;
+esac
+
+# Do 'set' in a subshell so we don't clobber the current shell's
+# arguments. Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+ am_has_slept=no
+ for am_try in 1 2; do
+ echo "timestamp, slept: $am_has_slept" > conftest.file
+ set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
+ if test "$[*]" = "X"; then
+ # -L didn't work.
+ set X `ls -t "$srcdir/configure" conftest.file`
+ fi
+ if test "$[*]" != "X $srcdir/configure conftest.file" \
+ && test "$[*]" != "X conftest.file $srcdir/configure"; then
+
+ # If neither matched, then we have a broken ls. This can happen
+ # if, for instance, CONFIG_SHELL is bash and it inherits a
+ # broken ls alias from the environment. This has actually
+ # happened. Such a system could not be considered "sane".
+ AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
+ alias in your environment])
+ fi
+ if test "$[2]" = conftest.file || test $am_try -eq 2; then
+ break
+ fi
+ # Just in case.
+ sleep 1
+ am_has_slept=yes
+ done
+ test "$[2]" = conftest.file
+ )
+then
+ # Ok.
+ :
+else
+ AC_MSG_ERROR([newly created file is older than distributed files!
+Check your system clock])
+fi
+AC_MSG_RESULT([yes])
+# If we didn't sleep, we still need to ensure time stamps of config.status and
+# generated files are strictly newer.
+am_sleep_pid=
+if grep 'slept: no' conftest.file >/dev/null 2>&1; then
+ ( sleep 1 ) &
+ am_sleep_pid=$!
+fi
+AC_CONFIG_COMMANDS_PRE(
+ [AC_MSG_CHECKING([that generated files are newer than configure])
+ if test -n "$am_sleep_pid"; then
+ # Hide warnings about reused PIDs.
+ wait $am_sleep_pid 2>/dev/null
+ fi
+ AC_MSG_RESULT([done])])
+rm -f conftest.file
+])
+
+# Copyright (C) 2009-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_SILENT_RULES([DEFAULT])
+# --------------------------
+# Enable less verbose build rules; with the default set to DEFAULT
+# ("yes" being less verbose, "no" or empty being verbose).
+AC_DEFUN([AM_SILENT_RULES],
+[AC_ARG_ENABLE([silent-rules], [dnl
+AS_HELP_STRING(
+ [--enable-silent-rules],
+ [less verbose build output (undo: "make V=1")])
+AS_HELP_STRING(
+ [--disable-silent-rules],
+ [verbose build output (undo: "make V=0")])dnl
+])
+case $enable_silent_rules in @%:@ (((
+ yes) AM_DEFAULT_VERBOSITY=0;;
+ no) AM_DEFAULT_VERBOSITY=1;;
+ *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);;
+esac
+dnl
+dnl A few 'make' implementations (e.g., NonStop OS and NextStep)
+dnl do not support nested variable expansions.
+dnl See automake bug#9928 and bug#10237.
+am_make=${MAKE-make}
+AC_CACHE_CHECK([whether $am_make supports nested variables],
+ [am_cv_make_support_nested_variables],
+ [if AS_ECHO([['TRUE=$(BAR$(V))
+BAR0=false
+BAR1=true
+V=1
+am__doit:
+ @$(TRUE)
+.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then
+ am_cv_make_support_nested_variables=yes
+else
+ am_cv_make_support_nested_variables=no
+fi])
+if test $am_cv_make_support_nested_variables = yes; then
+ dnl Using '$V' instead of '$(V)' breaks IRIX make.
+ AM_V='$(V)'
+ AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
+else
+ AM_V=$AM_DEFAULT_VERBOSITY
+ AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
+fi
+AC_SUBST([AM_V])dnl
+AM_SUBST_NOTMAKE([AM_V])dnl
+AC_SUBST([AM_DEFAULT_V])dnl
+AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl
+AC_SUBST([AM_DEFAULT_VERBOSITY])dnl
+AM_BACKSLASH='\'
+AC_SUBST([AM_BACKSLASH])dnl
+_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
+])
+
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_PROG_INSTALL_STRIP
+# ---------------------
+# One issue with vendor 'install' (even GNU) is that you can't
+# specify the program used to strip binaries. This is especially
+# annoying in cross-compiling environments, where the build's strip
+# is unlikely to handle the host's binaries.
+# Fortunately install-sh will honor a STRIPPROG variable, so we
+# always use install-sh in "make install-strip", and initialize
+# STRIPPROG with the value of the STRIP variable (set by the user).
+AC_DEFUN([AM_PROG_INSTALL_STRIP],
+[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+# Installed binaries are usually stripped using 'strip' when the user
+# run "make install-strip". However 'strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the 'STRIP' environment variable to overrule this program.
+dnl Don't test for $cross_compiling = yes, because it might be 'maybe'.
+if test "$cross_compiling" != no; then
+ AC_CHECK_TOOL([STRIP], [strip], :)
+fi
+INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
+AC_SUBST([INSTALL_STRIP_PROGRAM])])
+
+# Copyright (C) 2006-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# _AM_SUBST_NOTMAKE(VARIABLE)
+# ---------------------------
+# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
+# This macro is traced by Automake.
+AC_DEFUN([_AM_SUBST_NOTMAKE])
+
+# AM_SUBST_NOTMAKE(VARIABLE)
+# --------------------------
+# Public sister of _AM_SUBST_NOTMAKE.
+AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
+
+# Check how to create a tarball. -*- Autoconf -*-
+
+# Copyright (C) 2004-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# _AM_PROG_TAR(FORMAT)
+# --------------------
+# Check how to create a tarball in format FORMAT.
+# FORMAT should be one of 'v7', 'ustar', or 'pax'.
+#
+# Substitute a variable $(am__tar) that is a command
+# writing to stdout a FORMAT-tarball containing the directory
+# $tardir.
+# tardir=directory && $(am__tar) > result.tar
+#
+# Substitute a variable $(am__untar) that extract such
+# a tarball read from stdin.
+# $(am__untar) < result.tar
+#
+AC_DEFUN([_AM_PROG_TAR],
+[# Always define AMTAR for backward compatibility. Yes, it's still used
+# in the wild :-( We should find a proper way to deprecate it ...
+AC_SUBST([AMTAR], ['$${TAR-tar}'])
+
+# We'll loop over all known methods to create a tar archive until one works.
+_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
+
+m4_if([$1], [v7],
+ [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
+
+ [m4_case([$1],
+ [ustar],
+ [# The POSIX 1988 'ustar' format is defined with fixed-size fields.
+ # There is notably a 21 bits limit for the UID and the GID. In fact,
+ # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343
+ # and bug#13588).
+ am_max_uid=2097151 # 2^21 - 1
+ am_max_gid=$am_max_uid
+ # The $UID and $GID variables are not portable, so we need to resort
+ # to the POSIX-mandated id(1) utility. Errors in the 'id' calls
+ # below are definitely unexpected, so allow the users to see them
+ # (that is, avoid stderr redirection).
+ am_uid=`id -u || echo unknown`
+ am_gid=`id -g || echo unknown`
+ AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format])
+ if test $am_uid -le $am_max_uid; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ _am_tools=none
+ fi
+ AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format])
+ if test $am_gid -le $am_max_gid; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ _am_tools=none
+ fi],
+
+ [pax],
+ [],
+
+ [m4_fatal([Unknown tar format])])
+
+ AC_MSG_CHECKING([how to create a $1 tar archive])
+
+ # Go ahead even if we have the value already cached. We do so because we
+ # need to set the values for the 'am__tar' and 'am__untar' variables.
+ _am_tools=${am_cv_prog_tar_$1-$_am_tools}
+
+ for _am_tool in $_am_tools; do
+ case $_am_tool in
+ gnutar)
+ for _am_tar in tar gnutar gtar; do
+ AM_RUN_LOG([$_am_tar --version]) && break
+ done
+ am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
+ am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
+ am__untar="$_am_tar -xf -"
+ ;;
+ plaintar)
+ # Must skip GNU tar: if it does not support --format= it doesn't create
+ # ustar tarball either.
+ (tar --version) >/dev/null 2>&1 && continue
+ am__tar='tar chf - "$$tardir"'
+ am__tar_='tar chf - "$tardir"'
+ am__untar='tar xf -'
+ ;;
+ pax)
+ am__tar='pax -L -x $1 -w "$$tardir"'
+ am__tar_='pax -L -x $1 -w "$tardir"'
+ am__untar='pax -r'
+ ;;
+ cpio)
+ am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
+ am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
+ am__untar='cpio -i -H $1 -d'
+ ;;
+ none)
+ am__tar=false
+ am__tar_=false
+ am__untar=false
+ ;;
+ esac
+
+ # If the value was cached, stop now. We just wanted to have am__tar
+ # and am__untar set.
+ test -n "${am_cv_prog_tar_$1}" && break
+
+ # tar/untar a dummy directory, and stop if the command works.
+ rm -rf conftest.dir
+ mkdir conftest.dir
+ echo GrepMe > conftest.dir/file
+ AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
+ rm -rf conftest.dir
+ if test -s conftest.tar; then
+ AM_RUN_LOG([$am__untar <conftest.tar])
+ AM_RUN_LOG([cat conftest.dir/file])
+ grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
+ fi
+ done
+ rm -rf conftest.dir
+
+ AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
+ AC_MSG_RESULT([$am_cv_prog_tar_$1])])
+
+AC_SUBST([am__tar])
+AC_SUBST([am__untar])
+]) # _AM_PROG_TAR
+
+m4_include([m4/ac_have_attribute.m4])
+m4_include([m4/ac_have_builtin_expect.m4])
+m4_include([m4/ac_have_sync_val_compare_and_swap.m4])
+m4_include([m4/ac_rwlock.m4])
+m4_include([m4/acx_pthread.m4])
+m4_include([m4/google_namespace.m4])
+m4_include([m4/libtool.m4])
+m4_include([m4/ltoptions.m4])
+m4_include([m4/ltsugar.m4])
+m4_include([m4/ltversion.m4])
+m4_include([m4/lt~obsolete.m4])
+m4_include([m4/namespaces.m4])
+m4_include([m4/pc_from_ucontext.m4])
+m4_include([m4/stl_namespace.m4])
+m4_include([m4/using_operator.m4])
diff --git a/thirdparty/glog/glog-0.3.5/cmake/DetermineGflagsNamespace.cmake b/thirdparty/glog/glog-0.3.5/cmake/DetermineGflagsNamespace.cmake
new file mode 100644
index 0000000..e5e50cc
--- /dev/null
+++ b/thirdparty/glog/glog-0.3.5/cmake/DetermineGflagsNamespace.cmake
@@ -0,0 +1,69 @@
+macro(determine_gflags_namespace VARIABLE)
+ if (NOT DEFINED "${VARIABLE}")
+ if (CMAKE_REQUIRED_INCLUDES)
+ set (CHECK_INCLUDE_FILE_CXX_INCLUDE_DIRS "-DINCLUDE_DIRECTORIES=${CMAKE_REQUIRED_INCLUDES}")
+ else ()
+ set (CHECK_INCLUDE_FILE_CXX_INCLUDE_DIRS)
+ endif ()
+
+ set(MACRO_CHECK_INCLUDE_FILE_FLAGS ${CMAKE_REQUIRED_FLAGS})
+
+ set(_NAMESPACES gflags google)
+ set(_check_code
+"
+#include <gflags/gflags.h>
+
+int main(int argc, char**argv)
+{
+ GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
+}
+")
+ if (NOT CMAKE_REQUIRED_QUIET)
+ message (STATUS "Looking for gflags namespace")
+ endif ()
+ if (${ARGC} EQUAL 3)
+ set (CMAKE_CXX_FLAGS_SAVE ${CMAKE_CXX_FLAGS})
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARGV2}")
+ endif ()
+
+ set (_check_file
+ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/DetermineGflagsNamespace.cxx)
+
+ foreach (_namespace ${_NAMESPACES})
+ file (WRITE "${_check_file}" "${_check_code}")
+ try_compile (${VARIABLE}
+ "${CMAKE_BINARY_DIR}" "${_check_file}"
+ COMPILE_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}" -DGFLAGS_NAMESPACE=${_namespace}
+ LINK_LIBRARIES "${gflags_LIBRARIES}"
+ CMAKE_FLAGS -DINCLUDE_DIRECTORIES:STRING="${gflags_INCLUDE_DIR}"
+ OUTPUT_VARIABLE OUTPUT)
+
+ if (${VARIABLE})
+ set (${VARIABLE} ${_namespace} CACHE INTERNAL "gflags namespace" FORCE)
+ break ()
+ else ()
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Determining the gflags namespace ${_namespace} failed with the following output:\n"
+ "${OUTPUT}\n\n")
+ endif ()
+ endforeach (_namespace)
+
+ if (${ARGC} EQUAL 3)
+ set (CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_SAVE})
+ endif ()
+
+ if (${VARIABLE})
+ if (NOT CMAKE_REQUIRED_QUIET)
+ message (STATUS "Looking for gflags namespace - ${${VARIABLE}}")
+ endif ()
+ file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "Determining the gflags namespace passed with the following output:\n"
+ "${OUTPUT}\n\n")
+ else ()
+ if (NOT CMAKE_REQUIRED_QUIET)
+ message (STATUS "Looking for gflags namespace - failed")
+ endif ()
+ set (${VARIABLE} ${_namespace} CACHE INTERNAL "gflags namespace")
+ endif ()
+ endif ()
+endmacro ()
diff --git a/thirdparty/glog/glog-0.3.5/cmake/INSTALL.md b/thirdparty/glog/glog-0.3.5/cmake/INSTALL.md
new file mode 100644
index 0000000..d1b3952
--- /dev/null
+++ b/thirdparty/glog/glog-0.3.5/cmake/INSTALL.md
@@ -0,0 +1,30 @@
+Building Glog with CMake
+========================
+
+1. Create a build directory and `cd` to it.
+2. Run
+ ```bash
+ cmake path/to/glog
+ ```
+
+3. Afterwards, generated files (GNU make, Visual Studio, etc.) can be used to
+ compile the project.
+
+
+Consuming Glog in a CMake Project
+=================================
+
+To use Glog in your project `myproj`, use:
+
+```cmake
+cmake_minimum_required (VERSION 3.0)
+project (myproj)
+
+find_package (glog 0.3.5 REQUIRED)
+
+add_executable (myapp main.cpp)
+target_link_libraries (myapp glog::glog)
+```
+
+Compile definitions and options will be added automatically to your target as
+needed.
diff --git a/thirdparty/glog/glog-0.3.4/compile b/thirdparty/glog/glog-0.3.5/compile
index 9bb997a..9bb997a 100644
--- a/thirdparty/glog/glog-0.3.4/compile
+++ b/thirdparty/glog/glog-0.3.5/compile
diff --git a/thirdparty/glog/glog-0.3.5/config.guess b/thirdparty/glog/glog-0.3.5/config.guess
new file mode 100644
index 0000000..d143759
--- /dev/null
+++ b/thirdparty/glog/glog-0.3.5/config.guess
@@ -0,0 +1,1523 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
+# Inc.
+
+timestamp='2007-07-22'
+
+#
+# This file has been modified by Huawei.
+# Copyright (C) 2018-2019, Huawei.
+#
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Originally written by Per Bothner <per@bothner.com>.
+# Please send patches to <config-patches@gnu.org>. Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub. If it succeeds, it prints the system name on stdout, and
+# exits with 0. Otherwise, it exits with 1.
+#
+# The plan is that this can be called by configure scripts if you
+# don't specify an explicit build system type.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit ;;
+ --version | -v )
+ echo "$version" ; exit ;;
+ --help | --h* | -h )
+ echo "$usage"; exit ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help" >&2
+ exit 1 ;;
+ * )
+ break ;;
+ esac
+done
+
+if test $# != 0; then
+ echo "$me: too many arguments$help" >&2
+ exit 1
+fi
+
+trap 'exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
+
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+# Portable tmp directory creation inspired by the Autoconf team.
+
+set_cc_for_build='
+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
+: ${TMPDIR=/tmp} ;
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
+dummy=$tmp/dummy ;
+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,) echo "int x;" > $dummy.c ;
+ for c in cc gcc c89 c99 ; do
+ if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+ CC_FOR_BUILD="$c"; break ;
+ fi ;
+ done ;
+ if test x"$CC_FOR_BUILD" = x ; then
+ CC_FOR_BUILD=no_compiler_found ;
+ fi
+ ;;
+ ,,*) CC_FOR_BUILD=$CC ;;
+ ,*,*) CC_FOR_BUILD=$HOST_CC ;;
+esac ; set_cc_for_build= ;'
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 1994-08-24)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+ PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+ *:NetBSD:*:*)
+ # NetBSD (nbsd) targets should (where applicable) match one or
+ # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+ # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
+ # switched to ELF, *-*-netbsd* would select the old
+ # object file format. This provides both forward
+ # compatibility and a consistent mechanism for selecting the
+ # object file format.
+ #
+ # Note: NetBSD doesn't particularly care about the vendor
+ # portion of the name. We always set it to "unknown".
+ sysctl="sysctl -n hw.machine_arch"
+ UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+ /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+ case "${UNAME_MACHINE_ARCH}" in
+ armeb) machine=armeb-unknown ;;
+ arm*) machine=arm-unknown ;;
+ sh3el) machine=shl-unknown ;;
+ sh3eb) machine=sh-unknown ;;
+ sh5el) machine=sh5le-unknown ;;
+ *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+ esac
+ # The Operating System including object format, if it has switched
+ # to ELF recently, or will in the future.
+ case "${UNAME_MACHINE_ARCH}" in
+ arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+ eval $set_cc_for_build
+ if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep __ELF__ >/dev/null
+ then
+ # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+ # Return netbsd for either. FIX?
+ os=netbsd
+ else
+ os=netbsdelf
+ fi
+ ;;
+ *)
+ os=netbsd
+ ;;
+ esac
+ # The OS release
+ # Debian GNU/NetBSD machines have a different userland, and
+ # thus, need a distinct triplet. However, they do not need
+ # kernel version information, so it can be replaced with a
+ # suitable tag, in the style of linux-gnu.
+ case "${UNAME_VERSION}" in
+ Debian*)
+ release='-gnu'
+ ;;
+ *)
+ release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ ;;
+ esac
+ # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+ # contains redundant information, the shorter form:
+ # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+ echo "${machine}-${os}${release}"
+ exit ;;
+ *:OpenBSD:*:*)
+ UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
+ echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
+ exit ;;
+ *:ekkoBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+ exit ;;
+ *:SolidBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
+ exit ;;
+ macppc:MirBSD:*:*)
+ echo powerpc-unknown-mirbsd${UNAME_RELEASE}
+ exit ;;
+ *:MirBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+ exit ;;
+ alpha:OSF1:*:*)
+ case $UNAME_RELEASE in
+ *4.0)
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+ ;;
+ *5.*)
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+ ;;
+ esac
+ # According to Compaq, /usr/sbin/psrinfo has been available on
+ # OSF/1 and Tru64 systems produced since 1995. I hope that
+ # covers most systems running today. This code pipes the CPU
+ # types through head -n 1, so we only detect the type of CPU 0.
+ ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
+ case "$ALPHA_CPU_TYPE" in
+ "EV4 (21064)")
+ UNAME_MACHINE="alpha" ;;
+ "EV4.5 (21064)")
+ UNAME_MACHINE="alpha" ;;
+ "LCA4 (21066/21068)")
+ UNAME_MACHINE="alpha" ;;
+ "EV5 (21164)")
+ UNAME_MACHINE="alphaev5" ;;
+ "EV5.6 (21164A)")
+ UNAME_MACHINE="alphaev56" ;;
+ "EV5.6 (21164PC)")
+ UNAME_MACHINE="alphapca56" ;;
+ "EV5.7 (21164PC)")
+ UNAME_MACHINE="alphapca57" ;;
+ "EV6 (21264)")
+ UNAME_MACHINE="alphaev6" ;;
+ "EV6.7 (21264A)")
+ UNAME_MACHINE="alphaev67" ;;
+ "EV6.8CB (21264C)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.8AL (21264B)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.8CX (21264D)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.9A (21264/EV69A)")
+ UNAME_MACHINE="alphaev69" ;;
+ "EV7 (21364)")
+ UNAME_MACHINE="alphaev7" ;;
+ "EV7.9 (21364A)")
+ UNAME_MACHINE="alphaev79" ;;
+ esac
+ # A Pn.n version is a patched version.
+ # A Vn.n version is a released version.
+ # A Tn.n version is a released field test version.
+ # A Xn.n version is an unreleased experimental baselevel.
+ # 1.2 uses "1.2" for uname -r.
+ echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ exit ;;
+ Alpha\ *:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # Should we change UNAME_MACHINE based on the output of uname instead
+ # of the specific Alpha model?
+ echo alpha-pc-interix
+ exit ;;
+ 21064:Windows_NT:50:3)
+ echo alpha-dec-winnt3.5
+ exit ;;
+ Amiga*:UNIX_System_V:4.0:*)
+ echo m68k-unknown-sysv4
+ exit ;;
+ *:[Aa]miga[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-amigaos
+ exit ;;
+ *:[Mm]orph[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-morphos
+ exit ;;
+ *:OS/390:*:*)
+ echo i370-ibm-openedition
+ exit ;;
+ *:z/VM:*:*)
+ echo s390-ibm-zvmoe
+ exit ;;
+ *:OS400:*:*)
+ echo powerpc-ibm-os400
+ exit ;;
+ arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+ echo arm-acorn-riscix${UNAME_RELEASE}
+ exit ;;
+ arm:riscos:*:*|arm:RISCOS:*:*)
+ echo arm-unknown-riscos
+ exit ;;
+ SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+ echo hppa1.1-hitachi-hiuxmpp
+ exit ;;
+ Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+ # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+ if test "`(/bin/universe) 2>/dev/null`" = att ; then
+ echo pyramid-pyramid-sysv3
+ else
+ echo pyramid-pyramid-bsd
+ fi
+ exit ;;
+ NILE*:*:*:dcosx)
+ echo pyramid-pyramid-svr4
+ exit ;;
+ DRS?6000:unix:4.0:6*)
+ echo sparc-icl-nx6
+ exit ;;
+ DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
+ case `/usr/bin/uname -p` in
+ sparc) echo sparc-icl-nx7; exit ;;
+ esac ;;
+ sun4H:SunOS:5.*:*)
+ echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+ echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
+ echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:6*:*)
+ # According to config.sub, this is the proper way to canonicalize
+ # SunOS6. Hard to guess exactly what SunOS6 will be like, but
+ # it's likely to be more like Solaris than SunOS4.
+ echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:*:*)
+ case "`/usr/bin/arch -k`" in
+ Series*|S4*)
+ UNAME_RELEASE=`uname -v`
+ ;;
+ esac
+ # Japanese Language versions have a version number like `4.1.3-JL'.
+ echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+ exit ;;
+ sun3*:SunOS:*:*)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ exit ;;
+ sun*:*:4.2BSD:*)
+ UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+ test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+ case "`/bin/arch`" in
+ sun3)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ ;;
+ sun4)
+ echo sparc-sun-sunos${UNAME_RELEASE}
+ ;;
+ esac
+ exit ;;
+ aushp:SunOS:*:*)
+ echo sparc-auspex-sunos${UNAME_RELEASE}
+ exit ;;
+ # The situation for MiNT is a little confusing. The machine name
+ # can be virtually everything (everything which is not
+ # "atarist" or "atariste" at least should have a processor
+ # > m68000). The system name ranges from "MiNT" over "FreeMiNT"
+ # to the lowercase version "mint" (or "freemint"). Finally
+ # the system name "TOS" denotes a system which is actually not
+ # MiNT. But MiNT is downward compatible to TOS, so this should
+ # be no problem.
+ atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+ echo m68k-milan-mint${UNAME_RELEASE}
+ exit ;;
+ hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+ echo m68k-hades-mint${UNAME_RELEASE}
+ exit ;;
+ *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+ echo m68k-unknown-mint${UNAME_RELEASE}
+ exit ;;
+ m68k:machten:*:*)
+ echo m68k-apple-machten${UNAME_RELEASE}
+ exit ;;
+ powerpc:machten:*:*)
+ echo powerpc-apple-machten${UNAME_RELEASE}
+ exit ;;
+ RISC*:Mach:*:*)
+ echo mips-dec-mach_bsd4.3
+ exit ;;
+ RISC*:ULTRIX:*:*)
+ echo mips-dec-ultrix${UNAME_RELEASE}
+ exit ;;
+ VAX*:ULTRIX*:*:*)
+ echo vax-dec-ultrix${UNAME_RELEASE}
+ exit ;;
+ 2020:CLIX:*:* | 2430:CLIX:*:*)
+ echo clipper-intergraph-clix${UNAME_RELEASE}
+ exit ;;
+ mips:*:*:UMIPS | mips:*:*:RISCos)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h> /* for printf() prototype */
+ int main (int argc, char *argv[]) {
+#else
+ int main (argc, argv) int argc; char *argv[]; {
+#endif
+ #if defined (host_mips) && defined (MIPSEB)
+ #if defined (SYSTYPE_SYSV)
+ printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_SVR4)
+ printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+ printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+ #endif
+ #endif
+ exit (-1);
+ }
+EOF
+ $CC_FOR_BUILD -o $dummy $dummy.c &&
+ dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
+ SYSTEM_NAME=`$dummy $dummyarg` &&
+ { echo "$SYSTEM_NAME"; exit; }
+ echo mips-mips-riscos${UNAME_RELEASE}
+ exit ;;
+ Motorola:PowerMAX_OS:*:*)
+ echo powerpc-motorola-powermax
+ exit ;;
+ Motorola:*:4.3:PL8-*)
+ echo powerpc-harris-powermax
+ exit ;;
+ Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+ echo powerpc-harris-powermax
+ exit ;;
+ Night_Hawk:Power_UNIX:*:*)
+ echo powerpc-harris-powerunix
+ exit ;;
+ m88k:CX/UX:7*:*)
+ echo m88k-harris-cxux7
+ exit ;;
+ m88k:*:4*:R4*)
+ echo m88k-motorola-sysv4
+ exit ;;
+ m88k:*:3*:R3*)
+ echo m88k-motorola-sysv3
+ exit ;;
+ AViiON:dgux:*:*)
+ # DG/UX returns AViiON for all architectures
+ UNAME_PROCESSOR=`/usr/bin/uname -p`
+ if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+ then
+ if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+ [ ${TARGET_BINARY_INTERFACE}x = x ]
+ then
+ echo m88k-dg-dgux${UNAME_RELEASE}
+ else
+ echo m88k-dg-dguxbcs${UNAME_RELEASE}
+ fi
+ else
+ echo i586-dg-dgux${UNAME_RELEASE}
+ fi
+ exit ;;
+ M88*:DolphinOS:*:*) # DolphinOS (SVR3)
+ echo m88k-dolphin-sysv3
+ exit ;;
+ M88*:*:R3*:*)
+ # Delta 88k system running SVR3
+ echo m88k-motorola-sysv3
+ exit ;;
+ XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+ echo m88k-tektronix-sysv3
+ exit ;;
+ Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+ echo m68k-tektronix-bsd
+ exit ;;
+ *:IRIX*:*:*)
+ echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+ exit ;;
+ ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+ echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
+ exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
+ i*86:AIX:*:*)
+ echo i386-ibm-aix
+ exit ;;
+ ia64:AIX:*:*)
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+ exit ;;
+ *:AIX:2:3)
+ if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <sys/systemcfg.h>
+
+ main()
+ {
+ if (!__power_pc())
+ exit(1);
+ puts("powerpc-ibm-aix3.2.5");
+ exit(0);
+ }
+EOF
+ if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
+ then
+ echo "$SYSTEM_NAME"
+ else
+ echo rs6000-ibm-aix3.2.5
+ fi
+ elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+ echo rs6000-ibm-aix3.2.4
+ else
+ echo rs6000-ibm-aix3.2
+ fi
+ exit ;;
+ *:AIX:*:[45])
+ IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
+ if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+ IBM_ARCH=rs6000
+ else
+ IBM_ARCH=powerpc
+ fi
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+ exit ;;
+ *:AIX:*:*)
+ echo rs6000-ibm-aix
+ exit ;;
+ ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+ echo romp-ibm-bsd4.4
+ exit ;;
+ ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
+ echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
+ exit ;; # report: romp-ibm BSD 4.3
+ *:BOSX:*:*)
+ echo rs6000-bull-bosx
+ exit ;;
+ DPX/2?00:B.O.S.:*:*)
+ echo m68k-bull-sysv3
+ exit ;;
+ 9000/[34]??:4.3bsd:1.*:*)
+ echo m68k-hp-bsd
+ exit ;;
+ hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+ echo m68k-hp-bsd4.4
+ exit ;;
+ 9000/[34678]??:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ case "${UNAME_MACHINE}" in
+ 9000/31? ) HP_ARCH=m68000 ;;
+ 9000/[34]?? ) HP_ARCH=m68k ;;
+ 9000/[678][0-9][0-9])
+ if [ -x /usr/bin/getconf ]; then
+ sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+ sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+ case "${sc_cpu_version}" in
+ 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+ 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+ 532) # CPU_PA_RISC2_0
+ case "${sc_kernel_bits}" in
+ 32) HP_ARCH="hppa2.0n" ;;
+ 64) HP_ARCH="hppa2.0w" ;;
+ '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
+ esac ;;
+ esac
+ fi
+ if [ "${HP_ARCH}" = "" ]; then
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+
+ #define _HPUX_SOURCE
+ #include <stdlib.h>
+ #include <unistd.h>
+
+ int main ()
+ {
+ #if defined(_SC_KERNEL_BITS)
+ long bits = sysconf(_SC_KERNEL_BITS);
+ #endif
+ long cpu = sysconf (_SC_CPU_VERSION);
+
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+ case CPU_PA_RISC2_0:
+ #if defined(_SC_KERNEL_BITS)
+ switch (bits)
+ {
+ case 64: puts ("hppa2.0w"); break;
+ case 32: puts ("hppa2.0n"); break;
+ default: puts ("hppa2.0"); break;
+ } break;
+ #else /* !defined(_SC_KERNEL_BITS) */
+ puts ("hppa2.0"); break;
+ #endif
+ default: puts ("hppa1.0"); break;
+ }
+ exit (0);
+ }
+EOF
+ (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+ test -z "$HP_ARCH" && HP_ARCH=hppa
+ fi ;;
+ esac
+ if [ ${HP_ARCH} = "hppa2.0w" ]
+ then
+ eval $set_cc_for_build
+
+ # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
+ # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
+ # generating 64-bit code. GNU and HP use different nomenclature:
+ #
+ # $ CC_FOR_BUILD=cc ./config.guess
+ # => hppa2.0w-hp-hpux11.23
+ # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
+ # => hppa64-hp-hpux11.23
+
+ if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
+ grep __LP64__ >/dev/null
+ then
+ HP_ARCH="hppa2.0w"
+ else
+ HP_ARCH="hppa64"
+ fi
+ fi
+ echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+ exit ;;
+ ia64:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ echo ia64-hp-hpux${HPUX_REV}
+ exit ;;
+ 3050*:HI-UX:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <unistd.h>
+ int
+ main ()
+ {
+ long cpu = sysconf (_SC_CPU_VERSION);
+ /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+ true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
+ results, however. */
+ if (CPU_IS_PA_RISC (cpu))
+ {
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+ default: puts ("hppa-hitachi-hiuxwe2"); break;
+ }
+ }
+ else if (CPU_IS_HP_MC68K (cpu))
+ puts ("m68k-hitachi-hiuxwe2");
+ else puts ("unknown-hitachi-hiuxwe2");
+ exit (0);
+ }
+EOF
+ $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
+ { echo "$SYSTEM_NAME"; exit; }
+ echo unknown-hitachi-hiuxwe2
+ exit ;;
+ 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+ echo hppa1.1-hp-bsd
+ exit ;;
+ 9000/8??:4.3bsd:*:*)
+ echo hppa1.0-hp-bsd
+ exit ;;
+ *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+ echo hppa1.0-hp-mpeix
+ exit ;;
+ hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+ echo hppa1.1-hp-osf
+ exit ;;
+ hp8??:OSF1:*:*)
+ echo hppa1.0-hp-osf
+ exit ;;
+ i*86:OSF1:*:*)
+ if [ -x /usr/sbin/sysversion ] ; then
+ echo ${UNAME_MACHINE}-unknown-osf1mk
+ else
+ echo ${UNAME_MACHINE}-unknown-osf1
+ fi
+ exit ;;
+ parisc*:Lites*:*:*)
+ echo hppa1.1-hp-lites
+ exit ;;
+ C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+ echo c1-convex-bsd
+ exit ;;
+ C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit ;;
+ C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+ echo c34-convex-bsd
+ exit ;;
+ C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+ echo c38-convex-bsd
+ exit ;;
+ C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+ echo c4-convex-bsd
+ exit ;;
+ CRAY*Y-MP:*:*:*)
+ echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*[A-Z]90:*:*:*)
+ echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+ -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*TS:*:*:*)
+ echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*T3E:*:*:*)
+ echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*SV1:*:*:*)
+ echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ *:UNICOS/mp:*:*)
+ echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+ FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+ echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit ;;
+ 5000:UNIX_System_V:4.*:*)
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+ echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit ;;
+ i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+ echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+ exit ;;
+ sparc*:BSD/OS:*:*)
+ echo sparc-unknown-bsdi${UNAME_RELEASE}
+ exit ;;
+ *:BSD/OS:*:*)
+ echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+ exit ;;
+ *:FreeBSD:*:*)
+ case ${UNAME_MACHINE} in
+ pc98)
+ echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ amd64)
+ echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ *)
+ echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ esac
+ exit ;;
+ i*:CYGWIN*:*)
+ echo ${UNAME_MACHINE}-pc-cygwin
+ exit ;;
+ *:MINGW*:*)
+ echo ${UNAME_MACHINE}-pc-mingw32
+ exit ;;
+ i*:windows32*:*)
+ # uname -m includes "-pc" on this system.
+ echo ${UNAME_MACHINE}-mingw32
+ exit ;;
+ i*:PW*:*)
+ echo ${UNAME_MACHINE}-pc-pw32
+ exit ;;
+ *:Interix*:[3456]*)
+ case ${UNAME_MACHINE} in
+ x86)
+ echo i586-pc-interix${UNAME_RELEASE}
+ exit ;;
+ EM64T | authenticamd)
+ echo x86_64-unknown-interix${UNAME_RELEASE}
+ exit ;;
+ esac ;;
+ [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+ echo i${UNAME_MACHINE}-pc-mks
+ exit ;;
+ i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+ # UNAME_MACHINE based on the output of uname instead of i386?
+ echo i586-pc-interix
+ exit ;;
+ i*:UWIN*:*)
+ echo ${UNAME_MACHINE}-pc-uwin
+ exit ;;
+ amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
+ echo x86_64-unknown-cygwin
+ exit ;;
+ p*:CYGWIN*:*)
+ echo powerpcle-unknown-cygwin
+ exit ;;
+ prep*:SunOS:5.*:*)
+ echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ *:GNU:*:*)
+ # the GNU system
+ echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+ exit ;;
+ *:GNU/*:*:*)
+ # other systems with GNU libc and userland
+ echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
+ exit ;;
+ i*86:Minix:*:*)
+ echo ${UNAME_MACHINE}-pc-minix
+ exit ;;
+ arm*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ avr32*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ cris:Linux:*:*)
+ echo cris-axis-linux-gnu
+ exit ;;
+ crisv32:Linux:*:*)
+ echo crisv32-axis-linux-gnu
+ exit ;;
+ frv:Linux:*:*)
+ echo frv-unknown-linux-gnu
+ exit ;;
+ ia64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ m32r*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ m68*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ mips:Linux:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #undef CPU
+ #undef mips
+ #undef mipsel
+ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+ CPU=mipsel
+ #else
+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+ CPU=mips
+ #else
+ CPU=
+ #endif
+ #endif
+EOF
+ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+ /^CPU/{
+ s: ::g
+ p
+ }'`"
+ test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+ ;;
+ mips64:Linux:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #undef CPU
+ #undef mips64
+ #undef mips64el
+ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+ CPU=mips64el
+ #else
+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+ CPU=mips64
+ #else
+ CPU=
+ #endif
+ #endif
+EOF
+ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+ /^CPU/{
+ s: ::g
+ p
+ }'`"
+ test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+ ;;
+ or32:Linux:*:*)
+ echo or32-unknown-linux-gnu
+ exit ;;
+ ppc:Linux:*:*)
+ echo powerpc-unknown-linux-gnu
+ exit ;;
+ ppc64:Linux:*:*)
+ echo powerpc64-unknown-linux-gnu
+ exit ;;
+ ppc64le:Linux:*:*)
+ echo powerpc64le-unknown-linux-gnu
+ exit ;;
+ alpha:Linux:*:*)
+ case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+ EV5) UNAME_MACHINE=alphaev5 ;;
+ EV56) UNAME_MACHINE=alphaev56 ;;
+ PCA56) UNAME_MACHINE=alphapca56 ;;
+ PCA57) UNAME_MACHINE=alphapca56 ;;
+ EV6) UNAME_MACHINE=alphaev6 ;;
+ EV67) UNAME_MACHINE=alphaev67 ;;
+ EV68*) UNAME_MACHINE=alphaev68 ;;
+ esac
+ objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
+ if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+ echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+ exit ;;
+ parisc:Linux:*:* | hppa:Linux:*:*)
+ # Look for CPU level
+ case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+ PA7*) echo hppa1.1-unknown-linux-gnu ;;
+ PA8*) echo hppa2.0-unknown-linux-gnu ;;
+ *) echo hppa-unknown-linux-gnu ;;
+ esac
+ exit ;;
+ parisc64:Linux:*:* | hppa64:Linux:*:*)
+ echo hppa64-unknown-linux-gnu
+ exit ;;
+ s390:Linux:*:* | s390x:Linux:*:*)
+ echo ${UNAME_MACHINE}-ibm-linux
+ exit ;;
+ sh64*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ sh*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ sparc:Linux:*:* | sparc64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ vax:Linux:*:*)
+ echo ${UNAME_MACHINE}-dec-linux-gnu
+ exit ;;
+ x86_64:Linux:*:*)
+ echo x86_64-unknown-linux-gnu
+ exit ;;
+ xtensa:Linux:*:*)
+ echo xtensa-unknown-linux-gnu
+ exit ;;
+ i*86:Linux:*:*)
+ # The BFD linker knows what the default object file format is, so
+ # first see if it will tell us. cd to the root directory to prevent
+ # problems with other programs or directories called `ld' in the path.
+ # Set LC_ALL=C to ensure ld outputs messages in English.
+ ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
+ | sed -ne '/supported targets:/!d
+ s/[ ][ ]*/ /g
+ s/.*supported targets: *//
+ s/ .*//
+ p'`
+ case "$ld_supported_targets" in
+ elf32-i386)
+ TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
+ ;;
+ a.out-i386-linux)
+ echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+ exit ;;
+ coff-i386)
+ echo "${UNAME_MACHINE}-pc-linux-gnucoff"
+ exit ;;
+ "")
+ # Either a pre-BFD a.out linker (linux-gnuoldld) or
+ # one that does not give us useful --help.
+ echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
+ exit ;;
+ esac
+ # Determine whether the default compiler is a.out or elf
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <features.h>
+ #ifdef __ELF__
+ # ifdef __GLIBC__
+ # if __GLIBC__ >= 2
+ LIBC=gnu
+ # else
+ LIBC=gnulibc1
+ # endif
+ # else
+ LIBC=gnulibc1
+ # endif
+ #else
+ #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
+ LIBC=gnu
+ #else
+ LIBC=gnuaout
+ #endif
+ #endif
+ #ifdef __dietlibc__
+ LIBC=dietlibc
+ #endif
+EOF
+ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+ /^LIBC/{
+ s: ::g
+ p
+ }'`"
+ test x"${LIBC}" != x && {
+ echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
+ exit
+ }
+ test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
+ ;;
+ i*86:DYNIX/ptx:4*:*)
+ # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+ # earlier versions are messed up and put the nodename in both
+ # sysname and nodename.
+ echo i386-sequent-sysv4
+ exit ;;
+ i*86:UNIX_SV:4.2MP:2.*)
+ # Unixware is an offshoot of SVR4, but it has its own version
+ # number series starting with 2...
+ # I am not positive that other SVR4 systems won't match this,
+ # I just have to hope. -- rms.
+ # Use sysv4.2uw... so that sysv4* matches it.
+ echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+ exit ;;
+ i*86:OS/2:*:*)
+ # If we were able to find `uname', then EMX Unix compatibility
+ # is probably installed.
+ echo ${UNAME_MACHINE}-pc-os2-emx
+ exit ;;
+ i*86:XTS-300:*:STOP)
+ echo ${UNAME_MACHINE}-unknown-stop
+ exit ;;
+ i*86:atheos:*:*)
+ echo ${UNAME_MACHINE}-unknown-atheos
+ exit ;;
+ i*86:syllable:*:*)
+ echo ${UNAME_MACHINE}-pc-syllable
+ exit ;;
+ i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
+ echo i386-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ i*86:*DOS:*:*)
+ echo ${UNAME_MACHINE}-pc-msdosdjgpp
+ exit ;;
+ i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+ UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+ if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+ echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+ else
+ echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+ fi
+ exit ;;
+ i*86:*:5:[678]*)
+ # UnixWare 7.x, OpenUNIX and OpenServer 6.
+ case `/bin/uname -X | grep "^Machine"` in
+ *486*) UNAME_MACHINE=i486 ;;
+ *Pentium) UNAME_MACHINE=i586 ;;
+ *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+ esac
+ echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+ exit ;;
+ i*86:*:3.2:*)
+ if test -f /usr/options/cb.name; then
+ UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+ echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+ elif /bin/uname -X 2>/dev/null >/dev/null ; then
+ UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
+ (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
+ (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
+ && UNAME_MACHINE=i586
+ (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
+ && UNAME_MACHINE=i686
+ (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
+ && UNAME_MACHINE=i686
+ echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+ else
+ echo ${UNAME_MACHINE}-pc-sysv32
+ fi
+ exit ;;
+ pc:*:*:*)
+ # Left here for compatibility:
+ # uname -m prints for DJGPP always 'pc', but it prints nothing about
+ # the processor, so we play safe by assuming i386.
+ echo i386-pc-msdosdjgpp
+ exit ;;
+ Intel:Mach:3*:*)
+ echo i386-pc-mach3
+ exit ;;
+ paragon:*:*:*)
+ echo i860-intel-osf1
+ exit ;;
+ i860:*:4.*:*) # i860-SVR4
+ if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+ echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+ else # Add other i860-SVR4 vendors below as they are discovered.
+ echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
+ fi
+ exit ;;
+ mini*:CTIX:SYS*5:*)
+ # "miniframe"
+ echo m68010-convergent-sysv
+ exit ;;
+ mc68k:UNIX:SYSTEM5:3.51m)
+ echo m68k-convergent-sysv
+ exit ;;
+ M680?0:D-NIX:5.3:*)
+ echo m68k-diab-dnix
+ exit ;;
+ M68*:*:R3V[5678]*:*)
+ test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
+ 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
+ OS_REL=''
+ test -r /etc/.relid \
+ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+ 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4; exit; } ;;
+ m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+ echo m68k-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ mc68030:UNIX_System_V:4.*:*)
+ echo m68k-atari-sysv4
+ exit ;;
+ TSUNAMI:LynxOS:2.*:*)
+ echo sparc-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ rs6000:LynxOS:2.*:*)
+ echo rs6000-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
+ echo powerpc-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ SM[BE]S:UNIX_SV:*:*)
+ echo mips-dde-sysv${UNAME_RELEASE}
+ exit ;;
+ RM*:ReliantUNIX-*:*:*)
+ echo mips-sni-sysv4
+ exit ;;
+ RM*:SINIX-*:*:*)
+ echo mips-sni-sysv4
+ exit ;;
+ *:SINIX-*:*:*)
+ if uname -p 2>/dev/null >/dev/null ; then
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ echo ${UNAME_MACHINE}-sni-sysv4
+ else
+ echo ns32k-sni-sysv
+ fi
+ exit ;;
+ PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+ # says <Richard.M.Bartel@ccMail.Census.GOV>
+ echo i586-unisys-sysv4
+ exit ;;
+ *:UNIX_System_V:4*:FTX*)
+ # From Gerald Hewes <hewes@openmarket.com>.
+ # How about differentiating between stratus architectures? -djm
+ echo hppa1.1-stratus-sysv4
+ exit ;;
+ *:*:*:FTX*)
+ # From seanf@swdc.stratus.com.
+ echo i860-stratus-sysv4
+ exit ;;
+ i*86:VOS:*:*)
+ # From Paul.Green@stratus.com.
+ echo ${UNAME_MACHINE}-stratus-vos
+ exit ;;
+ *:VOS:*:*)
+ # From Paul.Green@stratus.com.
+ echo hppa1.1-stratus-vos
+ exit ;;
+ mc68*:A/UX:*:*)
+ echo m68k-apple-aux${UNAME_RELEASE}
+ exit ;;
+ news*:NEWS-OS:6*:*)
+ echo mips-sony-newsos6
+ exit ;;
+ R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+ if [ -d /usr/nec ]; then
+ echo mips-nec-sysv${UNAME_RELEASE}
+ else
+ echo mips-unknown-sysv${UNAME_RELEASE}
+ fi
+ exit ;;
+ BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
+ echo powerpc-be-beos
+ exit ;;
+ BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
+ echo powerpc-apple-beos
+ exit ;;
+ BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
+ echo i586-pc-beos
+ exit ;;
+ SX-4:SUPER-UX:*:*)
+ echo sx4-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-5:SUPER-UX:*:*)
+ echo sx5-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-6:SUPER-UX:*:*)
+ echo sx6-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-7:SUPER-UX:*:*)
+ echo sx7-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-8:SUPER-UX:*:*)
+ echo sx8-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-8R:SUPER-UX:*:*)
+ echo sx8r-nec-superux${UNAME_RELEASE}
+ exit ;;
+ Power*:Rhapsody:*:*)
+ echo powerpc-apple-rhapsody${UNAME_RELEASE}
+ exit ;;
+ *:Rhapsody:*:*)
+ echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+ exit ;;
+ *:Darwin:*:*)
+ UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
+ case $UNAME_PROCESSOR in
+ unknown) UNAME_PROCESSOR=powerpc ;;
+ esac
+ echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+ exit ;;
+ *:procnto*:*:* | *:QNX:[0123456789]*:*)
+ UNAME_PROCESSOR=`uname -p`
+ if test "$UNAME_PROCESSOR" = "x86"; then
+ UNAME_PROCESSOR=i386
+ UNAME_MACHINE=pc
+ fi
+ echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+ exit ;;
+ *:QNX:*:4*)
+ echo i386-pc-qnx
+ exit ;;
+ NSE-?:NONSTOP_KERNEL:*:*)
+ echo nse-tandem-nsk${UNAME_RELEASE}
+ exit ;;
+ NSR-?:NONSTOP_KERNEL:*:*)
+ echo nsr-tandem-nsk${UNAME_RELEASE}
+ exit ;;
+ *:NonStop-UX:*:*)
+ echo mips-compaq-nonstopux
+ exit ;;
+ BS2000:POSIX*:*:*)
+ echo bs2000-siemens-sysv
+ exit ;;
+ DS/*:UNIX_System_V:*:*)
+ echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+ exit ;;
+ *:Plan9:*:*)
+ # "uname -m" is not consistent, so use $cputype instead. 386
+ # is converted to i386 for consistency with other x86
+ # operating systems.
+ if test "$cputype" = "386"; then
+ UNAME_MACHINE=i386
+ else
+ UNAME_MACHINE="$cputype"
+ fi
+ echo ${UNAME_MACHINE}-unknown-plan9
+ exit ;;
+ *:TOPS-10:*:*)
+ echo pdp10-unknown-tops10
+ exit ;;
+ *:TENEX:*:*)
+ echo pdp10-unknown-tenex
+ exit ;;
+ KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+ echo pdp10-dec-tops20
+ exit ;;
+ XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+ echo pdp10-xkl-tops20
+ exit ;;
+ *:TOPS-20:*:*)
+ echo pdp10-unknown-tops20
+ exit ;;
+ *:ITS:*:*)
+ echo pdp10-unknown-its
+ exit ;;
+ SEI:*:*:SEIUX)
+ echo mips-sei-seiux${UNAME_RELEASE}
+ exit ;;
+ *:DragonFly:*:*)
+ echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+ exit ;;
+ *:*VMS:*:*)
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ case "${UNAME_MACHINE}" in
+ A*) echo alpha-dec-vms ; exit ;;
+ I*) echo ia64-dec-vms ; exit ;;
+ V*) echo vax-dec-vms ; exit ;;
+ esac ;;
+ *:XENIX:*:SysV)
+ echo i386-pc-xenix
+ exit ;;
+ i*86:skyos:*:*)
+ echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
+ exit ;;
+ i*86:rdos:*:*)
+ echo ${UNAME_MACHINE}-pc-rdos
+ exit ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+eval $set_cc_for_build
+cat >$dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+ /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
+ I don't know.... */
+ printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+ printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+ "4"
+#else
+ ""
+#endif
+ ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+ printf ("arm-acorn-riscix\n"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+ printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+ int version;
+ version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+ if (version < 4)
+ printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+ else
+ printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+ exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+ printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+ printf ("ns32k-encore-mach\n"); exit (0);
+#else
+ printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+ printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+ printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+ printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+ struct utsname un;
+
+ uname(&un);
+
+ if (strncmp(un.version, "V2", 2) == 0) {
+ printf ("i386-sequent-ptx2\n"); exit (0);
+ }
+ if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+ printf ("i386-sequent-ptx1\n"); exit (0);
+ }
+ printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+# if !defined (ultrix)
+# include <sys/param.h>
+# if defined (BSD)
+# if BSD == 43
+ printf ("vax-dec-bsd4.3\n"); exit (0);
+# else
+# if BSD == 199006
+ printf ("vax-dec-bsd4.3reno\n"); exit (0);
+# else
+ printf ("vax-dec-bsd\n"); exit (0);
+# endif
+# endif
+# else
+ printf ("vax-dec-bsd\n"); exit (0);
+# endif
+# else
+ printf ("vax-dec-ultrix\n"); exit (0);
+# endif
+#endif
+
+#if defined (alliant) && defined (i860)
+ printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+ exit (1);
+}
+EOF
+
+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
+ { echo "$SYSTEM_NAME"; exit; }
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+ case `getsysinfo -f cpu_type` in
+ c1*)
+ echo c1-convex-bsd
+ exit ;;
+ c2*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit ;;
+ c34*)
+ echo c34-convex-bsd
+ exit ;;
+ c38*)
+ echo c38-convex-bsd
+ exit ;;
+ c4*)
+ echo c4-convex-bsd
+ exit ;;
+ esac
+fi
+
+cat >&2 <<EOF
+$0: unable to guess system type
+
+This script, last modified $timestamp, has failed to recognize
+the operating system you are using. It is advised that you
+download the most up to date version of the config scripts from
+
+ http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
+and
+ http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches@gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo = `(hostinfo) 2>/dev/null`
+/bin/universe = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/thirdparty/glog/glog-0.3.5/config.sub b/thirdparty/glog/glog-0.3.5/config.sub
new file mode 100644
index 0000000..1761d8b
--- /dev/null
+++ b/thirdparty/glog/glog-0.3.5/config.sub
@@ -0,0 +1,1626 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
+# Inc.
+
+timestamp='2007-06-28'
+
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine. It does not imply ALL GNU software can.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Please send patches to <config-patches@gnu.org>. Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support. The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+ $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit ;;
+ --version | -v )
+ echo "$version" ; exit ;;
+ --help | --h* | -h )
+ echo "$usage"; exit ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help"
+ exit 1 ;;
+
+ *local*)
+ # First pass through any local machine types.
+ echo $1
+ exit ;;
+
+ * )
+ break ;;
+ esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+ exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+ exit 1;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+ nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
+ uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
+ storm-chaos* | os2-emx* | rtmk-nova*)
+ os=-$maybe_os
+ basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+ ;;
+ *)
+ basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+ if [ $basic_machine != $1 ]
+ then os=`echo $1 | sed 's/.*-/-/'`
+ else os=; fi
+ ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work. We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+ -sun*os*)
+ # Prevent following clause from handling this invalid input.
+ ;;
+ -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+ -apple | -axis | -knuth | -cray)
+ os=
+ basic_machine=$1
+ ;;
+ -sim | -cisco | -oki | -wec | -winbond)
+ os=
+ basic_machine=$1
+ ;;
+ -scout)
+ ;;
+ -wrs)
+ os=-vxworks
+ basic_machine=$1
+ ;;
+ -chorusos*)
+ os=-chorusos
+ basic_machine=$1
+ ;;
+ -chorusrdb)
+ os=-chorusrdb
+ basic_machine=$1
+ ;;
+ -hiux*)
+ os=-hiuxwe2
+ ;;
+ -sco6)
+ os=-sco5v6
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco5)
+ os=-sco3.2v5
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco4)
+ os=-sco3.2v4
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2.[4-9]*)
+ os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2v[4-9]*)
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco5v6*)
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco*)
+ os=-sco3.2v2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -udk*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -isc)
+ os=-isc2.2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -clix*)
+ basic_machine=clipper-intergraph
+ ;;
+ -isc*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -lynx*)
+ os=-lynxos
+ ;;
+ -ptx*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+ ;;
+ -windowsnt*)
+ os=`echo $os | sed -e 's/windowsnt/winnt/'`
+ ;;
+ -psos*)
+ os=-psos
+ ;;
+ -mint | -mint[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+ # Recognize the basic CPU types without company name.
+ # Some are omitted here because they have special meanings below.
+ 1750a | 580 \
+ | a29k \
+ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+ | am33_2.0 \
+ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
+ | bfin \
+ | c4x | clipper \
+ | d10v | d30v | dlx | dsp16xx \
+ | fido | fr30 | frv \
+ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+ | i370 | i860 | i960 | ia64 \
+ | ip2k | iq2000 \
+ | m32c | m32r | m32rle | m68000 | m68k | m88k \
+ | maxq | mb | microblaze | mcore | mep \
+ | mips | mipsbe | mipseb | mipsel | mipsle \
+ | mips16 \
+ | mips64 | mips64el \
+ | mips64vr | mips64vrel \
+ | mips64orion | mips64orionel \
+ | mips64vr4100 | mips64vr4100el \
+ | mips64vr4300 | mips64vr4300el \
+ | mips64vr5000 | mips64vr5000el \
+ | mips64vr5900 | mips64vr5900el \
+ | mipsisa32 | mipsisa32el \
+ | mipsisa32r2 | mipsisa32r2el \
+ | mipsisa64 | mipsisa64el \
+ | mipsisa64r2 | mipsisa64r2el \
+ | mipsisa64sb1 | mipsisa64sb1el \
+ | mipsisa64sr71k | mipsisa64sr71kel \
+ | mipstx39 | mipstx39el \
+ | mn10200 | mn10300 \
+ | mt \
+ | msp430 \
+ | nios | nios2 \
+ | ns16k | ns32k \
+ | or32 \
+ | pdp10 | pdp11 | pj | pjl \
+ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+ | pyramid \
+ | score \
+ | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+ | sh64 | sh64le \
+ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
+ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
+ | spu | strongarm \
+ | tahoe | thumb | tic4x | tic80 | tron \
+ | v850 | v850e \
+ | we32k \
+ | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
+ | z8k)
+ basic_machine=$basic_machine-unknown
+ ;;
+ m6811 | m68hc11 | m6812 | m68hc12)
+ # Motorola 68HC11/12.
+ basic_machine=$basic_machine-unknown
+ os=-none
+ ;;
+ m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+ ;;
+ ms1)
+ basic_machine=mt-unknown
+ ;;
+
+ # We use `pc' rather than `unknown'
+ # because (1) that's what they normally are, and
+ # (2) the word "unknown" tends to confuse beginning users.
+ i*86 | x86_64)
+ basic_machine=$basic_machine-pc
+ ;;
+ # Object if more than one company name word.
+ *-*-*)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+ # Recognize the basic CPU types with company name.
+ 580-* \
+ | a29k-* \
+ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
+ | avr-* | avr32-* \
+ | bfin-* | bs2000-* \
+ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
+ | clipper-* | craynv-* | cydra-* \
+ | d10v-* | d30v-* | dlx-* \
+ | elxsi-* \
+ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
+ | h8300-* | h8500-* \
+ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+ | i*86-* | i860-* | i960-* | ia64-* \
+ | ip2k-* | iq2000-* \
+ | m32c-* | m32r-* | m32rle-* \
+ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+ | m88110-* | m88k-* | maxq-* | mcore-* \
+ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+ | mips16-* \
+ | mips64-* | mips64el-* \
+ | mips64vr-* | mips64vrel-* \
+ | mips64orion-* | mips64orionel-* \
+ | mips64vr4100-* | mips64vr4100el-* \
+ | mips64vr4300-* | mips64vr4300el-* \
+ | mips64vr5000-* | mips64vr5000el-* \
+ | mips64vr5900-* | mips64vr5900el-* \
+ | mipsisa32-* | mipsisa32el-* \
+ | mipsisa32r2-* | mipsisa32r2el-* \
+ | mipsisa64-* | mipsisa64el-* \
+ | mipsisa64r2-* | mipsisa64r2el-* \
+ | mipsisa64sb1-* | mipsisa64sb1el-* \
+ | mipsisa64sr71k-* | mipsisa64sr71kel-* \
+ | mipstx39-* | mipstx39el-* \
+ | mmix-* \
+ | mt-* \
+ | msp430-* \
+ | nios-* | nios2-* \
+ | none-* | np1-* | ns16k-* | ns32k-* \
+ | orion-* \
+ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+ | pyramid-* \
+ | romp-* | rs6000-* \
+ | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
+ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
+ | sparclite-* \
+ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
+ | tahoe-* | thumb-* \
+ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
+ | tron-* \
+ | v850-* | v850e-* | vax-* \
+ | we32k-* \
+ | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
+ | xstormy16-* | xtensa-* \
+ | ymp-* \
+ | z8k-*)
+ ;;
+ # Recognize the various machine names and aliases which stand
+ # for a CPU type and a company and sometimes even an OS.
+ 386bsd)
+ basic_machine=i386-unknown
+ os=-bsd
+ ;;
+ 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+ basic_machine=m68000-att
+ ;;
+ 3b*)
+ basic_machine=we32k-att
+ ;;
+ a29khif)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ abacus)
+ basic_machine=abacus-unknown
+ ;;
+ adobe68k)
+ basic_machine=m68010-adobe
+ os=-scout
+ ;;
+ alliant | fx80)
+ basic_machine=fx80-alliant
+ ;;
+ altos | altos3068)
+ basic_machine=m68k-altos
+ ;;
+ am29k)
+ basic_machine=a29k-none
+ os=-bsd
+ ;;
+ amd64)
+ basic_machine=x86_64-pc
+ ;;
+ amd64-*)
+ basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ amdahl)
+ basic_machine=580-amdahl
+ os=-sysv
+ ;;
+ amiga | amiga-*)
+ basic_machine=m68k-unknown
+ ;;
+ amigaos | amigados)
+ basic_machine=m68k-unknown
+ os=-amigaos
+ ;;
+ amigaunix | amix)
+ basic_machine=m68k-unknown
+ os=-sysv4
+ ;;
+ apollo68)
+ basic_machine=m68k-apollo
+ os=-sysv
+ ;;
+ apollo68bsd)
+ basic_machine=m68k-apollo
+ os=-bsd
+ ;;
+ aux)
+ basic_machine=m68k-apple
+ os=-aux
+ ;;
+ balance)
+ basic_machine=ns32k-sequent
+ os=-dynix
+ ;;
+ c90)
+ basic_machine=c90-cray
+ os=-unicos
+ ;;
+ convex-c1)
+ basic_machine=c1-convex
+ os=-bsd
+ ;;
+ convex-c2)
+ basic_machine=c2-convex
+ os=-bsd
+ ;;
+ convex-c32)
+ basic_machine=c32-convex
+ os=-bsd
+ ;;
+ convex-c34)
+ basic_machine=c34-convex
+ os=-bsd
+ ;;
+ convex-c38)
+ basic_machine=c38-convex
+ os=-bsd
+ ;;
+ cray | j90)
+ basic_machine=j90-cray
+ os=-unicos
+ ;;
+ craynv)
+ basic_machine=craynv-cray
+ os=-unicosmp
+ ;;
+ cr16)
+ basic_machine=cr16-unknown
+ os=-elf
+ ;;
+ crds | unos)
+ basic_machine=m68k-crds
+ ;;
+ crisv32 | crisv32-* | etraxfs*)
+ basic_machine=crisv32-axis
+ ;;
+ cris | cris-* | etrax*)
+ basic_machine=cris-axis
+ ;;
+ crx)
+ basic_machine=crx-unknown
+ os=-elf
+ ;;
+ da30 | da30-*)
+ basic_machine=m68k-da30
+ ;;
+ decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+ basic_machine=mips-dec
+ ;;
+ decsystem10* | dec10*)
+ basic_machine=pdp10-dec
+ os=-tops10
+ ;;
+ decsystem20* | dec20*)
+ basic_machine=pdp10-dec
+ os=-tops20
+ ;;
+ delta | 3300 | motorola-3300 | motorola-delta \
+ | 3300-motorola | delta-motorola)
+ basic_machine=m68k-motorola
+ ;;
+ delta88)
+ basic_machine=m88k-motorola
+ os=-sysv3
+ ;;
+ djgpp)
+ basic_machine=i586-pc
+ os=-msdosdjgpp
+ ;;
+ dpx20 | dpx20-*)
+ basic_machine=rs6000-bull
+ os=-bosx
+ ;;
+ dpx2* | dpx2*-bull)
+ basic_machine=m68k-bull
+ os=-sysv3
+ ;;
+ ebmon29k)
+ basic_machine=a29k-amd
+ os=-ebmon
+ ;;
+ elxsi)
+ basic_machine=elxsi-elxsi
+ os=-bsd
+ ;;
+ encore | umax | mmax)
+ basic_machine=ns32k-encore
+ ;;
+ es1800 | OSE68k | ose68k | ose | OSE)
+ basic_machine=m68k-ericsson
+ os=-ose
+ ;;
+ fx2800)
+ basic_machine=i860-alliant
+ ;;
+ genix)
+ basic_machine=ns32k-ns
+ ;;
+ gmicro)
+ basic_machine=tron-gmicro
+ os=-sysv
+ ;;
+ go32)
+ basic_machine=i386-pc
+ os=-go32
+ ;;
+ h3050r* | hiux*)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ h8300hms)
+ basic_machine=h8300-hitachi
+ os=-hms
+ ;;
+ h8300xray)
+ basic_machine=h8300-hitachi
+ os=-xray
+ ;;
+ h8500hms)
+ basic_machine=h8500-hitachi
+ os=-hms
+ ;;
+ harris)
+ basic_machine=m88k-harris
+ os=-sysv3
+ ;;
+ hp300-*)
+ basic_machine=m68k-hp
+ ;;
+ hp300bsd)
+ basic_machine=m68k-hp
+ os=-bsd
+ ;;
+ hp300hpux)
+ basic_machine=m68k-hp
+ os=-hpux
+ ;;
+ hp3k9[0-9][0-9] | hp9[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k2[0-9][0-9] | hp9k31[0-9])
+ basic_machine=m68000-hp
+ ;;
+ hp9k3[2-9][0-9])
+ basic_machine=m68k-hp
+ ;;
+ hp9k6[0-9][0-9] | hp6[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k7[0-79][0-9] | hp7[0-79][0-9])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k78[0-9] | hp78[0-9])
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][13679] | hp8[0-9][13679])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][0-9] | hp8[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hppa-next)
+ os=-nextstep3
+ ;;
+ hppaosf)
+ basic_machine=hppa1.1-hp
+ os=-osf
+ ;;
+ hppro)
+ basic_machine=hppa1.1-hp
+ os=-proelf
+ ;;
+ i370-ibm* | ibm*)
+ basic_machine=i370-ibm
+ ;;
+# I'm not sure what "Sysv32" means. Should this be sysv3.2?
+ i*86v32)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv32
+ ;;
+ i*86v4*)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv4
+ ;;
+ i*86v)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv
+ ;;
+ i*86sol2)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-solaris2
+ ;;
+ i386mach)
+ basic_machine=i386-mach
+ os=-mach
+ ;;
+ i386-vsta | vsta)
+ basic_machine=i386-unknown
+ os=-vsta
+ ;;
+ iris | iris4d)
+ basic_machine=mips-sgi
+ case $os in
+ -irix*)
+ ;;
+ *)
+ os=-irix4
+ ;;
+ esac
+ ;;
+ isi68 | isi)
+ basic_machine=m68k-isi
+ os=-sysv
+ ;;
+ m88k-omron*)
+ basic_machine=m88k-omron
+ ;;
+ magnum | m3230)
+ basic_machine=mips-mips
+ os=-sysv
+ ;;
+ merlin)
+ basic_machine=ns32k-utek
+ os=-sysv
+ ;;
+ mingw32)
+ basic_machine=i386-pc
+ os=-mingw32
+ ;;
+ mingw32ce)
+ basic_machine=arm-unknown
+ os=-mingw32ce
+ ;;
+ miniframe)
+ basic_machine=m68000-convergent
+ ;;
+ *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+ mips3*-*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+ ;;
+ mips3*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+ ;;
+ monitor)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ morphos)
+ basic_machine=powerpc-unknown
+ os=-morphos
+ ;;
+ msdos)
+ basic_machine=i386-pc
+ os=-msdos
+ ;;
+ ms1-*)
+ basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
+ ;;
+ mvs)
+ basic_machine=i370-ibm
+ os=-mvs
+ ;;
+ ncr3000)
+ basic_machine=i486-ncr
+ os=-sysv4
+ ;;
+ netbsd386)
+ basic_machine=i386-unknown
+ os=-netbsd
+ ;;
+ netwinder)
+ basic_machine=armv4l-rebel
+ os=-linux
+ ;;
+ news | news700 | news800 | news900)
+ basic_machine=m68k-sony
+ os=-newsos
+ ;;
+ news1000)
+ basic_machine=m68030-sony
+ os=-newsos
+ ;;
+ news-3600 | risc-news)
+ basic_machine=mips-sony
+ os=-newsos
+ ;;
+ necv70)
+ basic_machine=v70-nec
+ os=-sysv
+ ;;
+ next | m*-next )
+ basic_machine=m68k-next
+ case $os in
+ -nextstep* )
+ ;;
+ -ns2*)
+ os=-nextstep2
+ ;;
+ *)
+ os=-nextstep3
+ ;;
+ esac
+ ;;
+ nh3000)
+ basic_machine=m68k-harris
+ os=-cxux
+ ;;
+ nh[45]000)
+ basic_machine=m88k-harris
+ os=-cxux
+ ;;
+ nindy960)
+ basic_machine=i960-intel
+ os=-nindy
+ ;;
+ mon960)
+ basic_machine=i960-intel
+ os=-mon960
+ ;;
+ nonstopux)
+ basic_machine=mips-compaq
+ os=-nonstopux
+ ;;
+ np1)
+ basic_machine=np1-gould
+ ;;
+ nsr-tandem)
+ basic_machine=nsr-tandem
+ ;;
+ op50n-* | op60c-*)
+ basic_machine=hppa1.1-oki
+ os=-proelf
+ ;;
+ openrisc | openrisc-*)
+ basic_machine=or32-unknown
+ ;;
+ os400)
+ basic_machine=powerpc-ibm
+ os=-os400
+ ;;
+ OSE68000 | ose68000)
+ basic_machine=m68000-ericsson
+ os=-ose
+ ;;
+ os68k)
+ basic_machine=m68k-none
+ os=-os68k
+ ;;
+ pa-hitachi)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ paragon)
+ basic_machine=i860-intel
+ os=-osf
+ ;;
+ pbd)
+ basic_machine=sparc-tti
+ ;;
+ pbb)
+ basic_machine=m68k-tti
+ ;;
+ pc532 | pc532-*)
+ basic_machine=ns32k-pc532
+ ;;
+ pc98)
+ basic_machine=i386-pc
+ ;;
+ pc98-*)
+ basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentium | p5 | k5 | k6 | nexgen | viac3)
+ basic_machine=i586-pc
+ ;;
+ pentiumpro | p6 | 6x86 | athlon | athlon_*)
+ basic_machine=i686-pc
+ ;;
+ pentiumii | pentium2 | pentiumiii | pentium3)
+ basic_machine=i686-pc
+ ;;
+ pentium4)
+ basic_machine=i786-pc
+ ;;
+ pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+ basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumpro-* | p6-* | 6x86-* | athlon-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentium4-*)
+ basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pn)
+ basic_machine=pn-gould
+ ;;
+ power) basic_machine=power-ibm
+ ;;
+ ppc) basic_machine=powerpc-unknown
+ ;;
+ ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppcle | powerpclittle | ppc-le | powerpc-little)
+ basic_machine=powerpcle-unknown
+ ;;
+ ppcle-* | powerpclittle-*)
+ basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppc64) basic_machine=powerpc64-unknown
+ ;;
+ ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+ basic_machine=powerpc64le-unknown
+ ;;
+ ppc64le-* | powerpc64little-*)
+ basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ps2)
+ basic_machine=i386-ibm
+ ;;
+ pw32)
+ basic_machine=i586-unknown
+ os=-pw32
+ ;;
+ rdos)
+ basic_machine=i386-pc
+ os=-rdos
+ ;;
+ rom68k)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ rm[46]00)
+ basic_machine=mips-siemens
+ ;;
+ rtpc | rtpc-*)
+ basic_machine=romp-ibm
+ ;;
+ s390 | s390-*)
+ basic_machine=s390-ibm
+ ;;
+ s390x | s390x-*)
+ basic_machine=s390x-ibm
+ ;;
+ sa29200)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ sb1)
+ basic_machine=mipsisa64sb1-unknown
+ ;;
+ sb1el)
+ basic_machine=mipsisa64sb1el-unknown
+ ;;
+ sde)
+ basic_machine=mipsisa32-sde
+ os=-elf
+ ;;
+ sei)
+ basic_machine=mips-sei
+ os=-seiux
+ ;;
+ sequent)
+ basic_machine=i386-sequent
+ ;;
+ sh)
+ basic_machine=sh-hitachi
+ os=-hms
+ ;;
+ sh5el)
+ basic_machine=sh5le-unknown
+ ;;
+ sh64)
+ basic_machine=sh64-unknown
+ ;;
+ sparclite-wrs | simso-wrs)
+ basic_machine=sparclite-wrs
+ os=-vxworks
+ ;;
+ sps7)
+ basic_machine=m68k-bull
+ os=-sysv2
+ ;;
+ spur)
+ basic_machine=spur-unknown
+ ;;
+ st2000)
+ basic_machine=m68k-tandem
+ ;;
+ stratus)
+ basic_machine=i860-stratus
+ os=-sysv4
+ ;;
+ sun2)
+ basic_machine=m68000-sun
+ ;;
+ sun2os3)
+ basic_machine=m68000-sun
+ os=-sunos3
+ ;;
+ sun2os4)
+ basic_machine=m68000-sun
+ os=-sunos4
+ ;;
+ sun3os3)
+ basic_machine=m68k-sun
+ os=-sunos3
+ ;;
+ sun3os4)
+ basic_machine=m68k-sun
+ os=-sunos4
+ ;;
+ sun4os3)
+ basic_machine=sparc-sun
+ os=-sunos3
+ ;;
+ sun4os4)
+ basic_machine=sparc-sun
+ os=-sunos4
+ ;;
+ sun4sol2)
+ basic_machine=sparc-sun
+ os=-solaris2
+ ;;
+ sun3 | sun3-*)
+ basic_machine=m68k-sun
+ ;;
+ sun4)
+ basic_machine=sparc-sun
+ ;;
+ sun386 | sun386i | roadrunner)
+ basic_machine=i386-sun
+ ;;
+ sv1)
+ basic_machine=sv1-cray
+ os=-unicos
+ ;;
+ symmetry)
+ basic_machine=i386-sequent
+ os=-dynix
+ ;;
+ t3e)
+ basic_machine=alphaev5-cray
+ os=-unicos
+ ;;
+ t90)
+ basic_machine=t90-cray
+ os=-unicos
+ ;;
+ tic54x | c54x*)
+ basic_machine=tic54x-unknown
+ os=-coff
+ ;;
+ tic55x | c55x*)
+ basic_machine=tic55x-unknown
+ os=-coff
+ ;;
+ tic6x | c6x*)
+ basic_machine=tic6x-unknown
+ os=-coff
+ ;;
+ tx39)
+ basic_machine=mipstx39-unknown
+ ;;
+ tx39el)
+ basic_machine=mipstx39el-unknown
+ ;;
+ toad1)
+ basic_machine=pdp10-xkl
+ os=-tops20
+ ;;
+ tower | tower-32)
+ basic_machine=m68k-ncr
+ ;;
+ tpf)
+ basic_machine=s390x-ibm
+ os=-tpf
+ ;;
+ udi29k)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ ultra3)
+ basic_machine=a29k-nyu
+ os=-sym1
+ ;;
+ v810 | necv810)
+ basic_machine=v810-nec
+ os=-none
+ ;;
+ vaxv)
+ basic_machine=vax-dec
+ os=-sysv
+ ;;
+ vms)
+ basic_machine=vax-dec
+ os=-vms
+ ;;
+ vpp*|vx|vx-*)
+ basic_machine=f301-fujitsu
+ ;;
+ vxworks960)
+ basic_machine=i960-wrs
+ os=-vxworks
+ ;;
+ vxworks68)
+ basic_machine=m68k-wrs
+ os=-vxworks
+ ;;
+ vxworks29k)
+ basic_machine=a29k-wrs
+ os=-vxworks
+ ;;
+ w65*)
+ basic_machine=w65-wdc
+ os=-none
+ ;;
+ w89k-*)
+ basic_machine=hppa1.1-winbond
+ os=-proelf
+ ;;
+ xbox)
+ basic_machine=i686-pc
+ os=-mingw32
+ ;;
+ xps | xps100)
+ basic_machine=xps100-honeywell
+ ;;
+ ymp)
+ basic_machine=ymp-cray
+ os=-unicos
+ ;;
+ z8k-*-coff)
+ basic_machine=z8k-unknown
+ os=-sim
+ ;;
+ none)
+ basic_machine=none-none
+ os=-none
+ ;;
+
+# Here we handle the default manufacturer of certain CPU types. It is in
+# some cases the only manufacturer, in others, it is the most popular.
+ w89k)
+ basic_machine=hppa1.1-winbond
+ ;;
+ op50n)
+ basic_machine=hppa1.1-oki
+ ;;
+ op60c)
+ basic_machine=hppa1.1-oki
+ ;;
+ romp)
+ basic_machine=romp-ibm
+ ;;
+ mmix)
+ basic_machine=mmix-knuth
+ ;;
+ rs6000)
+ basic_machine=rs6000-ibm
+ ;;
+ vax)
+ basic_machine=vax-dec
+ ;;
+ pdp10)
+ # there are many clones, so DEC is not a safe bet
+ basic_machine=pdp10-unknown
+ ;;
+ pdp11)
+ basic_machine=pdp11-dec
+ ;;
+ we32k)
+ basic_machine=we32k-att
+ ;;
+ sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
+ basic_machine=sh-unknown
+ ;;
+ sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
+ basic_machine=sparc-sun
+ ;;
+ cydra)
+ basic_machine=cydra-cydrome
+ ;;
+ orion)
+ basic_machine=orion-highlevel
+ ;;
+ orion105)
+ basic_machine=clipper-highlevel
+ ;;
+ mac | mpw | mac-mpw)
+ basic_machine=m68k-apple
+ ;;
+ pmac | pmac-mpw)
+ basic_machine=powerpc-apple
+ ;;
+ *-unknown)
+ # Make sure to match an already-canonicalized machine name.
+ ;;
+ *)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+ *-digital*)
+ basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+ ;;
+ *-commodore*)
+ basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+ ;;
+ *)
+ ;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+ # First match some system type aliases
+ # that might get confused with valid system types.
+ # -solaris* is a basic system type, with this one exception.
+ -solaris1 | -solaris1.*)
+ os=`echo $os | sed -e 's|solaris1|sunos4|'`
+ ;;
+ -solaris)
+ os=-solaris2
+ ;;
+ -svr4*)
+ os=-sysv4
+ ;;
+ -unixware*)
+ os=-sysv4.2uw
+ ;;
+ -gnu/linux*)
+ os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+ ;;
+ # First accept the basic system types.
+ # The portable systems comes first.
+ # Each alternative MUST END IN A *, to match a version number.
+ # -sysv* is not here because it comes later, after sysvr4.
+ -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
+ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+ | -aos* \
+ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
+ | -openbsd* | -solidbsd* \
+ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
+ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ | -chorusos* | -chorusrdb* \
+ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
+ | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
+ | -skyos* | -haiku* | -rdos* | -toppers* | -drops*)
+ # Remember, each alternative MUST END IN *, to match a version number.
+ ;;
+ -qnx*)
+ case $basic_machine in
+ x86-* | i*86-*)
+ ;;
+ *)
+ os=-nto$os
+ ;;
+ esac
+ ;;
+ -nto-qnx*)
+ ;;
+ -nto*)
+ os=`echo $os | sed -e 's|nto|nto-qnx|'`
+ ;;
+ -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
+ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+ ;;
+ -mac*)
+ os=`echo $os | sed -e 's|mac|macos|'`
+ ;;
+ -linux-dietlibc)
+ os=-linux-dietlibc
+ ;;
+ -linux*)
+ os=`echo $os | sed -e 's|linux|linux-gnu|'`
+ ;;
+ -sunos5*)
+ os=`echo $os | sed -e 's|sunos5|solaris2|'`
+ ;;
+ -sunos6*)
+ os=`echo $os | sed -e 's|sunos6|solaris3|'`
+ ;;
+ -opened*)
+ os=-openedition
+ ;;
+ -os400*)
+ os=-os400
+ ;;
+ -wince*)
+ os=-wince
+ ;;
+ -osfrose*)
+ os=-osfrose
+ ;;
+ -osf*)
+ os=-osf
+ ;;
+ -utek*)
+ os=-bsd
+ ;;
+ -dynix*)
+ os=-bsd
+ ;;
+ -acis*)
+ os=-aos
+ ;;
+ -atheos*)
+ os=-atheos
+ ;;
+ -syllable*)
+ os=-syllable
+ ;;
+ -386bsd)
+ os=-bsd
+ ;;
+ -ctix* | -uts*)
+ os=-sysv
+ ;;
+ -nova*)
+ os=-rtmk-nova
+ ;;
+ -ns2 )
+ os=-nextstep2
+ ;;
+ -nsk*)
+ os=-nsk
+ ;;
+ # Preserve the version number of sinix5.
+ -sinix5.*)
+ os=`echo $os | sed -e 's|sinix|sysv|'`
+ ;;
+ -sinix*)
+ os=-sysv4
+ ;;
+ -tpf*)
+ os=-tpf
+ ;;
+ -triton*)
+ os=-sysv3
+ ;;
+ -oss*)
+ os=-sysv3
+ ;;
+ -svr4)
+ os=-sysv4
+ ;;
+ -svr3)
+ os=-sysv3
+ ;;
+ -sysvr4)
+ os=-sysv4
+ ;;
+ # This must come after -sysvr4.
+ -sysv*)
+ ;;
+ -ose*)
+ os=-ose
+ ;;
+ -es1800*)
+ os=-ose
+ ;;
+ -xenix)
+ os=-xenix
+ ;;
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ os=-mint
+ ;;
+ -aros*)
+ os=-aros
+ ;;
+ -kaos*)
+ os=-kaos
+ ;;
+ -zvmoe)
+ os=-zvmoe
+ ;;
+ -none)
+ ;;
+ *)
+ # Get rid of the `-' at the beginning of $os.
+ os=`echo $os | sed 's/[^-]*-//'`
+ echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system. Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+ score-*)
+ os=-elf
+ ;;
+ spu-*)
+ os=-elf
+ ;;
+ *-acorn)
+ os=-riscix1.2
+ ;;
+ arm*-rebel)
+ os=-linux
+ ;;
+ arm*-semi)
+ os=-aout
+ ;;
+ c4x-* | tic4x-*)
+ os=-coff
+ ;;
+ # This must come before the *-dec entry.
+ pdp10-*)
+ os=-tops20
+ ;;
+ pdp11-*)
+ os=-none
+ ;;
+ *-dec | vax-*)
+ os=-ultrix4.2
+ ;;
+ m68*-apollo)
+ os=-domain
+ ;;
+ i386-sun)
+ os=-sunos4.0.2
+ ;;
+ m68000-sun)
+ os=-sunos3
+ # This also exists in the configure program, but was not the
+ # default.
+ # os=-sunos4
+ ;;
+ m68*-cisco)
+ os=-aout
+ ;;
+ mep-*)
+ os=-elf
+ ;;
+ mips*-cisco)
+ os=-elf
+ ;;
+ mips*-*)
+ os=-elf
+ ;;
+ or32-*)
+ os=-coff
+ ;;
+ *-tti) # must be before sparc entry or we get the wrong os.
+ os=-sysv3
+ ;;
+ sparc-* | *-sun)
+ os=-sunos4.1.1
+ ;;
+ *-be)
+ os=-beos
+ ;;
+ *-haiku)
+ os=-haiku
+ ;;
+ *-ibm)
+ os=-aix
+ ;;
+ *-knuth)
+ os=-mmixware
+ ;;
+ *-wec)
+ os=-proelf
+ ;;
+ *-winbond)
+ os=-proelf
+ ;;
+ *-oki)
+ os=-proelf
+ ;;
+ *-hp)
+ os=-hpux
+ ;;
+ *-hitachi)
+ os=-hiux
+ ;;
+ i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+ os=-sysv
+ ;;
+ *-cbm)
+ os=-amigaos
+ ;;
+ *-dg)
+ os=-dgux
+ ;;
+ *-dolphin)
+ os=-sysv3
+ ;;
+ m68k-ccur)
+ os=-rtu
+ ;;
+ m88k-omron*)
+ os=-luna
+ ;;
+ *-next )
+ os=-nextstep
+ ;;
+ *-sequent)
+ os=-ptx
+ ;;
+ *-crds)
+ os=-unos
+ ;;
+ *-ns)
+ os=-genix
+ ;;
+ i370-*)
+ os=-mvs
+ ;;
+ *-next)
+ os=-nextstep3
+ ;;
+ *-gould)
+ os=-sysv
+ ;;
+ *-highlevel)
+ os=-bsd
+ ;;
+ *-encore)
+ os=-bsd
+ ;;
+ *-sgi)
+ os=-irix
+ ;;
+ *-siemens)
+ os=-sysv4
+ ;;
+ *-masscomp)
+ os=-rtu
+ ;;
+ f30[01]-fujitsu | f700-fujitsu)
+ os=-uxpv
+ ;;
+ *-rom68k)
+ os=-coff
+ ;;
+ *-*bug)
+ os=-coff
+ ;;
+ *-apple)
+ os=-macos
+ ;;
+ *-atari*)
+ os=-mint
+ ;;
+ *)
+ os=-none
+ ;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer. We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+ *-unknown)
+ case $os in
+ -riscix*)
+ vendor=acorn
+ ;;
+ -sunos*)
+ vendor=sun
+ ;;
+ -aix*)
+ vendor=ibm
+ ;;
+ -beos*)
+ vendor=be
+ ;;
+ -hpux*)
+ vendor=hp
+ ;;
+ -mpeix*)
+ vendor=hp
+ ;;
+ -hiux*)
+ vendor=hitachi
+ ;;
+ -unos*)
+ vendor=crds
+ ;;
+ -dgux*)
+ vendor=dg
+ ;;
+ -luna*)
+ vendor=omron
+ ;;
+ -genix*)
+ vendor=ns
+ ;;
+ -mvs* | -opened*)
+ vendor=ibm
+ ;;
+ -os400*)
+ vendor=ibm
+ ;;
+ -ptx*)
+ vendor=sequent
+ ;;
+ -tpf*)
+ vendor=ibm
+ ;;
+ -vxsim* | -vxworks* | -windiss*)
+ vendor=wrs
+ ;;
+ -aux*)
+ vendor=apple
+ ;;
+ -hms*)
+ vendor=hitachi
+ ;;
+ -mpw* | -macos*)
+ vendor=apple
+ ;;
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ vendor=atari
+ ;;
+ -vos*)
+ vendor=stratus
+ ;;
+ esac
+ basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+ ;;
+esac
+
+echo $basic_machine$os
+exit
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/thirdparty/glog/glog-0.3.5/configure b/thirdparty/glog/glog-0.3.5/configure
new file mode 100644
index 0000000..63d7e41
--- /dev/null
+++ b/thirdparty/glog/glog-0.3.5/configure
@@ -0,0 +1,20104 @@
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.69 for glog 0.3.5.
+#
+# Report bugs to <opensource@google.com>.
+#
+#
+# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
+#
+#
+# This file has been modified by Huawei.
+# Copyright (C) 2018-2019, Huawei.
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+ emulate sh
+ NULLCMD=:
+ # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in #(
+ *posix*) :
+ set -o posix ;; #(
+ *) :
+ ;;
+esac
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+ as_echo='print -r --'
+ as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+ as_echo='printf %s\n'
+ as_echo_n='printf %s'
+else
+ if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+ as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+ as_echo_n='/usr/ucb/echo -n'
+ else
+ as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+ as_echo_n_body='eval
+ arg=$1;
+ case $arg in #(
+ *"$as_nl"*)
+ expr "X$arg" : "X\\(.*\\)$as_nl";
+ arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+ esac;
+ expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+ '
+ export as_echo_n_body
+ as_echo_n='sh -c $as_echo_n_body as_echo'
+ fi
+ export as_echo_body
+ as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ PATH_SEPARATOR=:
+ (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+ (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+ PATH_SEPARATOR=';'
+ }
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order. Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" "" $as_nl"
+
+# Find who we are. Look in the path if we contain no directory separator.
+as_myself=
+case $0 in #((
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+ done
+IFS=$as_save_IFS
+
+ ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+ as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+ $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+ exit 1
+fi
+
+# Unset variables that we do not need and which cause bugs (e.g. in
+# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1"
+# suppresses any "Segmentation fault" message there. '((' could
+# trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset \
+ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+# Use a proper internal environment variable to ensure we don't fall
+ # into an infinite loop, continuously re-executing ourselves.
+ if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
+ _as_can_reexec=no; export _as_can_reexec;
+ # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+ *v*x* | *x*v* ) as_opts=-vx ;;
+ *v* ) as_opts=-v ;;
+ *x* ) as_opts=-x ;;
+ * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+as_fn_exit 255
+ fi
+ # We don't want this to propagate to other subprocesses.
+ { _as_can_reexec=; unset _as_can_reexec;}
+if test "x$CONFIG_SHELL" = x; then
+ as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
+ emulate sh
+ NULLCMD=:
+ # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '\${1+\"\$@\"}'='\"\$@\"'
+ setopt NO_GLOB_SUBST
+else
+ case \`(set -o) 2>/dev/null\` in #(
+ *posix*) :
+ set -o posix ;; #(
+ *) :
+ ;;
+esac
+fi
+"
+ as_required="as_fn_return () { (exit \$1); }
+as_fn_success () { as_fn_return 0; }
+as_fn_failure () { as_fn_return 1; }
+as_fn_ret_success () { return 0; }
+as_fn_ret_failure () { return 1; }
+
+exitcode=0
+as_fn_success || { exitcode=1; echo as_fn_success failed.; }
+as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
+as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
+as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
+if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
+
+else
+ exitcode=1; echo positional parameters were not saved.
+fi
+test x\$exitcode = x0 || exit 1
+test -x / || exit 1"
+ as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
+ as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
+ eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
+ test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
+
+ test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || (
+ ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+ ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO
+ ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO
+ PATH=/empty FPATH=/empty; export PATH FPATH
+ test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\
+ || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1
+test \$(( 1 + 1 )) = 2 || exit 1"
+ if (eval "$as_required") 2>/dev/null; then :
+ as_have_required=yes
+else
+ as_have_required=no
+fi
+ if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
+
+else
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+as_found=false
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ as_found=:
+ case $as_dir in #(
+ /*)
+ for as_base in sh bash ksh sh5; do
+ # Try only shells that exist, to save several forks.
+ as_shell=$as_dir/$as_base
+ if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
+ { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
+ CONFIG_SHELL=$as_shell as_have_required=yes
+ if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
+ break 2
+fi
+fi
+ done;;
+ esac
+ as_found=false
+done
+$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
+ { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
+ CONFIG_SHELL=$SHELL as_have_required=yes
+fi; }
+IFS=$as_save_IFS
+
+
+ if test "x$CONFIG_SHELL" != x; then :
+ export CONFIG_SHELL
+ # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+ *v*x* | *x*v* ) as_opts=-vx ;;
+ *v* ) as_opts=-v ;;
+ *x* ) as_opts=-x ;;
+ * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+exit 255
+fi
+
+ if test x$as_have_required = xno; then :
+ $as_echo "$0: This script requires a shell more modern than all"
+ $as_echo "$0: the shells that I found on your system."
+ if test x${ZSH_VERSION+set} = xset ; then
+ $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
+ $as_echo "$0: be upgraded to zsh 4.3.4 or later."
+ else
+ $as_echo "$0: Please tell bug-autoconf@gnu.org and
+$0: opensource@google.com about your system, including any
+$0: error possibly output before this message. Then install
+$0: a modern shell, or manually run the script under such a
+$0: shell if you do have one."
+ fi
+ exit 1
+fi
+fi
+fi
+SHELL=${CONFIG_SHELL-/bin/sh}
+export SHELL
+# Unset more variables known to interfere with behavior of common tools.
+CLICOLOR_FORCE= GREP_OPTIONS=
+unset CLICOLOR_FORCE GREP_OPTIONS
+
+## --------------------- ##
+## M4sh Shell Functions. ##
+## --------------------- ##
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+ { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+ return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+ set +e
+ as_fn_set_status $1
+ exit $1
+} # as_fn_exit
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+ case $as_dir in #(
+ -*) as_dir=./$as_dir;;
+ esac
+ test -d "$as_dir" || eval $as_mkdir_p || {
+ as_dirs=
+ while :; do
+ case $as_dir in #(
+ *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+ *) as_qdir=$as_dir;;
+ esac
+ as_dirs="'$as_qdir' $as_dirs"
+ as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_dir" : 'X\(//\)[^/]' \| \
+ X"$as_dir" : 'X\(//\)$' \| \
+ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ test -d "$as_dir" && break
+ done
+ test -z "$as_dirs" || eval "mkdir $as_dirs"
+ } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+ test -f "$1" && test -x "$1"
+} # as_fn_executable_p
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+ eval 'as_fn_append ()
+ {
+ eval $1+=\$2
+ }'
+else
+ as_fn_append ()
+ {
+ eval $1=\$$1\$2
+ }
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+ eval 'as_fn_arith ()
+ {
+ as_val=$(( $* ))
+ }'
+else
+ as_fn_arith ()
+ {
+ as_val=`expr "$@" || test $? -eq 1`
+ }
+fi # as_fn_arith
+
+
+# as_fn_error STATUS ERROR [LINENO LOG_FD]
+# ----------------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with STATUS, using 1 if that was 0.
+as_fn_error ()
+{
+ as_status=$1; test $as_status -eq 0 && as_status=1
+ if test "$4"; then
+ as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+ fi
+ $as_echo "$as_me: error: $2" >&2
+ as_fn_exit $as_status
+} # as_fn_error
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+ test "X`expr 00001 : '.*\(...\)'`" = X001; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+ as_dirname=dirname
+else
+ as_dirname=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+
+ as_lineno_1=$LINENO as_lineno_1a=$LINENO
+ as_lineno_2=$LINENO as_lineno_2a=$LINENO
+ eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
+ test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
+ # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-)
+ sed -n '
+ p
+ /[$]LINENO/=
+ ' <$as_myself |
+ sed '
+ s/[$]LINENO.*/&-/
+ t lineno
+ b
+ :lineno
+ N
+ :loop
+ s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+ t loop
+ s/-\n.*//
+ ' >$as_me.lineno &&
+ chmod +x "$as_me.lineno" ||
+ { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
+
+ # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
+ # already done that, so ensure we don't try to do so again and fall
+ # in an infinite loop. This has already happened in practice.
+ _as_can_reexec=no; export _as_can_reexec
+ # Don't try to exec as it changes $[0], causing all sort of problems
+ # (the dirname of $[0] is not the place where we might find the
+ # original and so on. Autoconf is especially sensitive to this).
+ . "./$as_me.lineno"
+ # Exit status is that of the last command.
+ exit
+}
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in #(((((
+-n*)
+ case `echo 'xy\c'` in
+ *c*) ECHO_T=' ';; # ECHO_T is single tab character.
+ xy) ECHO_C='\c';;
+ *) echo `echo ksh88 bug on AIX 6.1` > /dev/null
+ ECHO_T=' ';;
+ esac;;
+*)
+ ECHO_N='-n';;
+esac
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+ rm -f conf$$.dir/conf$$.file
+else
+ rm -f conf$$.dir
+ mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+ if ln -s conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s='ln -s'
+ # ... but there are two gotchas:
+ # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+ # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+ # In both cases, we have to default to `cp -pR'.
+ ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+ as_ln_s='cp -pR'
+ elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+ else
+ as_ln_s='cp -pR'
+ fi
+else
+ as_ln_s='cp -pR'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p='mkdir -p "$as_dir"'
+else
+ test -d ./-p && rmdir ./-p
+ as_mkdir_p=false
+fi
+
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+
+test -n "$DJDIR" || exec 7<&0 </dev/null
+exec 6>&1
+
+# Name of the host.
+# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+ac_clean_files=
+ac_config_libobj_dir=.
+LIBOBJS=
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+
+# Identity of this package.
+PACKAGE_NAME='glog'
+PACKAGE_TARNAME='glog'
+PACKAGE_VERSION='0.3.5'
+PACKAGE_STRING='glog 0.3.5'
+PACKAGE_BUGREPORT='opensource@google.com'
+PACKAGE_URL=''
+
+ac_unique_file="README"
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stdio.h>
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+# endif
+#endif
+#ifdef HAVE_STRING_H
+# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
+# include <memory.h>
+# endif
+# include <string.h>
+#endif
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif"
+
+ac_subst_vars='am__EXEEXT_FALSE
+am__EXEEXT_TRUE
+LTLIBOBJS
+LIBOBJS
+GMOCK_LIBS
+GTEST_LIBS
+GFLAGS_LIBS
+MINGW_CFLAGS
+GMOCK_CFLAGS
+GTEST_CFLAGS
+GFLAGS_CFLAGS
+ac_cv_have_libgflags
+ac_cv_have___uint16
+ac_cv_have_u_int16_t
+ac_cv_have_uint16_t
+ac_cv_have_unistd_h
+ac_cv_have_inttypes_h
+ac_cv_have_systypes_h
+ac_cv_have_stdint_h
+ac_cv_have___builtin_expect
+ac_cv___attribute___printf_4_5
+ac_cv___attribute___noinline
+ac_cv___attribute___noreturn
+ac_cv_cxx_using_operator
+ac_google_namespace
+ac_google_end_namespace
+ac_google_start_namespace
+UNWIND_LIBS
+HAVE_GMOCK_FALSE
+HAVE_GMOCK_TRUE
+GMOCK_CONFIG
+GTEST_CONFIG
+PTHREAD_CFLAGS
+PTHREAD_LIBS
+PTHREAD_CC
+acx_pthread_config
+DISABLE_RTTI_FALSE
+DISABLE_RTTI_TRUE
+X86_64_FALSE
+X86_64_TRUE
+ENABLE_FRAME_POINTERS_FALSE
+ENABLE_FRAME_POINTERS_TRUE
+LIBTOOL_DEPS
+CXXCPP
+OTOOL64
+OTOOL
+LIPO
+NMEDIT
+DSYMUTIL
+MANIFEST_TOOL
+RANLIB
+ac_ct_AR
+AR
+DLLTOOL
+OBJDUMP
+LN_S
+NM
+ac_ct_DUMPBIN
+DUMPBIN
+LD
+FGREP
+EGREP
+GREP
+SED
+host_os
+host_vendor
+host_cpu
+host
+build_os
+build_vendor
+build_cpu
+build
+LIBTOOL
+GCC_FALSE
+GCC_TRUE
+am__fastdepCXX_FALSE
+am__fastdepCXX_TRUE
+CXXDEPMODE
+ac_ct_CXX
+CXXFLAGS
+CXX
+CPP
+am__fastdepCC_FALSE
+am__fastdepCC_TRUE
+CCDEPMODE
+am__nodep
+AMDEPBACKSLASH
+AMDEP_FALSE
+AMDEP_TRUE
+am__quote
+am__include
+DEPDIR
+OBJEXT
+EXEEXT
+ac_ct_CC
+CPPFLAGS
+LDFLAGS
+CFLAGS
+CC
+AM_BACKSLASH
+AM_DEFAULT_VERBOSITY
+AM_DEFAULT_V
+AM_V
+am__untar
+am__tar
+AMTAR
+am__leading_dot
+SET_MAKE
+AWK
+mkdir_p
+MKDIR_P
+INSTALL_STRIP_PROGRAM
+STRIP
+install_sh
+MAKEINFO
+AUTOHEADER
+AUTOMAKE
+AUTOCONF
+ACLOCAL
+VERSION
+PACKAGE
+CYGPATH_W
+am__isrc
+INSTALL_DATA
+INSTALL_SCRIPT
+INSTALL_PROGRAM
+target_alias
+host_alias
+build_alias
+LIBS
+ECHO_T
+ECHO_N
+ECHO_C
+DEFS
+mandir
+localedir
+libdir
+psdir
+pdfdir
+dvidir
+htmldir
+infodir
+docdir
+oldincludedir
+includedir
+localstatedir
+sharedstatedir
+sysconfdir
+datadir
+datarootdir
+libexecdir
+sbindir
+bindir
+program_transform_name
+prefix
+exec_prefix
+PACKAGE_URL
+PACKAGE_BUGREPORT
+PACKAGE_STRING
+PACKAGE_VERSION
+PACKAGE_TARNAME
+PACKAGE_NAME
+PATH_SEPARATOR
+SHELL'
+ac_subst_files=''
+ac_user_opts='
+enable_option_checking
+enable_silent_rules
+enable_dependency_tracking
+enable_shared
+enable_static
+with_pic
+enable_fast_install
+with_gnu_ld
+with_sysroot
+enable_libtool_lock
+enable_frame_pointers
+enable_rtti
+with_gflags
+enable_namespace
+'
+ ac_precious_vars='build_alias
+host_alias
+target_alias
+CC
+CFLAGS
+LDFLAGS
+LIBS
+CPPFLAGS
+CPP
+CXX
+CXXFLAGS
+CCC
+CXXCPP'
+
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+ac_unrecognized_opts=
+ac_unrecognized_sep=
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+cache_file=/dev/null
+exec_prefix=NONE
+no_create=
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+verbose=
+x_includes=NONE
+x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
+# (The list follows the same order as the GNU Coding Standards.)
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datarootdir='${prefix}/share'
+datadir='${datarootdir}'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
+infodir='${datarootdir}/info'
+htmldir='${docdir}'
+dvidir='${docdir}'
+pdfdir='${docdir}'
+psdir='${docdir}'
+libdir='${exec_prefix}/lib'
+localedir='${datarootdir}/locale'
+mandir='${datarootdir}/man'
+
+ac_prev=
+ac_dashdash=
+for ac_option
+do
+ # If the previous option needs an argument, assign it.
+ if test -n "$ac_prev"; then
+ eval $ac_prev=\$ac_option
+ ac_prev=
+ continue
+ fi
+
+ case $ac_option in
+ *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+ *=) ac_optarg= ;;
+ *) ac_optarg=yes ;;
+ esac
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+
+ case $ac_dashdash$ac_option in
+ --)
+ ac_dashdash=yes ;;
+
+ -bindir | --bindir | --bindi | --bind | --bin | --bi)
+ ac_prev=bindir ;;
+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+ bindir=$ac_optarg ;;
+
+ -build | --build | --buil | --bui | --bu)
+ ac_prev=build_alias ;;
+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+ build_alias=$ac_optarg ;;
+
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+ cache_file=$ac_optarg ;;
+
+ --config-cache | -C)
+ cache_file=config.cache ;;
+
+ -datadir | --datadir | --datadi | --datad)
+ ac_prev=datadir ;;
+ -datadir=* | --datadir=* | --datadi=* | --datad=*)
+ datadir=$ac_optarg ;;
+
+ -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
+ | --dataroo | --dataro | --datar)
+ ac_prev=datarootdir ;;
+ -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
+ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
+ datarootdir=$ac_optarg ;;
+
+ -disable-* | --disable-*)
+ ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+ as_fn_error $? "invalid feature name: $ac_useropt"
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+ *"
+"enable_$ac_useropt"
+"*) ;;
+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
+ ac_unrecognized_sep=', ';;
+ esac
+ eval enable_$ac_useropt=no ;;
+
+ -docdir | --docdir | --docdi | --doc | --do)
+ ac_prev=docdir ;;
+ -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
+ docdir=$ac_optarg ;;
+
+ -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
+ ac_prev=dvidir ;;
+ -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
+ dvidir=$ac_optarg ;;
+
+ -enable-* | --enable-*)
+ ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+ as_fn_error $? "invalid feature name: $ac_useropt"
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+ *"
+"enable_$ac_useropt"
+"*) ;;
+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
+ ac_unrecognized_sep=', ';;
+ esac
+ eval enable_$ac_useropt=\$ac_optarg ;;
+
+ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+ | --exec | --exe | --ex)
+ ac_prev=exec_prefix ;;
+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+ | --exec=* | --exe=* | --ex=*)
+ exec_prefix=$ac_optarg ;;
+
+ -gas | --gas | --ga | --g)
+ # Obsolete; use --with-gas.
+ with_gas=yes ;;
+
+ -help | --help | --hel | --he | -h)
+ ac_init_help=long ;;
+ -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+ ac_init_help=recursive ;;
+ -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+ ac_init_help=short ;;
+
+ -host | --host | --hos | --ho)
+ ac_prev=host_alias ;;
+ -host=* | --host=* | --hos=* | --ho=*)
+ host_alias=$ac_optarg ;;
+
+ -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
+ ac_prev=htmldir ;;
+ -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
+ | --ht=*)
+ htmldir=$ac_optarg ;;
+
+ -includedir | --includedir | --includedi | --included | --include \
+ | --includ | --inclu | --incl | --inc)
+ ac_prev=includedir ;;
+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+ | --includ=* | --inclu=* | --incl=* | --inc=*)
+ includedir=$ac_optarg ;;
+
+ -infodir | --infodir | --infodi | --infod | --info | --inf)
+ ac_prev=infodir ;;
+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+ infodir=$ac_optarg ;;
+
+ -libdir | --libdir | --libdi | --libd)
+ ac_prev=libdir ;;
+ -libdir=* | --libdir=* | --libdi=* | --libd=*)
+ libdir=$ac_optarg ;;
+
+ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+ | --libexe | --libex | --libe)
+ ac_prev=libexecdir ;;
+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+ | --libexe=* | --libex=* | --libe=*)
+ libexecdir=$ac_optarg ;;
+
+ -localedir | --localedir | --localedi | --localed | --locale)
+ ac_prev=localedir ;;
+ -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
+ localedir=$ac_optarg ;;
+
+ -localstatedir | --localstatedir | --localstatedi | --localstated \
+ | --localstate | --localstat | --localsta | --localst | --locals)
+ ac_prev=localstatedir ;;
+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
+ localstatedir=$ac_optarg ;;
+
+ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+ ac_prev=mandir ;;
+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+ mandir=$ac_optarg ;;
+
+ -nfp | --nfp | --nf)
+ # Obsolete; use --without-fp.
+ with_fp=no ;;
+
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c | -n)
+ no_create=yes ;;
+
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+ no_recursion=yes ;;
+
+ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+ | --oldin | --oldi | --old | --ol | --o)
+ ac_prev=oldincludedir ;;
+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+ oldincludedir=$ac_optarg ;;
+
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+ prefix=$ac_optarg ;;
+
+ -program-prefix | --program-prefix | --program-prefi | --program-pref \
+ | --program-pre | --program-pr | --program-p)
+ ac_prev=program_prefix ;;
+ -program-prefix=* | --program-prefix=* | --program-prefi=* \
+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+ program_prefix=$ac_optarg ;;
+
+ -program-suffix | --program-suffix | --program-suffi | --program-suff \
+ | --program-suf | --program-su | --program-s)
+ ac_prev=program_suffix ;;
+ -program-suffix=* | --program-suffix=* | --program-suffi=* \
+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+ program_suffix=$ac_optarg ;;
+
+ -program-transform-name | --program-transform-name \
+ | --program-transform-nam | --program-transform-na \
+ | --program-transform-n | --program-transform- \
+ | --program-transform | --program-transfor \
+ | --program-transfo | --program-transf \
+ | --program-trans | --program-tran \
+ | --progr-tra | --program-tr | --program-t)
+ ac_prev=program_transform_name ;;
+ -program-transform-name=* | --program-transform-name=* \
+ | --program-transform-nam=* | --program-transform-na=* \
+ | --program-transform-n=* | --program-transform-=* \
+ | --program-transform=* | --program-transfor=* \
+ | --program-transfo=* | --program-transf=* \
+ | --program-trans=* | --program-tran=* \
+ | --progr-tra=* | --program-tr=* | --program-t=*)
+ program_transform_name=$ac_optarg ;;
+
+ -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
+ ac_prev=pdfdir ;;
+ -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
+ pdfdir=$ac_optarg ;;
+
+ -psdir | --psdir | --psdi | --psd | --ps)
+ ac_prev=psdir ;;
+ -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
+ psdir=$ac_optarg ;;
+
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+ | --sbi=* | --sb=*)
+ sbindir=$ac_optarg ;;
+
+ -sharedstatedir | --sharedstatedir | --sharedstatedi \
+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+ | --sharedst | --shareds | --shared | --share | --shar \
+ | --sha | --sh)
+ ac_prev=sharedstatedir ;;
+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+ | --sha=* | --sh=*)
+ sharedstatedir=$ac_optarg ;;
+
+ -site | --site | --sit)
+ ac_prev=site ;;
+ -site=* | --site=* | --sit=*)
+ site=$ac_optarg ;;
+
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ srcdir=$ac_optarg ;;
+
+ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+ | --syscon | --sysco | --sysc | --sys | --sy)
+ ac_prev=sysconfdir ;;
+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+ sysconfdir=$ac_optarg ;;
+
+ -target | --target | --targe | --targ | --tar | --ta | --t)
+ ac_prev=target_alias ;;
+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+ target_alias=$ac_optarg ;;
+
+ -v | -verbose | --verbose | --verbos | --verbo | --verb)
+ verbose=yes ;;
+
+ -version | --version | --versio | --versi | --vers | -V)
+ ac_init_version=: ;;
+
+ -with-* | --with-*)
+ ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+ as_fn_error $? "invalid package name: $ac_useropt"
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+ *"
+"with_$ac_useropt"
+"*) ;;
+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
+ ac_unrecognized_sep=', ';;
+ esac
+ eval with_$ac_useropt=\$ac_optarg ;;
+
+ -without-* | --without-*)
+ ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+ as_fn_error $? "invalid package name: $ac_useropt"
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+ *"
+"with_$ac_useropt"
+"*) ;;
+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
+ ac_unrecognized_sep=', ';;
+ esac
+ eval with_$ac_useropt=no ;;
+
+ --x)
+ # Obsolete; use --with-x.
+ with_x=yes ;;
+
+ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+ | --x-incl | --x-inc | --x-in | --x-i)
+ ac_prev=x_includes ;;
+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+ x_includes=$ac_optarg ;;
+
+ -x-libraries | --x-libraries | --x-librarie | --x-librari \
+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+ ac_prev=x_libraries ;;
+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+ x_libraries=$ac_optarg ;;
+
+ -*) as_fn_error $? "unrecognized option: \`$ac_option'
+Try \`$0 --help' for more information"
+ ;;
+
+ *=*)
+ ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+ # Reject names that are not valid shell variable names.
+ case $ac_envvar in #(
+ '' | [0-9]* | *[!_$as_cr_alnum]* )
+ as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
+ esac
+ eval $ac_envvar=\$ac_optarg
+ export $ac_envvar ;;
+
+ *)
+ # FIXME: should be removed in autoconf 3.0.
+ $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+ expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+ $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+ : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"
+ ;;
+
+ esac
+done
+
+if test -n "$ac_prev"; then
+ ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+ as_fn_error $? "missing argument to $ac_option"
+fi
+
+if test -n "$ac_unrecognized_opts"; then
+ case $enable_option_checking in
+ no) ;;
+ fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
+ *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
+ esac
+fi
+
+# Check all directory arguments for consistency.
+for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
+ datadir sysconfdir sharedstatedir localstatedir includedir \
+ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
+ libdir localedir mandir
+do
+ eval ac_val=\$$ac_var
+ # Remove trailing slashes.
+ case $ac_val in
+ */ )
+ ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
+ eval $ac_var=\$ac_val;;
+ esac
+ # Be sure to have absolute directory names.
+ case $ac_val in
+ [\\/$]* | ?:[\\/]* ) continue;;
+ NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
+ esac
+ as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
+done
+
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+# FIXME: To remove some day.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: To remove some day.
+if test "x$host_alias" != x; then
+ if test "x$build_alias" = x; then
+ cross_compiling=maybe
+ elif test "x$build_alias" != "x$host_alias"; then
+ cross_compiling=yes
+ fi
+fi
+
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+test "$silent" = yes && exec 6>/dev/null
+
+
+ac_pwd=`pwd` && test -n "$ac_pwd" &&
+ac_ls_di=`ls -di .` &&
+ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
+ as_fn_error $? "working directory cannot be determined"
+test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
+ as_fn_error $? "pwd does not report name of working directory"
+
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+ ac_srcdir_defaulted=yes
+ # Try the directory containing this script, then the parent directory.
+ ac_confdir=`$as_dirname -- "$as_myself" ||
+$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_myself" : 'X\(//\)[^/]' \| \
+ X"$as_myself" : 'X\(//\)$' \| \
+ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_myself" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ srcdir=$ac_confdir
+ if test ! -r "$srcdir/$ac_unique_file"; then
+ srcdir=..
+ fi
+else
+ ac_srcdir_defaulted=no
+fi
+if test ! -r "$srcdir/$ac_unique_file"; then
+ test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
+ as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
+fi
+ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
+ac_abs_confdir=`(
+ cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
+ pwd)`
+# When building in place, set srcdir=.
+if test "$ac_abs_confdir" = "$ac_pwd"; then
+ srcdir=.
+fi
+# Remove unnecessary trailing slashes from srcdir.
+# Double slashes in file names in object file debugging info
+# mess up M-x gdb in Emacs.
+case $srcdir in
+*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
+esac
+for ac_var in $ac_precious_vars; do
+ eval ac_env_${ac_var}_set=\${${ac_var}+set}
+ eval ac_env_${ac_var}_value=\$${ac_var}
+ eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
+ eval ac_cv_env_${ac_var}_value=\$${ac_var}
+done
+
+#
+# Report the --help message.
+#
+if test "$ac_init_help" = "long"; then
+ # Omit some internal or obsolete options to make the list less imposing.
+ # This message is too long to be a string in the A/UX 3.1 sh.
+ cat <<_ACEOF
+\`configure' configures glog 0.3.5 to adapt to many kinds of systems.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE. See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+ -h, --help display this help and exit
+ --help=short display options specific to this package
+ --help=recursive display the short help of all the included packages
+ -V, --version display version information and exit
+ -q, --quiet, --silent do not print \`checking ...' messages
+ --cache-file=FILE cache test results in FILE [disabled]
+ -C, --config-cache alias for \`--cache-file=config.cache'
+ -n, --no-create do not create output files
+ --srcdir=DIR find the sources in DIR [configure dir or \`..']
+
+Installation directories:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [$ac_default_prefix]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [PREFIX]
+
+By default, \`make install' will install all the files in
+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
+an installation prefix other than \`$ac_default_prefix' using \`--prefix',
+for instance \`--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+ --bindir=DIR user executables [EPREFIX/bin]
+ --sbindir=DIR system admin executables [EPREFIX/sbin]
+ --libexecdir=DIR program executables [EPREFIX/libexec]
+ --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --libdir=DIR object code libraries [EPREFIX/lib]
+ --includedir=DIR C header files [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc [/usr/include]
+ --datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
+ --datadir=DIR read-only architecture-independent data [DATAROOTDIR]
+ --infodir=DIR info documentation [DATAROOTDIR/info]
+ --localedir=DIR locale-dependent data [DATAROOTDIR/locale]
+ --mandir=DIR man documentation [DATAROOTDIR/man]
+ --docdir=DIR documentation root [DATAROOTDIR/doc/glog]
+ --htmldir=DIR html documentation [DOCDIR]
+ --dvidir=DIR dvi documentation [DOCDIR]
+ --pdfdir=DIR pdf documentation [DOCDIR]
+ --psdir=DIR ps documentation [DOCDIR]
+_ACEOF
+
+ cat <<\_ACEOF
+
+Program names:
+ --program-prefix=PREFIX prepend PREFIX to installed program names
+ --program-suffix=SUFFIX append SUFFIX to installed program names
+ --program-transform-name=PROGRAM run sed PROGRAM on installed program names
+
+System types:
+ --build=BUILD configure for building on BUILD [guessed]
+ --host=HOST cross-compile to build programs to run on HOST [BUILD]
+_ACEOF
+fi
+
+if test -n "$ac_init_help"; then
+ case $ac_init_help in
+ short | recursive ) echo "Configuration of glog 0.3.5:";;
+ esac
+ cat <<\_ACEOF
+
+Optional Features:
+ --disable-option-checking ignore unrecognized --enable/--with options
+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --enable-silent-rules less verbose build output (undo: "make V=1")
+ --disable-silent-rules verbose build output (undo: "make V=0")
+ --enable-dependency-tracking
+ do not reject slow dependency extractors
+ --disable-dependency-tracking
+ speeds up one-time build
+ --enable-shared[=PKGS] build shared libraries [default=yes]
+ --enable-static[=PKGS] build static libraries [default=yes]
+ --enable-fast-install[=PKGS]
+ optimize for fast installation [default=yes]
+ --disable-libtool-lock avoid locking (might break parallel builds)
+ --enable-frame-pointers On x86_64 systems, compile with
+ -fno-omit-frame-pointer (see INSTALL)
+ --disable-rtti Disable RTTI in glog
+ --enable-namespace=FOO to define these Google
+ classes in the FOO namespace. --disable-namespace
+ to define them in the global namespace. Default
+ is to define them in namespace google.
+
+Optional Packages:
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+ --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use
+ both]
+ --with-gnu-ld assume the C compiler uses GNU ld [default=no]
+ --with-sysroot=DIR Search for dependent libraries within DIR
+ (or the compiler's sysroot if not specified).
+ --with-gflags=GFLAGS_DIR
+
+Some influential environment variables:
+ CC C compiler command
+ CFLAGS C compiler flags
+ LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
+ nonstandard directory <lib dir>
+ LIBS libraries to pass to the linker, e.g. -l<library>
+ CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
+ you have headers in a nonstandard directory <include dir>
+ CPP C preprocessor
+ CXX C++ compiler command
+ CXXFLAGS C++ compiler flags
+ CXXCPP C++ preprocessor
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+Report bugs to <opensource@google.com>.
+_ACEOF
+ac_status=$?
+fi
+
+if test "$ac_init_help" = "recursive"; then
+ # If there are subdirs, report their specific --help.
+ for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+ test -d "$ac_dir" ||
+ { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
+ continue
+ ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+ ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+ # A ".." for each directory in $ac_dir_suffix.
+ ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+ case $ac_top_builddir_sub in
+ "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+ *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+ esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+ .) # We are building in place.
+ ac_srcdir=.
+ ac_top_srcdir=$ac_top_builddir_sub
+ ac_abs_top_srcdir=$ac_pwd ;;
+ [\\/]* | ?:[\\/]* ) # Absolute name.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir
+ ac_abs_top_srcdir=$srcdir ;;
+ *) # Relative name.
+ ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_build_prefix$srcdir
+ ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+ cd "$ac_dir" || { ac_status=$?; continue; }
+ # Check for guested configure.
+ if test -f "$ac_srcdir/configure.gnu"; then
+ echo &&
+ $SHELL "$ac_srcdir/configure.gnu" --help=recursive
+ elif test -f "$ac_srcdir/configure"; then
+ echo &&
+ $SHELL "$ac_srcdir/configure" --help=recursive
+ else
+ $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+ fi || ac_status=$?
+ cd "$ac_pwd" || { ac_status=$?; break; }
+ done
+fi
+
+test -n "$ac_init_help" && exit $ac_status
+if $ac_init_version; then
+ cat <<\_ACEOF
+glog configure 0.3.5
+generated by GNU Autoconf 2.69
+
+Copyright (C) 2012 Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+_ACEOF
+ exit
+fi
+
+## ------------------------ ##
+## Autoconf initialization. ##
+## ------------------------ ##
+
+# ac_fn_c_try_compile LINENO
+# --------------------------
+# Try to compile conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_compile ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ rm -f conftest.$ac_objext
+ if { { ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_compile") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ grep -v '^ *+' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ mv -f conftest.er1 conftest.err
+ fi
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=1
+fi
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_compile
+
+# ac_fn_c_try_cpp LINENO
+# ----------------------
+# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_cpp ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ if { { ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ grep -v '^ *+' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ mv -f conftest.er1 conftest.err
+ fi
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } > conftest.i && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=1
+fi
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_cpp
+
+# ac_fn_cxx_try_compile LINENO
+# ----------------------------
+# Try to compile conftest.$ac_ext, and return whether this succeeded.
+ac_fn_cxx_try_compile ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ rm -f conftest.$ac_objext
+ if { { ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_compile") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ grep -v '^ *+' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ mv -f conftest.er1 conftest.err
+ fi
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && {
+ test -z "$ac_cxx_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=1
+fi
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_cxx_try_compile
+
+# ac_fn_c_try_link LINENO
+# -----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_link ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ rm -f conftest.$ac_objext conftest$ac_exeext
+ if { { ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_link") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ grep -v '^ *+' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ mv -f conftest.er1 conftest.err
+ fi
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext && {
+ test "$cross_compiling" = yes ||
+ test -x conftest$ac_exeext
+ }; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=1
+fi
+ # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
+ # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
+ # interfere with the next link command; also delete a directory that is
+ # left behind by Apple's compiler. We do this before executing the actions.
+ rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_link
+
+# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists and can be compiled using the include files in
+# INCLUDES, setting the cache variable VAR accordingly.
+ac_fn_c_check_header_compile ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ eval "$3=yes"
+else
+ eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_header_compile
+
+# ac_fn_c_try_run LINENO
+# ----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
+# that executables *can* be run.
+ac_fn_c_try_run ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ if { { ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_link") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
+ { { case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: program exited with status $ac_status" >&5
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=$ac_status
+fi
+ rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_run
+
+# ac_fn_c_check_func LINENO FUNC VAR
+# ----------------------------------
+# Tests whether FUNC exists, setting the cache variable VAR accordingly
+ac_fn_c_check_func ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+/* Define $2 to an innocuous variant, in case <limits.h> declares $2.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define $2 innocuous_$2
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $2 (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $2
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $2 ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined __stub_$2 || defined __stub___$2
+choke me
+#endif
+
+int
+main ()
+{
+return $2 ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ eval "$3=yes"
+else
+ eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_func
+
+# ac_fn_cxx_try_cpp LINENO
+# ------------------------
+# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
+ac_fn_cxx_try_cpp ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ if { { ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ grep -v '^ *+' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ mv -f conftest.er1 conftest.err
+ fi
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } > conftest.i && {
+ test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
+ test ! -s conftest.err
+ }; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=1
+fi
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_cxx_try_cpp
+
+# ac_fn_cxx_try_link LINENO
+# -------------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded.
+ac_fn_cxx_try_link ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ rm -f conftest.$ac_objext conftest$ac_exeext
+ if { { ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_link") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ grep -v '^ *+' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ mv -f conftest.er1 conftest.err
+ fi
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && {
+ test -z "$ac_cxx_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext && {
+ test "$cross_compiling" = yes ||
+ test -x conftest$ac_exeext
+ }; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=1
+fi
+ # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
+ # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
+ # interfere with the next link command; also delete a directory that is
+ # left behind by Apple's compiler. We do this before executing the actions.
+ rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_cxx_try_link
+
+# ac_fn_cxx_try_run LINENO
+# ------------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
+# that executables *can* be run.
+ac_fn_cxx_try_run ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ if { { ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_link") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
+ { { case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: program exited with status $ac_status" >&5
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=$ac_status
+fi
+ rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_cxx_try_run
+
+# ac_fn_cxx_check_header_mongrel LINENO HEADER VAR INCLUDES
+# ---------------------------------------------------------
+# Tests whether HEADER exists, giving a warning if it cannot be compiled using
+# the include files in INCLUDES and setting the cache variable VAR
+# accordingly.
+ac_fn_cxx_check_header_mongrel ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ if eval \${$3+:} false; then :
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+else
+ # Is the header compilable?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
+$as_echo_n "checking $2 usability... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_header_compiler=yes
+else
+ ac_header_compiler=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
+$as_echo_n "checking $2 presence... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <$2>
+_ACEOF
+if ac_fn_cxx_try_cpp "$LINENO"; then :
+ ac_header_preproc=yes
+else
+ ac_header_preproc=no
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in #((
+ yes:no: )
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+ ;;
+ no:yes:* )
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+( $as_echo "## ------------------------------------ ##
+## Report this to opensource@google.com ##
+## ------------------------------------ ##"
+ ) | sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ eval "$3=\$ac_header_compiler"
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+fi
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_cxx_check_header_mongrel
+
+# ac_fn_cxx_compute_int LINENO EXPR VAR INCLUDES
+# ----------------------------------------------
+# Tries to find the compile-time value of EXPR in a program that includes
+# INCLUDES, setting VAR accordingly. Returns whether the value could be
+# computed
+ac_fn_cxx_compute_int ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ if test "$cross_compiling" = yes; then
+ # Depending upon the size, compute the lo and hi bounds.
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) >= 0)];
+test_array [0] = 0;
+return test_array [0];
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_lo=0 ac_mid=0
+ while :; do
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) <= $ac_mid)];
+test_array [0] = 0;
+return test_array [0];
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_hi=$ac_mid; break
+else
+ as_fn_arith $ac_mid + 1 && ac_lo=$as_val
+ if test $ac_lo -le $ac_mid; then
+ ac_lo= ac_hi=
+ break
+ fi
+ as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ done
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) < 0)];
+test_array [0] = 0;
+return test_array [0];
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_hi=-1 ac_mid=-1
+ while :; do
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) >= $ac_mid)];
+test_array [0] = 0;
+return test_array [0];
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_lo=$ac_mid; break
+else
+ as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val
+ if test $ac_mid -le $ac_hi; then
+ ac_lo= ac_hi=
+ break
+ fi
+ as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ done
+else
+ ac_lo= ac_hi=
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+# Binary search between lo and hi bounds.
+while test "x$ac_lo" != "x$ac_hi"; do
+ as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) <= $ac_mid)];
+test_array [0] = 0;
+return test_array [0];
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_hi=$ac_mid
+else
+ as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+case $ac_lo in #((
+?*) eval "$3=\$ac_lo"; ac_retval=0 ;;
+'') ac_retval=1 ;;
+esac
+ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+static long int longval () { return $2; }
+static unsigned long int ulongval () { return $2; }
+#include <stdio.h>
+#include <stdlib.h>
+int
+main ()
+{
+
+ FILE *f = fopen ("conftest.val", "w");
+ if (! f)
+ return 1;
+ if (($2) < 0)
+ {
+ long int i = longval ();
+ if (i != ($2))
+ return 1;
+ fprintf (f, "%ld", i);
+ }
+ else
+ {
+ unsigned long int i = ulongval ();
+ if (i != ($2))
+ return 1;
+ fprintf (f, "%lu", i);
+ }
+ /* Do not output a trailing newline, as this causes \r\n confusion
+ on some platforms. */
+ return ferror (f) || fclose (f) != 0;
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_run "$LINENO"; then :
+ echo >>conftest.val; read $3 <conftest.val; ac_retval=0
+else
+ ac_retval=1
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+rm -f conftest.val
+
+ fi
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_cxx_compute_int
+
+# ac_fn_cxx_check_type LINENO TYPE VAR INCLUDES
+# ---------------------------------------------
+# Tests whether TYPE exists after having included INCLUDES, setting cache
+# variable VAR accordingly.
+ac_fn_cxx_check_type ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ eval "$3=no"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+int
+main ()
+{
+if (sizeof ($2))
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+int
+main ()
+{
+if (sizeof (($2)))
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+
+else
+ eval "$3=yes"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_cxx_check_type
+
+# ac_fn_cxx_check_func LINENO FUNC VAR
+# ------------------------------------
+# Tests whether FUNC exists, setting the cache variable VAR accordingly
+ac_fn_cxx_check_func ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+/* Define $2 to an innocuous variant, in case <limits.h> declares $2.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define $2 innocuous_$2
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $2 (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $2
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $2 ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined __stub_$2 || defined __stub___$2
+choke me
+#endif
+
+int
+main ()
+{
+return $2 ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+ eval "$3=yes"
+else
+ eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_cxx_check_func
+cat >config.log <<_ACEOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by glog $as_me 0.3.5, which was
+generated by GNU Autoconf 2.69. Invocation command line was
+
+ $ $0 $@
+
+_ACEOF
+exec 5>>config.log
+{
+cat <<_ASUNAME
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
+
+/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown`
+/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
+/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
+
+_ASUNAME
+
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ $as_echo "PATH: $as_dir"
+ done
+IFS=$as_save_IFS
+
+} >&5
+
+cat >&5 <<_ACEOF
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+_ACEOF
+
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Strip out --silent because we don't want to record it for future runs.
+# Also quote any args containing shell meta-characters.
+# Make two passes to allow for proper duplicate-argument suppression.
+ac_configure_args=
+ac_configure_args0=
+ac_configure_args1=
+ac_must_keep_next=false
+for ac_pass in 1 2
+do
+ for ac_arg
+ do
+ case $ac_arg in
+ -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ continue ;;
+ *\'*)
+ ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+ esac
+ case $ac_pass in
+ 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
+ 2)
+ as_fn_append ac_configure_args1 " '$ac_arg'"
+ if test $ac_must_keep_next = true; then
+ ac_must_keep_next=false # Got value, back to normal.
+ else
+ case $ac_arg in
+ *=* | --config-cache | -C | -disable-* | --disable-* \
+ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
+ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
+ | -with-* | --with-* | -without-* | --without-* | --x)
+ case "$ac_configure_args0 " in
+ "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
+ esac
+ ;;
+ -* ) ac_must_keep_next=true ;;
+ esac
+ fi
+ as_fn_append ac_configure_args " '$ac_arg'"
+ ;;
+ esac
+ done
+done
+{ ac_configure_args0=; unset ac_configure_args0;}
+{ ac_configure_args1=; unset ac_configure_args1;}
+
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log. We remove comments because anyway the quotes in there
+# would cause problems or look ugly.
+# WARNING: Use '\'' to represent an apostrophe within the trap.
+# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
+trap 'exit_status=$?
+ # Save into config.log some information that might help in debugging.
+ {
+ echo
+
+ $as_echo "## ---------------- ##
+## Cache variables. ##
+## ---------------- ##"
+ echo
+ # The following way of writing the cache mishandles newlines in values,
+(
+ for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
+ eval ac_val=\$$ac_var
+ case $ac_val in #(
+ *${as_nl}*)
+ case $ac_var in #(
+ *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+ esac
+ case $ac_var in #(
+ _ | IFS | as_nl) ;; #(
+ BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+ *) { eval $ac_var=; unset $ac_var;} ;;
+ esac ;;
+ esac
+ done
+ (set) 2>&1 |
+ case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
+ *${as_nl}ac_space=\ *)
+ sed -n \
+ "s/'\''/'\''\\\\'\'''\''/g;
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
+ ;; #(
+ *)
+ sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+ ;;
+ esac |
+ sort
+)
+ echo
+
+ $as_echo "## ----------------- ##
+## Output variables. ##
+## ----------------- ##"
+ echo
+ for ac_var in $ac_subst_vars
+ do
+ eval ac_val=\$$ac_var
+ case $ac_val in
+ *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+ esac
+ $as_echo "$ac_var='\''$ac_val'\''"
+ done | sort
+ echo
+
+ if test -n "$ac_subst_files"; then
+ $as_echo "## ------------------- ##
+## File substitutions. ##
+## ------------------- ##"
+ echo
+ for ac_var in $ac_subst_files
+ do
+ eval ac_val=\$$ac_var
+ case $ac_val in
+ *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+ esac
+ $as_echo "$ac_var='\''$ac_val'\''"
+ done | sort
+ echo
+ fi
+
+ if test -s confdefs.h; then
+ $as_echo "## ----------- ##
+## confdefs.h. ##
+## ----------- ##"
+ echo
+ cat confdefs.h
+ echo
+ fi
+ test "$ac_signal" != 0 &&
+ $as_echo "$as_me: caught signal $ac_signal"
+ $as_echo "$as_me: exit $exit_status"
+ } >&5
+ rm -f core *.core core.conftest.* &&
+ rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
+ exit $exit_status
+' 0
+for ac_signal in 1 2 13 15; do
+ trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -f -r conftest* confdefs.h
+
+$as_echo "/* confdefs.h */" > confdefs.h
+
+# Predefined preprocessor variables.
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_NAME "$PACKAGE_NAME"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_VERSION "$PACKAGE_VERSION"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_STRING "$PACKAGE_STRING"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_URL "$PACKAGE_URL"
+_ACEOF
+
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer an explicitly selected file to automatically selected ones.
+ac_site_file1=NONE
+ac_site_file2=NONE
+if test -n "$CONFIG_SITE"; then
+ # We do not want a PATH search for config.site.
+ case $CONFIG_SITE in #((
+ -*) ac_site_file1=./$CONFIG_SITE;;
+ */*) ac_site_file1=$CONFIG_SITE;;
+ *) ac_site_file1=./$CONFIG_SITE;;
+ esac
+elif test "x$prefix" != xNONE; then
+ ac_site_file1=$prefix/share/config.site
+ ac_site_file2=$prefix/etc/config.site
+else
+ ac_site_file1=$ac_default_prefix/share/config.site
+ ac_site_file2=$ac_default_prefix/etc/config.site
+fi
+for ac_site_file in "$ac_site_file1" "$ac_site_file2"
+do
+ test "x$ac_site_file" = xNONE && continue
+ if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
+$as_echo "$as_me: loading site script $ac_site_file" >&6;}
+ sed 's/^/| /' "$ac_site_file" >&5
+ . "$ac_site_file" \
+ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "failed to load site script $ac_site_file
+See \`config.log' for more details" "$LINENO" 5; }
+ fi
+done
+
+if test -r "$cache_file"; then
+ # Some versions of bash will fail to source /dev/null (special files
+ # actually), so we avoid doing that. DJGPP emulates it as a regular file.
+ if test /dev/null != "$cache_file" && test -f "$cache_file"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
+$as_echo "$as_me: loading cache $cache_file" >&6;}
+ case $cache_file in
+ [\\/]* | ?:[\\/]* ) . "$cache_file";;
+ *) . "./$cache_file";;
+ esac
+ fi
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
+$as_echo "$as_me: creating cache $cache_file" >&6;}
+ >$cache_file
+fi
+
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in $ac_precious_vars; do
+ eval ac_old_set=\$ac_cv_env_${ac_var}_set
+ eval ac_new_set=\$ac_env_${ac_var}_set
+ eval ac_old_val=\$ac_cv_env_${ac_var}_value
+ eval ac_new_val=\$ac_env_${ac_var}_value
+ case $ac_old_set,$ac_new_set in
+ set,)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,set)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,);;
+ *)
+ if test "x$ac_old_val" != "x$ac_new_val"; then
+ # differences in whitespace do not lead to failure.
+ ac_old_val_w=`echo x $ac_old_val`
+ ac_new_val_w=`echo x $ac_new_val`
+ if test "$ac_old_val_w" != "$ac_new_val_w"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
+$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+ ac_cache_corrupted=:
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
+$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
+ eval $ac_var=\$ac_old_val
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5
+$as_echo "$as_me: former value: \`$ac_old_val'" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5
+$as_echo "$as_me: current value: \`$ac_new_val'" >&2;}
+ fi;;
+ esac
+ # Pass precious variables to config.status.
+ if test "$ac_new_set" = set; then
+ case $ac_new_val in
+ *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+ *) ac_arg=$ac_var=$ac_new_val ;;
+ esac
+ case " $ac_configure_args " in
+ *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
+ *) as_fn_append ac_configure_args " '$ac_arg'" ;;
+ esac
+ fi
+done
+if $ac_cache_corrupted; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
+$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+ as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
+fi
+## -------------------- ##
+## Main body of script. ##
+## -------------------- ##
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+# The argument here is just something that should be in the current directory
+# (for sanity checking)
+
+
+am__api_version='1.13'
+
+ac_aux_dir=
+for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
+ if test -f "$ac_dir/install-sh"; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install-sh -c"
+ break
+ elif test -f "$ac_dir/install.sh"; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install.sh -c"
+ break
+ elif test -f "$ac_dir/shtool"; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/shtool install -c"
+ break
+ fi
+done
+if test -z "$ac_aux_dir"; then
+ as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
+fi
+
+# These three variables are undocumented and unsupported,
+# and are intended to be withdrawn in a future Autoconf release.
+# They can cause serious problems if a builder's source tree is in a directory
+# whose full name contains unusual characters.
+ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var.
+ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var.
+ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
+
+
+# Find a good install program. We prefer a C program (faster),
+# so one script is as good as another. But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AmigaOS /C/install, which installs bootblocks on floppy discs
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# OS/2's system install, which has a completely different semantic
+# ./install, which can be erroneously created by make from ./install.sh.
+# Reject install programs that cannot install multiple files.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
+$as_echo_n "checking for a BSD-compatible install... " >&6; }
+if test -z "$INSTALL"; then
+if ${ac_cv_path_install+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ # Account for people who put trailing slashes in PATH elements.
+case $as_dir/ in #((
+ ./ | .// | /[cC]/* | \
+ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
+ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \
+ /usr/ucb/* ) ;;
+ *)
+ # OSF1 and SCO ODT 3.0 have their own names for install.
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
+ if test $ac_prog = install &&
+ grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+ # AIX install. It has an incompatible calling convention.
+ :
+ elif test $ac_prog = install &&
+ grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+ # program-specific install script used by HP pwplus--don't use.
+ :
+ else
+ rm -rf conftest.one conftest.two conftest.dir
+ echo one > conftest.one
+ echo two > conftest.two
+ mkdir conftest.dir
+ if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
+ test -s conftest.one && test -s conftest.two &&
+ test -s conftest.dir/conftest.one &&
+ test -s conftest.dir/conftest.two
+ then
+ ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+ break 3
+ fi
+ fi
+ fi
+ done
+ done
+ ;;
+esac
+
+ done
+IFS=$as_save_IFS
+
+rm -rf conftest.one conftest.two conftest.dir
+
+fi
+ if test "${ac_cv_path_install+set}" = set; then
+ INSTALL=$ac_cv_path_install
+ else
+ # As a last resort, use the slow shell script. Don't cache a
+ # value for INSTALL within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the value is a relative name.
+ INSTALL=$ac_install_sh
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5
+$as_echo "$INSTALL" >&6; }
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5
+$as_echo_n "checking whether build environment is sane... " >&6; }
+# Reject unsafe characters in $srcdir or the absolute working directory
+# name. Accept space and tab only in the latter.
+am_lf='
+'
+case `pwd` in
+ *[\\\"\#\$\&\'\`$am_lf]*)
+ as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;;
+esac
+case $srcdir in
+ *[\\\"\#\$\&\'\`$am_lf\ \ ]*)
+ as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;;
+esac
+
+# Do 'set' in a subshell so we don't clobber the current shell's
+# arguments. Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+ am_has_slept=no
+ for am_try in 1 2; do
+ echo "timestamp, slept: $am_has_slept" > conftest.file
+ set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
+ if test "$*" = "X"; then
+ # -L didn't work.
+ set X `ls -t "$srcdir/configure" conftest.file`
+ fi
+ if test "$*" != "X $srcdir/configure conftest.file" \
+ && test "$*" != "X conftest.file $srcdir/configure"; then
+
+ # If neither matched, then we have a broken ls. This can happen
+ # if, for instance, CONFIG_SHELL is bash and it inherits a
+ # broken ls alias from the environment. This has actually
+ # happened. Such a system could not be considered "sane".
+ as_fn_error $? "ls -t appears to fail. Make sure there is not a broken
+ alias in your environment" "$LINENO" 5
+ fi
+ if test "$2" = conftest.file || test $am_try -eq 2; then
+ break
+ fi
+ # Just in case.
+ sleep 1
+ am_has_slept=yes
+ done
+ test "$2" = conftest.file
+ )
+then
+ # Ok.
+ :
+else
+ as_fn_error $? "newly created file is older than distributed files!
+Check your system clock" "$LINENO" 5
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+# If we didn't sleep, we still need to ensure time stamps of config.status and
+# generated files are strictly newer.
+am_sleep_pid=
+if grep 'slept: no' conftest.file >/dev/null 2>&1; then
+ ( sleep 1 ) &
+ am_sleep_pid=$!
+fi
+
+rm -f conftest.file
+
+test "$program_prefix" != NONE &&
+ program_transform_name="s&^&$program_prefix&;$program_transform_name"
+# Use a double $ so make ignores it.
+test "$program_suffix" != NONE &&
+ program_transform_name="s&\$&$program_suffix&;$program_transform_name"
+# Double any \ or $.
+# By default was `s,x,x', remove it if useless.
+ac_script='s/[\\$]/&&/g;s/;s,x,x,$//'
+program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
+
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+
+if test x"${MISSING+set}" != xset; then
+ case $am_aux_dir in
+ *\ * | *\ *)
+ MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
+ *)
+ MISSING="\${SHELL} $am_aux_dir/missing" ;;
+ esac
+fi
+# Use eval to expand $SHELL
+if eval "$MISSING --is-lightweight"; then
+ am_missing_run="$MISSING "
+else
+ am_missing_run=
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5
+$as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;}
+fi
+
+if test x"${install_sh}" != xset; then
+ case $am_aux_dir in
+ *\ * | *\ *)
+ install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
+ *)
+ install_sh="\${SHELL} $am_aux_dir/install-sh"
+ esac
+fi
+
+# Installed binaries are usually stripped using 'strip' when the user
+# run "make install-strip". However 'strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the 'STRIP' environment variable to overrule this program.
+if test "$cross_compiling" != no; then
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_STRIP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$STRIP"; then
+ ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
+$as_echo "$STRIP" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+ ac_ct_STRIP=$STRIP
+ # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_STRIP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_STRIP"; then
+ ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_STRIP="strip"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
+$as_echo "$ac_ct_STRIP" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_STRIP" = x; then
+ STRIP=":"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ STRIP=$ac_ct_STRIP
+ fi
+else
+ STRIP="$ac_cv_prog_STRIP"
+fi
+
+fi
+INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5
+$as_echo_n "checking for a thread-safe mkdir -p... " >&6; }
+if test -z "$MKDIR_P"; then
+ if ${ac_cv_path_mkdir+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_prog in mkdir gmkdir; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue
+ case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #(
+ 'mkdir (GNU coreutils) '* | \
+ 'mkdir (coreutils) '* | \
+ 'mkdir (fileutils) '4.1*)
+ ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext
+ break 3;;
+ esac
+ done
+ done
+ done
+IFS=$as_save_IFS
+
+fi
+
+ test -d ./--version && rmdir ./--version
+ if test "${ac_cv_path_mkdir+set}" = set; then
+ MKDIR_P="$ac_cv_path_mkdir -p"
+ else
+ # As a last resort, use the slow shell script. Don't cache a
+ # value for MKDIR_P within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the value is a relative name.
+ MKDIR_P="$ac_install_sh -d"
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5
+$as_echo "$MKDIR_P" >&6; }
+
+for ac_prog in gawk mawk nawk awk
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_AWK+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$AWK"; then
+ ac_cv_prog_AWK="$AWK" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_AWK="$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+AWK=$ac_cv_prog_AWK
+if test -n "$AWK"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5
+$as_echo "$AWK" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$AWK" && break
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
+$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
+set x ${MAKE-make}
+ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
+if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.make <<\_ACEOF
+SHELL = /bin/sh
+all:
+ @echo '@@@%%%=$(MAKE)=@@@%%%'
+_ACEOF
+# GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
+case `${MAKE-make} -f conftest.make 2>/dev/null` in
+ *@@@%%%=?*=@@@%%%*)
+ eval ac_cv_prog_make_${ac_make}_set=yes;;
+ *)
+ eval ac_cv_prog_make_${ac_make}_set=no;;
+esac
+rm -f conftest.make
+fi
+if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ SET_MAKE=
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+ am__leading_dot=.
+else
+ am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+
+# Check whether --enable-silent-rules was given.
+if test "${enable_silent_rules+set}" = set; then :
+ enableval=$enable_silent_rules;
+fi
+
+case $enable_silent_rules in # (((
+ yes) AM_DEFAULT_VERBOSITY=0;;
+ no) AM_DEFAULT_VERBOSITY=1;;
+ *) AM_DEFAULT_VERBOSITY=1;;
+esac
+am_make=${MAKE-make}
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5
+$as_echo_n "checking whether $am_make supports nested variables... " >&6; }
+if ${am_cv_make_support_nested_variables+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if $as_echo 'TRUE=$(BAR$(V))
+BAR0=false
+BAR1=true
+V=1
+am__doit:
+ @$(TRUE)
+.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then
+ am_cv_make_support_nested_variables=yes
+else
+ am_cv_make_support_nested_variables=no
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5
+$as_echo "$am_cv_make_support_nested_variables" >&6; }
+if test $am_cv_make_support_nested_variables = yes; then
+ AM_V='$(V)'
+ AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
+else
+ AM_V=$AM_DEFAULT_VERBOSITY
+ AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
+fi
+AM_BACKSLASH='\'
+
+if test "`cd $srcdir && pwd`" != "`pwd`"; then
+ # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
+ # is not polluted with repeated "-I."
+ am__isrc=' -I$(srcdir)'
+ # test to see if srcdir already configured
+ if test -f $srcdir/config.status; then
+ as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5
+ fi
+fi
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+ if (cygpath --version) >/dev/null 2>/dev/null; then
+ CYGPATH_W='cygpath -w'
+ else
+ CYGPATH_W=echo
+ fi
+fi
+
+
+# Define the identity of the package.
+ PACKAGE='glog'
+ VERSION='0.3.5'
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE "$PACKAGE"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define VERSION "$VERSION"
+_ACEOF
+
+# Some tools Automake needs.
+
+ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"}
+
+
+AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"}
+
+
+AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"}
+
+
+AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}
+
+
+MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
+
+# For better backward compatibility. To be removed once Automake 1.9.x
+# dies out for good. For more background, see:
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
+mkdir_p='$(MKDIR_P)'
+
+# We need awk for the "check" target. The system "awk" is bad on
+# some platforms.
+# Always define AMTAR for backward compatibility. Yes, it's still used
+# in the wild :-( We should find a proper way to deprecate it ...
+AMTAR='$${TAR-tar}'
+
+
+# We'll loop over all known methods to create a tar archive until one works.
+_am_tools='gnutar pax cpio none'
+
+am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'
+
+
+
+
+
+
+# POSIX will say in a future version that running "rm -f" with no argument
+# is OK; and we want to be able to make that assumption in our Makefile
+# recipes. So use an aggressive probe to check that the usage we want is
+# actually supported "in the wild" to an acceptable degree.
+# See automake bug#10828.
+# To make any issue more visible, cause the running configure to be aborted
+# by default if the 'rm' program in use doesn't match our expectations; the
+# user can still override this though.
+if rm -f && rm -fr && rm -rf; then : OK; else
+ cat >&2 <<'END'
+Oops!
+
+Your 'rm' program seems unable to run without file operands specified
+on the command line, even when the '-f' option is present. This is contrary
+to the behaviour of most rm programs out there, and not conforming with
+the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542>
+
+Please tell bug-automake@gnu.org about your system, including the value
+of your $PATH and any error possibly output before this message. This
+can help us improve future automake versions.
+
+END
+ if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
+ echo 'Configuration will proceed anyway, since you have set the' >&2
+ echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
+ echo >&2
+ else
+ cat >&2 <<'END'
+Aborting the configuration process, to ensure you take notice of the issue.
+
+You can download and install GNU coreutils to get an 'rm' implementation
+that behaves properly: <http://www.gnu.org/software/coreutils/>.
+
+If you want to complete the configuration process using your problematic
+'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
+to "yes", and re-run configure.
+
+END
+ as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5
+ fi
+fi
+ac_config_headers="$ac_config_headers src/config.h"
+
+
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+
+# Checks for programs.
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="${ac_tool_prefix}gcc"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+ ac_ct_CC=$CC
+ # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="gcc"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_CC" = x; then
+ CC=""
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ CC=$ac_ct_CC
+ fi
+else
+ CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="${ac_tool_prefix}cc"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ fi
+fi
+if test -z "$CC"; then
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ ac_prog_rejected=no
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+ fi
+ ac_cv_prog_CC="cc"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+if test $ac_prog_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $ac_cv_prog_CC
+ shift
+ if test $# != 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same basename, so the bogon will be chosen
+ # first if we set CC to just the basename; use the full file name.
+ shift
+ ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+ fi
+fi
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$CC"; then
+ if test -n "$ac_tool_prefix"; then
+ for ac_prog in cl.exe
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$CC" && break
+ done
+fi
+if test -z "$CC"; then
+ ac_ct_CC=$CC
+ for ac_prog in cl.exe
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$ac_ct_CC" && break
+done
+
+ if test "x$ac_ct_CC" = x; then
+ CC=""
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ CC=$ac_ct_CC
+ fi
+fi
+
+fi
+
+
+test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "no acceptable C compiler found in \$PATH
+See \`config.log' for more details" "$LINENO" 5; }
+
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+ { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ sed '10a\
+... rest of stderr output deleted ...
+ 10q' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ fi
+ rm -f conftest.er1 conftest.err
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+done
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
+$as_echo_n "checking whether the C compiler works... " >&6; }
+ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+
+# The possible output files:
+ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
+
+ac_rmfiles=
+for ac_file in $ac_files
+do
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+ * ) ac_rmfiles="$ac_rmfiles $ac_file";;
+ esac
+done
+rm -f $ac_rmfiles
+
+if { { ac_try="$ac_link_default"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_link_default") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then :
+ # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
+# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
+# in a Makefile. We should not override ac_cv_exeext if it was cached,
+# so that the user can short-circuit this test for compilers unknown to
+# Autoconf.
+for ac_file in $ac_files ''
+do
+ test -f "$ac_file" || continue
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
+ ;;
+ [ab].out )
+ # We found the default executable, but exeext='' is most
+ # certainly right.
+ break;;
+ *.* )
+ if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
+ then :; else
+ ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+ fi
+ # We set ac_cv_exeext here because the later test for it is not
+ # safe: cross compilers may not add the suffix if given an `-o'
+ # argument, so we may need to know it at that point already.
+ # Even if this section looks crufty: it has the advantage of
+ # actually working.
+ break;;
+ * )
+ break;;
+ esac
+done
+test "$ac_cv_exeext" = no && ac_cv_exeext=
+
+else
+ ac_file=''
+fi
+if test -z "$ac_file"; then :
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+$as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "C compiler cannot create executables
+See \`config.log' for more details" "$LINENO" 5; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
+$as_echo_n "checking for C compiler default output file name... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
+$as_echo "$ac_file" >&6; }
+ac_exeext=$ac_cv_exeext
+
+rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
+$as_echo_n "checking for suffix of executables... " >&6; }
+if { { ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_link") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then :
+ # If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in conftest.exe conftest conftest.*; do
+ test -f "$ac_file" || continue
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+ *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+ break;;
+ * ) break;;
+ esac
+done
+else
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+rm -f conftest conftest$ac_cv_exeext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
+$as_echo "$ac_cv_exeext" >&6; }
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdio.h>
+int
+main ()
+{
+FILE *f = fopen ("conftest.out", "w");
+ return ferror (f) || fclose (f) != 0;
+
+ ;
+ return 0;
+}
+_ACEOF
+ac_clean_files="$ac_clean_files conftest.out"
+# Check that the compiler produces executables we can run. If not, either
+# the compiler is broken, or we cross compile.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
+$as_echo_n "checking whether we are cross compiling... " >&6; }
+if test "$cross_compiling" != yes; then
+ { { ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_link") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+ if { ac_try='./conftest$ac_cv_exeext'
+ { { case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }; then
+ cross_compiling=no
+ else
+ if test "$cross_compiling" = maybe; then
+ cross_compiling=yes
+ else
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details" "$LINENO" 5; }
+ fi
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
+$as_echo "$cross_compiling" >&6; }
+
+rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
+ac_clean_files=$ac_clean_files_save
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
+$as_echo_n "checking for suffix of object files... " >&6; }
+if ${ac_cv_objext+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { { ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_compile") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then :
+ for ac_file in conftest.o conftest.obj conftest.*; do
+ test -f "$ac_file" || continue;
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
+ *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+ break;;
+ esac
+done
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot compute suffix of object files: cannot compile
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
+$as_echo "$ac_cv_objext" >&6; }
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
+$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
+if ${ac_cv_c_compiler_gnu+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+#ifndef __GNUC__
+ choke me
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_compiler_gnu=yes
+else
+ ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
+$as_echo "$ac_cv_c_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+ GCC=yes
+else
+ GCC=
+fi
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
+$as_echo_n "checking whether $CC accepts -g... " >&6; }
+if ${ac_cv_prog_cc_g+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_save_c_werror_flag=$ac_c_werror_flag
+ ac_c_werror_flag=yes
+ ac_cv_prog_cc_g=no
+ CFLAGS="-g"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_prog_cc_g=yes
+else
+ CFLAGS=""
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+ ac_c_werror_flag=$ac_save_c_werror_flag
+ CFLAGS="-g"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_prog_cc_g=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_c_werror_flag=$ac_save_c_werror_flag
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
+$as_echo "$ac_cv_prog_cc_g" >&6; }
+if test "$ac_test_CFLAGS" = set; then
+ CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-g"
+ fi
+else
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
+$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
+if ${ac_cv_prog_cc_c89+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_cv_prog_cc_c89=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdarg.h>
+#include <stdio.h>
+struct stat;
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+ char **p;
+ int i;
+{
+ return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+ char *s;
+ va_list v;
+ va_start (v,p);
+ s = g (p, va_arg (v,int));
+ va_end (v);
+ return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
+ function prototypes and stuff, but not '\xHH' hex character constants.
+ These don't provoke an error unfortunately, instead are silently treated
+ as 'x'. The following induces an error, until -std is added to get
+ proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
+ array size at least. It's necessary to write '\x00'==0 to get something
+ that's true only with -std. */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+ inside strings and character constants. */
+#define FOO(x) 'x'
+int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
+ ;
+ return 0;
+}
+_ACEOF
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
+ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+ CC="$ac_save_CC $ac_arg"
+ if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_prog_cc_c89=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext
+ test "x$ac_cv_prog_cc_c89" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c89" in
+ x)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
+ xno)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
+ *)
+ CC="$CC $ac_cv_prog_cc_c89"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
+$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
+esac
+if test "x$ac_cv_prog_cc_c89" != xno; then :
+
+fi
+
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5
+$as_echo_n "checking whether $CC understands -c and -o together... " >&6; }
+if ${am_cv_prog_cc_c_o+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+ # Make sure it works both with $CC and with simple cc.
+ # Following AC_PROG_CC_C_O, we do the test twice because some
+ # compilers refuse to overwrite an existing .o file with -o,
+ # though they will create one.
+ am_cv_prog_cc_c_o=yes
+ for am_i in 1 2; do
+ if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5
+ ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } \
+ && test -f conftest2.$ac_objext; then
+ : OK
+ else
+ am_cv_prog_cc_c_o=no
+ break
+ fi
+ done
+ rm -f core conftest*
+ unset am_i
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5
+$as_echo "$am_cv_prog_cc_c_o" >&6; }
+if test "$am_cv_prog_cc_c_o" != yes; then
+ # Losing compiler, so override with the script.
+ # FIXME: It is wrong to rewrite CC.
+ # But if we don't then we get into trouble of one sort or another.
+ # A longer-term fix would be to have automake use am__CC in this case,
+ # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
+ CC="$am_aux_dir/compile $CC"
+fi
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+DEPDIR="${am__leading_dot}deps"
+
+ac_config_commands="$ac_config_commands depfiles"
+
+
+am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+ @echo this is the am__doit target
+.PHONY: am__doit
+END
+# If we don't find an include directive, just comment out the code.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5
+$as_echo_n "checking for style of include used by $am_make... " >&6; }
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# Ignore all kinds of additional output from 'make'.
+case `$am_make -s -f confmf 2> /dev/null` in #(
+*the\ am__doit\ target*)
+ am__include=include
+ am__quote=
+ _am_result=GNU
+ ;;
+esac
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+ echo '.include "confinc"' > confmf
+ case `$am_make -s -f confmf 2> /dev/null` in #(
+ *the\ am__doit\ target*)
+ am__include=.include
+ am__quote="\""
+ _am_result=BSD
+ ;;
+ esac
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5
+$as_echo "$_am_result" >&6; }
+rm -f confinc confmf
+
+# Check whether --enable-dependency-tracking was given.
+if test "${enable_dependency_tracking+set}" = set; then :
+ enableval=$enable_dependency_tracking;
+fi
+
+if test "x$enable_dependency_tracking" != xno; then
+ am_depcomp="$ac_aux_dir/depcomp"
+ AMDEPBACKSLASH='\'
+ am__nodep='_no'
+fi
+ if test "x$enable_dependency_tracking" != xno; then
+ AMDEP_TRUE=
+ AMDEP_FALSE='#'
+else
+ AMDEP_TRUE='#'
+ AMDEP_FALSE=
+fi
+
+
+
+depcc="$CC" am_compiler_list=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
+$as_echo_n "checking dependency style of $depcc... " >&6; }
+if ${am_cv_CC_dependencies_compiler_type+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+ # We make a subdir and do the tests there. Otherwise we can end up
+ # making bogus files that we don't know about and never remove. For
+ # instance it was reported that on HP-UX the gcc test will end up
+ # making a dummy file named 'D' -- because '-MD' means "put the output
+ # in D".
+ rm -rf conftest.dir
+ mkdir conftest.dir
+ # Copy depcomp to subdir because otherwise we won't find it if we're
+ # using a relative directory.
+ cp "$am_depcomp" conftest.dir
+ cd conftest.dir
+ # We will build objects and dependencies in a subdirectory because
+ # it helps to detect inapplicable dependency modes. For instance
+ # both Tru64's cc and ICC support -MD to output dependencies as a
+ # side effect of compilation, but ICC will put the dependencies in
+ # the current directory while Tru64 will put them in the object
+ # directory.
+ mkdir sub
+
+ am_cv_CC_dependencies_compiler_type=none
+ if test "$am_compiler_list" = ""; then
+ am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+ fi
+ am__universal=false
+ case " $depcc " in #(
+ *\ -arch\ *\ -arch\ *) am__universal=true ;;
+ esac
+
+ for depmode in $am_compiler_list; do
+ # Setup a source with many dependencies, because some compilers
+ # like to wrap large dependency lists on column 80 (with \), and
+ # we should not choose a depcomp mode which is confused by this.
+ #
+ # We need to recreate these files for each test, as the compiler may
+ # overwrite some of them when testing with obscure command lines.
+ # This happens at least with the AIX C compiler.
+ : > sub/conftest.c
+ for i in 1 2 3 4 5 6; do
+ echo '#include "conftst'$i'.h"' >> sub/conftest.c
+ # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
+ # Solaris 10 /bin/sh.
+ echo '/* dummy */' > sub/conftst$i.h
+ done
+ echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+ # We check with '-c' and '-o' for the sake of the "dashmstdout"
+ # mode. It turns out that the SunPro C++ compiler does not properly
+ # handle '-M -o', and we need to detect this. Also, some Intel
+ # versions had trouble with output in subdirs.
+ am__obj=sub/conftest.${OBJEXT-o}
+ am__minus_obj="-o $am__obj"
+ case $depmode in
+ gcc)
+ # This depmode causes a compiler race in universal mode.
+ test "$am__universal" = false || continue
+ ;;
+ nosideeffect)
+ # After this tag, mechanisms are not by side-effect, so they'll
+ # only be used when explicitly requested.
+ if test "x$enable_dependency_tracking" = xyes; then
+ continue
+ else
+ break
+ fi
+ ;;
+ msvc7 | msvc7msys | msvisualcpp | msvcmsys)
+ # This compiler won't grok '-c -o', but also, the minuso test has
+ # not run yet. These depmodes are late enough in the game, and
+ # so weak that their functioning should not be impacted.
+ am__obj=conftest.${OBJEXT-o}
+ am__minus_obj=
+ ;;
+ none) break ;;
+ esac
+ if depmode=$depmode \
+ source=sub/conftest.c object=$am__obj \
+ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+ >/dev/null 2>conftest.err &&
+ grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+ grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+ grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+ ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+ # icc doesn't choke on unknown options, it will just issue warnings
+ # or remarks (even with -Werror). So we grep stderr for any message
+ # that says an option was ignored or not supported.
+ # When given -MP, icc 7.0 and 7.1 complain thusly:
+ # icc: Command line warning: ignoring option '-M'; no argument required
+ # The diagnosis changed in icc 8.0:
+ # icc: Command line remark: option '-MP' not supported
+ if (grep 'ignoring option' conftest.err ||
+ grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+ am_cv_CC_dependencies_compiler_type=$depmode
+ break
+ fi
+ fi
+ done
+
+ cd ..
+ rm -rf conftest.dir
+else
+ am_cv_CC_dependencies_compiler_type=none
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5
+$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; }
+CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
+
+ if
+ test "x$enable_dependency_tracking" != xno \
+ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
+ am__fastdepCC_TRUE=
+ am__fastdepCC_FALSE='#'
+else
+ am__fastdepCC_TRUE='#'
+ am__fastdepCC_FALSE=
+fi
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
+$as_echo_n "checking how to run the C preprocessor... " >&6; }
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+fi
+if test -z "$CPP"; then
+ if ${ac_cv_prog_CPP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ # Double quotes because CPP needs to be expanded
+ for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+ do
+ ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+else
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether nonexistent headers
+ # can be detected and how.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+ # Broken: success on invalid input.
+continue
+else
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+ break
+fi
+
+ done
+ ac_cv_prog_CPP=$CPP
+
+fi
+ CPP=$ac_cv_prog_CPP
+else
+ ac_cv_prog_CPP=$CPP
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
+$as_echo "$CPP" >&6; }
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+else
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether nonexistent headers
+ # can be detected and how.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+ # Broken: success on invalid input.
+continue
+else
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+
+else
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+if test -z "$CXX"; then
+ if test -n "$CCC"; then
+ CXX=$CCC
+ else
+ if test -n "$ac_tool_prefix"; then
+ for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CXX+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CXX"; then
+ ac_cv_prog_CXX="$CXX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+CXX=$ac_cv_prog_CXX
+if test -n "$CXX"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5
+$as_echo "$CXX" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$CXX" && break
+ done
+fi
+if test -z "$CXX"; then
+ ac_ct_CXX=$CXX
+ for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CXX+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_CXX"; then
+ ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CXX="$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
+if test -n "$ac_ct_CXX"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5
+$as_echo "$ac_ct_CXX" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$ac_ct_CXX" && break
+done
+
+ if test "x$ac_ct_CXX" = x; then
+ CXX="g++"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ CXX=$ac_ct_CXX
+ fi
+fi
+
+ fi
+fi
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+ { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ sed '10a\
+... rest of stderr output deleted ...
+ 10q' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ fi
+ rm -f conftest.er1 conftest.err
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5
+$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; }
+if ${ac_cv_cxx_compiler_gnu+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+#ifndef __GNUC__
+ choke me
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_compiler_gnu=yes
+else
+ ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5
+$as_echo "$ac_cv_cxx_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+ GXX=yes
+else
+ GXX=
+fi
+ac_test_CXXFLAGS=${CXXFLAGS+set}
+ac_save_CXXFLAGS=$CXXFLAGS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5
+$as_echo_n "checking whether $CXX accepts -g... " >&6; }
+if ${ac_cv_prog_cxx_g+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_save_cxx_werror_flag=$ac_cxx_werror_flag
+ ac_cxx_werror_flag=yes
+ ac_cv_prog_cxx_g=no
+ CXXFLAGS="-g"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_cv_prog_cxx_g=yes
+else
+ CXXFLAGS=""
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+
+else
+ ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+ CXXFLAGS="-g"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_cv_prog_cxx_g=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5
+$as_echo "$ac_cv_prog_cxx_g" >&6; }
+if test "$ac_test_CXXFLAGS" = set; then
+ CXXFLAGS=$ac_save_CXXFLAGS
+elif test $ac_cv_prog_cxx_g = yes; then
+ if test "$GXX" = yes; then
+ CXXFLAGS="-g -O2"
+ else
+ CXXFLAGS="-g"
+ fi
+else
+ if test "$GXX" = yes; then
+ CXXFLAGS="-O2"
+ else
+ CXXFLAGS=
+ fi
+fi
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+depcc="$CXX" am_compiler_list=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
+$as_echo_n "checking dependency style of $depcc... " >&6; }
+if ${am_cv_CXX_dependencies_compiler_type+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+ # We make a subdir and do the tests there. Otherwise we can end up
+ # making bogus files that we don't know about and never remove. For
+ # instance it was reported that on HP-UX the gcc test will end up
+ # making a dummy file named 'D' -- because '-MD' means "put the output
+ # in D".
+ rm -rf conftest.dir
+ mkdir conftest.dir
+ # Copy depcomp to subdir because otherwise we won't find it if we're
+ # using a relative directory.
+ cp "$am_depcomp" conftest.dir
+ cd conftest.dir
+ # We will build objects and dependencies in a subdirectory because
+ # it helps to detect inapplicable dependency modes. For instance
+ # both Tru64's cc and ICC support -MD to output dependencies as a
+ # side effect of compilation, but ICC will put the dependencies in
+ # the current directory while Tru64 will put them in the object
+ # directory.
+ mkdir sub
+
+ am_cv_CXX_dependencies_compiler_type=none
+ if test "$am_compiler_list" = ""; then
+ am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+ fi
+ am__universal=false
+ case " $depcc " in #(
+ *\ -arch\ *\ -arch\ *) am__universal=true ;;
+ esac
+
+ for depmode in $am_compiler_list; do
+ # Setup a source with many dependencies, because some compilers
+ # like to wrap large dependency lists on column 80 (with \), and
+ # we should not choose a depcomp mode which is confused by this.
+ #
+ # We need to recreate these files for each test, as the compiler may
+ # overwrite some of them when testing with obscure command lines.
+ # This happens at least with the AIX C compiler.
+ : > sub/conftest.c
+ for i in 1 2 3 4 5 6; do
+ echo '#include "conftst'$i'.h"' >> sub/conftest.c
+ # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
+ # Solaris 10 /bin/sh.
+ echo '/* dummy */' > sub/conftst$i.h
+ done
+ echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+ # We check with '-c' and '-o' for the sake of the "dashmstdout"
+ # mode. It turns out that the SunPro C++ compiler does not properly
+ # handle '-M -o', and we need to detect this. Also, some Intel
+ # versions had trouble with output in subdirs.
+ am__obj=sub/conftest.${OBJEXT-o}
+ am__minus_obj="-o $am__obj"
+ case $depmode in
+ gcc)
+ # This depmode causes a compiler race in universal mode.
+ test "$am__universal" = false || continue
+ ;;
+ nosideeffect)
+ # After this tag, mechanisms are not by side-effect, so they'll
+ # only be used when explicitly requested.
+ if test "x$enable_dependency_tracking" = xyes; then
+ continue
+ else
+ break
+ fi
+ ;;
+ msvc7 | msvc7msys | msvisualcpp | msvcmsys)
+ # This compiler won't grok '-c -o', but also, the minuso test has
+ # not run yet. These depmodes are late enough in the game, and
+ # so weak that their functioning should not be impacted.
+ am__obj=conftest.${OBJEXT-o}
+ am__minus_obj=
+ ;;
+ none) break ;;
+ esac
+ if depmode=$depmode \
+ source=sub/conftest.c object=$am__obj \
+ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+ >/dev/null 2>conftest.err &&
+ grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+ grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+ grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+ ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+ # icc doesn't choke on unknown options, it will just issue warnings
+ # or remarks (even with -Werror). So we grep stderr for any message
+ # that says an option was ignored or not supported.
+ # When given -MP, icc 7.0 and 7.1 complain thusly:
+ # icc: Command line warning: ignoring option '-M'; no argument required
+ # The diagnosis changed in icc 8.0:
+ # icc: Command line remark: option '-MP' not supported
+ if (grep 'ignoring option' conftest.err ||
+ grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+ am_cv_CXX_dependencies_compiler_type=$depmode
+ break
+ fi
+ fi
+ done
+
+ cd ..
+ rm -rf conftest.dir
+else
+ am_cv_CXX_dependencies_compiler_type=none
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5
+$as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; }
+CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type
+
+ if
+ test "x$enable_dependency_tracking" != xno \
+ && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then
+ am__fastdepCXX_TRUE=
+ am__fastdepCXX_FALSE='#'
+else
+ am__fastdepCXX_TRUE='#'
+ am__fastdepCXX_FALSE=
+fi
+
+
+ if test "$GCC" = yes; then
+ GCC_TRUE=
+ GCC_FALSE='#'
+else
+ GCC_TRUE='#'
+ GCC_FALSE=
+fi
+ # let the Makefile know if we're gcc
+
+case `pwd` in
+ *\ * | *\ *)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
+$as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;;
+esac
+
+
+
+macro_version='2.4.2'
+macro_revision='1.3337'
+
+
+
+
+
+
+
+
+
+
+
+
+
+ltmain="$ac_aux_dir/ltmain.sh"
+
+# Make sure we can run config.sub.
+$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
+ as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
+$as_echo_n "checking build system type... " >&6; }
+if ${ac_cv_build+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_build_alias=$build_alias
+test "x$ac_build_alias" = x &&
+ ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
+test "x$ac_build_alias" = x &&
+ as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
+ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
+ as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
+$as_echo "$ac_cv_build" >&6; }
+case $ac_cv_build in
+*-*-*) ;;
+*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
+esac
+build=$ac_cv_build
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_build
+shift
+build_cpu=$1
+build_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+build_os=$*
+IFS=$ac_save_IFS
+case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
+$as_echo_n "checking host system type... " >&6; }
+if ${ac_cv_host+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test "x$host_alias" = x; then
+ ac_cv_host=$ac_cv_build
+else
+ ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
+ as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
+$as_echo "$ac_cv_host" >&6; }
+case $ac_cv_host in
+*-*-*) ;;
+*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
+esac
+host=$ac_cv_host
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_host
+shift
+host_cpu=$1
+host_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+host_os=$*
+IFS=$ac_save_IFS
+case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
+
+
+# Backslashify metacharacters that are still active within
+# double-quoted strings.
+sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\(["`\\]\)/\\\1/g'
+
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
+# Sed substitution to delay expansion of an escaped single quote.
+delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
+
+# Sed substitution to avoid accidental globbing in evaled expressions
+no_glob_subst='s/\*/\\\*/g'
+
+ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
+ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5
+$as_echo_n "checking how to print strings... " >&6; }
+# Test print first, because it will be a builtin if present.
+if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \
+ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then
+ ECHO='print -r --'
+elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then
+ ECHO='printf %s\n'
+else
+ # Use this function as a fallback that always works.
+ func_fallback_echo ()
+ {
+ eval 'cat <<_LTECHO_EOF
+$1
+_LTECHO_EOF'
+ }
+ ECHO='func_fallback_echo'
+fi
+
+# func_echo_all arg...
+# Invoke $ECHO with all args, space-separated.
+func_echo_all ()
+{
+ $ECHO ""
+}
+
+case "$ECHO" in
+ printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5
+$as_echo "printf" >&6; } ;;
+ print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5
+$as_echo "print -r" >&6; } ;;
+ *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5
+$as_echo "cat" >&6; } ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5
+$as_echo_n "checking for a sed that does not truncate output... " >&6; }
+if ${ac_cv_path_SED+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
+ for ac_i in 1 2 3 4 5 6 7; do
+ ac_script="$ac_script$as_nl$ac_script"
+ done
+ echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed
+ { ac_script=; unset ac_script;}
+ if test -z "$SED"; then
+ ac_path_SED_found=false
+ # Loop through the user's path and test for each of PROGNAME-LIST
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_prog in sed gsed; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ ac_path_SED="$as_dir/$ac_prog$ac_exec_ext"
+ as_fn_executable_p "$ac_path_SED" || continue
+# Check for GNU ac_path_SED and select it if it is found.
+ # Check for GNU $ac_path_SED
+case `"$ac_path_SED" --version 2>&1` in
+*GNU*)
+ ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;;
+*)
+ ac_count=0
+ $as_echo_n 0123456789 >"conftest.in"
+ while :
+ do
+ cat "conftest.in" "conftest.in" >"conftest.tmp"
+ mv "conftest.tmp" "conftest.in"
+ cp "conftest.in" "conftest.nl"
+ $as_echo '' >> "conftest.nl"
+ "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break
+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+ as_fn_arith $ac_count + 1 && ac_count=$as_val
+ if test $ac_count -gt ${ac_path_SED_max-0}; then
+ # Best one so far, save it but keep looking for a better one
+ ac_cv_path_SED="$ac_path_SED"
+ ac_path_SED_max=$ac_count
+ fi
+ # 10*(2^10) chars as input seems more than enough
+ test $ac_count -gt 10 && break
+ done
+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+ $ac_path_SED_found && break 3
+ done
+ done
+ done
+IFS=$as_save_IFS
+ if test -z "$ac_cv_path_SED"; then
+ as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5
+ fi
+else
+ ac_cv_path_SED=$SED
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5
+$as_echo "$ac_cv_path_SED" >&6; }
+ SED="$ac_cv_path_SED"
+ rm -f conftest.sed
+
+test -z "$SED" && SED=sed
+Xsed="$SED -e 1s/^X//"
+
+
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
+$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
+if ${ac_cv_path_GREP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -z "$GREP"; then
+ ac_path_GREP_found=false
+ # Loop through the user's path and test for each of PROGNAME-LIST
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_prog in grep ggrep; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
+ as_fn_executable_p "$ac_path_GREP" || continue
+# Check for GNU ac_path_GREP and select it if it is found.
+ # Check for GNU $ac_path_GREP
+case `"$ac_path_GREP" --version 2>&1` in
+*GNU*)
+ ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+ ac_count=0
+ $as_echo_n 0123456789 >"conftest.in"
+ while :
+ do
+ cat "conftest.in" "conftest.in" >"conftest.tmp"
+ mv "conftest.tmp" "conftest.in"
+ cp "conftest.in" "conftest.nl"
+ $as_echo 'GREP' >> "conftest.nl"
+ "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+ as_fn_arith $ac_count + 1 && ac_count=$as_val
+ if test $ac_count -gt ${ac_path_GREP_max-0}; then
+ # Best one so far, save it but keep looking for a better one
+ ac_cv_path_GREP="$ac_path_GREP"
+ ac_path_GREP_max=$ac_count
+ fi
+ # 10*(2^10) chars as input seems more than enough
+ test $ac_count -gt 10 && break
+ done
+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+ $ac_path_GREP_found && break 3
+ done
+ done
+ done
+IFS=$as_save_IFS
+ if test -z "$ac_cv_path_GREP"; then
+ as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+ fi
+else
+ ac_cv_path_GREP=$GREP
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
+$as_echo "$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
+$as_echo_n "checking for egrep... " >&6; }
+if ${ac_cv_path_EGREP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+ then ac_cv_path_EGREP="$GREP -E"
+ else
+ if test -z "$EGREP"; then
+ ac_path_EGREP_found=false
+ # Loop through the user's path and test for each of PROGNAME-LIST
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_prog in egrep; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
+ as_fn_executable_p "$ac_path_EGREP" || continue
+# Check for GNU ac_path_EGREP and select it if it is found.
+ # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+ ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+ ac_count=0
+ $as_echo_n 0123456789 >"conftest.in"
+ while :
+ do
+ cat "conftest.in" "conftest.in" >"conftest.tmp"
+ mv "conftest.tmp" "conftest.in"
+ cp "conftest.in" "conftest.nl"
+ $as_echo 'EGREP' >> "conftest.nl"
+ "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+ as_fn_arith $ac_count + 1 && ac_count=$as_val
+ if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+ # Best one so far, save it but keep looking for a better one
+ ac_cv_path_EGREP="$ac_path_EGREP"
+ ac_path_EGREP_max=$ac_count
+ fi
+ # 10*(2^10) chars as input seems more than enough
+ test $ac_count -gt 10 && break
+ done
+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+ $ac_path_EGREP_found && break 3
+ done
+ done
+ done
+IFS=$as_save_IFS
+ if test -z "$ac_cv_path_EGREP"; then
+ as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+ fi
+else
+ ac_cv_path_EGREP=$EGREP
+fi
+
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
+$as_echo "$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5
+$as_echo_n "checking for fgrep... " >&6; }
+if ${ac_cv_path_FGREP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1
+ then ac_cv_path_FGREP="$GREP -F"
+ else
+ if test -z "$FGREP"; then
+ ac_path_FGREP_found=false
+ # Loop through the user's path and test for each of PROGNAME-LIST
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_prog in fgrep; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext"
+ as_fn_executable_p "$ac_path_FGREP" || continue
+# Check for GNU ac_path_FGREP and select it if it is found.
+ # Check for GNU $ac_path_FGREP
+case `"$ac_path_FGREP" --version 2>&1` in
+*GNU*)
+ ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;;
+*)
+ ac_count=0
+ $as_echo_n 0123456789 >"conftest.in"
+ while :
+ do
+ cat "conftest.in" "conftest.in" >"conftest.tmp"
+ mv "conftest.tmp" "conftest.in"
+ cp "conftest.in" "conftest.nl"
+ $as_echo 'FGREP' >> "conftest.nl"
+ "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break
+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+ as_fn_arith $ac_count + 1 && ac_count=$as_val
+ if test $ac_count -gt ${ac_path_FGREP_max-0}; then
+ # Best one so far, save it but keep looking for a better one
+ ac_cv_path_FGREP="$ac_path_FGREP"
+ ac_path_FGREP_max=$ac_count
+ fi
+ # 10*(2^10) chars as input seems more than enough
+ test $ac_count -gt 10 && break
+ done
+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+ $ac_path_FGREP_found && break 3
+ done
+ done
+ done
+IFS=$as_save_IFS
+ if test -z "$ac_cv_path_FGREP"; then
+ as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+ fi
+else
+ ac_cv_path_FGREP=$FGREP
+fi
+
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5
+$as_echo "$ac_cv_path_FGREP" >&6; }
+ FGREP="$ac_cv_path_FGREP"
+
+
+test -z "$GREP" && GREP=grep
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# Check whether --with-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then :
+ withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+else
+ with_gnu_ld=no
+fi
+
+ac_prog=ld
+if test "$GCC" = yes; then
+ # Check if gcc -print-prog-name=ld gives a path.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
+$as_echo_n "checking for ld used by $CC... " >&6; }
+ case $host in
+ *-*-mingw*)
+ # gcc leaves a trailing carriage return which upsets mingw
+ ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+ *)
+ ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+ esac
+ case $ac_prog in
+ # Accept absolute paths.
+ [\\/]* | ?:[\\/]*)
+ re_direlt='/[^/][^/]*/\.\./'
+ # Canonicalize the pathname of ld
+ ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
+ while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
+ ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
+ done
+ test -z "$LD" && LD="$ac_prog"
+ ;;
+ "")
+ # If it fails, then pretend we aren't using GCC.
+ ac_prog=ld
+ ;;
+ *)
+ # If it is relative, then search for the first ld in PATH.
+ with_gnu_ld=unknown
+ ;;
+ esac
+elif test "$with_gnu_ld" = yes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
+$as_echo_n "checking for GNU ld... " >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
+$as_echo_n "checking for non-GNU ld... " >&6; }
+fi
+if ${lt_cv_path_LD+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -z "$LD"; then
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ for ac_dir in $PATH; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+ lt_cv_path_LD="$ac_dir/$ac_prog"
+ # Check to see if the program is GNU ld. I'd rather use --version,
+ # but apparently some variants of GNU ld only accept -v.
+ # Break only if it was the GNU/non-GNU ld that we prefer.
+ case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+ *GNU* | *'with BFD'*)
+ test "$with_gnu_ld" != no && break
+ ;;
+ *)
+ test "$with_gnu_ld" != yes && break
+ ;;
+ esac
+ fi
+ done
+ IFS="$lt_save_ifs"
+else
+ lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
+
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
+$as_echo "$LD" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
+$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
+if ${lt_cv_prog_gnu_ld+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ # I'd rather use --version here, but apparently some GNU lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+ lt_cv_prog_gnu_ld=yes
+ ;;
+*)
+ lt_cv_prog_gnu_ld=no
+ ;;
+esac
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&5
+$as_echo "$lt_cv_prog_gnu_ld" >&6; }
+with_gnu_ld=$lt_cv_prog_gnu_ld
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5
+$as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; }
+if ${lt_cv_path_NM+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$NM"; then
+ # Let the user override the test.
+ lt_cv_path_NM="$NM"
+else
+ lt_nm_to_check="${ac_tool_prefix}nm"
+ if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+ lt_nm_to_check="$lt_nm_to_check nm"
+ fi
+ for lt_tmp_nm in $lt_nm_to_check; do
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ tmp_nm="$ac_dir/$lt_tmp_nm"
+ if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+ # Check to see if the nm accepts a BSD-compat flag.
+ # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+ # nm: unknown option "B" ignored
+ # Tru64's nm complains that /dev/null is an invalid object file
+ case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+ */dev/null* | *'Invalid file or object type'*)
+ lt_cv_path_NM="$tmp_nm -B"
+ break
+ ;;
+ *)
+ case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+ */dev/null*)
+ lt_cv_path_NM="$tmp_nm -p"
+ break
+ ;;
+ *)
+ lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+ continue # so that we can try to find one that supports BSD flags
+ ;;
+ esac
+ ;;
+ esac
+ fi
+ done
+ IFS="$lt_save_ifs"
+ done
+ : ${lt_cv_path_NM=no}
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5
+$as_echo "$lt_cv_path_NM" >&6; }
+if test "$lt_cv_path_NM" != "no"; then
+ NM="$lt_cv_path_NM"
+else
+ # Didn't find any BSD compatible name lister, look for dumpbin.
+ if test -n "$DUMPBIN"; then :
+ # Let the user override the test.
+ else
+ if test -n "$ac_tool_prefix"; then
+ for ac_prog in dumpbin "link -dump"
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_DUMPBIN+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$DUMPBIN"; then
+ ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+DUMPBIN=$ac_cv_prog_DUMPBIN
+if test -n "$DUMPBIN"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5
+$as_echo "$DUMPBIN" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$DUMPBIN" && break
+ done
+fi
+if test -z "$DUMPBIN"; then
+ ac_ct_DUMPBIN=$DUMPBIN
+ for ac_prog in dumpbin "link -dump"
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_DUMPBIN"; then
+ ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_DUMPBIN="$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN
+if test -n "$ac_ct_DUMPBIN"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5
+$as_echo "$ac_ct_DUMPBIN" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$ac_ct_DUMPBIN" && break
+done
+
+ if test "x$ac_ct_DUMPBIN" = x; then
+ DUMPBIN=":"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ DUMPBIN=$ac_ct_DUMPBIN
+ fi
+fi
+
+ case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in
+ *COFF*)
+ DUMPBIN="$DUMPBIN -symbols"
+ ;;
+ *)
+ DUMPBIN=:
+ ;;
+ esac
+ fi
+
+ if test "$DUMPBIN" != ":"; then
+ NM="$DUMPBIN"
+ fi
+fi
+test -z "$NM" && NM=nm
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5
+$as_echo_n "checking the name lister ($NM) interface... " >&6; }
+if ${lt_cv_nm_interface+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_nm_interface="BSD nm"
+ echo "int some_variable = 0;" > conftest.$ac_ext
+ (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5)
+ (eval "$ac_compile" 2>conftest.err)
+ cat conftest.err >&5
+ (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+ (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
+ cat conftest.err >&5
+ (eval echo "\"\$as_me:$LINENO: output\"" >&5)
+ cat conftest.out >&5
+ if $GREP 'External.*some_variable' conftest.out > /dev/null; then
+ lt_cv_nm_interface="MS dumpbin"
+ fi
+ rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5
+$as_echo "$lt_cv_nm_interface" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
+$as_echo_n "checking whether ln -s works... " >&6; }
+LN_S=$as_ln_s
+if test "$LN_S" = "ln -s"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5
+$as_echo "no, using $LN_S" >&6; }
+fi
+
+# find the maximum length of command line arguments
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5
+$as_echo_n "checking the maximum length of command line arguments... " >&6; }
+if ${lt_cv_sys_max_cmd_len+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ i=0
+ teststring="ABCD"
+
+ case $build_os in
+ msdosdjgpp*)
+ # On DJGPP, this test can blow up pretty badly due to problems in libc
+ # (any single argument exceeding 2000 bytes causes a buffer overrun
+ # during glob expansion). Even if it were fixed, the result of this
+ # check would be larger than it should be.
+ lt_cv_sys_max_cmd_len=12288; # 12K is about right
+ ;;
+
+ gnu*)
+ # Under GNU Hurd, this test is not required because there is
+ # no limit to the length of command line arguments.
+ # Libtool will interpret -1 as no limit whatsoever
+ lt_cv_sys_max_cmd_len=-1;
+ ;;
+
+ cygwin* | mingw* | cegcc*)
+ # On Win9x/ME, this test blows up -- it succeeds, but takes
+ # about 5 minutes as the teststring grows exponentially.
+ # Worse, since 9x/ME are not pre-emptively multitasking,
+ # you end up with a "frozen" computer, even though with patience
+ # the test eventually succeeds (with a max line length of 256k).
+ # Instead, let's just punt: use the minimum linelength reported by
+ # all of the supported platforms: 8192 (on NT/2K/XP).
+ lt_cv_sys_max_cmd_len=8192;
+ ;;
+
+ mint*)
+ # On MiNT this can take a long time and run out of memory.
+ lt_cv_sys_max_cmd_len=8192;
+ ;;
+
+ amigaos*)
+ # On AmigaOS with pdksh, this test takes hours, literally.
+ # So we just punt and use a minimum line length of 8192.
+ lt_cv_sys_max_cmd_len=8192;
+ ;;
+
+ netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+ # This has been around since 386BSD, at least. Likely further.
+ if test -x /sbin/sysctl; then
+ lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
+ elif test -x /usr/sbin/sysctl; then
+ lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+ else
+ lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs
+ fi
+ # And add a safety zone
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+ ;;
+
+ interix*)
+ # We know the value 262144 and hardcode it with a safety zone (like BSD)
+ lt_cv_sys_max_cmd_len=196608
+ ;;
+
+ os2*)
+ # The test takes a long time on OS/2.
+ lt_cv_sys_max_cmd_len=8192
+ ;;
+
+ osf*)
+ # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
+ # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
+ # nice to cause kernel panics so lets avoid the loop below.
+ # First set a reasonable default.
+ lt_cv_sys_max_cmd_len=16384
+ #
+ if test -x /sbin/sysconfig; then
+ case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
+ *1*) lt_cv_sys_max_cmd_len=-1 ;;
+ esac
+ fi
+ ;;
+ sco3.2v5*)
+ lt_cv_sys_max_cmd_len=102400
+ ;;
+ sysv5* | sco5v6* | sysv4.2uw2*)
+ kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
+ if test -n "$kargmax"; then
+ lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'`
+ else
+ lt_cv_sys_max_cmd_len=32768
+ fi
+ ;;
+ *)
+ lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
+ if test -n "$lt_cv_sys_max_cmd_len"; then
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+ else
+ # Make teststring a little bigger before we do anything with it.
+ # a 1K string should be a reasonable start.
+ for i in 1 2 3 4 5 6 7 8 ; do
+ teststring=$teststring$teststring
+ done
+ SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+ # If test is not a shell built-in, we'll probably end up computing a
+ # maximum length that is only half of the actual maximum length, but
+ # we can't tell.
+ while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \
+ = "X$teststring$teststring"; } >/dev/null 2>&1 &&
+ test $i != 17 # 1/2 MB should be enough
+ do
+ i=`expr $i + 1`
+ teststring=$teststring$teststring
+ done
+ # Only check the string length outside the loop.
+ lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
+ teststring=
+ # Add a significant safety factor because C++ compilers can tack on
+ # massive amounts of additional arguments before passing them to the
+ # linker. It appears as though 1/2 is a usable value.
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+ fi
+ ;;
+ esac
+
+fi
+
+if test -n $lt_cv_sys_max_cmd_len ; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5
+$as_echo "$lt_cv_sys_max_cmd_len" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5
+$as_echo "none" >&6; }
+fi
+max_cmd_len=$lt_cv_sys_max_cmd_len
+
+
+
+
+
+
+: ${CP="cp -f"}
+: ${MV="mv -f"}
+: ${RM="rm -f"}
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5
+$as_echo_n "checking whether the shell understands some XSI constructs... " >&6; }
+# Try some XSI features
+xsi_shell=no
+( _lt_dummy="a/b/c"
+ test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \
+ = c,a/b,b/c, \
+ && eval 'test $(( 1 + 1 )) -eq 2 \
+ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
+ && xsi_shell=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5
+$as_echo "$xsi_shell" >&6; }
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5
+$as_echo_n "checking whether the shell understands \"+=\"... " >&6; }
+lt_shell_append=no
+( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \
+ >/dev/null 2>&1 \
+ && lt_shell_append=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5
+$as_echo "$lt_shell_append" >&6; }
+
+
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+ lt_unset=unset
+else
+ lt_unset=false
+fi
+
+
+
+
+
+# test EBCDIC or ASCII
+case `echo X|tr X '\101'` in
+ A) # ASCII based system
+ # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
+ lt_SP2NL='tr \040 \012'
+ lt_NL2SP='tr \015\012 \040\040'
+ ;;
+ *) # EBCDIC based system
+ lt_SP2NL='tr \100 \n'
+ lt_NL2SP='tr \r\n \100\100'
+ ;;
+esac
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5
+$as_echo_n "checking how to convert $build file names to $host format... " >&6; }
+if ${lt_cv_to_host_file_cmd+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $host in
+ *-*-mingw* )
+ case $build in
+ *-*-mingw* ) # actually msys
+ lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32
+ ;;
+ *-*-cygwin* )
+ lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32
+ ;;
+ * ) # otherwise, assume *nix
+ lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32
+ ;;
+ esac
+ ;;
+ *-*-cygwin* )
+ case $build in
+ *-*-mingw* ) # actually msys
+ lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin
+ ;;
+ *-*-cygwin* )
+ lt_cv_to_host_file_cmd=func_convert_file_noop
+ ;;
+ * ) # otherwise, assume *nix
+ lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin
+ ;;
+ esac
+ ;;
+ * ) # unhandled hosts (and "normal" native builds)
+ lt_cv_to_host_file_cmd=func_convert_file_noop
+ ;;
+esac
+
+fi
+
+to_host_file_cmd=$lt_cv_to_host_file_cmd
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5
+$as_echo "$lt_cv_to_host_file_cmd" >&6; }
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5
+$as_echo_n "checking how to convert $build file names to toolchain format... " >&6; }
+if ${lt_cv_to_tool_file_cmd+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ #assume ordinary cross tools, or native build.
+lt_cv_to_tool_file_cmd=func_convert_file_noop
+case $host in
+ *-*-mingw* )
+ case $build in
+ *-*-mingw* ) # actually msys
+ lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32
+ ;;
+ esac
+ ;;
+esac
+
+fi
+
+to_tool_file_cmd=$lt_cv_to_tool_file_cmd
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5
+$as_echo "$lt_cv_to_tool_file_cmd" >&6; }
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5
+$as_echo_n "checking for $LD option to reload object files... " >&6; }
+if ${lt_cv_ld_reload_flag+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_ld_reload_flag='-r'
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5
+$as_echo "$lt_cv_ld_reload_flag" >&6; }
+reload_flag=$lt_cv_ld_reload_flag
+case $reload_flag in
+"" | " "*) ;;
+*) reload_flag=" $reload_flag" ;;
+esac
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+case $host_os in
+ cygwin* | mingw* | pw32* | cegcc*)
+ if test "$GCC" != yes; then
+ reload_cmds=false
+ fi
+ ;;
+ darwin*)
+ if test "$GCC" = yes; then
+ reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
+ else
+ reload_cmds='$LD$reload_flag -o $output$reload_objs'
+ fi
+ ;;
+esac
+
+
+
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args.
+set dummy ${ac_tool_prefix}objdump; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_OBJDUMP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$OBJDUMP"; then
+ ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+OBJDUMP=$ac_cv_prog_OBJDUMP
+if test -n "$OBJDUMP"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5
+$as_echo "$OBJDUMP" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_OBJDUMP"; then
+ ac_ct_OBJDUMP=$OBJDUMP
+ # Extract the first word of "objdump", so it can be a program name with args.
+set dummy objdump; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_OBJDUMP"; then
+ ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_OBJDUMP="objdump"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP
+if test -n "$ac_ct_OBJDUMP"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5
+$as_echo "$ac_ct_OBJDUMP" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_OBJDUMP" = x; then
+ OBJDUMP="false"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ OBJDUMP=$ac_ct_OBJDUMP
+ fi
+else
+ OBJDUMP="$ac_cv_prog_OBJDUMP"
+fi
+
+test -z "$OBJDUMP" && OBJDUMP=objdump
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5
+$as_echo_n "checking how to recognize dependent libraries... " >&6; }
+if ${lt_cv_deplibs_check_method+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_file_magic_cmd='$MAGIC_CMD'
+lt_cv_file_magic_test_file=
+lt_cv_deplibs_check_method='unknown'
+# Need to set the preceding variable on all platforms that support
+# interlibrary dependencies.
+# 'none' -- dependencies not supported.
+# `unknown' -- same as none, but documents that we really don't know.
+# 'pass_all' -- all dependencies passed with no checks.
+# 'test_compile' -- check by making test program.
+# 'file_magic [[regex]]' -- check by looking for files in library path
+# which responds to the $file_magic_cmd with a given extended regex.
+# If you have `file' or equivalent on your system and you're not sure
+# whether `pass_all' will *always* work, you probably want this one.
+
+case $host_os in
+aix[4-9]*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+beos*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+bsdi[45]*)
+ lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
+ lt_cv_file_magic_cmd='/usr/bin/file -L'
+ lt_cv_file_magic_test_file=/shlib/libc.so
+ ;;
+
+cygwin*)
+ # func_win32_libid is a shell function defined in ltmain.sh
+ lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+ lt_cv_file_magic_cmd='func_win32_libid'
+ ;;
+
+mingw* | pw32*)
+ # Base MSYS/MinGW do not provide the 'file' command needed by
+ # func_win32_libid shell function, so use a weaker test based on 'objdump',
+ # unless we find 'file', for example because we are cross-compiling.
+ # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.
+ if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then
+ lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+ lt_cv_file_magic_cmd='func_win32_libid'
+ else
+ # Keep this pattern in sync with the one in func_win32_libid.
+ lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)'
+ lt_cv_file_magic_cmd='$OBJDUMP -f'
+ fi
+ ;;
+
+cegcc*)
+ # use the weaker test based on 'objdump'. See mingw*.
+ lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'
+ lt_cv_file_magic_cmd='$OBJDUMP -f'
+ ;;
+
+darwin* | rhapsody*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+freebsd* | dragonfly*)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+ case $host_cpu in
+ i*86 )
+ # Not sure whether the presence of OpenBSD here was a mistake.
+ # Let's accept both of them until this is cleared up.
+ lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library'
+ lt_cv_file_magic_cmd=/usr/bin/file
+ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
+ ;;
+ esac
+ else
+ lt_cv_deplibs_check_method=pass_all
+ fi
+ ;;
+
+gnu*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+haiku*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+hpux10.20* | hpux11*)
+ lt_cv_file_magic_cmd=/usr/bin/file
+ case $host_cpu in
+ ia64*)
+ lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
+ lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+ ;;
+ hppa*64*)
+ lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'
+ lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+ ;;
+ *)
+ lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library'
+ lt_cv_file_magic_test_file=/usr/lib/libc.sl
+ ;;
+ esac
+ ;;
+
+interix[3-9]*)
+ # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
+ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$'
+ ;;
+
+irix5* | irix6* | nonstopux*)
+ case $LD in
+ *-32|*"-32 ") libmagic=32-bit;;
+ *-n32|*"-n32 ") libmagic=N32;;
+ *-64|*"-64 ") libmagic=64-bit;;
+ *) libmagic=never-match;;
+ esac
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+# This must be glibc/ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+netbsd* | netbsdelf*-gnu)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
+ else
+ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$'
+ fi
+ ;;
+
+newos6*)
+ lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
+ lt_cv_file_magic_cmd=/usr/bin/file
+ lt_cv_file_magic_test_file=/usr/lib/libnls.so
+ ;;
+
+*nto* | *qnx*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+openbsd*)
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$'
+ else
+ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
+ fi
+ ;;
+
+osf3* | osf4* | osf5*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+rdos*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+solaris*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+sysv4 | sysv4.3*)
+ case $host_vendor in
+ motorola)
+ lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'
+ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
+ ;;
+ ncr)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+ sequent)
+ lt_cv_file_magic_cmd='/bin/file'
+ lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
+ ;;
+ sni)
+ lt_cv_file_magic_cmd='/bin/file'
+ lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib"
+ lt_cv_file_magic_test_file=/lib/libc.so
+ ;;
+ siemens)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+ pc)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+ esac
+ ;;
+
+tpf*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+esac
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5
+$as_echo "$lt_cv_deplibs_check_method" >&6; }
+
+file_magic_glob=
+want_nocaseglob=no
+if test "$build" = "$host"; then
+ case $host_os in
+ mingw* | pw32*)
+ if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then
+ want_nocaseglob=yes
+ else
+ file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"`
+ fi
+ ;;
+ esac
+fi
+
+file_magic_cmd=$lt_cv_file_magic_cmd
+deplibs_check_method=$lt_cv_deplibs_check_method
+test -z "$deplibs_check_method" && deplibs_check_method=unknown
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args.
+set dummy ${ac_tool_prefix}dlltool; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_DLLTOOL+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$DLLTOOL"; then
+ ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+DLLTOOL=$ac_cv_prog_DLLTOOL
+if test -n "$DLLTOOL"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5
+$as_echo "$DLLTOOL" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_DLLTOOL"; then
+ ac_ct_DLLTOOL=$DLLTOOL
+ # Extract the first word of "dlltool", so it can be a program name with args.
+set dummy dlltool; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_DLLTOOL"; then
+ ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_DLLTOOL="dlltool"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL
+if test -n "$ac_ct_DLLTOOL"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5
+$as_echo "$ac_ct_DLLTOOL" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_DLLTOOL" = x; then
+ DLLTOOL="false"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ DLLTOOL=$ac_ct_DLLTOOL
+ fi
+else
+ DLLTOOL="$ac_cv_prog_DLLTOOL"
+fi
+
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5
+$as_echo_n "checking how to associate runtime and link libraries... " >&6; }
+if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_sharedlib_from_linklib_cmd='unknown'
+
+case $host_os in
+cygwin* | mingw* | pw32* | cegcc*)
+ # two different shell functions defined in ltmain.sh
+ # decide which to use based on capabilities of $DLLTOOL
+ case `$DLLTOOL --help 2>&1` in
+ *--identify-strict*)
+ lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib
+ ;;
+ *)
+ lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback
+ ;;
+ esac
+ ;;
+*)
+ # fallback: assume linklib IS sharedlib
+ lt_cv_sharedlib_from_linklib_cmd="$ECHO"
+ ;;
+esac
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5
+$as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; }
+sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd
+test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO
+
+
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+ for ac_prog in ar
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_AR+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$AR"; then
+ ac_cv_prog_AR="$AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_AR="$ac_tool_prefix$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+AR=$ac_cv_prog_AR
+if test -n "$AR"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
+$as_echo "$AR" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$AR" && break
+ done
+fi
+if test -z "$AR"; then
+ ac_ct_AR=$AR
+ for ac_prog in ar
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_AR+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_AR"; then
+ ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_AR="$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_AR=$ac_cv_prog_ac_ct_AR
+if test -n "$ac_ct_AR"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
+$as_echo "$ac_ct_AR" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$ac_ct_AR" && break
+done
+
+ if test "x$ac_ct_AR" = x; then
+ AR="false"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ AR=$ac_ct_AR
+ fi
+fi
+
+: ${AR=ar}
+: ${AR_FLAGS=cru}
+
+
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5
+$as_echo_n "checking for archiver @FILE support... " >&6; }
+if ${lt_cv_ar_at_file+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_ar_at_file=no
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ echo conftest.$ac_objext > conftest.lst
+ lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5'
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5
+ (eval $lt_ar_try) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+ if test "$ac_status" -eq 0; then
+ # Ensure the archiver fails upon bogus file names.
+ rm -f conftest.$ac_objext libconftest.a
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5
+ (eval $lt_ar_try) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+ if test "$ac_status" -ne 0; then
+ lt_cv_ar_at_file=@
+ fi
+ fi
+ rm -f conftest.* libconftest.a
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5
+$as_echo "$lt_cv_ar_at_file" >&6; }
+
+if test "x$lt_cv_ar_at_file" = xno; then
+ archiver_list_spec=
+else
+ archiver_list_spec=$lt_cv_ar_at_file
+fi
+
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_STRIP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$STRIP"; then
+ ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
+$as_echo "$STRIP" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+ ac_ct_STRIP=$STRIP
+ # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_STRIP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_STRIP"; then
+ ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_STRIP="strip"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
+$as_echo "$ac_ct_STRIP" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_STRIP" = x; then
+ STRIP=":"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ STRIP=$ac_ct_STRIP
+ fi
+else
+ STRIP="$ac_cv_prog_STRIP"
+fi
+
+test -z "$STRIP" && STRIP=:
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_RANLIB+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$RANLIB"; then
+ ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+RANLIB=$ac_cv_prog_RANLIB
+if test -n "$RANLIB"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
+$as_echo "$RANLIB" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_RANLIB"; then
+ ac_ct_RANLIB=$RANLIB
+ # Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_RANLIB+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_RANLIB"; then
+ ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_RANLIB="ranlib"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
+if test -n "$ac_ct_RANLIB"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
+$as_echo "$ac_ct_RANLIB" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_RANLIB" = x; then
+ RANLIB=":"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ RANLIB=$ac_ct_RANLIB
+ fi
+else
+ RANLIB="$ac_cv_prog_RANLIB"
+fi
+
+test -z "$RANLIB" && RANLIB=:
+
+
+
+
+
+
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
+
+if test -n "$RANLIB"; then
+ case $host_os in
+ openbsd*)
+ old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib"
+ ;;
+ *)
+ old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib"
+ ;;
+ esac
+ old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib"
+fi
+
+case $host_os in
+ darwin*)
+ lock_old_archive_extraction=yes ;;
+ *)
+ lock_old_archive_extraction=no ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5
+$as_echo_n "checking command to parse $NM output from $compiler object... " >&6; }
+if ${lt_cv_sys_global_symbol_pipe+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+# These are sane defaults that work on at least a few old systems.
+# [They come from Ultrix. What could be older than Ultrix?!! ;)]
+
+# Character class describing NM global symbol codes.
+symcode='[BCDEGRST]'
+
+# Regexp to match symbols that can be accessed directly from C.
+sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
+
+# Define system-specific variables.
+case $host_os in
+aix*)
+ symcode='[BCDT]'
+ ;;
+cygwin* | mingw* | pw32* | cegcc*)
+ symcode='[ABCDGISTW]'
+ ;;
+hpux*)
+ if test "$host_cpu" = ia64; then
+ symcode='[ABCDEGRST]'
+ fi
+ ;;
+irix* | nonstopux*)
+ symcode='[BCDEGRST]'
+ ;;
+osf*)
+ symcode='[BCDEGQRST]'
+ ;;
+solaris*)
+ symcode='[BDRT]'
+ ;;
+sco3.2v5*)
+ symcode='[DT]'
+ ;;
+sysv4.2uw2*)
+ symcode='[DT]'
+ ;;
+sysv5* | sco5v6* | unixware* | OpenUNIX*)
+ symcode='[ABDT]'
+ ;;
+sysv4)
+ symcode='[DFNSTU]'
+ ;;
+esac
+
+# If we're using GNU nm, then use its standard symbol codes.
+case `$NM -V 2>&1` in
+*GNU* | *'with BFD'*)
+ symcode='[ABCDGIRSTW]' ;;
+esac
+
+# Transform an extracted symbol line into a proper C declaration.
+# Some systems (esp. on ia64) link data and code symbols differently,
+# so use this general approach.
+lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+
+# Transform an extracted symbol line into symbol name and symbol address
+lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'"
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'"
+
+# Handle CRLF in mingw tool chain
+opt_cr=
+case $build_os in
+mingw*)
+ opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
+ ;;
+esac
+
+# Try without a prefix underscore, then with it.
+for ac_symprfx in "" "_"; do
+
+ # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
+ symxfrm="\\1 $ac_symprfx\\2 \\2"
+
+ # Write the raw and C identifiers.
+ if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+ # Fake it for dumpbin and say T for any non-static function
+ # and D for any global variable.
+ # Also find C++ and __fastcall symbols from MSVC++,
+ # which start with @ or ?.
+ lt_cv_sys_global_symbol_pipe="$AWK '"\
+" {last_section=section; section=\$ 3};"\
+" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\
+" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
+" \$ 0!~/External *\|/{next};"\
+" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
+" {if(hide[section]) next};"\
+" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
+" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
+" s[1]~/^[@?]/{print s[1], s[1]; next};"\
+" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
+" ' prfx=^$ac_symprfx"
+ else
+ lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+ fi
+ lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'"
+
+ # Check to see that the pipe works correctly.
+ pipe_works=no
+
+ rm -f conftest*
+ cat > conftest.$ac_ext <<_LT_EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(void);
+void nm_test_func(void){}
+#ifdef __cplusplus
+}
+#endif
+int main(){nm_test_var='a';nm_test_func();return(0);}
+_LT_EOF
+
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ # Now try to grab the symbols.
+ nlist=conftest.nm
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5
+ (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && test -s "$nlist"; then
+ # Try sorting and uniquifying the output.
+ if sort "$nlist" | uniq > "$nlist"T; then
+ mv -f "$nlist"T "$nlist"
+ else
+ rm -f "$nlist"T
+ fi
+
+ # Make sure that we snagged all the symbols we need.
+ if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
+ if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
+ cat <<_LT_EOF > conftest.$ac_ext
+/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */
+#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
+/* DATA imports from DLLs on WIN32 con't be const, because runtime
+ relocations are performed -- see ld's documentation on pseudo-relocs. */
+# define LT_DLSYM_CONST
+#elif defined(__osf__)
+/* This system does not cope well with relocations in const data. */
+# define LT_DLSYM_CONST
+#else
+# define LT_DLSYM_CONST const
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+_LT_EOF
+ # Now generate the symbol file.
+ eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
+
+ cat <<_LT_EOF >> conftest.$ac_ext
+
+/* The mapping between symbol names and symbols. */
+LT_DLSYM_CONST struct {
+ const char *name;
+ void *address;
+}
+lt__PROGRAM__LTX_preloaded_symbols[] =
+{
+ { "@PROGRAM@", (void *) 0 },
+_LT_EOF
+ $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+ cat <<\_LT_EOF >> conftest.$ac_ext
+ {0, (void *) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+ return lt__PROGRAM__LTX_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+_LT_EOF
+ # Now try linking the two files.
+ mv conftest.$ac_objext conftstm.$ac_objext
+ lt_globsym_save_LIBS=$LIBS
+ lt_globsym_save_CFLAGS=$CFLAGS
+ LIBS="conftstm.$ac_objext"
+ CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag"
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && test -s conftest${ac_exeext}; then
+ pipe_works=yes
+ fi
+ LIBS=$lt_globsym_save_LIBS
+ CFLAGS=$lt_globsym_save_CFLAGS
+ else
+ echo "cannot find nm_test_func in $nlist" >&5
+ fi
+ else
+ echo "cannot find nm_test_var in $nlist" >&5
+ fi
+ else
+ echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5
+ fi
+ else
+ echo "$progname: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ fi
+ rm -rf conftest* conftst*
+
+ # Do not use the global_symbol_pipe unless it works.
+ if test "$pipe_works" = yes; then
+ break
+ else
+ lt_cv_sys_global_symbol_pipe=
+ fi
+done
+
+fi
+
+if test -z "$lt_cv_sys_global_symbol_pipe"; then
+ lt_cv_sys_global_symbol_to_cdecl=
+fi
+if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5
+$as_echo "failed" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
+$as_echo "ok" >&6; }
+fi
+
+# Response file support.
+if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+ nm_file_list_spec='@'
+elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then
+ nm_file_list_spec='@'
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5
+$as_echo_n "checking for sysroot... " >&6; }
+
+# Check whether --with-sysroot was given.
+if test "${with_sysroot+set}" = set; then :
+ withval=$with_sysroot;
+else
+ with_sysroot=no
+fi
+
+
+lt_sysroot=
+case ${with_sysroot} in #(
+ yes)
+ if test "$GCC" = yes; then
+ lt_sysroot=`$CC --print-sysroot 2>/dev/null`
+ fi
+ ;; #(
+ /*)
+ lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"`
+ ;; #(
+ no|'')
+ ;; #(
+ *)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}" >&5
+$as_echo "${with_sysroot}" >&6; }
+ as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5
+ ;;
+esac
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5
+$as_echo "${lt_sysroot:-no}" >&6; }
+
+
+
+
+
+
+# Check whether --enable-libtool-lock was given.
+if test "${enable_libtool_lock+set}" = set; then :
+ enableval=$enable_libtool_lock;
+fi
+
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case $host in
+ia64-*-hpux*)
+ # Find out which ABI we are using.
+ echo 'int i;' > conftest.$ac_ext
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ case `/usr/bin/file conftest.$ac_objext` in
+ *ELF-32*)
+ HPUX_IA64_MODE="32"
+ ;;
+ *ELF-64*)
+ HPUX_IA64_MODE="64"
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+*-*-irix6*)
+ # Find out which ABI we are using.
+ echo '#line '$LINENO' "configure"' > conftest.$ac_ext
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ if test "$lt_cv_prog_gnu_ld" = yes; then
+ case `/usr/bin/file conftest.$ac_objext` in
+ *32-bit*)
+ LD="${LD-ld} -melf32bsmip"
+ ;;
+ *N32*)
+ LD="${LD-ld} -melf32bmipn32"
+ ;;
+ *64-bit*)
+ LD="${LD-ld} -melf64bmip"
+ ;;
+ esac
+ else
+ case `/usr/bin/file conftest.$ac_objext` in
+ *32-bit*)
+ LD="${LD-ld} -32"
+ ;;
+ *N32*)
+ LD="${LD-ld} -n32"
+ ;;
+ *64-bit*)
+ LD="${LD-ld} -64"
+ ;;
+ esac
+ fi
+ fi
+ rm -rf conftest*
+ ;;
+
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
+s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
+ # Find out which ABI we are using.
+ echo 'int i;' > conftest.$ac_ext
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ case `/usr/bin/file conftest.o` in
+ *32-bit*)
+ case $host in
+ x86_64-*kfreebsd*-gnu)
+ LD="${LD-ld} -m elf_i386_fbsd"
+ ;;
+ x86_64-*linux*)
+ LD="${LD-ld} -m elf_i386"
+ ;;
+ ppc64-*linux*|powerpc64-*linux*)
+ LD="${LD-ld} -m elf32ppclinux"
+ ;;
+ s390x-*linux*)
+ LD="${LD-ld} -m elf_s390"
+ ;;
+ sparc64-*linux*)
+ LD="${LD-ld} -m elf32_sparc"
+ ;;
+ esac
+ ;;
+ *64-bit*)
+ case $host in
+ x86_64-*kfreebsd*-gnu)
+ LD="${LD-ld} -m elf_x86_64_fbsd"
+ ;;
+ x86_64-*linux*)
+ LD="${LD-ld} -m elf_x86_64"
+ ;;
+ ppc*-*linux*|powerpc*-*linux*)
+ LD="${LD-ld} -m elf64ppc"
+ ;;
+ s390*-*linux*|s390*-*tpf*)
+ LD="${LD-ld} -m elf64_s390"
+ ;;
+ sparc*-*linux*)
+ LD="${LD-ld} -m elf64_sparc"
+ ;;
+ esac
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+
+*-*-sco3.2v5*)
+ # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+ SAVE_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -belf"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5
+$as_echo_n "checking whether the C compiler needs -belf... " >&6; }
+if ${lt_cv_cc_needs_belf+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ lt_cv_cc_needs_belf=yes
+else
+ lt_cv_cc_needs_belf=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5
+$as_echo "$lt_cv_cc_needs_belf" >&6; }
+ if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+ # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+ CFLAGS="$SAVE_CFLAGS"
+ fi
+ ;;
+*-*solaris*)
+ # Find out which ABI we are using.
+ echo 'int i;' > conftest.$ac_ext
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ case `/usr/bin/file conftest.o` in
+ *64-bit*)
+ case $lt_cv_prog_gnu_ld in
+ yes*)
+ case $host in
+ i?86-*-solaris*)
+ LD="${LD-ld} -m elf_x86_64"
+ ;;
+ sparc*-*-solaris*)
+ LD="${LD-ld} -m elf64_sparc"
+ ;;
+ esac
+ # GNU ld 2.21 introduced _sol2 emulations. Use them if available.
+ if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then
+ LD="${LD-ld}_sol2"
+ fi
+ ;;
+ *)
+ if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
+ LD="${LD-ld} -64"
+ fi
+ ;;
+ esac
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+esac
+
+need_locks="$enable_libtool_lock"
+
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args.
+set dummy ${ac_tool_prefix}mt; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_MANIFEST_TOOL+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$MANIFEST_TOOL"; then
+ ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL
+if test -n "$MANIFEST_TOOL"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5
+$as_echo "$MANIFEST_TOOL" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_MANIFEST_TOOL"; then
+ ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL
+ # Extract the first word of "mt", so it can be a program name with args.
+set dummy mt; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_MANIFEST_TOOL"; then
+ ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_MANIFEST_TOOL="mt"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL
+if test -n "$ac_ct_MANIFEST_TOOL"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5
+$as_echo "$ac_ct_MANIFEST_TOOL" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_MANIFEST_TOOL" = x; then
+ MANIFEST_TOOL=":"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL
+ fi
+else
+ MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL"
+fi
+
+test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5
+$as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; }
+if ${lt_cv_path_mainfest_tool+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_path_mainfest_tool=no
+ echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5
+ $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out
+ cat conftest.err >&5
+ if $GREP 'Manifest Tool' conftest.out > /dev/null; then
+ lt_cv_path_mainfest_tool=yes
+ fi
+ rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5
+$as_echo "$lt_cv_path_mainfest_tool" >&6; }
+if test "x$lt_cv_path_mainfest_tool" != xyes; then
+ MANIFEST_TOOL=:
+fi
+
+
+
+
+
+
+ case $host_os in
+ rhapsody* | darwin*)
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args.
+set dummy ${ac_tool_prefix}dsymutil; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_DSYMUTIL+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$DSYMUTIL"; then
+ ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+DSYMUTIL=$ac_cv_prog_DSYMUTIL
+if test -n "$DSYMUTIL"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5
+$as_echo "$DSYMUTIL" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_DSYMUTIL"; then
+ ac_ct_DSYMUTIL=$DSYMUTIL
+ # Extract the first word of "dsymutil", so it can be a program name with args.
+set dummy dsymutil; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_DSYMUTIL"; then
+ ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_DSYMUTIL="dsymutil"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL
+if test -n "$ac_ct_DSYMUTIL"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5
+$as_echo "$ac_ct_DSYMUTIL" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_DSYMUTIL" = x; then
+ DSYMUTIL=":"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ DSYMUTIL=$ac_ct_DSYMUTIL
+ fi
+else
+ DSYMUTIL="$ac_cv_prog_DSYMUTIL"
+fi
+
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args.
+set dummy ${ac_tool_prefix}nmedit; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_NMEDIT+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$NMEDIT"; then
+ ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+NMEDIT=$ac_cv_prog_NMEDIT
+if test -n "$NMEDIT"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5
+$as_echo "$NMEDIT" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_NMEDIT"; then
+ ac_ct_NMEDIT=$NMEDIT
+ # Extract the first word of "nmedit", so it can be a program name with args.
+set dummy nmedit; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_NMEDIT"; then
+ ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_NMEDIT="nmedit"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT
+if test -n "$ac_ct_NMEDIT"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5
+$as_echo "$ac_ct_NMEDIT" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_NMEDIT" = x; then
+ NMEDIT=":"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ NMEDIT=$ac_ct_NMEDIT
+ fi
+else
+ NMEDIT="$ac_cv_prog_NMEDIT"
+fi
+
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args.
+set dummy ${ac_tool_prefix}lipo; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_LIPO+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$LIPO"; then
+ ac_cv_prog_LIPO="$LIPO" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_LIPO="${ac_tool_prefix}lipo"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+LIPO=$ac_cv_prog_LIPO
+if test -n "$LIPO"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5
+$as_echo "$LIPO" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_LIPO"; then
+ ac_ct_LIPO=$LIPO
+ # Extract the first word of "lipo", so it can be a program name with args.
+set dummy lipo; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_LIPO+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_LIPO"; then
+ ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_LIPO="lipo"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO
+if test -n "$ac_ct_LIPO"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5
+$as_echo "$ac_ct_LIPO" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_LIPO" = x; then
+ LIPO=":"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ LIPO=$ac_ct_LIPO
+ fi
+else
+ LIPO="$ac_cv_prog_LIPO"
+fi
+
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args.
+set dummy ${ac_tool_prefix}otool; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_OTOOL+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$OTOOL"; then
+ ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_OTOOL="${ac_tool_prefix}otool"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+OTOOL=$ac_cv_prog_OTOOL
+if test -n "$OTOOL"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5
+$as_echo "$OTOOL" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_OTOOL"; then
+ ac_ct_OTOOL=$OTOOL
+ # Extract the first word of "otool", so it can be a program name with args.
+set dummy otool; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_OTOOL+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_OTOOL"; then
+ ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_OTOOL="otool"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL
+if test -n "$ac_ct_OTOOL"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5
+$as_echo "$ac_ct_OTOOL" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_OTOOL" = x; then
+ OTOOL=":"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ OTOOL=$ac_ct_OTOOL
+ fi
+else
+ OTOOL="$ac_cv_prog_OTOOL"
+fi
+
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args.
+set dummy ${ac_tool_prefix}otool64; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_OTOOL64+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$OTOOL64"; then
+ ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+OTOOL64=$ac_cv_prog_OTOOL64
+if test -n "$OTOOL64"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5
+$as_echo "$OTOOL64" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_OTOOL64"; then
+ ac_ct_OTOOL64=$OTOOL64
+ # Extract the first word of "otool64", so it can be a program name with args.
+set dummy otool64; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_OTOOL64"; then
+ ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_OTOOL64="otool64"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64
+if test -n "$ac_ct_OTOOL64"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5
+$as_echo "$ac_ct_OTOOL64" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_OTOOL64" = x; then
+ OTOOL64=":"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ OTOOL64=$ac_ct_OTOOL64
+ fi
+else
+ OTOOL64="$ac_cv_prog_OTOOL64"
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5
+$as_echo_n "checking for -single_module linker flag... " >&6; }
+if ${lt_cv_apple_cc_single_mod+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_apple_cc_single_mod=no
+ if test -z "${LT_MULTI_MODULE}"; then
+ # By default we will add the -single_module flag. You can override
+ # by either setting the environment variable LT_MULTI_MODULE
+ # non-empty at configure time, or by adding -multi_module to the
+ # link flags.
+ rm -rf libconftest.dylib*
+ echo "int foo(void){return 1;}" > conftest.c
+ echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+-dynamiclib -Wl,-single_module conftest.c" >&5
+ $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
+ _lt_result=$?
+ # If there is a non-empty error log, and "single_module"
+ # appears in it, assume the flag caused a linker warning
+ if test -s conftest.err && $GREP single_module conftest.err; then
+ cat conftest.err >&5
+ # Otherwise, if the output was created with a 0 exit code from
+ # the compiler, it worked.
+ elif test -f libconftest.dylib && test $_lt_result -eq 0; then
+ lt_cv_apple_cc_single_mod=yes
+ else
+ cat conftest.err >&5
+ fi
+ rm -rf libconftest.dylib*
+ rm -f conftest.*
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5
+$as_echo "$lt_cv_apple_cc_single_mod" >&6; }
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5
+$as_echo_n "checking for -exported_symbols_list linker flag... " >&6; }
+if ${lt_cv_ld_exported_symbols_list+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_ld_exported_symbols_list=no
+ save_LDFLAGS=$LDFLAGS
+ echo "_main" > conftest.sym
+ LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ lt_cv_ld_exported_symbols_list=yes
+else
+ lt_cv_ld_exported_symbols_list=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ LDFLAGS="$save_LDFLAGS"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5
+$as_echo "$lt_cv_ld_exported_symbols_list" >&6; }
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5
+$as_echo_n "checking for -force_load linker flag... " >&6; }
+if ${lt_cv_ld_force_load+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_ld_force_load=no
+ cat > conftest.c << _LT_EOF
+int forced_loaded() { return 2;}
+_LT_EOF
+ echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5
+ $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5
+ echo "$AR cru libconftest.a conftest.o" >&5
+ $AR cru libconftest.a conftest.o 2>&5
+ echo "$RANLIB libconftest.a" >&5
+ $RANLIB libconftest.a 2>&5
+ cat > conftest.c << _LT_EOF
+int main() { return 0;}
+_LT_EOF
+ echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5
+ $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err
+ _lt_result=$?
+ if test -s conftest.err && $GREP force_load conftest.err; then
+ cat conftest.err >&5
+ elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then
+ lt_cv_ld_force_load=yes
+ else
+ cat conftest.err >&5
+ fi
+ rm -f conftest.err libconftest.a conftest conftest.c
+ rm -rf conftest.dSYM
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5
+$as_echo "$lt_cv_ld_force_load" >&6; }
+ case $host_os in
+ rhapsody* | darwin1.[012])
+ _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+ darwin1.*)
+ _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+ darwin*) # darwin 5.x on
+ # if running on 10.5 or later, the deployment target defaults
+ # to the OS version, if on x86, and 10.4, the deployment
+ # target defaults to 10.4. Don't you love it?
+ case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
+ 10.0,*86*-darwin8*|10.0,*-darwin[91]*)
+ _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+ 10.[012]*)
+ _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+ 10.*)
+ _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+ esac
+ ;;
+ esac
+ if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+ _lt_dar_single_mod='$single_module'
+ fi
+ if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
+ _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+ else
+ _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ fi
+ if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then
+ _lt_dsymutil='~$DSYMUTIL $lib || :'
+ else
+ _lt_dsymutil=
+ fi
+ ;;
+ esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if ${ac_cv_header_stdc+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_header_stdc=yes
+else
+ ac_cv_header_stdc=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "memchr" >/dev/null 2>&1; then :
+
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "free" >/dev/null 2>&1; then :
+
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+ if test "$cross_compiling" = yes; then :
+ :
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+ (('a' <= (c) && (c) <= 'i') \
+ || ('j' <= (c) && (c) <= 'r') \
+ || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+ int i;
+ for (i = 0; i < 256; i++)
+ if (XOR (islower (i), ISLOWER (i))
+ || toupper (i) != TOUPPER (i))
+ return 2;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+
+else
+ ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+$as_echo "#define STDC_HEADERS 1" >>confdefs.h
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+ inttypes.h stdint.h unistd.h
+do :
+ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
+"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in dlfcn.h
+do :
+ ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default
+"
+if test "x$ac_cv_header_dlfcn_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DLFCN_H 1
+_ACEOF
+
+fi
+
+done
+
+
+
+func_stripname_cnf ()
+{
+ case ${2} in
+ .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
+ *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
+ esac
+} # func_stripname_cnf
+
+
+
+
+
+# Set options
+
+
+
+ enable_dlopen=no
+
+
+ enable_win32_dll=no
+
+
+ # Check whether --enable-shared was given.
+if test "${enable_shared+set}" = set; then :
+ enableval=$enable_shared; p=${PACKAGE-default}
+ case $enableval in
+ yes) enable_shared=yes ;;
+ no) enable_shared=no ;;
+ *)
+ enable_shared=no
+ # Look at the argument we got. We use all the common list separators.
+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ for pkg in $enableval; do
+ IFS="$lt_save_ifs"
+ if test "X$pkg" = "X$p"; then
+ enable_shared=yes
+ fi
+ done
+ IFS="$lt_save_ifs"
+ ;;
+ esac
+else
+ enable_shared=yes
+fi
+
+
+
+
+
+
+
+
+
+ # Check whether --enable-static was given.
+if test "${enable_static+set}" = set; then :
+ enableval=$enable_static; p=${PACKAGE-default}
+ case $enableval in
+ yes) enable_static=yes ;;
+ no) enable_static=no ;;
+ *)
+ enable_static=no
+ # Look at the argument we got. We use all the common list separators.
+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ for pkg in $enableval; do
+ IFS="$lt_save_ifs"
+ if test "X$pkg" = "X$p"; then
+ enable_static=yes
+ fi
+ done
+ IFS="$lt_save_ifs"
+ ;;
+ esac
+else
+ enable_static=yes
+fi
+
+
+
+
+
+
+
+
+
+
+# Check whether --with-pic was given.
+if test "${with_pic+set}" = set; then :
+ withval=$with_pic; lt_p=${PACKAGE-default}
+ case $withval in
+ yes|no) pic_mode=$withval ;;
+ *)
+ pic_mode=default
+ # Look at the argument we got. We use all the common list separators.
+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ for lt_pkg in $withval; do
+ IFS="$lt_save_ifs"
+ if test "X$lt_pkg" = "X$lt_p"; then
+ pic_mode=yes
+ fi
+ done
+ IFS="$lt_save_ifs"
+ ;;
+ esac
+else
+ pic_mode=default
+fi
+
+
+test -z "$pic_mode" && pic_mode=default
+
+
+
+
+
+
+
+ # Check whether --enable-fast-install was given.
+if test "${enable_fast_install+set}" = set; then :
+ enableval=$enable_fast_install; p=${PACKAGE-default}
+ case $enableval in
+ yes) enable_fast_install=yes ;;
+ no) enable_fast_install=no ;;
+ *)
+ enable_fast_install=no
+ # Look at the argument we got. We use all the common list separators.
+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ for pkg in $enableval; do
+ IFS="$lt_save_ifs"
+ if test "X$pkg" = "X$p"; then
+ enable_fast_install=yes
+ fi
+ done
+ IFS="$lt_save_ifs"
+ ;;
+ esac
+else
+ enable_fast_install=yes
+fi
+
+
+
+
+
+
+
+
+
+
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ltmain"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+test -z "$LN_S" && LN_S="ln -s"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+if test -n "${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5
+$as_echo_n "checking for objdir... " >&6; }
+if ${lt_cv_objdir+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+ lt_cv_objdir=.libs
+else
+ # MS-DOS does not allow filenames that begin with a dot.
+ lt_cv_objdir=_libs
+fi
+rmdir .libs 2>/dev/null
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5
+$as_echo "$lt_cv_objdir" >&6; }
+objdir=$lt_cv_objdir
+
+
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define LT_OBJDIR "$lt_cv_objdir/"
+_ACEOF
+
+
+
+
+case $host_os in
+aix3*)
+ # AIX sometimes has problems with the GCC collect2 program. For some
+ # reason, if we set the COLLECT_NAMES environment variable, the problems
+ # vanish in a puff of smoke.
+ if test "X${COLLECT_NAMES+set}" != Xset; then
+ COLLECT_NAMES=
+ export COLLECT_NAMES
+ fi
+ ;;
+esac
+
+# Global variables:
+ofile=libtool
+can_build_shared=yes
+
+# All known linkers require a `.a' archive for static linking (except MSVC,
+# which needs '.lib').
+libext=a
+
+with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+old_CC="$CC"
+old_CFLAGS="$CFLAGS"
+
+# Set sane defaults for various variables
+test -z "$CC" && CC=cc
+test -z "$LTCC" && LTCC=$CC
+test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
+test -z "$LD" && LD=ld
+test -z "$ac_objext" && ac_objext=o
+
+for cc_temp in $compiler""; do
+ case $cc_temp in
+ compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+ distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+ \-*) ;;
+ *) break;;
+ esac
+done
+cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+
+
+# Only perform the check for file, if the check method requires it
+test -z "$MAGIC_CMD" && MAGIC_CMD=file
+case $deplibs_check_method in
+file_magic*)
+ if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5
+$as_echo_n "checking for ${ac_tool_prefix}file... " >&6; }
+if ${lt_cv_path_MAGIC_CMD+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $MAGIC_CMD in
+[\\/*] | ?:[\\/]*)
+ lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+ ;;
+*)
+ lt_save_MAGIC_CMD="$MAGIC_CMD"
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
+ for ac_dir in $ac_dummy; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/${ac_tool_prefix}file; then
+ lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file"
+ if test -n "$file_magic_test_file"; then
+ case $deplibs_check_method in
+ "file_magic "*)
+ file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+ MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+ if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+ $EGREP "$file_magic_regex" > /dev/null; then
+ :
+ else
+ cat <<_LT_EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such. This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem. Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+_LT_EOF
+ fi ;;
+ esac
+ fi
+ break
+ fi
+ done
+ IFS="$lt_save_ifs"
+ MAGIC_CMD="$lt_save_MAGIC_CMD"
+ ;;
+esac
+fi
+
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
+$as_echo "$MAGIC_CMD" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+
+
+
+if test -z "$lt_cv_path_MAGIC_CMD"; then
+ if test -n "$ac_tool_prefix"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5
+$as_echo_n "checking for file... " >&6; }
+if ${lt_cv_path_MAGIC_CMD+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $MAGIC_CMD in
+[\\/*] | ?:[\\/]*)
+ lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+ ;;
+*)
+ lt_save_MAGIC_CMD="$MAGIC_CMD"
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
+ for ac_dir in $ac_dummy; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/file; then
+ lt_cv_path_MAGIC_CMD="$ac_dir/file"
+ if test -n "$file_magic_test_file"; then
+ case $deplibs_check_method in
+ "file_magic "*)
+ file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+ MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+ if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+ $EGREP "$file_magic_regex" > /dev/null; then
+ :
+ else
+ cat <<_LT_EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such. This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem. Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+_LT_EOF
+ fi ;;
+ esac
+ fi
+ break
+ fi
+ done
+ IFS="$lt_save_ifs"
+ MAGIC_CMD="$lt_save_MAGIC_CMD"
+ ;;
+esac
+fi
+
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
+$as_echo "$MAGIC_CMD" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ else
+ MAGIC_CMD=:
+ fi
+fi
+
+ fi
+ ;;
+esac
+
+# Use C for the default configuration in the libtool script
+
+lt_save_CC="$CC"
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+# Source file extension for C test sources.
+ac_ext=c
+
+# Object file extension for compiled C test sources.
+objext=o
+objext=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(){return(0);}'
+
+
+
+
+
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+# Save the default compiler, since it gets overwritten when the other
+# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
+compiler_DEFAULT=$CC
+
+# save warnings/boilerplate of simple test code
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$RM conftest*
+
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$RM -r conftest*
+
+
+## CAVEAT EMPTOR:
+## There is no encapsulation within the following macros, do not change
+## the running order or otherwise move them around unless you know exactly
+## what you are doing...
+if test -n "$compiler"; then
+
+lt_prog_compiler_no_builtin_flag=
+
+if test "$GCC" = yes; then
+ case $cc_basename in
+ nvcc*)
+ lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;;
+ *)
+ lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;;
+ esac
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
+$as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; }
+if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_rtti_exceptions=no
+ ac_outfile=conftest.$ac_objext
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+ lt_compiler_flag="-fno-rtti -fno-exceptions"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ # The option is referenced via a variable to avoid confusing sed.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>conftest.err)
+ ac_status=$?
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s "$ac_outfile"; then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings other than the usual output.
+ $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+ if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler_rtti_exceptions=yes
+ fi
+ fi
+ $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
+$as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; }
+
+if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
+ lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions"
+else
+ :
+fi
+
+fi
+
+
+
+
+
+
+ lt_prog_compiler_wl=
+lt_prog_compiler_pic=
+lt_prog_compiler_static=
+
+
+ if test "$GCC" = yes; then
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_static='-static'
+
+ case $host_os in
+ aix*)
+ # All AIX code is PIC.
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ lt_prog_compiler_static='-Bstatic'
+ fi
+ ;;
+
+ amigaos*)
+ case $host_cpu in
+ powerpc)
+ # see comment about AmigaOS4 .so support
+ lt_prog_compiler_pic='-fPIC'
+ ;;
+ m68k)
+ # FIXME: we need at least 68020 code to build shared libraries, but
+ # adding the `-m68020' flag to GCC prevents building anything better,
+ # like `-m68040'.
+ lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'
+ ;;
+ esac
+ ;;
+
+ beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+ # PIC is the default for these OSes.
+ ;;
+
+ mingw* | cygwin* | pw32* | os2* | cegcc*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ # Although the cygwin gcc ignores -fPIC, still need this for old-style
+ # (--disable-auto-import) libraries
+ lt_prog_compiler_pic='-DDLL_EXPORT'
+ ;;
+
+ darwin* | rhapsody*)
+ # PIC is the default on this platform
+ # Common symbols not allowed in MH_DYLIB files
+ lt_prog_compiler_pic='-fno-common'
+ ;;
+
+ haiku*)
+ # PIC is the default for Haiku.
+ # The "-static" flag exists, but is broken.
+ lt_prog_compiler_static=
+ ;;
+
+ hpux*)
+ # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
+ # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag
+ # sets the default TLS model and affects inlining.
+ case $host_cpu in
+ hppa*64*)
+ # +Z the default
+ ;;
+ *)
+ lt_prog_compiler_pic='-fPIC'
+ ;;
+ esac
+ ;;
+
+ interix[3-9]*)
+ # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+ # Instead, we relocate shared libraries at runtime.
+ ;;
+
+ msdosdjgpp*)
+ # Just because we use GCC doesn't mean we suddenly get shared libraries
+ # on systems that don't support them.
+ lt_prog_compiler_can_build_shared=no
+ enable_shared=no
+ ;;
+
+ *nto* | *qnx*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ lt_prog_compiler_pic='-fPIC -shared'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ lt_prog_compiler_pic=-Kconform_pic
+ fi
+ ;;
+
+ *)
+ lt_prog_compiler_pic='-fPIC'
+ ;;
+ esac
+
+ case $cc_basename in
+ nvcc*) # Cuda Compiler Driver 2.2
+ lt_prog_compiler_wl='-Xlinker '
+ if test -n "$lt_prog_compiler_pic"; then
+ lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic"
+ fi
+ ;;
+ esac
+ else
+ # PORTME Check for flag to pass linker flags through the system compiler.
+ case $host_os in
+ aix*)
+ lt_prog_compiler_wl='-Wl,'
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ lt_prog_compiler_static='-Bstatic'
+ else
+ lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp'
+ fi
+ ;;
+
+ mingw* | cygwin* | pw32* | os2* | cegcc*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ lt_prog_compiler_pic='-DDLL_EXPORT'
+ ;;
+
+ hpux9* | hpux10* | hpux11*)
+ lt_prog_compiler_wl='-Wl,'
+ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+ # not for PA HP-UX.
+ case $host_cpu in
+ hppa*64*|ia64*)
+ # +Z the default
+ ;;
+ *)
+ lt_prog_compiler_pic='+Z'
+ ;;
+ esac
+ # Is there a better lt_prog_compiler_static that works with the bundled CC?
+ lt_prog_compiler_static='${wl}-a ${wl}archive'
+ ;;
+
+ irix5* | irix6* | nonstopux*)
+ lt_prog_compiler_wl='-Wl,'
+ # PIC (with -KPIC) is the default.
+ lt_prog_compiler_static='-non_shared'
+ ;;
+
+ linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ case $cc_basename in
+ # old Intel for x86_64 which still supported -KPIC.
+ ecc*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-static'
+ ;;
+ # icc used to be incompatible with GCC.
+ # ICC 10 doesn't accept -KPIC any more.
+ icc* | ifort*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-fPIC'
+ lt_prog_compiler_static='-static'
+ ;;
+ # Lahey Fortran 8.1.
+ lf95*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='--shared'
+ lt_prog_compiler_static='--static'
+ ;;
+ nagfor*)
+ # NAG Fortran compiler
+ lt_prog_compiler_wl='-Wl,-Wl,,'
+ lt_prog_compiler_pic='-PIC'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+ pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
+ # Portland Group compilers (*not* the Pentium gcc compiler,
+ # which looks to be a dead project)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-fpic'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+ ccc*)
+ lt_prog_compiler_wl='-Wl,'
+ # All Alpha code is PIC.
+ lt_prog_compiler_static='-non_shared'
+ ;;
+ xl* | bgxl* | bgf* | mpixl*)
+ # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-qpic'
+ lt_prog_compiler_static='-qstaticlink'
+ ;;
+ *)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*)
+ # Sun Fortran 8.3 passes all unrecognized flags to the linker
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ lt_prog_compiler_wl=''
+ ;;
+ *Sun\ F* | *Sun*Fortran*)
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ lt_prog_compiler_wl='-Qoption ld '
+ ;;
+ *Sun\ C*)
+ # Sun C 5.9
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ lt_prog_compiler_wl='-Wl,'
+ ;;
+ *Intel*\ [CF]*Compiler*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-fPIC'
+ lt_prog_compiler_static='-static'
+ ;;
+ *Portland\ Group*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-fpic'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+
+ newsos6)
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+
+ *nto* | *qnx*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ lt_prog_compiler_pic='-fPIC -shared'
+ ;;
+
+ osf3* | osf4* | osf5*)
+ lt_prog_compiler_wl='-Wl,'
+ # All OSF/1 code is PIC.
+ lt_prog_compiler_static='-non_shared'
+ ;;
+
+ rdos*)
+ lt_prog_compiler_static='-non_shared'
+ ;;
+
+ solaris*)
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ case $cc_basename in
+ f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)
+ lt_prog_compiler_wl='-Qoption ld ';;
+ *)
+ lt_prog_compiler_wl='-Wl,';;
+ esac
+ ;;
+
+ sunos4*)
+ lt_prog_compiler_wl='-Qoption ld '
+ lt_prog_compiler_pic='-PIC'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+
+ sysv4 | sysv4.2uw2* | sysv4.3*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec ;then
+ lt_prog_compiler_pic='-Kconform_pic'
+ lt_prog_compiler_static='-Bstatic'
+ fi
+ ;;
+
+ sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+
+ unicos*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_can_build_shared=no
+ ;;
+
+ uts4*)
+ lt_prog_compiler_pic='-pic'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+
+ *)
+ lt_prog_compiler_can_build_shared=no
+ ;;
+ esac
+ fi
+
+case $host_os in
+ # For platforms which do not support PIC, -DPIC is meaningless:
+ *djgpp*)
+ lt_prog_compiler_pic=
+ ;;
+ *)
+ lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC"
+ ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5
+$as_echo_n "checking for $compiler option to produce PIC... " >&6; }
+if ${lt_cv_prog_compiler_pic+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_pic=$lt_prog_compiler_pic
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5
+$as_echo "$lt_cv_prog_compiler_pic" >&6; }
+lt_prog_compiler_pic=$lt_cv_prog_compiler_pic
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
+$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; }
+if ${lt_cv_prog_compiler_pic_works+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_pic_works=no
+ ac_outfile=conftest.$ac_objext
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+ lt_compiler_flag="$lt_prog_compiler_pic -DPIC"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ # The option is referenced via a variable to avoid confusing sed.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>conftest.err)
+ ac_status=$?
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s "$ac_outfile"; then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings other than the usual output.
+ $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+ if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler_pic_works=yes
+ fi
+ fi
+ $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5
+$as_echo "$lt_cv_prog_compiler_pic_works" >&6; }
+
+if test x"$lt_cv_prog_compiler_pic_works" = xyes; then
+ case $lt_prog_compiler_pic in
+ "" | " "*) ;;
+ *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;
+ esac
+else
+ lt_prog_compiler_pic=
+ lt_prog_compiler_can_build_shared=no
+fi
+
+fi
+
+
+
+
+
+
+
+
+
+
+
+#
+# Check to make sure the static flag actually works.
+#
+wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5
+$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
+if ${lt_cv_prog_compiler_static_works+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_static_works=no
+ save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
+ echo "$lt_simple_link_test_code" > conftest.$ac_ext
+ if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+ # The linker can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ if test -s conftest.err; then
+ # Append any errors to the config.log.
+ cat conftest.err 1>&5
+ $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+ if diff conftest.exp conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler_static_works=yes
+ fi
+ else
+ lt_cv_prog_compiler_static_works=yes
+ fi
+ fi
+ $RM -r conftest*
+ LDFLAGS="$save_LDFLAGS"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5
+$as_echo "$lt_cv_prog_compiler_static_works" >&6; }
+
+if test x"$lt_cv_prog_compiler_static_works" = xyes; then
+ :
+else
+ lt_prog_compiler_static=
+fi
+
+
+
+
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if ${lt_cv_prog_compiler_c_o+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_c_o=no
+ $RM -r conftest 2>/dev/null
+ mkdir conftest
+ cd conftest
+ mkdir out
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ lt_compiler_flag="-o out/conftest2.$ac_objext"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>out/conftest.err)
+ ac_status=$?
+ cat out/conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s out/conftest2.$ac_objext
+ then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
+ $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+ if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler_c_o=yes
+ fi
+ fi
+ chmod u+w . 2>&5
+ $RM conftest*
+ # SGI C++ compiler will create directory out/ii_files/ for
+ # template instantiation
+ test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+ $RM out/* && rmdir out
+ cd ..
+ $RM -r conftest
+ $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
+$as_echo "$lt_cv_prog_compiler_c_o" >&6; }
+
+
+
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if ${lt_cv_prog_compiler_c_o+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_c_o=no
+ $RM -r conftest 2>/dev/null
+ mkdir conftest
+ cd conftest
+ mkdir out
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ lt_compiler_flag="-o out/conftest2.$ac_objext"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>out/conftest.err)
+ ac_status=$?
+ cat out/conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s out/conftest2.$ac_objext
+ then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
+ $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+ if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler_c_o=yes
+ fi
+ fi
+ chmod u+w . 2>&5
+ $RM conftest*
+ # SGI C++ compiler will create directory out/ii_files/ for
+ # template instantiation
+ test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+ $RM out/* && rmdir out
+ cd ..
+ $RM -r conftest
+ $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
+$as_echo "$lt_cv_prog_compiler_c_o" >&6; }
+
+
+
+
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then
+ # do not overwrite the value of need_locks provided by the user
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
+$as_echo_n "checking if we can lock with hard links... " >&6; }
+ hard_links=yes
+ $RM conftest*
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ touch conftest.a
+ ln conftest.a conftest.b 2>&5 || hard_links=no
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
+$as_echo "$hard_links" >&6; }
+ if test "$hard_links" = no; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
+$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+ need_locks=warn
+ fi
+else
+ need_locks=no
+fi
+
+
+
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
+
+ runpath_var=
+ allow_undefined_flag=
+ always_export_symbols=no
+ archive_cmds=
+ archive_expsym_cmds=
+ compiler_needs_object=no
+ enable_shared_with_static_runtimes=no
+ export_dynamic_flag_spec=
+ export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ hardcode_automatic=no
+ hardcode_direct=no
+ hardcode_direct_absolute=no
+ hardcode_libdir_flag_spec=
+ hardcode_libdir_separator=
+ hardcode_minus_L=no
+ hardcode_shlibpath_var=unsupported
+ inherit_rpath=no
+ link_all_deplibs=unknown
+ module_cmds=
+ module_expsym_cmds=
+ old_archive_from_new_cmds=
+ old_archive_from_expsyms_cmds=
+ thread_safe_flag_spec=
+ whole_archive_flag_spec=
+ # include_expsyms should be a list of space-separated symbols to be *always*
+ # included in the symbol list
+ include_expsyms=
+ # exclude_expsyms can be an extended regexp of symbols to exclude
+ # it will be wrapped by ` (' and `)$', so one must not match beginning or
+ # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+ # as well as any symbol that contains `d'.
+ exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
+ # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+ # platforms (ab)use it in PIC code, but their linkers get confused if
+ # the symbol is explicitly referenced. Since portable code cannot
+ # rely on this symbol name, it's probably fine to never include it in
+ # preloaded symbol tables.
+ # Exclude shared library initialization/finalization symbols.
+ extract_expsyms_cmds=
+
+ case $host_os in
+ cygwin* | mingw* | pw32* | cegcc*)
+ # FIXME: the MSVC++ port hasn't been tested in a loooong time
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ if test "$GCC" != yes; then
+ with_gnu_ld=no
+ fi
+ ;;
+ interix*)
+ # we just hope/assume this is gcc and not c89 (= MSVC++)
+ with_gnu_ld=yes
+ ;;
+ openbsd*)
+ with_gnu_ld=no
+ ;;
+ linux* | k*bsd*-gnu | gnu*)
+ link_all_deplibs=no
+ ;;
+ esac
+
+ ld_shlibs=yes
+
+ # On some targets, GNU ld is compatible enough with the native linker
+ # that we're better off using the native interface for both.
+ lt_use_gnu_ld_interface=no
+ if test "$with_gnu_ld" = yes; then
+ case $host_os in
+ aix*)
+ # The AIX port of GNU ld has always aspired to compatibility
+ # with the native linker. However, as the warning in the GNU ld
+ # block says, versions before 2.19.5* couldn't really create working
+ # shared libraries, regardless of the interface used.
+ case `$LD -v 2>&1` in
+ *\ \(GNU\ Binutils\)\ 2.19.5*) ;;
+ *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;;
+ *\ \(GNU\ Binutils\)\ [3-9]*) ;;
+ *)
+ lt_use_gnu_ld_interface=yes
+ ;;
+ esac
+ ;;
+ *)
+ lt_use_gnu_ld_interface=yes
+ ;;
+ esac
+ fi
+
+ if test "$lt_use_gnu_ld_interface" = yes; then
+ # If archive_cmds runs LD, not CC, wlarc should be empty
+ wlarc='${wl}'
+
+ # Set some defaults for GNU ld with shared library support. These
+ # are reset later if shared libraries are not supported. Putting them
+ # here allows them to be overridden if necessary.
+ runpath_var=LD_RUN_PATH
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ export_dynamic_flag_spec='${wl}--export-dynamic'
+ # ancient GNU ld didn't support --whole-archive et. al.
+ if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
+ whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ else
+ whole_archive_flag_spec=
+ fi
+ supports_anon_versioning=no
+ case `$LD -v 2>&1` in
+ *GNU\ gold*) supports_anon_versioning=yes ;;
+ *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+ *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+ *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+ *\ 2.11.*) ;; # other 2.11 versions
+ *) supports_anon_versioning=yes ;;
+ esac
+
+ # See if GNU ld supports shared libraries.
+ case $host_os in
+ aix[3-9]*)
+ # On AIX/PPC, the GNU linker is very broken
+ if test "$host_cpu" != ia64; then
+ ld_shlibs=no
+ cat <<_LT_EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.19, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support. If you
+*** really care for shared libraries, you may want to install binutils
+*** 2.20 or above, or modify your PATH so that a non-GNU linker is found.
+*** You will then need to restart the configuration process.
+
+_LT_EOF
+ fi
+ ;;
+
+ amigaos*)
+ case $host_cpu in
+ powerpc)
+ # see comment about AmigaOS4 .so support
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds=''
+ ;;
+ m68k)
+ archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_minus_L=yes
+ ;;
+ esac
+ ;;
+
+ beos*)
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ allow_undefined_flag=unsupported
+ # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+ # support --undefined. This deserves some investigation. FIXME
+ archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+
+ cygwin* | mingw* | pw32* | cegcc*)
+ # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
+ # as there is no search path for DLLs.
+ hardcode_libdir_flag_spec='-L$libdir'
+ export_dynamic_flag_spec='${wl}--export-all-symbols'
+ allow_undefined_flag=unsupported
+ always_export_symbols=no
+ enable_shared_with_static_runtimes=yes
+ export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols'
+ exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'
+
+ if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ # If the export-symbols file already is a .def file (1st line
+ # is EXPORTS), use it as is; otherwise, prepend...
+ archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+ cp $export_symbols $output_objdir/$soname.def;
+ else
+ echo EXPORTS > $output_objdir/$soname.def;
+ cat $export_symbols >> $output_objdir/$soname.def;
+ fi~
+ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+
+ haiku*)
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ link_all_deplibs=yes
+ ;;
+
+ interix[3-9]*)
+ hardcode_direct=no
+ hardcode_shlibpath_var=no
+ hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+ export_dynamic_flag_spec='${wl}-E'
+ # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+ # Instead, shared libraries are loaded at an image base (0x10000000 by
+ # default) and relocated if they conflict, which is a slow very memory
+ # consuming and fragmenting process. To avoid this, we pick a random,
+ # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+ # time. Moving up from 0x10000000 also allows more sbrk(2) space.
+ archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ ;;
+
+ gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
+ tmp_diet=no
+ if test "$host_os" = linux-dietlibc; then
+ case $cc_basename in
+ diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn)
+ esac
+ fi
+ if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
+ && test "$tmp_diet" = no
+ then
+ tmp_addflag=' $pic_flag'
+ tmp_sharedflag='-shared'
+ case $cc_basename,$host_cpu in
+ pgcc*) # Portland Group C compiler
+ whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+ tmp_addflag=' $pic_flag'
+ ;;
+ pgf77* | pgf90* | pgf95* | pgfortran*)
+ # Portland Group f77 and f90 compilers
+ whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+ tmp_addflag=' $pic_flag -Mnomain' ;;
+ ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
+ tmp_addflag=' -i_dynamic' ;;
+ efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
+ tmp_addflag=' -i_dynamic -nofor_main' ;;
+ ifc* | ifort*) # Intel Fortran compiler
+ tmp_addflag=' -nofor_main' ;;
+ lf95*) # Lahey Fortran 8.1
+ whole_archive_flag_spec=
+ tmp_sharedflag='--shared' ;;
+ xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below)
+ tmp_sharedflag='-qmkshrobj'
+ tmp_addflag= ;;
+ nvcc*) # Cuda Compiler Driver 2.2
+ whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+ compiler_needs_object=yes
+ ;;
+ esac
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*) # Sun C 5.9
+ whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+ compiler_needs_object=yes
+ tmp_sharedflag='-G' ;;
+ *Sun\ F*) # Sun Fortran 8.3
+ tmp_sharedflag='-G' ;;
+ esac
+ archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+ if test "x$supports_anon_versioning" = xyes; then
+ archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
+ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+ echo "local: *; };" >> $output_objdir/$libname.ver~
+ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+ fi
+
+ case $cc_basename in
+ xlf* | bgf* | bgxlf* | mpixlf*)
+ # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
+ whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive'
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
+ if test "x$supports_anon_versioning" = xyes; then
+ archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
+ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+ echo "local: *; };" >> $output_objdir/$libname.ver~
+ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+ fi
+ ;;
+ esac
+ else
+ ld_shlibs=no
+ fi
+ ;;
+
+ netbsd* | netbsdelf*-gnu)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+ wlarc=
+ else
+ archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ fi
+ ;;
+
+ solaris*)
+ if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
+ ld_shlibs=no
+ cat <<_LT_EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems. Therefore, libtool
+*** is disabling shared libraries support. We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer. Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+ elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+
+ sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+ case `$LD -v 2>&1` in
+ *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
+ ld_shlibs=no
+ cat <<_LT_EOF 1>&2
+
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** reliably create shared libraries on SCO systems. Therefore, libtool
+*** is disabling shared libraries support. We urge you to upgrade GNU
+*** binutils to release 2.16.91.0.3 or newer. Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+ ;;
+ *)
+ # For security reasons, it is highly recommended that you always
+ # use absolute paths for naming shared libraries, and exclude the
+ # DT_RUNPATH tag from executables and libraries. But doing so
+ # requires that you compile everything twice, which is a pain.
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+ esac
+ ;;
+
+ sunos4*)
+ archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ wlarc=
+ hardcode_direct=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ *)
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+ esac
+
+ if test "$ld_shlibs" = no; then
+ runpath_var=
+ hardcode_libdir_flag_spec=
+ export_dynamic_flag_spec=
+ whole_archive_flag_spec=
+ fi
+ else
+ # PORTME fill in a description of your system's linker (not GNU ld)
+ case $host_os in
+ aix3*)
+ allow_undefined_flag=unsupported
+ always_export_symbols=yes
+ archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+ # Note: this linker hardcodes the directories in LIBPATH if there
+ # are no directories specified by -L.
+ hardcode_minus_L=yes
+ if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+ # Neither direct hardcoding nor static linking is supported with a
+ # broken collect2.
+ hardcode_direct=unsupported
+ fi
+ ;;
+
+ aix[4-9]*)
+ if test "$host_cpu" = ia64; then
+ # On IA64, the linker does run time linking by default, so we don't
+ # have to do anything special.
+ aix_use_runtimelinking=no
+ exp_sym_flag='-Bexport'
+ no_entry_flag=""
+ else
+ # If we're using GNU nm, then we don't want the "-C" option.
+ # -C means demangle to AIX nm, but means don't demangle with GNU nm
+ # Also, AIX nm treats weak defined symbols like other global
+ # defined symbols, whereas GNU nm marks them as "W".
+ if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+ export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ else
+ export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ fi
+ aix_use_runtimelinking=no
+
+ # Test if we are trying to use run time linking or normal
+ # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+ # need to do runtime linking.
+ case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
+ for ld_flag in $LDFLAGS; do
+ if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+ aix_use_runtimelinking=yes
+ break
+ fi
+ done
+ ;;
+ esac
+
+ exp_sym_flag='-bexport'
+ no_entry_flag='-bnoentry'
+ fi
+
+ # When large executables or shared objects are built, AIX ld can
+ # have problems creating the table of contents. If linking a library
+ # or program results in "error TOC overflow" add -mminimal-toc to
+ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
+ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+ archive_cmds=''
+ hardcode_direct=yes
+ hardcode_direct_absolute=yes
+ hardcode_libdir_separator=':'
+ link_all_deplibs=yes
+ file_list_spec='${wl}-f,'
+
+ if test "$GCC" = yes; then
+ case $host_os in aix4.[012]|aix4.[012].*)
+ # We only want to do this on AIX 4.2 and lower, the check
+ # below for broken collect2 doesn't work under 4.3+
+ collect2name=`${CC} -print-prog-name=collect2`
+ if test -f "$collect2name" &&
+ strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+ then
+ # We have reworked collect2
+ :
+ else
+ # We have old collect2
+ hardcode_direct=unsupported
+ # It fails to find uninstalled libraries when the uninstalled
+ # path is not listed in the libpath. Setting hardcode_minus_L
+ # to unsupported forces relinking
+ hardcode_minus_L=yes
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_libdir_separator=
+ fi
+ ;;
+ esac
+ shared_flag='-shared'
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag="$shared_flag "'${wl}-G'
+ fi
+ link_all_deplibs=no
+ else
+ # not using gcc
+ if test "$host_cpu" = ia64; then
+ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+ # chokes on -Wl,-G. The following line is correct:
+ shared_flag='-G'
+ else
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag='${wl}-G'
+ else
+ shared_flag='${wl}-bM:SRE'
+ fi
+ fi
+ fi
+
+ export_dynamic_flag_spec='${wl}-bexpall'
+ # It seems that -bexpall does not export symbols beginning with
+ # underscore (_), so it is better to generate a list of symbols to export.
+ always_export_symbols=yes
+ if test "$aix_use_runtimelinking" = yes; then
+ # Warning - without using the other runtime loading flags (-brtl),
+ # -berok will link without error, but may produce a broken library.
+ allow_undefined_flag='-berok'
+ # Determine the default libpath from the value encoded in an
+ # empty executable.
+ if test "${lt_cv_aix_libpath+set}" = set; then
+ aix_libpath=$lt_cv_aix_libpath
+else
+ if ${lt_cv_aix_libpath_+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+ lt_aix_libpath_sed='
+ /Import File Strings/,/^$/ {
+ /^0/ {
+ s/^0 *\([^ ]*\) *$/\1/
+ p
+ }
+ }'
+ lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+ # Check for a 64-bit object if we didn't find anything.
+ if test -z "$lt_cv_aix_libpath_"; then
+ lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+ fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ if test -z "$lt_cv_aix_libpath_"; then
+ lt_cv_aix_libpath_="/usr/lib:/lib"
+ fi
+
+fi
+
+ aix_libpath=$lt_cv_aix_libpath_
+fi
+
+ hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+ archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+ else
+ if test "$host_cpu" = ia64; then
+ hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
+ allow_undefined_flag="-z nodefs"
+ archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+ else
+ # Determine the default libpath from the value encoded in an
+ # empty executable.
+ if test "${lt_cv_aix_libpath+set}" = set; then
+ aix_libpath=$lt_cv_aix_libpath
+else
+ if ${lt_cv_aix_libpath_+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+ lt_aix_libpath_sed='
+ /Import File Strings/,/^$/ {
+ /^0/ {
+ s/^0 *\([^ ]*\) *$/\1/
+ p
+ }
+ }'
+ lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+ # Check for a 64-bit object if we didn't find anything.
+ if test -z "$lt_cv_aix_libpath_"; then
+ lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+ fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ if test -z "$lt_cv_aix_libpath_"; then
+ lt_cv_aix_libpath_="/usr/lib:/lib"
+ fi
+
+fi
+
+ aix_libpath=$lt_cv_aix_libpath_
+fi
+
+ hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+ # Warning - without using the other run time loading flags,
+ # -berok will link without error, but may produce a broken library.
+ no_undefined_flag=' ${wl}-bernotok'
+ allow_undefined_flag=' ${wl}-berok'
+ if test "$with_gnu_ld" = yes; then
+ # We only use this code for GNU lds that support --whole-archive.
+ whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+ else
+ # Exported symbols can be pulled into shared objects from archives
+ whole_archive_flag_spec='$convenience'
+ fi
+ archive_cmds_need_lc=yes
+ # This is similar to how AIX traditionally builds its shared libraries.
+ archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+ fi
+ fi
+ ;;
+
+ amigaos*)
+ case $host_cpu in
+ powerpc)
+ # see comment about AmigaOS4 .so support
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds=''
+ ;;
+ m68k)
+ archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_minus_L=yes
+ ;;
+ esac
+ ;;
+
+ bsdi[45]*)
+ export_dynamic_flag_spec=-rdynamic
+ ;;
+
+ cygwin* | mingw* | pw32* | cegcc*)
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ # hardcode_libdir_flag_spec is actually meaningless, as there is
+ # no search path for DLLs.
+ case $cc_basename in
+ cl*)
+ # Native MSVC
+ hardcode_libdir_flag_spec=' '
+ allow_undefined_flag=unsupported
+ always_export_symbols=yes
+ file_list_spec='@'
+ # Tell ltmain to make .lib files, not .a files.
+ libext=lib
+ # Tell ltmain to make .dll files, not .so files.
+ shrext_cmds=".dll"
+ # FIXME: Setting linknames here is a bad hack.
+ archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
+ archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+ sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
+ else
+ sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
+ fi~
+ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+ linknames='
+ # The linker will not automatically build a static lib if we build a DLL.
+ # _LT_TAGVAR(old_archive_from_new_cmds, )='true'
+ enable_shared_with_static_runtimes=yes
+ exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
+ export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols'
+ # Don't use ranlib
+ old_postinstall_cmds='chmod 644 $oldlib'
+ postlink_cmds='lt_outputfile="@OUTPUT@"~
+ lt_tool_outputfile="@TOOL_OUTPUT@"~
+ case $lt_outputfile in
+ *.exe|*.EXE) ;;
+ *)
+ lt_outputfile="$lt_outputfile.exe"
+ lt_tool_outputfile="$lt_tool_outputfile.exe"
+ ;;
+ esac~
+ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
+ $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+ $RM "$lt_outputfile.manifest";
+ fi'
+ ;;
+ *)
+ # Assume MSVC wrapper
+ hardcode_libdir_flag_spec=' '
+ allow_undefined_flag=unsupported
+ # Tell ltmain to make .lib files, not .a files.
+ libext=lib
+ # Tell ltmain to make .dll files, not .so files.
+ shrext_cmds=".dll"
+ # FIXME: Setting linknames here is a bad hack.
+ archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='
+ # The linker will automatically build a .lib file if we build a DLL.
+ old_archive_from_new_cmds='true'
+ # FIXME: Should let the user specify the lib program.
+ old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs'
+ enable_shared_with_static_runtimes=yes
+ ;;
+ esac
+ ;;
+
+ darwin* | rhapsody*)
+
+
+ archive_cmds_need_lc=no
+ hardcode_direct=no
+ hardcode_automatic=yes
+ hardcode_shlibpath_var=unsupported
+ if test "$lt_cv_ld_force_load" = "yes"; then
+ whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
+
+ else
+ whole_archive_flag_spec=''
+ fi
+ link_all_deplibs=yes
+ allow_undefined_flag="$_lt_dar_allow_undefined"
+ case $cc_basename in
+ ifort*) _lt_dar_can_shared=yes ;;
+ *) _lt_dar_can_shared=$GCC ;;
+ esac
+ if test "$_lt_dar_can_shared" = "yes"; then
+ output_verbose_link_cmd=func_echo_all
+ archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+ module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+ archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+ module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+
+ else
+ ld_shlibs=no
+ fi
+
+ ;;
+
+ dgux*)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_shlibpath_var=no
+ ;;
+
+ # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+ # support. Future versions do this automatically, but an explicit c++rt0.o
+ # does not break anything, and helps significantly (at the cost of a little
+ # extra space).
+ freebsd2.2*)
+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_direct=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+ freebsd2.*)
+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct=yes
+ hardcode_minus_L=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+ freebsd* | dragonfly*)
+ archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_direct=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ hpux9*)
+ if test "$GCC" = yes; then
+ archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ else
+ archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ fi
+ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator=:
+ hardcode_direct=yes
+
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L=yes
+ export_dynamic_flag_spec='${wl}-E'
+ ;;
+
+ hpux10*)
+ if test "$GCC" = yes && test "$with_gnu_ld" = no; then
+ archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+ fi
+ if test "$with_gnu_ld" = no; then
+ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator=:
+ hardcode_direct=yes
+ hardcode_direct_absolute=yes
+ export_dynamic_flag_spec='${wl}-E'
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L=yes
+ fi
+ ;;
+
+ hpux11*)
+ if test "$GCC" = yes && test "$with_gnu_ld" = no; then
+ case $host_cpu in
+ hppa*64*)
+ archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ ia64*)
+ archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ else
+ case $host_cpu in
+ hppa*64*)
+ archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ ia64*)
+ archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+
+ # Older versions of the 11.00 compiler do not understand -b yet
+ # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5
+$as_echo_n "checking if $CC understands -b... " >&6; }
+if ${lt_cv_prog_compiler__b+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler__b=no
+ save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -b"
+ echo "$lt_simple_link_test_code" > conftest.$ac_ext
+ if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+ # The linker can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ if test -s conftest.err; then
+ # Append any errors to the config.log.
+ cat conftest.err 1>&5
+ $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+ if diff conftest.exp conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler__b=yes
+ fi
+ else
+ lt_cv_prog_compiler__b=yes
+ fi
+ fi
+ $RM -r conftest*
+ LDFLAGS="$save_LDFLAGS"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5
+$as_echo "$lt_cv_prog_compiler__b" >&6; }
+
+if test x"$lt_cv_prog_compiler__b" = xyes; then
+ archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+else
+ archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+fi
+
+ ;;
+ esac
+ fi
+ if test "$with_gnu_ld" = no; then
+ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator=:
+
+ case $host_cpu in
+ hppa*64*|ia64*)
+ hardcode_direct=no
+ hardcode_shlibpath_var=no
+ ;;
+ *)
+ hardcode_direct=yes
+ hardcode_direct_absolute=yes
+ export_dynamic_flag_spec='${wl}-E'
+
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L=yes
+ ;;
+ esac
+ fi
+ ;;
+
+ irix5* | irix6* | nonstopux*)
+ if test "$GCC" = yes; then
+ archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ # Try to use the -exported_symbol ld option, if it does not
+ # work, assume that -exports_file does not work either and
+ # implicitly export all symbols.
+ # This should be the same for all languages, so no per-tag cache variable.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5
+$as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; }
+if ${lt_cv_irix_exported_symbol+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+int foo (void) { return 0; }
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ lt_cv_irix_exported_symbol=yes
+else
+ lt_cv_irix_exported_symbol=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ LDFLAGS="$save_LDFLAGS"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5
+$as_echo "$lt_cv_irix_exported_symbol" >&6; }
+ if test "$lt_cv_irix_exported_symbol" = yes; then
+ archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
+ fi
+ else
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+ archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+ fi
+ archive_cmds_need_lc='no'
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator=:
+ inherit_rpath=yes
+ link_all_deplibs=yes
+ ;;
+
+ netbsd* | netbsdelf*-gnu)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
+ else
+ archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
+ fi
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_direct=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ newsos6)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct=yes
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator=:
+ hardcode_shlibpath_var=no
+ ;;
+
+ *nto* | *qnx*)
+ ;;
+
+ openbsd*)
+ if test -f /usr/libexec/ld.so; then
+ hardcode_direct=yes
+ hardcode_shlibpath_var=no
+ hardcode_direct_absolute=yes
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+ hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+ export_dynamic_flag_spec='${wl}-E'
+ else
+ case $host_os in
+ openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_libdir_flag_spec='-R$libdir'
+ ;;
+ *)
+ archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+ ;;
+ esac
+ fi
+ else
+ ld_shlibs=no
+ fi
+ ;;
+
+ os2*)
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_minus_L=yes
+ allow_undefined_flag=unsupported
+ archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+ old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+ ;;
+
+ osf3*)
+ if test "$GCC" = yes; then
+ allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+ archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ else
+ allow_undefined_flag=' -expect_unresolved \*'
+ archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+ fi
+ archive_cmds_need_lc='no'
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator=:
+ ;;
+
+ osf4* | osf5*) # as osf3* with the addition of -msym flag
+ if test "$GCC" = yes; then
+ allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+ archive_cmds='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ else
+ allow_undefined_flag=' -expect_unresolved \*'
+ archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+ archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
+ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+
+ # Both c and cxx compiler support -rpath directly
+ hardcode_libdir_flag_spec='-rpath $libdir'
+ fi
+ archive_cmds_need_lc='no'
+ hardcode_libdir_separator=:
+ ;;
+
+ solaris*)
+ no_undefined_flag=' -z defs'
+ if test "$GCC" = yes; then
+ wlarc='${wl}'
+ archive_cmds='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+ else
+ case `$CC -V 2>&1` in
+ *"Compilers 5.0"*)
+ wlarc=''
+ archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+ ;;
+ *)
+ wlarc='${wl}'
+ archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+ ;;
+ esac
+ fi
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_shlibpath_var=no
+ case $host_os in
+ solaris2.[0-5] | solaris2.[0-5].*) ;;
+ *)
+ # The compiler driver will combine and reorder linker options,
+ # but understands `-z linker_flag'. GCC discards it without `$wl',
+ # but is careful enough not to reorder.
+ # Supported since Solaris 2.6 (maybe 2.5.1?)
+ if test "$GCC" = yes; then
+ whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+ else
+ whole_archive_flag_spec='-z allextract$convenience -z defaultextract'
+ fi
+ ;;
+ esac
+ link_all_deplibs=yes
+ ;;
+
+ sunos4*)
+ if test "x$host_vendor" = xsequent; then
+ # Use $CC to link under sequent, because it throws in some extra .o
+ # files that make .init and .fini sections work.
+ archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+ fi
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_direct=yes
+ hardcode_minus_L=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ sysv4)
+ case $host_vendor in
+ sni)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct=yes # is this really true???
+ ;;
+ siemens)
+ ## LD is ld it makes a PLAMLIB
+ ## CC just makes a GrossModule.
+ archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+ reload_cmds='$CC -r -o $output$reload_objs'
+ hardcode_direct=no
+ ;;
+ motorola)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct=no #Motorola manual says yes, but my tests say they lie
+ ;;
+ esac
+ runpath_var='LD_RUN_PATH'
+ hardcode_shlibpath_var=no
+ ;;
+
+ sysv4.3*)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_shlibpath_var=no
+ export_dynamic_flag_spec='-Bexport'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_shlibpath_var=no
+ runpath_var=LD_RUN_PATH
+ hardcode_runpath_var=yes
+ ld_shlibs=yes
+ fi
+ ;;
+
+ sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
+ no_undefined_flag='${wl}-z,text'
+ archive_cmds_need_lc=no
+ hardcode_shlibpath_var=no
+ runpath_var='LD_RUN_PATH'
+
+ if test "$GCC" = yes; then
+ archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ fi
+ ;;
+
+ sysv5* | sco3.2v5* | sco5v6*)
+ # Note: We can NOT use -z defs as we might desire, because we do not
+ # link with -lc, and that would cause any symbols used from libc to
+ # always be unresolved, which means just about no library would
+ # ever link correctly. If we're not using GNU ld we use -z text
+ # though, which does catch some bad symbols but isn't as heavy-handed
+ # as -z defs.
+ no_undefined_flag='${wl}-z,text'
+ allow_undefined_flag='${wl}-z,nodefs'
+ archive_cmds_need_lc=no
+ hardcode_shlibpath_var=no
+ hardcode_libdir_flag_spec='${wl}-R,$libdir'
+ hardcode_libdir_separator=':'
+ link_all_deplibs=yes
+ export_dynamic_flag_spec='${wl}-Bexport'
+ runpath_var='LD_RUN_PATH'
+
+ if test "$GCC" = yes; then
+ archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ fi
+ ;;
+
+ uts4*)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_shlibpath_var=no
+ ;;
+
+ *)
+ ld_shlibs=no
+ ;;
+ esac
+
+ if test x$host_vendor = xsni; then
+ case $host in
+ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+ export_dynamic_flag_spec='${wl}-Blargedynsym'
+ ;;
+ esac
+ fi
+ fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5
+$as_echo "$ld_shlibs" >&6; }
+test "$ld_shlibs" = no && can_build_shared=no
+
+with_gnu_ld=$with_gnu_ld
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc" in
+x|xyes)
+ # Assume -lc should be added
+ archive_cmds_need_lc=yes
+
+ if test "$enable_shared" = yes && test "$GCC" = yes; then
+ case $archive_cmds in
+ *'~'*)
+ # FIXME: we may have to deal with multi-command sequences.
+ ;;
+ '$CC '*)
+ # Test whether the compiler implicitly links with -lc since on some
+ # systems, -lgcc has to come before -lc. If gcc already passes -lc
+ # to ld, don't add -lc before -lgcc.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
+$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
+if ${lt_cv_archive_cmds_need_lc+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ $RM conftest*
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } 2>conftest.err; then
+ soname=conftest
+ lib=conftest
+ libobjs=conftest.$ac_objext
+ deplibs=
+ wl=$lt_prog_compiler_wl
+ pic_flag=$lt_prog_compiler_pic
+ compiler_flags=-v
+ linker_flags=-v
+ verstring=
+ output_objdir=.
+ libname=conftest
+ lt_save_allow_undefined_flag=$allow_undefined_flag
+ allow_undefined_flag=
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5
+ (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+ then
+ lt_cv_archive_cmds_need_lc=no
+ else
+ lt_cv_archive_cmds_need_lc=yes
+ fi
+ allow_undefined_flag=$lt_save_allow_undefined_flag
+ else
+ cat conftest.err 1>&5
+ fi
+ $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5
+$as_echo "$lt_cv_archive_cmds_need_lc" >&6; }
+ archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc
+ ;;
+ esac
+ fi
+ ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
+$as_echo_n "checking dynamic linker characteristics... " >&6; }
+
+if test "$GCC" = yes; then
+ case $host_os in
+ darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
+ *) lt_awk_arg="/^libraries:/" ;;
+ esac
+ case $host_os in
+ mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;;
+ *) lt_sed_strip_eq="s,=/,/,g" ;;
+ esac
+ lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
+ case $lt_search_path_spec in
+ *\;*)
+ # if the path contains ";" then we assume it to be the separator
+ # otherwise default to the standard path separator (i.e. ":") - it is
+ # assumed that no part of a normal pathname contains ";" but that should
+ # okay in the real world where ";" in dirpaths is itself problematic.
+ lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'`
+ ;;
+ *)
+ lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"`
+ ;;
+ esac
+ # Ok, now we have the path, separated by spaces, we can step through it
+ # and add multilib dir if necessary.
+ lt_tmp_lt_search_path_spec=
+ lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+ for lt_sys_path in $lt_search_path_spec; do
+ if test -d "$lt_sys_path/$lt_multi_os_dir"; then
+ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
+ else
+ test -d "$lt_sys_path" && \
+ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
+ fi
+ done
+ lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '
+BEGIN {RS=" "; FS="/|\n";} {
+ lt_foo="";
+ lt_count=0;
+ for (lt_i = NF; lt_i > 0; lt_i--) {
+ if ($lt_i != "" && $lt_i != ".") {
+ if ($lt_i == "..") {
+ lt_count++;
+ } else {
+ if (lt_count == 0) {
+ lt_foo="/" $lt_i lt_foo;
+ } else {
+ lt_count--;
+ }
+ }
+ }
+ }
+ if (lt_foo != "") { lt_freq[lt_foo]++; }
+ if (lt_freq[lt_foo] == 1) { print lt_foo; }
+}'`
+ # AWK program above erroneously prepends '/' to C:/dos/paths
+ # for these hosts.
+ case $host_os in
+ mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\
+ $SED 's,/\([A-Za-z]:\),\1,g'` ;;
+ esac
+ sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`
+else
+ sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+ shlibpath_var=LIBPATH
+
+ # AIX 3 has no versioning support, so we append a major version to the name.
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+
+aix[4-9]*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ hardcode_into_libs=yes
+ if test "$host_cpu" = ia64; then
+ # AIX 5 supports IA64
+ library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ else
+ # With GCC up to 2.95.x, collect2 would create an import file
+ # for dependence libraries. The import file would start with
+ # the line `#! .'. This would cause the generated library to
+ # depend on `.', always an invalid library. This was fixed in
+ # development snapshots of GCC prior to 3.0.
+ case $host_os in
+ aix4 | aix4.[01] | aix4.[01].*)
+ if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+ echo ' yes '
+ echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+ :
+ else
+ can_build_shared=no
+ fi
+ ;;
+ esac
+ # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+ # soname into executable. Probably we can add versioning support to
+ # collect2, so additional links can be useful in future.
+ if test "$aix_use_runtimelinking" = yes; then
+ # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+ # instead of lib<name>.a to let people know that these are not
+ # typical AIX shared libraries.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ else
+ # We preserve .a as extension for shared libraries through AIX4.2
+ # and later when we are not doing run time linking.
+ library_names_spec='${libname}${release}.a $libname.a'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ fi
+ shlibpath_var=LIBPATH
+ fi
+ ;;
+
+amigaos*)
+ case $host_cpu in
+ powerpc)
+ # Since July 2007 AmigaOS4 officially supports .so libraries.
+ # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ ;;
+ m68k)
+ library_names_spec='$libname.ixlibrary $libname.a'
+ # Create ${libname}_ixlibrary.a entries in /sys/libs.
+ finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+ ;;
+ esac
+ ;;
+
+beos*)
+ library_names_spec='${libname}${shared_ext}'
+ dynamic_linker="$host_os ld.so"
+ shlibpath_var=LIBRARY_PATH
+ ;;
+
+bsdi[45]*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+ sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+ # the default ld.so.conf also contains /usr/contrib/lib and
+ # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+ # libtool to hard-code these into programs
+ ;;
+
+cygwin* | mingw* | pw32* | cegcc*)
+ version_type=windows
+ shrext_cmds=".dll"
+ need_version=no
+ need_lib_prefix=no
+
+ case $GCC,$cc_basename in
+ yes,*)
+ # gcc
+ library_names_spec='$libname.dll.a'
+ # DLL is installed to $(libdir)/../bin by postinstall_cmds
+ postinstall_cmds='base_file=`basename \${file}`~
+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+ dldir=$destdir/`dirname \$dlpath`~
+ test -d \$dldir || mkdir -p \$dldir~
+ $install_prog $dir/$dlname \$dldir/$dlname~
+ chmod a+x \$dldir/$dlname~
+ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+ eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+ fi'
+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+ dlpath=$dir/\$dldll~
+ $RM \$dlpath'
+ shlibpath_overrides_runpath=yes
+
+ case $host_os in
+ cygwin*)
+ # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+ soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+
+ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
+ ;;
+ mingw* | cegcc*)
+ # MinGW DLLs use traditional 'lib' prefix
+ soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+ ;;
+ pw32*)
+ # pw32 DLLs use 'pw' prefix rather than 'lib'
+ library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+ ;;
+ esac
+ dynamic_linker='Win32 ld.exe'
+ ;;
+
+ *,cl*)
+ # Native MSVC
+ libname_spec='$name'
+ soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+ library_names_spec='${libname}.dll.lib'
+
+ case $build_os in
+ mingw*)
+ sys_lib_search_path_spec=
+ lt_save_ifs=$IFS
+ IFS=';'
+ for lt_path in $LIB
+ do
+ IFS=$lt_save_ifs
+ # Let DOS variable expansion print the short 8.3 style file name.
+ lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"`
+ sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path"
+ done
+ IFS=$lt_save_ifs
+ # Convert to MSYS style.
+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'`
+ ;;
+ cygwin*)
+ # Convert to unix form, then to dos form, then back to unix form
+ # but this time dos style (no spaces!) so that the unix form looks
+ # like /cygdrive/c/PROGRA~1:/cygdr...
+ sys_lib_search_path_spec=`cygpath --path --unix "$LIB"`
+ sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null`
+ sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ ;;
+ *)
+ sys_lib_search_path_spec="$LIB"
+ if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
+ # It is most probably a Windows format PATH.
+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+ else
+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ fi
+ # FIXME: find the short name or the path components, as spaces are
+ # common. (e.g. "Program Files" -> "PROGRA~1")
+ ;;
+ esac
+
+ # DLL is installed to $(libdir)/../bin by postinstall_cmds
+ postinstall_cmds='base_file=`basename \${file}`~
+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+ dldir=$destdir/`dirname \$dlpath`~
+ test -d \$dldir || mkdir -p \$dldir~
+ $install_prog $dir/$dlname \$dldir/$dlname'
+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+ dlpath=$dir/\$dldll~
+ $RM \$dlpath'
+ shlibpath_overrides_runpath=yes
+ dynamic_linker='Win32 link.exe'
+ ;;
+
+ *)
+ # Assume MSVC wrapper
+ library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+ dynamic_linker='Win32 ld.exe'
+ ;;
+ esac
+ # FIXME: first we should search . and the directory the executable is in
+ shlibpath_var=PATH
+ ;;
+
+darwin* | rhapsody*)
+ dynamic_linker="$host_os dyld"
+ version_type=darwin
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+ soname_spec='${libname}${release}${major}$shared_ext'
+ shlibpath_overrides_runpath=yes
+ shlibpath_var=DYLD_LIBRARY_PATH
+ shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+
+ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"
+ sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+ ;;
+
+dgux*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+freebsd* | dragonfly*)
+ # DragonFly does not have aout. When/if they implement a new
+ # versioning mechanism, adjust this.
+ if test -x /usr/bin/objformat; then
+ objformat=`/usr/bin/objformat`
+ else
+ case $host_os in
+ freebsd[23].*) objformat=aout ;;
+ *) objformat=elf ;;
+ esac
+ fi
+ version_type=freebsd-$objformat
+ case $version_type in
+ freebsd-elf*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+ need_version=no
+ need_lib_prefix=no
+ ;;
+ freebsd-*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+ need_version=yes
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_os in
+ freebsd2.*)
+ shlibpath_overrides_runpath=yes
+ ;;
+ freebsd3.[01]* | freebsdelf3.[01]*)
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+ freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
+ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+ *) # from 4.6 on, and DragonFly
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+ esac
+ ;;
+
+gnu*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+
+haiku*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ dynamic_linker="$host_os runtime_loader"
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
+ hardcode_into_libs=yes
+ ;;
+
+hpux9* | hpux10* | hpux11*)
+ # Give a soname corresponding to the major version so that dld.sl refuses to
+ # link against other versions.
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ case $host_cpu in
+ ia64*)
+ shrext_cmds='.so'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.so"
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ if test "X$HPUX_IA64_MODE" = X32; then
+ sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+ else
+ sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+ fi
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ hppa*64*)
+ shrext_cmds='.sl'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ *)
+ shrext_cmds='.sl'
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=SHLIB_PATH
+ shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+ esac
+ # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
+ postinstall_cmds='chmod 555 $lib'
+ # or fails outright, so override atomically:
+ install_override_mode=555
+ ;;
+
+interix[3-9]*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+
+irix5* | irix6* | nonstopux*)
+ case $host_os in
+ nonstopux*) version_type=nonstopux ;;
+ *)
+ if test "$lt_cv_prog_gnu_ld" = yes; then
+ version_type=linux # correct to gnu/linux during the next big refactor
+ else
+ version_type=irix
+ fi ;;
+ esac
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+ case $host_os in
+ irix5* | nonstopux*)
+ libsuff= shlibsuff=
+ ;;
+ *)
+ case $LD in # libtool.m4 will add one of these switches to LD
+ *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+ libsuff= shlibsuff= libmagic=32-bit;;
+ *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+ libsuff=32 shlibsuff=N32 libmagic=N32;;
+ *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+ libsuff=64 shlibsuff=64 libmagic=64-bit;;
+ *) libsuff= shlibsuff= libmagic=never-match;;
+ esac
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+ sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+ hardcode_into_libs=yes
+ ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+ dynamic_linker=no
+ ;;
+
+# This must be glibc/ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+
+ # Some binutils ld are patched to set DT_RUNPATH
+ if ${lt_cv_shlibpath_overrides_runpath+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_shlibpath_overrides_runpath=no
+ save_LDFLAGS=$LDFLAGS
+ save_libdir=$libdir
+ eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \
+ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\""
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then :
+ lt_cv_shlibpath_overrides_runpath=yes
+fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ LDFLAGS=$save_LDFLAGS
+ libdir=$save_libdir
+
+fi
+
+ shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath
+
+ # This implies no fast_install, which is unacceptable.
+ # Some rework will be needed to allow for fast_install
+ # before this can be enabled.
+ hardcode_into_libs=yes
+
+ # Append ld.so.conf contents to the search path
+ if test -f /etc/ld.so.conf; then
+ lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
+ sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+ fi
+
+ # We used to test for /lib/ld.so.1 and disable shared libraries on
+ # powerpc, because MkLinux only supported shared libraries with the
+ # GNU dynamic linker. Since this was broken with cross compilers,
+ # most powerpc-linux boxes support dynamic linking these days and
+ # people can always --disable-shared, the test was removed, and we
+ # assume the GNU/Linux dynamic linker is in use.
+ dynamic_linker='GNU/Linux ld.so'
+ ;;
+
+netbsdelf*-gnu)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ dynamic_linker='NetBSD ld.elf_so'
+ ;;
+
+netbsd*)
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ dynamic_linker='NetBSD (a.out) ld.so'
+ else
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ dynamic_linker='NetBSD ld.elf_so'
+ fi
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+
+newsos6)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ ;;
+
+*nto* | *qnx*)
+ version_type=qnx
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ dynamic_linker='ldqnx.so'
+ ;;
+
+openbsd*)
+ version_type=sunos
+ sys_lib_dlsearch_path_spec="/usr/lib"
+ need_lib_prefix=no
+ # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+ case $host_os in
+ openbsd3.3 | openbsd3.3.*) need_version=yes ;;
+ *) need_version=no ;;
+ esac
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ case $host_os in
+ openbsd2.[89] | openbsd2.[89].*)
+ shlibpath_overrides_runpath=no
+ ;;
+ *)
+ shlibpath_overrides_runpath=yes
+ ;;
+ esac
+ else
+ shlibpath_overrides_runpath=yes
+ fi
+ ;;
+
+os2*)
+ libname_spec='$name'
+ shrext_cmds=".dll"
+ need_lib_prefix=no
+ library_names_spec='$libname${shared_ext} $libname.a'
+ dynamic_linker='OS/2 ld.exe'
+ shlibpath_var=LIBPATH
+ ;;
+
+osf3* | osf4* | osf5*)
+ version_type=osf
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+ sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+ ;;
+
+rdos*)
+ dynamic_linker=no
+ ;;
+
+solaris*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ # ldd complains unless libraries are executable
+ postinstall_cmds='chmod +x $lib'
+ ;;
+
+sunos4*)
+ version_type=sunos
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ if test "$with_gnu_ld" = yes; then
+ need_lib_prefix=no
+ fi
+ need_version=yes
+ ;;
+
+sysv4 | sysv4.3*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_vendor in
+ sni)
+ shlibpath_overrides_runpath=no
+ need_lib_prefix=no
+ runpath_var=LD_RUN_PATH
+ ;;
+ siemens)
+ need_lib_prefix=no
+ ;;
+ motorola)
+ need_lib_prefix=no
+ need_version=no
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+ ;;
+ esac
+ ;;
+
+sysv4*MP*)
+ if test -d /usr/nec ;then
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+ soname_spec='$libname${shared_ext}.$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ fi
+ ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+ version_type=freebsd-elf
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ if test "$with_gnu_ld" = yes; then
+ sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+ else
+ sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+ case $host_os in
+ sco3.2v5*)
+ sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+ ;;
+ esac
+ fi
+ sys_lib_dlsearch_path_spec='/usr/lib'
+ ;;
+
+tpf*)
+ # TPF is a cross-target only. Preferred cross-host = GNU/Linux.
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+
+uts4*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+*)
+ dynamic_linker=no
+ ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
+$as_echo "$dynamic_linker" >&6; }
+test "$dynamic_linker" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+ variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+ sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+fi
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+ sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
+$as_echo_n "checking how to hardcode library paths into programs... " >&6; }
+hardcode_action=
+if test -n "$hardcode_libdir_flag_spec" ||
+ test -n "$runpath_var" ||
+ test "X$hardcode_automatic" = "Xyes" ; then
+
+ # We can hardcode non-existent directories.
+ if test "$hardcode_direct" != no &&
+ # If the only mechanism to avoid hardcoding is shlibpath_var, we
+ # have to relink, otherwise we might link with an installed library
+ # when we should be linking with a yet-to-be-installed one
+ ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no &&
+ test "$hardcode_minus_L" != no; then
+ # Linking always hardcodes the temporary library directory.
+ hardcode_action=relink
+ else
+ # We can link without hardcoding, and we can hardcode nonexisting dirs.
+ hardcode_action=immediate
+ fi
+else
+ # We cannot hardcode anything, or else we can only hardcode existing
+ # directories.
+ hardcode_action=unsupported
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5
+$as_echo "$hardcode_action" >&6; }
+
+if test "$hardcode_action" = relink ||
+ test "$inherit_rpath" = yes; then
+ # Fast installation is not supported
+ enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+ test "$enable_shared" = no; then
+ # Fast installation is not necessary
+ enable_fast_install=needless
+fi
+
+
+
+
+
+
+ if test "x$enable_dlopen" != xyes; then
+ enable_dlopen=unknown
+ enable_dlopen_self=unknown
+ enable_dlopen_self_static=unknown
+else
+ lt_cv_dlopen=no
+ lt_cv_dlopen_libs=
+
+ case $host_os in
+ beos*)
+ lt_cv_dlopen="load_add_on"
+ lt_cv_dlopen_libs=
+ lt_cv_dlopen_self=yes
+ ;;
+
+ mingw* | pw32* | cegcc*)
+ lt_cv_dlopen="LoadLibrary"
+ lt_cv_dlopen_libs=
+ ;;
+
+ cygwin*)
+ lt_cv_dlopen="dlopen"
+ lt_cv_dlopen_libs=
+ ;;
+
+ darwin*)
+ # if libdl is installed we need to link against it
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+$as_echo_n "checking for dlopen in -ldl... " >&6; }
+if ${ac_cv_lib_dl_dlopen+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_dl_dlopen=yes
+else
+ ac_cv_lib_dl_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+
+ lt_cv_dlopen="dyld"
+ lt_cv_dlopen_libs=
+ lt_cv_dlopen_self=yes
+
+fi
+
+ ;;
+
+ *)
+ ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load"
+if test "x$ac_cv_func_shl_load" = xyes; then :
+ lt_cv_dlopen="shl_load"
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5
+$as_echo_n "checking for shl_load in -ldld... " >&6; }
+if ${ac_cv_lib_dld_shl_load+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char shl_load ();
+int
+main ()
+{
+return shl_load ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_dld_shl_load=yes
+else
+ ac_cv_lib_dld_shl_load=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5
+$as_echo "$ac_cv_lib_dld_shl_load" >&6; }
+if test "x$ac_cv_lib_dld_shl_load" = xyes; then :
+ lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"
+else
+ ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"
+if test "x$ac_cv_func_dlopen" = xyes; then :
+ lt_cv_dlopen="dlopen"
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+$as_echo_n "checking for dlopen in -ldl... " >&6; }
+if ${ac_cv_lib_dl_dlopen+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_dl_dlopen=yes
+else
+ ac_cv_lib_dl_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5
+$as_echo_n "checking for dlopen in -lsvld... " >&6; }
+if ${ac_cv_lib_svld_dlopen+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsvld $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_svld_dlopen=yes
+else
+ ac_cv_lib_svld_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5
+$as_echo "$ac_cv_lib_svld_dlopen" >&6; }
+if test "x$ac_cv_lib_svld_dlopen" = xyes; then :
+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5
+$as_echo_n "checking for dld_link in -ldld... " >&6; }
+if ${ac_cv_lib_dld_dld_link+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dld_link ();
+int
+main ()
+{
+return dld_link ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_dld_dld_link=yes
+else
+ ac_cv_lib_dld_dld_link=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5
+$as_echo "$ac_cv_lib_dld_dld_link" >&6; }
+if test "x$ac_cv_lib_dld_dld_link" = xyes; then :
+ lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+ ;;
+ esac
+
+ if test "x$lt_cv_dlopen" != xno; then
+ enable_dlopen=yes
+ else
+ enable_dlopen=no
+ fi
+
+ case $lt_cv_dlopen in
+ dlopen)
+ save_CPPFLAGS="$CPPFLAGS"
+ test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+ save_LDFLAGS="$LDFLAGS"
+ wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+ save_LIBS="$LIBS"
+ LIBS="$lt_cv_dlopen_libs $LIBS"
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5
+$as_echo_n "checking whether a program can dlopen itself... " >&6; }
+if ${lt_cv_dlopen_self+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test "$cross_compiling" = yes; then :
+ lt_cv_dlopen_self=cross
+else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<_LT_EOF
+#line $LINENO "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+# define LT_DLGLOBAL RTLD_GLOBAL
+#else
+# ifdef DL_GLOBAL
+# define LT_DLGLOBAL DL_GLOBAL
+# else
+# define LT_DLGLOBAL 0
+# endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+ find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+# ifdef RTLD_LAZY
+# define LT_DLLAZY_OR_NOW RTLD_LAZY
+# else
+# ifdef DL_LAZY
+# define LT_DLLAZY_OR_NOW DL_LAZY
+# else
+# ifdef RTLD_NOW
+# define LT_DLLAZY_OR_NOW RTLD_NOW
+# else
+# ifdef DL_NOW
+# define LT_DLLAZY_OR_NOW DL_NOW
+# else
+# define LT_DLLAZY_OR_NOW 0
+# endif
+# endif
+# endif
+# endif
+#endif
+
+/* When -fvisbility=hidden is used, assume the code has been annotated
+ correspondingly for the symbols needed. */
+#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+int fnord () __attribute__((visibility("default")));
+#endif
+
+int fnord () { return 42; }
+int main ()
+{
+ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+ int status = $lt_dlunknown;
+
+ if (self)
+ {
+ if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
+ else
+ {
+ if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+ else puts (dlerror ());
+ }
+ /* dlclose (self); */
+ }
+ else
+ puts (dlerror ());
+
+ return status;
+}
+_LT_EOF
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
+ (./conftest; exit; ) >&5 2>/dev/null
+ lt_status=$?
+ case x$lt_status in
+ x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
+ x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
+ x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;;
+ esac
+ else :
+ # compilation failed
+ lt_cv_dlopen_self=no
+ fi
+fi
+rm -fr conftest*
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5
+$as_echo "$lt_cv_dlopen_self" >&6; }
+
+ if test "x$lt_cv_dlopen_self" = xyes; then
+ wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5
+$as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; }
+if ${lt_cv_dlopen_self_static+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test "$cross_compiling" = yes; then :
+ lt_cv_dlopen_self_static=cross
+else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<_LT_EOF
+#line $LINENO "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+# define LT_DLGLOBAL RTLD_GLOBAL
+#else
+# ifdef DL_GLOBAL
+# define LT_DLGLOBAL DL_GLOBAL
+# else
+# define LT_DLGLOBAL 0
+# endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+ find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+# ifdef RTLD_LAZY
+# define LT_DLLAZY_OR_NOW RTLD_LAZY
+# else
+# ifdef DL_LAZY
+# define LT_DLLAZY_OR_NOW DL_LAZY
+# else
+# ifdef RTLD_NOW
+# define LT_DLLAZY_OR_NOW RTLD_NOW
+# else
+# ifdef DL_NOW
+# define LT_DLLAZY_OR_NOW DL_NOW
+# else
+# define LT_DLLAZY_OR_NOW 0
+# endif
+# endif
+# endif
+# endif
+#endif
+
+/* When -fvisbility=hidden is used, assume the code has been annotated
+ correspondingly for the symbols needed. */
+#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+int fnord () __attribute__((visibility("default")));
+#endif
+
+int fnord () { return 42; }
+int main ()
+{
+ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+ int status = $lt_dlunknown;
+
+ if (self)
+ {
+ if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
+ else
+ {
+ if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+ else puts (dlerror ());
+ }
+ /* dlclose (self); */
+ }
+ else
+ puts (dlerror ());
+
+ return status;
+}
+_LT_EOF
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
+ (./conftest; exit; ) >&5 2>/dev/null
+ lt_status=$?
+ case x$lt_status in
+ x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
+ x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
+ x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;;
+ esac
+ else :
+ # compilation failed
+ lt_cv_dlopen_self_static=no
+ fi
+fi
+rm -fr conftest*
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5
+$as_echo "$lt_cv_dlopen_self_static" >&6; }
+ fi
+
+ CPPFLAGS="$save_CPPFLAGS"
+ LDFLAGS="$save_LDFLAGS"
+ LIBS="$save_LIBS"
+ ;;
+ esac
+
+ case $lt_cv_dlopen_self in
+ yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+ *) enable_dlopen_self=unknown ;;
+ esac
+
+ case $lt_cv_dlopen_self_static in
+ yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+ *) enable_dlopen_self_static=unknown ;;
+ esac
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+striplib=
+old_striplib=
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5
+$as_echo_n "checking whether stripping libraries is possible... " >&6; }
+if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
+ test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+ test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+ case $host_os in
+ darwin*)
+ if test -n "$STRIP" ; then
+ striplib="$STRIP -x"
+ old_striplib="$STRIP -S"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ fi
+ ;;
+ *)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ ;;
+ esac
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+ # Report which library types will actually be built
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5
+$as_echo_n "checking if libtool supports shared libraries... " >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5
+$as_echo "$can_build_shared" >&6; }
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5
+$as_echo_n "checking whether to build shared libraries... " >&6; }
+ test "$can_build_shared" = "no" && enable_shared=no
+
+ # On AIX, shared libraries and static libraries use the same namespace, and
+ # are all built from PIC.
+ case $host_os in
+ aix3*)
+ test "$enable_shared" = yes && enable_static=no
+ if test -n "$RANLIB"; then
+ archive_cmds="$archive_cmds~\$RANLIB \$lib"
+ postinstall_cmds='$RANLIB $lib'
+ fi
+ ;;
+
+ aix[4-9]*)
+ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+ test "$enable_shared" = yes && enable_static=no
+ fi
+ ;;
+ esac
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5
+$as_echo "$enable_shared" >&6; }
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5
+$as_echo_n "checking whether to build static libraries... " >&6; }
+ # Make sure either enable_shared or enable_static is yes.
+ test "$enable_shared" = yes || enable_static=yes
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5
+$as_echo "$enable_static" >&6; }
+
+
+
+
+fi
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+CC="$lt_save_CC"
+
+ if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+ ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+ (test "X$CXX" != "Xg++"))) ; then
+ ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5
+$as_echo_n "checking how to run the C++ preprocessor... " >&6; }
+if test -z "$CXXCPP"; then
+ if ${ac_cv_prog_CXXCPP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ # Double quotes because CXXCPP needs to be expanded
+ for CXXCPP in "$CXX -E" "/lib/cpp"
+ do
+ ac_preproc_ok=false
+for ac_cxx_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if ac_fn_cxx_try_cpp "$LINENO"; then :
+
+else
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether nonexistent headers
+ # can be detected and how.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_cxx_try_cpp "$LINENO"; then :
+ # Broken: success on invalid input.
+continue
+else
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+ break
+fi
+
+ done
+ ac_cv_prog_CXXCPP=$CXXCPP
+
+fi
+ CXXCPP=$ac_cv_prog_CXXCPP
+else
+ ac_cv_prog_CXXCPP=$CXXCPP
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5
+$as_echo "$CXXCPP" >&6; }
+ac_preproc_ok=false
+for ac_cxx_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if ac_fn_cxx_try_cpp "$LINENO"; then :
+
+else
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether nonexistent headers
+ # can be detected and how.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_cxx_try_cpp "$LINENO"; then :
+ # Broken: success on invalid input.
+continue
+else
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+
+else
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+else
+ _lt_caught_CXX_error=yes
+fi
+
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+archive_cmds_need_lc_CXX=no
+allow_undefined_flag_CXX=
+always_export_symbols_CXX=no
+archive_expsym_cmds_CXX=
+compiler_needs_object_CXX=no
+export_dynamic_flag_spec_CXX=
+hardcode_direct_CXX=no
+hardcode_direct_absolute_CXX=no
+hardcode_libdir_flag_spec_CXX=
+hardcode_libdir_separator_CXX=
+hardcode_minus_L_CXX=no
+hardcode_shlibpath_var_CXX=unsupported
+hardcode_automatic_CXX=no
+inherit_rpath_CXX=no
+module_cmds_CXX=
+module_expsym_cmds_CXX=
+link_all_deplibs_CXX=unknown
+old_archive_cmds_CXX=$old_archive_cmds
+reload_flag_CXX=$reload_flag
+reload_cmds_CXX=$reload_cmds
+no_undefined_flag_CXX=
+whole_archive_flag_spec_CXX=
+enable_shared_with_static_runtimes_CXX=no
+
+# Source file extension for C++ test sources.
+ac_ext=cpp
+
+# Object file extension for compiled C++ test sources.
+objext=o
+objext_CXX=$objext
+
+# No sense in running all these tests if we already determined that
+# the CXX compiler isn't working. Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_caught_CXX_error" != yes; then
+ # Code to be used in simple compile tests
+ lt_simple_compile_test_code="int some_variable = 0;"
+
+ # Code to be used in simple link tests
+ lt_simple_link_test_code='int main(int, char *[]) { return(0); }'
+
+ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+
+
+
+
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+ # save warnings/boilerplate of simple test code
+ ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$RM conftest*
+
+ ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$RM -r conftest*
+
+
+ # Allow CC to be a program name with arguments.
+ lt_save_CC=$CC
+ lt_save_CFLAGS=$CFLAGS
+ lt_save_LD=$LD
+ lt_save_GCC=$GCC
+ GCC=$GXX
+ lt_save_with_gnu_ld=$with_gnu_ld
+ lt_save_path_LD=$lt_cv_path_LD
+ if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
+ lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
+ else
+ $as_unset lt_cv_prog_gnu_ld
+ fi
+ if test -n "${lt_cv_path_LDCXX+set}"; then
+ lt_cv_path_LD=$lt_cv_path_LDCXX
+ else
+ $as_unset lt_cv_path_LD
+ fi
+ test -z "${LDCXX+set}" || LD=$LDCXX
+ CC=${CXX-"c++"}
+ CFLAGS=$CXXFLAGS
+ compiler=$CC
+ compiler_CXX=$CC
+ for cc_temp in $compiler""; do
+ case $cc_temp in
+ compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+ distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+ \-*) ;;
+ *) break;;
+ esac
+done
+cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+
+
+ if test -n "$compiler"; then
+ # We don't want -fno-exception when compiling C++ code, so set the
+ # no_builtin_flag separately
+ if test "$GXX" = yes; then
+ lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin'
+ else
+ lt_prog_compiler_no_builtin_flag_CXX=
+ fi
+
+ if test "$GXX" = yes; then
+ # Set up default GNU C++ configuration
+
+
+
+# Check whether --with-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then :
+ withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+else
+ with_gnu_ld=no
+fi
+
+ac_prog=ld
+if test "$GCC" = yes; then
+ # Check if gcc -print-prog-name=ld gives a path.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
+$as_echo_n "checking for ld used by $CC... " >&6; }
+ case $host in
+ *-*-mingw*)
+ # gcc leaves a trailing carriage return which upsets mingw
+ ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+ *)
+ ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+ esac
+ case $ac_prog in
+ # Accept absolute paths.
+ [\\/]* | ?:[\\/]*)
+ re_direlt='/[^/][^/]*/\.\./'
+ # Canonicalize the pathname of ld
+ ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
+ while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
+ ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
+ done
+ test -z "$LD" && LD="$ac_prog"
+ ;;
+ "")
+ # If it fails, then pretend we aren't using GCC.
+ ac_prog=ld
+ ;;
+ *)
+ # If it is relative, then search for the first ld in PATH.
+ with_gnu_ld=unknown
+ ;;
+ esac
+elif test "$with_gnu_ld" = yes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
+$as_echo_n "checking for GNU ld... " >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
+$as_echo_n "checking for non-GNU ld... " >&6; }
+fi
+if ${lt_cv_path_LD+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -z "$LD"; then
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ for ac_dir in $PATH; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+ lt_cv_path_LD="$ac_dir/$ac_prog"
+ # Check to see if the program is GNU ld. I'd rather use --version,
+ # but apparently some variants of GNU ld only accept -v.
+ # Break only if it was the GNU/non-GNU ld that we prefer.
+ case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+ *GNU* | *'with BFD'*)
+ test "$with_gnu_ld" != no && break
+ ;;
+ *)
+ test "$with_gnu_ld" != yes && break
+ ;;
+ esac
+ fi
+ done
+ IFS="$lt_save_ifs"
+else
+ lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
+
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
+$as_echo "$LD" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
+$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
+if ${lt_cv_prog_gnu_ld+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ # I'd rather use --version here, but apparently some GNU lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+ lt_cv_prog_gnu_ld=yes
+ ;;
+*)
+ lt_cv_prog_gnu_ld=no
+ ;;
+esac
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&5
+$as_echo "$lt_cv_prog_gnu_ld" >&6; }
+with_gnu_ld=$lt_cv_prog_gnu_ld
+
+
+
+
+
+
+
+ # Check if GNU C++ uses GNU ld as the underlying linker, since the
+ # archiving commands below assume that GNU ld is being used.
+ if test "$with_gnu_ld" = yes; then
+ archive_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+ export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+
+ # If archive_cmds runs LD, not CC, wlarc should be empty
+ # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
+ # investigate it a little bit more. (MM)
+ wlarc='${wl}'
+
+ # ancient GNU ld didn't support --whole-archive et. al.
+ if eval "`$CC -print-prog-name=ld` --help 2>&1" |
+ $GREP 'no-whole-archive' > /dev/null; then
+ whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ else
+ whole_archive_flag_spec_CXX=
+ fi
+ else
+ with_gnu_ld=no
+ wlarc=
+
+ # A generic and very simple default shared library creation
+ # command for GNU C++ for the case where it uses the native
+ # linker, instead of GNU ld. If possible, this setting should
+ # overridden to take advantage of the native linker features on
+ # the platform it is being used on.
+ archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+ fi
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+
+ else
+ GXX=no
+ with_gnu_ld=no
+ wlarc=
+ fi
+
+ # PORTME: fill in a description of your system's C++ link characteristics
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
+ ld_shlibs_CXX=yes
+ case $host_os in
+ aix3*)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ aix[4-9]*)
+ if test "$host_cpu" = ia64; then
+ # On IA64, the linker does run time linking by default, so we don't
+ # have to do anything special.
+ aix_use_runtimelinking=no
+ exp_sym_flag='-Bexport'
+ no_entry_flag=""
+ else
+ aix_use_runtimelinking=no
+
+ # Test if we are trying to use run time linking or normal
+ # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+ # need to do runtime linking.
+ case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
+ for ld_flag in $LDFLAGS; do
+ case $ld_flag in
+ *-brtl*)
+ aix_use_runtimelinking=yes
+ break
+ ;;
+ esac
+ done
+ ;;
+ esac
+
+ exp_sym_flag='-bexport'
+ no_entry_flag='-bnoentry'
+ fi
+
+ # When large executables or shared objects are built, AIX ld can
+ # have problems creating the table of contents. If linking a library
+ # or program results in "error TOC overflow" add -mminimal-toc to
+ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
+ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+ archive_cmds_CXX=''
+ hardcode_direct_CXX=yes
+ hardcode_direct_absolute_CXX=yes
+ hardcode_libdir_separator_CXX=':'
+ link_all_deplibs_CXX=yes
+ file_list_spec_CXX='${wl}-f,'
+
+ if test "$GXX" = yes; then
+ case $host_os in aix4.[012]|aix4.[012].*)
+ # We only want to do this on AIX 4.2 and lower, the check
+ # below for broken collect2 doesn't work under 4.3+
+ collect2name=`${CC} -print-prog-name=collect2`
+ if test -f "$collect2name" &&
+ strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+ then
+ # We have reworked collect2
+ :
+ else
+ # We have old collect2
+ hardcode_direct_CXX=unsupported
+ # It fails to find uninstalled libraries when the uninstalled
+ # path is not listed in the libpath. Setting hardcode_minus_L
+ # to unsupported forces relinking
+ hardcode_minus_L_CXX=yes
+ hardcode_libdir_flag_spec_CXX='-L$libdir'
+ hardcode_libdir_separator_CXX=
+ fi
+ esac
+ shared_flag='-shared'
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag="$shared_flag "'${wl}-G'
+ fi
+ else
+ # not using gcc
+ if test "$host_cpu" = ia64; then
+ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+ # chokes on -Wl,-G. The following line is correct:
+ shared_flag='-G'
+ else
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag='${wl}-G'
+ else
+ shared_flag='${wl}-bM:SRE'
+ fi
+ fi
+ fi
+
+ export_dynamic_flag_spec_CXX='${wl}-bexpall'
+ # It seems that -bexpall does not export symbols beginning with
+ # underscore (_), so it is better to generate a list of symbols to
+ # export.
+ always_export_symbols_CXX=yes
+ if test "$aix_use_runtimelinking" = yes; then
+ # Warning - without using the other runtime loading flags (-brtl),
+ # -berok will link without error, but may produce a broken library.
+ allow_undefined_flag_CXX='-berok'
+ # Determine the default libpath from the value encoded in an empty
+ # executable.
+ if test "${lt_cv_aix_libpath+set}" = set; then
+ aix_libpath=$lt_cv_aix_libpath
+else
+ if ${lt_cv_aix_libpath__CXX+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+
+ lt_aix_libpath_sed='
+ /Import File Strings/,/^$/ {
+ /^0/ {
+ s/^0 *\([^ ]*\) *$/\1/
+ p
+ }
+ }'
+ lt_cv_aix_libpath__CXX=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+ # Check for a 64-bit object if we didn't find anything.
+ if test -z "$lt_cv_aix_libpath__CXX"; then
+ lt_cv_aix_libpath__CXX=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+ fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ if test -z "$lt_cv_aix_libpath__CXX"; then
+ lt_cv_aix_libpath__CXX="/usr/lib:/lib"
+ fi
+
+fi
+
+ aix_libpath=$lt_cv_aix_libpath__CXX
+fi
+
+ hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
+
+ archive_expsym_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+ else
+ if test "$host_cpu" = ia64; then
+ hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib'
+ allow_undefined_flag_CXX="-z nodefs"
+ archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+ else
+ # Determine the default libpath from the value encoded in an
+ # empty executable.
+ if test "${lt_cv_aix_libpath+set}" = set; then
+ aix_libpath=$lt_cv_aix_libpath
+else
+ if ${lt_cv_aix_libpath__CXX+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+
+ lt_aix_libpath_sed='
+ /Import File Strings/,/^$/ {
+ /^0/ {
+ s/^0 *\([^ ]*\) *$/\1/
+ p
+ }
+ }'
+ lt_cv_aix_libpath__CXX=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+ # Check for a 64-bit object if we didn't find anything.
+ if test -z "$lt_cv_aix_libpath__CXX"; then
+ lt_cv_aix_libpath__CXX=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+ fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ if test -z "$lt_cv_aix_libpath__CXX"; then
+ lt_cv_aix_libpath__CXX="/usr/lib:/lib"
+ fi
+
+fi
+
+ aix_libpath=$lt_cv_aix_libpath__CXX
+fi
+
+ hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
+ # Warning - without using the other run time loading flags,
+ # -berok will link without error, but may produce a broken library.
+ no_undefined_flag_CXX=' ${wl}-bernotok'
+ allow_undefined_flag_CXX=' ${wl}-berok'
+ if test "$with_gnu_ld" = yes; then
+ # We only use this code for GNU lds that support --whole-archive.
+ whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+ else
+ # Exported symbols can be pulled into shared objects from archives
+ whole_archive_flag_spec_CXX='$convenience'
+ fi
+ archive_cmds_need_lc_CXX=yes
+ # This is similar to how AIX traditionally builds its shared
+ # libraries.
+ archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+ fi
+ fi
+ ;;
+
+ beos*)
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ allow_undefined_flag_CXX=unsupported
+ # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+ # support --undefined. This deserves some investigation. FIXME
+ archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ else
+ ld_shlibs_CXX=no
+ fi
+ ;;
+
+ chorus*)
+ case $cc_basename in
+ *)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ esac
+ ;;
+
+ cygwin* | mingw* | pw32* | cegcc*)
+ case $GXX,$cc_basename in
+ ,cl* | no,cl*)
+ # Native MSVC
+ # hardcode_libdir_flag_spec is actually meaningless, as there is
+ # no search path for DLLs.
+ hardcode_libdir_flag_spec_CXX=' '
+ allow_undefined_flag_CXX=unsupported
+ always_export_symbols_CXX=yes
+ file_list_spec_CXX='@'
+ # Tell ltmain to make .lib files, not .a files.
+ libext=lib
+ # Tell ltmain to make .dll files, not .so files.
+ shrext_cmds=".dll"
+ # FIXME: Setting linknames here is a bad hack.
+ archive_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
+ archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+ $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
+ else
+ $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
+ fi~
+ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+ linknames='
+ # The linker will not automatically build a static lib if we build a DLL.
+ # _LT_TAGVAR(old_archive_from_new_cmds, CXX)='true'
+ enable_shared_with_static_runtimes_CXX=yes
+ # Don't use ranlib
+ old_postinstall_cmds_CXX='chmod 644 $oldlib'
+ postlink_cmds_CXX='lt_outputfile="@OUTPUT@"~
+ lt_tool_outputfile="@TOOL_OUTPUT@"~
+ case $lt_outputfile in
+ *.exe|*.EXE) ;;
+ *)
+ lt_outputfile="$lt_outputfile.exe"
+ lt_tool_outputfile="$lt_tool_outputfile.exe"
+ ;;
+ esac~
+ func_to_tool_file "$lt_outputfile"~
+ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
+ $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+ $RM "$lt_outputfile.manifest";
+ fi'
+ ;;
+ *)
+ # g++
+ # _LT_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless,
+ # as there is no search path for DLLs.
+ hardcode_libdir_flag_spec_CXX='-L$libdir'
+ export_dynamic_flag_spec_CXX='${wl}--export-all-symbols'
+ allow_undefined_flag_CXX=unsupported
+ always_export_symbols_CXX=no
+ enable_shared_with_static_runtimes_CXX=yes
+
+ if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+ archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ # If the export-symbols file already is a .def file (1st line
+ # is EXPORTS), use it as is; otherwise, prepend...
+ archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+ cp $export_symbols $output_objdir/$soname.def;
+ else
+ echo EXPORTS > $output_objdir/$soname.def;
+ cat $export_symbols >> $output_objdir/$soname.def;
+ fi~
+ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ else
+ ld_shlibs_CXX=no
+ fi
+ ;;
+ esac
+ ;;
+ darwin* | rhapsody*)
+
+
+ archive_cmds_need_lc_CXX=no
+ hardcode_direct_CXX=no
+ hardcode_automatic_CXX=yes
+ hardcode_shlibpath_var_CXX=unsupported
+ if test "$lt_cv_ld_force_load" = "yes"; then
+ whole_archive_flag_spec_CXX='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
+
+ else
+ whole_archive_flag_spec_CXX=''
+ fi
+ link_all_deplibs_CXX=yes
+ allow_undefined_flag_CXX="$_lt_dar_allow_undefined"
+ case $cc_basename in
+ ifort*) _lt_dar_can_shared=yes ;;
+ *) _lt_dar_can_shared=$GCC ;;
+ esac
+ if test "$_lt_dar_can_shared" = "yes"; then
+ output_verbose_link_cmd=func_echo_all
+ archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+ module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+ archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+ module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+ if test "$lt_cv_apple_cc_single_mod" != "yes"; then
+ archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
+ archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
+ fi
+
+ else
+ ld_shlibs_CXX=no
+ fi
+
+ ;;
+
+ dgux*)
+ case $cc_basename in
+ ec++*)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ ghcx*)
+ # Green Hills C++ Compiler
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ esac
+ ;;
+
+ freebsd2.*)
+ # C++ shared libraries reported to be fairly broken before
+ # switch to ELF
+ ld_shlibs_CXX=no
+ ;;
+
+ freebsd-elf*)
+ archive_cmds_need_lc_CXX=no
+ ;;
+
+ freebsd* | dragonfly*)
+ # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
+ # conventions
+ ld_shlibs_CXX=yes
+ ;;
+
+ gnu*)
+ ;;
+
+ haiku*)
+ archive_cmds_CXX='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ link_all_deplibs_CXX=yes
+ ;;
+
+ hpux9*)
+ hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator_CXX=:
+ export_dynamic_flag_spec_CXX='${wl}-E'
+ hardcode_direct_CXX=yes
+ hardcode_minus_L_CXX=yes # Not in the search PATH,
+ # but as the default
+ # location of the library.
+
+ case $cc_basename in
+ CC*)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ aCC*)
+ archive_cmds_CXX='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+ ;;
+ *)
+ if test "$GXX" = yes; then
+ archive_cmds_CXX='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ else
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ fi
+ ;;
+ esac
+ ;;
+
+ hpux10*|hpux11*)
+ if test $with_gnu_ld = no; then
+ hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator_CXX=:
+
+ case $host_cpu in
+ hppa*64*|ia64*)
+ ;;
+ *)
+ export_dynamic_flag_spec_CXX='${wl}-E'
+ ;;
+ esac
+ fi
+ case $host_cpu in
+ hppa*64*|ia64*)
+ hardcode_direct_CXX=no
+ hardcode_shlibpath_var_CXX=no
+ ;;
+ *)
+ hardcode_direct_CXX=yes
+ hardcode_direct_absolute_CXX=yes
+ hardcode_minus_L_CXX=yes # Not in the search PATH,
+ # but as the default
+ # location of the library.
+ ;;
+ esac
+
+ case $cc_basename in
+ CC*)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ aCC*)
+ case $host_cpu in
+ hppa*64*)
+ archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ ia64*)
+ archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ *)
+ archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ esac
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+ ;;
+ *)
+ if test "$GXX" = yes; then
+ if test $with_gnu_ld = no; then
+ case $host_cpu in
+ hppa*64*)
+ archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ ia64*)
+ archive_cmds_CXX='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ *)
+ archive_cmds_CXX='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ esac
+ fi
+ else
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ fi
+ ;;
+ esac
+ ;;
+
+ interix[3-9]*)
+ hardcode_direct_CXX=no
+ hardcode_shlibpath_var_CXX=no
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+ export_dynamic_flag_spec_CXX='${wl}-E'
+ # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+ # Instead, shared libraries are loaded at an image base (0x10000000 by
+ # default) and relocated if they conflict, which is a slow very memory
+ # consuming and fragmenting process. To avoid this, we pick a random,
+ # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+ # time. Moving up from 0x10000000 also allows more sbrk(2) space.
+ archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ ;;
+ irix5* | irix6*)
+ case $cc_basename in
+ CC*)
+ # SGI C++
+ archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+
+ # Archives containing C++ object files must be created using
+ # "CC -ar", where "CC" is the IRIX C++ compiler. This is
+ # necessary to make sure instantiated templates are included
+ # in the archive.
+ old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs'
+ ;;
+ *)
+ if test "$GXX" = yes; then
+ if test "$with_gnu_ld" = no; then
+ archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ else
+ archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib'
+ fi
+ fi
+ link_all_deplibs_CXX=yes
+ ;;
+ esac
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator_CXX=:
+ inherit_rpath_CXX=yes
+ ;;
+
+ linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ case $cc_basename in
+ KCC*)
+ # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+ # KCC will only create a shared library if the output file
+ # ends with ".so" (or ".sl" for HP-UX), so rename the library
+ # to its proper name (with version) after linking.
+ archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+ archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+ export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+
+ # Archives containing C++ object files must be created using
+ # "CC -Bstatic", where "CC" is the KAI C++ compiler.
+ old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs'
+ ;;
+ icpc* | ecpc* )
+ # Intel C++
+ with_gnu_ld=yes
+ # version 8.0 and above of icpc choke on multiply defined symbols
+ # if we add $predep_objects and $postdep_objects, however 7.1 and
+ # earlier do not add the objects themselves.
+ case `$CC -V 2>&1` in
+ *"Version 7."*)
+ archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ ;;
+ *) # Version 8.0 or newer
+ tmp_idyn=
+ case $host_cpu in
+ ia64*) tmp_idyn=' -i_dynamic';;
+ esac
+ archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ ;;
+ esac
+ archive_cmds_need_lc_CXX=no
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+ export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+ whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+ ;;
+ pgCC* | pgcpp*)
+ # Portland Group C++ compiler
+ case `$CC -V` in
+ *pgCC\ [1-5].* | *pgcpp\ [1-5].*)
+ prelink_cmds_CXX='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
+ compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
+ old_archive_cmds_CXX='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
+ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
+ $RANLIB $oldlib'
+ archive_cmds_CXX='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+ archive_expsym_cmds_CXX='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+ ;;
+ *) # Version 6 and above use weak symbols
+ archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+ archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+ ;;
+ esac
+
+ hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir'
+ export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+ whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+ ;;
+ cxx*)
+ # Compaq C++
+ archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+
+ runpath_var=LD_RUN_PATH
+ hardcode_libdir_flag_spec_CXX='-rpath $libdir'
+ hardcode_libdir_separator_CXX=:
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
+ ;;
+ xl* | mpixl* | bgxl*)
+ # IBM XL 8.0 on PPC, with GNU ld
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+ export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+ archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ if test "x$supports_anon_versioning" = xyes; then
+ archive_expsym_cmds_CXX='echo "{ global:" > $output_objdir/$libname.ver~
+ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+ echo "local: *; };" >> $output_objdir/$libname.ver~
+ $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+ fi
+ ;;
+ *)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*)
+ # Sun C++ 5.9
+ no_undefined_flag_CXX=' -zdefs'
+ archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ archive_expsym_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+ hardcode_libdir_flag_spec_CXX='-R$libdir'
+ whole_archive_flag_spec_CXX='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+ compiler_needs_object_CXX=yes
+
+ # Not sure whether something based on
+ # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
+ # would be better.
+ output_verbose_link_cmd='func_echo_all'
+
+ # Archives containing C++ object files must be created using
+ # "CC -xar", where "CC" is the Sun C++ compiler. This is
+ # necessary to make sure instantiated templates are included
+ # in the archive.
+ old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs'
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+
+ lynxos*)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+
+ m88k*)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+
+ mvs*)
+ case $cc_basename in
+ cxx*)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ esac
+ ;;
+
+ netbsd*)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ archive_cmds_CXX='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
+ wlarc=
+ hardcode_libdir_flag_spec_CXX='-R$libdir'
+ hardcode_direct_CXX=yes
+ hardcode_shlibpath_var_CXX=no
+ fi
+ # Workaround some broken pre-1.5 toolchains
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
+ ;;
+
+ *nto* | *qnx*)
+ ld_shlibs_CXX=yes
+ ;;
+
+ openbsd2*)
+ # C++ shared libraries are fairly broken
+ ld_shlibs_CXX=no
+ ;;
+
+ openbsd*)
+ if test -f /usr/libexec/ld.so; then
+ hardcode_direct_CXX=yes
+ hardcode_shlibpath_var_CXX=no
+ hardcode_direct_absolute_CXX=yes
+ archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
+ export_dynamic_flag_spec_CXX='${wl}-E'
+ whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ fi
+ output_verbose_link_cmd=func_echo_all
+ else
+ ld_shlibs_CXX=no
+ fi
+ ;;
+
+ osf3* | osf4* | osf5*)
+ case $cc_basename in
+ KCC*)
+ # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+ # KCC will only create a shared library if the output file
+ # ends with ".so" (or ".sl" for HP-UX), so rename the library
+ # to its proper name (with version) after linking.
+ archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+ hardcode_libdir_separator_CXX=:
+
+ # Archives containing C++ object files must be created using
+ # the KAI C++ compiler.
+ case $host in
+ osf3*) old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' ;;
+ *) old_archive_cmds_CXX='$CC -o $oldlib $oldobjs' ;;
+ esac
+ ;;
+ RCC*)
+ # Rational C++ 2.4.1
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ cxx*)
+ case $host in
+ osf3*)
+ allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
+ archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+ ;;
+ *)
+ allow_undefined_flag_CXX=' -expect_unresolved \*'
+ archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+ archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
+ echo "-hidden">> $lib.exp~
+ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~
+ $RM $lib.exp'
+ hardcode_libdir_flag_spec_CXX='-rpath $libdir'
+ ;;
+ esac
+
+ hardcode_libdir_separator_CXX=:
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+ ;;
+ *)
+ if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+ allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
+ case $host in
+ osf3*)
+ archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ ;;
+ *)
+ archive_cmds_CXX='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ ;;
+ esac
+
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator_CXX=:
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+
+ else
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ fi
+ ;;
+ esac
+ ;;
+
+ psos*)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+
+ sunos4*)
+ case $cc_basename in
+ CC*)
+ # Sun C++ 4.x
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ lcc*)
+ # Lucid
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ esac
+ ;;
+
+ solaris*)
+ case $cc_basename in
+ CC* | sunCC*)
+ # Sun C++ 4.2, 5.x and Centerline C++
+ archive_cmds_need_lc_CXX=yes
+ no_undefined_flag_CXX=' -zdefs'
+ archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+ hardcode_libdir_flag_spec_CXX='-R$libdir'
+ hardcode_shlibpath_var_CXX=no
+ case $host_os in
+ solaris2.[0-5] | solaris2.[0-5].*) ;;
+ *)
+ # The compiler driver will combine and reorder linker options,
+ # but understands `-z linker_flag'.
+ # Supported since Solaris 2.6 (maybe 2.5.1?)
+ whole_archive_flag_spec_CXX='-z allextract$convenience -z defaultextract'
+ ;;
+ esac
+ link_all_deplibs_CXX=yes
+
+ output_verbose_link_cmd='func_echo_all'
+
+ # Archives containing C++ object files must be created using
+ # "CC -xar", where "CC" is the Sun C++ compiler. This is
+ # necessary to make sure instantiated templates are included
+ # in the archive.
+ old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs'
+ ;;
+ gcx*)
+ # Green Hills C++ Compiler
+ archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+
+ # The C++ compiler must be used to create the archive.
+ old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
+ ;;
+ *)
+ # GNU C++ compiler with Solaris linker
+ if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+ no_undefined_flag_CXX=' ${wl}-z ${wl}defs'
+ if $CC --version | $GREP -v '^2\.7' > /dev/null; then
+ archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+ archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+ else
+ # g++ 2.7 appears to require `-G' NOT `-shared' on this
+ # platform.
+ archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+ archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+ fi
+
+ hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir'
+ case $host_os in
+ solaris2.[0-5] | solaris2.[0-5].*) ;;
+ *)
+ whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+ ;;
+ esac
+ fi
+ ;;
+ esac
+ ;;
+
+ sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
+ no_undefined_flag_CXX='${wl}-z,text'
+ archive_cmds_need_lc_CXX=no
+ hardcode_shlibpath_var_CXX=no
+ runpath_var='LD_RUN_PATH'
+
+ case $cc_basename in
+ CC*)
+ archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ ;;
+
+ sysv5* | sco3.2v5* | sco5v6*)
+ # Note: We can NOT use -z defs as we might desire, because we do not
+ # link with -lc, and that would cause any symbols used from libc to
+ # always be unresolved, which means just about no library would
+ # ever link correctly. If we're not using GNU ld we use -z text
+ # though, which does catch some bad symbols but isn't as heavy-handed
+ # as -z defs.
+ no_undefined_flag_CXX='${wl}-z,text'
+ allow_undefined_flag_CXX='${wl}-z,nodefs'
+ archive_cmds_need_lc_CXX=no
+ hardcode_shlibpath_var_CXX=no
+ hardcode_libdir_flag_spec_CXX='${wl}-R,$libdir'
+ hardcode_libdir_separator_CXX=':'
+ link_all_deplibs_CXX=yes
+ export_dynamic_flag_spec_CXX='${wl}-Bexport'
+ runpath_var='LD_RUN_PATH'
+
+ case $cc_basename in
+ CC*)
+ archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ old_archive_cmds_CXX='$CC -Tprelink_objects $oldobjs~
+ '"$old_archive_cmds_CXX"
+ reload_cmds_CXX='$CC -Tprelink_objects $reload_objs~
+ '"$reload_cmds_CXX"
+ ;;
+ *)
+ archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ ;;
+
+ tandem*)
+ case $cc_basename in
+ NCC*)
+ # NonStop-UX NCC 3.20
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ esac
+ ;;
+
+ vxworks*)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+
+ *)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ esac
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5
+$as_echo "$ld_shlibs_CXX" >&6; }
+ test "$ld_shlibs_CXX" = no && can_build_shared=no
+
+ GCC_CXX="$GXX"
+ LD_CXX="$LD"
+
+ ## CAVEAT EMPTOR:
+ ## There is no encapsulation within the following macros, do not change
+ ## the running order or otherwise move them around unless you know exactly
+ ## what you are doing...
+ # Dependencies to place before and after the object being linked:
+predep_objects_CXX=
+postdep_objects_CXX=
+predeps_CXX=
+postdeps_CXX=
+compiler_lib_search_path_CXX=
+
+cat > conftest.$ac_ext <<_LT_EOF
+class Foo
+{
+public:
+ Foo (void) { a = 0; }
+private:
+ int a;
+};
+_LT_EOF
+
+
+_lt_libdeps_save_CFLAGS=$CFLAGS
+case "$CC $CFLAGS " in #(
+*\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;;
+*\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;;
+*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;;
+esac
+
+if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ # Parse the compiler output and extract the necessary
+ # objects, libraries and library flags.
+
+ # Sentinel used to keep track of whether or not we are before
+ # the conftest object file.
+ pre_test_object_deps_done=no
+
+ for p in `eval "$output_verbose_link_cmd"`; do
+ case ${prev}${p} in
+
+ -L* | -R* | -l*)
+ # Some compilers place space between "-{L,R}" and the path.
+ # Remove the space.
+ if test $p = "-L" ||
+ test $p = "-R"; then
+ prev=$p
+ continue
+ fi
+
+ # Expand the sysroot to ease extracting the directories later.
+ if test -z "$prev"; then
+ case $p in
+ -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;;
+ -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;;
+ -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;;
+ esac
+ fi
+ case $p in
+ =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;;
+ esac
+ if test "$pre_test_object_deps_done" = no; then
+ case ${prev} in
+ -L | -R)
+ # Internal compiler library paths should come after those
+ # provided the user. The postdeps already come after the
+ # user supplied libs so there is no need to process them.
+ if test -z "$compiler_lib_search_path_CXX"; then
+ compiler_lib_search_path_CXX="${prev}${p}"
+ else
+ compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}"
+ fi
+ ;;
+ # The "-l" case would never come before the object being
+ # linked, so don't bother handling this case.
+ esac
+ else
+ if test -z "$postdeps_CXX"; then
+ postdeps_CXX="${prev}${p}"
+ else
+ postdeps_CXX="${postdeps_CXX} ${prev}${p}"
+ fi
+ fi
+ prev=
+ ;;
+
+ *.lto.$objext) ;; # Ignore GCC LTO objects
+ *.$objext)
+ # This assumes that the test object file only shows up
+ # once in the compiler output.
+ if test "$p" = "conftest.$objext"; then
+ pre_test_object_deps_done=yes
+ continue
+ fi
+
+ if test "$pre_test_object_deps_done" = no; then
+ if test -z "$predep_objects_CXX"; then
+ predep_objects_CXX="$p"
+ else
+ predep_objects_CXX="$predep_objects_CXX $p"
+ fi
+ else
+ if test -z "$postdep_objects_CXX"; then
+ postdep_objects_CXX="$p"
+ else
+ postdep_objects_CXX="$postdep_objects_CXX $p"
+ fi
+ fi
+ ;;
+
+ *) ;; # Ignore the rest.
+
+ esac
+ done
+
+ # Clean up.
+ rm -f a.out a.exe
+else
+ echo "libtool.m4: error: problem compiling CXX test program"
+fi
+
+$RM -f confest.$objext
+CFLAGS=$_lt_libdeps_save_CFLAGS
+
+# PORTME: override above test on systems where it is broken
+case $host_os in
+interix[3-9]*)
+ # Interix 3.5 installs completely hosed .la files for C++, so rather than
+ # hack all around it, let's just trust "g++" to DTRT.
+ predep_objects_CXX=
+ postdep_objects_CXX=
+ postdeps_CXX=
+ ;;
+
+linux*)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*)
+ # Sun C++ 5.9
+
+ # The more standards-conforming stlport4 library is
+ # incompatible with the Cstd library. Avoid specifying
+ # it if it's in CXXFLAGS. Ignore libCrun as
+ # -library=stlport4 depends on it.
+ case " $CXX $CXXFLAGS " in
+ *" -library=stlport4 "*)
+ solaris_use_stlport4=yes
+ ;;
+ esac
+
+ if test "$solaris_use_stlport4" != yes; then
+ postdeps_CXX='-library=Cstd -library=Crun'
+ fi
+ ;;
+ esac
+ ;;
+
+solaris*)
+ case $cc_basename in
+ CC* | sunCC*)
+ # The more standards-conforming stlport4 library is
+ # incompatible with the Cstd library. Avoid specifying
+ # it if it's in CXXFLAGS. Ignore libCrun as
+ # -library=stlport4 depends on it.
+ case " $CXX $CXXFLAGS " in
+ *" -library=stlport4 "*)
+ solaris_use_stlport4=yes
+ ;;
+ esac
+
+ # Adding this requires a known-good setup of shared libraries for
+ # Sun compiler versions before 5.6, else PIC objects from an old
+ # archive will be linked into the output, leading to subtle bugs.
+ if test "$solaris_use_stlport4" != yes; then
+ postdeps_CXX='-library=Cstd -library=Crun'
+ fi
+ ;;
+ esac
+ ;;
+esac
+
+
+case " $postdeps_CXX " in
+*" -lc "*) archive_cmds_need_lc_CXX=no ;;
+esac
+ compiler_lib_search_dirs_CXX=
+if test -n "${compiler_lib_search_path_CXX}"; then
+ compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ lt_prog_compiler_wl_CXX=
+lt_prog_compiler_pic_CXX=
+lt_prog_compiler_static_CXX=
+
+
+ # C++ specific cases for pic, static, wl, etc.
+ if test "$GXX" = yes; then
+ lt_prog_compiler_wl_CXX='-Wl,'
+ lt_prog_compiler_static_CXX='-static'
+
+ case $host_os in
+ aix*)
+ # All AIX code is PIC.
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ lt_prog_compiler_static_CXX='-Bstatic'
+ fi
+ ;;
+
+ amigaos*)
+ case $host_cpu in
+ powerpc)
+ # see comment about AmigaOS4 .so support
+ lt_prog_compiler_pic_CXX='-fPIC'
+ ;;
+ m68k)
+ # FIXME: we need at least 68020 code to build shared libraries, but
+ # adding the `-m68020' flag to GCC prevents building anything better,
+ # like `-m68040'.
+ lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4'
+ ;;
+ esac
+ ;;
+
+ beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+ # PIC is the default for these OSes.
+ ;;
+ mingw* | cygwin* | os2* | pw32* | cegcc*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ # Although the cygwin gcc ignores -fPIC, still need this for old-style
+ # (--disable-auto-import) libraries
+ lt_prog_compiler_pic_CXX='-DDLL_EXPORT'
+ ;;
+ darwin* | rhapsody*)
+ # PIC is the default on this platform
+ # Common symbols not allowed in MH_DYLIB files
+ lt_prog_compiler_pic_CXX='-fno-common'
+ ;;
+ *djgpp*)
+ # DJGPP does not support shared libraries at all
+ lt_prog_compiler_pic_CXX=
+ ;;
+ haiku*)
+ # PIC is the default for Haiku.
+ # The "-static" flag exists, but is broken.
+ lt_prog_compiler_static_CXX=
+ ;;
+ interix[3-9]*)
+ # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+ # Instead, we relocate shared libraries at runtime.
+ ;;
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ lt_prog_compiler_pic_CXX=-Kconform_pic
+ fi
+ ;;
+ hpux*)
+ # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
+ # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag
+ # sets the default TLS model and affects inlining.
+ case $host_cpu in
+ hppa*64*)
+ ;;
+ *)
+ lt_prog_compiler_pic_CXX='-fPIC'
+ ;;
+ esac
+ ;;
+ *qnx* | *nto*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ lt_prog_compiler_pic_CXX='-fPIC -shared'
+ ;;
+ *)
+ lt_prog_compiler_pic_CXX='-fPIC'
+ ;;
+ esac
+ else
+ case $host_os in
+ aix[4-9]*)
+ # All AIX code is PIC.
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ lt_prog_compiler_static_CXX='-Bstatic'
+ else
+ lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp'
+ fi
+ ;;
+ chorus*)
+ case $cc_basename in
+ cxch68*)
+ # Green Hills C++ Compiler
+ # _LT_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
+ ;;
+ esac
+ ;;
+ mingw* | cygwin* | os2* | pw32* | cegcc*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ lt_prog_compiler_pic_CXX='-DDLL_EXPORT'
+ ;;
+ dgux*)
+ case $cc_basename in
+ ec++*)
+ lt_prog_compiler_pic_CXX='-KPIC'
+ ;;
+ ghcx*)
+ # Green Hills C++ Compiler
+ lt_prog_compiler_pic_CXX='-pic'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ freebsd* | dragonfly*)
+ # FreeBSD uses GNU C++
+ ;;
+ hpux9* | hpux10* | hpux11*)
+ case $cc_basename in
+ CC*)
+ lt_prog_compiler_wl_CXX='-Wl,'
+ lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
+ if test "$host_cpu" != ia64; then
+ lt_prog_compiler_pic_CXX='+Z'
+ fi
+ ;;
+ aCC*)
+ lt_prog_compiler_wl_CXX='-Wl,'
+ lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
+ case $host_cpu in
+ hppa*64*|ia64*)
+ # +Z the default
+ ;;
+ *)
+ lt_prog_compiler_pic_CXX='+Z'
+ ;;
+ esac
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ interix*)
+ # This is c89, which is MS Visual C++ (no shared libs)
+ # Anyone wants to do a port?
+ ;;
+ irix5* | irix6* | nonstopux*)
+ case $cc_basename in
+ CC*)
+ lt_prog_compiler_wl_CXX='-Wl,'
+ lt_prog_compiler_static_CXX='-non_shared'
+ # CC pic flag -KPIC is the default.
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ case $cc_basename in
+ KCC*)
+ # KAI C++ Compiler
+ lt_prog_compiler_wl_CXX='--backend -Wl,'
+ lt_prog_compiler_pic_CXX='-fPIC'
+ ;;
+ ecpc* )
+ # old Intel C++ for x86_64 which still supported -KPIC.
+ lt_prog_compiler_wl_CXX='-Wl,'
+ lt_prog_compiler_pic_CXX='-KPIC'
+ lt_prog_compiler_static_CXX='-static'
+ ;;
+ icpc* )
+ # Intel C++, used to be incompatible with GCC.
+ # ICC 10 doesn't accept -KPIC any more.
+ lt_prog_compiler_wl_CXX='-Wl,'
+ lt_prog_compiler_pic_CXX='-fPIC'
+ lt_prog_compiler_static_CXX='-static'
+ ;;
+ pgCC* | pgcpp*)
+ # Portland Group C++ compiler
+ lt_prog_compiler_wl_CXX='-Wl,'
+ lt_prog_compiler_pic_CXX='-fpic'
+ lt_prog_compiler_static_CXX='-Bstatic'
+ ;;
+ cxx*)
+ # Compaq C++
+ # Make sure the PIC flag is empty. It appears that all Alpha
+ # Linux and Compaq Tru64 Unix objects are PIC.
+ lt_prog_compiler_pic_CXX=
+ lt_prog_compiler_static_CXX='-non_shared'
+ ;;
+ xlc* | xlC* | bgxl[cC]* | mpixl[cC]*)
+ # IBM XL 8.0, 9.0 on PPC and BlueGene
+ lt_prog_compiler_wl_CXX='-Wl,'
+ lt_prog_compiler_pic_CXX='-qpic'
+ lt_prog_compiler_static_CXX='-qstaticlink'
+ ;;
+ *)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*)
+ # Sun C++ 5.9
+ lt_prog_compiler_pic_CXX='-KPIC'
+ lt_prog_compiler_static_CXX='-Bstatic'
+ lt_prog_compiler_wl_CXX='-Qoption ld '
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+ lynxos*)
+ ;;
+ m88k*)
+ ;;
+ mvs*)
+ case $cc_basename in
+ cxx*)
+ lt_prog_compiler_pic_CXX='-W c,exportall'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ netbsd* | netbsdelf*-gnu)
+ ;;
+ *qnx* | *nto*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ lt_prog_compiler_pic_CXX='-fPIC -shared'
+ ;;
+ osf3* | osf4* | osf5*)
+ case $cc_basename in
+ KCC*)
+ lt_prog_compiler_wl_CXX='--backend -Wl,'
+ ;;
+ RCC*)
+ # Rational C++ 2.4.1
+ lt_prog_compiler_pic_CXX='-pic'
+ ;;
+ cxx*)
+ # Digital/Compaq C++
+ lt_prog_compiler_wl_CXX='-Wl,'
+ # Make sure the PIC flag is empty. It appears that all Alpha
+ # Linux and Compaq Tru64 Unix objects are PIC.
+ lt_prog_compiler_pic_CXX=
+ lt_prog_compiler_static_CXX='-non_shared'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ psos*)
+ ;;
+ solaris*)
+ case $cc_basename in
+ CC* | sunCC*)
+ # Sun C++ 4.2, 5.x and Centerline C++
+ lt_prog_compiler_pic_CXX='-KPIC'
+ lt_prog_compiler_static_CXX='-Bstatic'
+ lt_prog_compiler_wl_CXX='-Qoption ld '
+ ;;
+ gcx*)
+ # Green Hills C++ Compiler
+ lt_prog_compiler_pic_CXX='-PIC'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ sunos4*)
+ case $cc_basename in
+ CC*)
+ # Sun C++ 4.x
+ lt_prog_compiler_pic_CXX='-pic'
+ lt_prog_compiler_static_CXX='-Bstatic'
+ ;;
+ lcc*)
+ # Lucid
+ lt_prog_compiler_pic_CXX='-pic'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+ case $cc_basename in
+ CC*)
+ lt_prog_compiler_wl_CXX='-Wl,'
+ lt_prog_compiler_pic_CXX='-KPIC'
+ lt_prog_compiler_static_CXX='-Bstatic'
+ ;;
+ esac
+ ;;
+ tandem*)
+ case $cc_basename in
+ NCC*)
+ # NonStop-UX NCC 3.20
+ lt_prog_compiler_pic_CXX='-KPIC'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ vxworks*)
+ ;;
+ *)
+ lt_prog_compiler_can_build_shared_CXX=no
+ ;;
+ esac
+ fi
+
+case $host_os in
+ # For platforms which do not support PIC, -DPIC is meaningless:
+ *djgpp*)
+ lt_prog_compiler_pic_CXX=
+ ;;
+ *)
+ lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC"
+ ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5
+$as_echo_n "checking for $compiler option to produce PIC... " >&6; }
+if ${lt_cv_prog_compiler_pic_CXX+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_pic_CXX=$lt_prog_compiler_pic_CXX
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_CXX" >&5
+$as_echo "$lt_cv_prog_compiler_pic_CXX" >&6; }
+lt_prog_compiler_pic_CXX=$lt_cv_prog_compiler_pic_CXX
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic_CXX"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5
+$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... " >&6; }
+if ${lt_cv_prog_compiler_pic_works_CXX+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_pic_works_CXX=no
+ ac_outfile=conftest.$ac_objext
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+ lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ # The option is referenced via a variable to avoid confusing sed.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>conftest.err)
+ ac_status=$?
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s "$ac_outfile"; then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings other than the usual output.
+ $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+ if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler_pic_works_CXX=yes
+ fi
+ fi
+ $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works_CXX" >&5
+$as_echo "$lt_cv_prog_compiler_pic_works_CXX" >&6; }
+
+if test x"$lt_cv_prog_compiler_pic_works_CXX" = xyes; then
+ case $lt_prog_compiler_pic_CXX in
+ "" | " "*) ;;
+ *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;;
+ esac
+else
+ lt_prog_compiler_pic_CXX=
+ lt_prog_compiler_can_build_shared_CXX=no
+fi
+
+fi
+
+
+
+
+
+#
+# Check to make sure the static flag actually works.
+#
+wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5
+$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
+if ${lt_cv_prog_compiler_static_works_CXX+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_static_works_CXX=no
+ save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
+ echo "$lt_simple_link_test_code" > conftest.$ac_ext
+ if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+ # The linker can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ if test -s conftest.err; then
+ # Append any errors to the config.log.
+ cat conftest.err 1>&5
+ $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+ if diff conftest.exp conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler_static_works_CXX=yes
+ fi
+ else
+ lt_cv_prog_compiler_static_works_CXX=yes
+ fi
+ fi
+ $RM -r conftest*
+ LDFLAGS="$save_LDFLAGS"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works_CXX" >&5
+$as_echo "$lt_cv_prog_compiler_static_works_CXX" >&6; }
+
+if test x"$lt_cv_prog_compiler_static_works_CXX" = xyes; then
+ :
+else
+ lt_prog_compiler_static_CXX=
+fi
+
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if ${lt_cv_prog_compiler_c_o_CXX+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_c_o_CXX=no
+ $RM -r conftest 2>/dev/null
+ mkdir conftest
+ cd conftest
+ mkdir out
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ lt_compiler_flag="-o out/conftest2.$ac_objext"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>out/conftest.err)
+ ac_status=$?
+ cat out/conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s out/conftest2.$ac_objext
+ then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
+ $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+ if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler_c_o_CXX=yes
+ fi
+ fi
+ chmod u+w . 2>&5
+ $RM conftest*
+ # SGI C++ compiler will create directory out/ii_files/ for
+ # template instantiation
+ test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+ $RM out/* && rmdir out
+ cd ..
+ $RM -r conftest
+ $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5
+$as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; }
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if ${lt_cv_prog_compiler_c_o_CXX+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_c_o_CXX=no
+ $RM -r conftest 2>/dev/null
+ mkdir conftest
+ cd conftest
+ mkdir out
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ lt_compiler_flag="-o out/conftest2.$ac_objext"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>out/conftest.err)
+ ac_status=$?
+ cat out/conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s out/conftest2.$ac_objext
+ then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
+ $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+ if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler_c_o_CXX=yes
+ fi
+ fi
+ chmod u+w . 2>&5
+ $RM conftest*
+ # SGI C++ compiler will create directory out/ii_files/ for
+ # template instantiation
+ test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+ $RM out/* && rmdir out
+ cd ..
+ $RM -r conftest
+ $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5
+$as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; }
+
+
+
+
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then
+ # do not overwrite the value of need_locks provided by the user
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
+$as_echo_n "checking if we can lock with hard links... " >&6; }
+ hard_links=yes
+ $RM conftest*
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ touch conftest.a
+ ln conftest.a conftest.b 2>&5 || hard_links=no
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
+$as_echo "$hard_links" >&6; }
+ if test "$hard_links" = no; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
+$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+ need_locks=warn
+ fi
+else
+ need_locks=no
+fi
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
+
+ export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ exclude_expsyms_CXX='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
+ case $host_os in
+ aix[4-9]*)
+ # If we're using GNU nm, then we don't want the "-C" option.
+ # -C means demangle to AIX nm, but means don't demangle with GNU nm
+ # Also, AIX nm treats weak defined symbols like other global defined
+ # symbols, whereas GNU nm marks them as "W".
+ if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+ export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ else
+ export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ fi
+ ;;
+ pw32*)
+ export_symbols_cmds_CXX="$ltdll_cmds"
+ ;;
+ cygwin* | mingw* | cegcc*)
+ case $cc_basename in
+ cl*)
+ exclude_expsyms_CXX='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
+ ;;
+ *)
+ export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols'
+ exclude_expsyms_CXX='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'
+ ;;
+ esac
+ ;;
+ linux* | k*bsd*-gnu | gnu*)
+ link_all_deplibs_CXX=no
+ ;;
+ *)
+ export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ ;;
+ esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5
+$as_echo "$ld_shlibs_CXX" >&6; }
+test "$ld_shlibs_CXX" = no && can_build_shared=no
+
+with_gnu_ld_CXX=$with_gnu_ld
+
+
+
+
+
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc_CXX" in
+x|xyes)
+ # Assume -lc should be added
+ archive_cmds_need_lc_CXX=yes
+
+ if test "$enable_shared" = yes && test "$GCC" = yes; then
+ case $archive_cmds_CXX in
+ *'~'*)
+ # FIXME: we may have to deal with multi-command sequences.
+ ;;
+ '$CC '*)
+ # Test whether the compiler implicitly links with -lc since on some
+ # systems, -lgcc has to come before -lc. If gcc already passes -lc
+ # to ld, don't add -lc before -lgcc.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
+$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
+if ${lt_cv_archive_cmds_need_lc_CXX+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ $RM conftest*
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } 2>conftest.err; then
+ soname=conftest
+ lib=conftest
+ libobjs=conftest.$ac_objext
+ deplibs=
+ wl=$lt_prog_compiler_wl_CXX
+ pic_flag=$lt_prog_compiler_pic_CXX
+ compiler_flags=-v
+ linker_flags=-v
+ verstring=
+ output_objdir=.
+ libname=conftest
+ lt_save_allow_undefined_flag=$allow_undefined_flag_CXX
+ allow_undefined_flag_CXX=
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5
+ (eval $archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+ then
+ lt_cv_archive_cmds_need_lc_CXX=no
+ else
+ lt_cv_archive_cmds_need_lc_CXX=yes
+ fi
+ allow_undefined_flag_CXX=$lt_save_allow_undefined_flag
+ else
+ cat conftest.err 1>&5
+ fi
+ $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc_CXX" >&5
+$as_echo "$lt_cv_archive_cmds_need_lc_CXX" >&6; }
+ archive_cmds_need_lc_CXX=$lt_cv_archive_cmds_need_lc_CXX
+ ;;
+ esac
+ fi
+ ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
+$as_echo_n "checking dynamic linker characteristics... " >&6; }
+
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+ shlibpath_var=LIBPATH
+
+ # AIX 3 has no versioning support, so we append a major version to the name.
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+
+aix[4-9]*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ hardcode_into_libs=yes
+ if test "$host_cpu" = ia64; then
+ # AIX 5 supports IA64
+ library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ else
+ # With GCC up to 2.95.x, collect2 would create an import file
+ # for dependence libraries. The import file would start with
+ # the line `#! .'. This would cause the generated library to
+ # depend on `.', always an invalid library. This was fixed in
+ # development snapshots of GCC prior to 3.0.
+ case $host_os in
+ aix4 | aix4.[01] | aix4.[01].*)
+ if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+ echo ' yes '
+ echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+ :
+ else
+ can_build_shared=no
+ fi
+ ;;
+ esac
+ # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+ # soname into executable. Probably we can add versioning support to
+ # collect2, so additional links can be useful in future.
+ if test "$aix_use_runtimelinking" = yes; then
+ # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+ # instead of lib<name>.a to let people know that these are not
+ # typical AIX shared libraries.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ else
+ # We preserve .a as extension for shared libraries through AIX4.2
+ # and later when we are not doing run time linking.
+ library_names_spec='${libname}${release}.a $libname.a'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ fi
+ shlibpath_var=LIBPATH
+ fi
+ ;;
+
+amigaos*)
+ case $host_cpu in
+ powerpc)
+ # Since July 2007 AmigaOS4 officially supports .so libraries.
+ # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ ;;
+ m68k)
+ library_names_spec='$libname.ixlibrary $libname.a'
+ # Create ${libname}_ixlibrary.a entries in /sys/libs.
+ finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+ ;;
+ esac
+ ;;
+
+beos*)
+ library_names_spec='${libname}${shared_ext}'
+ dynamic_linker="$host_os ld.so"
+ shlibpath_var=LIBRARY_PATH
+ ;;
+
+bsdi[45]*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+ sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+ # the default ld.so.conf also contains /usr/contrib/lib and
+ # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+ # libtool to hard-code these into programs
+ ;;
+
+cygwin* | mingw* | pw32* | cegcc*)
+ version_type=windows
+ shrext_cmds=".dll"
+ need_version=no
+ need_lib_prefix=no
+
+ case $GCC,$cc_basename in
+ yes,*)
+ # gcc
+ library_names_spec='$libname.dll.a'
+ # DLL is installed to $(libdir)/../bin by postinstall_cmds
+ postinstall_cmds='base_file=`basename \${file}`~
+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+ dldir=$destdir/`dirname \$dlpath`~
+ test -d \$dldir || mkdir -p \$dldir~
+ $install_prog $dir/$dlname \$dldir/$dlname~
+ chmod a+x \$dldir/$dlname~
+ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+ eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+ fi'
+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+ dlpath=$dir/\$dldll~
+ $RM \$dlpath'
+ shlibpath_overrides_runpath=yes
+
+ case $host_os in
+ cygwin*)
+ # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+ soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+
+ ;;
+ mingw* | cegcc*)
+ # MinGW DLLs use traditional 'lib' prefix
+ soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+ ;;
+ pw32*)
+ # pw32 DLLs use 'pw' prefix rather than 'lib'
+ library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+ ;;
+ esac
+ dynamic_linker='Win32 ld.exe'
+ ;;
+
+ *,cl*)
+ # Native MSVC
+ libname_spec='$name'
+ soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+ library_names_spec='${libname}.dll.lib'
+
+ case $build_os in
+ mingw*)
+ sys_lib_search_path_spec=
+ lt_save_ifs=$IFS
+ IFS=';'
+ for lt_path in $LIB
+ do
+ IFS=$lt_save_ifs
+ # Let DOS variable expansion print the short 8.3 style file name.
+ lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"`
+ sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path"
+ done
+ IFS=$lt_save_ifs
+ # Convert to MSYS style.
+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'`
+ ;;
+ cygwin*)
+ # Convert to unix form, then to dos form, then back to unix form
+ # but this time dos style (no spaces!) so that the unix form looks
+ # like /cygdrive/c/PROGRA~1:/cygdr...
+ sys_lib_search_path_spec=`cygpath --path --unix "$LIB"`
+ sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null`
+ sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ ;;
+ *)
+ sys_lib_search_path_spec="$LIB"
+ if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
+ # It is most probably a Windows format PATH.
+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+ else
+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ fi
+ # FIXME: find the short name or the path components, as spaces are
+ # common. (e.g. "Program Files" -> "PROGRA~1")
+ ;;
+ esac
+
+ # DLL is installed to $(libdir)/../bin by postinstall_cmds
+ postinstall_cmds='base_file=`basename \${file}`~
+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+ dldir=$destdir/`dirname \$dlpath`~
+ test -d \$dldir || mkdir -p \$dldir~
+ $install_prog $dir/$dlname \$dldir/$dlname'
+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+ dlpath=$dir/\$dldll~
+ $RM \$dlpath'
+ shlibpath_overrides_runpath=yes
+ dynamic_linker='Win32 link.exe'
+ ;;
+
+ *)
+ # Assume MSVC wrapper
+ library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+ dynamic_linker='Win32 ld.exe'
+ ;;
+ esac
+ # FIXME: first we should search . and the directory the executable is in
+ shlibpath_var=PATH
+ ;;
+
+darwin* | rhapsody*)
+ dynamic_linker="$host_os dyld"
+ version_type=darwin
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+ soname_spec='${libname}${release}${major}$shared_ext'
+ shlibpath_overrides_runpath=yes
+ shlibpath_var=DYLD_LIBRARY_PATH
+ shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+
+ sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+ ;;
+
+dgux*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+freebsd* | dragonfly*)
+ # DragonFly does not have aout. When/if they implement a new
+ # versioning mechanism, adjust this.
+ if test -x /usr/bin/objformat; then
+ objformat=`/usr/bin/objformat`
+ else
+ case $host_os in
+ freebsd[23].*) objformat=aout ;;
+ *) objformat=elf ;;
+ esac
+ fi
+ version_type=freebsd-$objformat
+ case $version_type in
+ freebsd-elf*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+ need_version=no
+ need_lib_prefix=no
+ ;;
+ freebsd-*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+ need_version=yes
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_os in
+ freebsd2.*)
+ shlibpath_overrides_runpath=yes
+ ;;
+ freebsd3.[01]* | freebsdelf3.[01]*)
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+ freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
+ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+ *) # from 4.6 on, and DragonFly
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+ esac
+ ;;
+
+gnu*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+
+haiku*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ dynamic_linker="$host_os runtime_loader"
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
+ hardcode_into_libs=yes
+ ;;
+
+hpux9* | hpux10* | hpux11*)
+ # Give a soname corresponding to the major version so that dld.sl refuses to
+ # link against other versions.
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ case $host_cpu in
+ ia64*)
+ shrext_cmds='.so'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.so"
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ if test "X$HPUX_IA64_MODE" = X32; then
+ sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+ else
+ sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+ fi
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ hppa*64*)
+ shrext_cmds='.sl'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ *)
+ shrext_cmds='.sl'
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=SHLIB_PATH
+ shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+ esac
+ # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
+ postinstall_cmds='chmod 555 $lib'
+ # or fails outright, so override atomically:
+ install_override_mode=555
+ ;;
+
+interix[3-9]*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+
+irix5* | irix6* | nonstopux*)
+ case $host_os in
+ nonstopux*) version_type=nonstopux ;;
+ *)
+ if test "$lt_cv_prog_gnu_ld" = yes; then
+ version_type=linux # correct to gnu/linux during the next big refactor
+ else
+ version_type=irix
+ fi ;;
+ esac
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+ case $host_os in
+ irix5* | nonstopux*)
+ libsuff= shlibsuff=
+ ;;
+ *)
+ case $LD in # libtool.m4 will add one of these switches to LD
+ *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+ libsuff= shlibsuff= libmagic=32-bit;;
+ *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+ libsuff=32 shlibsuff=N32 libmagic=N32;;
+ *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+ libsuff=64 shlibsuff=64 libmagic=64-bit;;
+ *) libsuff= shlibsuff= libmagic=never-match;;
+ esac
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+ sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+ hardcode_into_libs=yes
+ ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+ dynamic_linker=no
+ ;;
+
+# This must be glibc/ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+
+ # Some binutils ld are patched to set DT_RUNPATH
+ if ${lt_cv_shlibpath_overrides_runpath+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_shlibpath_overrides_runpath=no
+ save_LDFLAGS=$LDFLAGS
+ save_libdir=$libdir
+ eval "libdir=/foo; wl=\"$lt_prog_compiler_wl_CXX\"; \
+ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec_CXX\""
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+ if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then :
+ lt_cv_shlibpath_overrides_runpath=yes
+fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ LDFLAGS=$save_LDFLAGS
+ libdir=$save_libdir
+
+fi
+
+ shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath
+
+ # This implies no fast_install, which is unacceptable.
+ # Some rework will be needed to allow for fast_install
+ # before this can be enabled.
+ hardcode_into_libs=yes
+
+ # Append ld.so.conf contents to the search path
+ if test -f /etc/ld.so.conf; then
+ lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
+ sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+ fi
+
+ # We used to test for /lib/ld.so.1 and disable shared libraries on
+ # powerpc, because MkLinux only supported shared libraries with the
+ # GNU dynamic linker. Since this was broken with cross compilers,
+ # most powerpc-linux boxes support dynamic linking these days and
+ # people can always --disable-shared, the test was removed, and we
+ # assume the GNU/Linux dynamic linker is in use.
+ dynamic_linker='GNU/Linux ld.so'
+ ;;
+
+netbsdelf*-gnu)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ dynamic_linker='NetBSD ld.elf_so'
+ ;;
+
+netbsd*)
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ dynamic_linker='NetBSD (a.out) ld.so'
+ else
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ dynamic_linker='NetBSD ld.elf_so'
+ fi
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+
+newsos6)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ ;;
+
+*nto* | *qnx*)
+ version_type=qnx
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ dynamic_linker='ldqnx.so'
+ ;;
+
+openbsd*)
+ version_type=sunos
+ sys_lib_dlsearch_path_spec="/usr/lib"
+ need_lib_prefix=no
+ # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+ case $host_os in
+ openbsd3.3 | openbsd3.3.*) need_version=yes ;;
+ *) need_version=no ;;
+ esac
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ case $host_os in
+ openbsd2.[89] | openbsd2.[89].*)
+ shlibpath_overrides_runpath=no
+ ;;
+ *)
+ shlibpath_overrides_runpath=yes
+ ;;
+ esac
+ else
+ shlibpath_overrides_runpath=yes
+ fi
+ ;;
+
+os2*)
+ libname_spec='$name'
+ shrext_cmds=".dll"
+ need_lib_prefix=no
+ library_names_spec='$libname${shared_ext} $libname.a'
+ dynamic_linker='OS/2 ld.exe'
+ shlibpath_var=LIBPATH
+ ;;
+
+osf3* | osf4* | osf5*)
+ version_type=osf
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+ sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+ ;;
+
+rdos*)
+ dynamic_linker=no
+ ;;
+
+solaris*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ # ldd complains unless libraries are executable
+ postinstall_cmds='chmod +x $lib'
+ ;;
+
+sunos4*)
+ version_type=sunos
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ if test "$with_gnu_ld" = yes; then
+ need_lib_prefix=no
+ fi
+ need_version=yes
+ ;;
+
+sysv4 | sysv4.3*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_vendor in
+ sni)
+ shlibpath_overrides_runpath=no
+ need_lib_prefix=no
+ runpath_var=LD_RUN_PATH
+ ;;
+ siemens)
+ need_lib_prefix=no
+ ;;
+ motorola)
+ need_lib_prefix=no
+ need_version=no
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+ ;;
+ esac
+ ;;
+
+sysv4*MP*)
+ if test -d /usr/nec ;then
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+ soname_spec='$libname${shared_ext}.$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ fi
+ ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+ version_type=freebsd-elf
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ if test "$with_gnu_ld" = yes; then
+ sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+ else
+ sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+ case $host_os in
+ sco3.2v5*)
+ sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+ ;;
+ esac
+ fi
+ sys_lib_dlsearch_path_spec='/usr/lib'
+ ;;
+
+tpf*)
+ # TPF is a cross-target only. Preferred cross-host = GNU/Linux.
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+
+uts4*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+*)
+ dynamic_linker=no
+ ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
+$as_echo "$dynamic_linker" >&6; }
+test "$dynamic_linker" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+ variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+ sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+fi
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+ sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
+$as_echo_n "checking how to hardcode library paths into programs... " >&6; }
+hardcode_action_CXX=
+if test -n "$hardcode_libdir_flag_spec_CXX" ||
+ test -n "$runpath_var_CXX" ||
+ test "X$hardcode_automatic_CXX" = "Xyes" ; then
+
+ # We can hardcode non-existent directories.
+ if test "$hardcode_direct_CXX" != no &&
+ # If the only mechanism to avoid hardcoding is shlibpath_var, we
+ # have to relink, otherwise we might link with an installed library
+ # when we should be linking with a yet-to-be-installed one
+ ## test "$_LT_TAGVAR(hardcode_shlibpath_var, CXX)" != no &&
+ test "$hardcode_minus_L_CXX" != no; then
+ # Linking always hardcodes the temporary library directory.
+ hardcode_action_CXX=relink
+ else
+ # We can link without hardcoding, and we can hardcode nonexisting dirs.
+ hardcode_action_CXX=immediate
+ fi
+else
+ # We cannot hardcode anything, or else we can only hardcode existing
+ # directories.
+ hardcode_action_CXX=unsupported
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_CXX" >&5
+$as_echo "$hardcode_action_CXX" >&6; }
+
+if test "$hardcode_action_CXX" = relink ||
+ test "$inherit_rpath_CXX" = yes; then
+ # Fast installation is not supported
+ enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+ test "$enable_shared" = no; then
+ # Fast installation is not necessary
+ enable_fast_install=needless
+fi
+
+
+
+
+
+
+
+ fi # test -n "$compiler"
+
+ CC=$lt_save_CC
+ CFLAGS=$lt_save_CFLAGS
+ LDCXX=$LD
+ LD=$lt_save_LD
+ GCC=$lt_save_GCC
+ with_gnu_ld=$lt_save_with_gnu_ld
+ lt_cv_path_LDCXX=$lt_cv_path_LD
+ lt_cv_path_LD=$lt_save_path_LD
+ lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
+ lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
+fi # test "$_lt_caught_CXX_error" != yes
+
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ac_config_commands="$ac_config_commands libtool"
+
+
+
+
+# Only expand once:
+
+
+
+
+# Check whether some low-level functions/files are available
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if ${ac_cv_header_stdc+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_cv_header_stdc=yes
+else
+ ac_cv_header_stdc=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "memchr" >/dev/null 2>&1; then :
+
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "free" >/dev/null 2>&1; then :
+
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+ if test "$cross_compiling" = yes; then :
+ :
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+ (('a' <= (c) && (c) <= 'i') \
+ || ('j' <= (c) && (c) <= 'r') \
+ || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+ int i;
+ for (i = 0; i < 256; i++)
+ if (XOR (islower (i), ISLOWER (i))
+ || toupper (i) != TOUPPER (i))
+ return 2;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_run "$LINENO"; then :
+
+else
+ ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+$as_echo "#define STDC_HEADERS 1" >>confdefs.h
+
+fi
+
+
+# These are tested for by AC_HEADER_STDC, but I check again to set the var
+ac_fn_cxx_check_header_mongrel "$LINENO" "stdint.h" "ac_cv_header_stdint_h" "$ac_includes_default"
+if test "x$ac_cv_header_stdint_h" = xyes; then :
+ ac_cv_have_stdint_h=1
+else
+ ac_cv_have_stdint_h=0
+fi
+
+
+ac_fn_cxx_check_header_mongrel "$LINENO" "sys/types.h" "ac_cv_header_sys_types_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_types_h" = xyes; then :
+ ac_cv_have_systypes_h=1
+else
+ ac_cv_have_systypes_h=0
+fi
+
+
+ac_fn_cxx_check_header_mongrel "$LINENO" "inttypes.h" "ac_cv_header_inttypes_h" "$ac_includes_default"
+if test "x$ac_cv_header_inttypes_h" = xyes; then :
+ ac_cv_have_inttypes_h=1
+else
+ ac_cv_have_inttypes_h=0
+fi
+
+
+for ac_header in unistd.h
+do :
+ ac_fn_cxx_check_header_mongrel "$LINENO" "unistd.h" "ac_cv_header_unistd_h" "$ac_includes_default"
+if test "x$ac_cv_header_unistd_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_UNISTD_H 1
+_ACEOF
+ ac_cv_have_unistd_h=1
+else
+ ac_cv_have_unistd_h=0
+fi
+
+done
+
+for ac_header in syscall.h
+do :
+ ac_fn_cxx_check_header_mongrel "$LINENO" "syscall.h" "ac_cv_header_syscall_h" "$ac_includes_default"
+if test "x$ac_cv_header_syscall_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_SYSCALL_H 1
+_ACEOF
+
+fi
+
+done
+
+for ac_header in sys/syscall.h
+do :
+ ac_fn_cxx_check_header_mongrel "$LINENO" "sys/syscall.h" "ac_cv_header_sys_syscall_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_syscall_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_SYSCALL_H 1
+_ACEOF
+
+fi
+
+done
+
+# For backtrace with glibc.
+for ac_header in execinfo.h
+do :
+ ac_fn_cxx_check_header_mongrel "$LINENO" "execinfo.h" "ac_cv_header_execinfo_h" "$ac_includes_default"
+if test "x$ac_cv_header_execinfo_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_EXECINFO_H 1
+_ACEOF
+
+fi
+
+done
+
+# For backtrace with libunwind.
+for ac_header in libunwind.h
+do :
+ ac_fn_cxx_check_header_mongrel "$LINENO" "libunwind.h" "ac_cv_header_libunwind_h" "$ac_includes_default"
+if test "x$ac_cv_header_libunwind_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBUNWIND_H 1
+_ACEOF
+ ac_cv_have_libunwind_h=1
+else
+ ac_cv_have_libunwind_h=0
+fi
+
+done
+
+for ac_header in ucontext.h
+do :
+ ac_fn_cxx_check_header_mongrel "$LINENO" "ucontext.h" "ac_cv_header_ucontext_h" "$ac_includes_default"
+if test "x$ac_cv_header_ucontext_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_UCONTEXT_H 1
+_ACEOF
+
+fi
+
+done
+
+for ac_header in sys/utsname.h
+do :
+ ac_fn_cxx_check_header_mongrel "$LINENO" "sys/utsname.h" "ac_cv_header_sys_utsname_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_utsname_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_UTSNAME_H 1
+_ACEOF
+
+fi
+
+done
+
+for ac_header in pwd.h
+do :
+ ac_fn_cxx_check_header_mongrel "$LINENO" "pwd.h" "ac_cv_header_pwd_h" "$ac_includes_default"
+if test "x$ac_cv_header_pwd_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_PWD_H 1
+_ACEOF
+
+fi
+
+done
+
+for ac_header in syslog.h
+do :
+ ac_fn_cxx_check_header_mongrel "$LINENO" "syslog.h" "ac_cv_header_syslog_h" "$ac_includes_default"
+if test "x$ac_cv_header_syslog_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_SYSLOG_H 1
+_ACEOF
+
+fi
+
+done
+
+for ac_header in sys/time.h
+do :
+ ac_fn_cxx_check_header_mongrel "$LINENO" "sys/time.h" "ac_cv_header_sys_time_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_time_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_TIME_H 1
+_ACEOF
+
+fi
+
+done
+
+for ac_header in glob.h
+do :
+ ac_fn_cxx_check_header_mongrel "$LINENO" "glob.h" "ac_cv_header_glob_h" "$ac_includes_default"
+if test "x$ac_cv_header_glob_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_GLOB_H 1
+_ACEOF
+
+fi
+
+done
+
+# For backtrace with gcc.
+for ac_header in unwind.h
+do :
+ ac_fn_cxx_check_header_mongrel "$LINENO" "unwind.h" "ac_cv_header_unwind_h" "$ac_includes_default"
+if test "x$ac_cv_header_unwind_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_UNWIND_H 1
+_ACEOF
+
+fi
+
+done
+
+
+ac_fn_cxx_check_header_mongrel "$LINENO" "windows.h" "ac_cv_header_windows_h" "$ac_includes_default"
+if test "x$ac_cv_header_windows_h" = xyes; then :
+ ac_cv_have_windows_h=1
+else
+ ac_cv_have_windows_h=0
+fi
+
+
+if test x"$ac_cv_have_windows_h" = x"1"; then
+ MINGW_CFLAGS=-Isrc/windows
+fi
+
+# The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of void *" >&5
+$as_echo_n "checking size of void *... " >&6; }
+if ${ac_cv_sizeof_void_p+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if ac_fn_cxx_compute_int "$LINENO" "(long int) (sizeof (void *))" "ac_cv_sizeof_void_p" "$ac_includes_default"; then :
+
+else
+ if test "$ac_cv_type_void_p" = yes; then
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "cannot compute sizeof (void *)
+See \`config.log' for more details" "$LINENO" 5; }
+ else
+ ac_cv_sizeof_void_p=0
+ fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_void_p" >&5
+$as_echo "$ac_cv_sizeof_void_p" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_VOID_P $ac_cv_sizeof_void_p
+_ACEOF
+
+
+
+# These are the types I need. We look for them in either stdint.h,
+# sys/types.h, or inttypes.h, all of which are part of the default-includes.
+ac_fn_cxx_check_type "$LINENO" "uint16_t" "ac_cv_type_uint16_t" "$ac_includes_default"
+if test "x$ac_cv_type_uint16_t" = xyes; then :
+ ac_cv_have_uint16_t=1
+else
+ ac_cv_have_uint16_t=0
+fi
+
+ac_fn_cxx_check_type "$LINENO" "u_int16_t" "ac_cv_type_u_int16_t" "$ac_includes_default"
+if test "x$ac_cv_type_u_int16_t" = xyes; then :
+ ac_cv_have_u_int16_t=1
+else
+ ac_cv_have_u_int16_t=0
+fi
+
+ac_fn_cxx_check_type "$LINENO" "__uint16" "ac_cv_type___uint16" "$ac_includes_default"
+if test "x$ac_cv_type___uint16" = xyes; then :
+ ac_cv_have___uint16=1
+else
+ ac_cv_have___uint16=0
+fi
+
+
+ac_fn_cxx_check_func "$LINENO" "sigaltstack" "ac_cv_func_sigaltstack"
+if test "x$ac_cv_func_sigaltstack" = xyes; then :
+
+$as_echo "#define HAVE_SIGALTSTACK 1" >>confdefs.h
+
+fi
+
+ac_fn_cxx_check_func "$LINENO" "sigaction" "ac_cv_func_sigaction"
+if test "x$ac_cv_func_sigaction" = xyes; then :
+
+$as_echo "#define HAVE_SIGACTION 1" >>confdefs.h
+
+fi
+
+ac_fn_cxx_check_func "$LINENO" "dladdr" "ac_cv_func_dladdr"
+if test "x$ac_cv_func_dladdr" = xyes; then :
+
+$as_echo "#define HAVE_DLADDR 1" >>confdefs.h
+
+fi
+
+ac_fn_cxx_check_func "$LINENO" "fcntl" "ac_cv_func_fcntl"
+if test "x$ac_cv_func_fcntl" = xyes; then :
+
+$as_echo "#define HAVE_FCNTL 1" >>confdefs.h
+
+fi
+
+ac_fn_cxx_check_func "$LINENO" "pread" "ac_cv_func_pread"
+if test "x$ac_cv_func_pread" = xyes; then :
+
+$as_echo "#define HAVE_PREAD 1" >>confdefs.h
+
+fi
+
+ac_fn_cxx_check_func "$LINENO" "pwrite" "ac_cv_func_pwrite"
+if test "x$ac_cv_func_pwrite" = xyes; then :
+
+$as_echo "#define HAVE_PWRITE 1" >>confdefs.h
+
+fi
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __attribute__" >&5
+$as_echo_n "checking for __attribute__... " >&6; }
+ if ${ac_cv___attribute__+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdlib.h>
+ static void foo(void) __attribute__ ((unused));
+ void foo(void) { exit(1); }
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_cv___attribute__=yes
+else
+ ac_cv___attribute__=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+ if test "$ac_cv___attribute__" = "yes"; then
+
+$as_echo "#define HAVE___ATTRIBUTE__ 1" >>confdefs.h
+
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv___attribute__" >&5
+$as_echo "$ac_cv___attribute__" >&6; }
+
+# We only care about these two attributes.
+if test x"$ac_cv___attribute__" = x"yes"; then
+ ac_cv___attribute___noreturn="__attribute__ ((noreturn))"
+ ac_cv___attribute___noinline="__attribute__ ((noinline))"
+ ac_cv___attribute___printf_4_5="__attribute__((__format__ (__printf__, 4, 5)))"
+else
+ ac_cv___attribute___noreturn=
+ ac_cv___attribute___noinline=
+ ac_cv___attribute___printf_4_5=
+fi
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_expect" >&5
+$as_echo_n "checking for __builtin_expect... " >&6; }
+ if ${ac_cv___builtin_expect+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+int foo(void) { if (__builtin_expect(0, 0)) return 1; return 0; }
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_cv___builtin_expect=yes
+else
+ ac_cv___builtin_expect=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+ if test "$ac_cv___builtin_expect" = "yes"; then
+
+$as_echo "#define HAVE___BUILTIN_EXPECT 1" >>confdefs.h
+
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv___builtin_expect" >&5
+$as_echo "$ac_cv___builtin_expect" >&6; }
+
+if test x"$ac_cv___builtin_expect" = x"yes"; then
+ ac_cv_have___builtin_expect=1
+else
+ ac_cv_have___builtin_expect=0
+fi
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __sync_val_compare_and_swap" >&5
+$as_echo_n "checking for __sync_val_compare_and_swap... " >&6; }
+ if ${ac_cv___sync_val_compare_and_swap+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+int a; if (__sync_val_compare_and_swap(&a, 0, 1)) return 1; return 0;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+ ac_cv___sync_val_compare_and_swap=yes
+else
+ ac_cv___sync_val_compare_and_swap=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+
+ if test "$ac_cv___sync_val_compare_and_swap" = "yes"; then
+
+$as_echo "#define HAVE___SYNC_VAL_COMPARE_AND_SWAP 1" >>confdefs.h
+
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv___sync_val_compare_and_swap" >&5
+$as_echo "$ac_cv___sync_val_compare_and_swap" >&6; }
+
+
+# On x86_64, instead of libunwind, we can choose to compile with frame-pointers
+# (This isn't needed on i386, where -fno-omit-frame-pointer is the default).
+# Check whether --enable-frame_pointers was given.
+if test "${enable_frame_pointers+set}" = set; then :
+ enableval=$enable_frame_pointers;
+else
+ enable_frame_pointers=no
+fi
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+return __x86_64__ == 1 ? 0 : 1
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ is_x86_64=yes
+else
+ is_x86_64=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ if test "$enable_frame_pointers" = yes; then
+ ENABLE_FRAME_POINTERS_TRUE=
+ ENABLE_FRAME_POINTERS_FALSE='#'
+else
+ ENABLE_FRAME_POINTERS_TRUE='#'
+ ENABLE_FRAME_POINTERS_FALSE=
+fi
+
+ if test "$is_x86_64" = yes; then
+ X86_64_TRUE=
+ X86_64_FALSE='#'
+else
+ X86_64_TRUE='#'
+ X86_64_FALSE=
+fi
+
+
+# Check whether --enable-rtti was given.
+if test "${enable_rtti+set}" = set; then :
+ enableval=$enable_rtti;
+fi
+
+ if test x"$enable_rtti" = x"no"; then
+ DISABLE_RTTI_TRUE=
+ DISABLE_RTTI_FALSE='#'
+else
+ DISABLE_RTTI_TRUE='#'
+ DISABLE_RTTI_FALSE=
+fi
+
+if test x"$enable_rtti" = x"no"; then
+
+$as_echo "#define DISABLE_RTTI 1" >>confdefs.h
+
+fi
+
+# Some of the code in this directory depends on pthreads
+
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+acx_pthread_ok=no
+
+# We used to check for pthread.h first, but this fails if pthread.h
+# requires special compiler flags (e.g. on True64 or Sequent).
+# It gets checked for in the link test anyway.
+
+# First of all, check if the user has set any of the PTHREAD_LIBS,
+# etcetera environment variables, and if threads linking works using
+# them:
+if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+ save_LIBS="$LIBS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS" >&5
+$as_echo_n "checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS... " >&6; }
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char pthread_join ();
+int
+main ()
+{
+return pthread_join ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ acx_pthread_ok=yes
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_pthread_ok" >&5
+$as_echo "$acx_pthread_ok" >&6; }
+ if test x"$acx_pthread_ok" = xno; then
+ PTHREAD_LIBS=""
+ PTHREAD_CFLAGS=""
+ fi
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+fi
+
+# We must check for the threads library under a number of different
+# names; the ordering is very important because some systems
+# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
+# libraries is broken (non-POSIX).
+
+# Create a list of thread flags to try. Items starting with a "-" are
+# C compiler flags, and other items are library names, except for "none"
+# which indicates that we try without any flags at all, and "pthread-config"
+# which is a program returning the flags for the Pth emulation library.
+
+acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
+
+# The ordering *is* (sometimes) important. Some notes on the
+# individual items follow:
+
+# pthreads: AIX (must check this before -lpthread)
+# none: in case threads are in libc; should be tried before -Kthread and
+# other compiler flags to prevent continual compiler warnings
+# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
+# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
+# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
+# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
+# -pthreads: Solaris/gcc
+# -mthreads: Mingw32/gcc, Lynx/gcc
+# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
+# doesn't hurt to check since this sometimes defines pthreads too;
+# also defines -D_REENTRANT)
+# ... -mt is also the pthreads flag for HP/aCC
+# pthread: Linux, etcetera
+# --thread-safe: KAI C++
+# pthread-config: use pthread-config program (for GNU Pth library)
+
+case "${host_cpu}-${host_os}" in
+ *solaris*)
+
+ # On Solaris (at least, for some versions), libc contains stubbed
+ # (non-functional) versions of the pthreads routines, so link-based
+ # tests will erroneously succeed. (We need to link with -pthreads/-mt/
+ # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
+ # a function called by this macro, so we could check for that, but
+ # who knows whether they'll stub that too in a future libc.) So,
+ # we'll just look for -pthreads and -lpthread first:
+
+ acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
+ ;;
+esac
+
+if test x"$acx_pthread_ok" = xno; then
+for flag in $acx_pthread_flags; do
+
+ case $flag in
+ none)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work without any flags" >&5
+$as_echo_n "checking whether pthreads work without any flags... " >&6; }
+ ;;
+
+ -*)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work with $flag" >&5
+$as_echo_n "checking whether pthreads work with $flag... " >&6; }
+ PTHREAD_CFLAGS="$flag"
+ ;;
+
+ pthread-config)
+ # Extract the first word of "pthread-config", so it can be a program name with args.
+set dummy pthread-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_acx_pthread_config+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$acx_pthread_config"; then
+ ac_cv_prog_acx_pthread_config="$acx_pthread_config" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_acx_pthread_config="yes"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+ test -z "$ac_cv_prog_acx_pthread_config" && ac_cv_prog_acx_pthread_config="no"
+fi
+fi
+acx_pthread_config=$ac_cv_prog_acx_pthread_config
+if test -n "$acx_pthread_config"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_pthread_config" >&5
+$as_echo "$acx_pthread_config" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ if test x"$acx_pthread_config" = xno; then continue; fi
+ PTHREAD_CFLAGS="`pthread-config --cflags`"
+ PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
+ ;;
+
+ *)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the pthreads library -l$flag" >&5
+$as_echo_n "checking for the pthreads library -l$flag... " >&6; }
+ PTHREAD_LIBS="-l$flag"
+ ;;
+ esac
+
+ save_LIBS="$LIBS"
+ save_CFLAGS="$CFLAGS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+
+ # Check for various functions. We must include pthread.h,
+ # since some functions may be macros. (On the Sequent, we
+ # need a special flag -Kthread to make this header compile.)
+ # We check for pthread_join because it is in -lpthread on IRIX
+ # while pthread_create is in libc. We check for pthread_attr_init
+ # due to DEC craziness with -lpthreads. We check for
+ # pthread_cleanup_push because it is one of the few pthread
+ # functions on Solaris that doesn't have a non-functional libc stub.
+ # We try pthread_create on general principles.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <pthread.h>
+int
+main ()
+{
+pthread_t th; pthread_join(th, 0);
+ pthread_attr_init(0); pthread_cleanup_push(0, 0);
+ pthread_create(0,0,0,0); pthread_cleanup_pop(0);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ acx_pthread_ok=yes
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_pthread_ok" >&5
+$as_echo "$acx_pthread_ok" >&6; }
+ if test "x$acx_pthread_ok" = xyes; then
+ break;
+ fi
+
+ PTHREAD_LIBS=""
+ PTHREAD_CFLAGS=""
+done
+fi
+
+# Various other checks:
+if test "x$acx_pthread_ok" = xyes; then
+ save_LIBS="$LIBS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+
+ # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for joinable pthread attribute" >&5
+$as_echo_n "checking for joinable pthread attribute... " >&6; }
+ attr_name=unknown
+ for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <pthread.h>
+int
+main ()
+{
+int attr=$attr; return attr;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ attr_name=$attr; break
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ done
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $attr_name" >&5
+$as_echo "$attr_name" >&6; }
+ if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
+
+cat >>confdefs.h <<_ACEOF
+#define PTHREAD_CREATE_JOINABLE $attr_name
+_ACEOF
+
+ fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if more special flags are required for pthreads" >&5
+$as_echo_n "checking if more special flags are required for pthreads... " >&6; }
+ flag=no
+ case "${host_cpu}-${host_os}" in
+ *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
+ *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
+ esac
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${flag}" >&5
+$as_echo "${flag}" >&6; }
+ if test "x$flag" != xno; then
+ PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
+ fi
+
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+ # More AIX lossage: must compile with xlc_r or cc_r
+ if test x"$GCC" != xyes; then
+ for ac_prog in xlc_r cc_r
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_PTHREAD_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$PTHREAD_CC"; then
+ ac_cv_prog_PTHREAD_CC="$PTHREAD_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_PTHREAD_CC="$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+PTHREAD_CC=$ac_cv_prog_PTHREAD_CC
+if test -n "$PTHREAD_CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PTHREAD_CC" >&5
+$as_echo "$PTHREAD_CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$PTHREAD_CC" && break
+done
+test -n "$PTHREAD_CC" || PTHREAD_CC="${CC}"
+
+ else
+ PTHREAD_CC=$CC
+ fi
+
+ # The next part tries to detect GCC inconsistency with -shared on some
+ # architectures and systems. The problem is that in certain
+ # configurations, when -shared is specified, GCC "forgets" to
+ # internally use various flags which are still necessary.
+
+ #
+ # Prepare the flags
+ #
+ save_CFLAGS="$CFLAGS"
+ save_LIBS="$LIBS"
+ save_CC="$CC"
+
+ # Try with the flags determined by the earlier checks.
+ #
+ # -Wl,-z,defs forces link-time symbol resolution, so that the
+ # linking checks with -shared actually have any value
+ #
+ # FIXME: -fPIC is required for -shared on many architectures,
+ # so we specify it here, but the right way would probably be to
+ # properly detect whether it is actually required.
+ CFLAGS="-shared -fPIC -Wl,-z,defs $CFLAGS $PTHREAD_CFLAGS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+ CC="$PTHREAD_CC"
+
+ # In order not to create several levels of indentation, we test
+ # the value of "$done" until we find the cure or run out of ideas.
+ done="no"
+
+ # First, make sure the CFLAGS we added are actually accepted by our
+ # compiler. If not (and OS X's ld, for instance, does not accept -z),
+ # then we can't do this test.
+ if test x"$done" = xno; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to check for GCC pthread/shared inconsistencies" >&5
+$as_echo_n "checking whether to check for GCC pthread/shared inconsistencies... " >&6; }
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+else
+ done=yes
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
+ if test "x$done" = xyes ; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ fi
+ fi
+
+ if test x"$done" = xno; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -pthread is sufficient with -shared" >&5
+$as_echo_n "checking whether -pthread is sufficient with -shared... " >&6; }
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <pthread.h>
+int
+main ()
+{
+pthread_t th; pthread_join(th, 0);
+ pthread_attr_init(0); pthread_cleanup_push(0, 0);
+ pthread_create(0,0,0,0); pthread_cleanup_pop(0);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ done=yes
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
+ if test "x$done" = xyes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ fi
+ fi
+
+ #
+ # Linux gcc on some architectures such as mips/mipsel forgets
+ # about -lpthread
+ #
+ if test x"$done" = xno; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lpthread fixes that" >&5
+$as_echo_n "checking whether -lpthread fixes that... " >&6; }
+ LIBS="-lpthread $PTHREAD_LIBS $save_LIBS"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <pthread.h>
+int
+main ()
+{
+pthread_t th; pthread_join(th, 0);
+ pthread_attr_init(0); pthread_cleanup_push(0, 0);
+ pthread_create(0,0,0,0); pthread_cleanup_pop(0);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ done=yes
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
+ if test "x$done" = xyes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ PTHREAD_LIBS="-lpthread $PTHREAD_LIBS"
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ fi
+ fi
+ #
+ # FreeBSD 4.10 gcc forgets to use -lc_r instead of -lc
+ #
+ if test x"$done" = xno; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc_r fixes that" >&5
+$as_echo_n "checking whether -lc_r fixes that... " >&6; }
+ LIBS="-lc_r $PTHREAD_LIBS $save_LIBS"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <pthread.h>
+int
+main ()
+{
+pthread_t th; pthread_join(th, 0);
+ pthread_attr_init(0); pthread_cleanup_push(0, 0);
+ pthread_create(0,0,0,0); pthread_cleanup_pop(0);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ done=yes
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
+ if test "x$done" = xyes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ PTHREAD_LIBS="-lc_r $PTHREAD_LIBS"
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ fi
+ fi
+ if test x"$done" = xno; then
+ # OK, we have run out of ideas
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Impossible to determine how to use pthreads with shared libraries" >&5
+$as_echo "$as_me: WARNING: Impossible to determine how to use pthreads with shared libraries" >&2;}
+
+ # so it's not safe to assume that we may use pthreads
+ acx_pthread_ok=no
+ fi
+
+ CFLAGS="$save_CFLAGS"
+ LIBS="$save_LIBS"
+ CC="$save_CC"
+else
+ PTHREAD_CC="$CC"
+fi
+
+
+
+
+
+# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
+if test x"$acx_pthread_ok" = xyes; then
+
+$as_echo "#define HAVE_PTHREAD 1" >>confdefs.h
+
+ :
+else
+ acx_pthread_ok=no
+
+fi
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+
+if test x"$acx_pthread_ok" = x"yes"; then
+ # To make libglog depend on libpthread on Linux, we need to add
+ # -lpthread in addition to -pthread.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_self in -lpthread" >&5
+$as_echo_n "checking for pthread_self in -lpthread... " >&6; }
+if ${ac_cv_lib_pthread_pthread_self+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpthread $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char pthread_self ();
+int
+main ()
+{
+return pthread_self ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+ ac_cv_lib_pthread_pthread_self=yes
+else
+ ac_cv_lib_pthread_pthread_self=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_self" >&5
+$as_echo "$ac_cv_lib_pthread_pthread_self" >&6; }
+if test "x$ac_cv_lib_pthread_pthread_self" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBPTHREAD 1
+_ACEOF
+
+ LIBS="-lpthread $LIBS"
+
+fi
+
+fi
+
+# Check if there is google-gflags library installed.
+SAVE_CFLAGS="$CFLAGS"
+SAVE_LIBS="$LIBS"
+
+# Check whether --with-gflags was given.
+if test "${with_gflags+set}" = set; then :
+ withval=$with_gflags; GFLAGS_CFLAGS="-I${with_gflags}/include"
+ GFLAGS_LIBS="-L${with_gflags}/lib -lgflags"
+ CFLAGS="$CFLAGS $GFLAGS_CFLAGS"
+ LIBS="$LIBS $GFLAGS_LIBS"
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lgflags" >&5
+$as_echo_n "checking for main in -lgflags... " >&6; }
+if ${ac_cv_lib_gflags_main+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lgflags $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+
+int
+main ()
+{
+return main ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+ ac_cv_lib_gflags_main=yes
+else
+ ac_cv_lib_gflags_main=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gflags_main" >&5
+$as_echo "$ac_cv_lib_gflags_main" >&6; }
+if test "x$ac_cv_lib_gflags_main" = xyes; then :
+ ac_cv_have_libgflags=1
+else
+ ac_cv_have_libgflags=0
+fi
+
+if test x"$ac_cv_have_libgflags" = x"1"; then
+
+$as_echo "#define HAVE_LIB_GFLAGS 1" >>confdefs.h
+
+ if test x"$GFLAGS_LIBS" = x""; then
+ GFLAGS_LIBS="-lgflags"
+ fi
+else
+ GFLAGS_CFLAGS=
+ GFLAGS_LIBS=
+fi
+CFLAGS="$SAVE_CFLAGS"
+LIBS="$SAVE_LIBS"
+
+# TODO(hamaji): Use official m4 macros provided by testing libraries
+# once the m4 macro of Google Mocking becomes ready.
+# Check if there is Google Test library installed.
+# Extract the first word of "gtest-config", so it can be a program name with args.
+set dummy gtest-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_GTEST_CONFIG+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$GTEST_CONFIG"; then
+ ac_cv_prog_GTEST_CONFIG="$GTEST_CONFIG" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_GTEST_CONFIG=""yes""
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+GTEST_CONFIG=$ac_cv_prog_GTEST_CONFIG
+if test -n "$GTEST_CONFIG"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GTEST_CONFIG" >&5
+$as_echo "$GTEST_CONFIG" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lgtest" >&5
+$as_echo_n "checking for main in -lgtest... " >&6; }
+if ${ac_cv_lib_gtest_main+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lgtest $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+
+int
+main ()
+{
+return main ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+ ac_cv_lib_gtest_main=yes
+else
+ ac_cv_lib_gtest_main=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gtest_main" >&5
+$as_echo "$ac_cv_lib_gtest_main" >&6; }
+if test "x$ac_cv_lib_gtest_main" = xyes; then :
+ have_gtest_lib="yes"
+fi
+
+if test x"$GTEST_CONFIG" = "xyes" -a x"$have_gtest_lib" = "xyes"; then
+ GTEST_CFLAGS=`gtest-config --cppflags --cxxflags`
+ GTEST_LIBS=`gtest-config --ldflags --libs`
+
+$as_echo "#define HAVE_LIB_GTEST 1" >>confdefs.h
+
+
+ # Check if there is Google Mocking library installed.
+ # Extract the first word of "gmock-config", so it can be a program name with args.
+set dummy gmock-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_GMOCK_CONFIG+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$GMOCK_CONFIG"; then
+ ac_cv_prog_GMOCK_CONFIG="$GMOCK_CONFIG" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_GMOCK_CONFIG=""yes""
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+GMOCK_CONFIG=$ac_cv_prog_GMOCK_CONFIG
+if test -n "$GMOCK_CONFIG"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GMOCK_CONFIG" >&5
+$as_echo "$GMOCK_CONFIG" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ if test x"$GMOCK_CONFIG" = "xyes"; then
+ GMOCK_CFLAGS=`gmock-config --cppflags --cxxflags`
+ GMOCK_LIBS=`gmock-config --ldflags --libs`
+
+$as_echo "#define HAVE_LIB_GMOCK 1" >>confdefs.h
+
+ else
+ # We don't run test cases which use Google Mocking framework.
+ GMOCK_CFLAGS=
+ GMOCK_LIBS=
+ fi
+else
+ # We'll use src/googletest.h for our unittests.
+ GTEST_CFLAGS=
+ GTEST_LIBS=
+fi
+ if test x"$GMOCK_CONFIG" = "xyes"; then
+ HAVE_GMOCK_TRUE=
+ HAVE_GMOCK_FALSE='#'
+else
+ HAVE_GMOCK_TRUE='#'
+ HAVE_GMOCK_FALSE=
+fi
+
+
+# We want to link in libunwind if it exists
+UNWIND_LIBS=
+# Unfortunately, we need to check the header file in addition to the
+# lib file to check if libunwind is available since libunwind-0.98
+# doesn't install all necessary header files.
+if test x"$ac_cv_have_libunwind_h" = x"1"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for backtrace in -lunwind" >&5
+$as_echo_n "checking for backtrace in -lunwind... " >&6; }
+if ${ac_cv_lib_unwind_backtrace+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lunwind $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char backtrace ();
+int
+main ()
+{
+return backtrace ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+ ac_cv_lib_unwind_backtrace=yes
+else
+ ac_cv_lib_unwind_backtrace=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_unwind_backtrace" >&5
+$as_echo "$ac_cv_lib_unwind_backtrace" >&6; }
+if test "x$ac_cv_lib_unwind_backtrace" = xyes; then :
+ UNWIND_LIBS=-lunwind
+fi
+
+fi
+
+if test x"$UNWIND_LIBS" != x""; then
+
+$as_echo "#define HAVE_LIB_UNWIND 1" >>confdefs.h
+
+fi
+
+# We'd like to use read/write locks in several places in the code.
+# See if our pthreads support extends to that. Note: for linux, it
+# does as long as you define _XOPEN_SOURCE appropriately.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking support for pthread_rwlock_* functions" >&5
+$as_echo_n "checking support for pthread_rwlock_* functions... " >&6; }
+if ${ac_cv_rwlock+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#define _XOPEN_SOURCE 500
+ #include <pthread.h>
+int
+main ()
+{
+pthread_rwlock_t l; pthread_rwlock_init(&l, NULL);
+ pthread_rwlock_rdlock(&l);
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_rwlock=yes
+else
+ ac_cv_rwlock=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_rwlock" >&5
+$as_echo "$ac_cv_rwlock" >&6; }
+if test "$ac_cv_rwlock" = yes; then
+
+$as_echo "#define HAVE_RWLOCK 1" >>confdefs.h
+
+fi
+
+
+# Find out what namespace 'normal' STL code lives in, and also what namespace
+# the user wants our classes to be defined in
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler implements namespaces" >&5
+$as_echo_n "checking whether the compiler implements namespaces... " >&6; }
+if ${ac_cv_cxx_namespaces+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+namespace Outer {
+ namespace Inner { int i = 0; }}
+int
+main ()
+{
+using namespace Outer::Inner; return i;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_cv_cxx_namespaces=yes
+else
+ ac_cv_cxx_namespaces=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_namespaces" >&5
+$as_echo "$ac_cv_cxx_namespaces" >&6; }
+ if test "$ac_cv_cxx_namespaces" = yes; then
+
+$as_echo "#define HAVE_NAMESPACES 1" >>confdefs.h
+
+ fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking what namespace STL code is in" >&5
+$as_echo_n "checking what namespace STL code is in... " >&6; }
+if ${ac_cv_cxx_stl_namespace+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+
+ ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <vector>
+int
+main ()
+{
+vector<int> t; return 0;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_cv_cxx_stl_namespace=none
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <vector>
+int
+main ()
+{
+std::vector<int> t; return 0;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_cv_cxx_stl_namespace=std
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_stl_namespace" >&5
+$as_echo "$ac_cv_cxx_stl_namespace" >&6; }
+ if test "$ac_cv_cxx_stl_namespace" = none; then
+
+$as_echo "#define STL_NAMESPACE /**/" >>confdefs.h
+
+ fi
+ if test "$ac_cv_cxx_stl_namespace" = std; then
+
+$as_echo "#define STL_NAMESPACE std" >>confdefs.h
+
+ fi
+
+google_namespace_default=google_ns
+ # Check whether --enable-namespace was given.
+if test "${enable_namespace+set}" = set; then :
+ enableval=$enable_namespace; case "$enableval" in
+ yes) google_namespace="$google_namespace_default" ;;
+ no) google_namespace="" ;;
+ *) google_namespace="$enableval" ;;
+ esac
+else
+ google_namespace="$google_namespace_default"
+fi
+
+ if test -n "$google_namespace"; then
+ ac_google_namespace="$google_namespace"
+ ac_google_start_namespace="namespace $google_namespace {"
+ ac_google_end_namespace="}"
+ else
+ ac_google_namespace=""
+ ac_google_start_namespace=""
+ ac_google_end_namespace=""
+ fi
+
+cat >>confdefs.h <<_ACEOF
+#define GOOGLE_NAMESPACE $ac_google_namespace
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define _START_GOOGLE_NAMESPACE_ $ac_google_start_namespace
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define _END_GOOGLE_NAMESPACE_ $ac_google_end_namespace
+_ACEOF
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler supports using ::operator<<" >&5
+$as_echo_n "checking whether compiler supports using ::operator<<... " >&6; }
+if ${ac_cv_cxx_using_operator+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <iostream>
+ std::ostream& operator<<(std::ostream&, struct s);
+int
+main ()
+{
+using ::operator<<; return 0;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_cv_cxx_using_operator=1
+else
+ ac_cv_cxx_using_operator=0
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_using_operator" >&5
+$as_echo "$ac_cv_cxx_using_operator" >&6; }
+ if test "$ac_cv_cxx_using_operator" = 1; then
+
+$as_echo "#define HAVE_USING_OPERATOR 1" >>confdefs.h
+
+ fi
+
+for ac_header in ucontext.h
+do :
+ ac_fn_cxx_check_header_mongrel "$LINENO" "ucontext.h" "ac_cv_header_ucontext_h" "$ac_includes_default"
+if test "x$ac_cv_header_ucontext_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_UCONTEXT_H 1
+_ACEOF
+
+fi
+
+done
+
+ for ac_header in sys/ucontext.h
+do :
+ ac_fn_cxx_check_header_mongrel "$LINENO" "sys/ucontext.h" "ac_cv_header_sys_ucontext_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_ucontext_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_UCONTEXT_H 1
+_ACEOF
+
+fi
+
+done
+ # ucontext on OS X 10.6 (at least)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to access the program counter from a struct ucontext" >&5
+$as_echo_n "checking how to access the program counter from a struct ucontext... " >&6; }
+ pc_fields=" uc_mcontext.gregs[REG_PC]" # Solaris x86 (32 + 64 bit)
+ pc_fields="$pc_fields uc_mcontext.gregs[REG_EIP]" # Linux (i386)
+ pc_fields="$pc_fields uc_mcontext.gregs[REG_RIP]" # Linux (x86_64)
+ pc_fields="$pc_fields uc_mcontext.sc_ip" # Linux (ia64)
+ pc_fields="$pc_fields uc_mcontext.uc_regs->gregs[PT_NIP]" # Linux (ppc)
+ pc_fields="$pc_fields uc_mcontext.gregs[R15]" # Linux (arm old [untested])
+ pc_fields="$pc_fields uc_mcontext.arm_pc" # Linux (arm new [untested])
+ pc_fields="$pc_fields uc_mcontext.mc_eip" # FreeBSD (i386)
+ pc_fields="$pc_fields uc_mcontext.mc_rip" # FreeBSD (x86_64 [untested])
+ pc_fields="$pc_fields uc_mcontext.__gregs[_REG_EIP]" # NetBSD (i386)
+ pc_fields="$pc_fields uc_mcontext.__gregs[_REG_RIP]" # NetBSD (x86_64)
+ pc_fields="$pc_fields uc_mcontext->ss.eip" # OS X (i386, <=10.4)
+ pc_fields="$pc_fields uc_mcontext->__ss.__eip" # OS X (i386, >=10.5)
+ pc_fields="$pc_fields uc_mcontext->ss.rip" # OS X (x86_64)
+ pc_fields="$pc_fields uc_mcontext->__ss.__rip" # OS X (>=10.5 [untested])
+ pc_fields="$pc_fields uc_mcontext->ss.srr0" # OS X (ppc, ppc64 [untested])
+ pc_fields="$pc_fields uc_mcontext->__ss.__srr0" # OS X (>=10.5 [untested])
+ pc_field_found=false
+ for pc_field in $pc_fields; do
+ if ! $pc_field_found; then
+ if test "x$ac_cv_header_sys_ucontext_h" = xyes; then
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#define _GNU_SOURCE 1
+ #include <sys/ucontext.h>
+int
+main ()
+{
+ucontext_t u; return u.$pc_field == 0;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+
+cat >>confdefs.h <<_ACEOF
+#define PC_FROM_UCONTEXT $pc_field
+_ACEOF
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $pc_field" >&5
+$as_echo "$pc_field" >&6; }
+ pc_field_found=true
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#define _GNU_SOURCE 1
+ #include <ucontext.h>
+int
+main ()
+{
+ucontext_t u; return u.$pc_field == 0;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+
+cat >>confdefs.h <<_ACEOF
+#define PC_FROM_UCONTEXT $pc_field
+_ACEOF
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $pc_field" >&5
+$as_echo "$pc_field" >&6; }
+ pc_field_found=true
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ fi
+ fi
+ done
+ if ! $pc_field_found; then
+ pc_fields=" sc_eip" # OpenBSD (i386)
+ pc_fields="$pc_fields sc_rip" # OpenBSD (x86_64)
+ for pc_field in $pc_fields; do
+ if ! $pc_field_found; then
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <signal.h>
+int
+main ()
+{
+ucontext_t u; return u.$pc_field == 0;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+
+cat >>confdefs.h <<_ACEOF
+#define PC_FROM_UCONTEXT $pc_field
+_ACEOF
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $pc_field" >&5
+$as_echo "$pc_field" >&6; }
+ pc_field_found=true
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ fi
+ done
+ fi
+ if ! $pc_field_found; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Could not find the PC. Will not output failed addresses..." >&5
+$as_echo "$as_me: WARNING: Could not find the PC. Will not output failed addresses..." >&2;}
+ fi
+
+
+cat >>confdefs.h <<_ACEOF
+#define TEST_SRC_DIR "$srcdir"
+_ACEOF
+
+
+# These are what's needed by logging.h.in and raw_logging.h.in
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# Write generated configuration file
+ac_config_files="$ac_config_files Makefile src/glog/logging.h src/glog/raw_logging.h src/glog/vlog_is_on.h src/glog/stl_logging.h"
+
+ac_config_files="$ac_config_files libglog.pc"
+
+cat >confcache <<\_ACEOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems. If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+_ACEOF
+
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, we kill variables containing newlines.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(
+ for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
+ eval ac_val=\$$ac_var
+ case $ac_val in #(
+ *${as_nl}*)
+ case $ac_var in #(
+ *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+ esac
+ case $ac_var in #(
+ _ | IFS | as_nl) ;; #(
+ BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+ *) { eval $ac_var=; unset $ac_var;} ;;
+ esac ;;
+ esac
+ done
+
+ (set) 2>&1 |
+ case $as_nl`(ac_space=' '; set) 2>&1` in #(
+ *${as_nl}ac_space=\ *)
+ # `set' does not quote correctly, so add quotes: double-quote
+ # substitution turns \\\\ into \\, and sed turns \\ into \.
+ sed -n \
+ "s/'/'\\\\''/g;
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+ ;; #(
+ *)
+ # `set' quotes correctly as required by POSIX, so do not add quotes.
+ sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+ ;;
+ esac |
+ sort
+) |
+ sed '
+ /^ac_cv_env_/b end
+ t clear
+ :clear
+ s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+ t end
+ s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+ :end' >>confcache
+if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
+ if test -w "$cache_file"; then
+ if test "x$cache_file" != "x/dev/null"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
+$as_echo "$as_me: updating cache $cache_file" >&6;}
+ if test ! -f "$cache_file" || test -h "$cache_file"; then
+ cat confcache >"$cache_file"
+ else
+ case $cache_file in #(
+ */* | ?:*)
+ mv -f confcache "$cache_file"$$ &&
+ mv -f "$cache_file"$$ "$cache_file" ;; #(
+ *)
+ mv -f confcache "$cache_file" ;;
+ esac
+ fi
+ fi
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
+$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
+ fi
+fi
+rm -f confcache
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+DEFS=-DHAVE_CONFIG_H
+
+ac_libobjs=
+ac_ltlibobjs=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+ # 1. Remove the extension, and $U if already installed.
+ ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
+ ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
+ # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR
+ # will be set to the directory where LIBOBJS objects are built.
+ as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
+ as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
+
+LTLIBOBJS=$ac_ltlibobjs
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5
+$as_echo_n "checking that generated files are newer than configure... " >&6; }
+ if test -n "$am_sleep_pid"; then
+ # Hide warnings about reused PIDs.
+ wait $am_sleep_pid 2>/dev/null
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5
+$as_echo "done" >&6; }
+ if test -n "$EXEEXT"; then
+ am__EXEEXT_TRUE=
+ am__EXEEXT_FALSE='#'
+else
+ am__EXEEXT_TRUE='#'
+ am__EXEEXT_FALSE=
+fi
+
+if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
+ as_fn_error $? "conditional \"AMDEP\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
+ as_fn_error $? "conditional \"am__fastdepCC\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then
+ as_fn_error $? "conditional \"am__fastdepCXX\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${GCC_TRUE}" && test -z "${GCC_FALSE}"; then
+ as_fn_error $? "conditional \"GCC\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${ENABLE_FRAME_POINTERS_TRUE}" && test -z "${ENABLE_FRAME_POINTERS_FALSE}"; then
+ as_fn_error $? "conditional \"ENABLE_FRAME_POINTERS\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${X86_64_TRUE}" && test -z "${X86_64_FALSE}"; then
+ as_fn_error $? "conditional \"X86_64\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${DISABLE_RTTI_TRUE}" && test -z "${DISABLE_RTTI_FALSE}"; then
+ as_fn_error $? "conditional \"DISABLE_RTTI\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${HAVE_GMOCK_TRUE}" && test -z "${HAVE_GMOCK_FALSE}"; then
+ as_fn_error $? "conditional \"HAVE_GMOCK\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+
+: "${CONFIG_STATUS=./config.status}"
+ac_write_fail=0
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
+$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
+as_write_fail=0
+cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+
+debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
+
+SHELL=\${CONFIG_SHELL-$SHELL}
+export SHELL
+_ASEOF
+cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+ emulate sh
+ NULLCMD=:
+ # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in #(
+ *posix*) :
+ set -o posix ;; #(
+ *) :
+ ;;
+esac
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+ as_echo='print -r --'
+ as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+ as_echo='printf %s\n'
+ as_echo_n='printf %s'
+else
+ if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+ as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+ as_echo_n='/usr/ucb/echo -n'
+ else
+ as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+ as_echo_n_body='eval
+ arg=$1;
+ case $arg in #(
+ *"$as_nl"*)
+ expr "X$arg" : "X\\(.*\\)$as_nl";
+ arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+ esac;
+ expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+ '
+ export as_echo_n_body
+ as_echo_n='sh -c $as_echo_n_body as_echo'
+ fi
+ export as_echo_body
+ as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ PATH_SEPARATOR=:
+ (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+ (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+ PATH_SEPARATOR=';'
+ }
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order. Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" "" $as_nl"
+
+# Find who we are. Look in the path if we contain no directory separator.
+as_myself=
+case $0 in #((
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+ done
+IFS=$as_save_IFS
+
+ ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+ as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+ $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+ exit 1
+fi
+
+# Unset variables that we do not need and which cause bugs (e.g. in
+# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1"
+# suppresses any "Segmentation fault" message there. '((' could
+# trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset \
+ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+
+# as_fn_error STATUS ERROR [LINENO LOG_FD]
+# ----------------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with STATUS, using 1 if that was 0.
+as_fn_error ()
+{
+ as_status=$1; test $as_status -eq 0 && as_status=1
+ if test "$4"; then
+ as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+ fi
+ $as_echo "$as_me: error: $2" >&2
+ as_fn_exit $as_status
+} # as_fn_error
+
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+ return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+ set +e
+ as_fn_set_status $1
+ exit $1
+} # as_fn_exit
+
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+ { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+ eval 'as_fn_append ()
+ {
+ eval $1+=\$2
+ }'
+else
+ as_fn_append ()
+ {
+ eval $1=\$$1\$2
+ }
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+ eval 'as_fn_arith ()
+ {
+ as_val=$(( $* ))
+ }'
+else
+ as_fn_arith ()
+ {
+ as_val=`expr "$@" || test $? -eq 1`
+ }
+fi # as_fn_arith
+
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+ test "X`expr 00001 : '.*\(...\)'`" = X001; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+ as_dirname=dirname
+else
+ as_dirname=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in #(((((
+-n*)
+ case `echo 'xy\c'` in
+ *c*) ECHO_T=' ';; # ECHO_T is single tab character.
+ xy) ECHO_C='\c';;
+ *) echo `echo ksh88 bug on AIX 6.1` > /dev/null
+ ECHO_T=' ';;
+ esac;;
+*)
+ ECHO_N='-n';;
+esac
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+ rm -f conf$$.dir/conf$$.file
+else
+ rm -f conf$$.dir
+ mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+ if ln -s conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s='ln -s'
+ # ... but there are two gotchas:
+ # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+ # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+ # In both cases, we have to default to `cp -pR'.
+ ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+ as_ln_s='cp -pR'
+ elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+ else
+ as_ln_s='cp -pR'
+ fi
+else
+ as_ln_s='cp -pR'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+ case $as_dir in #(
+ -*) as_dir=./$as_dir;;
+ esac
+ test -d "$as_dir" || eval $as_mkdir_p || {
+ as_dirs=
+ while :; do
+ case $as_dir in #(
+ *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+ *) as_qdir=$as_dir;;
+ esac
+ as_dirs="'$as_qdir' $as_dirs"
+ as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_dir" : 'X\(//\)[^/]' \| \
+ X"$as_dir" : 'X\(//\)$' \| \
+ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ test -d "$as_dir" && break
+ done
+ test -z "$as_dirs" || eval "mkdir $as_dirs"
+ } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p='mkdir -p "$as_dir"'
+else
+ test -d ./-p && rmdir ./-p
+ as_mkdir_p=false
+fi
+
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+ test -f "$1" && test -x "$1"
+} # as_fn_executable_p
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+exec 6>&1
+## ----------------------------------- ##
+## Main body of $CONFIG_STATUS script. ##
+## ----------------------------------- ##
+_ASEOF
+test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# Save the log message, to keep $0 and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling.
+ac_log="
+This file was extended by glog $as_me 0.3.5, which was
+generated by GNU Autoconf 2.69. Invocation command line was
+
+ CONFIG_FILES = $CONFIG_FILES
+ CONFIG_HEADERS = $CONFIG_HEADERS
+ CONFIG_LINKS = $CONFIG_LINKS
+ CONFIG_COMMANDS = $CONFIG_COMMANDS
+ $ $0 $@
+
+on `(hostname || uname -n) 2>/dev/null | sed 1q`
+"
+
+_ACEOF
+
+case $ac_config_files in *"
+"*) set x $ac_config_files; shift; ac_config_files=$*;;
+esac
+
+case $ac_config_headers in *"
+"*) set x $ac_config_headers; shift; ac_config_headers=$*;;
+esac
+
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+# Files that config.status was made for.
+config_files="$ac_config_files"
+config_headers="$ac_config_headers"
+config_commands="$ac_config_commands"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+ac_cs_usage="\
+\`$as_me' instantiates files and other configuration actions
+from templates according to the current configuration. Unless the files
+and actions are specified as TAGs, all are instantiated by default.
+
+Usage: $0 [OPTION]... [TAG]...
+
+ -h, --help print this help, then exit
+ -V, --version print version number and configuration settings, then exit
+ --config print configuration, then exit
+ -q, --quiet, --silent
+ do not print progress messages
+ -d, --debug don't remove temporary files
+ --recheck update $as_me by reconfiguring in the same conditions
+ --file=FILE[:TEMPLATE]
+ instantiate the configuration file FILE
+ --header=FILE[:TEMPLATE]
+ instantiate the configuration header FILE
+
+Configuration files:
+$config_files
+
+Configuration headers:
+$config_headers
+
+Configuration commands:
+$config_commands
+
+Report bugs to <opensource@google.com>."
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
+ac_cs_version="\\
+glog config.status 0.3.5
+configured by $0, generated by GNU Autoconf 2.69,
+ with options \\"\$ac_cs_config\\"
+
+Copyright (C) 2012 Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+
+ac_pwd='$ac_pwd'
+srcdir='$srcdir'
+INSTALL='$INSTALL'
+MKDIR_P='$MKDIR_P'
+AWK='$AWK'
+test -n "\$AWK" || AWK=awk
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# The default lists apply if the user does not specify any file.
+ac_need_defaults=:
+while test $# != 0
+do
+ case $1 in
+ --*=?*)
+ ac_option=`expr "X$1" : 'X\([^=]*\)='`
+ ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
+ ac_shift=:
+ ;;
+ --*=)
+ ac_option=`expr "X$1" : 'X\([^=]*\)='`
+ ac_optarg=
+ ac_shift=:
+ ;;
+ *)
+ ac_option=$1
+ ac_optarg=$2
+ ac_shift=shift
+ ;;
+ esac
+
+ case $ac_option in
+ # Handling of the options.
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+ ac_cs_recheck=: ;;
+ --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
+ $as_echo "$ac_cs_version"; exit ;;
+ --config | --confi | --conf | --con | --co | --c )
+ $as_echo "$ac_cs_config"; exit ;;
+ --debug | --debu | --deb | --de | --d | -d )
+ debug=: ;;
+ --file | --fil | --fi | --f )
+ $ac_shift
+ case $ac_optarg in
+ *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+ '') as_fn_error $? "missing file argument" ;;
+ esac
+ as_fn_append CONFIG_FILES " '$ac_optarg'"
+ ac_need_defaults=false;;
+ --header | --heade | --head | --hea )
+ $ac_shift
+ case $ac_optarg in
+ *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+ esac
+ as_fn_append CONFIG_HEADERS " '$ac_optarg'"
+ ac_need_defaults=false;;
+ --he | --h)
+ # Conflict between --help and --header
+ as_fn_error $? "ambiguous option: \`$1'
+Try \`$0 --help' for more information.";;
+ --help | --hel | -h )
+ $as_echo "$ac_cs_usage"; exit ;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil | --si | --s)
+ ac_cs_silent=: ;;
+
+ # This is an error.
+ -*) as_fn_error $? "unrecognized option: \`$1'
+Try \`$0 --help' for more information." ;;
+
+ *) as_fn_append ac_config_targets " $1"
+ ac_need_defaults=false ;;
+
+ esac
+ shift
+done
+
+ac_configure_extra_args=
+
+if $ac_cs_silent; then
+ exec 6>/dev/null
+ ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+if \$ac_cs_recheck; then
+ set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+ shift
+ \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
+ CONFIG_SHELL='$SHELL'
+ export CONFIG_SHELL
+ exec "\$@"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+exec 5>>config.log
+{
+ echo
+ sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+ $as_echo "$ac_log"
+} >&5
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+#
+# INIT-COMMANDS
+#
+AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"
+
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+sed_quote_subst='$sed_quote_subst'
+double_quote_subst='$double_quote_subst'
+delay_variable_subst='$delay_variable_subst'
+macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`'
+macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`'
+enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`'
+enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`'
+pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`'
+enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`'
+SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`'
+ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`'
+PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`'
+host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`'
+host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`'
+host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`'
+build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`'
+build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`'
+build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`'
+SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`'
+Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`'
+GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`'
+EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`'
+FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`'
+LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`'
+NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`'
+LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`'
+max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`'
+ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`'
+exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`'
+lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`'
+lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`'
+lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`'
+lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`'
+lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`'
+reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`'
+reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`'
+OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`'
+deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`'
+file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`'
+file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`'
+want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`'
+DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`'
+sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`'
+AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`'
+AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`'
+archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`'
+STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`'
+RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`'
+old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`'
+old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`'
+old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`'
+lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`'
+CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`'
+CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`'
+compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`'
+GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`'
+nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`'
+lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`'
+objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`'
+MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`'
+lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`'
+need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`'
+MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`'
+DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`'
+NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`'
+LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`'
+OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`'
+OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`'
+libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`'
+shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`'
+extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`'
+archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`'
+enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`'
+export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`'
+whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`'
+compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`'
+old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`'
+old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`'
+archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`'
+archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`'
+module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`'
+module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`'
+with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`'
+allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`'
+no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`'
+hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`'
+hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`'
+hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`'
+hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`'
+hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`'
+hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`'
+inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`'
+link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`'
+always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`'
+export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`'
+exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`'
+include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`'
+prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`'
+postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`'
+file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`'
+variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`'
+need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`'
+need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`'
+version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`'
+runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`'
+shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`'
+shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`'
+libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`'
+library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`'
+soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`'
+install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`'
+postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`'
+postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`'
+finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`'
+finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`'
+hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`'
+sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`'
+sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`'
+hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`'
+enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`'
+enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`'
+enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`'
+old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`'
+striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`'
+compiler_lib_search_dirs='`$ECHO "$compiler_lib_search_dirs" | $SED "$delay_single_quote_subst"`'
+predep_objects='`$ECHO "$predep_objects" | $SED "$delay_single_quote_subst"`'
+postdep_objects='`$ECHO "$postdep_objects" | $SED "$delay_single_quote_subst"`'
+predeps='`$ECHO "$predeps" | $SED "$delay_single_quote_subst"`'
+postdeps='`$ECHO "$postdeps" | $SED "$delay_single_quote_subst"`'
+compiler_lib_search_path='`$ECHO "$compiler_lib_search_path" | $SED "$delay_single_quote_subst"`'
+LD_CXX='`$ECHO "$LD_CXX" | $SED "$delay_single_quote_subst"`'
+reload_flag_CXX='`$ECHO "$reload_flag_CXX" | $SED "$delay_single_quote_subst"`'
+reload_cmds_CXX='`$ECHO "$reload_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+old_archive_cmds_CXX='`$ECHO "$old_archive_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+compiler_CXX='`$ECHO "$compiler_CXX" | $SED "$delay_single_quote_subst"`'
+GCC_CXX='`$ECHO "$GCC_CXX" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_no_builtin_flag_CXX='`$ECHO "$lt_prog_compiler_no_builtin_flag_CXX" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_pic_CXX='`$ECHO "$lt_prog_compiler_pic_CXX" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_wl_CXX='`$ECHO "$lt_prog_compiler_wl_CXX" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_static_CXX='`$ECHO "$lt_prog_compiler_static_CXX" | $SED "$delay_single_quote_subst"`'
+lt_cv_prog_compiler_c_o_CXX='`$ECHO "$lt_cv_prog_compiler_c_o_CXX" | $SED "$delay_single_quote_subst"`'
+archive_cmds_need_lc_CXX='`$ECHO "$archive_cmds_need_lc_CXX" | $SED "$delay_single_quote_subst"`'
+enable_shared_with_static_runtimes_CXX='`$ECHO "$enable_shared_with_static_runtimes_CXX" | $SED "$delay_single_quote_subst"`'
+export_dynamic_flag_spec_CXX='`$ECHO "$export_dynamic_flag_spec_CXX" | $SED "$delay_single_quote_subst"`'
+whole_archive_flag_spec_CXX='`$ECHO "$whole_archive_flag_spec_CXX" | $SED "$delay_single_quote_subst"`'
+compiler_needs_object_CXX='`$ECHO "$compiler_needs_object_CXX" | $SED "$delay_single_quote_subst"`'
+old_archive_from_new_cmds_CXX='`$ECHO "$old_archive_from_new_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+old_archive_from_expsyms_cmds_CXX='`$ECHO "$old_archive_from_expsyms_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+archive_cmds_CXX='`$ECHO "$archive_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+archive_expsym_cmds_CXX='`$ECHO "$archive_expsym_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+module_cmds_CXX='`$ECHO "$module_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+module_expsym_cmds_CXX='`$ECHO "$module_expsym_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+with_gnu_ld_CXX='`$ECHO "$with_gnu_ld_CXX" | $SED "$delay_single_quote_subst"`'
+allow_undefined_flag_CXX='`$ECHO "$allow_undefined_flag_CXX" | $SED "$delay_single_quote_subst"`'
+no_undefined_flag_CXX='`$ECHO "$no_undefined_flag_CXX" | $SED "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec_CXX='`$ECHO "$hardcode_libdir_flag_spec_CXX" | $SED "$delay_single_quote_subst"`'
+hardcode_libdir_separator_CXX='`$ECHO "$hardcode_libdir_separator_CXX" | $SED "$delay_single_quote_subst"`'
+hardcode_direct_CXX='`$ECHO "$hardcode_direct_CXX" | $SED "$delay_single_quote_subst"`'
+hardcode_direct_absolute_CXX='`$ECHO "$hardcode_direct_absolute_CXX" | $SED "$delay_single_quote_subst"`'
+hardcode_minus_L_CXX='`$ECHO "$hardcode_minus_L_CXX" | $SED "$delay_single_quote_subst"`'
+hardcode_shlibpath_var_CXX='`$ECHO "$hardcode_shlibpath_var_CXX" | $SED "$delay_single_quote_subst"`'
+hardcode_automatic_CXX='`$ECHO "$hardcode_automatic_CXX" | $SED "$delay_single_quote_subst"`'
+inherit_rpath_CXX='`$ECHO "$inherit_rpath_CXX" | $SED "$delay_single_quote_subst"`'
+link_all_deplibs_CXX='`$ECHO "$link_all_deplibs_CXX" | $SED "$delay_single_quote_subst"`'
+always_export_symbols_CXX='`$ECHO "$always_export_symbols_CXX" | $SED "$delay_single_quote_subst"`'
+export_symbols_cmds_CXX='`$ECHO "$export_symbols_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+exclude_expsyms_CXX='`$ECHO "$exclude_expsyms_CXX" | $SED "$delay_single_quote_subst"`'
+include_expsyms_CXX='`$ECHO "$include_expsyms_CXX" | $SED "$delay_single_quote_subst"`'
+prelink_cmds_CXX='`$ECHO "$prelink_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+postlink_cmds_CXX='`$ECHO "$postlink_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+file_list_spec_CXX='`$ECHO "$file_list_spec_CXX" | $SED "$delay_single_quote_subst"`'
+hardcode_action_CXX='`$ECHO "$hardcode_action_CXX" | $SED "$delay_single_quote_subst"`'
+compiler_lib_search_dirs_CXX='`$ECHO "$compiler_lib_search_dirs_CXX" | $SED "$delay_single_quote_subst"`'
+predep_objects_CXX='`$ECHO "$predep_objects_CXX" | $SED "$delay_single_quote_subst"`'
+postdep_objects_CXX='`$ECHO "$postdep_objects_CXX" | $SED "$delay_single_quote_subst"`'
+predeps_CXX='`$ECHO "$predeps_CXX" | $SED "$delay_single_quote_subst"`'
+postdeps_CXX='`$ECHO "$postdeps_CXX" | $SED "$delay_single_quote_subst"`'
+compiler_lib_search_path_CXX='`$ECHO "$compiler_lib_search_path_CXX" | $SED "$delay_single_quote_subst"`'
+
+LTCC='$LTCC'
+LTCFLAGS='$LTCFLAGS'
+compiler='$compiler_DEFAULT'
+
+# A function that is used when there is no print builtin or printf.
+func_fallback_echo ()
+{
+ eval 'cat <<_LTECHO_EOF
+\$1
+_LTECHO_EOF'
+}
+
+# Quote evaled strings.
+for var in SHELL \
+ECHO \
+PATH_SEPARATOR \
+SED \
+GREP \
+EGREP \
+FGREP \
+LD \
+NM \
+LN_S \
+lt_SP2NL \
+lt_NL2SP \
+reload_flag \
+OBJDUMP \
+deplibs_check_method \
+file_magic_cmd \
+file_magic_glob \
+want_nocaseglob \
+DLLTOOL \
+sharedlib_from_linklib_cmd \
+AR \
+AR_FLAGS \
+archiver_list_spec \
+STRIP \
+RANLIB \
+CC \
+CFLAGS \
+compiler \
+lt_cv_sys_global_symbol_pipe \
+lt_cv_sys_global_symbol_to_cdecl \
+lt_cv_sys_global_symbol_to_c_name_address \
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \
+nm_file_list_spec \
+lt_prog_compiler_no_builtin_flag \
+lt_prog_compiler_pic \
+lt_prog_compiler_wl \
+lt_prog_compiler_static \
+lt_cv_prog_compiler_c_o \
+need_locks \
+MANIFEST_TOOL \
+DSYMUTIL \
+NMEDIT \
+LIPO \
+OTOOL \
+OTOOL64 \
+shrext_cmds \
+export_dynamic_flag_spec \
+whole_archive_flag_spec \
+compiler_needs_object \
+with_gnu_ld \
+allow_undefined_flag \
+no_undefined_flag \
+hardcode_libdir_flag_spec \
+hardcode_libdir_separator \
+exclude_expsyms \
+include_expsyms \
+file_list_spec \
+variables_saved_for_relink \
+libname_spec \
+library_names_spec \
+soname_spec \
+install_override_mode \
+finish_eval \
+old_striplib \
+striplib \
+compiler_lib_search_dirs \
+predep_objects \
+postdep_objects \
+predeps \
+postdeps \
+compiler_lib_search_path \
+LD_CXX \
+reload_flag_CXX \
+compiler_CXX \
+lt_prog_compiler_no_builtin_flag_CXX \
+lt_prog_compiler_pic_CXX \
+lt_prog_compiler_wl_CXX \
+lt_prog_compiler_static_CXX \
+lt_cv_prog_compiler_c_o_CXX \
+export_dynamic_flag_spec_CXX \
+whole_archive_flag_spec_CXX \
+compiler_needs_object_CXX \
+with_gnu_ld_CXX \
+allow_undefined_flag_CXX \
+no_undefined_flag_CXX \
+hardcode_libdir_flag_spec_CXX \
+hardcode_libdir_separator_CXX \
+exclude_expsyms_CXX \
+include_expsyms_CXX \
+file_list_spec_CXX \
+compiler_lib_search_dirs_CXX \
+predep_objects_CXX \
+postdep_objects_CXX \
+predeps_CXX \
+postdeps_CXX \
+compiler_lib_search_path_CXX; do
+ case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
+ *[\\\\\\\`\\"\\\$]*)
+ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+ ;;
+ *)
+ eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+ ;;
+ esac
+done
+
+# Double-quote double-evaled strings.
+for var in reload_cmds \
+old_postinstall_cmds \
+old_postuninstall_cmds \
+old_archive_cmds \
+extract_expsyms_cmds \
+old_archive_from_new_cmds \
+old_archive_from_expsyms_cmds \
+archive_cmds \
+archive_expsym_cmds \
+module_cmds \
+module_expsym_cmds \
+export_symbols_cmds \
+prelink_cmds \
+postlink_cmds \
+postinstall_cmds \
+postuninstall_cmds \
+finish_cmds \
+sys_lib_search_path_spec \
+sys_lib_dlsearch_path_spec \
+reload_cmds_CXX \
+old_archive_cmds_CXX \
+old_archive_from_new_cmds_CXX \
+old_archive_from_expsyms_cmds_CXX \
+archive_cmds_CXX \
+archive_expsym_cmds_CXX \
+module_cmds_CXX \
+module_expsym_cmds_CXX \
+export_symbols_cmds_CXX \
+prelink_cmds_CXX \
+postlink_cmds_CXX; do
+ case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
+ *[\\\\\\\`\\"\\\$]*)
+ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+ ;;
+ *)
+ eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+ ;;
+ esac
+done
+
+ac_aux_dir='$ac_aux_dir'
+xsi_shell='$xsi_shell'
+lt_shell_append='$lt_shell_append'
+
+# See if we are running on zsh, and set the options which allow our
+# commands through without removal of \ escapes INIT.
+if test -n "\${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+fi
+
+
+ PACKAGE='$PACKAGE'
+ VERSION='$VERSION'
+ TIMESTAMP='$TIMESTAMP'
+ RM='$RM'
+ ofile='$ofile'
+
+
+
+
+
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+
+# Handling of arguments.
+for ac_config_target in $ac_config_targets
+do
+ case $ac_config_target in
+ "src/config.h") CONFIG_HEADERS="$CONFIG_HEADERS src/config.h" ;;
+ "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
+ "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
+ "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+ "src/glog/logging.h") CONFIG_FILES="$CONFIG_FILES src/glog/logging.h" ;;
+ "src/glog/raw_logging.h") CONFIG_FILES="$CONFIG_FILES src/glog/raw_logging.h" ;;
+ "src/glog/vlog_is_on.h") CONFIG_FILES="$CONFIG_FILES src/glog/vlog_is_on.h" ;;
+ "src/glog/stl_logging.h") CONFIG_FILES="$CONFIG_FILES src/glog/stl_logging.h" ;;
+ "libglog.pc") CONFIG_FILES="$CONFIG_FILES libglog.pc" ;;
+
+ *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
+ esac
+done
+
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used. Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+ test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+ test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
+ test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
+fi
+
+# Have a temporary directory for convenience. Make it in the build tree
+# simply because there is no reason against having it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Hook for its removal unless debugging.
+# Note that there is a small window in which the directory will not be cleaned:
+# after its creation but before its name has been assigned to `$tmp'.
+$debug ||
+{
+ tmp= ac_tmp=
+ trap 'exit_status=$?
+ : "${ac_tmp:=$tmp}"
+ { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
+' 0
+ trap 'as_fn_exit 1' 1 2 13 15
+}
+# Create a (secure) tmp directory for tmp files.
+
+{
+ tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
+ test -d "$tmp"
+} ||
+{
+ tmp=./conf$$-$RANDOM
+ (umask 077 && mkdir "$tmp")
+} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
+ac_tmp=$tmp
+
+# Set up the scripts for CONFIG_FILES section.
+# No need to generate them if there are no CONFIG_FILES.
+# This happens for instance with `./config.status config.h'.
+if test -n "$CONFIG_FILES"; then
+
+
+ac_cr=`echo X | tr X '\015'`
+# On cygwin, bash can eat \r inside `` if the user requested igncr.
+# But we know of no other shell where ac_cr would be empty at this
+# point, so we can use a bashism as a fallback.
+if test "x$ac_cr" = x; then
+ eval ac_cr=\$\'\\r\'
+fi
+ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
+if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
+ ac_cs_awk_cr='\\r'
+else
+ ac_cs_awk_cr=$ac_cr
+fi
+
+echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
+_ACEOF
+
+
+{
+ echo "cat >conf$$subs.awk <<_ACEOF" &&
+ echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
+ echo "_ACEOF"
+} >conf$$subs.sh ||
+ as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
+ac_delim='%!_!# '
+for ac_last_try in false false false false false :; do
+ . ./conf$$subs.sh ||
+ as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+
+ ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
+ if test $ac_delim_n = $ac_delim_num; then
+ break
+ elif $ac_last_try; then
+ as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+ else
+ ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+ fi
+done
+rm -f conf$$subs.sh
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&
+_ACEOF
+sed -n '
+h
+s/^/S["/; s/!.*/"]=/
+p
+g
+s/^[^!]*!//
+:repl
+t repl
+s/'"$ac_delim"'$//
+t delim
+:nl
+h
+s/\(.\{148\}\)..*/\1/
+t more1
+s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
+p
+n
+b repl
+:more1
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t nl
+:delim
+h
+s/\(.\{148\}\)..*/\1/
+t more2
+s/["\\]/\\&/g; s/^/"/; s/$/"/
+p
+b
+:more2
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t delim
+' <conf$$subs.awk | sed '
+/^[^""]/{
+ N
+ s/\n//
+}
+' >>$CONFIG_STATUS || ac_write_fail=1
+rm -f conf$$subs.awk
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+_ACAWK
+cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&
+ for (key in S) S_is_set[key] = 1
+ FS = ""
+
+}
+{
+ line = $ 0
+ nfields = split(line, field, "@")
+ substed = 0
+ len = length(field[1])
+ for (i = 2; i < nfields; i++) {
+ key = field[i]
+ keylen = length(key)
+ if (S_is_set[key]) {
+ value = S[key]
+ line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
+ len += length(value) + length(field[++i])
+ substed = 1
+ } else
+ len += 1 + keylen
+ }
+
+ print line
+}
+
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
+ sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
+else
+ cat
+fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
+ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
+_ACEOF
+
+# VPATH may cause trouble with some makes, so we remove sole $(srcdir),
+# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+ ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{
+h
+s///
+s/^/:/
+s/[ ]*$/:/
+s/:\$(srcdir):/:/g
+s/:\${srcdir}:/:/g
+s/:@srcdir@:/:/g
+s/^:*//
+s/:*$//
+x
+s/\(=[ ]*\).*/\1/
+G
+s/\n//
+s/^[^=]*=[ ]*$//
+}'
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+fi # test -n "$CONFIG_FILES"
+
+# Set up the scripts for CONFIG_HEADERS section.
+# No need to generate them if there are no CONFIG_HEADERS.
+# This happens for instance with `./config.status Makefile'.
+if test -n "$CONFIG_HEADERS"; then
+cat >"$ac_tmp/defines.awk" <<\_ACAWK ||
+BEGIN {
+_ACEOF
+
+# Transform confdefs.h into an awk script `defines.awk', embedded as
+# here-document in config.status, that substitutes the proper values into
+# config.h.in to produce config.h.
+
+# Create a delimiter string that does not exist in confdefs.h, to ease
+# handling of long lines.
+ac_delim='%!_!# '
+for ac_last_try in false false :; do
+ ac_tt=`sed -n "/$ac_delim/p" confdefs.h`
+ if test -z "$ac_tt"; then
+ break
+ elif $ac_last_try; then
+ as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5
+ else
+ ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+ fi
+done
+
+# For the awk script, D is an array of macro values keyed by name,
+# likewise P contains macro parameters if any. Preserve backslash
+# newline sequences.
+
+ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
+sed -n '
+s/.\{148\}/&'"$ac_delim"'/g
+t rset
+:rset
+s/^[ ]*#[ ]*define[ ][ ]*/ /
+t def
+d
+:def
+s/\\$//
+t bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3"/p
+s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p
+d
+:bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3\\\\\\n"\\/p
+t cont
+s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
+t cont
+d
+:cont
+n
+s/.\{148\}/&'"$ac_delim"'/g
+t clear
+:clear
+s/\\$//
+t bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/"/p
+d
+:bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
+b cont
+' <confdefs.h | sed '
+s/'"$ac_delim"'/"\\\
+"/g' >>$CONFIG_STATUS || ac_write_fail=1
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ for (key in D) D_is_set[key] = 1
+ FS = ""
+}
+/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
+ line = \$ 0
+ split(line, arg, " ")
+ if (arg[1] == "#") {
+ defundef = arg[2]
+ mac1 = arg[3]
+ } else {
+ defundef = substr(arg[1], 2)
+ mac1 = arg[2]
+ }
+ split(mac1, mac2, "(") #)
+ macro = mac2[1]
+ prefix = substr(line, 1, index(line, defundef) - 1)
+ if (D_is_set[macro]) {
+ # Preserve the white space surrounding the "#".
+ print prefix "define", macro P[macro] D[macro]
+ next
+ } else {
+ # Replace #undef with comments. This is necessary, for example,
+ # in the case of _POSIX_SOURCE, which is predefined and required
+ # on some systems where configure will not decide to define it.
+ if (defundef == "undef") {
+ print "/*", prefix defundef, macro, "*/"
+ next
+ }
+ }
+}
+{ print }
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+ as_fn_error $? "could not setup config headers machinery" "$LINENO" 5
+fi # test -n "$CONFIG_HEADERS"
+
+
+eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS"
+shift
+for ac_tag
+do
+ case $ac_tag in
+ :[FHLC]) ac_mode=$ac_tag; continue;;
+ esac
+ case $ac_mode$ac_tag in
+ :[FHL]*:*);;
+ :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
+ :[FH]-) ac_tag=-:-;;
+ :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
+ esac
+ ac_save_IFS=$IFS
+ IFS=:
+ set x $ac_tag
+ IFS=$ac_save_IFS
+ shift
+ ac_file=$1
+ shift
+
+ case $ac_mode in
+ :L) ac_source=$1;;
+ :[FH])
+ ac_file_inputs=
+ for ac_f
+ do
+ case $ac_f in
+ -) ac_f="$ac_tmp/stdin";;
+ *) # Look for the file first in the build tree, then in the source tree
+ # (if the path is not absolute). The absolute path cannot be DOS-style,
+ # because $ac_f cannot contain `:'.
+ test -f "$ac_f" ||
+ case $ac_f in
+ [\\/$]*) false;;
+ *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
+ esac ||
+ as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
+ esac
+ case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
+ as_fn_append ac_file_inputs " '$ac_f'"
+ done
+
+ # Let's still pretend it is `configure' which instantiates (i.e., don't
+ # use $as_me), people would be surprised to read:
+ # /* config.h. Generated by config.status. */
+ configure_input='Generated from '`
+ $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
+ `' by configure.'
+ if test x"$ac_file" != x-; then
+ configure_input="$ac_file. $configure_input"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
+$as_echo "$as_me: creating $ac_file" >&6;}
+ fi
+ # Neutralize special characters interpreted by sed in replacement strings.
+ case $configure_input in #(
+ *\&* | *\|* | *\\* )
+ ac_sed_conf_input=`$as_echo "$configure_input" |
+ sed 's/[\\\\&|]/\\\\&/g'`;; #(
+ *) ac_sed_conf_input=$configure_input;;
+ esac
+
+ case $ac_tag in
+ *:-:* | *:-) cat >"$ac_tmp/stdin" \
+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
+ esac
+ ;;
+ esac
+
+ ac_dir=`$as_dirname -- "$ac_file" ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$ac_file" : 'X\(//\)[^/]' \| \
+ X"$ac_file" : 'X\(//\)$' \| \
+ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$ac_file" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ as_dir="$ac_dir"; as_fn_mkdir_p
+ ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+ ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+ # A ".." for each directory in $ac_dir_suffix.
+ ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+ case $ac_top_builddir_sub in
+ "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+ *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+ esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+ .) # We are building in place.
+ ac_srcdir=.
+ ac_top_srcdir=$ac_top_builddir_sub
+ ac_abs_top_srcdir=$ac_pwd ;;
+ [\\/]* | ?:[\\/]* ) # Absolute name.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir
+ ac_abs_top_srcdir=$srcdir ;;
+ *) # Relative name.
+ ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_build_prefix$srcdir
+ ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+
+ case $ac_mode in
+ :F)
+ #
+ # CONFIG_FILE
+ #
+
+ case $INSTALL in
+ [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
+ *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
+ esac
+ ac_MKDIR_P=$MKDIR_P
+ case $MKDIR_P in
+ [\\/$]* | ?:[\\/]* ) ;;
+ */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;;
+ esac
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# If the template does not know about datarootdir, expand it.
+# FIXME: This hack should be removed a few years after 2.60.
+ac_datarootdir_hack=; ac_datarootdir_seen=
+ac_sed_dataroot='
+/datarootdir/ {
+ p
+ q
+}
+/@datadir@/p
+/@docdir@/p
+/@infodir@/p
+/@localedir@/p
+/@mandir@/p'
+case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
+*datarootdir*) ac_datarootdir_seen=yes;;
+*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
+$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ ac_datarootdir_hack='
+ s&@datadir@&$datadir&g
+ s&@docdir@&$docdir&g
+ s&@infodir@&$infodir&g
+ s&@localedir@&$localedir&g
+ s&@mandir@&$mandir&g
+ s&\\\${datarootdir}&$datarootdir&g' ;;
+esac
+_ACEOF
+
+# Neutralize VPATH when `$srcdir' = `.'.
+# Shell code in configure.ac might set extrasub.
+# FIXME: do we really want to maintain this feature?
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_sed_extra="$ac_vpsub
+$extrasub
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s|@configure_input@|$ac_sed_conf_input|;t t
+s&@top_builddir@&$ac_top_builddir_sub&;t t
+s&@top_build_prefix@&$ac_top_build_prefix&;t t
+s&@srcdir@&$ac_srcdir&;t t
+s&@abs_srcdir@&$ac_abs_srcdir&;t t
+s&@top_srcdir@&$ac_top_srcdir&;t t
+s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
+s&@builddir@&$ac_builddir&;t t
+s&@abs_builddir@&$ac_abs_builddir&;t t
+s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
+s&@INSTALL@&$ac_INSTALL&;t t
+s&@MKDIR_P@&$ac_MKDIR_P&;t t
+$ac_datarootdir_hack
+"
+eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
+ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+
+test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
+ { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
+ { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \
+ "$ac_tmp/out"`; test -z "$ac_out"; } &&
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined. Please make sure it is defined" >&5
+$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined. Please make sure it is defined" >&2;}
+
+ rm -f "$ac_tmp/stdin"
+ case $ac_file in
+ -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
+ *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;
+ esac \
+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+ ;;
+ :H)
+ #
+ # CONFIG_HEADER
+ #
+ if test x"$ac_file" != x-; then
+ {
+ $as_echo "/* $configure_input */" \
+ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs"
+ } >"$ac_tmp/config.h" \
+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+ if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
+$as_echo "$as_me: $ac_file is unchanged" >&6;}
+ else
+ rm -f "$ac_file"
+ mv "$ac_tmp/config.h" "$ac_file" \
+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+ fi
+ else
+ $as_echo "/* $configure_input */" \
+ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \
+ || as_fn_error $? "could not create -" "$LINENO" 5
+ fi
+# Compute "$ac_file"'s index in $config_headers.
+_am_arg="$ac_file"
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+ case $_am_header in
+ $_am_arg | $_am_arg:* )
+ break ;;
+ * )
+ _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+ esac
+done
+echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" ||
+$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$_am_arg" : 'X\(//\)[^/]' \| \
+ X"$_am_arg" : 'X\(//\)$' \| \
+ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$_am_arg" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`/stamp-h$_am_stamp_count
+ ;;
+
+ :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5
+$as_echo "$as_me: executing $ac_file commands" >&6;}
+ ;;
+ esac
+
+
+ case $ac_file$ac_mode in
+ "depfiles":C) test x"$AMDEP_TRUE" != x"" || {
+ # Older Autoconf quotes --file arguments for eval, but not when files
+ # are listed without --file. Let's play safe and only enable the eval
+ # if we detect the quoting.
+ case $CONFIG_FILES in
+ *\'*) eval set x "$CONFIG_FILES" ;;
+ *) set x $CONFIG_FILES ;;
+ esac
+ shift
+ for mf
+ do
+ # Strip MF so we end up with the name of the file.
+ mf=`echo "$mf" | sed -e 's/:.*$//'`
+ # Check whether this is an Automake generated Makefile or not.
+ # We used to match only the files named 'Makefile.in', but
+ # some people rename them; so instead we look at the file content.
+ # Grep'ing the first line is not enough: some people post-process
+ # each Makefile.in and add a new line on top of each file to say so.
+ # Grep'ing the whole file is not good either: AIX grep has a line
+ # limit of 2048, but all sed's we know have understand at least 4000.
+ if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
+ dirpart=`$as_dirname -- "$mf" ||
+$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$mf" : 'X\(//\)[^/]' \| \
+ X"$mf" : 'X\(//\)$' \| \
+ X"$mf" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$mf" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ else
+ continue
+ fi
+ # Extract the definition of DEPDIR, am__include, and am__quote
+ # from the Makefile without running 'make'.
+ DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
+ test -z "$DEPDIR" && continue
+ am__include=`sed -n 's/^am__include = //p' < "$mf"`
+ test -z "$am__include" && continue
+ am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
+ # Find all dependency output files, they are included files with
+ # $(DEPDIR) in their names. We invoke sed twice because it is the
+ # simplest approach to changing $(DEPDIR) to its actual value in the
+ # expansion.
+ for file in `sed -n "
+ s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
+ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
+ # Make sure the directory exists.
+ test -f "$dirpart/$file" && continue
+ fdir=`$as_dirname -- "$file" ||
+$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$file" : 'X\(//\)[^/]' \| \
+ X"$file" : 'X\(//\)$' \| \
+ X"$file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$file" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ as_dir=$dirpart/$fdir; as_fn_mkdir_p
+ # echo "creating $dirpart/$file"
+ echo '# dummy' > "$dirpart/$file"
+ done
+ done
+}
+ ;;
+ "libtool":C)
+
+ # See if we are running on zsh, and set the options which allow our
+ # commands through without removal of \ escapes.
+ if test -n "${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+ fi
+
+ cfgfile="${ofile}T"
+ trap "$RM \"$cfgfile\"; exit 1" 1 2 15
+ $RM "$cfgfile"
+
+ cat <<_LT_EOF >> "$cfgfile"
+#! $SHELL
+
+# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+# NOTE: Changes made to this file will be lost: look at ltmain.sh.
+#
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
+# 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
+# Written by Gordon Matzigkeit, 1996
+#
+# This file is part of GNU Libtool.
+#
+# GNU Libtool is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# As a special exception to the GNU General Public License,
+# if you distribute this file as part of a program or library that
+# is built using GNU Libtool, you may include this file under the
+# same distribution terms that you use for the rest of that program.
+#
+# GNU Libtool is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Libtool; see the file COPYING. If not, a copy
+# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
+# obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+
+# The names of the tagged configurations supported by this script.
+available_tags="CXX "
+
+# ### BEGIN LIBTOOL CONFIG
+
+# Which release of libtool.m4 was used?
+macro_version=$macro_version
+macro_revision=$macro_revision
+
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
+
+# Whether or not to build static libraries.
+build_old_libs=$enable_static
+
+# What type of objects to build.
+pic_mode=$pic_mode
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# Shell to use when invoking shell scripts.
+SHELL=$lt_SHELL
+
+# An echo program that protects backslashes.
+ECHO=$lt_ECHO
+
+# The PATH separator for the build system.
+PATH_SEPARATOR=$lt_PATH_SEPARATOR
+
+# The host system.
+host_alias=$host_alias
+host=$host
+host_os=$host_os
+
+# The build system.
+build_alias=$build_alias
+build=$build
+build_os=$build_os
+
+# A sed program that does not truncate output.
+SED=$lt_SED
+
+# Sed that helps us avoid accidentally triggering echo(1) options like -n.
+Xsed="\$SED -e 1s/^X//"
+
+# A grep program that handles long lines.
+GREP=$lt_GREP
+
+# An ERE matcher.
+EGREP=$lt_EGREP
+
+# A literal string matcher.
+FGREP=$lt_FGREP
+
+# A BSD- or MS-compatible name lister.
+NM=$lt_NM
+
+# Whether we need soft or hard links.
+LN_S=$lt_LN_S
+
+# What is the maximum length of a command?
+max_cmd_len=$max_cmd_len
+
+# Object file suffix (normally "o").
+objext=$ac_objext
+
+# Executable file suffix (normally "").
+exeext=$exeext
+
+# whether the shell understands "unset".
+lt_unset=$lt_unset
+
+# turn spaces into newlines.
+SP2NL=$lt_lt_SP2NL
+
+# turn newlines into spaces.
+NL2SP=$lt_lt_NL2SP
+
+# convert \$build file names to \$host format.
+to_host_file_cmd=$lt_cv_to_host_file_cmd
+
+# convert \$build files to toolchain format.
+to_tool_file_cmd=$lt_cv_to_tool_file_cmd
+
+# An object symbol dumper.
+OBJDUMP=$lt_OBJDUMP
+
+# Method to check whether dependent libraries are shared objects.
+deplibs_check_method=$lt_deplibs_check_method
+
+# Command to use when deplibs_check_method = "file_magic".
+file_magic_cmd=$lt_file_magic_cmd
+
+# How to find potential files when deplibs_check_method = "file_magic".
+file_magic_glob=$lt_file_magic_glob
+
+# Find potential files using nocaseglob when deplibs_check_method = "file_magic".
+want_nocaseglob=$lt_want_nocaseglob
+
+# DLL creation program.
+DLLTOOL=$lt_DLLTOOL
+
+# Command to associate shared and link libraries.
+sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd
+
+# The archiver.
+AR=$lt_AR
+
+# Flags to create an archive.
+AR_FLAGS=$lt_AR_FLAGS
+
+# How to feed a file listing to the archiver.
+archiver_list_spec=$lt_archiver_list_spec
+
+# A symbol stripping program.
+STRIP=$lt_STRIP
+
+# Commands used to install an old-style archive.
+RANLIB=$lt_RANLIB
+old_postinstall_cmds=$lt_old_postinstall_cmds
+old_postuninstall_cmds=$lt_old_postuninstall_cmds
+
+# Whether to use a lock for old archive extraction.
+lock_old_archive_extraction=$lock_old_archive_extraction
+
+# A C compiler.
+LTCC=$lt_CC
+
+# LTCC compiler flags.
+LTCFLAGS=$lt_CFLAGS
+
+# Take the output of nm and produce a listing of raw symbols and C names.
+global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration.
+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
+
+# Transform the output of nm in a C name address pair.
+global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
+
+# Transform the output of nm in a C name address pair when lib prefix is needed.
+global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix
+
+# Specify filename containing input files for \$NM.
+nm_file_list_spec=$lt_nm_file_list_spec
+
+# The root where to search for dependent libraries,and in which our libraries should be installed.
+lt_sysroot=$lt_sysroot
+
+# The name of the directory that contains temporary libtool files.
+objdir=$objdir
+
+# Used to examine libraries when file_magic_cmd begins with "file".
+MAGIC_CMD=$MAGIC_CMD
+
+# Must we lock files when doing compilation?
+need_locks=$lt_need_locks
+
+# Manifest tool.
+MANIFEST_TOOL=$lt_MANIFEST_TOOL
+
+# Tool to manipulate archived DWARF debug symbol files on Mac OS X.
+DSYMUTIL=$lt_DSYMUTIL
+
+# Tool to change global to local symbols on Mac OS X.
+NMEDIT=$lt_NMEDIT
+
+# Tool to manipulate fat objects and archives on Mac OS X.
+LIPO=$lt_LIPO
+
+# ldd/readelf like tool for Mach-O binaries on Mac OS X.
+OTOOL=$lt_OTOOL
+
+# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4.
+OTOOL64=$lt_OTOOL64
+
+# Old archive suffix (normally "a").
+libext=$libext
+
+# Shared library suffix (normally ".so").
+shrext_cmds=$lt_shrext_cmds
+
+# The commands to extract the exported symbol list from a shared archive.
+extract_expsyms_cmds=$lt_extract_expsyms_cmds
+
+# Variables whose values should be saved in libtool wrapper scripts and
+# restored at link time.
+variables_saved_for_relink=$lt_variables_saved_for_relink
+
+# Do we need the "lib" prefix for modules?
+need_lib_prefix=$need_lib_prefix
+
+# Do we need a version for libraries?
+need_version=$need_version
+
+# Library versioning type.
+version_type=$version_type
+
+# Shared library runtime path variable.
+runpath_var=$runpath_var
+
+# Shared library path variable.
+shlibpath_var=$shlibpath_var
+
+# Is shlibpath searched before the hard-coded library search path?
+shlibpath_overrides_runpath=$shlibpath_overrides_runpath
+
+# Format of library name prefix.
+libname_spec=$lt_libname_spec
+
+# List of archive names. First name is the real one, the rest are links.
+# The last name is the one that the linker finds with -lNAME
+library_names_spec=$lt_library_names_spec
+
+# The coded name of the library, if different from the real name.
+soname_spec=$lt_soname_spec
+
+# Permission mode override for installation of shared libraries.
+install_override_mode=$lt_install_override_mode
+
+# Command to use after installation of a shared archive.
+postinstall_cmds=$lt_postinstall_cmds
+
+# Command to use after uninstallation of a shared archive.
+postuninstall_cmds=$lt_postuninstall_cmds
+
+# Commands used to finish a libtool library installation in a directory.
+finish_cmds=$lt_finish_cmds
+
+# As "finish_cmds", except a single script fragment to be evaled but
+# not shown.
+finish_eval=$lt_finish_eval
+
+# Whether we should hardcode library paths into libraries.
+hardcode_into_libs=$hardcode_into_libs
+
+# Compile-time system search path for libraries.
+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+
+# Run-time system search path for libraries.
+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
+
+# Whether dlopen is supported.
+dlopen_support=$enable_dlopen
+
+# Whether dlopen of programs is supported.
+dlopen_self=$enable_dlopen_self
+
+# Whether dlopen of statically linked programs is supported.
+dlopen_self_static=$enable_dlopen_self_static
+
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
+
+
+# The linker used to build libraries.
+LD=$lt_LD
+
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag
+reload_cmds=$lt_reload_cmds
+
+# Commands used to build an old-style archive.
+old_archive_cmds=$lt_old_archive_cmds
+
+# A language specific compiler.
+CC=$lt_compiler
+
+# Is the compiler the GNU compiler?
+with_gcc=$GCC
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic
+
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc
+
+# Whether or not to disallow shared libs when runtime libs are static.
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec
+
+# Whether the compiler copes with passing no objects directly.
+compiler_needs_object=$lt_compiler_needs_object
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds
+
+# Commands used to build a shared archive.
+archive_cmds=$lt_archive_cmds
+archive_expsym_cmds=$lt_archive_expsym_cmds
+
+# Commands used to build a loadable module if different from building
+# a shared archive.
+module_cmds=$lt_module_cmds
+module_expsym_cmds=$lt_module_expsym_cmds
+
+# Whether we are building with GNU ld or not.
+with_gnu_ld=$lt_with_gnu_ld
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag
+
+# Flag that enforces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec
+
+# Whether we need a single "-rpath" flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary.
+hardcode_direct=$hardcode_direct
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary and the resulting library dependency is
+# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
+# library is relocated.
+hardcode_direct_absolute=$hardcode_direct_absolute
+
+# Set to "yes" if using the -LDIR flag during linking hardcodes DIR
+# into the resulting binary.
+hardcode_minus_L=$hardcode_minus_L
+
+# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
+# into the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var
+
+# Set to "yes" if building a shared library automatically hardcodes DIR
+# into the library and all subsequent libraries and executables linked
+# against it.
+hardcode_automatic=$hardcode_automatic
+
+# Set to yes if linker adds runtime paths of dependent libraries
+# to runtime path list.
+inherit_rpath=$inherit_rpath
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs
+
+# Set to "yes" if exported symbols are required.
+always_export_symbols=$always_export_symbols
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms
+
+# Commands necessary for linking programs (against libraries) with templates.
+prelink_cmds=$lt_prelink_cmds
+
+# Commands necessary for finishing linking programs.
+postlink_cmds=$lt_postlink_cmds
+
+# Specify filename containing input files.
+file_list_spec=$lt_file_list_spec
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action
+
+# The directories searched by this compiler when creating a shared library.
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs
+
+# Dependencies to place before and after the objects being linked to
+# create a shared library.
+predep_objects=$lt_predep_objects
+postdep_objects=$lt_postdep_objects
+predeps=$lt_predeps
+postdeps=$lt_postdeps
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path
+
+# ### END LIBTOOL CONFIG
+
+_LT_EOF
+
+ case $host_os in
+ aix3*)
+ cat <<\_LT_EOF >> "$cfgfile"
+# AIX sometimes has problems with the GCC collect2 program. For some
+# reason, if we set the COLLECT_NAMES environment variable, the problems
+# vanish in a puff of smoke.
+if test "X${COLLECT_NAMES+set}" != Xset; then
+ COLLECT_NAMES=
+ export COLLECT_NAMES
+fi
+_LT_EOF
+ ;;
+ esac
+
+
+ltmain="$ac_aux_dir/ltmain.sh"
+
+
+ # We use sed instead of cat because bash on DJGPP gets confused if
+ # if finds mixed CR/LF and LF-only lines. Since sed operates in
+ # text mode, it properly converts lines to CR/LF. This bash problem
+ # is reportedly fixed, but why not run on old versions too?
+ sed '$q' "$ltmain" >> "$cfgfile" \
+ || (rm -f "$cfgfile"; exit 1)
+
+ if test x"$xsi_shell" = xyes; then
+ sed -e '/^func_dirname ()$/,/^} # func_dirname /c\
+func_dirname ()\
+{\
+\ case ${1} in\
+\ */*) func_dirname_result="${1%/*}${2}" ;;\
+\ * ) func_dirname_result="${3}" ;;\
+\ esac\
+} # Extended-shell func_dirname implementation' "$cfgfile" > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+ sed -e '/^func_basename ()$/,/^} # func_basename /c\
+func_basename ()\
+{\
+\ func_basename_result="${1##*/}"\
+} # Extended-shell func_basename implementation' "$cfgfile" > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+ sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\
+func_dirname_and_basename ()\
+{\
+\ case ${1} in\
+\ */*) func_dirname_result="${1%/*}${2}" ;;\
+\ * ) func_dirname_result="${3}" ;;\
+\ esac\
+\ func_basename_result="${1##*/}"\
+} # Extended-shell func_dirname_and_basename implementation' "$cfgfile" > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+ sed -e '/^func_stripname ()$/,/^} # func_stripname /c\
+func_stripname ()\
+{\
+\ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are\
+\ # positional parameters, so assign one to ordinary parameter first.\
+\ func_stripname_result=${3}\
+\ func_stripname_result=${func_stripname_result#"${1}"}\
+\ func_stripname_result=${func_stripname_result%"${2}"}\
+} # Extended-shell func_stripname implementation' "$cfgfile" > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+ sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\
+func_split_long_opt ()\
+{\
+\ func_split_long_opt_name=${1%%=*}\
+\ func_split_long_opt_arg=${1#*=}\
+} # Extended-shell func_split_long_opt implementation' "$cfgfile" > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+ sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\
+func_split_short_opt ()\
+{\
+\ func_split_short_opt_arg=${1#??}\
+\ func_split_short_opt_name=${1%"$func_split_short_opt_arg"}\
+} # Extended-shell func_split_short_opt implementation' "$cfgfile" > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+ sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\
+func_lo2o ()\
+{\
+\ case ${1} in\
+\ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\
+\ *) func_lo2o_result=${1} ;;\
+\ esac\
+} # Extended-shell func_lo2o implementation' "$cfgfile" > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+ sed -e '/^func_xform ()$/,/^} # func_xform /c\
+func_xform ()\
+{\
+ func_xform_result=${1%.*}.lo\
+} # Extended-shell func_xform implementation' "$cfgfile" > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+ sed -e '/^func_arith ()$/,/^} # func_arith /c\
+func_arith ()\
+{\
+ func_arith_result=$(( $* ))\
+} # Extended-shell func_arith implementation' "$cfgfile" > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+ sed -e '/^func_len ()$/,/^} # func_len /c\
+func_len ()\
+{\
+ func_len_result=${#1}\
+} # Extended-shell func_len implementation' "$cfgfile" > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+fi
+
+if test x"$lt_shell_append" = xyes; then
+ sed -e '/^func_append ()$/,/^} # func_append /c\
+func_append ()\
+{\
+ eval "${1}+=\\${2}"\
+} # Extended-shell func_append implementation' "$cfgfile" > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+ sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\
+func_append_quoted ()\
+{\
+\ func_quote_for_eval "${2}"\
+\ eval "${1}+=\\\\ \\$func_quote_for_eval_result"\
+} # Extended-shell func_append_quoted implementation' "$cfgfile" > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+ # Save a `func_append' function call where possible by direct use of '+='
+ sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+ test 0 -eq $? || _lt_function_replace_fail=:
+else
+ # Save a `func_append' function call even when '+=' is not available
+ sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+ test 0 -eq $? || _lt_function_replace_fail=:
+fi
+
+if test x"$_lt_function_replace_fail" = x":"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile" >&5
+$as_echo "$as_me: WARNING: Unable to substitute extended shell functions in $ofile" >&2;}
+fi
+
+
+ mv -f "$cfgfile" "$ofile" ||
+ (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
+ chmod +x "$ofile"
+
+
+ cat <<_LT_EOF >> "$ofile"
+
+# ### BEGIN LIBTOOL TAG CONFIG: CXX
+
+# The linker used to build libraries.
+LD=$lt_LD_CXX
+
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag_CXX
+reload_cmds=$lt_reload_cmds_CXX
+
+# Commands used to build an old-style archive.
+old_archive_cmds=$lt_old_archive_cmds_CXX
+
+# A language specific compiler.
+CC=$lt_compiler_CXX
+
+# Is the compiler the GNU compiler?
+with_gcc=$GCC_CXX
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic_CXX
+
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl_CXX
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static_CXX
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc_CXX
+
+# Whether or not to disallow shared libs when runtime libs are static.
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX
+
+# Whether the compiler copes with passing no objects directly.
+compiler_needs_object=$lt_compiler_needs_object_CXX
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX
+
+# Commands used to build a shared archive.
+archive_cmds=$lt_archive_cmds_CXX
+archive_expsym_cmds=$lt_archive_expsym_cmds_CXX
+
+# Commands used to build a loadable module if different from building
+# a shared archive.
+module_cmds=$lt_module_cmds_CXX
+module_expsym_cmds=$lt_module_expsym_cmds_CXX
+
+# Whether we are building with GNU ld or not.
+with_gnu_ld=$lt_with_gnu_ld_CXX
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag_CXX
+
+# Flag that enforces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag_CXX
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX
+
+# Whether we need a single "-rpath" flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary.
+hardcode_direct=$hardcode_direct_CXX
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary and the resulting library dependency is
+# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
+# library is relocated.
+hardcode_direct_absolute=$hardcode_direct_absolute_CXX
+
+# Set to "yes" if using the -LDIR flag during linking hardcodes DIR
+# into the resulting binary.
+hardcode_minus_L=$hardcode_minus_L_CXX
+
+# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
+# into the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX
+
+# Set to "yes" if building a shared library automatically hardcodes DIR
+# into the library and all subsequent libraries and executables linked
+# against it.
+hardcode_automatic=$hardcode_automatic_CXX
+
+# Set to yes if linker adds runtime paths of dependent libraries
+# to runtime path list.
+inherit_rpath=$inherit_rpath_CXX
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs_CXX
+
+# Set to "yes" if exported symbols are required.
+always_export_symbols=$always_export_symbols_CXX
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds_CXX
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms_CXX
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms_CXX
+
+# Commands necessary for linking programs (against libraries) with templates.
+prelink_cmds=$lt_prelink_cmds_CXX
+
+# Commands necessary for finishing linking programs.
+postlink_cmds=$lt_postlink_cmds_CXX
+
+# Specify filename containing input files.
+file_list_spec=$lt_file_list_spec_CXX
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action_CXX
+
+# The directories searched by this compiler when creating a shared library.
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_CXX
+
+# Dependencies to place before and after the objects being linked to
+# create a shared library.
+predep_objects=$lt_predep_objects_CXX
+postdep_objects=$lt_postdep_objects_CXX
+predeps=$lt_predeps_CXX
+postdeps=$lt_postdeps_CXX
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path_CXX
+
+# ### END LIBTOOL TAG CONFIG: CXX
+_LT_EOF
+
+ ;;
+
+ esac
+done # for ac_tag
+
+
+as_fn_exit 0
+_ACEOF
+ac_clean_files=$ac_clean_files_save
+
+test $ac_write_fail = 0 ||
+ as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
+
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded. So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status. When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+ ac_cs_success=:
+ ac_config_status_args=
+ test "$silent" = yes &&
+ ac_config_status_args="$ac_config_status_args --quiet"
+ exec 5>/dev/null
+ $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
+ exec 5>>config.log
+ # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+ # would make configure fail if this is the last instruction.
+ $ac_cs_success || as_fn_exit 1
+fi
+if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
+$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
+fi
+
diff --git a/thirdparty/glog/glog-0.3.4/configure.ac b/thirdparty/glog/glog-0.3.5/configure.ac
index 5e89a69..4c9a678 100644
--- a/thirdparty/glog/glog-0.3.4/configure.ac
+++ b/thirdparty/glog/glog-0.3.5/configure.ac
@@ -5,7 +5,7 @@
# make sure we're interpreted by some minimal autoconf
AC_PREREQ(2.57)
-AC_INIT(glog, 0.3.4, opensource@google.com)
+AC_INIT(glog, 0.3.5, opensource@google.com)
# The argument here is just something that should be in the current directory
# (for sanity checking)
AC_CONFIG_SRCDIR(README)
diff --git a/thirdparty/glog/glog-0.3.5/depcomp b/thirdparty/glog/glog-0.3.5/depcomp
new file mode 100644
index 0000000..e5f9736
--- /dev/null
+++ b/thirdparty/glog/glog-0.3.5/depcomp
@@ -0,0 +1,589 @@
+#! /bin/sh
+# depcomp - compile a program generating dependencies as side-effects
+
+scriptversion=2007-03-29.01
+
+# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007 Free Software
+# Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
+
+case $1 in
+ '')
+ echo "$0: No command. Try \`$0 --help' for more information." 1>&2
+ exit 1;
+ ;;
+ -h | --h*)
+ cat <<\EOF
+Usage: depcomp [--help] [--version] PROGRAM [ARGS]
+
+Run PROGRAMS ARGS to compile a file, generating dependencies
+as side-effects.
+
+Environment variables:
+ depmode Dependency tracking mode.
+ source Source file read by `PROGRAMS ARGS'.
+ object Object file output by `PROGRAMS ARGS'.
+ DEPDIR directory where to store dependencies.
+ depfile Dependency file to output.
+ tmpdepfile Temporary file to use when outputing dependencies.
+ libtool Whether libtool is used (yes/no).
+
+Report bugs to <bug-automake@gnu.org>.
+EOF
+ exit $?
+ ;;
+ -v | --v*)
+ echo "depcomp $scriptversion"
+ exit $?
+ ;;
+esac
+
+if test -z "$depmode" || test -z "$source" || test -z "$object"; then
+ echo "depcomp: Variables source, object and depmode must be set" 1>&2
+ exit 1
+fi
+
+# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
+depfile=${depfile-`echo "$object" |
+ sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
+tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
+
+rm -f "$tmpdepfile"
+
+# Some modes work just like other modes, but use different flags. We
+# parameterize here, but still list the modes in the big case below,
+# to make depend.m4 easier to write. Note that we *cannot* use a case
+# here, because this file can only contain one case statement.
+if test "$depmode" = hp; then
+ # HP compiler uses -M and no extra arg.
+ gccflag=-M
+ depmode=gcc
+fi
+
+if test "$depmode" = dashXmstdout; then
+ # This is just like dashmstdout with a different argument.
+ dashmflag=-xM
+ depmode=dashmstdout
+fi
+
+case "$depmode" in
+gcc3)
+## gcc 3 implements dependency tracking that does exactly what
+## we want. Yay! Note: for some reason libtool 1.4 doesn't like
+## it if -MD -MP comes after the -MF stuff. Hmm.
+## Unfortunately, FreeBSD c89 acceptance of flags depends upon
+## the command line argument order; so add the flags where they
+## appear in depend2.am. Note that the slowdown incurred here
+## affects only configure: in makefiles, %FASTDEP% shortcuts this.
+ for arg
+ do
+ case $arg in
+ -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
+ *) set fnord "$@" "$arg" ;;
+ esac
+ shift # fnord
+ shift # $arg
+ done
+ "$@"
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ mv "$tmpdepfile" "$depfile"
+ ;;
+
+gcc)
+## There are various ways to get dependency output from gcc. Here's
+## why we pick this rather obscure method:
+## - Don't want to use -MD because we'd like the dependencies to end
+## up in a subdir. Having to rename by hand is ugly.
+## (We might end up doing this anyway to support other compilers.)
+## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
+## -MM, not -M (despite what the docs say).
+## - Using -M directly means running the compiler twice (even worse
+## than renaming).
+ if test -z "$gccflag"; then
+ gccflag=-MD,
+ fi
+ "$@" -Wp,"$gccflag$tmpdepfile"
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ rm -f "$depfile"
+ echo "$object : \\" > "$depfile"
+ alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
+## The second -e expression handles DOS-style file names with drive letters.
+ sed -e 's/^[^:]*: / /' \
+ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
+## This next piece of magic avoids the `deleted header file' problem.
+## The problem is that when a header file which appears in a .P file
+## is deleted, the dependency causes make to die (because there is
+## typically no way to rebuild the header). We avoid this by adding
+## dummy dependencies for each header file. Too bad gcc doesn't do
+## this for us directly.
+ tr ' ' '
+' < "$tmpdepfile" |
+## Some versions of gcc put a space before the `:'. On the theory
+## that the space means something, we add a space to the output as
+## well.
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly. Breaking it into two sed invocations is a workaround.
+ sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+hp)
+ # This case exists only to let depend.m4 do its work. It works by
+ # looking at the text of this script. This case will never be run,
+ # since it is checked for above.
+ exit 1
+ ;;
+
+sgi)
+ if test "$libtool" = yes; then
+ "$@" "-Wp,-MDupdate,$tmpdepfile"
+ else
+ "$@" -MDupdate "$tmpdepfile"
+ fi
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ rm -f "$depfile"
+
+ if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
+ echo "$object : \\" > "$depfile"
+
+ # Clip off the initial element (the dependent). Don't try to be
+ # clever and replace this with sed code, as IRIX sed won't handle
+ # lines with more than a fixed number of characters (4096 in
+ # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
+ # the IRIX cc adds comments like `#:fec' to the end of the
+ # dependency line.
+ tr ' ' '
+' < "$tmpdepfile" \
+ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
+ tr '
+' ' ' >> $depfile
+ echo >> $depfile
+
+ # The second pass generates a dummy entry for each header file.
+ tr ' ' '
+' < "$tmpdepfile" \
+ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
+ >> $depfile
+ else
+ # The sourcefile does not contain any dependencies, so just
+ # store a dummy comment line, to avoid errors with the Makefile
+ # "include basename.Plo" scheme.
+ echo "#dummy" > "$depfile"
+ fi
+ rm -f "$tmpdepfile"
+ ;;
+
+aix)
+ # The C for AIX Compiler uses -M and outputs the dependencies
+ # in a .u file. In older versions, this file always lives in the
+ # current directory. Also, the AIX compiler puts `$object:' at the
+ # start of each line; $object doesn't have directory information.
+ # Version 6 uses the directory in both cases.
+ dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+ test "x$dir" = "x$object" && dir=
+ base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+ if test "$libtool" = yes; then
+ tmpdepfile1=$dir$base.u
+ tmpdepfile2=$base.u
+ tmpdepfile3=$dir.libs/$base.u
+ "$@" -Wc,-M
+ else
+ tmpdepfile1=$dir$base.u
+ tmpdepfile2=$dir$base.u
+ tmpdepfile3=$dir$base.u
+ "$@" -M
+ fi
+ stat=$?
+
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+ exit $stat
+ fi
+
+ for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+ do
+ test -f "$tmpdepfile" && break
+ done
+ if test -f "$tmpdepfile"; then
+ # Each line is of the form `foo.o: dependent.h'.
+ # Do two passes, one to just change these to
+ # `$object: dependent.h' and one to simply `dependent.h:'.
+ sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
+ # That's a tab and a space in the [].
+ sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+ else
+ # The sourcefile does not contain any dependencies, so just
+ # store a dummy comment line, to avoid errors with the Makefile
+ # "include basename.Plo" scheme.
+ echo "#dummy" > "$depfile"
+ fi
+ rm -f "$tmpdepfile"
+ ;;
+
+icc)
+ # Intel's C compiler understands `-MD -MF file'. However on
+ # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
+ # ICC 7.0 will fill foo.d with something like
+ # foo.o: sub/foo.c
+ # foo.o: sub/foo.h
+ # which is wrong. We want:
+ # sub/foo.o: sub/foo.c
+ # sub/foo.o: sub/foo.h
+ # sub/foo.c:
+ # sub/foo.h:
+ # ICC 7.1 will output
+ # foo.o: sub/foo.c sub/foo.h
+ # and will wrap long lines using \ :
+ # foo.o: sub/foo.c ... \
+ # sub/foo.h ... \
+ # ...
+
+ "$@" -MD -MF "$tmpdepfile"
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ rm -f "$depfile"
+ # Each line is of the form `foo.o: dependent.h',
+ # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
+ # Do two passes, one to just change these to
+ # `$object: dependent.h' and one to simply `dependent.h:'.
+ sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
+ # Some versions of the HPUX 10.20 sed can't process this invocation
+ # correctly. Breaking it into two sed invocations is a workaround.
+ sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
+ sed -e 's/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+hp2)
+ # The "hp" stanza above does not work with aCC (C++) and HP's ia64
+ # compilers, which have integrated preprocessors. The correct option
+ # to use with these is +Maked; it writes dependencies to a file named
+ # 'foo.d', which lands next to the object file, wherever that
+ # happens to be.
+ # Much of this is similar to the tru64 case; see comments there.
+ dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+ test "x$dir" = "x$object" && dir=
+ base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+ if test "$libtool" = yes; then
+ tmpdepfile1=$dir$base.d
+ tmpdepfile2=$dir.libs/$base.d
+ "$@" -Wc,+Maked
+ else
+ tmpdepfile1=$dir$base.d
+ tmpdepfile2=$dir$base.d
+ "$@" +Maked
+ fi
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile1" "$tmpdepfile2"
+ exit $stat
+ fi
+
+ for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
+ do
+ test -f "$tmpdepfile" && break
+ done
+ if test -f "$tmpdepfile"; then
+ sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
+ # Add `dependent.h:' lines.
+ sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
+ else
+ echo "#dummy" > "$depfile"
+ fi
+ rm -f "$tmpdepfile" "$tmpdepfile2"
+ ;;
+
+tru64)
+ # The Tru64 compiler uses -MD to generate dependencies as a side
+ # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
+ # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
+ # dependencies in `foo.d' instead, so we check for that too.
+ # Subdirectories are respected.
+ dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+ test "x$dir" = "x$object" && dir=
+ base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+
+ if test "$libtool" = yes; then
+ # With Tru64 cc, shared objects can also be used to make a
+ # static library. This mechanism is used in libtool 1.4 series to
+ # handle both shared and static libraries in a single compilation.
+ # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
+ #
+ # With libtool 1.5 this exception was removed, and libtool now
+ # generates 2 separate objects for the 2 libraries. These two
+ # compilations output dependencies in $dir.libs/$base.o.d and
+ # in $dir$base.o.d. We have to check for both files, because
+ # one of the two compilations can be disabled. We should prefer
+ # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
+ # automatically cleaned when .libs/ is deleted, while ignoring
+ # the former would cause a distcleancheck panic.
+ tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
+ tmpdepfile2=$dir$base.o.d # libtool 1.5
+ tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
+ tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
+ "$@" -Wc,-MD
+ else
+ tmpdepfile1=$dir$base.o.d
+ tmpdepfile2=$dir$base.d
+ tmpdepfile3=$dir$base.d
+ tmpdepfile4=$dir$base.d
+ "$@" -MD
+ fi
+
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+ exit $stat
+ fi
+
+ for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+ do
+ test -f "$tmpdepfile" && break
+ done
+ if test -f "$tmpdepfile"; then
+ sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
+ # That's a tab and a space in the [].
+ sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+ else
+ echo "#dummy" > "$depfile"
+ fi
+ rm -f "$tmpdepfile"
+ ;;
+
+#nosideeffect)
+ # This comment above is used by automake to tell side-effect
+ # dependency tracking mechanisms from slower ones.
+
+dashmstdout)
+ # Important note: in order to support this mode, a compiler *must*
+ # always write the preprocessed file to stdout, regardless of -o.
+ "$@" || exit $?
+
+ # Remove the call to Libtool.
+ if test "$libtool" = yes; then
+ while test $1 != '--mode=compile'; do
+ shift
+ done
+ shift
+ fi
+
+ # Remove `-o $object'.
+ IFS=" "
+ for arg
+ do
+ case $arg in
+ -o)
+ shift
+ ;;
+ $object)
+ shift
+ ;;
+ *)
+ set fnord "$@" "$arg"
+ shift # fnord
+ shift # $arg
+ ;;
+ esac
+ done
+
+ test -z "$dashmflag" && dashmflag=-M
+ # Require at least two characters before searching for `:'
+ # in the target name. This is to cope with DOS-style filenames:
+ # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
+ "$@" $dashmflag |
+ sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
+ rm -f "$depfile"
+ cat < "$tmpdepfile" > "$depfile"
+ tr ' ' '
+' < "$tmpdepfile" | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly. Breaking it into two sed invocations is a workaround.
+ sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+dashXmstdout)
+ # This case only exists to satisfy depend.m4. It is never actually
+ # run, as this mode is specially recognized in the preamble.
+ exit 1
+ ;;
+
+makedepend)
+ "$@" || exit $?
+ # Remove any Libtool call
+ if test "$libtool" = yes; then
+ while test $1 != '--mode=compile'; do
+ shift
+ done
+ shift
+ fi
+ # X makedepend
+ shift
+ cleared=no
+ for arg in "$@"; do
+ case $cleared in
+ no)
+ set ""; shift
+ cleared=yes ;;
+ esac
+ case "$arg" in
+ -D*|-I*)
+ set fnord "$@" "$arg"; shift ;;
+ # Strip any option that makedepend may not understand. Remove
+ # the object too, otherwise makedepend will parse it as a source file.
+ -*|$object)
+ ;;
+ *)
+ set fnord "$@" "$arg"; shift ;;
+ esac
+ done
+ obj_suffix="`echo $object | sed 's/^.*\././'`"
+ touch "$tmpdepfile"
+ ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
+ rm -f "$depfile"
+ cat < "$tmpdepfile" > "$depfile"
+ sed '1,2d' "$tmpdepfile" | tr ' ' '
+' | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly. Breaking it into two sed invocations is a workaround.
+ sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile" "$tmpdepfile".bak
+ ;;
+
+cpp)
+ # Important note: in order to support this mode, a compiler *must*
+ # always write the preprocessed file to stdout.
+ "$@" || exit $?
+
+ # Remove the call to Libtool.
+ if test "$libtool" = yes; then
+ while test $1 != '--mode=compile'; do
+ shift
+ done
+ shift
+ fi
+
+ # Remove `-o $object'.
+ IFS=" "
+ for arg
+ do
+ case $arg in
+ -o)
+ shift
+ ;;
+ $object)
+ shift
+ ;;
+ *)
+ set fnord "$@" "$arg"
+ shift # fnord
+ shift # $arg
+ ;;
+ esac
+ done
+
+ "$@" -E |
+ sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
+ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
+ sed '$ s: \\$::' > "$tmpdepfile"
+ rm -f "$depfile"
+ echo "$object : \\" > "$depfile"
+ cat < "$tmpdepfile" >> "$depfile"
+ sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+msvisualcpp)
+ # Important note: in order to support this mode, a compiler *must*
+ # always write the preprocessed file to stdout, regardless of -o,
+ # because we must use -o when running libtool.
+ "$@" || exit $?
+ IFS=" "
+ for arg
+ do
+ case "$arg" in
+ "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
+ set fnord "$@"
+ shift
+ shift
+ ;;
+ *)
+ set fnord "$@" "$arg"
+ shift
+ shift
+ ;;
+ esac
+ done
+ "$@" -E |
+ sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
+ rm -f "$depfile"
+ echo "$object : \\" > "$depfile"
+ . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
+ echo " " >> "$depfile"
+ . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+none)
+ exec "$@"
+ ;;
+
+*)
+ echo "Unknown depmode $depmode" 1>&2
+ exit 1
+ ;;
+esac
+
+exit 0
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/thirdparty/glog/glog-0.3.4/doc/designstyle.css b/thirdparty/glog/glog-0.3.5/doc/designstyle.css
index f5d1ec2..f5d1ec2 100644
--- a/thirdparty/glog/glog-0.3.4/doc/designstyle.css
+++ b/thirdparty/glog/glog-0.3.5/doc/designstyle.css
diff --git a/thirdparty/glog/glog-0.3.4/doc/glog.html b/thirdparty/glog/glog-0.3.5/doc/glog.html
index 8b200ba..8b200ba 100644
--- a/thirdparty/glog/glog-0.3.4/doc/glog.html
+++ b/thirdparty/glog/glog-0.3.5/doc/glog.html
diff --git a/thirdparty/glog/glog-0.3.5/glog-config.cmake.in b/thirdparty/glog/glog-0.3.5/glog-config.cmake.in
new file mode 100644
index 0000000..e3c44ae
--- /dev/null
+++ b/thirdparty/glog/glog-0.3.5/glog-config.cmake.in
@@ -0,0 +1,7 @@
+@PACKAGE_INIT@
+
+include (CMakeFindDependencyMacro)
+
+@gflags_DEPENDENCY@
+
+include ("${CMAKE_CURRENT_LIST_DIR}/glog-targets.cmake")
diff --git a/thirdparty/glog/glog-0.3.4/google-glog.sln b/thirdparty/glog/glog-0.3.5/google-glog.sln
index fb7a4a5..a34ec72 100644
--- a/thirdparty/glog/glog-0.3.4/google-glog.sln
+++ b/thirdparty/glog/glog-0.3.5/google-glog.sln
@@ -1,44 +1,44 @@
-
-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual C++ Express 2008
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libglog", "vsprojects\libglog\libglog.vcproj", "{34BD04BD-BC1D-4BFC-AAFC-ED02D9E960F1}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "logging_unittest", "vsprojects\logging_unittest\logging_unittest.vcproj", "{DD0690AA-5E09-46B5-83FD-4B28604CABA8}"
- ProjectSection(ProjectDependencies) = postProject
- {34BD04BD-BC1D-4BFC-AAFC-ED02D9E960F1} = {34BD04BD-BC1D-4BFC-AAFC-ED02D9E960F1}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libglog_static", "vsprojects\libglog_static\libglog_static.vcproj", "{772C2111-BBBF-49E6-B912-198A7F7A88E5}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "logging_unittest_static", "vsprojects\logging_unittest_static\logging_unittest_static.vcproj", "{9B239B45-84A9-4E06-AC46-8E220CD43974}"
- ProjectSection(ProjectDependencies) = postProject
- {772C2111-BBBF-49E6-B912-198A7F7A88E5} = {772C2111-BBBF-49E6-B912-198A7F7A88E5}
- EndProjectSection
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {34BD04BD-BC1D-4BFC-AAFC-ED02D9E960F1}.Debug|Win32.ActiveCfg = Debug|Win32
- {34BD04BD-BC1D-4BFC-AAFC-ED02D9E960F1}.Debug|Win32.Build.0 = Debug|Win32
- {34BD04BD-BC1D-4BFC-AAFC-ED02D9E960F1}.Release|Win32.ActiveCfg = Release|Win32
- {34BD04BD-BC1D-4BFC-AAFC-ED02D9E960F1}.Release|Win32.Build.0 = Release|Win32
- {DD0690AA-5E09-46B5-83FD-4B28604CABA8}.Debug|Win32.ActiveCfg = Debug|Win32
- {DD0690AA-5E09-46B5-83FD-4B28604CABA8}.Debug|Win32.Build.0 = Debug|Win32
- {DD0690AA-5E09-46B5-83FD-4B28604CABA8}.Release|Win32.ActiveCfg = Release|Win32
- {DD0690AA-5E09-46B5-83FD-4B28604CABA8}.Release|Win32.Build.0 = Release|Win32
- {772C2111-BBBF-49E6-B912-198A7F7A88E5}.Debug|Win32.ActiveCfg = Debug|Win32
- {772C2111-BBBF-49E6-B912-198A7F7A88E5}.Debug|Win32.Build.0 = Debug|Win32
- {772C2111-BBBF-49E6-B912-198A7F7A88E5}.Release|Win32.ActiveCfg = Release|Win32
- {772C2111-BBBF-49E6-B912-198A7F7A88E5}.Release|Win32.Build.0 = Release|Win32
- {9B239B45-84A9-4E06-AC46-8E220CD43974}.Debug|Win32.ActiveCfg = Debug|Win32
- {9B239B45-84A9-4E06-AC46-8E220CD43974}.Debug|Win32.Build.0 = Debug|Win32
- {9B239B45-84A9-4E06-AC46-8E220CD43974}.Release|Win32.ActiveCfg = Release|Win32
- {9B239B45-84A9-4E06-AC46-8E220CD43974}.Release|Win32.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual C++ Express 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libglog", "vsprojects\libglog\libglog.vcproj", "{34BD04BD-BC1D-4BFC-AAFC-ED02D9E960F1}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "logging_unittest", "vsprojects\logging_unittest\logging_unittest.vcproj", "{DD0690AA-5E09-46B5-83FD-4B28604CABA8}"
+ ProjectSection(ProjectDependencies) = postProject
+ {34BD04BD-BC1D-4BFC-AAFC-ED02D9E960F1} = {34BD04BD-BC1D-4BFC-AAFC-ED02D9E960F1}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libglog_static", "vsprojects\libglog_static\libglog_static.vcproj", "{772C2111-BBBF-49E6-B912-198A7F7A88E5}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "logging_unittest_static", "vsprojects\logging_unittest_static\logging_unittest_static.vcproj", "{9B239B45-84A9-4E06-AC46-8E220CD43974}"
+ ProjectSection(ProjectDependencies) = postProject
+ {772C2111-BBBF-49E6-B912-198A7F7A88E5} = {772C2111-BBBF-49E6-B912-198A7F7A88E5}
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {34BD04BD-BC1D-4BFC-AAFC-ED02D9E960F1}.Debug|Win32.ActiveCfg = Debug|Win32
+ {34BD04BD-BC1D-4BFC-AAFC-ED02D9E960F1}.Debug|Win32.Build.0 = Debug|Win32
+ {34BD04BD-BC1D-4BFC-AAFC-ED02D9E960F1}.Release|Win32.ActiveCfg = Release|Win32
+ {34BD04BD-BC1D-4BFC-AAFC-ED02D9E960F1}.Release|Win32.Build.0 = Release|Win32
+ {DD0690AA-5E09-46B5-83FD-4B28604CABA8}.Debug|Win32.ActiveCfg = Debug|Win32
+ {DD0690AA-5E09-46B5-83FD-4B28604CABA8}.Debug|Win32.Build.0 = Debug|Win32
+ {DD0690AA-5E09-46B5-83FD-4B28604CABA8}.Release|Win32.ActiveCfg = Release|Win32
+ {DD0690AA-5E09-46B5-83FD-4B28604CABA8}.Release|Win32.Build.0 = Release|Win32
+ {772C2111-BBBF-49E6-B912-198A7F7A88E5}.Debug|Win32.ActiveCfg = Debug|Win32
+ {772C2111-BBBF-49E6-B912-198A7F7A88E5}.Debug|Win32.Build.0 = Debug|Win32
+ {772C2111-BBBF-49E6-B912-198A7F7A88E5}.Release|Win32.ActiveCfg = Release|Win32
+ {772C2111-BBBF-49E6-B912-198A7F7A88E5}.Release|Win32.Build.0 = Release|Win32
+ {9B239B45-84A9-4E06-AC46-8E220CD43974}.Debug|Win32.ActiveCfg = Debug|Win32
+ {9B239B45-84A9-4E06-AC46-8E220CD43974}.Debug|Win32.Build.0 = Debug|Win32
+ {9B239B45-84A9-4E06-AC46-8E220CD43974}.Release|Win32.ActiveCfg = Release|Win32
+ {9B239B45-84A9-4E06-AC46-8E220CD43974}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/thirdparty/glog/glog-0.3.5/install-sh b/thirdparty/glog/glog-0.3.5/install-sh
new file mode 100644
index 0000000..a5897de
--- /dev/null
+++ b/thirdparty/glog/glog-0.3.5/install-sh
@@ -0,0 +1,519 @@
+#!/bin/sh
+# install - install a program, script, or datafile
+
+scriptversion=2006-12-25.00
+
+# This originates from X11R5 (mit/util/scripts/install.sh), which was
+# later released in X11R6 (xc/config/util/install.sh) with the
+# following copyright and license.
+#
+# Copyright (C) 1994 X Consortium
+#
+# 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
+# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
+# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name of the X Consortium shall not
+# be used in advertising or otherwise to promote the sale, use or other deal-
+# ings in this Software without prior written authorization from the X Consor-
+# tium.
+#
+#
+# FSF changes to this file are in the public domain.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.
+
+nl='
+'
+IFS=" "" $nl"
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit=${DOITPROG-}
+if test -z "$doit"; then
+ doit_exec=exec
+else
+ doit_exec=$doit
+fi
+
+# Put in absolute file names if you don't have them in your path;
+# or use environment vars.
+
+chgrpprog=${CHGRPPROG-chgrp}
+chmodprog=${CHMODPROG-chmod}
+chownprog=${CHOWNPROG-chown}
+cmpprog=${CMPPROG-cmp}
+cpprog=${CPPROG-cp}
+mkdirprog=${MKDIRPROG-mkdir}
+mvprog=${MVPROG-mv}
+rmprog=${RMPROG-rm}
+stripprog=${STRIPPROG-strip}
+
+posix_glob='?'
+initialize_posix_glob='
+ test "$posix_glob" != "?" || {
+ if (set -f) 2>/dev/null; then
+ posix_glob=
+ else
+ posix_glob=:
+ fi
+ }
+'
+
+posix_mkdir=
+
+# Desired mode of installed file.
+mode=0755
+
+chgrpcmd=
+chmodcmd=$chmodprog
+chowncmd=
+mvcmd=$mvprog
+rmcmd="$rmprog -f"
+stripcmd=
+
+src=
+dst=
+dir_arg=
+dst_arg=
+
+copy_on_change=false
+no_target_directory=
+
+usage="\
+Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
+ or: $0 [OPTION]... SRCFILES... DIRECTORY
+ or: $0 [OPTION]... -t DIRECTORY SRCFILES...
+ or: $0 [OPTION]... -d DIRECTORIES...
+
+In the 1st form, copy SRCFILE to DSTFILE.
+In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
+In the 4th, create DIRECTORIES.
+
+Options:
+ --help display this help and exit.
+ --version display version info and exit.
+
+ -c (ignored)
+ -C install only if different (preserve the last data modification time)
+ -d create directories instead of installing files.
+ -g GROUP $chgrpprog installed files to GROUP.
+ -m MODE $chmodprog installed files to MODE.
+ -o USER $chownprog installed files to USER.
+ -s $stripprog installed files.
+ -t DIRECTORY install into DIRECTORY.
+ -T report an error if DSTFILE is a directory.
+
+Environment variables override the default commands:
+ CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
+ RMPROG STRIPPROG
+"
+
+while test $# -ne 0; do
+ case $1 in
+ -c) ;;
+
+ -C) copy_on_change=true;;
+
+ -d) dir_arg=true;;
+
+ -g) chgrpcmd="$chgrpprog $2"
+ shift;;
+
+ --help) echo "$usage"; exit $?;;
+
+ -m) mode=$2
+ case $mode in
+ *' '* | *' '* | *'
+'* | *'*'* | *'?'* | *'['*)
+ echo "$0: invalid mode: $mode" >&2
+ exit 1;;
+ esac
+ shift;;
+
+ -o) chowncmd="$chownprog $2"
+ shift;;
+
+ -s) stripcmd=$stripprog;;
+
+ -t) dst_arg=$2
+ shift;;
+
+ -T) no_target_directory=true;;
+
+ --version) echo "$0 $scriptversion"; exit $?;;
+
+ --) shift
+ break;;
+
+ -*) echo "$0: invalid option: $1" >&2
+ exit 1;;
+
+ *) break;;
+ esac
+ shift
+done
+
+if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
+ # When -d is used, all remaining arguments are directories to create.
+ # When -t is used, the destination is already specified.
+ # Otherwise, the last argument is the destination. Remove it from $@.
+ for arg
+ do
+ if test -n "$dst_arg"; then
+ # $@ is not empty: it contains at least $arg.
+ set fnord "$@" "$dst_arg"
+ shift # fnord
+ fi
+ shift # arg
+ dst_arg=$arg
+ done
+fi
+
+if test $# -eq 0; then
+ if test -z "$dir_arg"; then
+ echo "$0: no input file specified." >&2
+ exit 1
+ fi
+ # It's OK to call `install-sh -d' without argument.
+ # This can happen when creating conditional directories.
+ exit 0
+fi
+
+if test -z "$dir_arg"; then
+ trap '(exit $?); exit' 1 2 13 15
+
+ # Set umask so as not to create temps with too-generous modes.
+ # However, 'strip' requires both read and write access to temps.
+ case $mode in
+ # Optimize common cases.
+ *644) cp_umask=133;;
+ *755) cp_umask=22;;
+
+ *[0-7])
+ if test -z "$stripcmd"; then
+ u_plus_rw=
+ else
+ u_plus_rw='% 200'
+ fi
+ cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
+ *)
+ if test -z "$stripcmd"; then
+ u_plus_rw=
+ else
+ u_plus_rw=,u+rw
+ fi
+ cp_umask=$mode$u_plus_rw;;
+ esac
+fi
+
+for src
+do
+ # Protect names starting with `-'.
+ case $src in
+ -*) src=./$src;;
+ esac
+
+ if test -n "$dir_arg"; then
+ dst=$src
+ dstdir=$dst
+ test -d "$dstdir"
+ dstdir_status=$?
+ else
+
+ # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
+ # might cause directories to be created, which would be especially bad
+ # if $src (and thus $dsttmp) contains '*'.
+ if test ! -f "$src" && test ! -d "$src"; then
+ echo "$0: $src does not exist." >&2
+ exit 1
+ fi
+
+ if test -z "$dst_arg"; then
+ echo "$0: no destination specified." >&2
+ exit 1
+ fi
+
+ dst=$dst_arg
+ # Protect names starting with `-'.
+ case $dst in
+ -*) dst=./$dst;;
+ esac
+
+ # If destination is a directory, append the input filename; won't work
+ # if double slashes aren't ignored.
+ if test -d "$dst"; then
+ if test -n "$no_target_directory"; then
+ echo "$0: $dst_arg: Is a directory" >&2
+ exit 1
+ fi
+ dstdir=$dst
+ dst=$dstdir/`basename "$src"`
+ dstdir_status=0
+ else
+ # Prefer dirname, but fall back on a substitute if dirname fails.
+ dstdir=`
+ (dirname "$dst") 2>/dev/null ||
+ expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$dst" : 'X\(//\)[^/]' \| \
+ X"$dst" : 'X\(//\)$' \| \
+ X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
+ echo X"$dst" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'
+ `
+
+ test -d "$dstdir"
+ dstdir_status=$?
+ fi
+ fi
+
+ obsolete_mkdir_used=false
+
+ if test $dstdir_status != 0; then
+ case $posix_mkdir in
+ '')
+ # Create intermediate dirs using mode 755 as modified by the umask.
+ # This is like FreeBSD 'install' as of 1997-10-28.
+ umask=`umask`
+ case $stripcmd.$umask in
+ # Optimize common cases.
+ *[2367][2367]) mkdir_umask=$umask;;
+ .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
+
+ *[0-7])
+ mkdir_umask=`expr $umask + 22 \
+ - $umask % 100 % 40 + $umask % 20 \
+ - $umask % 10 % 4 + $umask % 2
+ `;;
+ *) mkdir_umask=$umask,go-w;;
+ esac
+
+ # With -d, create the new directory with the user-specified mode.
+ # Otherwise, rely on $mkdir_umask.
+ if test -n "$dir_arg"; then
+ mkdir_mode=-m$mode
+ else
+ mkdir_mode=
+ fi
+
+ posix_mkdir=false
+ case $umask in
+ *[123567][0-7][0-7])
+ # POSIX mkdir -p sets u+wx bits regardless of umask, which
+ # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
+ ;;
+ *)
+ tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
+ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
+
+ if (umask $mkdir_umask &&
+ exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
+ then
+ if test -z "$dir_arg" || {
+ # Check for POSIX incompatibilities with -m.
+ # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
+ # other-writeable bit of parent directory when it shouldn't.
+ # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
+ ls_ld_tmpdir=`ls -ld "$tmpdir"`
+ case $ls_ld_tmpdir in
+ d????-?r-*) different_mode=700;;
+ d????-?--*) different_mode=755;;
+ *) false;;
+ esac &&
+ $mkdirprog -m$different_mode -p -- "$tmpdir" && {
+ ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
+ test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
+ }
+ }
+ then posix_mkdir=:
+ fi
+ rmdir "$tmpdir/d" "$tmpdir"
+ else
+ # Remove any dirs left behind by ancient mkdir implementations.
+ rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
+ fi
+ trap '' 0;;
+ esac;;
+ esac
+
+ if
+ $posix_mkdir && (
+ umask $mkdir_umask &&
+ $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
+ )
+ then :
+ else
+
+ # The umask is ridiculous, or mkdir does not conform to POSIX,
+ # or it failed possibly due to a race condition. Create the
+ # directory the slow way, step by step, checking for races as we go.
+
+ case $dstdir in
+ /*) prefix='/';;
+ -*) prefix='./';;
+ *) prefix='';;
+ esac
+
+ eval "$initialize_posix_glob"
+
+ oIFS=$IFS
+ IFS=/
+ $posix_glob set -f
+ set fnord $dstdir
+ shift
+ $posix_glob set +f
+ IFS=$oIFS
+
+ prefixes=
+
+ for d
+ do
+ test -z "$d" && continue
+
+ prefix=$prefix$d
+ if test -d "$prefix"; then
+ prefixes=
+ else
+ if $posix_mkdir; then
+ (umask=$mkdir_umask &&
+ $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
+ # Don't fail if two instances are running concurrently.
+ test -d "$prefix" || exit 1
+ else
+ case $prefix in
+ *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
+ *) qprefix=$prefix;;
+ esac
+ prefixes="$prefixes '$qprefix'"
+ fi
+ fi
+ prefix=$prefix/
+ done
+
+ if test -n "$prefixes"; then
+ # Don't fail if two instances are running concurrently.
+ (umask $mkdir_umask &&
+ eval "\$doit_exec \$mkdirprog $prefixes") ||
+ test -d "$dstdir" || exit 1
+ obsolete_mkdir_used=true
+ fi
+ fi
+ fi
+
+ if test -n "$dir_arg"; then
+ { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
+ { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
+ { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
+ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
+ else
+
+ # Make a couple of temp file names in the proper directory.
+ dsttmp=$dstdir/_inst.$$_
+ rmtmp=$dstdir/_rm.$$_
+
+ # Trap to clean up those temp files at exit.
+ trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
+
+ # Copy the file name to the temp name.
+ (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
+
+ # and set any options; do chmod last to preserve setuid bits.
+ #
+ # If any of these fail, we abort the whole thing. If we want to
+ # ignore errors from any of these, just make sure not to ignore
+ # errors from the above "$doit $cpprog $src $dsttmp" command.
+ #
+ { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
+ { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
+ { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
+ { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
+
+ # If -C, don't bother to copy if it wouldn't change the file.
+ if $copy_on_change &&
+ old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
+ new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
+
+ eval "$initialize_posix_glob" &&
+ $posix_glob set -f &&
+ set X $old && old=:$2:$4:$5:$6 &&
+ set X $new && new=:$2:$4:$5:$6 &&
+ $posix_glob set +f &&
+
+ test "$old" = "$new" &&
+ $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
+ then
+ rm -f "$dsttmp"
+ else
+ # Rename the file to the real destination.
+ $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
+
+ # The rename failed, perhaps because mv can't rename something else
+ # to itself, or perhaps because mv is so ancient that it does not
+ # support -f.
+ {
+ # Now remove or move aside any old file at destination location.
+ # We try this two ways since rm can't unlink itself on some
+ # systems and the destination file might be busy for other
+ # reasons. In this case, the final cleanup might fail but the new
+ # file should still install successfully.
+ {
+ test ! -f "$dst" ||
+ $doit $rmcmd -f "$dst" 2>/dev/null ||
+ { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
+ { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
+ } ||
+ { echo "$0: cannot unlink or rename $dst" >&2
+ (exit 1); exit 1
+ }
+ } &&
+
+ # Now rename the file to the real destination.
+ $doit $mvcmd "$dsttmp" "$dst"
+ }
+ fi || exit 1
+
+ trap '' 0
+ fi
+done
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/thirdparty/glog/glog-0.3.4/libglog.pc.in b/thirdparty/glog/glog-0.3.5/libglog.pc.in
index ad2b077..ad2b077 100644
--- a/thirdparty/glog/glog-0.3.4/libglog.pc.in
+++ b/thirdparty/glog/glog-0.3.5/libglog.pc.in
diff --git a/thirdparty/glog/glog-0.3.5/ltmain.sh b/thirdparty/glog/glog-0.3.5/ltmain.sh
new file mode 100644
index 0000000..c2852d8
--- /dev/null
+++ b/thirdparty/glog/glog-0.3.5/ltmain.sh
@@ -0,0 +1,9661 @@
+
+# libtool (GNU libtool) 2.4.2
+# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
+# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions. There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# GNU Libtool is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# As a special exception to the GNU General Public License,
+# if you distribute this file as part of a program or library that
+# is built using GNU Libtool, you may include this file under the
+# same distribution terms that you use for the rest of that program.
+#
+# GNU Libtool is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Libtool; see the file COPYING. If not, a copy
+# can be downloaded from http://www.gnu.org/licenses/gpl.html,
+# or obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# Usage: $progname [OPTION]... [MODE-ARG]...
+#
+# Provide generalized library-building support services.
+#
+# --config show all configuration variables
+# --debug enable verbose shell tracing
+# -n, --dry-run display commands without modifying any files
+# --features display basic configuration information and exit
+# --mode=MODE use operation mode MODE
+# --preserve-dup-deps don't remove duplicate dependency libraries
+# --quiet, --silent don't print informational messages
+# --no-quiet, --no-silent
+# print informational messages (default)
+# --no-warn don't display warning messages
+# --tag=TAG use configuration variables from tag TAG
+# -v, --verbose print more informational messages than default
+# --no-verbose don't print the extra informational messages
+# --version print version information
+# -h, --help, --help-all print short, long, or detailed help message
+#
+# MODE must be one of the following:
+#
+# clean remove files from the build directory
+# compile compile a source file into a libtool object
+# execute automatically set library path, then run a program
+# finish complete the installation of libtool libraries
+# install install libraries or executables
+# link create a library or an executable
+# uninstall remove libraries from an installed directory
+#
+# MODE-ARGS vary depending on the MODE. When passed as first option,
+# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
+# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
+#
+# When reporting a bug, please describe a test case to reproduce it and
+# include the following information:
+#
+# host-triplet: $host
+# shell: $SHELL
+# compiler: $LTCC
+# compiler flags: $LTCFLAGS
+# linker: $LD (gnu? $with_gnu_ld)
+# $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1
+# automake: $automake_version
+# autoconf: $autoconf_version
+#
+# Report bugs to <bug-libtool@gnu.org>.
+# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
+# General help using GNU software: <http://www.gnu.org/gethelp/>.
+
+PROGRAM=libtool
+PACKAGE=libtool
+VERSION="2.4.2 Debian-2.4.2-1ubuntu1"
+TIMESTAMP=""
+package_revision=1.3337
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# A function that is used when there is no print builtin or printf.
+func_fallback_echo ()
+{
+ eval 'cat <<_LTECHO_EOF
+$1
+_LTECHO_EOF'
+}
+
+# NLS nuisances: We save the old values to restore during execute mode.
+lt_user_locale=
+lt_safe_locale=
+for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
+do
+ eval "if test \"\${$lt_var+set}\" = set; then
+ save_$lt_var=\$$lt_var
+ $lt_var=C
+ export $lt_var
+ lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
+ lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
+ fi"
+done
+LC_ALL=C
+LANGUAGE=C
+export LANGUAGE LC_ALL
+
+$lt_unset CDPATH
+
+
+# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
+# is ksh but when the shell is invoked as "sh" and the current value of
+# the _XPG environment variable is not equal to 1 (one), the special
+# positional parameter $0, within a function call, is the name of the
+# function.
+progpath="$0"
+
+
+
+: ${CP="cp -f"}
+test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
+: ${MAKE="make"}
+: ${MKDIR="mkdir"}
+: ${MV="mv -f"}
+: ${RM="rm -f"}
+: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
+: ${Xsed="$SED -e 1s/^X//"}
+
+# Global variables:
+EXIT_SUCCESS=0
+EXIT_FAILURE=1
+EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
+EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
+
+exit_status=$EXIT_SUCCESS
+
+# Make sure IFS has a sensible default
+lt_nl='
+'
+IFS=" $lt_nl"
+
+dirname="s,/[^/]*$,,"
+basename="s,^.*/,,"
+
+# func_dirname file append nondir_replacement
+# Compute the dirname of FILE. If nonempty, add APPEND to the result,
+# otherwise set result to NONDIR_REPLACEMENT.
+func_dirname ()
+{
+ func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
+ if test "X$func_dirname_result" = "X${1}"; then
+ func_dirname_result="${3}"
+ else
+ func_dirname_result="$func_dirname_result${2}"
+ fi
+} # func_dirname may be replaced by extended shell implementation
+
+
+# func_basename file
+func_basename ()
+{
+ func_basename_result=`$ECHO "${1}" | $SED "$basename"`
+} # func_basename may be replaced by extended shell implementation
+
+
+# func_dirname_and_basename file append nondir_replacement
+# perform func_basename and func_dirname in a single function
+# call:
+# dirname: Compute the dirname of FILE. If nonempty,
+# add APPEND to the result, otherwise set result
+# to NONDIR_REPLACEMENT.
+# value returned in "$func_dirname_result"
+# basename: Compute filename of FILE.
+# value retuned in "$func_basename_result"
+# Implementation must be kept synchronized with func_dirname
+# and func_basename. For efficiency, we do not delegate to
+# those functions but instead duplicate the functionality here.
+func_dirname_and_basename ()
+{
+ # Extract subdirectory from the argument.
+ func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
+ if test "X$func_dirname_result" = "X${1}"; then
+ func_dirname_result="${3}"
+ else
+ func_dirname_result="$func_dirname_result${2}"
+ fi
+ func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
+} # func_dirname_and_basename may be replaced by extended shell implementation
+
+
+# func_stripname prefix suffix name
+# strip PREFIX and SUFFIX off of NAME.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+# func_strip_suffix prefix name
+func_stripname ()
+{
+ case ${2} in
+ .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
+ *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
+ esac
+} # func_stripname may be replaced by extended shell implementation
+
+
+# These SED scripts presuppose an absolute path with a trailing slash.
+pathcar='s,^/\([^/]*\).*$,\1,'
+pathcdr='s,^/[^/]*,,'
+removedotparts=':dotsl
+ s@/\./@/@g
+ t dotsl
+ s,/\.$,/,'
+collapseslashes='s@/\{1,\}@/@g'
+finalslash='s,/*$,/,'
+
+# func_normal_abspath PATH
+# Remove doubled-up and trailing slashes, "." path components,
+# and cancel out any ".." path components in PATH after making
+# it an absolute path.
+# value returned in "$func_normal_abspath_result"
+func_normal_abspath ()
+{
+ # Start from root dir and reassemble the path.
+ func_normal_abspath_result=
+ func_normal_abspath_tpath=$1
+ func_normal_abspath_altnamespace=
+ case $func_normal_abspath_tpath in
+ "")
+ # Empty path, that just means $cwd.
+ func_stripname '' '/' "`pwd`"
+ func_normal_abspath_result=$func_stripname_result
+ return
+ ;;
+ # The next three entries are used to spot a run of precisely
+ # two leading slashes without using negated character classes;
+ # we take advantage of case's first-match behaviour.
+ ///*)
+ # Unusual form of absolute path, do nothing.
+ ;;
+ //*)
+ # Not necessarily an ordinary path; POSIX reserves leading '//'
+ # and for example Cygwin uses it to access remote file shares
+ # over CIFS/SMB, so we conserve a leading double slash if found.
+ func_normal_abspath_altnamespace=/
+ ;;
+ /*)
+ # Absolute path, do nothing.
+ ;;
+ *)
+ # Relative path, prepend $cwd.
+ func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
+ ;;
+ esac
+ # Cancel out all the simple stuff to save iterations. We also want
+ # the path to end with a slash for ease of parsing, so make sure
+ # there is one (and only one) here.
+ func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
+ -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
+ while :; do
+ # Processed it all yet?
+ if test "$func_normal_abspath_tpath" = / ; then
+ # If we ascended to the root using ".." the result may be empty now.
+ if test -z "$func_normal_abspath_result" ; then
+ func_normal_abspath_result=/
+ fi
+ break
+ fi
+ func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
+ -e "$pathcar"`
+ func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
+ -e "$pathcdr"`
+ # Figure out what to do with it
+ case $func_normal_abspath_tcomponent in
+ "")
+ # Trailing empty path component, ignore it.
+ ;;
+ ..)
+ # Parent dir; strip last assembled component from result.
+ func_dirname "$func_normal_abspath_result"
+ func_normal_abspath_result=$func_dirname_result
+ ;;
+ *)
+ # Actual path component, append it.
+ func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
+ ;;
+ esac
+ done
+ # Restore leading double-slash if one was found on entry.
+ func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
+}
+
+# func_relative_path SRCDIR DSTDIR
+# generates a relative path from SRCDIR to DSTDIR, with a trailing
+# slash if non-empty, suitable for immediately appending a filename
+# without needing to append a separator.
+# value returned in "$func_relative_path_result"
+func_relative_path ()
+{
+ func_relative_path_result=
+ func_normal_abspath "$1"
+ func_relative_path_tlibdir=$func_normal_abspath_result
+ func_normal_abspath "$2"
+ func_relative_path_tbindir=$func_normal_abspath_result
+
+ # Ascend the tree starting from libdir
+ while :; do
+ # check if we have found a prefix of bindir
+ case $func_relative_path_tbindir in
+ $func_relative_path_tlibdir)
+ # found an exact match
+ func_relative_path_tcancelled=
+ break
+ ;;
+ $func_relative_path_tlibdir*)
+ # found a matching prefix
+ func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
+ func_relative_path_tcancelled=$func_stripname_result
+ if test -z "$func_relative_path_result"; then
+ func_relative_path_result=.
+ fi
+ break
+ ;;
+ *)
+ func_dirname $func_relative_path_tlibdir
+ func_relative_path_tlibdir=${func_dirname_result}
+ if test "x$func_relative_path_tlibdir" = x ; then
+ # Have to descend all the way to the root!
+ func_relative_path_result=../$func_relative_path_result
+ func_relative_path_tcancelled=$func_relative_path_tbindir
+ break
+ fi
+ func_relative_path_result=../$func_relative_path_result
+ ;;
+ esac
+ done
+
+ # Now calculate path; take care to avoid doubling-up slashes.
+ func_stripname '' '/' "$func_relative_path_result"
+ func_relative_path_result=$func_stripname_result
+ func_stripname '/' '/' "$func_relative_path_tcancelled"
+ if test "x$func_stripname_result" != x ; then
+ func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
+ fi
+
+ # Normalisation. If bindir is libdir, return empty string,
+ # else relative path ending with a slash; either way, target
+ # file name can be directly appended.
+ if test ! -z "$func_relative_path_result"; then
+ func_stripname './' '' "$func_relative_path_result/"
+ func_relative_path_result=$func_stripname_result
+ fi
+}
+
+# The name of this program:
+func_dirname_and_basename "$progpath"
+progname=$func_basename_result
+
+# Make sure we have an absolute path for reexecution:
+case $progpath in
+ [\\/]*|[A-Za-z]:\\*) ;;
+ *[\\/]*)
+ progdir=$func_dirname_result
+ progdir=`cd "$progdir" && pwd`
+ progpath="$progdir/$progname"
+ ;;
+ *)
+ save_IFS="$IFS"
+ IFS=${PATH_SEPARATOR-:}
+ for progdir in $PATH; do
+ IFS="$save_IFS"
+ test -x "$progdir/$progname" && break
+ done
+ IFS="$save_IFS"
+ test -n "$progdir" || progdir=`pwd`
+ progpath="$progdir/$progname"
+ ;;
+esac
+
+# Sed substitution that helps us do robust quoting. It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed="${SED}"' -e 1s/^X//'
+sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\(["`\\]\)/\\\1/g'
+
+# Sed substitution that turns a string into a regex matching for the
+# string literally.
+sed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
+
+# Sed substitution that converts a w32 file name or path
+# which contains forward slashes, into one that contains
+# (escaped) backslashes. A very naive implementation.
+lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
+
+# Re-`\' parameter expansions in output of double_quote_subst that were
+# `\'-ed in input to the same. If an odd number of `\' preceded a '$'
+# in input to double_quote_subst, that '$' was protected from expansion.
+# Since each input `\' is now two `\'s, look for any number of runs of
+# four `\'s followed by two `\'s and then a '$'. `\' that '$'.
+bs='\\'
+bs2='\\\\'
+bs4='\\\\\\\\'
+dollar='\$'
+sed_double_backslash="\
+ s/$bs4/&\\
+/g
+ s/^$bs2$dollar/$bs&/
+ s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
+ s/\n//g"
+
+# Standard options:
+opt_dry_run=false
+opt_help=false
+opt_quiet=false
+opt_verbose=false
+opt_warning=:
+
+# func_echo arg...
+# Echo program name prefixed message, along with the current mode
+# name if it has been set yet.
+func_echo ()
+{
+ $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
+}
+
+# func_verbose arg...
+# Echo program name prefixed message in verbose mode only.
+func_verbose ()
+{
+ $opt_verbose && func_echo ${1+"$@"}
+
+ # A bug in bash halts the script if the last line of a function
+ # fails when set -e is in force, so we need another command to
+ # work around that:
+ :
+}
+
+# func_echo_all arg...
+# Invoke $ECHO with all args, space-separated.
+func_echo_all ()
+{
+ $ECHO "$*"
+}
+
+# func_error arg...
+# Echo program name prefixed message to standard error.
+func_error ()
+{
+ $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
+}
+
+# func_warning arg...
+# Echo program name prefixed warning message to standard error.
+func_warning ()
+{
+ $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
+
+ # bash bug again:
+ :
+}
+
+# func_fatal_error arg...
+# Echo program name prefixed message to standard error, and exit.
+func_fatal_error ()
+{
+ func_error ${1+"$@"}
+ exit $EXIT_FAILURE
+}
+
+# func_fatal_help arg...
+# Echo program name prefixed message to standard error, followed by
+# a help hint, and exit.
+func_fatal_help ()
+{
+ func_error ${1+"$@"}
+ func_fatal_error "$help"
+}
+help="Try \`$progname --help' for more information." ## default
+
+
+# func_grep expression filename
+# Check whether EXPRESSION matches any line of FILENAME, without output.
+func_grep ()
+{
+ $GREP "$1" "$2" >/dev/null 2>&1
+}
+
+
+# func_mkdir_p directory-path
+# Make sure the entire path to DIRECTORY-PATH is available.
+func_mkdir_p ()
+{
+ my_directory_path="$1"
+ my_dir_list=
+
+ if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
+
+ # Protect directory names starting with `-'
+ case $my_directory_path in
+ -*) my_directory_path="./$my_directory_path" ;;
+ esac
+
+ # While some portion of DIR does not yet exist...
+ while test ! -d "$my_directory_path"; do
+ # ...make a list in topmost first order. Use a colon delimited
+ # list incase some portion of path contains whitespace.
+ my_dir_list="$my_directory_path:$my_dir_list"
+
+ # If the last portion added has no slash in it, the list is done
+ case $my_directory_path in */*) ;; *) break ;; esac
+
+ # ...otherwise throw away the child directory and loop
+ my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
+ done
+ my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
+
+ save_mkdir_p_IFS="$IFS"; IFS=':'
+ for my_dir in $my_dir_list; do
+ IFS="$save_mkdir_p_IFS"
+ # mkdir can fail with a `File exist' error if two processes
+ # try to create one of the directories concurrently. Don't
+ # stop in that case!
+ $MKDIR "$my_dir" 2>/dev/null || :
+ done
+ IFS="$save_mkdir_p_IFS"
+
+ # Bail out if we (or some other process) failed to create a directory.
+ test -d "$my_directory_path" || \
+ func_fatal_error "Failed to create \`$1'"
+ fi
+}
+
+
+# func_mktempdir [string]
+# Make a temporary directory that won't clash with other running
+# libtool processes, and avoids race conditions if possible. If
+# given, STRING is the basename for that directory.
+func_mktempdir ()
+{
+ my_template="${TMPDIR-/tmp}/${1-$progname}"
+
+ if test "$opt_dry_run" = ":"; then
+ # Return a directory name, but don't create it in dry-run mode
+ my_tmpdir="${my_template}-$$"
+ else
+
+ # If mktemp works, use that first and foremost
+ my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
+
+ if test ! -d "$my_tmpdir"; then
+ # Failing that, at least try and use $RANDOM to avoid a race
+ my_tmpdir="${my_template}-${RANDOM-0}$$"
+
+ save_mktempdir_umask=`umask`
+ umask 0077
+ $MKDIR "$my_tmpdir"
+ umask $save_mktempdir_umask
+ fi
+
+ # If we're not in dry-run mode, bomb out on failure
+ test -d "$my_tmpdir" || \
+ func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
+ fi
+
+ $ECHO "$my_tmpdir"
+}
+
+
+# func_quote_for_eval arg
+# Aesthetically quote ARG to be evaled later.
+# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
+# is double-quoted, suitable for a subsequent eval, whereas
+# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
+# which are still active within double quotes backslashified.
+func_quote_for_eval ()
+{
+ case $1 in
+ *[\\\`\"\$]*)
+ func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
+ *)
+ func_quote_for_eval_unquoted_result="$1" ;;
+ esac
+
+ case $func_quote_for_eval_unquoted_result in
+ # Double-quote args containing shell metacharacters to delay
+ # word splitting, command substitution and and variable
+ # expansion for a subsequent eval.
+ # Many Bourne shells cannot handle close brackets correctly
+ # in scan sets, so we specify it separately.
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
+ func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
+ ;;
+ *)
+ func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
+ esac
+}
+
+
+# func_quote_for_expand arg
+# Aesthetically quote ARG to be evaled later; same as above,
+# but do not quote variable references.
+func_quote_for_expand ()
+{
+ case $1 in
+ *[\\\`\"]*)
+ my_arg=`$ECHO "$1" | $SED \
+ -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
+ *)
+ my_arg="$1" ;;
+ esac
+
+ case $my_arg in
+ # Double-quote args containing shell metacharacters to delay
+ # word splitting and command substitution for a subsequent eval.
+ # Many Bourne shells cannot handle close brackets correctly
+ # in scan sets, so we specify it separately.
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
+ my_arg="\"$my_arg\""
+ ;;
+ esac
+
+ func_quote_for_expand_result="$my_arg"
+}
+
+
+# func_show_eval cmd [fail_exp]
+# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
+# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
+# is given, then evaluate it.
+func_show_eval ()
+{
+ my_cmd="$1"
+ my_fail_exp="${2-:}"
+
+ ${opt_silent-false} || {
+ func_quote_for_expand "$my_cmd"
+ eval "func_echo $func_quote_for_expand_result"
+ }
+
+ if ${opt_dry_run-false}; then :; else
+ eval "$my_cmd"
+ my_status=$?
+ if test "$my_status" -eq 0; then :; else
+ eval "(exit $my_status); $my_fail_exp"
+ fi
+ fi
+}
+
+
+# func_show_eval_locale cmd [fail_exp]
+# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
+# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
+# is given, then evaluate it. Use the saved locale for evaluation.
+func_show_eval_locale ()
+{
+ my_cmd="$1"
+ my_fail_exp="${2-:}"
+
+ ${opt_silent-false} || {
+ func_quote_for_expand "$my_cmd"
+ eval "func_echo $func_quote_for_expand_result"
+ }
+
+ if ${opt_dry_run-false}; then :; else
+ eval "$lt_user_locale
+ $my_cmd"
+ my_status=$?
+ eval "$lt_safe_locale"
+ if test "$my_status" -eq 0; then :; else
+ eval "(exit $my_status); $my_fail_exp"
+ fi
+ fi
+}
+
+# func_tr_sh
+# Turn $1 into a string suitable for a shell variable name.
+# Result is stored in $func_tr_sh_result. All characters
+# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
+# if $1 begins with a digit, a '_' is prepended as well.
+func_tr_sh ()
+{
+ case $1 in
+ [0-9]* | *[!a-zA-Z0-9_]*)
+ func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
+ ;;
+ * )
+ func_tr_sh_result=$1
+ ;;
+ esac
+}
+
+
+# func_version
+# Echo version message to standard output and exit.
+func_version ()
+{
+ $opt_debug
+
+ $SED -n '/(C)/!b go
+ :more
+ /\./!{
+ N
+ s/\n# / /
+ b more
+ }
+ :go
+ /^# '$PROGRAM' (GNU /,/# warranty; / {
+ s/^# //
+ s/^# *$//
+ s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
+ p
+ }' < "$progpath"
+ exit $?
+}
+
+# func_usage
+# Echo short help message to standard output and exit.
+func_usage ()
+{
+ $opt_debug
+
+ $SED -n '/^# Usage:/,/^# *.*--help/ {
+ s/^# //
+ s/^# *$//
+ s/\$progname/'$progname'/
+ p
+ }' < "$progpath"
+ echo
+ $ECHO "run \`$progname --help | more' for full usage"
+ exit $?
+}
+
+# func_help [NOEXIT]
+# Echo long help message to standard output and exit,
+# unless 'noexit' is passed as argument.
+func_help ()
+{
+ $opt_debug
+
+ $SED -n '/^# Usage:/,/# Report bugs to/ {
+ :print
+ s/^# //
+ s/^# *$//
+ s*\$progname*'$progname'*
+ s*\$host*'"$host"'*
+ s*\$SHELL*'"$SHELL"'*
+ s*\$LTCC*'"$LTCC"'*
+ s*\$LTCFLAGS*'"$LTCFLAGS"'*
+ s*\$LD*'"$LD"'*
+ s/\$with_gnu_ld/'"$with_gnu_ld"'/
+ s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
+ s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
+ p
+ d
+ }
+ /^# .* home page:/b print
+ /^# General help using/b print
+ ' < "$progpath"
+ ret=$?
+ if test -z "$1"; then
+ exit $ret
+ fi
+}
+
+# func_missing_arg argname
+# Echo program name prefixed message to standard error and set global
+# exit_cmd.
+func_missing_arg ()
+{
+ $opt_debug
+
+ func_error "missing argument for $1."
+ exit_cmd=exit
+}
+
+
+# func_split_short_opt shortopt
+# Set func_split_short_opt_name and func_split_short_opt_arg shell
+# variables after splitting SHORTOPT after the 2nd character.
+func_split_short_opt ()
+{
+ my_sed_short_opt='1s/^\(..\).*$/\1/;q'
+ my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
+
+ func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
+ func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
+} # func_split_short_opt may be replaced by extended shell implementation
+
+
+# func_split_long_opt longopt
+# Set func_split_long_opt_name and func_split_long_opt_arg shell
+# variables after splitting LONGOPT at the `=' sign.
+func_split_long_opt ()
+{
+ my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
+ my_sed_long_arg='1s/^--[^=]*=//'
+
+ func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
+ func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
+} # func_split_long_opt may be replaced by extended shell implementation
+
+exit_cmd=:
+
+
+
+
+
+magic="%%%MAGIC variable%%%"
+magic_exe="%%%MAGIC EXE variable%%%"
+
+# Global variables.
+nonopt=
+preserve_args=
+lo2o="s/\\.lo\$/.${objext}/"
+o2lo="s/\\.${objext}\$/.lo/"
+extracted_archives=
+extracted_serial=0
+
+# If this variable is set in any of the actions, the command in it
+# will be execed at the end. This prevents here-documents from being
+# left over by shells.
+exec_cmd=
+
+# func_append var value
+# Append VALUE to the end of shell variable VAR.
+func_append ()
+{
+ eval "${1}=\$${1}\${2}"
+} # func_append may be replaced by extended shell implementation
+
+# func_append_quoted var value
+# Quote VALUE and append to the end of shell variable VAR, separated
+# by a space.
+func_append_quoted ()
+{
+ func_quote_for_eval "${2}"
+ eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
+} # func_append_quoted may be replaced by extended shell implementation
+
+
+# func_arith arithmetic-term...
+func_arith ()
+{
+ func_arith_result=`expr "${@}"`
+} # func_arith may be replaced by extended shell implementation
+
+
+# func_len string
+# STRING may not start with a hyphen.
+func_len ()
+{
+ func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
+} # func_len may be replaced by extended shell implementation
+
+
+# func_lo2o object
+func_lo2o ()
+{
+ func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
+} # func_lo2o may be replaced by extended shell implementation
+
+
+# func_xform libobj-or-source
+func_xform ()
+{
+ func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
+} # func_xform may be replaced by extended shell implementation
+
+
+# func_fatal_configuration arg...
+# Echo program name prefixed message to standard error, followed by
+# a configuration failure hint, and exit.
+func_fatal_configuration ()
+{
+ func_error ${1+"$@"}
+ func_error "See the $PACKAGE documentation for more information."
+ func_fatal_error "Fatal configuration error."
+}
+
+
+# func_config
+# Display the configuration for all the tags in this script.
+func_config ()
+{
+ re_begincf='^# ### BEGIN LIBTOOL'
+ re_endcf='^# ### END LIBTOOL'
+
+ # Default configuration.
+ $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
+
+ # Now print the configurations for the tags.
+ for tagname in $taglist; do
+ $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
+ done
+
+ exit $?
+}
+
+# func_features
+# Display the features supported by this script.
+func_features ()
+{
+ echo "host: $host"
+ if test "$build_libtool_libs" = yes; then
+ echo "enable shared libraries"
+ else
+ echo "disable shared libraries"
+ fi
+ if test "$build_old_libs" = yes; then
+ echo "enable static libraries"
+ else
+ echo "disable static libraries"
+ fi
+
+ exit $?
+}
+
+# func_enable_tag tagname
+# Verify that TAGNAME is valid, and either flag an error and exit, or
+# enable the TAGNAME tag. We also add TAGNAME to the global $taglist
+# variable here.
+func_enable_tag ()
+{
+ # Global variable:
+ tagname="$1"
+
+ re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
+ re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
+ sed_extractcf="/$re_begincf/,/$re_endcf/p"
+
+ # Validate tagname.
+ case $tagname in
+ *[!-_A-Za-z0-9,/]*)
+ func_fatal_error "invalid tag name: $tagname"
+ ;;
+ esac
+
+ # Don't test for the "default" C tag, as we know it's
+ # there but not specially marked.
+ case $tagname in
+ CC) ;;
+ *)
+ if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
+ taglist="$taglist $tagname"
+
+ # Evaluate the configuration. Be careful to quote the path
+ # and the sed script, to avoid splitting on whitespace, but
+ # also don't use non-portable quotes within backquotes within
+ # quotes we have to do it in 2 steps:
+ extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
+ eval "$extractedcf"
+ else
+ func_error "ignoring unknown tag $tagname"
+ fi
+ ;;
+ esac
+}
+
+# func_check_version_match
+# Ensure that we are using m4 macros, and libtool script from the same
+# release of libtool.
+func_check_version_match ()
+{
+ if test "$package_revision" != "$macro_revision"; then
+ if test "$VERSION" != "$macro_version"; then
+ if test -z "$macro_version"; then
+ cat >&2 <<_LT_EOF
+$progname: Version mismatch error. This is $PACKAGE $VERSION, but the
+$progname: definition of this LT_INIT comes from an older release.
+$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
+$progname: and run autoconf again.
+_LT_EOF
+ else
+ cat >&2 <<_LT_EOF
+$progname: Version mismatch error. This is $PACKAGE $VERSION, but the
+$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
+$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
+$progname: and run autoconf again.
+_LT_EOF
+ fi
+ else
+ cat >&2 <<_LT_EOF
+$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision,
+$progname: but the definition of this LT_INIT comes from revision $macro_revision.
+$progname: You should recreate aclocal.m4 with macros from revision $package_revision
+$progname: of $PACKAGE $VERSION and run autoconf again.
+_LT_EOF
+ fi
+
+ exit $EXIT_MISMATCH
+ fi
+}
+
+
+# Shorthand for --mode=foo, only valid as the first argument
+case $1 in
+clean|clea|cle|cl)
+ shift; set dummy --mode clean ${1+"$@"}; shift
+ ;;
+compile|compil|compi|comp|com|co|c)
+ shift; set dummy --mode compile ${1+"$@"}; shift
+ ;;
+execute|execut|execu|exec|exe|ex|e)
+ shift; set dummy --mode execute ${1+"$@"}; shift
+ ;;
+finish|finis|fini|fin|fi|f)
+ shift; set dummy --mode finish ${1+"$@"}; shift
+ ;;
+install|instal|insta|inst|ins|in|i)
+ shift; set dummy --mode install ${1+"$@"}; shift
+ ;;
+link|lin|li|l)
+ shift; set dummy --mode link ${1+"$@"}; shift
+ ;;
+uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
+ shift; set dummy --mode uninstall ${1+"$@"}; shift
+ ;;
+esac
+
+
+
+# Option defaults:
+opt_debug=:
+opt_dry_run=false
+opt_config=false
+opt_preserve_dup_deps=false
+opt_features=false
+opt_finish=false
+opt_help=false
+opt_help_all=false
+opt_silent=:
+opt_warning=:
+opt_verbose=:
+opt_silent=false
+opt_verbose=false
+
+
+# Parse options once, thoroughly. This comes as soon as possible in the
+# script to make things like `--version' happen as quickly as we can.
+{
+ # this just eases exit handling
+ while test $# -gt 0; do
+ opt="$1"
+ shift
+ case $opt in
+ --debug|-x) opt_debug='set -x'
+ func_echo "enabling shell trace mode"
+ $opt_debug
+ ;;
+ --dry-run|--dryrun|-n)
+ opt_dry_run=:
+ ;;
+ --config)
+ opt_config=:
+func_config
+ ;;
+ --dlopen|-dlopen)
+ optarg="$1"
+ opt_dlopen="${opt_dlopen+$opt_dlopen
+}$optarg"
+ shift
+ ;;
+ --preserve-dup-deps)
+ opt_preserve_dup_deps=:
+ ;;
+ --features)
+ opt_features=:
+func_features
+ ;;
+ --finish)
+ opt_finish=:
+set dummy --mode finish ${1+"$@"}; shift
+ ;;
+ --help)
+ opt_help=:
+ ;;
+ --help-all)
+ opt_help_all=:
+opt_help=': help-all'
+ ;;
+ --mode)
+ test $# = 0 && func_missing_arg $opt && break
+ optarg="$1"
+ opt_mode="$optarg"
+case $optarg in
+ # Valid mode arguments:
+ clean|compile|execute|finish|install|link|relink|uninstall) ;;
+
+ # Catch anything else as an error
+ *) func_error "invalid argument for $opt"
+ exit_cmd=exit
+ break
+ ;;
+esac
+ shift
+ ;;
+ --no-silent|--no-quiet)
+ opt_silent=false
+func_append preserve_args " $opt"
+ ;;
+ --no-warning|--no-warn)
+ opt_warning=false
+func_append preserve_args " $opt"
+ ;;
+ --no-verbose)
+ opt_verbose=false
+func_append preserve_args " $opt"
+ ;;
+ --silent|--quiet)
+ opt_silent=:
+func_append preserve_args " $opt"
+ opt_verbose=false
+ ;;
+ --verbose|-v)
+ opt_verbose=:
+func_append preserve_args " $opt"
+opt_silent=false
+ ;;
+ --tag)
+ test $# = 0 && func_missing_arg $opt && break
+ optarg="$1"
+ opt_tag="$optarg"
+func_append preserve_args " $opt $optarg"
+func_enable_tag "$optarg"
+ shift
+ ;;
+
+ -\?|-h) func_usage ;;
+ --help) func_help ;;
+ --version) func_version ;;
+
+ # Separate optargs to long options:
+ --*=*)
+ func_split_long_opt "$opt"
+ set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
+ shift
+ ;;
+
+ # Separate non-argument short options:
+ -\?*|-h*|-n*|-v*)
+ func_split_short_opt "$opt"
+ set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
+ shift
+ ;;
+
+ --) break ;;
+ -*) func_fatal_help "unrecognized option \`$opt'" ;;
+ *) set dummy "$opt" ${1+"$@"}; shift; break ;;
+ esac
+ done
+
+ # Validate options:
+
+ # save first non-option argument
+ if test "$#" -gt 0; then
+ nonopt="$opt"
+ shift
+ fi
+
+ # preserve --debug
+ test "$opt_debug" = : || func_append preserve_args " --debug"
+
+ case $host in
+ *cygwin* | *mingw* | *pw32* | *cegcc*)
+ # don't eliminate duplications in $postdeps and $predeps
+ opt_duplicate_compiler_generated_deps=:
+ ;;
+ *)
+ opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
+ ;;
+ esac
+
+ $opt_help || {
+ # Sanity checks first:
+ func_check_version_match
+
+ if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
+ func_fatal_configuration "not configured to build any kind of library"
+ fi
+
+ # Darwin sucks
+ eval std_shrext=\"$shrext_cmds\"
+
+ # Only execute mode is allowed to have -dlopen flags.
+ if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
+ func_error "unrecognized option \`-dlopen'"
+ $ECHO "$help" 1>&2
+ exit $EXIT_FAILURE
+ fi
+
+ # Change the help message to a mode-specific one.
+ generic_help="$help"
+ help="Try \`$progname --help --mode=$opt_mode' for more information."
+ }
+
+
+ # Bail if the options were screwed
+ $exit_cmd $EXIT_FAILURE
+}
+
+
+
+
+## ----------- ##
+## Main. ##
+## ----------- ##
+
+# func_lalib_p file
+# True iff FILE is a libtool `.la' library or `.lo' object file.
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_lalib_p ()
+{
+ test -f "$1" &&
+ $SED -e 4q "$1" 2>/dev/null \
+ | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
+}
+
+# func_lalib_unsafe_p file
+# True iff FILE is a libtool `.la' library or `.lo' object file.
+# This function implements the same check as func_lalib_p without
+# resorting to external programs. To this end, it redirects stdin and
+# closes it afterwards, without saving the original file descriptor.
+# As a safety measure, use it only where a negative result would be
+# fatal anyway. Works if `file' does not exist.
+func_lalib_unsafe_p ()
+{
+ lalib_p=no
+ if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
+ for lalib_p_l in 1 2 3 4
+ do
+ read lalib_p_line
+ case "$lalib_p_line" in
+ \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
+ esac
+ done
+ exec 0<&5 5<&-
+ fi
+ test "$lalib_p" = yes
+}
+
+# func_ltwrapper_script_p file
+# True iff FILE is a libtool wrapper script
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_ltwrapper_script_p ()
+{
+ func_lalib_p "$1"
+}
+
+# func_ltwrapper_executable_p file
+# True iff FILE is a libtool wrapper executable
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_ltwrapper_executable_p ()
+{
+ func_ltwrapper_exec_suffix=
+ case $1 in
+ *.exe) ;;
+ *) func_ltwrapper_exec_suffix=.exe ;;
+ esac
+ $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
+}
+
+# func_ltwrapper_scriptname file
+# Assumes file is an ltwrapper_executable
+# uses $file to determine the appropriate filename for a
+# temporary ltwrapper_script.
+func_ltwrapper_scriptname ()
+{
+ func_dirname_and_basename "$1" "" "."
+ func_stripname '' '.exe' "$func_basename_result"
+ func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
+}
+
+# func_ltwrapper_p file
+# True iff FILE is a libtool wrapper script or wrapper executable
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_ltwrapper_p ()
+{
+ func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
+}
+
+
+# func_execute_cmds commands fail_cmd
+# Execute tilde-delimited COMMANDS.
+# If FAIL_CMD is given, eval that upon failure.
+# FAIL_CMD may read-access the current command in variable CMD!
+func_execute_cmds ()
+{
+ $opt_debug
+ save_ifs=$IFS; IFS='~'
+ for cmd in $1; do
+ IFS=$save_ifs
+ eval cmd=\"$cmd\"
+ func_show_eval "$cmd" "${2-:}"
+ done
+ IFS=$save_ifs
+}
+
+
+# func_source file
+# Source FILE, adding directory component if necessary.
+# Note that it is not necessary on cygwin/mingw to append a dot to
+# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
+# behavior happens only for exec(3), not for open(2)! Also, sourcing
+# `FILE.' does not work on cygwin managed mounts.
+func_source ()
+{
+ $opt_debug
+ case $1 in
+ */* | *\\*) . "$1" ;;
+ *) . "./$1" ;;
+ esac
+}
+
+
+# func_resolve_sysroot PATH
+# Replace a leading = in PATH with a sysroot. Store the result into
+# func_resolve_sysroot_result
+func_resolve_sysroot ()
+{
+ func_resolve_sysroot_result=$1
+ case $func_resolve_sysroot_result in
+ =*)
+ func_stripname '=' '' "$func_resolve_sysroot_result"
+ func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
+ ;;
+ esac
+}
+
+# func_replace_sysroot PATH
+# If PATH begins with the sysroot, replace it with = and
+# store the result into func_replace_sysroot_result.
+func_replace_sysroot ()
+{
+ case "$lt_sysroot:$1" in
+ ?*:"$lt_sysroot"*)
+ func_stripname "$lt_sysroot" '' "$1"
+ func_replace_sysroot_result="=$func_stripname_result"
+ ;;
+ *)
+ # Including no sysroot.
+ func_replace_sysroot_result=$1
+ ;;
+ esac
+}
+
+# func_infer_tag arg
+# Infer tagged configuration to use if any are available and
+# if one wasn't chosen via the "--tag" command line option.
+# Only attempt this if the compiler in the base compile
+# command doesn't match the default compiler.
+# arg is usually of the form 'gcc ...'
+func_infer_tag ()
+{
+ $opt_debug
+ if test -n "$available_tags" && test -z "$tagname"; then
+ CC_quoted=
+ for arg in $CC; do
+ func_append_quoted CC_quoted "$arg"
+ done
+ CC_expanded=`func_echo_all $CC`
+ CC_quoted_expanded=`func_echo_all $CC_quoted`
+ case $@ in
+ # Blanks in the command may have been stripped by the calling shell,
+ # but not from the CC environment variable when configure was run.
+ " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
+ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
+ # Blanks at the start of $base_compile will cause this to fail
+ # if we don't check for them as well.
+ *)
+ for z in $available_tags; do
+ if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
+ # Evaluate the configuration.
+ eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
+ CC_quoted=
+ for arg in $CC; do
+ # Double-quote args containing other shell metacharacters.
+ func_append_quoted CC_quoted "$arg"
+ done
+ CC_expanded=`func_echo_all $CC`
+ CC_quoted_expanded=`func_echo_all $CC_quoted`
+ case "$@ " in
+ " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
+ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
+ # The compiler in the base compile command matches
+ # the one in the tagged configuration.
+ # Assume this is the tagged configuration we want.
+ tagname=$z
+ break
+ ;;
+ esac
+ fi
+ done
+ # If $tagname still isn't set, then no tagged configuration
+ # was found and let the user know that the "--tag" command
+ # line option must be used.
+ if test -z "$tagname"; then
+ func_echo "unable to infer tagged configuration"
+ func_fatal_error "specify a tag with \`--tag'"
+# else
+# func_verbose "using $tagname tagged configuration"
+ fi
+ ;;
+ esac
+ fi
+}
+
+
+
+# func_write_libtool_object output_name pic_name nonpic_name
+# Create a libtool object file (analogous to a ".la" file),
+# but don't create it if we're doing a dry run.
+func_write_libtool_object ()
+{
+ write_libobj=${1}
+ if test "$build_libtool_libs" = yes; then
+ write_lobj=\'${2}\'
+ else
+ write_lobj=none
+ fi
+
+ if test "$build_old_libs" = yes; then
+ write_oldobj=\'${3}\'
+ else
+ write_oldobj=none
+ fi
+
+ $opt_dry_run || {
+ cat >${write_libobj}T <<EOF
+# $write_libobj - a libtool object file
+# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+pic_object=$write_lobj
+
+# Name of the non-PIC object
+non_pic_object=$write_oldobj
+
+EOF
+ $MV "${write_libobj}T" "${write_libobj}"
+ }
+}
+
+
+##################################################
+# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
+##################################################
+
+# func_convert_core_file_wine_to_w32 ARG
+# Helper function used by file name conversion functions when $build is *nix,
+# and $host is mingw, cygwin, or some other w32 environment. Relies on a
+# correctly configured wine environment available, with the winepath program
+# in $build's $PATH.
+#
+# ARG is the $build file name to be converted to w32 format.
+# Result is available in $func_convert_core_file_wine_to_w32_result, and will
+# be empty on error (or when ARG is empty)
+func_convert_core_file_wine_to_w32 ()
+{
+ $opt_debug
+ func_convert_core_file_wine_to_w32_result="$1"
+ if test -n "$1"; then
+ # Unfortunately, winepath does not exit with a non-zero error code, so we
+ # are forced to check the contents of stdout. On the other hand, if the
+ # command is not found, the shell will set an exit code of 127 and print
+ # *an error message* to stdout. So we must check for both error code of
+ # zero AND non-empty stdout, which explains the odd construction:
+ func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
+ if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
+ func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
+ $SED -e "$lt_sed_naive_backslashify"`
+ else
+ func_convert_core_file_wine_to_w32_result=
+ fi
+ fi
+}
+# end: func_convert_core_file_wine_to_w32
+
+
+# func_convert_core_path_wine_to_w32 ARG
+# Helper function used by path conversion functions when $build is *nix, and
+# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
+# configured wine environment available, with the winepath program in $build's
+# $PATH. Assumes ARG has no leading or trailing path separator characters.
+#
+# ARG is path to be converted from $build format to win32.
+# Result is available in $func_convert_core_path_wine_to_w32_result.
+# Unconvertible file (directory) names in ARG are skipped; if no directory names
+# are convertible, then the result may be empty.
+func_convert_core_path_wine_to_w32 ()
+{
+ $opt_debug
+ # unfortunately, winepath doesn't convert paths, only file names
+ func_convert_core_path_wine_to_w32_result=""
+ if test -n "$1"; then
+ oldIFS=$IFS
+ IFS=:
+ for func_convert_core_path_wine_to_w32_f in $1; do
+ IFS=$oldIFS
+ func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
+ if test -n "$func_convert_core_file_wine_to_w32_result" ; then
+ if test -z "$func_convert_core_path_wine_to_w32_result"; then
+ func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
+ else
+ func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
+ fi
+ fi
+ done
+ IFS=$oldIFS
+ fi
+}
+# end: func_convert_core_path_wine_to_w32
+
+
+# func_cygpath ARGS...
+# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
+# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
+# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
+# (2), returns the Cygwin file name or path in func_cygpath_result (input
+# file name or path is assumed to be in w32 format, as previously converted
+# from $build's *nix or MSYS format). In case (3), returns the w32 file name
+# or path in func_cygpath_result (input file name or path is assumed to be in
+# Cygwin format). Returns an empty string on error.
+#
+# ARGS are passed to cygpath, with the last one being the file name or path to
+# be converted.
+#
+# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
+# environment variable; do not put it in $PATH.
+func_cygpath ()
+{
+ $opt_debug
+ if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
+ func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
+ if test "$?" -ne 0; then
+ # on failure, ensure result is empty
+ func_cygpath_result=
+ fi
+ else
+ func_cygpath_result=
+ func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
+ fi
+}
+#end: func_cygpath
+
+
+# func_convert_core_msys_to_w32 ARG
+# Convert file name or path ARG from MSYS format to w32 format. Return
+# result in func_convert_core_msys_to_w32_result.
+func_convert_core_msys_to_w32 ()
+{
+ $opt_debug
+ # awkward: cmd appends spaces to result
+ func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
+ $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
+}
+#end: func_convert_core_msys_to_w32
+
+
+# func_convert_file_check ARG1 ARG2
+# Verify that ARG1 (a file name in $build format) was converted to $host
+# format in ARG2. Otherwise, emit an error message, but continue (resetting
+# func_to_host_file_result to ARG1).
+func_convert_file_check ()
+{
+ $opt_debug
+ if test -z "$2" && test -n "$1" ; then
+ func_error "Could not determine host file name corresponding to"
+ func_error " \`$1'"
+ func_error "Continuing, but uninstalled executables may not work."
+ # Fallback:
+ func_to_host_file_result="$1"
+ fi
+}
+# end func_convert_file_check
+
+
+# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
+# Verify that FROM_PATH (a path in $build format) was converted to $host
+# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
+# func_to_host_file_result to a simplistic fallback value (see below).
+func_convert_path_check ()
+{
+ $opt_debug
+ if test -z "$4" && test -n "$3"; then
+ func_error "Could not determine the host path corresponding to"
+ func_error " \`$3'"
+ func_error "Continuing, but uninstalled executables may not work."
+ # Fallback. This is a deliberately simplistic "conversion" and
+ # should not be "improved". See libtool.info.
+ if test "x$1" != "x$2"; then
+ lt_replace_pathsep_chars="s|$1|$2|g"
+ func_to_host_path_result=`echo "$3" |
+ $SED -e "$lt_replace_pathsep_chars"`
+ else
+ func_to_host_path_result="$3"
+ fi
+ fi
+}
+# end func_convert_path_check
+
+
+# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
+# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
+# and appending REPL if ORIG matches BACKPAT.
+func_convert_path_front_back_pathsep ()
+{
+ $opt_debug
+ case $4 in
+ $1 ) func_to_host_path_result="$3$func_to_host_path_result"
+ ;;
+ esac
+ case $4 in
+ $2 ) func_append func_to_host_path_result "$3"
+ ;;
+ esac
+}
+# end func_convert_path_front_back_pathsep
+
+
+##################################################
+# $build to $host FILE NAME CONVERSION FUNCTIONS #
+##################################################
+# invoked via `$to_host_file_cmd ARG'
+#
+# In each case, ARG is the path to be converted from $build to $host format.
+# Result will be available in $func_to_host_file_result.
+
+
+# func_to_host_file ARG
+# Converts the file name ARG from $build format to $host format. Return result
+# in func_to_host_file_result.
+func_to_host_file ()
+{
+ $opt_debug
+ $to_host_file_cmd "$1"
+}
+# end func_to_host_file
+
+
+# func_to_tool_file ARG LAZY
+# converts the file name ARG from $build format to toolchain format. Return
+# result in func_to_tool_file_result. If the conversion in use is listed
+# in (the comma separated) LAZY, no conversion takes place.
+func_to_tool_file ()
+{
+ $opt_debug
+ case ,$2, in
+ *,"$to_tool_file_cmd",*)
+ func_to_tool_file_result=$1
+ ;;
+ *)
+ $to_tool_file_cmd "$1"
+ func_to_tool_file_result=$func_to_host_file_result
+ ;;
+ esac
+}
+# end func_to_tool_file
+
+
+# func_convert_file_noop ARG
+# Copy ARG to func_to_host_file_result.
+func_convert_file_noop ()
+{
+ func_to_host_file_result="$1"
+}
+# end func_convert_file_noop
+
+
+# func_convert_file_msys_to_w32 ARG
+# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
+# conversion to w32 is not available inside the cwrapper. Returns result in
+# func_to_host_file_result.
+func_convert_file_msys_to_w32 ()
+{
+ $opt_debug
+ func_to_host_file_result="$1"
+ if test -n "$1"; then
+ func_convert_core_msys_to_w32 "$1"
+ func_to_host_file_result="$func_convert_core_msys_to_w32_result"
+ fi
+ func_convert_file_check "$1" "$func_to_host_file_result"
+}
+# end func_convert_file_msys_to_w32
+
+
+# func_convert_file_cygwin_to_w32 ARG
+# Convert file name ARG from Cygwin to w32 format. Returns result in
+# func_to_host_file_result.
+func_convert_file_cygwin_to_w32 ()
+{
+ $opt_debug
+ func_to_host_file_result="$1"
+ if test -n "$1"; then
+ # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
+ # LT_CYGPATH in this case.
+ func_to_host_file_result=`cygpath -m "$1"`
+ fi
+ func_convert_file_check "$1" "$func_to_host_file_result"
+}
+# end func_convert_file_cygwin_to_w32
+
+
+# func_convert_file_nix_to_w32 ARG
+# Convert file name ARG from *nix to w32 format. Requires a wine environment
+# and a working winepath. Returns result in func_to_host_file_result.
+func_convert_file_nix_to_w32 ()
+{
+ $opt_debug
+ func_to_host_file_result="$1"
+ if test -n "$1"; then
+ func_convert_core_file_wine_to_w32 "$1"
+ func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
+ fi
+ func_convert_file_check "$1" "$func_to_host_file_result"
+}
+# end func_convert_file_nix_to_w32
+
+
+# func_convert_file_msys_to_cygwin ARG
+# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
+# Returns result in func_to_host_file_result.
+func_convert_file_msys_to_cygwin ()
+{
+ $opt_debug
+ func_to_host_file_result="$1"
+ if test -n "$1"; then
+ func_convert_core_msys_to_w32 "$1"
+ func_cygpath -u "$func_convert_core_msys_to_w32_result"
+ func_to_host_file_result="$func_cygpath_result"
+ fi
+ func_convert_file_check "$1" "$func_to_host_file_result"
+}
+# end func_convert_file_msys_to_cygwin
+
+
+# func_convert_file_nix_to_cygwin ARG
+# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed
+# in a wine environment, working winepath, and LT_CYGPATH set. Returns result
+# in func_to_host_file_result.
+func_convert_file_nix_to_cygwin ()
+{
+ $opt_debug
+ func_to_host_file_result="$1"
+ if test -n "$1"; then
+ # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
+ func_convert_core_file_wine_to_w32 "$1"
+ func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
+ func_to_host_file_result="$func_cygpath_result"
+ fi
+ func_convert_file_check "$1" "$func_to_host_file_result"
+}
+# end func_convert_file_nix_to_cygwin
+
+
+#############################################
+# $build to $host PATH CONVERSION FUNCTIONS #
+#############################################
+# invoked via `$to_host_path_cmd ARG'
+#
+# In each case, ARG is the path to be converted from $build to $host format.
+# The result will be available in $func_to_host_path_result.
+#
+# Path separators are also converted from $build format to $host format. If
+# ARG begins or ends with a path separator character, it is preserved (but
+# converted to $host format) on output.
+#
+# All path conversion functions are named using the following convention:
+# file name conversion function : func_convert_file_X_to_Y ()
+# path conversion function : func_convert_path_X_to_Y ()
+# where, for any given $build/$host combination the 'X_to_Y' value is the
+# same. If conversion functions are added for new $build/$host combinations,
+# the two new functions must follow this pattern, or func_init_to_host_path_cmd
+# will break.
+
+
+# func_init_to_host_path_cmd
+# Ensures that function "pointer" variable $to_host_path_cmd is set to the
+# appropriate value, based on the value of $to_host_file_cmd.
+to_host_path_cmd=
+func_init_to_host_path_cmd ()
+{
+ $opt_debug
+ if test -z "$to_host_path_cmd"; then
+ func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
+ to_host_path_cmd="func_convert_path_${func_stripname_result}"
+ fi
+}
+
+
+# func_to_host_path ARG
+# Converts the path ARG from $build format to $host format. Return result
+# in func_to_host_path_result.
+func_to_host_path ()
+{
+ $opt_debug
+ func_init_to_host_path_cmd
+ $to_host_path_cmd "$1"
+}
+# end func_to_host_path
+
+
+# func_convert_path_noop ARG
+# Copy ARG to func_to_host_path_result.
+func_convert_path_noop ()
+{
+ func_to_host_path_result="$1"
+}
+# end func_convert_path_noop
+
+
+# func_convert_path_msys_to_w32 ARG
+# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
+# conversion to w32 is not available inside the cwrapper. Returns result in
+# func_to_host_path_result.
+func_convert_path_msys_to_w32 ()
+{
+ $opt_debug
+ func_to_host_path_result="$1"
+ if test -n "$1"; then
+ # Remove leading and trailing path separator characters from ARG. MSYS
+ # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
+ # and winepath ignores them completely.
+ func_stripname : : "$1"
+ func_to_host_path_tmp1=$func_stripname_result
+ func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
+ func_to_host_path_result="$func_convert_core_msys_to_w32_result"
+ func_convert_path_check : ";" \
+ "$func_to_host_path_tmp1" "$func_to_host_path_result"
+ func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
+ fi
+}
+# end func_convert_path_msys_to_w32
+
+
+# func_convert_path_cygwin_to_w32 ARG
+# Convert path ARG from Cygwin to w32 format. Returns result in
+# func_to_host_file_result.
+func_convert_path_cygwin_to_w32 ()
+{
+ $opt_debug
+ func_to_host_path_result="$1"
+ if test -n "$1"; then
+ # See func_convert_path_msys_to_w32:
+ func_stripname : : "$1"
+ func_to_host_path_tmp1=$func_stripname_result
+ func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
+ func_convert_path_check : ";" \
+ "$func_to_host_path_tmp1" "$func_to_host_path_result"
+ func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
+ fi
+}
+# end func_convert_path_cygwin_to_w32
+
+
+# func_convert_path_nix_to_w32 ARG
+# Convert path ARG from *nix to w32 format. Requires a wine environment and
+# a working winepath. Returns result in func_to_host_file_result.
+func_convert_path_nix_to_w32 ()
+{
+ $opt_debug
+ func_to_host_path_result="$1"
+ if test -n "$1"; then
+ # See func_convert_path_msys_to_w32:
+ func_stripname : : "$1"
+ func_to_host_path_tmp1=$func_stripname_result
+ func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
+ func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
+ func_convert_path_check : ";" \
+ "$func_to_host_path_tmp1" "$func_to_host_path_result"
+ func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
+ fi
+}
+# end func_convert_path_nix_to_w32
+
+
+# func_convert_path_msys_to_cygwin ARG
+# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
+# Returns result in func_to_host_file_result.
+func_convert_path_msys_to_cygwin ()
+{
+ $opt_debug
+ func_to_host_path_result="$1"
+ if test -n "$1"; then
+ # See func_convert_path_msys_to_w32:
+ func_stripname : : "$1"
+ func_to_host_path_tmp1=$func_stripname_result
+ func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
+ func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
+ func_to_host_path_result="$func_cygpath_result"
+ func_convert_path_check : : \
+ "$func_to_host_path_tmp1" "$func_to_host_path_result"
+ func_convert_path_front_back_pathsep ":*" "*:" : "$1"
+ fi
+}
+# end func_convert_path_msys_to_cygwin
+
+
+# func_convert_path_nix_to_cygwin ARG
+# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a
+# a wine environment, working winepath, and LT_CYGPATH set. Returns result in
+# func_to_host_file_result.
+func_convert_path_nix_to_cygwin ()
+{
+ $opt_debug
+ func_to_host_path_result="$1"
+ if test -n "$1"; then
+ # Remove leading and trailing path separator characters from
+ # ARG. msys behavior is inconsistent here, cygpath turns them
+ # into '.;' and ';.', and winepath ignores them completely.
+ func_stripname : : "$1"
+ func_to_host_path_tmp1=$func_stripname_result
+ func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
+ func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
+ func_to_host_path_result="$func_cygpath_result"
+ func_convert_path_check : : \
+ "$func_to_host_path_tmp1" "$func_to_host_path_result"
+ func_convert_path_front_back_pathsep ":*" "*:" : "$1"
+ fi
+}
+# end func_convert_path_nix_to_cygwin
+
+
+# func_mode_compile arg...
+func_mode_compile ()
+{
+ $opt_debug
+ # Get the compilation command and the source file.
+ base_compile=
+ srcfile="$nonopt" # always keep a non-empty value in "srcfile"
+ suppress_opt=yes
+ suppress_output=
+ arg_mode=normal
+ libobj=
+ later=
+ pie_flag=
+
+ for arg
+ do
+ case $arg_mode in
+ arg )
+ # do not "continue". Instead, add this to base_compile
+ lastarg="$arg"
+ arg_mode=normal
+ ;;
+
+ target )
+ libobj="$arg"
+ arg_mode=normal
+ continue
+ ;;
+
+ normal )
+ # Accept any command-line options.
+ case $arg in
+ -o)
+ test -n "$libobj" && \
+ func_fatal_error "you cannot specify \`-o' more than once"
+ arg_mode=target
+ continue
+ ;;
+
+ -pie | -fpie | -fPIE)
+ func_append pie_flag " $arg"
+ continue
+ ;;
+
+ -shared | -static | -prefer-pic | -prefer-non-pic)
+ func_append later " $arg"
+ continue
+ ;;
+
+ -no-suppress)
+ suppress_opt=no
+ continue
+ ;;
+
+ -Xcompiler)
+ arg_mode=arg # the next one goes into the "base_compile" arg list
+ continue # The current "srcfile" will either be retained or
+ ;; # replaced later. I would guess that would be a bug.
+
+ -Wc,*)
+ func_stripname '-Wc,' '' "$arg"
+ args=$func_stripname_result
+ lastarg=
+ save_ifs="$IFS"; IFS=','
+ for arg in $args; do
+ IFS="$save_ifs"
+ func_append_quoted lastarg "$arg"
+ done
+ IFS="$save_ifs"
+ func_stripname ' ' '' "$lastarg"
+ lastarg=$func_stripname_result
+
+ # Add the arguments to base_compile.
+ func_append base_compile " $lastarg"
+ continue
+ ;;
+
+ *)
+ # Accept the current argument as the source file.
+ # The previous "srcfile" becomes the current argument.
+ #
+ lastarg="$srcfile"
+ srcfile="$arg"
+ ;;
+ esac # case $arg
+ ;;
+ esac # case $arg_mode
+
+ # Aesthetically quote the previous argument.
+ func_append_quoted base_compile "$lastarg"
+ done # for arg
+
+ case $arg_mode in
+ arg)
+ func_fatal_error "you must specify an argument for -Xcompile"
+ ;;
+ target)
+ func_fatal_error "you must specify a target with \`-o'"
+ ;;
+ *)
+ # Get the name of the library object.
+ test -z "$libobj" && {
+ func_basename "$srcfile"
+ libobj="$func_basename_result"
+ }
+ ;;
+ esac
+
+ # Recognize several different file suffixes.
+ # If the user specifies -o file.o, it is replaced with file.lo
+ case $libobj in
+ *.[cCFSifmso] | \
+ *.ada | *.adb | *.ads | *.asm | \
+ *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
+ *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
+ func_xform "$libobj"
+ libobj=$func_xform_result
+ ;;
+ esac
+
+ case $libobj in
+ *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
+ *)
+ func_fatal_error "cannot determine name of library object from \`$libobj'"
+ ;;
+ esac
+
+ func_infer_tag $base_compile
+
+ for arg in $later; do
+ case $arg in
+ -shared)
+ test "$build_libtool_libs" != yes && \
+ func_fatal_configuration "can not build a shared library"
+ build_old_libs=no
+ continue
+ ;;
+
+ -static)
+ build_libtool_libs=no
+ build_old_libs=yes
+ continue
+ ;;
+
+ -prefer-pic)
+ pic_mode=yes
+ continue
+ ;;
+
+ -prefer-non-pic)
+ pic_mode=no
+ continue
+ ;;
+ esac
+ done
+
+ func_quote_for_eval "$libobj"
+ test "X$libobj" != "X$func_quote_for_eval_result" \
+ && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \
+ && func_warning "libobj name \`$libobj' may not contain shell special characters."
+ func_dirname_and_basename "$obj" "/" ""
+ objname="$func_basename_result"
+ xdir="$func_dirname_result"
+ lobj=${xdir}$objdir/$objname
+
+ test -z "$base_compile" && \
+ func_fatal_help "you must specify a compilation command"
+
+ # Delete any leftover library objects.
+ if test "$build_old_libs" = yes; then
+ removelist="$obj $lobj $libobj ${libobj}T"
+ else
+ removelist="$lobj $libobj ${libobj}T"
+ fi
+
+ # On Cygwin there's no "real" PIC flag so we must build both object types
+ case $host_os in
+ cygwin* | mingw* | pw32* | os2* | cegcc*)
+ pic_mode=default
+ ;;
+ esac
+ if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
+ # non-PIC code in shared libraries is not supported
+ pic_mode=default
+ fi
+
+ # Calculate the filename of the output object if compiler does
+ # not support -o with -c
+ if test "$compiler_c_o" = no; then
+ output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
+ lockfile="$output_obj.lock"
+ else
+ output_obj=
+ need_locks=no
+ lockfile=
+ fi
+
+ # Lock this critical section if it is needed
+ # We use this script file to make the link, it avoids creating a new file
+ if test "$need_locks" = yes; then
+ until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
+ func_echo "Waiting for $lockfile to be removed"
+ sleep 2
+ done
+ elif test "$need_locks" = warn; then
+ if test -f "$lockfile"; then
+ $ECHO "\
+*** ERROR, $lockfile exists and contains:
+`cat $lockfile 2>/dev/null`
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together. If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+ $opt_dry_run || $RM $removelist
+ exit $EXIT_FAILURE
+ fi
+ func_append removelist " $output_obj"
+ $ECHO "$srcfile" > "$lockfile"
+ fi
+
+ $opt_dry_run || $RM $removelist
+ func_append removelist " $lockfile"
+ trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
+
+ func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
+ srcfile=$func_to_tool_file_result
+ func_quote_for_eval "$srcfile"
+ qsrcfile=$func_quote_for_eval_result
+
+ # Only build a PIC object if we are building libtool libraries.
+ if test "$build_libtool_libs" = yes; then
+ # Without this assignment, base_compile gets emptied.
+ fbsd_hideous_sh_bug=$base_compile
+
+ if test "$pic_mode" != no; then
+ command="$base_compile $qsrcfile $pic_flag"
+ else
+ # Don't build PIC code
+ command="$base_compile $qsrcfile"
+ fi
+
+ func_mkdir_p "$xdir$objdir"
+
+ if test -z "$output_obj"; then
+ # Place PIC objects in $objdir
+ func_append command " -o $lobj"
+ fi
+
+ func_show_eval_locale "$command" \
+ 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
+
+ if test "$need_locks" = warn &&
+ test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
+ $ECHO "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together. If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+ $opt_dry_run || $RM $removelist
+ exit $EXIT_FAILURE
+ fi
+
+ # Just move the object if needed, then go on to compile the next one
+ if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
+ func_show_eval '$MV "$output_obj" "$lobj"' \
+ 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
+ fi
+
+ # Allow error messages only from the first compilation.
+ if test "$suppress_opt" = yes; then
+ suppress_output=' >/dev/null 2>&1'
+ fi
+ fi
+
+ # Only build a position-dependent object if we build old libraries.
+ if test "$build_old_libs" = yes; then
+ if test "$pic_mode" != yes; then
+ # Don't build PIC code
+ command="$base_compile $qsrcfile$pie_flag"
+ else
+ command="$base_compile $qsrcfile $pic_flag"
+ fi
+ if test "$compiler_c_o" = yes; then
+ func_append command " -o $obj"
+ fi
+
+ # Suppress compiler output if we already did a PIC compilation.
+ func_append command "$suppress_output"
+ func_show_eval_locale "$command" \
+ '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
+
+ if test "$need_locks" = warn &&
+ test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
+ $ECHO "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together. If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+ $opt_dry_run || $RM $removelist
+ exit $EXIT_FAILURE
+ fi
+
+ # Just move the object if needed
+ if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
+ func_show_eval '$MV "$output_obj" "$obj"' \
+ 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
+ fi
+ fi
+
+ $opt_dry_run || {
+ func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
+
+ # Unlock the critical section if it was locked
+ if test "$need_locks" != no; then
+ removelist=$lockfile
+ $RM "$lockfile"
+ fi
+ }
+
+ exit $EXIT_SUCCESS
+}
+
+$opt_help || {
+ test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
+}
+
+func_mode_help ()
+{
+ # We need to display help for each of the modes.
+ case $opt_mode in
+ "")
+ # Generic help is extracted from the usage comments
+ # at the start of this file.
+ func_help
+ ;;
+
+ clean)
+ $ECHO \
+"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
+
+Remove files from the build directory.
+
+RM is the name of the program to use to delete files associated with each FILE
+(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
+to RM.
+
+If FILE is a libtool library, object or program, all the files associated
+with it are deleted. Otherwise, only FILE itself is deleted using RM."
+ ;;
+
+ compile)
+ $ECHO \
+"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
+
+Compile a source file into a libtool library object.
+
+This mode accepts the following additional options:
+
+ -o OUTPUT-FILE set the output file name to OUTPUT-FILE
+ -no-suppress do not suppress compiler output for multiple passes
+ -prefer-pic try to build PIC objects only
+ -prefer-non-pic try to build non-PIC objects only
+ -shared do not build a \`.o' file suitable for static linking
+ -static only build a \`.o' file suitable for static linking
+ -Wc,FLAG pass FLAG directly to the compiler
+
+COMPILE-COMMAND is a command to be used in creating a \`standard' object file
+from the given SOURCEFILE.
+
+The output file name is determined by removing the directory component from
+SOURCEFILE, then substituting the C source code suffix \`.c' with the
+library object suffix, \`.lo'."
+ ;;
+
+ execute)
+ $ECHO \
+"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
+
+Automatically set library path, then run a program.
+
+This mode accepts the following additional options:
+
+ -dlopen FILE add the directory containing FILE to the library path
+
+This mode sets the library path environment variable according to \`-dlopen'
+flags.
+
+If any of the ARGS are libtool executable wrappers, then they are translated
+into their corresponding uninstalled binary, and any of their required library
+directories are added to the library path.
+
+Then, COMMAND is executed, with ARGS as arguments."
+ ;;
+
+ finish)
+ $ECHO \
+"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
+
+Complete the installation of libtool libraries.
+
+Each LIBDIR is a directory that contains libtool libraries.
+
+The commands that this mode executes may require superuser privileges. Use
+the \`--dry-run' option if you just want to see what would be executed."
+ ;;
+
+ install)
+ $ECHO \
+"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
+
+Install executables or libraries.
+
+INSTALL-COMMAND is the installation command. The first component should be
+either the \`install' or \`cp' program.
+
+The following components of INSTALL-COMMAND are treated specially:
+
+ -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation
+
+The rest of the components are interpreted as arguments to that command (only
+BSD-compatible install options are recognized)."
+ ;;
+
+ link)
+ $ECHO \
+"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
+
+Link object files or libraries together to form another library, or to
+create an executable program.
+
+LINK-COMMAND is a command using the C compiler that you would use to create
+a program from several object files.
+
+The following components of LINK-COMMAND are treated specially:
+
+ -all-static do not do any dynamic linking at all
+ -avoid-version do not add a version suffix if possible
+ -bindir BINDIR specify path to binaries directory (for systems where
+ libraries must be found in the PATH setting at runtime)
+ -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime
+ -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
+ -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
+ -export-symbols SYMFILE
+ try to export only the symbols listed in SYMFILE
+ -export-symbols-regex REGEX
+ try to export only the symbols matching REGEX
+ -LLIBDIR search LIBDIR for required installed libraries
+ -lNAME OUTPUT-FILE requires the installed library libNAME
+ -module build a library that can dlopened
+ -no-fast-install disable the fast-install mode
+ -no-install link a not-installable executable
+ -no-undefined declare that a library does not refer to external symbols
+ -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
+ -objectlist FILE Use a list of object files found in FILE to specify objects
+ -precious-files-regex REGEX
+ don't remove output files matching REGEX
+ -release RELEASE specify package release information
+ -rpath LIBDIR the created library will eventually be installed in LIBDIR
+ -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
+ -shared only do dynamic linking of libtool libraries
+ -shrext SUFFIX override the standard shared library file extension
+ -static do not do any dynamic linking of uninstalled libtool libraries
+ -static-libtool-libs
+ do not do any dynamic linking of libtool libraries
+ -version-info CURRENT[:REVISION[:AGE]]
+ specify library version info [each variable defaults to 0]
+ -weak LIBNAME declare that the target provides the LIBNAME interface
+ -Wc,FLAG
+ -Xcompiler FLAG pass linker-specific FLAG directly to the compiler
+ -Wl,FLAG
+ -Xlinker FLAG pass linker-specific FLAG directly to the linker
+ -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC)
+
+All other options (arguments beginning with \`-') are ignored.
+
+Every other argument is treated as a filename. Files ending in \`.la' are
+treated as uninstalled libtool libraries, other files are standard or library
+object files.
+
+If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
+only library objects (\`.lo' files) may be specified, and \`-rpath' is
+required, except when creating a convenience library.
+
+If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
+using \`ar' and \`ranlib', or on Windows using \`lib'.
+
+If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
+is created, otherwise an executable program is created."
+ ;;
+
+ uninstall)
+ $ECHO \
+"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
+
+Remove libraries from an installation directory.
+
+RM is the name of the program to use to delete files associated with each FILE
+(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
+to RM.
+
+If FILE is a libtool library, all the files associated with it are deleted.
+Otherwise, only FILE itself is deleted using RM."
+ ;;
+
+ *)
+ func_fatal_help "invalid operation mode \`$opt_mode'"
+ ;;
+ esac
+
+ echo
+ $ECHO "Try \`$progname --help' for more information about other modes."
+}
+
+# Now that we've collected a possible --mode arg, show help if necessary
+if $opt_help; then
+ if test "$opt_help" = :; then
+ func_mode_help
+ else
+ {
+ func_help noexit
+ for opt_mode in compile link execute install finish uninstall clean; do
+ func_mode_help
+ done
+ } | sed -n '1p; 2,$s/^Usage:/ or: /p'
+ {
+ func_help noexit
+ for opt_mode in compile link execute install finish uninstall clean; do
+ echo
+ func_mode_help
+ done
+ } |
+ sed '1d
+ /^When reporting/,/^Report/{
+ H
+ d
+ }
+ $x
+ /information about other modes/d
+ /more detailed .*MODE/d
+ s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
+ fi
+ exit $?
+fi
+
+
+# func_mode_execute arg...
+func_mode_execute ()
+{
+ $opt_debug
+ # The first argument is the command name.
+ cmd="$nonopt"
+ test -z "$cmd" && \
+ func_fatal_help "you must specify a COMMAND"
+
+ # Handle -dlopen flags immediately.
+ for file in $opt_dlopen; do
+ test -f "$file" \
+ || func_fatal_help "\`$file' is not a file"
+
+ dir=
+ case $file in
+ *.la)
+ func_resolve_sysroot "$file"
+ file=$func_resolve_sysroot_result
+
+ # Check to see that this really is a libtool archive.
+ func_lalib_unsafe_p "$file" \
+ || func_fatal_help "\`$lib' is not a valid libtool archive"
+
+ # Read the libtool library.
+ dlname=
+ library_names=
+ func_source "$file"
+
+ # Skip this library if it cannot be dlopened.
+ if test -z "$dlname"; then
+ # Warn if it was a shared library.
+ test -n "$library_names" && \
+ func_warning "\`$file' was not linked with \`-export-dynamic'"
+ continue
+ fi
+
+ func_dirname "$file" "" "."
+ dir="$func_dirname_result"
+
+ if test -f "$dir/$objdir/$dlname"; then
+ func_append dir "/$objdir"
+ else
+ if test ! -f "$dir/$dlname"; then
+ func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
+ fi
+ fi
+ ;;
+
+ *.lo)
+ # Just add the directory containing the .lo file.
+ func_dirname "$file" "" "."
+ dir="$func_dirname_result"
+ ;;
+
+ *)
+ func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
+ continue
+ ;;
+ esac
+
+ # Get the absolute pathname.
+ absdir=`cd "$dir" && pwd`
+ test -n "$absdir" && dir="$absdir"
+
+ # Now add the directory to shlibpath_var.
+ if eval "test -z \"\$$shlibpath_var\""; then
+ eval "$shlibpath_var=\"\$dir\""
+ else
+ eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
+ fi
+ done
+
+ # This variable tells wrapper scripts just to set shlibpath_var
+ # rather than running their programs.
+ libtool_execute_magic="$magic"
+
+ # Check if any of the arguments is a wrapper script.
+ args=
+ for file
+ do
+ case $file in
+ -* | *.la | *.lo ) ;;
+ *)
+ # Do a test to see if this is really a libtool program.
+ if func_ltwrapper_script_p "$file"; then
+ func_source "$file"
+ # Transform arg to wrapped name.
+ file="$progdir/$program"
+ elif func_ltwrapper_executable_p "$file"; then
+ func_ltwrapper_scriptname "$file"
+ func_source "$func_ltwrapper_scriptname_result"
+ # Transform arg to wrapped name.
+ file="$progdir/$program"
+ fi
+ ;;
+ esac
+ # Quote arguments (to preserve shell metacharacters).
+ func_append_quoted args "$file"
+ done
+
+ if test "X$opt_dry_run" = Xfalse; then
+ if test -n "$shlibpath_var"; then
+ # Export the shlibpath_var.
+ eval "export $shlibpath_var"
+ fi
+
+ # Restore saved environment variables
+ for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
+ do
+ eval "if test \"\${save_$lt_var+set}\" = set; then
+ $lt_var=\$save_$lt_var; export $lt_var
+ else
+ $lt_unset $lt_var
+ fi"
+ done
+
+ # Now prepare to actually exec the command.
+ exec_cmd="\$cmd$args"
+ else
+ # Display what would be done.
+ if test -n "$shlibpath_var"; then
+ eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
+ echo "export $shlibpath_var"
+ fi
+ $ECHO "$cmd$args"
+ exit $EXIT_SUCCESS
+ fi
+}
+
+test "$opt_mode" = execute && func_mode_execute ${1+"$@"}
+
+
+# func_mode_finish arg...
+func_mode_finish ()
+{
+ $opt_debug
+ libs=
+ libdirs=
+ admincmds=
+
+ for opt in "$nonopt" ${1+"$@"}
+ do
+ if test -d "$opt"; then
+ func_append libdirs " $opt"
+
+ elif test -f "$opt"; then
+ if func_lalib_unsafe_p "$opt"; then
+ func_append libs " $opt"
+ else
+ func_warning "\`$opt' is not a valid libtool archive"
+ fi
+
+ else
+ func_fatal_error "invalid argument \`$opt'"
+ fi
+ done
+
+ if test -n "$libs"; then
+ if test -n "$lt_sysroot"; then
+ sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
+ sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
+ else
+ sysroot_cmd=
+ fi
+
+ # Remove sysroot references
+ if $opt_dry_run; then
+ for lib in $libs; do
+ echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
+ done
+ else
+ tmpdir=`func_mktempdir`
+ for lib in $libs; do
+ sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
+ > $tmpdir/tmp-la
+ mv -f $tmpdir/tmp-la $lib
+ done
+ ${RM}r "$tmpdir"
+ fi
+ fi
+
+ if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
+ for libdir in $libdirs; do
+ if test -n "$finish_cmds"; then
+ # Do each command in the finish commands.
+ func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
+'"$cmd"'"'
+ fi
+ if test -n "$finish_eval"; then
+ # Do the single finish_eval.
+ eval cmds=\"$finish_eval\"
+ $opt_dry_run || eval "$cmds" || func_append admincmds "
+ $cmds"
+ fi
+ done
+ fi
+
+ # Exit here if they wanted silent mode.
+ $opt_silent && exit $EXIT_SUCCESS
+
+ if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
+ echo "----------------------------------------------------------------------"
+ echo "Libraries have been installed in:"
+ for libdir in $libdirs; do
+ $ECHO " $libdir"
+ done
+ echo
+ echo "If you ever happen to want to link against installed libraries"
+ echo "in a given directory, LIBDIR, you must either use libtool, and"
+ echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
+ echo "flag during linking and do at least one of the following:"
+ if test -n "$shlibpath_var"; then
+ echo " - add LIBDIR to the \`$shlibpath_var' environment variable"
+ echo " during execution"
+ fi
+ if test -n "$runpath_var"; then
+ echo " - add LIBDIR to the \`$runpath_var' environment variable"
+ echo " during linking"
+ fi
+ if test -n "$hardcode_libdir_flag_spec"; then
+ libdir=LIBDIR
+ eval flag=\"$hardcode_libdir_flag_spec\"
+
+ $ECHO " - use the \`$flag' linker flag"
+ fi
+ if test -n "$admincmds"; then
+ $ECHO " - have your system administrator run these commands:$admincmds"
+ fi
+ if test -f /etc/ld.so.conf; then
+ echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
+ fi
+ echo
+
+ echo "See any operating system documentation about shared libraries for"
+ case $host in
+ solaris2.[6789]|solaris2.1[0-9])
+ echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
+ echo "pages."
+ ;;
+ *)
+ echo "more information, such as the ld(1) and ld.so(8) manual pages."
+ ;;
+ esac
+ echo "----------------------------------------------------------------------"
+ fi
+ exit $EXIT_SUCCESS
+}
+
+test "$opt_mode" = finish && func_mode_finish ${1+"$@"}
+
+
+# func_mode_install arg...
+func_mode_install ()
+{
+ $opt_debug
+ # There may be an optional sh(1) argument at the beginning of
+ # install_prog (especially on Windows NT).
+ if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
+ # Allow the use of GNU shtool's install command.
+ case $nonopt in *shtool*) :;; *) false;; esac; then
+ # Aesthetically quote it.
+ func_quote_for_eval "$nonopt"
+ install_prog="$func_quote_for_eval_result "
+ arg=$1
+ shift
+ else
+ install_prog=
+ arg=$nonopt
+ fi
+
+ # The real first argument should be the name of the installation program.
+ # Aesthetically quote it.
+ func_quote_for_eval "$arg"
+ func_append install_prog "$func_quote_for_eval_result"
+ install_shared_prog=$install_prog
+ case " $install_prog " in
+ *[\\\ /]cp\ *) install_cp=: ;;
+ *) install_cp=false ;;
+ esac
+
+ # We need to accept at least all the BSD install flags.
+ dest=
+ files=
+ opts=
+ prev=
+ install_type=
+ isdir=no
+ stripme=
+ no_mode=:
+ for arg
+ do
+ arg2=
+ if test -n "$dest"; then
+ func_append files " $dest"
+ dest=$arg
+ continue
+ fi
+
+ case $arg in
+ -d) isdir=yes ;;
+ -f)
+ if $install_cp; then :; else
+ prev=$arg
+ fi
+ ;;
+ -g | -m | -o)
+ prev=$arg
+ ;;
+ -s)
+ stripme=" -s"
+ continue
+ ;;
+ -*)
+ ;;
+ *)
+ # If the previous option needed an argument, then skip it.
+ if test -n "$prev"; then
+ if test "x$prev" = x-m && test -n "$install_override_mode"; then
+ arg2=$install_override_mode
+ no_mode=false
+ fi
+ prev=
+ else
+ dest=$arg
+ continue
+ fi
+ ;;
+ esac
+
+ # Aesthetically quote the argument.
+ func_quote_for_eval "$arg"
+ func_append install_prog " $func_quote_for_eval_result"
+ if test -n "$arg2"; then
+ func_quote_for_eval "$arg2"
+ fi
+ func_append install_shared_prog " $func_quote_for_eval_result"
+ done
+
+ test -z "$install_prog" && \
+ func_fatal_help "you must specify an install program"
+
+ test -n "$prev" && \
+ func_fatal_help "the \`$prev' option requires an argument"
+
+ if test -n "$install_override_mode" && $no_mode; then
+ if $install_cp; then :; else
+ func_quote_for_eval "$install_override_mode"
+ func_append install_shared_prog " -m $func_quote_for_eval_result"
+ fi
+ fi
+
+ if test -z "$files"; then
+ if test -z "$dest"; then
+ func_fatal_help "no file or destination specified"
+ else
+ func_fatal_help "you must specify a destination"
+ fi
+ fi
+
+ # Strip any trailing slash from the destination.
+ func_stripname '' '/' "$dest"
+ dest=$func_stripname_result
+
+ # Check to see that the destination is a directory.
+ test -d "$dest" && isdir=yes
+ if test "$isdir" = yes; then
+ destdir="$dest"
+ destname=
+ else
+ func_dirname_and_basename "$dest" "" "."
+ destdir="$func_dirname_result"
+ destname="$func_basename_result"
+
+ # Not a directory, so check to see that there is only one file specified.
+ set dummy $files; shift
+ test "$#" -gt 1 && \
+ func_fatal_help "\`$dest' is not a directory"
+ fi
+ case $destdir in
+ [\\/]* | [A-Za-z]:[\\/]*) ;;
+ *)
+ for file in $files; do
+ case $file in
+ *.lo) ;;
+ *)
+ func_fatal_help "\`$destdir' must be an absolute directory name"
+ ;;
+ esac
+ done
+ ;;
+ esac
+
+ # This variable tells wrapper scripts just to set variables rather
+ # than running their programs.
+ libtool_install_magic="$magic"
+
+ staticlibs=
+ future_libdirs=
+ current_libdirs=
+ for file in $files; do
+
+ # Do each installation.
+ case $file in
+ *.$libext)
+ # Do the static libraries later.
+ func_append staticlibs " $file"
+ ;;
+
+ *.la)
+ func_resolve_sysroot "$file"
+ file=$func_resolve_sysroot_result
+
+ # Check to see that this really is a libtool archive.
+ func_lalib_unsafe_p "$file" \
+ || func_fatal_help "\`$file' is not a valid libtool archive"
+
+ library_names=
+ old_library=
+ relink_command=
+ func_source "$file"
+
+ # Add the libdir to current_libdirs if it is the destination.
+ if test "X$destdir" = "X$libdir"; then
+ case "$current_libdirs " in
+ *" $libdir "*) ;;
+ *) func_append current_libdirs " $libdir" ;;
+ esac
+ else
+ # Note the libdir as a future libdir.
+ case "$future_libdirs " in
+ *" $libdir "*) ;;
+ *) func_append future_libdirs " $libdir" ;;
+ esac
+ fi
+
+ func_dirname "$file" "/" ""
+ dir="$func_dirname_result"
+ func_append dir "$objdir"
+
+ if test -n "$relink_command"; then
+ # Determine the prefix the user has applied to our future dir.
+ inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
+
+ # Don't allow the user to place us outside of our expected
+ # location b/c this prevents finding dependent libraries that
+ # are installed to the same prefix.
+ # At present, this check doesn't affect windows .dll's that
+ # are installed into $libdir/../bin (currently, that works fine)
+ # but it's something to keep an eye on.
+ test "$inst_prefix_dir" = "$destdir" && \
+ func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
+
+ if test -n "$inst_prefix_dir"; then
+ # Stick the inst_prefix_dir data into the link command.
+ relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
+ else
+ relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
+ fi
+
+ func_warning "relinking \`$file'"
+ func_show_eval "$relink_command" \
+ 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
+ fi
+
+ # See the names of the shared library.
+ set dummy $library_names; shift
+ if test -n "$1"; then
+ realname="$1"
+ shift
+
+ srcname="$realname"
+ test -n "$relink_command" && srcname="$realname"T
+
+ # Install the shared library and build the symlinks.
+ func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
+ 'exit $?'
+ tstripme="$stripme"
+ case $host_os in
+ cygwin* | mingw* | pw32* | cegcc*)
+ case $realname in
+ *.dll.a)
+ tstripme=""
+ ;;
+ esac
+ ;;
+ esac
+ if test -n "$tstripme" && test -n "$striplib"; then
+ func_show_eval "$striplib $destdir/$realname" 'exit $?'
+ fi
+
+ if test "$#" -gt 0; then
+ # Delete the old symlinks, and create new ones.
+ # Try `ln -sf' first, because the `ln' binary might depend on
+ # the symlink we replace! Solaris /bin/ln does not understand -f,
+ # so we also need to try rm && ln -s.
+ for linkname
+ do
+ test "$linkname" != "$realname" \
+ && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
+ done
+ fi
+
+ # Do each command in the postinstall commands.
+ lib="$destdir/$realname"
+ func_execute_cmds "$postinstall_cmds" 'exit $?'
+ fi
+
+ # Install the pseudo-library for information purposes.
+ func_basename "$file"
+ name="$func_basename_result"
+ instname="$dir/$name"i
+ func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
+
+ # Maybe install the static library, too.
+ test -n "$old_library" && func_append staticlibs " $dir/$old_library"
+ ;;
+
+ *.lo)
+ # Install (i.e. copy) a libtool object.
+
+ # Figure out destination file name, if it wasn't already specified.
+ if test -n "$destname"; then
+ destfile="$destdir/$destname"
+ else
+ func_basename "$file"
+ destfile="$func_basename_result"
+ destfile="$destdir/$destfile"
+ fi
+
+ # Deduce the name of the destination old-style object file.
+ case $destfile in
+ *.lo)
+ func_lo2o "$destfile"
+ staticdest=$func_lo2o_result
+ ;;
+ *.$objext)
+ staticdest="$destfile"
+ destfile=
+ ;;
+ *)
+ func_fatal_help "cannot copy a libtool object to \`$destfile'"
+ ;;
+ esac
+
+ # Install the libtool object if requested.
+ test -n "$destfile" && \
+ func_show_eval "$install_prog $file $destfile" 'exit $?'
+
+ # Install the old object if enabled.
+ if test "$build_old_libs" = yes; then
+ # Deduce the name of the old-style object file.
+ func_lo2o "$file"
+ staticobj=$func_lo2o_result
+ func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
+ fi
+ exit $EXIT_SUCCESS
+ ;;
+
+ *)
+ # Figure out destination file name, if it wasn't already specified.
+ if test -n "$destname"; then
+ destfile="$destdir/$destname"
+ else
+ func_basename "$file"
+ destfile="$func_basename_result"
+ destfile="$destdir/$destfile"
+ fi
+
+ # If the file is missing, and there is a .exe on the end, strip it
+ # because it is most likely a libtool script we actually want to
+ # install
+ stripped_ext=""
+ case $file in
+ *.exe)
+ if test ! -f "$file"; then
+ func_stripname '' '.exe' "$file"
+ file=$func_stripname_result
+ stripped_ext=".exe"
+ fi
+ ;;
+ esac
+
+ # Do a test to see if this is really a libtool program.
+ case $host in
+ *cygwin* | *mingw*)
+ if func_ltwrapper_executable_p "$file"; then
+ func_ltwrapper_scriptname "$file"
+ wrapper=$func_ltwrapper_scriptname_result
+ else
+ func_stripname '' '.exe' "$file"
+ wrapper=$func_stripname_result
+ fi
+ ;;
+ *)
+ wrapper=$file
+ ;;
+ esac
+ if func_ltwrapper_script_p "$wrapper"; then
+ notinst_deplibs=
+ relink_command=
+
+ func_source "$wrapper"
+
+ # Check the variables that should have been set.
+ test -z "$generated_by_libtool_version" && \
+ func_fatal_error "invalid libtool wrapper script \`$wrapper'"
+
+ finalize=yes
+ for lib in $notinst_deplibs; do
+ # Check to see that each library is installed.
+ libdir=
+ if test -f "$lib"; then
+ func_source "$lib"
+ fi
+ libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
+ if test -n "$libdir" && test ! -f "$libfile"; then
+ func_warning "\`$lib' has not been installed in \`$libdir'"
+ finalize=no
+ fi
+ done
+
+ relink_command=
+ func_source "$wrapper"
+
+ outputname=
+ if test "$fast_install" = no && test -n "$relink_command"; then
+ $opt_dry_run || {
+ if test "$finalize" = yes; then
+ tmpdir=`func_mktempdir`
+ func_basename "$file$stripped_ext"
+ file="$func_basename_result"
+ outputname="$tmpdir/$file"
+ # Replace the output file specification.
+ relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
+
+ $opt_silent || {
+ func_quote_for_expand "$relink_command"
+ eval "func_echo $func_quote_for_expand_result"
+ }
+ if eval "$relink_command"; then :
+ else
+ func_error "error: relink \`$file' with the above command before installing it"
+ $opt_dry_run || ${RM}r "$tmpdir"
+ continue
+ fi
+ file="$outputname"
+ else
+ func_warning "cannot relink \`$file'"
+ fi
+ }
+ else
+ # Install the binary that we compiled earlier.
+ file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
+ fi
+ fi
+
+ # remove .exe since cygwin /usr/bin/install will append another
+ # one anyway
+ case $install_prog,$host in
+ */usr/bin/install*,*cygwin*)
+ case $file:$destfile in
+ *.exe:*.exe)
+ # this is ok
+ ;;
+ *.exe:*)
+ destfile=$destfile.exe
+ ;;
+ *:*.exe)
+ func_stripname '' '.exe' "$destfile"
+ destfile=$func_stripname_result
+ ;;
+ esac
+ ;;
+ esac
+ func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
+ $opt_dry_run || if test -n "$outputname"; then
+ ${RM}r "$tmpdir"
+ fi
+ ;;
+ esac
+ done
+
+ for file in $staticlibs; do
+ func_basename "$file"
+ name="$func_basename_result"
+
+ # Set up the ranlib parameters.
+ oldlib="$destdir/$name"
+ func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
+ tool_oldlib=$func_to_tool_file_result
+
+ func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
+
+ if test -n "$stripme" && test -n "$old_striplib"; then
+ func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
+ fi
+
+ # Do each command in the postinstall commands.
+ func_execute_cmds "$old_postinstall_cmds" 'exit $?'
+ done
+
+ test -n "$future_libdirs" && \
+ func_warning "remember to run \`$progname --finish$future_libdirs'"
+
+ if test -n "$current_libdirs"; then
+ # Maybe just do a dry run.
+ $opt_dry_run && current_libdirs=" -n$current_libdirs"
+ exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
+ else
+ exit $EXIT_SUCCESS
+ fi
+}
+
+test "$opt_mode" = install && func_mode_install ${1+"$@"}
+
+
+# func_generate_dlsyms outputname originator pic_p
+# Extract symbols from dlprefiles and create ${outputname}S.o with
+# a dlpreopen symbol table.
+func_generate_dlsyms ()
+{
+ $opt_debug
+ my_outputname="$1"
+ my_originator="$2"
+ my_pic_p="${3-no}"
+ my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
+ my_dlsyms=
+
+ if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+ if test -n "$NM" && test -n "$global_symbol_pipe"; then
+ my_dlsyms="${my_outputname}S.c"
+ else
+ func_error "not configured to extract global symbols from dlpreopened files"
+ fi
+ fi
+
+ if test -n "$my_dlsyms"; then
+ case $my_dlsyms in
+ "") ;;
+ *.c)
+ # Discover the nlist of each of the dlfiles.
+ nlist="$output_objdir/${my_outputname}.nm"
+
+ func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
+
+ # Parse the name list into a source file.
+ func_verbose "creating $output_objdir/$my_dlsyms"
+
+ $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
+/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
+/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
+
+#ifdef __cplusplus
+extern \"C\" {
+#endif
+
+#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
+#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
+#endif
+
+/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */
+#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
+/* DATA imports from DLLs on WIN32 con't be const, because runtime
+ relocations are performed -- see ld's documentation on pseudo-relocs. */
+# define LT_DLSYM_CONST
+#elif defined(__osf__)
+/* This system does not cope well with relocations in const data. */
+# define LT_DLSYM_CONST
+#else
+# define LT_DLSYM_CONST const
+#endif
+
+/* External symbol declarations for the compiler. */\
+"
+
+ if test "$dlself" = yes; then
+ func_verbose "generating symbol list for \`$output'"
+
+ $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
+
+ # Add our own program objects to the symbol list.
+ progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
+ for progfile in $progfiles; do
+ func_to_tool_file "$progfile" func_convert_file_msys_to_w32
+ func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
+ $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
+ done
+
+ if test -n "$exclude_expsyms"; then
+ $opt_dry_run || {
+ eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
+ eval '$MV "$nlist"T "$nlist"'
+ }
+ fi
+
+ if test -n "$export_symbols_regex"; then
+ $opt_dry_run || {
+ eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
+ eval '$MV "$nlist"T "$nlist"'
+ }
+ fi
+
+ # Prepare the list of exported symbols
+ if test -z "$export_symbols"; then
+ export_symbols="$output_objdir/$outputname.exp"
+ $opt_dry_run || {
+ $RM $export_symbols
+ eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
+ case $host in
+ *cygwin* | *mingw* | *cegcc* )
+ eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
+ eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
+ ;;
+ esac
+ }
+ else
+ $opt_dry_run || {
+ eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
+ eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
+ eval '$MV "$nlist"T "$nlist"'
+ case $host in
+ *cygwin* | *mingw* | *cegcc* )
+ eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
+ eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
+ ;;
+ esac
+ }
+ fi
+ fi
+
+ for dlprefile in $dlprefiles; do
+ func_verbose "extracting global C symbols from \`$dlprefile'"
+ func_basename "$dlprefile"
+ name="$func_basename_result"
+ case $host in
+ *cygwin* | *mingw* | *cegcc* )
+ # if an import library, we need to obtain dlname
+ if func_win32_import_lib_p "$dlprefile"; then
+ func_tr_sh "$dlprefile"
+ eval "curr_lafile=\$libfile_$func_tr_sh_result"
+ dlprefile_dlbasename=""
+ if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
+ # Use subshell, to avoid clobbering current variable values
+ dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
+ if test -n "$dlprefile_dlname" ; then
+ func_basename "$dlprefile_dlname"
+ dlprefile_dlbasename="$func_basename_result"
+ else
+ # no lafile. user explicitly requested -dlpreopen <import library>.
+ $sharedlib_from_linklib_cmd "$dlprefile"
+ dlprefile_dlbasename=$sharedlib_from_linklib_result
+ fi
+ fi
+ $opt_dry_run || {
+ if test -n "$dlprefile_dlbasename" ; then
+ eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
+ else
+ func_warning "Could not compute DLL name from $name"
+ eval '$ECHO ": $name " >> "$nlist"'
+ fi
+ func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
+ eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
+ $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
+ }
+ else # not an import lib
+ $opt_dry_run || {
+ eval '$ECHO ": $name " >> "$nlist"'
+ func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
+ eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
+ }
+ fi
+ ;;
+ *)
+ $opt_dry_run || {
+ eval '$ECHO ": $name " >> "$nlist"'
+ func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
+ eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
+ }
+ ;;
+ esac
+ done
+
+ $opt_dry_run || {
+ # Make sure we have at least an empty file.
+ test -f "$nlist" || : > "$nlist"
+
+ if test -n "$exclude_expsyms"; then
+ $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
+ $MV "$nlist"T "$nlist"
+ fi
+
+ # Try sorting and uniquifying the output.
+ if $GREP -v "^: " < "$nlist" |
+ if sort -k 3 </dev/null >/dev/null 2>&1; then
+ sort -k 3
+ else
+ sort +2
+ fi |
+ uniq > "$nlist"S; then
+ :
+ else
+ $GREP -v "^: " < "$nlist" > "$nlist"S
+ fi
+
+ if test -f "$nlist"S; then
+ eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
+ else
+ echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
+ fi
+
+ echo >> "$output_objdir/$my_dlsyms" "\
+
+/* The mapping between symbol names and symbols. */
+typedef struct {
+ const char *name;
+ void *address;
+} lt_dlsymlist;
+extern LT_DLSYM_CONST lt_dlsymlist
+lt_${my_prefix}_LTX_preloaded_symbols[];
+LT_DLSYM_CONST lt_dlsymlist
+lt_${my_prefix}_LTX_preloaded_symbols[] =
+{\
+ { \"$my_originator\", (void *) 0 },"
+
+ case $need_lib_prefix in
+ no)
+ eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
+ ;;
+ *)
+ eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
+ ;;
+ esac
+ echo >> "$output_objdir/$my_dlsyms" "\
+ {0, (void *) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+ return lt_${my_prefix}_LTX_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif\
+"
+ } # !$opt_dry_run
+
+ pic_flag_for_symtable=
+ case "$compile_command " in
+ *" -static "*) ;;
+ *)
+ case $host in
+ # compiling the symbol table file with pic_flag works around
+ # a FreeBSD bug that causes programs to crash when -lm is
+ # linked before any other PIC object. But we must not use
+ # pic_flag when linking with -static. The problem exists in
+ # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
+ *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
+ pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
+ *-*-hpux*)
+ pic_flag_for_symtable=" $pic_flag" ;;
+ *)
+ if test "X$my_pic_p" != Xno; then
+ pic_flag_for_symtable=" $pic_flag"
+ fi
+ ;;
+ esac
+ ;;
+ esac
+ symtab_cflags=
+ for arg in $LTCFLAGS; do
+ case $arg in
+ -pie | -fpie | -fPIE) ;;
+ *) func_append symtab_cflags " $arg" ;;
+ esac
+ done
+
+ # Now compile the dynamic symbol file.
+ func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
+
+ # Clean up the generated files.
+ func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
+
+ # Transform the symbol file into the correct name.
+ symfileobj="$output_objdir/${my_outputname}S.$objext"
+ case $host in
+ *cygwin* | *mingw* | *cegcc* )
+ if test -f "$output_objdir/$my_outputname.def"; then
+ compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
+ finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
+ else
+ compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
+ finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
+ fi
+ ;;
+ *)
+ compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
+ finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
+ ;;
+ esac
+ ;;
+ *)
+ func_fatal_error "unknown suffix for \`$my_dlsyms'"
+ ;;
+ esac
+ else
+ # We keep going just in case the user didn't refer to
+ # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
+ # really was required.
+
+ # Nullify the symbol file.
+ compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
+ finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
+ fi
+}
+
+# func_win32_libid arg
+# return the library type of file 'arg'
+#
+# Need a lot of goo to handle *both* DLLs and import libs
+# Has to be a shell function in order to 'eat' the argument
+# that is supplied when $file_magic_command is called.
+# Despite the name, also deal with 64 bit binaries.
+func_win32_libid ()
+{
+ $opt_debug
+ win32_libid_type="unknown"
+ win32_fileres=`file -L $1 2>/dev/null`
+ case $win32_fileres in
+ *ar\ archive\ import\ library*) # definitely import
+ win32_libid_type="x86 archive import"
+ ;;
+ *ar\ archive*) # could be an import, or static
+ # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
+ if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
+ $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
+ func_to_tool_file "$1" func_convert_file_msys_to_w32
+ win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
+ $SED -n -e '
+ 1,100{
+ / I /{
+ s,.*,import,
+ p
+ q
+ }
+ }'`
+ case $win32_nmres in
+ import*) win32_libid_type="x86 archive import";;
+ *) win32_libid_type="x86 archive static";;
+ esac
+ fi
+ ;;
+ *DLL*)
+ win32_libid_type="x86 DLL"
+ ;;
+ *executable*) # but shell scripts are "executable" too...
+ case $win32_fileres in
+ *MS\ Windows\ PE\ Intel*)
+ win32_libid_type="x86 DLL"
+ ;;
+ esac
+ ;;
+ esac
+ $ECHO "$win32_libid_type"
+}
+
+# func_cygming_dll_for_implib ARG
+#
+# Platform-specific function to extract the
+# name of the DLL associated with the specified
+# import library ARG.
+# Invoked by eval'ing the libtool variable
+# $sharedlib_from_linklib_cmd
+# Result is available in the variable
+# $sharedlib_from_linklib_result
+func_cygming_dll_for_implib ()
+{
+ $opt_debug
+ sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
+}
+
+# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
+#
+# The is the core of a fallback implementation of a
+# platform-specific function to extract the name of the
+# DLL associated with the specified import library LIBNAME.
+#
+# SECTION_NAME is either .idata$6 or .idata$7, depending
+# on the platform and compiler that created the implib.
+#
+# Echos the name of the DLL associated with the
+# specified import library.
+func_cygming_dll_for_implib_fallback_core ()
+{
+ $opt_debug
+ match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
+ $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
+ $SED '/^Contents of section '"$match_literal"':/{
+ # Place marker at beginning of archive member dllname section
+ s/.*/====MARK====/
+ p
+ d
+ }
+ # These lines can sometimes be longer than 43 characters, but
+ # are always uninteresting
+ /:[ ]*file format pe[i]\{,1\}-/d
+ /^In archive [^:]*:/d
+ # Ensure marker is printed
+ /^====MARK====/p
+ # Remove all lines with less than 43 characters
+ /^.\{43\}/!d
+ # From remaining lines, remove first 43 characters
+ s/^.\{43\}//' |
+ $SED -n '
+ # Join marker and all lines until next marker into a single line
+ /^====MARK====/ b para
+ H
+ $ b para
+ b
+ :para
+ x
+ s/\n//g
+ # Remove the marker
+ s/^====MARK====//
+ # Remove trailing dots and whitespace
+ s/[\. \t]*$//
+ # Print
+ /./p' |
+ # we now have a list, one entry per line, of the stringified
+ # contents of the appropriate section of all members of the
+ # archive which possess that section. Heuristic: eliminate
+ # all those which have a first or second character that is
+ # a '.' (that is, objdump's representation of an unprintable
+ # character.) This should work for all archives with less than
+ # 0x302f exports -- but will fail for DLLs whose name actually
+ # begins with a literal '.' or a single character followed by
+ # a '.'.
+ #
+ # Of those that remain, print the first one.
+ $SED -e '/^\./d;/^.\./d;q'
+}
+
+# func_cygming_gnu_implib_p ARG
+# This predicate returns with zero status (TRUE) if
+# ARG is a GNU/binutils-style import library. Returns
+# with nonzero status (FALSE) otherwise.
+func_cygming_gnu_implib_p ()
+{
+ $opt_debug
+ func_to_tool_file "$1" func_convert_file_msys_to_w32
+ func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'`
+ test -n "$func_cygming_gnu_implib_tmp"
+}
+
+# func_cygming_ms_implib_p ARG
+# This predicate returns with zero status (TRUE) if
+# ARG is an MS-style import library. Returns
+# with nonzero status (FALSE) otherwise.
+func_cygming_ms_implib_p ()
+{
+ $opt_debug
+ func_to_tool_file "$1" func_convert_file_msys_to_w32
+ func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
+ test -n "$func_cygming_ms_implib_tmp"
+}
+
+# func_cygming_dll_for_implib_fallback ARG
+# Platform-specific function to extract the
+# name of the DLL associated with the specified
+# import library ARG.
+#
+# This fallback implementation is for use when $DLLTOOL
+# does not support the --identify-strict option.
+# Invoked by eval'ing the libtool variable
+# $sharedlib_from_linklib_cmd
+# Result is available in the variable
+# $sharedlib_from_linklib_result
+func_cygming_dll_for_implib_fallback ()
+{
+ $opt_debug
+ if func_cygming_gnu_implib_p "$1" ; then
+ # binutils import library
+ sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
+ elif func_cygming_ms_implib_p "$1" ; then
+ # ms-generated import library
+ sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
+ else
+ # unknown
+ sharedlib_from_linklib_result=""
+ fi
+}
+
+
+# func_extract_an_archive dir oldlib
+func_extract_an_archive ()
+{
+ $opt_debug
+ f_ex_an_ar_dir="$1"; shift
+ f_ex_an_ar_oldlib="$1"
+ if test "$lock_old_archive_extraction" = yes; then
+ lockfile=$f_ex_an_ar_oldlib.lock
+ until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
+ func_echo "Waiting for $lockfile to be removed"
+ sleep 2
+ done
+ fi
+ func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
+ 'stat=$?; rm -f "$lockfile"; exit $stat'
+ if test "$lock_old_archive_extraction" = yes; then
+ $opt_dry_run || rm -f "$lockfile"
+ fi
+ if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
+ :
+ else
+ func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
+ fi
+}
+
+
+# func_extract_archives gentop oldlib ...
+func_extract_archives ()
+{
+ $opt_debug
+ my_gentop="$1"; shift
+ my_oldlibs=${1+"$@"}
+ my_oldobjs=""
+ my_xlib=""
+ my_xabs=""
+ my_xdir=""
+
+ for my_xlib in $my_oldlibs; do
+ # Extract the objects.
+ case $my_xlib in
+ [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
+ *) my_xabs=`pwd`"/$my_xlib" ;;
+ esac
+ func_basename "$my_xlib"
+ my_xlib="$func_basename_result"
+ my_xlib_u=$my_xlib
+ while :; do
+ case " $extracted_archives " in
+ *" $my_xlib_u "*)
+ func_arith $extracted_serial + 1
+ extracted_serial=$func_arith_result
+ my_xlib_u=lt$extracted_serial-$my_xlib ;;
+ *) break ;;
+ esac
+ done
+ extracted_archives="$extracted_archives $my_xlib_u"
+ my_xdir="$my_gentop/$my_xlib_u"
+
+ func_mkdir_p "$my_xdir"
+
+ case $host in
+ *-darwin*)
+ func_verbose "Extracting $my_xabs"
+ # Do not bother doing anything if just a dry run
+ $opt_dry_run || {
+ darwin_orig_dir=`pwd`
+ cd $my_xdir || exit $?
+ darwin_archive=$my_xabs
+ darwin_curdir=`pwd`
+ darwin_base_archive=`basename "$darwin_archive"`
+ darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
+ if test -n "$darwin_arches"; then
+ darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
+ darwin_arch=
+ func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
+ for darwin_arch in $darwin_arches ; do
+ func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
+ $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
+ cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
+ func_extract_an_archive "`pwd`" "${darwin_base_archive}"
+ cd "$darwin_curdir"
+ $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
+ done # $darwin_arches
+ ## Okay now we've a bunch of thin objects, gotta fatten them up :)
+ darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
+ darwin_file=
+ darwin_files=
+ for darwin_file in $darwin_filelist; do
+ darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
+ $LIPO -create -output "$darwin_file" $darwin_files
+ done # $darwin_filelist
+ $RM -rf unfat-$$
+ cd "$darwin_orig_dir"
+ else
+ cd $darwin_orig_dir
+ func_extract_an_archive "$my_xdir" "$my_xabs"
+ fi # $darwin_arches
+ } # !$opt_dry_run
+ ;;
+ *)
+ func_extract_an_archive "$my_xdir" "$my_xabs"
+ ;;
+ esac
+ my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
+ done
+
+ func_extract_archives_result="$my_oldobjs"
+}
+
+
+# func_emit_wrapper [arg=no]
+#
+# Emit a libtool wrapper script on stdout.
+# Don't directly open a file because we may want to
+# incorporate the script contents within a cygwin/mingw
+# wrapper executable. Must ONLY be called from within
+# func_mode_link because it depends on a number of variables
+# set therein.
+#
+# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
+# variable will take. If 'yes', then the emitted script
+# will assume that the directory in which it is stored is
+# the $objdir directory. This is a cygwin/mingw-specific
+# behavior.
+func_emit_wrapper ()
+{
+ func_emit_wrapper_arg1=${1-no}
+
+ $ECHO "\
+#! $SHELL
+
+# $output - temporary wrapper script for $objdir/$outputname
+# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+#
+# The $output program cannot be directly executed until all the libtool
+# libraries that it depends on are installed.
+#
+# This wrapper script should never be moved out of the build directory.
+# If it is, it will not operate correctly.
+
+# Sed substitution that helps us do robust quoting. It backslashifies
+# metacharacters that are still active within double-quoted strings.
+sed_quote_subst='$sed_quote_subst'
+
+# Be Bourne compatible
+if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '\${1+\"\$@\"}'='\"\$@\"'
+ setopt NO_GLOB_SUBST
+else
+ case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+relink_command=\"$relink_command\"
+
+# This environment variable determines our operation mode.
+if test \"\$libtool_install_magic\" = \"$magic\"; then
+ # install mode needs the following variables:
+ generated_by_libtool_version='$macro_version'
+ notinst_deplibs='$notinst_deplibs'
+else
+ # When we are sourced in execute mode, \$file and \$ECHO are already set.
+ if test \"\$libtool_execute_magic\" != \"$magic\"; then
+ file=\"\$0\""
+
+ qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
+ $ECHO "\
+
+# A function that is used when there is no print builtin or printf.
+func_fallback_echo ()
+{
+ eval 'cat <<_LTECHO_EOF
+\$1
+_LTECHO_EOF'
+}
+ ECHO=\"$qECHO\"
+ fi
+
+# Very basic option parsing. These options are (a) specific to
+# the libtool wrapper, (b) are identical between the wrapper
+# /script/ and the wrapper /executable/ which is used only on
+# windows platforms, and (c) all begin with the string "--lt-"
+# (application programs are unlikely to have options which match
+# this pattern).
+#
+# There are only two supported options: --lt-debug and
+# --lt-dump-script. There is, deliberately, no --lt-help.
+#
+# The first argument to this parsing function should be the
+# script's $0 value, followed by "$@".
+lt_option_debug=
+func_parse_lt_options ()
+{
+ lt_script_arg0=\$0
+ shift
+ for lt_opt
+ do
+ case \"\$lt_opt\" in
+ --lt-debug) lt_option_debug=1 ;;
+ --lt-dump-script)
+ lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
+ test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
+ lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
+ cat \"\$lt_dump_D/\$lt_dump_F\"
+ exit 0
+ ;;
+ --lt-*)
+ \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
+ exit 1
+ ;;
+ esac
+ done
+
+ # Print the debug banner immediately:
+ if test -n \"\$lt_option_debug\"; then
+ echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
+ fi
+}
+
+# Used when --lt-debug. Prints its arguments to stdout
+# (redirection is the responsibility of the caller)
+func_lt_dump_args ()
+{
+ lt_dump_args_N=1;
+ for lt_arg
+ do
+ \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
+ lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
+ done
+}
+
+# Core function for launching the target application
+func_exec_program_core ()
+{
+"
+ case $host in
+ # Backslashes separate directories on plain windows
+ *-*-mingw | *-*-os2* | *-cegcc*)
+ $ECHO "\
+ if test -n \"\$lt_option_debug\"; then
+ \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
+ func_lt_dump_args \${1+\"\$@\"} 1>&2
+ fi
+ exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
+"
+ ;;
+
+ *)
+ $ECHO "\
+ if test -n \"\$lt_option_debug\"; then
+ \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
+ func_lt_dump_args \${1+\"\$@\"} 1>&2
+ fi
+ exec \"\$progdir/\$program\" \${1+\"\$@\"}
+"
+ ;;
+ esac
+ $ECHO "\
+ \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
+ exit 1
+}
+
+# A function to encapsulate launching the target application
+# Strips options in the --lt-* namespace from \$@ and
+# launches target application with the remaining arguments.
+func_exec_program ()
+{
+ case \" \$* \" in
+ *\\ --lt-*)
+ for lt_wr_arg
+ do
+ case \$lt_wr_arg in
+ --lt-*) ;;
+ *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
+ esac
+ shift
+ done ;;
+ esac
+ func_exec_program_core \${1+\"\$@\"}
+}
+
+ # Parse options
+ func_parse_lt_options \"\$0\" \${1+\"\$@\"}
+
+ # Find the directory that this script lives in.
+ thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
+ test \"x\$thisdir\" = \"x\$file\" && thisdir=.
+
+ # Follow symbolic links until we get to the real thisdir.
+ file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
+ while test -n \"\$file\"; do
+ destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
+
+ # If there was a directory component, then change thisdir.
+ if test \"x\$destdir\" != \"x\$file\"; then
+ case \"\$destdir\" in
+ [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
+ *) thisdir=\"\$thisdir/\$destdir\" ;;
+ esac
+ fi
+
+ file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
+ file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
+ done
+
+ # Usually 'no', except on cygwin/mingw when embedded into
+ # the cwrapper.
+ WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
+ if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
+ # special case for '.'
+ if test \"\$thisdir\" = \".\"; then
+ thisdir=\`pwd\`
+ fi
+ # remove .libs from thisdir
+ case \"\$thisdir\" in
+ *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
+ $objdir ) thisdir=. ;;
+ esac
+ fi
+
+ # Try to get the absolute directory name.
+ absdir=\`cd \"\$thisdir\" && pwd\`
+ test -n \"\$absdir\" && thisdir=\"\$absdir\"
+"
+
+ if test "$fast_install" = yes; then
+ $ECHO "\
+ program=lt-'$outputname'$exeext
+ progdir=\"\$thisdir/$objdir\"
+
+ if test ! -f \"\$progdir/\$program\" ||
+ { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
+ test \"X\$file\" != \"X\$progdir/\$program\"; }; then
+
+ file=\"\$\$-\$program\"
+
+ if test ! -d \"\$progdir\"; then
+ $MKDIR \"\$progdir\"
+ else
+ $RM \"\$progdir/\$file\"
+ fi"
+
+ $ECHO "\
+
+ # relink executable if necessary
+ if test -n \"\$relink_command\"; then
+ if relink_command_output=\`eval \$relink_command 2>&1\`; then :
+ else
+ $ECHO \"\$relink_command_output\" >&2
+ $RM \"\$progdir/\$file\"
+ exit 1
+ fi
+ fi
+
+ $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
+ { $RM \"\$progdir/\$program\";
+ $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
+ $RM \"\$progdir/\$file\"
+ fi"
+ else
+ $ECHO "\
+ program='$outputname'
+ progdir=\"\$thisdir/$objdir\"
+"
+ fi
+
+ $ECHO "\
+
+ if test -f \"\$progdir/\$program\"; then"
+
+ # fixup the dll searchpath if we need to.
+ #
+ # Fix the DLL searchpath if we need to. Do this before prepending
+ # to shlibpath, because on Windows, both are PATH and uninstalled
+ # libraries must come first.
+ if test -n "$dllsearchpath"; then
+ $ECHO "\
+ # Add the dll search path components to the executable PATH
+ PATH=$dllsearchpath:\$PATH
+"
+ fi
+
+ # Export our shlibpath_var if we have one.
+ if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+ $ECHO "\
+ # Add our own library path to $shlibpath_var
+ $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
+
+ # Some systems cannot cope with colon-terminated $shlibpath_var
+ # The second colon is a workaround for a bug in BeOS R4 sed
+ $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
+
+ export $shlibpath_var
+"
+ fi
+
+ $ECHO "\
+ if test \"\$libtool_execute_magic\" != \"$magic\"; then
+ # Run the actual program with our arguments.
+ func_exec_program \${1+\"\$@\"}
+ fi
+ else
+ # The program doesn't exist.
+ \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
+ \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
+ \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
+ exit 1
+ fi
+fi\
+"
+}
+
+
+# func_emit_cwrapperexe_src
+# emit the source code for a wrapper executable on stdout
+# Must ONLY be called from within func_mode_link because
+# it depends on a number of variable set therein.
+func_emit_cwrapperexe_src ()
+{
+ cat <<EOF
+
+/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
+ Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+
+ The $output program cannot be directly executed until all the libtool
+ libraries that it depends on are installed.
+
+ This wrapper executable should never be moved out of the build directory.
+ If it is, it will not operate correctly.
+*/
+EOF
+ cat <<"EOF"
+#ifdef _MSC_VER
+# define _CRT_SECURE_NO_DEPRECATE 1
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#ifdef _MSC_VER
+# include <direct.h>
+# include <process.h>
+# include <io.h>
+#else
+# include <unistd.h>
+# include <stdint.h>
+# ifdef __CYGWIN__
+# include <io.h>
+# endif
+#endif
+#include <malloc.h>
+#include <stdarg.h>
+#include <assert.h>
+#include <string.h>
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+
+/* declarations of non-ANSI functions */
+#if defined(__MINGW32__)
+# ifdef __STRICT_ANSI__
+int _putenv (const char *);
+# endif
+#elif defined(__CYGWIN__)
+# ifdef __STRICT_ANSI__
+char *realpath (const char *, char *);
+int putenv (char *);
+int setenv (const char *, const char *, int);
+# endif
+/* #elif defined (other platforms) ... */
+#endif
+
+/* portability defines, excluding path handling macros */
+#if defined(_MSC_VER)
+# define setmode _setmode
+# define stat _stat
+# define chmod _chmod
+# define getcwd _getcwd
+# define putenv _putenv
+# define S_IXUSR _S_IEXEC
+# ifndef _INTPTR_T_DEFINED
+# define _INTPTR_T_DEFINED
+# define intptr_t int
+# endif
+#elif defined(__MINGW32__)
+# define setmode _setmode
+# define stat _stat
+# define chmod _chmod
+# define getcwd _getcwd
+# define putenv _putenv
+#elif defined(__CYGWIN__)
+# define HAVE_SETENV
+# define FOPEN_WB "wb"
+/* #elif defined (other platforms) ... */
+#endif
+
+#if defined(PATH_MAX)
+# define LT_PATHMAX PATH_MAX
+#elif defined(MAXPATHLEN)
+# define LT_PATHMAX MAXPATHLEN
+#else
+# define LT_PATHMAX 1024
+#endif
+
+#ifndef S_IXOTH
+# define S_IXOTH 0
+#endif
+#ifndef S_IXGRP
+# define S_IXGRP 0
+#endif
+
+/* path handling portability macros */
+#ifndef DIR_SEPARATOR
+# define DIR_SEPARATOR '/'
+# define PATH_SEPARATOR ':'
+#endif
+
+#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
+ defined (__OS2__)
+# define HAVE_DOS_BASED_FILE_SYSTEM
+# define FOPEN_WB "wb"
+# ifndef DIR_SEPARATOR_2
+# define DIR_SEPARATOR_2 '\\'
+# endif
+# ifndef PATH_SEPARATOR_2
+# define PATH_SEPARATOR_2 ';'
+# endif
+#endif
+
+#ifndef DIR_SEPARATOR_2
+# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
+#else /* DIR_SEPARATOR_2 */
+# define IS_DIR_SEPARATOR(ch) \
+ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
+#endif /* DIR_SEPARATOR_2 */
+
+#ifndef PATH_SEPARATOR_2
+# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
+#else /* PATH_SEPARATOR_2 */
+# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
+#endif /* PATH_SEPARATOR_2 */
+
+#ifndef FOPEN_WB
+# define FOPEN_WB "w"
+#endif
+#ifndef _O_BINARY
+# define _O_BINARY 0
+#endif
+
+#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
+#define XFREE(stale) do { \
+ if (stale) { free ((void *) stale); stale = 0; } \
+} while (0)
+
+#if defined(LT_DEBUGWRAPPER)
+static int lt_debug = 1;
+#else
+static int lt_debug = 0;
+#endif
+
+const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
+
+void *xmalloc (size_t num);
+char *xstrdup (const char *string);
+const char *base_name (const char *name);
+char *find_executable (const char *wrapper);
+char *chase_symlinks (const char *pathspec);
+int make_executable (const char *path);
+int check_executable (const char *path);
+char *strendzap (char *str, const char *pat);
+void lt_debugprintf (const char *file, int line, const char *fmt, ...);
+void lt_fatal (const char *file, int line, const char *message, ...);
+static const char *nonnull (const char *s);
+static const char *nonempty (const char *s);
+void lt_setenv (const char *name, const char *value);
+char *lt_extend_str (const char *orig_value, const char *add, int to_end);
+void lt_update_exe_path (const char *name, const char *value);
+void lt_update_lib_path (const char *name, const char *value);
+char **prepare_spawn (char **argv);
+void lt_dump_script (FILE *f);
+EOF
+
+ cat <<EOF
+volatile const char * MAGIC_EXE = "$magic_exe";
+const char * LIB_PATH_VARNAME = "$shlibpath_var";
+EOF
+
+ if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+ func_to_host_path "$temp_rpath"
+ cat <<EOF
+const char * LIB_PATH_VALUE = "$func_to_host_path_result";
+EOF
+ else
+ cat <<"EOF"
+const char * LIB_PATH_VALUE = "";
+EOF
+ fi
+
+ if test -n "$dllsearchpath"; then
+ func_to_host_path "$dllsearchpath:"
+ cat <<EOF
+const char * EXE_PATH_VARNAME = "PATH";
+const char * EXE_PATH_VALUE = "$func_to_host_path_result";
+EOF
+ else
+ cat <<"EOF"
+const char * EXE_PATH_VARNAME = "";
+const char * EXE_PATH_VALUE = "";
+EOF
+ fi
+
+ if test "$fast_install" = yes; then
+ cat <<EOF
+const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
+EOF
+ else
+ cat <<EOF
+const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
+EOF
+ fi
+
+
+ cat <<"EOF"
+
+#define LTWRAPPER_OPTION_PREFIX "--lt-"
+
+static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
+static const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script";
+static const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug";
+
+int
+main (int argc, char *argv[])
+{
+ char **newargz;
+ int newargc;
+ char *tmp_pathspec;
+ char *actual_cwrapper_path;
+ char *actual_cwrapper_name;
+ char *target_name;
+ char *lt_argv_zero;
+ intptr_t rval = 127;
+
+ int i;
+
+ program_name = (char *) xstrdup (base_name (argv[0]));
+ newargz = XMALLOC (char *, argc + 1);
+
+ /* very simple arg parsing; don't want to rely on getopt
+ * also, copy all non cwrapper options to newargz, except
+ * argz[0], which is handled differently
+ */
+ newargc=0;
+ for (i = 1; i < argc; i++)
+ {
+ if (strcmp (argv[i], dumpscript_opt) == 0)
+ {
+EOF
+ case "$host" in
+ *mingw* | *cygwin* )
+ # make stdout use "unix" line endings
+ echo " setmode(1,_O_BINARY);"
+ ;;
+ esac
+
+ cat <<"EOF"
+ lt_dump_script (stdout);
+ return 0;
+ }
+ if (strcmp (argv[i], debug_opt) == 0)
+ {
+ lt_debug = 1;
+ continue;
+ }
+ if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
+ {
+ /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
+ namespace, but it is not one of the ones we know about and
+ have already dealt with, above (inluding dump-script), then
+ report an error. Otherwise, targets might begin to believe
+ they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
+ namespace. The first time any user complains about this, we'll
+ need to make LTWRAPPER_OPTION_PREFIX a configure-time option
+ or a configure.ac-settable value.
+ */
+ lt_fatal (__FILE__, __LINE__,
+ "unrecognized %s option: '%s'",
+ ltwrapper_option_prefix, argv[i]);
+ }
+ /* otherwise ... */
+ newargz[++newargc] = xstrdup (argv[i]);
+ }
+ newargz[++newargc] = NULL;
+
+EOF
+ cat <<EOF
+ /* The GNU banner must be the first non-error debug message */
+ lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
+EOF
+ cat <<"EOF"
+ lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
+ lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
+
+ tmp_pathspec = find_executable (argv[0]);
+ if (tmp_pathspec == NULL)
+ lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
+ lt_debugprintf (__FILE__, __LINE__,
+ "(main) found exe (before symlink chase) at: %s\n",
+ tmp_pathspec);
+
+ actual_cwrapper_path = chase_symlinks (tmp_pathspec);
+ lt_debugprintf (__FILE__, __LINE__,
+ "(main) found exe (after symlink chase) at: %s\n",
+ actual_cwrapper_path);
+ XFREE (tmp_pathspec);
+
+ actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
+ strendzap (actual_cwrapper_path, actual_cwrapper_name);
+
+ /* wrapper name transforms */
+ strendzap (actual_cwrapper_name, ".exe");
+ tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
+ XFREE (actual_cwrapper_name);
+ actual_cwrapper_name = tmp_pathspec;
+ tmp_pathspec = 0;
+
+ /* target_name transforms -- use actual target program name; might have lt- prefix */
+ target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
+ strendzap (target_name, ".exe");
+ tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
+ XFREE (target_name);
+ target_name = tmp_pathspec;
+ tmp_pathspec = 0;
+
+ lt_debugprintf (__FILE__, __LINE__,
+ "(main) libtool target name: %s\n",
+ target_name);
+EOF
+
+ cat <<EOF
+ newargz[0] =
+ XMALLOC (char, (strlen (actual_cwrapper_path) +
+ strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
+ strcpy (newargz[0], actual_cwrapper_path);
+ strcat (newargz[0], "$objdir");
+ strcat (newargz[0], "/");
+EOF
+
+ cat <<"EOF"
+ /* stop here, and copy so we don't have to do this twice */
+ tmp_pathspec = xstrdup (newargz[0]);
+
+ /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
+ strcat (newargz[0], actual_cwrapper_name);
+
+ /* DO want the lt- prefix here if it exists, so use target_name */
+ lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
+ XFREE (tmp_pathspec);
+ tmp_pathspec = NULL;
+EOF
+
+ case $host_os in
+ mingw*)
+ cat <<"EOF"
+ {
+ char* p;
+ while ((p = strchr (newargz[0], '\\')) != NULL)
+ {
+ *p = '/';
+ }
+ while ((p = strchr (lt_argv_zero, '\\')) != NULL)
+ {
+ *p = '/';
+ }
+ }
+EOF
+ ;;
+ esac
+
+ cat <<"EOF"
+ XFREE (target_name);
+ XFREE (actual_cwrapper_path);
+ XFREE (actual_cwrapper_name);
+
+ lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
+ lt_setenv ("DUALCASE", "1"); /* for MSK sh */
+ /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must
+ be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
+ because on Windows, both *_VARNAMEs are PATH but uninstalled
+ libraries must come first. */
+ lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
+ lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
+
+ lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
+ nonnull (lt_argv_zero));
+ for (i = 0; i < newargc; i++)
+ {
+ lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
+ i, nonnull (newargz[i]));
+ }
+
+EOF
+
+ case $host_os in
+ mingw*)
+ cat <<"EOF"
+ /* execv doesn't actually work on mingw as expected on unix */
+ newargz = prepare_spawn (newargz);
+ rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
+ if (rval == -1)
+ {
+ /* failed to start process */
+ lt_debugprintf (__FILE__, __LINE__,
+ "(main) failed to launch target \"%s\": %s\n",
+ lt_argv_zero, nonnull (strerror (errno)));
+ return 127;
+ }
+ return rval;
+EOF
+ ;;
+ *)
+ cat <<"EOF"
+ execv (lt_argv_zero, newargz);
+ return rval; /* =127, but avoids unused variable warning */
+EOF
+ ;;
+ esac
+
+ cat <<"EOF"
+}
+
+void *
+xmalloc (size_t num)
+{
+ void *p = (void *) malloc (num);
+ if (!p)
+ lt_fatal (__FILE__, __LINE__, "memory exhausted");
+
+ return p;
+}
+
+char *
+xstrdup (const char *string)
+{
+ return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
+ string) : NULL;
+}
+
+const char *
+base_name (const char *name)
+{
+ const char *base;
+
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+ /* Skip over the disk name in MSDOS pathnames. */
+ if (isalpha ((unsigned char) name[0]) && name[1] == ':')
+ name += 2;
+#endif
+
+ for (base = name; *name; name++)
+ if (IS_DIR_SEPARATOR (*name))
+ base = name + 1;
+ return base;
+}
+
+int
+check_executable (const char *path)
+{
+ struct stat st;
+
+ lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
+ nonempty (path));
+ if ((!path) || (!*path))
+ return 0;
+
+ if ((stat (path, &st) >= 0)
+ && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
+ return 1;
+ else
+ return 0;
+}
+
+int
+make_executable (const char *path)
+{
+ int rval = 0;
+ struct stat st;
+
+ lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
+ nonempty (path));
+ if ((!path) || (!*path))
+ return 0;
+
+ if (stat (path, &st) >= 0)
+ {
+ rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
+ }
+ return rval;
+}
+
+/* Searches for the full path of the wrapper. Returns
+ newly allocated full path name if found, NULL otherwise
+ Does not chase symlinks, even on platforms that support them.
+*/
+char *
+find_executable (const char *wrapper)
+{
+ int has_slash = 0;
+ const char *p;
+ const char *p_next;
+ /* static buffer for getcwd */
+ char tmp[LT_PATHMAX + 1];
+ int tmp_len;
+ char *concat_name;
+
+ lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
+ nonempty (wrapper));
+
+ if ((wrapper == NULL) || (*wrapper == '\0'))
+ return NULL;
+
+ /* Absolute path? */
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+ if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
+ {
+ concat_name = xstrdup (wrapper);
+ if (check_executable (concat_name))
+ return concat_name;
+ XFREE (concat_name);
+ }
+ else
+ {
+#endif
+ if (IS_DIR_SEPARATOR (wrapper[0]))
+ {
+ concat_name = xstrdup (wrapper);
+ if (check_executable (concat_name))
+ return concat_name;
+ XFREE (concat_name);
+ }
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+ }
+#endif
+
+ for (p = wrapper; *p; p++)
+ if (*p == '/')
+ {
+ has_slash = 1;
+ break;
+ }
+ if (!has_slash)
+ {
+ /* no slashes; search PATH */
+ const char *path = getenv ("PATH");
+ if (path != NULL)
+ {
+ for (p = path; *p; p = p_next)
+ {
+ const char *q;
+ size_t p_len;
+ for (q = p; *q; q++)
+ if (IS_PATH_SEPARATOR (*q))
+ break;
+ p_len = q - p;
+ p_next = (*q == '\0' ? q : q + 1);
+ if (p_len == 0)
+ {
+ /* empty path: current directory */
+ if (getcwd (tmp, LT_PATHMAX) == NULL)
+ lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
+ nonnull (strerror (errno)));
+ tmp_len = strlen (tmp);
+ concat_name =
+ XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
+ memcpy (concat_name, tmp, tmp_len);
+ concat_name[tmp_len] = '/';
+ strcpy (concat_name + tmp_len + 1, wrapper);
+ }
+ else
+ {
+ concat_name =
+ XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
+ memcpy (concat_name, p, p_len);
+ concat_name[p_len] = '/';
+ strcpy (concat_name + p_len + 1, wrapper);
+ }
+ if (check_executable (concat_name))
+ return concat_name;
+ XFREE (concat_name);
+ }
+ }
+ /* not found in PATH; assume curdir */
+ }
+ /* Relative path | not found in path: prepend cwd */
+ if (getcwd (tmp, LT_PATHMAX) == NULL)
+ lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
+ nonnull (strerror (errno)));
+ tmp_len = strlen (tmp);
+ concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
+ memcpy (concat_name, tmp, tmp_len);
+ concat_name[tmp_len] = '/';
+ strcpy (concat_name + tmp_len + 1, wrapper);
+
+ if (check_executable (concat_name))
+ return concat_name;
+ XFREE (concat_name);
+ return NULL;
+}
+
+char *
+chase_symlinks (const char *pathspec)
+{
+#ifndef S_ISLNK
+ return xstrdup (pathspec);
+#else
+ char buf[LT_PATHMAX];
+ struct stat s;
+ char *tmp_pathspec = xstrdup (pathspec);
+ char *p;
+ int has_symlinks = 0;
+ while (strlen (tmp_pathspec) && !has_symlinks)
+ {
+ lt_debugprintf (__FILE__, __LINE__,
+ "checking path component for symlinks: %s\n",
+ tmp_pathspec);
+ if (lstat (tmp_pathspec, &s) == 0)
+ {
+ if (S_ISLNK (s.st_mode) != 0)
+ {
+ has_symlinks = 1;
+ break;
+ }
+
+ /* search backwards for last DIR_SEPARATOR */
+ p = tmp_pathspec + strlen (tmp_pathspec) - 1;
+ while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
+ p--;
+ if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
+ {
+ /* no more DIR_SEPARATORS left */
+ break;
+ }
+ *p = '\0';
+ }
+ else
+ {
+ lt_fatal (__FILE__, __LINE__,
+ "error accessing file \"%s\": %s",
+ tmp_pathspec, nonnull (strerror (errno)));
+ }
+ }
+ XFREE (tmp_pathspec);
+
+ if (!has_symlinks)
+ {
+ return xstrdup (pathspec);
+ }
+
+ tmp_pathspec = realpath (pathspec, buf);
+ if (tmp_pathspec == 0)
+ {
+ lt_fatal (__FILE__, __LINE__,
+ "could not follow symlinks for %s", pathspec);
+ }
+ return xstrdup (tmp_pathspec);
+#endif
+}
+
+char *
+strendzap (char *str, const char *pat)
+{
+ size_t len, patlen;
+
+ assert (str != NULL);
+ assert (pat != NULL);
+
+ len = strlen (str);
+ patlen = strlen (pat);
+
+ if (patlen <= len)
+ {
+ str += len - patlen;
+ if (strcmp (str, pat) == 0)
+ *str = '\0';
+ }
+ return str;
+}
+
+void
+lt_debugprintf (const char *file, int line, const char *fmt, ...)
+{
+ va_list args;
+ if (lt_debug)
+ {
+ (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
+ va_start (args, fmt);
+ (void) vfprintf (stderr, fmt, args);
+ va_end (args);
+ }
+}
+
+static void
+lt_error_core (int exit_status, const char *file,
+ int line, const char *mode,
+ const char *message, va_list ap)
+{
+ fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
+ vfprintf (stderr, message, ap);
+ fprintf (stderr, ".\n");
+
+ if (exit_status >= 0)
+ exit (exit_status);
+}
+
+void
+lt_fatal (const char *file, int line, const char *message, ...)
+{
+ va_list ap;
+ va_start (ap, message);
+ lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
+ va_end (ap);
+}
+
+static const char *
+nonnull (const char *s)
+{
+ return s ? s : "(null)";
+}
+
+static const char *
+nonempty (const char *s)
+{
+ return (s && !*s) ? "(empty)" : nonnull (s);
+}
+
+void
+lt_setenv (const char *name, const char *value)
+{
+ lt_debugprintf (__FILE__, __LINE__,
+ "(lt_setenv) setting '%s' to '%s'\n",
+ nonnull (name), nonnull (value));
+ {
+#ifdef HAVE_SETENV
+ /* always make a copy, for consistency with !HAVE_SETENV */
+ char *str = xstrdup (value);
+ setenv (name, str, 1);
+#else
+ int len = strlen (name) + 1 + strlen (value) + 1;
+ char *str = XMALLOC (char, len);
+ sprintf (str, "%s=%s", name, value);
+ if (putenv (str) != EXIT_SUCCESS)
+ {
+ XFREE (str);
+ }
+#endif
+ }
+}
+
+char *
+lt_extend_str (const char *orig_value, const char *add, int to_end)
+{
+ char *new_value;
+ if (orig_value && *orig_value)
+ {
+ int orig_value_len = strlen (orig_value);
+ int add_len = strlen (add);
+ new_value = XMALLOC (char, add_len + orig_value_len + 1);
+ if (to_end)
+ {
+ strcpy (new_value, orig_value);
+ strcpy (new_value + orig_value_len, add);
+ }
+ else
+ {
+ strcpy (new_value, add);
+ strcpy (new_value + add_len, orig_value);
+ }
+ }
+ else
+ {
+ new_value = xstrdup (add);
+ }
+ return new_value;
+}
+
+void
+lt_update_exe_path (const char *name, const char *value)
+{
+ lt_debugprintf (__FILE__, __LINE__,
+ "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
+ nonnull (name), nonnull (value));
+
+ if (name && *name && value && *value)
+ {
+ char *new_value = lt_extend_str (getenv (name), value, 0);
+ /* some systems can't cope with a ':'-terminated path #' */
+ int len = strlen (new_value);
+ while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
+ {
+ new_value[len-1] = '\0';
+ }
+ lt_setenv (name, new_value);
+ XFREE (new_value);
+ }
+}
+
+void
+lt_update_lib_path (const char *name, const char *value)
+{
+ lt_debugprintf (__FILE__, __LINE__,
+ "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
+ nonnull (name), nonnull (value));
+
+ if (name && *name && value && *value)
+ {
+ char *new_value = lt_extend_str (getenv (name), value, 0);
+ lt_setenv (name, new_value);
+ XFREE (new_value);
+ }
+}
+
+EOF
+ case $host_os in
+ mingw*)
+ cat <<"EOF"
+
+/* Prepares an argument vector before calling spawn().
+ Note that spawn() does not by itself call the command interpreter
+ (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
+ ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ GetVersionEx(&v);
+ v.dwPlatformId == VER_PLATFORM_WIN32_NT;
+ }) ? "cmd.exe" : "command.com").
+ Instead it simply concatenates the arguments, separated by ' ', and calls
+ CreateProcess(). We must quote the arguments since Win32 CreateProcess()
+ interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
+ special way:
+ - Space and tab are interpreted as delimiters. They are not treated as
+ delimiters if they are surrounded by double quotes: "...".
+ - Unescaped double quotes are removed from the input. Their only effect is
+ that within double quotes, space and tab are treated like normal
+ characters.
+ - Backslashes not followed by double quotes are not special.
+ - But 2*n+1 backslashes followed by a double quote become
+ n backslashes followed by a double quote (n >= 0):
+ \" -> "
+ \\\" -> \"
+ \\\\\" -> \\"
+ */
+#define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
+#define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
+char **
+prepare_spawn (char **argv)
+{
+ size_t argc;
+ char **new_argv;
+ size_t i;
+
+ /* Count number of arguments. */
+ for (argc = 0; argv[argc] != NULL; argc++)
+ ;
+
+ /* Allocate new argument vector. */
+ new_argv = XMALLOC (char *, argc + 1);
+
+ /* Put quoted arguments into the new argument vector. */
+ for (i = 0; i < argc; i++)
+ {
+ const char *string = argv[i];
+
+ if (string[0] == '\0')
+ new_argv[i] = xstrdup ("\"\"");
+ else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
+ {
+ int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
+ size_t length;
+ unsigned int backslashes;
+ const char *s;
+ char *quoted_string;
+ char *p;
+
+ length = 0;
+ backslashes = 0;
+ if (quote_around)
+ length++;
+ for (s = string; *s != '\0'; s++)
+ {
+ char c = *s;
+ if (c == '"')
+ length += backslashes + 1;
+ length++;
+ if (c == '\\')
+ backslashes++;
+ else
+ backslashes = 0;
+ }
+ if (quote_around)
+ length += backslashes + 1;
+
+ quoted_string = XMALLOC (char, length + 1);
+
+ p = quoted_string;
+ backslashes = 0;
+ if (quote_around)
+ *p++ = '"';
+ for (s = string; *s != '\0'; s++)
+ {
+ char c = *s;
+ if (c == '"')
+ {
+ unsigned int j;
+ for (j = backslashes + 1; j > 0; j--)
+ *p++ = '\\';
+ }
+ *p++ = c;
+ if (c == '\\')
+ backslashes++;
+ else
+ backslashes = 0;
+ }
+ if (quote_around)
+ {
+ unsigned int j;
+ for (j = backslashes; j > 0; j--)
+ *p++ = '\\';
+ *p++ = '"';
+ }
+ *p = '\0';
+
+ new_argv[i] = quoted_string;
+ }
+ else
+ new_argv[i] = (char *) string;
+ }
+ new_argv[argc] = NULL;
+
+ return new_argv;
+}
+EOF
+ ;;
+ esac
+
+ cat <<"EOF"
+void lt_dump_script (FILE* f)
+{
+EOF
+ func_emit_wrapper yes |
+ $SED -n -e '
+s/^\(.\{79\}\)\(..*\)/\1\
+\2/
+h
+s/\([\\"]\)/\\\1/g
+s/$/\\n/
+s/\([^\n]*\).*/ fputs ("\1", f);/p
+g
+D'
+ cat <<"EOF"
+}
+EOF
+}
+# end: func_emit_cwrapperexe_src
+
+# func_win32_import_lib_p ARG
+# True if ARG is an import lib, as indicated by $file_magic_cmd
+func_win32_import_lib_p ()
+{
+ $opt_debug
+ case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
+ *import*) : ;;
+ *) false ;;
+ esac
+}
+
+# func_mode_link arg...
+func_mode_link ()
+{
+ $opt_debug
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
+ # It is impossible to link a dll without this setting, and
+ # we shouldn't force the makefile maintainer to figure out
+ # which system we are compiling for in order to pass an extra
+ # flag for every libtool invocation.
+ # allow_undefined=no
+
+ # FIXME: Unfortunately, there are problems with the above when trying
+ # to make a dll which has undefined symbols, in which case not
+ # even a static library is built. For now, we need to specify
+ # -no-undefined on the libtool link line when we can be certain
+ # that all symbols are satisfied, otherwise we get a static library.
+ allow_undefined=yes
+ ;;
+ *)
+ allow_undefined=yes
+ ;;
+ esac
+ libtool_args=$nonopt
+ base_compile="$nonopt $@"
+ compile_command=$nonopt
+ finalize_command=$nonopt
+
+ compile_rpath=
+ finalize_rpath=
+ compile_shlibpath=
+ finalize_shlibpath=
+ convenience=
+ old_convenience=
+ deplibs=
+ old_deplibs=
+ compiler_flags=
+ linker_flags=
+ dllsearchpath=
+ lib_search_path=`pwd`
+ inst_prefix_dir=
+ new_inherited_linker_flags=
+
+ avoid_version=no
+ bindir=
+ dlfiles=
+ dlprefiles=
+ dlself=no
+ export_dynamic=no
+ export_symbols=
+ export_symbols_regex=
+ generated=
+ libobjs=
+ ltlibs=
+ module=no
+ no_install=no
+ objs=
+ non_pic_objects=
+ precious_files_regex=
+ prefer_static_libs=no
+ preload=no
+ prev=
+ prevarg=
+ release=
+ rpath=
+ xrpath=
+ perm_rpath=
+ temp_rpath=
+ thread_safe=no
+ vinfo=
+ vinfo_number=no
+ weak_libs=
+ single_module="${wl}-single_module"
+ func_infer_tag $base_compile
+
+ # We need to know -static, to get the right output filenames.
+ for arg
+ do
+ case $arg in
+ -shared)
+ test "$build_libtool_libs" != yes && \
+ func_fatal_configuration "can not build a shared library"
+ build_old_libs=no
+ break
+ ;;
+ -all-static | -static | -static-libtool-libs)
+ case $arg in
+ -all-static)
+ if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
+ func_warning "complete static linking is impossible in this configuration"
+ fi
+ if test -n "$link_static_flag"; then
+ dlopen_self=$dlopen_self_static
+ fi
+ prefer_static_libs=yes
+ ;;
+ -static)
+ if test -z "$pic_flag" && test -n "$link_static_flag"; then
+ dlopen_self=$dlopen_self_static
+ fi
+ prefer_static_libs=built
+ ;;
+ -static-libtool-libs)
+ if test -z "$pic_flag" && test -n "$link_static_flag"; then
+ dlopen_self=$dlopen_self_static
+ fi
+ prefer_static_libs=yes
+ ;;
+ esac
+ build_libtool_libs=no
+ build_old_libs=yes
+ break
+ ;;
+ esac
+ done
+
+ # See if our shared archives depend on static archives.
+ test -n "$old_archive_from_new_cmds" && build_old_libs=yes
+
+ # Go through the arguments, transforming them on the way.
+ while test "$#" -gt 0; do
+ arg="$1"
+ shift
+ func_quote_for_eval "$arg"
+ qarg=$func_quote_for_eval_unquoted_result
+ func_append libtool_args " $func_quote_for_eval_result"
+
+ # If the previous option needs an argument, assign it.
+ if test -n "$prev"; then
+ case $prev in
+ output)
+ func_append compile_command " @OUTPUT@"
+ func_append finalize_command " @OUTPUT@"
+ ;;
+ esac
+
+ case $prev in
+ bindir)
+ bindir="$arg"
+ prev=
+ continue
+ ;;
+ dlfiles|dlprefiles)
+ if test "$preload" = no; then
+ # Add the symbol object into the linking commands.
+ func_append compile_command " @SYMFILE@"
+ func_append finalize_command " @SYMFILE@"
+ preload=yes
+ fi
+ case $arg in
+ *.la | *.lo) ;; # We handle these cases below.
+ force)
+ if test "$dlself" = no; then
+ dlself=needless
+ export_dynamic=yes
+ fi
+ prev=
+ continue
+ ;;
+ self)
+ if test "$prev" = dlprefiles; then
+ dlself=yes
+ elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
+ dlself=yes
+ else
+ dlself=needless
+ export_dynamic=yes
+ fi
+ prev=
+ continue
+ ;;
+ *)
+ if test "$prev" = dlfiles; then
+ func_append dlfiles " $arg"
+ else
+ func_append dlprefiles " $arg"
+ fi
+ prev=
+ continue
+ ;;
+ esac
+ ;;
+ expsyms)
+ export_symbols="$arg"
+ test -f "$arg" \
+ || func_fatal_error "symbol file \`$arg' does not exist"
+ prev=
+ continue
+ ;;
+ expsyms_regex)
+ export_symbols_regex="$arg"
+ prev=
+ continue
+ ;;
+ framework)
+ case $host in
+ *-*-darwin*)
+ case "$deplibs " in
+ *" $qarg.ltframework "*) ;;
+ *) func_append deplibs " $qarg.ltframework" # this is fixed later
+ ;;
+ esac
+ ;;
+ esac
+ prev=
+ continue
+ ;;
+ inst_prefix)
+ inst_prefix_dir="$arg"
+ prev=
+ continue
+ ;;
+ objectlist)
+ if test -f "$arg"; then
+ save_arg=$arg
+ moreargs=
+ for fil in `cat "$save_arg"`
+ do
+# func_append moreargs " $fil"
+ arg=$fil
+ # A libtool-controlled object.
+
+ # Check to see that this really is a libtool object.
+ if func_lalib_unsafe_p "$arg"; then
+ pic_object=
+ non_pic_object=
+
+ # Read the .lo file
+ func_source "$arg"
+
+ if test -z "$pic_object" ||
+ test -z "$non_pic_object" ||
+ test "$pic_object" = none &&
+ test "$non_pic_object" = none; then
+ func_fatal_error "cannot find name of object for \`$arg'"
+ fi
+
+ # Extract subdirectory from the argument.
+ func_dirname "$arg" "/" ""
+ xdir="$func_dirname_result"
+
+ if test "$pic_object" != none; then
+ # Prepend the subdirectory the object is found in.
+ pic_object="$xdir$pic_object"
+
+ if test "$prev" = dlfiles; then
+ if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+ func_append dlfiles " $pic_object"
+ prev=
+ continue
+ else
+ # If libtool objects are unsupported, then we need to preload.
+ prev=dlprefiles
+ fi
+ fi
+
+ # CHECK ME: I think I busted this. -Ossama
+ if test "$prev" = dlprefiles; then
+ # Preload the old-style object.
+ func_append dlprefiles " $pic_object"
+ prev=
+ fi
+
+ # A PIC object.
+ func_append libobjs " $pic_object"
+ arg="$pic_object"
+ fi
+
+ # Non-PIC object.
+ if test "$non_pic_object" != none; then
+ # Prepend the subdirectory the object is found in.
+ non_pic_object="$xdir$non_pic_object"
+
+ # A standard non-PIC object
+ func_append non_pic_objects " $non_pic_object"
+ if test -z "$pic_object" || test "$pic_object" = none ; then
+ arg="$non_pic_object"
+ fi
+ else
+ # If the PIC object exists, use it instead.
+ # $xdir was prepended to $pic_object above.
+ non_pic_object="$pic_object"
+ func_append non_pic_objects " $non_pic_object"
+ fi
+ else
+ # Only an error if not doing a dry-run.
+ if $opt_dry_run; then
+ # Extract subdirectory from the argument.
+ func_dirname "$arg" "/" ""
+ xdir="$func_dirname_result"
+
+ func_lo2o "$arg"
+ pic_object=$xdir$objdir/$func_lo2o_result
+ non_pic_object=$xdir$func_lo2o_result
+ func_append libobjs " $pic_object"
+ func_append non_pic_objects " $non_pic_object"
+ else
+ func_fatal_error "\`$arg' is not a valid libtool object"
+ fi
+ fi
+ done
+ else
+ func_fatal_error "link input file \`$arg' does not exist"
+ fi
+ arg=$save_arg
+ prev=
+ continue
+ ;;
+ precious_regex)
+ precious_files_regex="$arg"
+ prev=
+ continue
+ ;;
+ release)
+ release="-$arg"
+ prev=
+ continue
+ ;;
+ rpath | xrpath)
+ # We need an absolute path.
+ case $arg in
+ [\\/]* | [A-Za-z]:[\\/]*) ;;
+ *)
+ func_fatal_error "only absolute run-paths are allowed"
+ ;;
+ esac
+ if test "$prev" = rpath; then
+ case "$rpath " in
+ *" $arg "*) ;;
+ *) func_append rpath " $arg" ;;
+ esac
+ else
+ case "$xrpath " in
+ *" $arg "*) ;;
+ *) func_append xrpath " $arg" ;;
+ esac
+ fi
+ prev=
+ continue
+ ;;
+ shrext)
+ shrext_cmds="$arg"
+ prev=
+ continue
+ ;;
+ weak)
+ func_append weak_libs " $arg"
+ prev=
+ continue
+ ;;
+ xcclinker)
+ func_append linker_flags " $qarg"
+ func_append compiler_flags " $qarg"
+ prev=
+ func_append compile_command " $qarg"
+ func_append finalize_command " $qarg"
+ continue
+ ;;
+ xcompiler)
+ func_append compiler_flags " $qarg"
+ prev=
+ func_append compile_command " $qarg"
+ func_append finalize_command " $qarg"
+ continue
+ ;;
+ xlinker)
+ func_append linker_flags " $qarg"
+ func_append compiler_flags " $wl$qarg"
+ prev=
+ func_append compile_command " $wl$qarg"
+ func_append finalize_command " $wl$qarg"
+ continue
+ ;;
+ *)
+ eval "$prev=\"\$arg\""
+ prev=
+ continue
+ ;;
+ esac
+ fi # test -n "$prev"
+
+ prevarg="$arg"
+
+ case $arg in
+ -all-static)
+ if test -n "$link_static_flag"; then
+ # See comment for -static flag below, for more details.
+ func_append compile_command " $link_static_flag"
+ func_append finalize_command " $link_static_flag"
+ fi
+ continue
+ ;;
+
+ -allow-undefined)
+ # FIXME: remove this flag sometime in the future.
+ func_fatal_error "\`-allow-undefined' must not be used because it is the default"
+ ;;
+
+ -avoid-version)
+ avoid_version=yes
+ continue
+ ;;
+
+ -bindir)
+ prev=bindir
+ continue
+ ;;
+
+ -dlopen)
+ prev=dlfiles
+ continue
+ ;;
+
+ -dlpreopen)
+ prev=dlprefiles
+ continue
+ ;;
+
+ -export-dynamic)
+ export_dynamic=yes
+ continue
+ ;;
+
+ -export-symbols | -export-symbols-regex)
+ if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
+ func_fatal_error "more than one -exported-symbols argument is not allowed"
+ fi
+ if test "X$arg" = "X-export-symbols"; then
+ prev=expsyms
+ else
+ prev=expsyms_regex
+ fi
+ continue
+ ;;
+
+ -framework)
+ prev=framework
+ continue
+ ;;
+
+ -inst-prefix-dir)
+ prev=inst_prefix
+ continue
+ ;;
+
+ # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
+ # so, if we see these flags be careful not to treat them like -L
+ -L[A-Z][A-Z]*:*)
+ case $with_gcc/$host in
+ no/*-*-irix* | /*-*-irix*)
+ func_append compile_command " $arg"
+ func_append finalize_command " $arg"
+ ;;
+ esac
+ continue
+ ;;
+
+ -L*)
+ func_stripname "-L" '' "$arg"
+ if test -z "$func_stripname_result"; then
+ if test "$#" -gt 0; then
+ func_fatal_error "require no space between \`-L' and \`$1'"
+ else
+ func_fatal_error "need path for \`-L' option"
+ fi
+ fi
+ func_resolve_sysroot "$func_stripname_result"
+ dir=$func_resolve_sysroot_result
+ # We need an absolute path.
+ case $dir in
+ [\\/]* | [A-Za-z]:[\\/]*) ;;
+ *)
+ absdir=`cd "$dir" && pwd`
+ test -z "$absdir" && \
+ func_fatal_error "cannot determine absolute directory name of \`$dir'"
+ dir="$absdir"
+ ;;
+ esac
+ case "$deplibs " in
+ *" -L$dir "* | *" $arg "*)
+ # Will only happen for absolute or sysroot arguments
+ ;;
+ *)
+ # Preserve sysroot, but never include relative directories
+ case $dir in
+ [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
+ *) func_append deplibs " -L$dir" ;;
+ esac
+ func_append lib_search_path " $dir"
+ ;;
+ esac
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
+ testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
+ case :$dllsearchpath: in
+ *":$dir:"*) ;;
+ ::) dllsearchpath=$dir;;
+ *) func_append dllsearchpath ":$dir";;
+ esac
+ case :$dllsearchpath: in
+ *":$testbindir:"*) ;;
+ ::) dllsearchpath=$testbindir;;
+ *) func_append dllsearchpath ":$testbindir";;
+ esac
+ ;;
+ esac
+ continue
+ ;;
+
+ -l*)
+ if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
+ # These systems don't actually have a C or math library (as such)
+ continue
+ ;;
+ *-*-os2*)
+ # These systems don't actually have a C library (as such)
+ test "X$arg" = "X-lc" && continue
+ ;;
+ *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+ # Do not include libc due to us having libc/libc_r.
+ test "X$arg" = "X-lc" && continue
+ ;;
+ *-*-rhapsody* | *-*-darwin1.[012])
+ # Rhapsody C and math libraries are in the System framework
+ func_append deplibs " System.ltframework"
+ continue
+ ;;
+ *-*-sco3.2v5* | *-*-sco5v6*)
+ # Causes problems with __ctype
+ test "X$arg" = "X-lc" && continue
+ ;;
+ *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
+ # Compiler inserts libc in the correct place for threads to work
+ test "X$arg" = "X-lc" && continue
+ ;;
+ esac
+ elif test "X$arg" = "X-lc_r"; then
+ case $host in
+ *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+ # Do not include libc_r directly, use -pthread flag.
+ continue
+ ;;
+ esac
+ fi
+ func_append deplibs " $arg"
+ continue
+ ;;
+
+ -module)
+ module=yes
+ continue
+ ;;
+
+ # Tru64 UNIX uses -model [arg] to determine the layout of C++
+ # classes, name mangling, and exception handling.
+ # Darwin uses the -arch flag to determine output architecture.
+ -model|-arch|-isysroot|--sysroot)
+ func_append compiler_flags " $arg"
+ func_append compile_command " $arg"
+ func_append finalize_command " $arg"
+ prev=xcompiler
+ continue
+ ;;
+
+ -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
+ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
+ func_append compiler_flags " $arg"
+ func_append compile_command " $arg"
+ func_append finalize_command " $arg"
+ case "$new_inherited_linker_flags " in
+ *" $arg "*) ;;
+ * ) func_append new_inherited_linker_flags " $arg" ;;
+ esac
+ continue
+ ;;
+
+ -multi_module)
+ single_module="${wl}-multi_module"
+ continue
+ ;;
+
+ -no-fast-install)
+ fast_install=no
+ continue
+ ;;
+
+ -no-install)
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
+ # The PATH hackery in wrapper scripts is required on Windows
+ # and Darwin in order for the loader to find any dlls it needs.
+ func_warning "\`-no-install' is ignored for $host"
+ func_warning "assuming \`-no-fast-install' instead"
+ fast_install=no
+ ;;
+ *) no_install=yes ;;
+ esac
+ continue
+ ;;
+
+ -no-undefined)
+ allow_undefined=no
+ continue
+ ;;
+
+ -objectlist)
+ prev=objectlist
+ continue
+ ;;
+
+ -o) prev=output ;;
+
+ -precious-files-regex)
+ prev=precious_regex
+ continue
+ ;;
+
+ -release)
+ prev=release
+ continue
+ ;;
+
+ -rpath)
+ prev=rpath
+ continue
+ ;;
+
+ -R)
+ prev=xrpath
+ continue
+ ;;
+
+ -R*)
+ func_stripname '-R' '' "$arg"
+ dir=$func_stripname_result
+ # We need an absolute path.
+ case $dir in
+ [\\/]* | [A-Za-z]:[\\/]*) ;;
+ =*)
+ func_stripname '=' '' "$dir"
+ dir=$lt_sysroot$func_stripname_result
+ ;;
+ *)
+ func_fatal_error "only absolute run-paths are allowed"
+ ;;
+ esac
+ case "$xrpath " in
+ *" $dir "*) ;;
+ *) func_append xrpath " $dir" ;;
+ esac
+ continue
+ ;;
+
+ -shared)
+ # The effects of -shared are defined in a previous loop.
+ continue
+ ;;
+
+ -shrext)
+ prev=shrext
+ continue
+ ;;
+
+ -static | -static-libtool-libs)
+ # The effects of -static are defined in a previous loop.
+ # We used to do the same as -all-static on platforms that
+ # didn't have a PIC flag, but the assumption that the effects
+ # would be equivalent was wrong. It would break on at least
+ # Digital Unix and AIX.
+ continue
+ ;;
+
+ -thread-safe)
+ thread_safe=yes
+ continue
+ ;;
+
+ -version-info)
+ prev=vinfo
+ continue
+ ;;
+
+ -version-number)
+ prev=vinfo
+ vinfo_number=yes
+ continue
+ ;;
+
+ -weak)
+ prev=weak
+ continue
+ ;;
+
+ -Wc,*)
+ func_stripname '-Wc,' '' "$arg"
+ args=$func_stripname_result
+ arg=
+ save_ifs="$IFS"; IFS=','
+ for flag in $args; do
+ IFS="$save_ifs"
+ func_quote_for_eval "$flag"
+ func_append arg " $func_quote_for_eval_result"
+ func_append compiler_flags " $func_quote_for_eval_result"
+ done
+ IFS="$save_ifs"
+ func_stripname ' ' '' "$arg"
+ arg=$func_stripname_result
+ ;;
+
+ -Wl,*)
+ func_stripname '-Wl,' '' "$arg"
+ args=$func_stripname_result
+ arg=
+ save_ifs="$IFS"; IFS=','
+ for flag in $args; do
+ IFS="$save_ifs"
+ func_quote_for_eval "$flag"
+ func_append arg " $wl$func_quote_for_eval_result"
+ func_append compiler_flags " $wl$func_quote_for_eval_result"
+ func_append linker_flags " $func_quote_for_eval_result"
+ done
+ IFS="$save_ifs"
+ func_stripname ' ' '' "$arg"
+ arg=$func_stripname_result
+ ;;
+
+ -Xcompiler)
+ prev=xcompiler
+ continue
+ ;;
+
+ -Xlinker)
+ prev=xlinker
+ continue
+ ;;
+
+ -XCClinker)
+ prev=xcclinker
+ continue
+ ;;
+
+ # -msg_* for osf cc
+ -msg_*)
+ func_quote_for_eval "$arg"
+ arg="$func_quote_for_eval_result"
+ ;;
+
+ # Flags to be passed through unchanged, with rationale:
+ # -64, -mips[0-9] enable 64-bit mode for the SGI compiler
+ # -r[0-9][0-9]* specify processor for the SGI compiler
+ # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
+ # +DA*, +DD* enable 64-bit mode for the HP compiler
+ # -q* compiler args for the IBM compiler
+ # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
+ # -F/path path to uninstalled frameworks, gcc on darwin
+ # -p, -pg, --coverage, -fprofile-* profiling flags for GCC
+ # @file GCC response files
+ # -tp=* Portland pgcc target processor selection
+ # --sysroot=* for sysroot support
+ # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
+ -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
+ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
+ -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
+ func_quote_for_eval "$arg"
+ arg="$func_quote_for_eval_result"
+ func_append compile_command " $arg"
+ func_append finalize_command " $arg"
+ func_append compiler_flags " $arg"
+ continue
+ ;;
+
+ # Some other compiler flag.
+ -* | +*)
+ func_quote_for_eval "$arg"
+ arg="$func_quote_for_eval_result"
+ ;;
+
+ *.$objext)
+ # A standard object.
+ func_append objs " $arg"
+ ;;
+
+ *.lo)
+ # A libtool-controlled object.
+
+ # Check to see that this really is a libtool object.
+ if func_lalib_unsafe_p "$arg"; then
+ pic_object=
+ non_pic_object=
+
+ # Read the .lo file
+ func_source "$arg"
+
+ if test -z "$pic_object" ||
+ test -z "$non_pic_object" ||
+ test "$pic_object" = none &&
+ test "$non_pic_object" = none; then
+ func_fatal_error "cannot find name of object for \`$arg'"
+ fi
+
+ # Extract subdirectory from the argument.
+ func_dirname "$arg" "/" ""
+ xdir="$func_dirname_result"
+
+ if test "$pic_object" != none; then
+ # Prepend the subdirectory the object is found in.
+ pic_object="$xdir$pic_object"
+
+ if test "$prev" = dlfiles; then
+ if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+ func_append dlfiles " $pic_object"
+ prev=
+ continue
+ else
+ # If libtool objects are unsupported, then we need to preload.
+ prev=dlprefiles
+ fi
+ fi
+
+ # CHECK ME: I think I busted this. -Ossama
+ if test "$prev" = dlprefiles; then
+ # Preload the old-style object.
+ func_append dlprefiles " $pic_object"
+ prev=
+ fi
+
+ # A PIC object.
+ func_append libobjs " $pic_object"
+ arg="$pic_object"
+ fi
+
+ # Non-PIC object.
+ if test "$non_pic_object" != none; then
+ # Prepend the subdirectory the object is found in.
+ non_pic_object="$xdir$non_pic_object"
+
+ # A standard non-PIC object
+ func_append non_pic_objects " $non_pic_object"
+ if test -z "$pic_object" || test "$pic_object" = none ; then
+ arg="$non_pic_object"
+ fi
+ else
+ # If the PIC object exists, use it instead.
+ # $xdir was prepended to $pic_object above.
+ non_pic_object="$pic_object"
+ func_append non_pic_objects " $non_pic_object"
+ fi
+ else
+ # Only an error if not doing a dry-run.
+ if $opt_dry_run; then
+ # Extract subdirectory from the argument.
+ func_dirname "$arg" "/" ""
+ xdir="$func_dirname_result"
+
+ func_lo2o "$arg"
+ pic_object=$xdir$objdir/$func_lo2o_result
+ non_pic_object=$xdir$func_lo2o_result
+ func_append libobjs " $pic_object"
+ func_append non_pic_objects " $non_pic_object"
+ else
+ func_fatal_error "\`$arg' is not a valid libtool object"
+ fi
+ fi
+ ;;
+
+ *.$libext)
+ # An archive.
+ func_append deplibs " $arg"
+ func_append old_deplibs " $arg"
+ continue
+ ;;
+
+ *.la)
+ # A libtool-controlled library.
+
+ func_resolve_sysroot "$arg"
+ if test "$prev" = dlfiles; then
+ # This library was specified with -dlopen.
+ func_append dlfiles " $func_resolve_sysroot_result"
+ prev=
+ elif test "$prev" = dlprefiles; then
+ # The library was specified with -dlpreopen.
+ func_append dlprefiles " $func_resolve_sysroot_result"
+ prev=
+ else
+ func_append deplibs " $func_resolve_sysroot_result"
+ fi
+ continue
+ ;;
+
+ # Some other compiler argument.
+ *)
+ # Unknown arguments in both finalize_command and compile_command need
+ # to be aesthetically quoted because they are evaled later.
+ func_quote_for_eval "$arg"
+ arg="$func_quote_for_eval_result"
+ ;;
+ esac # arg
+
+ # Now actually substitute the argument into the commands.
+ if test -n "$arg"; then
+ func_append compile_command " $arg"
+ func_append finalize_command " $arg"
+ fi
+ done # argument parsing loop
+
+ test -n "$prev" && \
+ func_fatal_help "the \`$prevarg' option requires an argument"
+
+ if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
+ eval arg=\"$export_dynamic_flag_spec\"
+ func_append compile_command " $arg"
+ func_append finalize_command " $arg"
+ fi
+
+ oldlibs=
+ # calculate the name of the file, without its directory
+ func_basename "$output"
+ outputname="$func_basename_result"
+ libobjs_save="$libobjs"
+
+ if test -n "$shlibpath_var"; then
+ # get the directories listed in $shlibpath_var
+ eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
+ else
+ shlib_search_path=
+ fi
+ eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
+ eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
+
+ func_dirname "$output" "/" ""
+ output_objdir="$func_dirname_result$objdir"
+ func_to_tool_file "$output_objdir/"
+ tool_output_objdir=$func_to_tool_file_result
+ # Create the object directory.
+ func_mkdir_p "$output_objdir"
+
+ # Determine the type of output
+ case $output in
+ "")
+ func_fatal_help "you must specify an output file"
+ ;;
+ *.$libext) linkmode=oldlib ;;
+ *.lo | *.$objext) linkmode=obj ;;
+ *.la) linkmode=lib ;;
+ *) linkmode=prog ;; # Anything else should be a program.
+ esac
+
+ specialdeplibs=
+
+ libs=
+ # Find all interdependent deplibs by searching for libraries
+ # that are linked more than once (e.g. -la -lb -la)
+ for deplib in $deplibs; do
+ if $opt_preserve_dup_deps ; then
+ case "$libs " in
+ *" $deplib "*) func_append specialdeplibs " $deplib" ;;
+ esac
+ fi
+ func_append libs " $deplib"
+ done
+
+ if test "$linkmode" = lib; then
+ libs="$predeps $libs $compiler_lib_search_path $postdeps"
+
+ # Compute libraries that are listed more than once in $predeps
+ # $postdeps and mark them as special (i.e., whose duplicates are
+ # not to be eliminated).
+ pre_post_deps=
+ if $opt_duplicate_compiler_generated_deps; then
+ for pre_post_dep in $predeps $postdeps; do
+ case "$pre_post_deps " in
+ *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
+ esac
+ func_append pre_post_deps " $pre_post_dep"
+ done
+ fi
+ pre_post_deps=
+ fi
+
+ deplibs=
+ newdependency_libs=
+ newlib_search_path=
+ need_relink=no # whether we're linking any uninstalled libtool libraries
+ notinst_deplibs= # not-installed libtool libraries
+ notinst_path= # paths that contain not-installed libtool libraries
+
+ case $linkmode in
+ lib)
+ passes="conv dlpreopen link"
+ for file in $dlfiles $dlprefiles; do
+ case $file in
+ *.la) ;;
+ *)
+ func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
+ ;;
+ esac
+ done
+ ;;
+ prog)
+ compile_deplibs=
+ finalize_deplibs=
+ alldeplibs=no
+ newdlfiles=
+ newdlprefiles=
+ passes="conv scan dlopen dlpreopen link"
+ ;;
+ *) passes="conv"
+ ;;
+ esac
+
+ for pass in $passes; do
+ # The preopen pass in lib mode reverses $deplibs; put it back here
+ # so that -L comes before libs that need it for instance...
+ if test "$linkmode,$pass" = "lib,link"; then
+ ## FIXME: Find the place where the list is rebuilt in the wrong
+ ## order, and fix it there properly
+ tmp_deplibs=
+ for deplib in $deplibs; do
+ tmp_deplibs="$deplib $tmp_deplibs"
+ done
+ deplibs="$tmp_deplibs"
+ fi
+
+ if test "$linkmode,$pass" = "lib,link" ||
+ test "$linkmode,$pass" = "prog,scan"; then
+ libs="$deplibs"
+ deplibs=
+ fi
+ if test "$linkmode" = prog; then
+ case $pass in
+ dlopen) libs="$dlfiles" ;;
+ dlpreopen) libs="$dlprefiles" ;;
+ link)
+ libs="$deplibs %DEPLIBS%"
+ test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
+ ;;
+ esac
+ fi
+ if test "$linkmode,$pass" = "lib,dlpreopen"; then
+ # Collect and forward deplibs of preopened libtool libs
+ for lib in $dlprefiles; do
+ # Ignore non-libtool-libs
+ dependency_libs=
+ func_resolve_sysroot "$lib"
+ case $lib in
+ *.la) func_source "$func_resolve_sysroot_result" ;;
+ esac
+
+ # Collect preopened libtool deplibs, except any this library
+ # has declared as weak libs
+ for deplib in $dependency_libs; do
+ func_basename "$deplib"
+ deplib_base=$func_basename_result
+ case " $weak_libs " in
+ *" $deplib_base "*) ;;
+ *) func_append deplibs " $deplib" ;;
+ esac
+ done
+ done
+ libs="$dlprefiles"
+ fi
+ if test "$pass" = dlopen; then
+ # Collect dlpreopened libraries
+ save_deplibs="$deplibs"
+ deplibs=
+ fi
+
+ for deplib in $libs; do
+ lib=
+ found=no
+ case $deplib in
+ -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
+ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
+ if test "$linkmode,$pass" = "prog,link"; then
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ else
+ func_append compiler_flags " $deplib"
+ if test "$linkmode" = lib ; then
+ case "$new_inherited_linker_flags " in
+ *" $deplib "*) ;;
+ * ) func_append new_inherited_linker_flags " $deplib" ;;
+ esac
+ fi
+ fi
+ continue
+ ;;
+ -l*)
+ if test "$linkmode" != lib && test "$linkmode" != prog; then
+ func_warning "\`-l' is ignored for archives/objects"
+ continue
+ fi
+ func_stripname '-l' '' "$deplib"
+ name=$func_stripname_result
+ if test "$linkmode" = lib; then
+ searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
+ else
+ searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
+ fi
+ for searchdir in $searchdirs; do
+ for search_ext in .la $std_shrext .so .a; do
+ # Search the libtool library
+ lib="$searchdir/lib${name}${search_ext}"
+ if test -f "$lib"; then
+ if test "$search_ext" = ".la"; then
+ found=yes
+ else
+ found=no
+ fi
+ break 2
+ fi
+ done
+ done
+ if test "$found" != yes; then
+ # deplib doesn't seem to be a libtool library
+ if test "$linkmode,$pass" = "prog,link"; then
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ else
+ deplibs="$deplib $deplibs"
+ test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+ fi
+ continue
+ else # deplib is a libtool library
+ # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
+ # We need to do some special things here, and not later.
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ case " $predeps $postdeps " in
+ *" $deplib "*)
+ if func_lalib_p "$lib"; then
+ library_names=
+ old_library=
+ func_source "$lib"
+ for l in $old_library $library_names; do
+ ll="$l"
+ done
+ if test "X$ll" = "X$old_library" ; then # only static version available
+ found=no
+ func_dirname "$lib" "" "."
+ ladir="$func_dirname_result"
+ lib=$ladir/$old_library
+ if test "$linkmode,$pass" = "prog,link"; then
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ else
+ deplibs="$deplib $deplibs"
+ test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+ fi
+ continue
+ fi
+ fi
+ ;;
+ *) ;;
+ esac
+ fi
+ fi
+ ;; # -l
+ *.ltframework)
+ if test "$linkmode,$pass" = "prog,link"; then
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ else
+ deplibs="$deplib $deplibs"
+ if test "$linkmode" = lib ; then
+ case "$new_inherited_linker_flags " in
+ *" $deplib "*) ;;
+ * ) func_append new_inherited_linker_flags " $deplib" ;;
+ esac
+ fi
+ fi
+ continue
+ ;;
+ -L*)
+ case $linkmode in
+ lib)
+ deplibs="$deplib $deplibs"
+ test "$pass" = conv && continue
+ newdependency_libs="$deplib $newdependency_libs"
+ func_stripname '-L' '' "$deplib"
+ func_resolve_sysroot "$func_stripname_result"
+ func_append newlib_search_path " $func_resolve_sysroot_result"
+ ;;
+ prog)
+ if test "$pass" = conv; then
+ deplibs="$deplib $deplibs"
+ continue
+ fi
+ if test "$pass" = scan; then
+ deplibs="$deplib $deplibs"
+ else
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ fi
+ func_stripname '-L' '' "$deplib"
+ func_resolve_sysroot "$func_stripname_result"
+ func_append newlib_search_path " $func_resolve_sysroot_result"
+ ;;
+ *)
+ func_warning "\`-L' is ignored for archives/objects"
+ ;;
+ esac # linkmode
+ continue
+ ;; # -L
+ -R*)
+ if test "$pass" = link; then
+ func_stripname '-R' '' "$deplib"
+ func_resolve_sysroot "$func_stripname_result"
+ dir=$func_resolve_sysroot_result
+ # Make sure the xrpath contains only unique directories.
+ case "$xrpath " in
+ *" $dir "*) ;;
+ *) func_append xrpath " $dir" ;;
+ esac
+ fi
+ deplibs="$deplib $deplibs"
+ continue
+ ;;
+ *.la)
+ func_resolve_sysroot "$deplib"
+ lib=$func_resolve_sysroot_result
+ ;;
+ *.$libext)
+ if test "$pass" = conv; then
+ deplibs="$deplib $deplibs"
+ continue
+ fi
+ case $linkmode in
+ lib)
+ # Linking convenience modules into shared libraries is allowed,
+ # but linking other static libraries is non-portable.
+ case " $dlpreconveniencelibs " in
+ *" $deplib "*) ;;
+ *)
+ valid_a_lib=no
+ case $deplibs_check_method in
+ match_pattern*)
+ set dummy $deplibs_check_method; shift
+ match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
+ if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
+ | $EGREP "$match_pattern_regex" > /dev/null; then
+ valid_a_lib=yes
+ fi
+ ;;
+ pass_all)
+ valid_a_lib=yes
+ ;;
+ esac
+ if test "$valid_a_lib" != yes; then
+ echo
+ $ECHO "*** Warning: Trying to link with static lib archive $deplib."
+ echo "*** I have the capability to make that library automatically link in when"
+ echo "*** you link to this library. But I can only do this if you have a"
+ echo "*** shared version of the library, which you do not appear to have"
+ echo "*** because the file extensions .$libext of this argument makes me believe"
+ echo "*** that it is just a static archive that I should not use here."
+ else
+ echo
+ $ECHO "*** Warning: Linking the shared library $output against the"
+ $ECHO "*** static library $deplib is not portable!"
+ deplibs="$deplib $deplibs"
+ fi
+ ;;
+ esac
+ continue
+ ;;
+ prog)
+ if test "$pass" != link; then
+ deplibs="$deplib $deplibs"
+ else
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ fi
+ continue
+ ;;
+ esac # linkmode
+ ;; # *.$libext
+ *.lo | *.$objext)
+ if test "$pass" = conv; then
+ deplibs="$deplib $deplibs"
+ elif test "$linkmode" = prog; then
+ if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
+ # If there is no dlopen support or we're linking statically,
+ # we need to preload.
+ func_append newdlprefiles " $deplib"
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ else
+ func_append newdlfiles " $deplib"
+ fi
+ fi
+ continue
+ ;;
+ %DEPLIBS%)
+ alldeplibs=yes
+ continue
+ ;;
+ esac # case $deplib
+
+ if test "$found" = yes || test -f "$lib"; then :
+ else
+ func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
+ fi
+
+ # Check to see that this really is a libtool archive.
+ func_lalib_unsafe_p "$lib" \
+ || func_fatal_error "\`$lib' is not a valid libtool archive"
+
+ func_dirname "$lib" "" "."
+ ladir="$func_dirname_result"
+
+ dlname=
+ dlopen=
+ dlpreopen=
+ libdir=
+ library_names=
+ old_library=
+ inherited_linker_flags=
+ # If the library was installed with an old release of libtool,
+ # it will not redefine variables installed, or shouldnotlink
+ installed=yes
+ shouldnotlink=no
+ avoidtemprpath=
+
+
+ # Read the .la file
+ func_source "$lib"
+
+ # Convert "-framework foo" to "foo.ltframework"
+ if test -n "$inherited_linker_flags"; then
+ tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
+ for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
+ case " $new_inherited_linker_flags " in
+ *" $tmp_inherited_linker_flag "*) ;;
+ *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
+ esac
+ done
+ fi
+ dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
+ if test "$linkmode,$pass" = "lib,link" ||
+ test "$linkmode,$pass" = "prog,scan" ||
+ { test "$linkmode" != prog && test "$linkmode" != lib; }; then
+ test -n "$dlopen" && func_append dlfiles " $dlopen"
+ test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
+ fi
+
+ if test "$pass" = conv; then
+ # Only check for convenience libraries
+ deplibs="$lib $deplibs"
+ if test -z "$libdir"; then
+ if test -z "$old_library"; then
+ func_fatal_error "cannot find name of link library for \`$lib'"
+ fi
+ # It is a libtool convenience library, so add in its objects.
+ func_append convenience " $ladir/$objdir/$old_library"
+ func_append old_convenience " $ladir/$objdir/$old_library"
+ tmp_libs=
+ for deplib in $dependency_libs; do
+ deplibs="$deplib $deplibs"
+ if $opt_preserve_dup_deps ; then
+ case "$tmp_libs " in
+ *" $deplib "*) func_append specialdeplibs " $deplib" ;;
+ esac
+ fi
+ func_append tmp_libs " $deplib"
+ done
+ elif test "$linkmode" != prog && test "$linkmode" != lib; then
+ func_fatal_error "\`$lib' is not a convenience library"
+ fi
+ continue
+ fi # $pass = conv
+
+
+ # Get the name of the library we link against.
+ linklib=
+ if test -n "$old_library" &&
+ { test "$prefer_static_libs" = yes ||
+ test "$prefer_static_libs,$installed" = "built,no"; }; then
+ linklib=$old_library
+ else
+ for l in $old_library $library_names; do
+ linklib="$l"
+ done
+ fi
+ if test -z "$linklib"; then
+ func_fatal_error "cannot find name of link library for \`$lib'"
+ fi
+
+ # This library was specified with -dlopen.
+ if test "$pass" = dlopen; then
+ if test -z "$libdir"; then
+ func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
+ fi
+ if test -z "$dlname" ||
+ test "$dlopen_support" != yes ||
+ test "$build_libtool_libs" = no; then
+ # If there is no dlname, no dlopen support or we're linking
+ # statically, we need to preload. We also need to preload any
+ # dependent libraries so libltdl's deplib preloader doesn't
+ # bomb out in the load deplibs phase.
+ func_append dlprefiles " $lib $dependency_libs"
+ else
+ func_append newdlfiles " $lib"
+ fi
+ continue
+ fi # $pass = dlopen
+
+ # We need an absolute path.
+ case $ladir in
+ [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
+ *)
+ abs_ladir=`cd "$ladir" && pwd`
+ if test -z "$abs_ladir"; then
+ func_warning "cannot determine absolute directory name of \`$ladir'"
+ func_warning "passing it literally to the linker, although it might fail"
+ abs_ladir="$ladir"
+ fi
+ ;;
+ esac
+ func_basename "$lib"
+ laname="$func_basename_result"
+
+ # Find the relevant object directory and library name.
+ if test "X$installed" = Xyes; then
+ if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
+ func_warning "library \`$lib' was moved."
+ dir="$ladir"
+ absdir="$abs_ladir"
+ libdir="$abs_ladir"
+ else
+ dir="$lt_sysroot$libdir"
+ absdir="$lt_sysroot$libdir"
+ fi
+ test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
+ else
+ if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
+ dir="$ladir"
+ absdir="$abs_ladir"
+ # Remove this search path later
+ func_append notinst_path " $abs_ladir"
+ else
+ dir="$ladir/$objdir"
+ absdir="$abs_ladir/$objdir"
+ # Remove this search path later
+ func_append notinst_path " $abs_ladir"
+ fi
+ fi # $installed = yes
+ func_stripname 'lib' '.la' "$laname"
+ name=$func_stripname_result
+
+ # This library was specified with -dlpreopen.
+ if test "$pass" = dlpreopen; then
+ if test -z "$libdir" && test "$linkmode" = prog; then
+ func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
+ fi
+ case "$host" in
+ # special handling for platforms with PE-DLLs.
+ *cygwin* | *mingw* | *cegcc* )
+ # Linker will automatically link against shared library if both
+ # static and shared are present. Therefore, ensure we extract
+ # symbols from the import library if a shared library is present
+ # (otherwise, the dlopen module name will be incorrect). We do
+ # this by putting the import library name into $newdlprefiles.
+ # We recover the dlopen module name by 'saving' the la file
+ # name in a special purpose variable, and (later) extracting the
+ # dlname from the la file.
+ if test -n "$dlname"; then
+ func_tr_sh "$dir/$linklib"
+ eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
+ func_append newdlprefiles " $dir/$linklib"
+ else
+ func_append newdlprefiles " $dir/$old_library"
+ # Keep a list of preopened convenience libraries to check
+ # that they are being used correctly in the link pass.
+ test -z "$libdir" && \
+ func_append dlpreconveniencelibs " $dir/$old_library"
+ fi
+ ;;
+ * )
+ # Prefer using a static library (so that no silly _DYNAMIC symbols
+ # are required to link).
+ if test -n "$old_library"; then
+ func_append newdlprefiles " $dir/$old_library"
+ # Keep a list of preopened convenience libraries to check
+ # that they are being used correctly in the link pass.
+ test -z "$libdir" && \
+ func_append dlpreconveniencelibs " $dir/$old_library"
+ # Otherwise, use the dlname, so that lt_dlopen finds it.
+ elif test -n "$dlname"; then
+ func_append newdlprefiles " $dir/$dlname"
+ else
+ func_append newdlprefiles " $dir/$linklib"
+ fi
+ ;;
+ esac
+ fi # $pass = dlpreopen
+
+ if test -z "$libdir"; then
+ # Link the convenience library
+ if test "$linkmode" = lib; then
+ deplibs="$dir/$old_library $deplibs"
+ elif test "$linkmode,$pass" = "prog,link"; then
+ compile_deplibs="$dir/$old_library $compile_deplibs"
+ finalize_deplibs="$dir/$old_library $finalize_deplibs"
+ else
+ deplibs="$lib $deplibs" # used for prog,scan pass
+ fi
+ continue
+ fi
+
+
+ if test "$linkmode" = prog && test "$pass" != link; then
+ func_append newlib_search_path " $ladir"
+ deplibs="$lib $deplibs"
+
+ linkalldeplibs=no
+ if test "$link_all_deplibs" != no || test -z "$library_names" ||
+ test "$build_libtool_libs" = no; then
+ linkalldeplibs=yes
+ fi
+
+ tmp_libs=
+ for deplib in $dependency_libs; do
+ case $deplib in
+ -L*) func_stripname '-L' '' "$deplib"
+ func_resolve_sysroot "$func_stripname_result"
+ func_append newlib_search_path " $func_resolve_sysroot_result"
+ ;;
+ esac
+ # Need to link against all dependency_libs?
+ if test "$linkalldeplibs" = yes; then
+ deplibs="$deplib $deplibs"
+ else
+ # Need to hardcode shared library paths
+ # or/and link against static libraries
+ newdependency_libs="$deplib $newdependency_libs"
+ fi
+ if $opt_preserve_dup_deps ; then
+ case "$tmp_libs " in
+ *" $deplib "*) func_append specialdeplibs " $deplib" ;;
+ esac
+ fi
+ func_append tmp_libs " $deplib"
+ done # for deplib
+ continue
+ fi # $linkmode = prog...
+
+ if test "$linkmode,$pass" = "prog,link"; then
+ if test -n "$library_names" &&
+ { { test "$prefer_static_libs" = no ||
+ test "$prefer_static_libs,$installed" = "built,yes"; } ||
+ test -z "$old_library"; }; then
+ # We need to hardcode the library path
+ if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
+ # Make sure the rpath contains only unique directories.
+ case "$temp_rpath:" in
+ *"$absdir:"*) ;;
+ *) func_append temp_rpath "$absdir:" ;;
+ esac
+ fi
+
+ # Hardcode the library path.
+ # Skip directories that are in the system default run-time
+ # search path.
+ case " $sys_lib_dlsearch_path " in
+ *" $absdir "*) ;;
+ *)
+ case "$compile_rpath " in
+ *" $absdir "*) ;;
+ *) func_append compile_rpath " $absdir" ;;
+ esac
+ ;;
+ esac
+ case " $sys_lib_dlsearch_path " in
+ *" $libdir "*) ;;
+ *)
+ case "$finalize_rpath " in
+ *" $libdir "*) ;;
+ *) func_append finalize_rpath " $libdir" ;;
+ esac
+ ;;
+ esac
+ fi # $linkmode,$pass = prog,link...
+
+ if test "$alldeplibs" = yes &&
+ { test "$deplibs_check_method" = pass_all ||
+ { test "$build_libtool_libs" = yes &&
+ test -n "$library_names"; }; }; then
+ # We only need to search for static libraries
+ continue
+ fi
+ fi
+
+ link_static=no # Whether the deplib will be linked statically
+ use_static_libs=$prefer_static_libs
+ if test "$use_static_libs" = built && test "$installed" = yes; then
+ use_static_libs=no
+ fi
+ if test -n "$library_names" &&
+ { test "$use_static_libs" = no || test -z "$old_library"; }; then
+ case $host in
+ *cygwin* | *mingw* | *cegcc*)
+ # No point in relinking DLLs because paths are not encoded
+ func_append notinst_deplibs " $lib"
+ need_relink=no
+ ;;
+ *)
+ if test "$installed" = no; then
+ func_append notinst_deplibs " $lib"
+ need_relink=yes
+ fi
+ ;;
+ esac
+ # This is a shared library
+
+ # Warn about portability, can't link against -module's on some
+ # systems (darwin). Don't bleat about dlopened modules though!
+ dlopenmodule=""
+ for dlpremoduletest in $dlprefiles; do
+ if test "X$dlpremoduletest" = "X$lib"; then
+ dlopenmodule="$dlpremoduletest"
+ break
+ fi
+ done
+ if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
+ echo
+ if test "$linkmode" = prog; then
+ $ECHO "*** Warning: Linking the executable $output against the loadable module"
+ else
+ $ECHO "*** Warning: Linking the shared library $output against the loadable module"
+ fi
+ $ECHO "*** $linklib is not portable!"
+ fi
+ if test "$linkmode" = lib &&
+ test "$hardcode_into_libs" = yes; then
+ # Hardcode the library path.
+ # Skip directories that are in the system default run-time
+ # search path.
+ case " $sys_lib_dlsearch_path " in
+ *" $absdir "*) ;;
+ *)
+ case "$compile_rpath " in
+ *" $absdir "*) ;;
+ *) func_append compile_rpath " $absdir" ;;
+ esac
+ ;;
+ esac
+ case " $sys_lib_dlsearch_path " in
+ *" $libdir "*) ;;
+ *)
+ case "$finalize_rpath " in
+ *" $libdir "*) ;;
+ *) func_append finalize_rpath " $libdir" ;;
+ esac
+ ;;
+ esac
+ fi
+
+ if test -n "$old_archive_from_expsyms_cmds"; then
+ # figure out the soname
+ set dummy $library_names
+ shift
+ realname="$1"
+ shift
+ libname=`eval "\\$ECHO \"$libname_spec\""`
+ # use dlname if we got it. it's perfectly good, no?
+ if test -n "$dlname"; then
+ soname="$dlname"
+ elif test -n "$soname_spec"; then
+ # bleh windows
+ case $host in
+ *cygwin* | mingw* | *cegcc*)
+ func_arith $current - $age
+ major=$func_arith_result
+ versuffix="-$major"
+ ;;
+ esac
+ eval soname=\"$soname_spec\"
+ else
+ soname="$realname"
+ fi
+
+ # Make a new name for the extract_expsyms_cmds to use
+ soroot="$soname"
+ func_basename "$soroot"
+ soname="$func_basename_result"
+ func_stripname 'lib' '.dll' "$soname"
+ newlib=libimp-$func_stripname_result.a
+
+ # If the library has no export list, then create one now
+ if test -f "$output_objdir/$soname-def"; then :
+ else
+ func_verbose "extracting exported symbol list from \`$soname'"
+ func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
+ fi
+
+ # Create $newlib
+ if test -f "$output_objdir/$newlib"; then :; else
+ func_verbose "generating import library for \`$soname'"
+ func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
+ fi
+ # make sure the library variables are pointing to the new library
+ dir=$output_objdir
+ linklib=$newlib
+ fi # test -n "$old_archive_from_expsyms_cmds"
+
+ if test "$linkmode" = prog || test "$opt_mode" != relink; then
+ add_shlibpath=
+ add_dir=
+ add=
+ lib_linked=yes
+ case $hardcode_action in
+ immediate | unsupported)
+ if test "$hardcode_direct" = no; then
+ add="$dir/$linklib"
+ case $host in
+ *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
+ *-*-sysv4*uw2*) add_dir="-L$dir" ;;
+ *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
+ *-*-unixware7*) add_dir="-L$dir" ;;
+ *-*-darwin* )
+ # if the lib is a (non-dlopened) module then we can not
+ # link against it, someone is ignoring the earlier warnings
+ if /usr/bin/file -L $add 2> /dev/null |
+ $GREP ": [^:]* bundle" >/dev/null ; then
+ if test "X$dlopenmodule" != "X$lib"; then
+ $ECHO "*** Warning: lib $linklib is a module, not a shared library"
+ if test -z "$old_library" ; then
+ echo
+ echo "*** And there doesn't seem to be a static archive available"
+ echo "*** The link will probably fail, sorry"
+ else
+ add="$dir/$old_library"
+ fi
+ elif test -n "$old_library"; then
+ add="$dir/$old_library"
+ fi
+ fi
+ esac
+ elif test "$hardcode_minus_L" = no; then
+ case $host in
+ *-*-sunos*) add_shlibpath="$dir" ;;
+ esac
+ add_dir="-L$dir"
+ add="-l$name"
+ elif test "$hardcode_shlibpath_var" = no; then
+ add_shlibpath="$dir"
+ add="-l$name"
+ else
+ lib_linked=no
+ fi
+ ;;
+ relink)
+ if test "$hardcode_direct" = yes &&
+ test "$hardcode_direct_absolute" = no; then
+ add="$dir/$linklib"
+ elif test "$hardcode_minus_L" = yes; then
+ add_dir="-L$absdir"
+ # Try looking first in the location we're being installed to.
+ if test -n "$inst_prefix_dir"; then
+ case $libdir in
+ [\\/]*)
+ func_append add_dir " -L$inst_prefix_dir$libdir"
+ ;;
+ esac
+ fi
+ add="-l$name"
+ elif test "$hardcode_shlibpath_var" = yes; then
+ add_shlibpath="$dir"
+ add="-l$name"
+ else
+ lib_linked=no
+ fi
+ ;;
+ *) lib_linked=no ;;
+ esac
+
+ if test "$lib_linked" != yes; then
+ func_fatal_configuration "unsupported hardcode properties"
+ fi
+
+ if test -n "$add_shlibpath"; then
+ case :$compile_shlibpath: in
+ *":$add_shlibpath:"*) ;;
+ *) func_append compile_shlibpath "$add_shlibpath:" ;;
+ esac
+ fi
+ if test "$linkmode" = prog; then
+ test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
+ test -n "$add" && compile_deplibs="$add $compile_deplibs"
+ else
+ test -n "$add_dir" && deplibs="$add_dir $deplibs"
+ test -n "$add" && deplibs="$add $deplibs"
+ if test "$hardcode_direct" != yes &&
+ test "$hardcode_minus_L" != yes &&
+ test "$hardcode_shlibpath_var" = yes; then
+ case :$finalize_shlibpath: in
+ *":$libdir:"*) ;;
+ *) func_append finalize_shlibpath "$libdir:" ;;
+ esac
+ fi
+ fi
+ fi
+
+ if test "$linkmode" = prog || test "$opt_mode" = relink; then
+ add_shlibpath=
+ add_dir=
+ add=
+ # Finalize command for both is simple: just hardcode it.
+ if test "$hardcode_direct" = yes &&
+ test "$hardcode_direct_absolute" = no; then
+ add="$libdir/$linklib"
+ elif test "$hardcode_minus_L" = yes; then
+ add_dir="-L$libdir"
+ add="-l$name"
+ elif test "$hardcode_shlibpath_var" = yes; then
+ case :$finalize_shlibpath: in
+ *":$libdir:"*) ;;
+ *) func_append finalize_shlibpath "$libdir:" ;;
+ esac
+ add="-l$name"
+ elif test "$hardcode_automatic" = yes; then
+ if test -n "$inst_prefix_dir" &&
+ test -f "$inst_prefix_dir$libdir/$linklib" ; then
+ add="$inst_prefix_dir$libdir/$linklib"
+ else
+ add="$libdir/$linklib"
+ fi
+ else
+ # We cannot seem to hardcode it, guess we'll fake it.
+ add_dir="-L$libdir"
+ # Try looking first in the location we're being installed to.
+ if test -n "$inst_prefix_dir"; then
+ case $libdir in
+ [\\/]*)
+ func_append add_dir " -L$inst_prefix_dir$libdir"
+ ;;
+ esac
+ fi
+ add="-l$name"
+ fi
+
+ if test "$linkmode" = prog; then
+ test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
+ test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
+ else
+ test -n "$add_dir" && deplibs="$add_dir $deplibs"
+ test -n "$add" && deplibs="$add $deplibs"
+ fi
+ fi
+ elif test "$linkmode" = prog; then
+ # Here we assume that one of hardcode_direct or hardcode_minus_L
+ # is not unsupported. This is valid on all known static and
+ # shared platforms.
+ if test "$hardcode_direct" != unsupported; then
+ test -n "$old_library" && linklib="$old_library"
+ compile_deplibs="$dir/$linklib $compile_deplibs"
+ finalize_deplibs="$dir/$linklib $finalize_deplibs"
+ else
+ compile_deplibs="-l$name -L$dir $compile_deplibs"
+ finalize_deplibs="-l$name -L$dir $finalize_deplibs"
+ fi
+ elif test "$build_libtool_libs" = yes; then
+ # Not a shared library
+ if test "$deplibs_check_method" != pass_all; then
+ # We're trying link a shared library against a static one
+ # but the system doesn't support it.
+
+ # Just print a warning and add the library to dependency_libs so
+ # that the program can be linked against the static library.
+ echo
+ $ECHO "*** Warning: This system can not link to static lib archive $lib."
+ echo "*** I have the capability to make that library automatically link in when"
+ echo "*** you link to this library. But I can only do this if you have a"
+ echo "*** shared version of the library, which you do not appear to have."
+ if test "$module" = yes; then
+ echo "*** But as you try to build a module library, libtool will still create "
+ echo "*** a static module, that should work as long as the dlopening application"
+ echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
+ if test -z "$global_symbol_pipe"; then
+ echo
+ echo "*** However, this would only work if libtool was able to extract symbol"
+ echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+ echo "*** not find such a program. So, this module is probably useless."
+ echo "*** \`nm' from GNU binutils and a full rebuild may help."
+ fi
+ if test "$build_old_libs" = no; then
+ build_libtool_libs=module
+ build_old_libs=yes
+ else
+ build_libtool_libs=no
+ fi
+ fi
+ else
+ deplibs="$dir/$old_library $deplibs"
+ link_static=yes
+ fi
+ fi # link shared/static library?
+
+ if test "$linkmode" = lib; then
+ if test -n "$dependency_libs" &&
+ { test "$hardcode_into_libs" != yes ||
+ test "$build_old_libs" = yes ||
+ test "$link_static" = yes; }; then
+ # Extract -R from dependency_libs
+ temp_deplibs=
+ for libdir in $dependency_libs; do
+ case $libdir in
+ -R*) func_stripname '-R' '' "$libdir"
+ temp_xrpath=$func_stripname_result
+ case " $xrpath " in
+ *" $temp_xrpath "*) ;;
+ *) func_append xrpath " $temp_xrpath";;
+ esac;;
+ *) func_append temp_deplibs " $libdir";;
+ esac
+ done
+ dependency_libs="$temp_deplibs"
+ fi
+
+ func_append newlib_search_path " $absdir"
+ # Link against this library
+ test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
+ # ... and its dependency_libs
+ tmp_libs=
+ for deplib in $dependency_libs; do
+ newdependency_libs="$deplib $newdependency_libs"
+ case $deplib in
+ -L*) func_stripname '-L' '' "$deplib"
+ func_resolve_sysroot "$func_stripname_result";;
+ *) func_resolve_sysroot "$deplib" ;;
+ esac
+ if $opt_preserve_dup_deps ; then
+ case "$tmp_libs " in
+ *" $func_resolve_sysroot_result "*)
+ func_append specialdeplibs " $func_resolve_sysroot_result" ;;
+ esac
+ fi
+ func_append tmp_libs " $func_resolve_sysroot_result"
+ done
+
+ if test "$link_all_deplibs" != no; then
+ # Add the search paths of all dependency libraries
+ for deplib in $dependency_libs; do
+ path=
+ case $deplib in
+ -L*) path="$deplib" ;;
+ *.la)
+ func_resolve_sysroot "$deplib"
+ deplib=$func_resolve_sysroot_result
+ func_dirname "$deplib" "" "."
+ dir=$func_dirname_result
+ # We need an absolute path.
+ case $dir in
+ [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
+ *)
+ absdir=`cd "$dir" && pwd`
+ if test -z "$absdir"; then
+ func_warning "cannot determine absolute directory name of \`$dir'"
+ absdir="$dir"
+ fi
+ ;;
+ esac
+ if $GREP "^installed=no" $deplib > /dev/null; then
+ case $host in
+ *-*-darwin*)
+ depdepl=
+ eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
+ if test -n "$deplibrary_names" ; then
+ for tmp in $deplibrary_names ; do
+ depdepl=$tmp
+ done
+ if test -f "$absdir/$objdir/$depdepl" ; then
+ depdepl="$absdir/$objdir/$depdepl"
+ darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
+ if test -z "$darwin_install_name"; then
+ darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
+ fi
+ func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
+ func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
+ path=
+ fi
+ fi
+ ;;
+ *)
+ path="-L$absdir/$objdir"
+ ;;
+ esac
+ else
+ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+ test -z "$libdir" && \
+ func_fatal_error "\`$deplib' is not a valid libtool archive"
+ test "$absdir" != "$libdir" && \
+ func_warning "\`$deplib' seems to be moved"
+
+ path="-L$absdir"
+ fi
+ ;;
+ esac
+ case " $deplibs " in
+ *" $path "*) ;;
+ *) deplibs="$path $deplibs" ;;
+ esac
+ done
+ fi # link_all_deplibs != no
+ fi # linkmode = lib
+ done # for deplib in $libs
+ if test "$pass" = link; then
+ if test "$linkmode" = "prog"; then
+ compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
+ finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
+ else
+ compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
+ fi
+ fi
+ dependency_libs="$newdependency_libs"
+ if test "$pass" = dlpreopen; then
+ # Link the dlpreopened libraries before other libraries
+ for deplib in $save_deplibs; do
+ deplibs="$deplib $deplibs"
+ done
+ fi
+ if test "$pass" != dlopen; then
+ if test "$pass" != conv; then
+ # Make sure lib_search_path contains only unique directories.
+ lib_search_path=
+ for dir in $newlib_search_path; do
+ case "$lib_search_path " in
+ *" $dir "*) ;;
+ *) func_append lib_search_path " $dir" ;;
+ esac
+ done
+ newlib_search_path=
+ fi
+
+ if test "$linkmode,$pass" != "prog,link"; then
+ vars="deplibs"
+ else
+ vars="compile_deplibs finalize_deplibs"
+ fi
+ for var in $vars dependency_libs; do
+ # Add libraries to $var in reverse order
+ eval tmp_libs=\"\$$var\"
+ new_libs=
+ for deplib in $tmp_libs; do
+ # FIXME: Pedantically, this is the right thing to do, so
+ # that some nasty dependency loop isn't accidentally
+ # broken:
+ #new_libs="$deplib $new_libs"
+ # Pragmatically, this seems to cause very few problems in
+ # practice:
+ case $deplib in
+ -L*) new_libs="$deplib $new_libs" ;;
+ -R*) ;;
+ *)
+ # And here is the reason: when a library appears more
+ # than once as an explicit dependence of a library, or
+ # is implicitly linked in more than once by the
+ # compiler, it is considered special, and multiple
+ # occurrences thereof are not removed. Compare this
+ # with having the same library being listed as a
+ # dependency of multiple other libraries: in this case,
+ # we know (pedantically, we assume) the library does not
+ # need to be listed more than once, so we keep only the
+ # last copy. This is not always right, but it is rare
+ # enough that we require users that really mean to play
+ # such unportable linking tricks to link the library
+ # using -Wl,-lname, so that libtool does not consider it
+ # for duplicate removal.
+ case " $specialdeplibs " in
+ *" $deplib "*) new_libs="$deplib $new_libs" ;;
+ *)
+ case " $new_libs " in
+ *" $deplib "*) ;;
+ *) new_libs="$deplib $new_libs" ;;
+ esac
+ ;;
+ esac
+ ;;
+ esac
+ done
+ tmp_libs=
+ for deplib in $new_libs; do
+ case $deplib in
+ -L*)
+ case " $tmp_libs " in
+ *" $deplib "*) ;;
+ *) func_append tmp_libs " $deplib" ;;
+ esac
+ ;;
+ *) func_append tmp_libs " $deplib" ;;
+ esac
+ done
+ eval $var=\"$tmp_libs\"
+ done # for var
+ fi
+ # Last step: remove runtime libs from dependency_libs
+ # (they stay in deplibs)
+ tmp_libs=
+ for i in $dependency_libs ; do
+ case " $predeps $postdeps $compiler_lib_search_path " in
+ *" $i "*)
+ i=""
+ ;;
+ esac
+ if test -n "$i" ; then
+ func_append tmp_libs " $i"
+ fi
+ done
+ dependency_libs=$tmp_libs
+ done # for pass
+ if test "$linkmode" = prog; then
+ dlfiles="$newdlfiles"
+ fi
+ if test "$linkmode" = prog || test "$linkmode" = lib; then
+ dlprefiles="$newdlprefiles"
+ fi
+
+ case $linkmode in
+ oldlib)
+ if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+ func_warning "\`-dlopen' is ignored for archives"
+ fi
+
+ case " $deplibs" in
+ *\ -l* | *\ -L*)
+ func_warning "\`-l' and \`-L' are ignored for archives" ;;
+ esac
+
+ test -n "$rpath" && \
+ func_warning "\`-rpath' is ignored for archives"
+
+ test -n "$xrpath" && \
+ func_warning "\`-R' is ignored for archives"
+
+ test -n "$vinfo" && \
+ func_warning "\`-version-info/-version-number' is ignored for archives"
+
+ test -n "$release" && \
+ func_warning "\`-release' is ignored for archives"
+
+ test -n "$export_symbols$export_symbols_regex" && \
+ func_warning "\`-export-symbols' is ignored for archives"
+
+ # Now set the variables for building old libraries.
+ build_libtool_libs=no
+ oldlibs="$output"
+ func_append objs "$old_deplibs"
+ ;;
+
+ lib)
+ # Make sure we only generate libraries of the form `libNAME.la'.
+ case $outputname in
+ lib*)
+ func_stripname 'lib' '.la' "$outputname"
+ name=$func_stripname_result
+ eval shared_ext=\"$shrext_cmds\"
+ eval libname=\"$libname_spec\"
+ ;;
+ *)
+ test "$module" = no && \
+ func_fatal_help "libtool library \`$output' must begin with \`lib'"
+
+ if test "$need_lib_prefix" != no; then
+ # Add the "lib" prefix for modules if required
+ func_stripname '' '.la' "$outputname"
+ name=$func_stripname_result
+ eval shared_ext=\"$shrext_cmds\"
+ eval libname=\"$libname_spec\"
+ else
+ func_stripname '' '.la' "$outputname"
+ libname=$func_stripname_result
+ fi
+ ;;
+ esac
+
+ if test -n "$objs"; then
+ if test "$deplibs_check_method" != pass_all; then
+ func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
+ else
+ echo
+ $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
+ $ECHO "*** objects $objs is not portable!"
+ func_append libobjs " $objs"
+ fi
+ fi
+
+ test "$dlself" != no && \
+ func_warning "\`-dlopen self' is ignored for libtool libraries"
+
+ set dummy $rpath
+ shift
+ test "$#" -gt 1 && \
+ func_warning "ignoring multiple \`-rpath's for a libtool library"
+
+ install_libdir="$1"
+
+ oldlibs=
+ if test -z "$rpath"; then
+ if test "$build_libtool_libs" = yes; then
+ # Building a libtool convenience library.
+ # Some compilers have problems with a `.al' extension so
+ # convenience libraries should have the same extension an
+ # archive normally would.
+ oldlibs="$output_objdir/$libname.$libext $oldlibs"
+ build_libtool_libs=convenience
+ build_old_libs=yes
+ fi
+
+ test -n "$vinfo" && \
+ func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
+
+ test -n "$release" && \
+ func_warning "\`-release' is ignored for convenience libraries"
+ else
+
+ # Parse the version information argument.
+ save_ifs="$IFS"; IFS=':'
+ set dummy $vinfo 0 0 0
+ shift
+ IFS="$save_ifs"
+
+ test -n "$7" && \
+ func_fatal_help "too many parameters to \`-version-info'"
+
+ # convert absolute version numbers to libtool ages
+ # this retains compatibility with .la files and attempts
+ # to make the code below a bit more comprehensible
+
+ case $vinfo_number in
+ yes)
+ number_major="$1"
+ number_minor="$2"
+ number_revision="$3"
+ #
+ # There are really only two kinds -- those that
+ # use the current revision as the major version
+ # and those that subtract age and use age as
+ # a minor version. But, then there is irix
+ # which has an extra 1 added just for fun
+ #
+ case $version_type in
+ # correct linux to gnu/linux during the next big refactor
+ darwin|linux|osf|windows|none)
+ func_arith $number_major + $number_minor
+ current=$func_arith_result
+ age="$number_minor"
+ revision="$number_revision"
+ ;;
+ freebsd-aout|freebsd-elf|qnx|sunos)
+ current="$number_major"
+ revision="$number_minor"
+ age="0"
+ ;;
+ irix|nonstopux)
+ func_arith $number_major + $number_minor
+ current=$func_arith_result
+ age="$number_minor"
+ revision="$number_minor"
+ lt_irix_increment=no
+ ;;
+ *)
+ func_fatal_configuration "$modename: unknown library version type \`$version_type'"
+ ;;
+ esac
+ ;;
+ no)
+ current="$1"
+ revision="$2"
+ age="$3"
+ ;;
+ esac
+
+ # Check that each of the things are valid numbers.
+ case $current in
+ 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+ *)
+ func_error "CURRENT \`$current' must be a nonnegative integer"
+ func_fatal_error "\`$vinfo' is not valid version information"
+ ;;
+ esac
+
+ case $revision in
+ 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+ *)
+ func_error "REVISION \`$revision' must be a nonnegative integer"
+ func_fatal_error "\`$vinfo' is not valid version information"
+ ;;
+ esac
+
+ case $age in
+ 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+ *)
+ func_error "AGE \`$age' must be a nonnegative integer"
+ func_fatal_error "\`$vinfo' is not valid version information"
+ ;;
+ esac
+
+ if test "$age" -gt "$current"; then
+ func_error "AGE \`$age' is greater than the current interface number \`$current'"
+ func_fatal_error "\`$vinfo' is not valid version information"
+ fi
+
+ # Calculate the version variables.
+ major=
+ versuffix=
+ verstring=
+ case $version_type in
+ none) ;;
+
+ darwin)
+ # Like Linux, but with the current version available in
+ # verstring for coding it into the library header
+ func_arith $current - $age
+ major=.$func_arith_result
+ versuffix="$major.$age.$revision"
+ # Darwin ld doesn't like 0 for these options...
+ func_arith $current + 1
+ minor_current=$func_arith_result
+ xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
+ verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
+ ;;
+
+ freebsd-aout)
+ major=".$current"
+ versuffix=".$current.$revision";
+ ;;
+
+ freebsd-elf)
+ major=".$current"
+ versuffix=".$current"
+ ;;
+
+ irix | nonstopux)
+ if test "X$lt_irix_increment" = "Xno"; then
+ func_arith $current - $age
+ else
+ func_arith $current - $age + 1
+ fi
+ major=$func_arith_result
+
+ case $version_type in
+ nonstopux) verstring_prefix=nonstopux ;;
+ *) verstring_prefix=sgi ;;
+ esac
+ verstring="$verstring_prefix$major.$revision"
+
+ # Add in all the interfaces that we are compatible with.
+ loop=$revision
+ while test "$loop" -ne 0; do
+ func_arith $revision - $loop
+ iface=$func_arith_result
+ func_arith $loop - 1
+ loop=$func_arith_result
+ verstring="$verstring_prefix$major.$iface:$verstring"
+ done
+
+ # Before this point, $major must not contain `.'.
+ major=.$major
+ versuffix="$major.$revision"
+ ;;
+
+ linux) # correct to gnu/linux during the next big refactor
+ func_arith $current - $age
+ major=.$func_arith_result
+ versuffix="$major.$age.$revision"
+ ;;
+
+ osf)
+ func_arith $current - $age
+ major=.$func_arith_result
+ versuffix=".$current.$age.$revision"
+ verstring="$current.$age.$revision"
+
+ # Add in all the interfaces that we are compatible with.
+ loop=$age
+ while test "$loop" -ne 0; do
+ func_arith $current - $loop
+ iface=$func_arith_result
+ func_arith $loop - 1
+ loop=$func_arith_result
+ verstring="$verstring:${iface}.0"
+ done
+
+ # Make executables depend on our current version.
+ func_append verstring ":${current}.0"
+ ;;
+
+ qnx)
+ major=".$current"
+ versuffix=".$current"
+ ;;
+
+ sunos)
+ major=".$current"
+ versuffix=".$current.$revision"
+ ;;
+
+ windows)
+ # Use '-' rather than '.', since we only want one
+ # extension on DOS 8.3 filesystems.
+ func_arith $current - $age
+ major=$func_arith_result
+ versuffix="-$major"
+ ;;
+
+ *)
+ func_fatal_configuration "unknown library version type \`$version_type'"
+ ;;
+ esac
+
+ # Clear the version info if we defaulted, and they specified a release.
+ if test -z "$vinfo" && test -n "$release"; then
+ major=
+ case $version_type in
+ darwin)
+ # we can't check for "0.0" in archive_cmds due to quoting
+ # problems, so we reset it completely
+ verstring=
+ ;;
+ *)
+ verstring="0.0"
+ ;;
+ esac
+ if test "$need_version" = no; then
+ versuffix=
+ else
+ versuffix=".0.0"
+ fi
+ fi
+
+ # Remove version info from name if versioning should be avoided
+ if test "$avoid_version" = yes && test "$need_version" = no; then
+ major=
+ versuffix=
+ verstring=""
+ fi
+
+ # Check to see if the archive will have undefined symbols.
+ if test "$allow_undefined" = yes; then
+ if test "$allow_undefined_flag" = unsupported; then
+ func_warning "undefined symbols not allowed in $host shared libraries"
+ build_libtool_libs=no
+ build_old_libs=yes
+ fi
+ else
+ # Don't allow undefined symbols.
+ allow_undefined_flag="$no_undefined_flag"
+ fi
+
+ fi
+
+ func_generate_dlsyms "$libname" "$libname" "yes"
+ func_append libobjs " $symfileobj"
+ test "X$libobjs" = "X " && libobjs=
+
+ if test "$opt_mode" != relink; then
+ # Remove our outputs, but don't remove object files since they
+ # may have been created when compiling PIC objects.
+ removelist=
+ tempremovelist=`$ECHO "$output_objdir/*"`
+ for p in $tempremovelist; do
+ case $p in
+ *.$objext | *.gcno)
+ ;;
+ $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
+ if test "X$precious_files_regex" != "X"; then
+ if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
+ then
+ continue
+ fi
+ fi
+ func_append removelist " $p"
+ ;;
+ *) ;;
+ esac
+ done
+ test -n "$removelist" && \
+ func_show_eval "${RM}r \$removelist"
+ fi
+
+ # Now set the variables for building old libraries.
+ if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
+ func_append oldlibs " $output_objdir/$libname.$libext"
+
+ # Transform .lo files to .o files.
+ oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
+ fi
+
+ # Eliminate all temporary directories.
+ #for path in $notinst_path; do
+ # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
+ # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
+ # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
+ #done
+
+ if test -n "$xrpath"; then
+ # If the user specified any rpath flags, then add them.
+ temp_xrpath=
+ for libdir in $xrpath; do
+ func_replace_sysroot "$libdir"
+ func_append temp_xrpath " -R$func_replace_sysroot_result"
+ case "$finalize_rpath " in
+ *" $libdir "*) ;;
+ *) func_append finalize_rpath " $libdir" ;;
+ esac
+ done
+ if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
+ dependency_libs="$temp_xrpath $dependency_libs"
+ fi
+ fi
+
+ # Make sure dlfiles contains only unique files that won't be dlpreopened
+ old_dlfiles="$dlfiles"
+ dlfiles=
+ for lib in $old_dlfiles; do
+ case " $dlprefiles $dlfiles " in
+ *" $lib "*) ;;
+ *) func_append dlfiles " $lib" ;;
+ esac
+ done
+
+ # Make sure dlprefiles contains only unique files
+ old_dlprefiles="$dlprefiles"
+ dlprefiles=
+ for lib in $old_dlprefiles; do
+ case "$dlprefiles " in
+ *" $lib "*) ;;
+ *) func_append dlprefiles " $lib" ;;
+ esac
+ done
+
+ if test "$build_libtool_libs" = yes; then
+ if test -n "$rpath"; then
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
+ # these systems don't actually have a c library (as such)!
+ ;;
+ *-*-rhapsody* | *-*-darwin1.[012])
+ # Rhapsody C library is in the System framework
+ func_append deplibs " System.ltframework"
+ ;;
+ *-*-netbsd*)
+ # Don't link with libc until the a.out ld.so is fixed.
+ ;;
+ *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+ # Do not include libc due to us having libc/libc_r.
+ ;;
+ *-*-sco3.2v5* | *-*-sco5v6*)
+ # Causes problems with __ctype
+ ;;
+ *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
+ # Compiler inserts libc in the correct place for threads to work
+ ;;
+ *)
+ # Add libc to deplibs on all other systems if necessary.
+ if test "$build_libtool_need_lc" = "yes"; then
+ func_append deplibs " -lc"
+ fi
+ ;;
+ esac
+ fi
+
+ # Transform deplibs into only deplibs that can be linked in shared.
+ name_save=$name
+ libname_save=$libname
+ release_save=$release
+ versuffix_save=$versuffix
+ major_save=$major
+ # I'm not sure if I'm treating the release correctly. I think
+ # release should show up in the -l (ie -lgmp5) so we don't want to
+ # add it in twice. Is that correct?
+ release=""
+ versuffix=""
+ major=""
+ newdeplibs=
+ droppeddeps=no
+ case $deplibs_check_method in
+ pass_all)
+ # Don't check for shared/static. Everything works.
+ # This might be a little naive. We might want to check
+ # whether the library exists or not. But this is on
+ # osf3 & osf4 and I'm not really sure... Just
+ # implementing what was already the behavior.
+ newdeplibs=$deplibs
+ ;;
+ test_compile)
+ # This code stresses the "libraries are programs" paradigm to its
+ # limits. Maybe even breaks it. We compile a program, linking it
+ # against the deplibs as a proxy for the library. Then we can check
+ # whether they linked in statically or dynamically with ldd.
+ $opt_dry_run || $RM conftest.c
+ cat > conftest.c <<EOF
+ int main() { return 0; }
+EOF
+ $opt_dry_run || $RM conftest
+ if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
+ ldd_output=`ldd conftest`
+ for i in $deplibs; do
+ case $i in
+ -l*)
+ func_stripname -l '' "$i"
+ name=$func_stripname_result
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ case " $predeps $postdeps " in
+ *" $i "*)
+ func_append newdeplibs " $i"
+ i=""
+ ;;
+ esac
+ fi
+ if test -n "$i" ; then
+ libname=`eval "\\$ECHO \"$libname_spec\""`
+ deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
+ set dummy $deplib_matches; shift
+ deplib_match=$1
+ if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+ func_append newdeplibs " $i"
+ else
+ droppeddeps=yes
+ echo
+ $ECHO "*** Warning: dynamic linker does not accept needed library $i."
+ echo "*** I have the capability to make that library automatically link in when"
+ echo "*** you link to this library. But I can only do this if you have a"
+ echo "*** shared version of the library, which I believe you do not have"
+ echo "*** because a test_compile did reveal that the linker did not use it for"
+ echo "*** its dynamic dependency list that programs get resolved with at runtime."
+ fi
+ fi
+ ;;
+ *)
+ func_append newdeplibs " $i"
+ ;;
+ esac
+ done
+ else
+ # Error occurred in the first compile. Let's try to salvage
+ # the situation: Compile a separate program for each library.
+ for i in $deplibs; do
+ case $i in
+ -l*)
+ func_stripname -l '' "$i"
+ name=$func_stripname_result
+ $opt_dry_run || $RM conftest
+ if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
+ ldd_output=`ldd conftest`
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ case " $predeps $postdeps " in
+ *" $i "*)
+ func_append newdeplibs " $i"
+ i=""
+ ;;
+ esac
+ fi
+ if test -n "$i" ; then
+ libname=`eval "\\$ECHO \"$libname_spec\""`
+ deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
+ set dummy $deplib_matches; shift
+ deplib_match=$1
+ if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+ func_append newdeplibs " $i"
+ else
+ droppeddeps=yes
+ echo
+ $ECHO "*** Warning: dynamic linker does not accept needed library $i."
+ echo "*** I have the capability to make that library automatically link in when"
+ echo "*** you link to this library. But I can only do this if you have a"
+ echo "*** shared version of the library, which you do not appear to have"
+ echo "*** because a test_compile did reveal that the linker did not use this one"
+ echo "*** as a dynamic dependency that programs can get resolved with at runtime."
+ fi
+ fi
+ else
+ droppeddeps=yes
+ echo
+ $ECHO "*** Warning! Library $i is needed by this library but I was not able to"
+ echo "*** make it link in! You will probably need to install it or some"
+ echo "*** library that it depends on before this library will be fully"
+ echo "*** functional. Installing it before continuing would be even better."
+ fi
+ ;;
+ *)
+ func_append newdeplibs " $i"
+ ;;
+ esac
+ done
+ fi
+ ;;
+ file_magic*)
+ set dummy $deplibs_check_method; shift
+ file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
+ for a_deplib in $deplibs; do
+ case $a_deplib in
+ -l*)
+ func_stripname -l '' "$a_deplib"
+ name=$func_stripname_result
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ case " $predeps $postdeps " in
+ *" $a_deplib "*)
+ func_append newdeplibs " $a_deplib"
+ a_deplib=""
+ ;;
+ esac
+ fi
+ if test -n "$a_deplib" ; then
+ libname=`eval "\\$ECHO \"$libname_spec\""`
+ if test -n "$file_magic_glob"; then
+ libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
+ else
+ libnameglob=$libname
+ fi
+ test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
+ for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
+ if test "$want_nocaseglob" = yes; then
+ shopt -s nocaseglob
+ potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
+ $nocaseglob
+ else
+ potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
+ fi
+ for potent_lib in $potential_libs; do
+ # Follow soft links.
+ if ls -lLd "$potent_lib" 2>/dev/null |
+ $GREP " -> " >/dev/null; then
+ continue
+ fi
+ # The statement above tries to avoid entering an
+ # endless loop below, in case of cyclic links.
+ # We might still enter an endless loop, since a link
+ # loop can be closed while we follow links,
+ # but so what?
+ potlib="$potent_lib"
+ while test -h "$potlib" 2>/dev/null; do
+ potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
+ case $potliblink in
+ [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
+ *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
+ esac
+ done
+ if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
+ $SED -e 10q |
+ $EGREP "$file_magic_regex" > /dev/null; then
+ func_append newdeplibs " $a_deplib"
+ a_deplib=""
+ break 2
+ fi
+ done
+ done
+ fi
+ if test -n "$a_deplib" ; then
+ droppeddeps=yes
+ echo
+ $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
+ echo "*** I have the capability to make that library automatically link in when"
+ echo "*** you link to this library. But I can only do this if you have a"
+ echo "*** shared version of the library, which you do not appear to have"
+ echo "*** because I did check the linker path looking for a file starting"
+ if test -z "$potlib" ; then
+ $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
+ else
+ $ECHO "*** with $libname and none of the candidates passed a file format test"
+ $ECHO "*** using a file magic. Last file checked: $potlib"
+ fi
+ fi
+ ;;
+ *)
+ # Add a -L argument.
+ func_append newdeplibs " $a_deplib"
+ ;;
+ esac
+ done # Gone through all deplibs.
+ ;;
+ match_pattern*)
+ set dummy $deplibs_check_method; shift
+ match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
+ for a_deplib in $deplibs; do
+ case $a_deplib in
+ -l*)
+ func_stripname -l '' "$a_deplib"
+ name=$func_stripname_result
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ case " $predeps $postdeps " in
+ *" $a_deplib "*)
+ func_append newdeplibs " $a_deplib"
+ a_deplib=""
+ ;;
+ esac
+ fi
+ if test -n "$a_deplib" ; then
+ libname=`eval "\\$ECHO \"$libname_spec\""`
+ for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
+ potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+ for potent_lib in $potential_libs; do
+ potlib="$potent_lib" # see symlink-check above in file_magic test
+ if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
+ $EGREP "$match_pattern_regex" > /dev/null; then
+ func_append newdeplibs " $a_deplib"
+ a_deplib=""
+ break 2
+ fi
+ done
+ done
+ fi
+ if test -n "$a_deplib" ; then
+ droppeddeps=yes
+ echo
+ $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
+ echo "*** I have the capability to make that library automatically link in when"
+ echo "*** you link to this library. But I can only do this if you have a"
+ echo "*** shared version of the library, which you do not appear to have"
+ echo "*** because I did check the linker path looking for a file starting"
+ if test -z "$potlib" ; then
+ $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
+ else
+ $ECHO "*** with $libname and none of the candidates passed a file format test"
+ $ECHO "*** using a regex pattern. Last file checked: $potlib"
+ fi
+ fi
+ ;;
+ *)
+ # Add a -L argument.
+ func_append newdeplibs " $a_deplib"
+ ;;
+ esac
+ done # Gone through all deplibs.
+ ;;
+ none | unknown | *)
+ newdeplibs=""
+ tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ for i in $predeps $postdeps ; do
+ # can't use Xsed below, because $i might contain '/'
+ tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
+ done
+ fi
+ case $tmp_deplibs in
+ *[!\ \ ]*)
+ echo
+ if test "X$deplibs_check_method" = "Xnone"; then
+ echo "*** Warning: inter-library dependencies are not supported in this platform."
+ else
+ echo "*** Warning: inter-library dependencies are not known to be supported."
+ fi
+ echo "*** All declared inter-library dependencies are being dropped."
+ droppeddeps=yes
+ ;;
+ esac
+ ;;
+ esac
+ versuffix=$versuffix_save
+ major=$major_save
+ release=$release_save
+ libname=$libname_save
+ name=$name_save
+
+ case $host in
+ *-*-rhapsody* | *-*-darwin1.[012])
+ # On Rhapsody replace the C library with the System framework
+ newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
+ ;;
+ esac
+
+ if test "$droppeddeps" = yes; then
+ if test "$module" = yes; then
+ echo
+ echo "*** Warning: libtool could not satisfy all declared inter-library"
+ $ECHO "*** dependencies of module $libname. Therefore, libtool will create"
+ echo "*** a static module, that should work as long as the dlopening"
+ echo "*** application is linked with the -dlopen flag."
+ if test -z "$global_symbol_pipe"; then
+ echo
+ echo "*** However, this would only work if libtool was able to extract symbol"
+ echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+ echo "*** not find such a program. So, this module is probably useless."
+ echo "*** \`nm' from GNU binutils and a full rebuild may help."
+ fi
+ if test "$build_old_libs" = no; then
+ oldlibs="$output_objdir/$libname.$libext"
+ build_libtool_libs=module
+ build_old_libs=yes
+ else
+ build_libtool_libs=no
+ fi
+ else
+ echo "*** The inter-library dependencies that have been dropped here will be"
+ echo "*** automatically added whenever a program is linked with this library"
+ echo "*** or is declared to -dlopen it."
+
+ if test "$allow_undefined" = no; then
+ echo
+ echo "*** Since this library must not contain undefined symbols,"
+ echo "*** because either the platform does not support them or"
+ echo "*** it was explicitly requested with -no-undefined,"
+ echo "*** libtool will only create a static version of it."
+ if test "$build_old_libs" = no; then
+ oldlibs="$output_objdir/$libname.$libext"
+ build_libtool_libs=module
+ build_old_libs=yes
+ else
+ build_libtool_libs=no
+ fi
+ fi
+ fi
+ fi
+ # Done checking deplibs!
+ deplibs=$newdeplibs
+ fi
+ # Time to change all our "foo.ltframework" stuff back to "-framework foo"
+ case $host in
+ *-*-darwin*)
+ newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
+ new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
+ deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
+ ;;
+ esac
+
+ # move library search paths that coincide with paths to not yet
+ # installed libraries to the beginning of the library search list
+ new_libs=
+ for path in $notinst_path; do
+ case " $new_libs " in
+ *" -L$path/$objdir "*) ;;
+ *)
+ case " $deplibs " in
+ *" -L$path/$objdir "*)
+ func_append new_libs " -L$path/$objdir" ;;
+ esac
+ ;;
+ esac
+ done
+ for deplib in $deplibs; do
+ case $deplib in
+ -L*)
+ case " $new_libs " in
+ *" $deplib "*) ;;
+ *) func_append new_libs " $deplib" ;;
+ esac
+ ;;
+ *) func_append new_libs " $deplib" ;;
+ esac
+ done
+ deplibs="$new_libs"
+
+ # All the library-specific variables (install_libdir is set above).
+ library_names=
+ old_library=
+ dlname=
+
+ # Test again, we may have decided not to build it any more
+ if test "$build_libtool_libs" = yes; then
+ # Remove ${wl} instances when linking with ld.
+ # FIXME: should test the right _cmds variable.
+ case $archive_cmds in
+ *\$LD\ *) wl= ;;
+ esac
+ if test "$hardcode_into_libs" = yes; then
+ # Hardcode the library paths
+ hardcode_libdirs=
+ dep_rpath=
+ rpath="$finalize_rpath"
+ test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
+ for libdir in $rpath; do
+ if test -n "$hardcode_libdir_flag_spec"; then
+ if test -n "$hardcode_libdir_separator"; then
+ func_replace_sysroot "$libdir"
+ libdir=$func_replace_sysroot_result
+ if test -z "$hardcode_libdirs"; then
+ hardcode_libdirs="$libdir"
+ else
+ # Just accumulate the unique libdirs.
+ case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+ *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+ ;;
+ *)
+ func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
+ ;;
+ esac
+ fi
+ else
+ eval flag=\"$hardcode_libdir_flag_spec\"
+ func_append dep_rpath " $flag"
+ fi
+ elif test -n "$runpath_var"; then
+ case "$perm_rpath " in
+ *" $libdir "*) ;;
+ *) func_append perm_rpath " $libdir" ;;
+ esac
+ fi
+ done
+ # Substitute the hardcoded libdirs into the rpath.
+ if test -n "$hardcode_libdir_separator" &&
+ test -n "$hardcode_libdirs"; then
+ libdir="$hardcode_libdirs"
+ eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
+ fi
+ if test -n "$runpath_var" && test -n "$perm_rpath"; then
+ # We should set the runpath_var.
+ rpath=
+ for dir in $perm_rpath; do
+ func_append rpath "$dir:"
+ done
+ eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
+ fi
+ test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
+ fi
+
+ shlibpath="$finalize_shlibpath"
+ test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
+ if test -n "$shlibpath"; then
+ eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
+ fi
+
+ # Get the real and link names of the library.
+ eval shared_ext=\"$shrext_cmds\"
+ eval library_names=\"$library_names_spec\"
+ set dummy $library_names
+ shift
+ realname="$1"
+ shift
+
+ if test -n "$soname_spec"; then
+ eval soname=\"$soname_spec\"
+ else
+ soname="$realname"
+ fi
+ if test -z "$dlname"; then
+ dlname=$soname
+ fi
+
+ lib="$output_objdir/$realname"
+ linknames=
+ for link
+ do
+ func_append linknames " $link"
+ done
+
+ # Use standard objects if they are pic
+ test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
+ test "X$libobjs" = "X " && libobjs=
+
+ delfiles=
+ if test -n "$export_symbols" && test -n "$include_expsyms"; then
+ $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
+ export_symbols="$output_objdir/$libname.uexp"
+ func_append delfiles " $export_symbols"
+ fi
+
+ orig_export_symbols=
+ case $host_os in
+ cygwin* | mingw* | cegcc*)
+ if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
+ # exporting using user supplied symfile
+ if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
+ # and it's NOT already a .def file. Must figure out
+ # which of the given symbols are data symbols and tag
+ # them as such. So, trigger use of export_symbols_cmds.
+ # export_symbols gets reassigned inside the "prepare
+ # the list of exported symbols" if statement, so the
+ # include_expsyms logic still works.
+ orig_export_symbols="$export_symbols"
+ export_symbols=
+ always_export_symbols=yes
+ fi
+ fi
+ ;;
+ esac
+
+ # Prepare the list of exported symbols
+ if test -z "$export_symbols"; then
+ if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
+ func_verbose "generating symbol list for \`$libname.la'"
+ export_symbols="$output_objdir/$libname.exp"
+ $opt_dry_run || $RM $export_symbols
+ cmds=$export_symbols_cmds
+ save_ifs="$IFS"; IFS='~'
+ for cmd1 in $cmds; do
+ IFS="$save_ifs"
+ # Take the normal branch if the nm_file_list_spec branch
+ # doesn't work or if tool conversion is not needed.
+ case $nm_file_list_spec~$to_tool_file_cmd in
+ *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
+ try_normal_branch=yes
+ eval cmd=\"$cmd1\"
+ func_len " $cmd"
+ len=$func_len_result
+ ;;
+ *)
+ try_normal_branch=no
+ ;;
+ esac
+ if test "$try_normal_branch" = yes \
+ && { test "$len" -lt "$max_cmd_len" \
+ || test "$max_cmd_len" -le -1; }
+ then
+ func_show_eval "$cmd" 'exit $?'
+ skipped_export=false
+ elif test -n "$nm_file_list_spec"; then
+ func_basename "$output"
+ output_la=$func_basename_result
+ save_libobjs=$libobjs
+ save_output=$output
+ output=${output_objdir}/${output_la}.nm
+ func_to_tool_file "$output"
+ libobjs=$nm_file_list_spec$func_to_tool_file_result
+ func_append delfiles " $output"
+ func_verbose "creating $NM input file list: $output"
+ for obj in $save_libobjs; do
+ func_to_tool_file "$obj"
+ $ECHO "$func_to_tool_file_result"
+ done > "$output"
+ eval cmd=\"$cmd1\"
+ func_show_eval "$cmd" 'exit $?'
+ output=$save_output
+ libobjs=$save_libobjs
+ skipped_export=false
+ else
+ # The command line is too long to execute in one step.
+ func_verbose "using reloadable object file for export list..."
+ skipped_export=:
+ # Break out early, otherwise skipped_export may be
+ # set to false by a later but shorter cmd.
+ break
+ fi
+ done
+ IFS="$save_ifs"
+ if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
+ func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
+ func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
+ fi
+ fi
+ fi
+
+ if test -n "$export_symbols" && test -n "$include_expsyms"; then
+ tmp_export_symbols="$export_symbols"
+ test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
+ $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
+ fi
+
+ if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
+ # The given exports_symbols file has to be filtered, so filter it.
+ func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
+ # FIXME: $output_objdir/$libname.filter potentially contains lots of
+ # 's' commands which not all seds can handle. GNU sed should be fine
+ # though. Also, the filter scales superlinearly with the number of
+ # global variables. join(1) would be nice here, but unfortunately
+ # isn't a blessed tool.
+ $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
+ func_append delfiles " $export_symbols $output_objdir/$libname.filter"
+ export_symbols=$output_objdir/$libname.def
+ $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
+ fi
+
+ tmp_deplibs=
+ for test_deplib in $deplibs; do
+ case " $convenience " in
+ *" $test_deplib "*) ;;
+ *)
+ func_append tmp_deplibs " $test_deplib"
+ ;;
+ esac
+ done
+ deplibs="$tmp_deplibs"
+
+ if test -n "$convenience"; then
+ if test -n "$whole_archive_flag_spec" &&
+ test "$compiler_needs_object" = yes &&
+ test -z "$libobjs"; then
+ # extract the archives, so we have objects to list.
+ # TODO: could optimize this to just extract one archive.
+ whole_archive_flag_spec=
+ fi
+ if test -n "$whole_archive_flag_spec"; then
+ save_libobjs=$libobjs
+ eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+ test "X$libobjs" = "X " && libobjs=
+ else
+ gentop="$output_objdir/${outputname}x"
+ func_append generated " $gentop"
+
+ func_extract_archives $gentop $convenience
+ func_append libobjs " $func_extract_archives_result"
+ test "X$libobjs" = "X " && libobjs=
+ fi
+ fi
+
+ if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
+ eval flag=\"$thread_safe_flag_spec\"
+ func_append linker_flags " $flag"
+ fi
+
+ # Make a backup of the uninstalled library when relinking
+ if test "$opt_mode" = relink; then
+ $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
+ fi
+
+ # Do each of the archive commands.
+ if test "$module" = yes && test -n "$module_cmds" ; then
+ if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
+ eval test_cmds=\"$module_expsym_cmds\"
+ cmds=$module_expsym_cmds
+ else
+ eval test_cmds=\"$module_cmds\"
+ cmds=$module_cmds
+ fi
+ else
+ if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+ eval test_cmds=\"$archive_expsym_cmds\"
+ cmds=$archive_expsym_cmds
+ else
+ eval test_cmds=\"$archive_cmds\"
+ cmds=$archive_cmds
+ fi
+ fi
+
+ if test "X$skipped_export" != "X:" &&
+ func_len " $test_cmds" &&
+ len=$func_len_result &&
+ test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+ :
+ else
+ # The command line is too long to link in one step, link piecewise
+ # or, if using GNU ld and skipped_export is not :, use a linker
+ # script.
+
+ # Save the value of $output and $libobjs because we want to
+ # use them later. If we have whole_archive_flag_spec, we
+ # want to use save_libobjs as it was before
+ # whole_archive_flag_spec was expanded, because we can't
+ # assume the linker understands whole_archive_flag_spec.
+ # This may have to be revisited, in case too many
+ # convenience libraries get linked in and end up exceeding
+ # the spec.
+ if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
+ save_libobjs=$libobjs
+ fi
+ save_output=$output
+ func_basename "$output"
+ output_la=$func_basename_result
+
+ # Clear the reloadable object creation command queue and
+ # initialize k to one.
+ test_cmds=
+ concat_cmds=
+ objlist=
+ last_robj=
+ k=1
+
+ if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
+ output=${output_objdir}/${output_la}.lnkscript
+ func_verbose "creating GNU ld script: $output"
+ echo 'INPUT (' > $output
+ for obj in $save_libobjs
+ do
+ func_to_tool_file "$obj"
+ $ECHO "$func_to_tool_file_result" >> $output
+ done
+ echo ')' >> $output
+ func_append delfiles " $output"
+ func_to_tool_file "$output"
+ output=$func_to_tool_file_result
+ elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
+ output=${output_objdir}/${output_la}.lnk
+ func_verbose "creating linker input file list: $output"
+ : > $output
+ set x $save_libobjs
+ shift
+ firstobj=
+ if test "$compiler_needs_object" = yes; then
+ firstobj="$1 "
+ shift
+ fi
+ for obj
+ do
+ func_to_tool_file "$obj"
+ $ECHO "$func_to_tool_file_result" >> $output
+ done
+ func_append delfiles " $output"
+ func_to_tool_file "$output"
+ output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
+ else
+ if test -n "$save_libobjs"; then
+ func_verbose "creating reloadable object files..."
+ output=$output_objdir/$output_la-${k}.$objext
+ eval test_cmds=\"$reload_cmds\"
+ func_len " $test_cmds"
+ len0=$func_len_result
+ len=$len0
+
+ # Loop over the list of objects to be linked.
+ for obj in $save_libobjs
+ do
+ func_len " $obj"
+ func_arith $len + $func_len_result
+ len=$func_arith_result
+ if test "X$objlist" = X ||
+ test "$len" -lt "$max_cmd_len"; then
+ func_append objlist " $obj"
+ else
+ # The command $test_cmds is almost too long, add a
+ # command to the queue.
+ if test "$k" -eq 1 ; then
+ # The first file doesn't have a previous command to add.
+ reload_objs=$objlist
+ eval concat_cmds=\"$reload_cmds\"
+ else
+ # All subsequent reloadable object files will link in
+ # the last one created.
+ reload_objs="$objlist $last_robj"
+ eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
+ fi
+ last_robj=$output_objdir/$output_la-${k}.$objext
+ func_arith $k + 1
+ k=$func_arith_result
+ output=$output_objdir/$output_la-${k}.$objext
+ objlist=" $obj"
+ func_len " $last_robj"
+ func_arith $len0 + $func_len_result
+ len=$func_arith_result
+ fi
+ done
+ # Handle the remaining objects by creating one last
+ # reloadable object file. All subsequent reloadable object
+ # files will link in the last one created.
+ test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+ reload_objs="$objlist $last_robj"
+ eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
+ if test -n "$last_robj"; then
+ eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
+ fi
+ func_append delfiles " $output"
+
+ else
+ output=
+ fi
+
+ if ${skipped_export-false}; then
+ func_verbose "generating symbol list for \`$libname.la'"
+ export_symbols="$output_objdir/$libname.exp"
+ $opt_dry_run || $RM $export_symbols
+ libobjs=$output
+ # Append the command to create the export file.
+ test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+ eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
+ if test -n "$last_robj"; then
+ eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
+ fi
+ fi
+
+ test -n "$save_libobjs" &&
+ func_verbose "creating a temporary reloadable object file: $output"
+
+ # Loop through the commands generated above and execute them.
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $concat_cmds; do
+ IFS="$save_ifs"
+ $opt_silent || {
+ func_quote_for_expand "$cmd"
+ eval "func_echo $func_quote_for_expand_result"
+ }
+ $opt_dry_run || eval "$cmd" || {
+ lt_exit=$?
+
+ # Restore the uninstalled library and exit
+ if test "$opt_mode" = relink; then
+ ( cd "$output_objdir" && \
+ $RM "${realname}T" && \
+ $MV "${realname}U" "$realname" )
+ fi
+
+ exit $lt_exit
+ }
+ done
+ IFS="$save_ifs"
+
+ if test -n "$export_symbols_regex" && ${skipped_export-false}; then
+ func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
+ func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
+ fi
+ fi
+
+ if ${skipped_export-false}; then
+ if test -n "$export_symbols" && test -n "$include_expsyms"; then
+ tmp_export_symbols="$export_symbols"
+ test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
+ $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
+ fi
+
+ if test -n "$orig_export_symbols"; then
+ # The given exports_symbols file has to be filtered, so filter it.
+ func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
+ # FIXME: $output_objdir/$libname.filter potentially contains lots of
+ # 's' commands which not all seds can handle. GNU sed should be fine
+ # though. Also, the filter scales superlinearly with the number of
+ # global variables. join(1) would be nice here, but unfortunately
+ # isn't a blessed tool.
+ $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
+ func_append delfiles " $export_symbols $output_objdir/$libname.filter"
+ export_symbols=$output_objdir/$libname.def
+ $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
+ fi
+ fi
+
+ libobjs=$output
+ # Restore the value of output.
+ output=$save_output
+
+ if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
+ eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+ test "X$libobjs" = "X " && libobjs=
+ fi
+ # Expand the library linking commands again to reset the
+ # value of $libobjs for piecewise linking.
+
+ # Do each of the archive commands.
+ if test "$module" = yes && test -n "$module_cmds" ; then
+ if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
+ cmds=$module_expsym_cmds
+ else
+ cmds=$module_cmds
+ fi
+ else
+ if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+ cmds=$archive_expsym_cmds
+ else
+ cmds=$archive_cmds
+ fi
+ fi
+ fi
+
+ if test -n "$delfiles"; then
+ # Append the command to remove temporary files to $cmds.
+ eval cmds=\"\$cmds~\$RM $delfiles\"
+ fi
+
+ # Add any objects from preloaded convenience libraries
+ if test -n "$dlprefiles"; then
+ gentop="$output_objdir/${outputname}x"
+ func_append generated " $gentop"
+
+ func_extract_archives $gentop $dlprefiles
+ func_append libobjs " $func_extract_archives_result"
+ test "X$libobjs" = "X " && libobjs=
+ fi
+
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ eval cmd=\"$cmd\"
+ $opt_silent || {
+ func_quote_for_expand "$cmd"
+ eval "func_echo $func_quote_for_expand_result"
+ }
+ $opt_dry_run || eval "$cmd" || {
+ lt_exit=$?
+
+ # Restore the uninstalled library and exit
+ if test "$opt_mode" = relink; then
+ ( cd "$output_objdir" && \
+ $RM "${realname}T" && \
+ $MV "${realname}U" "$realname" )
+ fi
+
+ exit $lt_exit
+ }
+ done
+ IFS="$save_ifs"
+
+ # Restore the uninstalled library and exit
+ if test "$opt_mode" = relink; then
+ $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
+
+ if test -n "$convenience"; then
+ if test -z "$whole_archive_flag_spec"; then
+ func_show_eval '${RM}r "$gentop"'
+ fi
+ fi
+
+ exit $EXIT_SUCCESS
+ fi
+
+ # Create links to the real library.
+ for linkname in $linknames; do
+ if test "$realname" != "$linkname"; then
+ func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
+ fi
+ done
+
+ # If -module or -export-dynamic was specified, set the dlname.
+ if test "$module" = yes || test "$export_dynamic" = yes; then
+ # On all known operating systems, these are identical.
+ dlname="$soname"
+ fi
+ fi
+ ;;
+
+ obj)
+ if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+ func_warning "\`-dlopen' is ignored for objects"
+ fi
+
+ case " $deplibs" in
+ *\ -l* | *\ -L*)
+ func_warning "\`-l' and \`-L' are ignored for objects" ;;
+ esac
+
+ test -n "$rpath" && \
+ func_warning "\`-rpath' is ignored for objects"
+
+ test -n "$xrpath" && \
+ func_warning "\`-R' is ignored for objects"
+
+ test -n "$vinfo" && \
+ func_warning "\`-version-info' is ignored for objects"
+
+ test -n "$release" && \
+ func_warning "\`-release' is ignored for objects"
+
+ case $output in
+ *.lo)
+ test -n "$objs$old_deplibs" && \
+ func_fatal_error "cannot build library object \`$output' from non-libtool objects"
+
+ libobj=$output
+ func_lo2o "$libobj"
+ obj=$func_lo2o_result
+ ;;
+ *)
+ libobj=
+ obj="$output"
+ ;;
+ esac
+
+ # Delete the old objects.
+ $opt_dry_run || $RM $obj $libobj
+
+ # Objects from convenience libraries. This assumes
+ # single-version convenience libraries. Whenever we create
+ # different ones for PIC/non-PIC, this we'll have to duplicate
+ # the extraction.
+ reload_conv_objs=
+ gentop=
+ # reload_cmds runs $LD directly, so let us get rid of
+ # -Wl from whole_archive_flag_spec and hope we can get by with
+ # turning comma into space..
+ wl=
+
+ if test -n "$convenience"; then
+ if test -n "$whole_archive_flag_spec"; then
+ eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
+ reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
+ else
+ gentop="$output_objdir/${obj}x"
+ func_append generated " $gentop"
+
+ func_extract_archives $gentop $convenience
+ reload_conv_objs="$reload_objs $func_extract_archives_result"
+ fi
+ fi
+
+ # If we're not building shared, we need to use non_pic_objs
+ test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
+
+ # Create the old-style object.
+ reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
+
+ output="$obj"
+ func_execute_cmds "$reload_cmds" 'exit $?'
+
+ # Exit if we aren't doing a library object file.
+ if test -z "$libobj"; then
+ if test -n "$gentop"; then
+ func_show_eval '${RM}r "$gentop"'
+ fi
+
+ exit $EXIT_SUCCESS
+ fi
+
+ if test "$build_libtool_libs" != yes; then
+ if test -n "$gentop"; then
+ func_show_eval '${RM}r "$gentop"'
+ fi
+
+ # Create an invalid libtool object if no PIC, so that we don't
+ # accidentally link it into a program.
+ # $show "echo timestamp > $libobj"
+ # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
+ exit $EXIT_SUCCESS
+ fi
+
+ if test -n "$pic_flag" || test "$pic_mode" != default; then
+ # Only do commands if we really have different PIC objects.
+ reload_objs="$libobjs $reload_conv_objs"
+ output="$libobj"
+ func_execute_cmds "$reload_cmds" 'exit $?'
+ fi
+
+ if test -n "$gentop"; then
+ func_show_eval '${RM}r "$gentop"'
+ fi
+
+ exit $EXIT_SUCCESS
+ ;;
+
+ prog)
+ case $host in
+ *cygwin*) func_stripname '' '.exe' "$output"
+ output=$func_stripname_result.exe;;
+ esac
+ test -n "$vinfo" && \
+ func_warning "\`-version-info' is ignored for programs"
+
+ test -n "$release" && \
+ func_warning "\`-release' is ignored for programs"
+
+ test "$preload" = yes \
+ && test "$dlopen_support" = unknown \
+ && test "$dlopen_self" = unknown \
+ && test "$dlopen_self_static" = unknown && \
+ func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
+
+ case $host in
+ *-*-rhapsody* | *-*-darwin1.[012])
+ # On Rhapsody replace the C library is the System framework
+ compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
+ finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
+ ;;
+ esac
+
+ case $host in
+ *-*-darwin*)
+ # Don't allow lazy linking, it breaks C++ global constructors
+ # But is supposedly fixed on 10.4 or later (yay!).
+ if test "$tagname" = CXX ; then
+ case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
+ 10.[0123])
+ func_append compile_command " ${wl}-bind_at_load"
+ func_append finalize_command " ${wl}-bind_at_load"
+ ;;
+ esac
+ fi
+ # Time to change all our "foo.ltframework" stuff back to "-framework foo"
+ compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
+ finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
+ ;;
+ esac
+
+
+ # move library search paths that coincide with paths to not yet
+ # installed libraries to the beginning of the library search list
+ new_libs=
+ for path in $notinst_path; do
+ case " $new_libs " in
+ *" -L$path/$objdir "*) ;;
+ *)
+ case " $compile_deplibs " in
+ *" -L$path/$objdir "*)
+ func_append new_libs " -L$path/$objdir" ;;
+ esac
+ ;;
+ esac
+ done
+ for deplib in $compile_deplibs; do
+ case $deplib in
+ -L*)
+ case " $new_libs " in
+ *" $deplib "*) ;;
+ *) func_append new_libs " $deplib" ;;
+ esac
+ ;;
+ *) func_append new_libs " $deplib" ;;
+ esac
+ done
+ compile_deplibs="$new_libs"
+
+
+ func_append compile_command " $compile_deplibs"
+ func_append finalize_command " $finalize_deplibs"
+
+ if test -n "$rpath$xrpath"; then
+ # If the user specified any rpath flags, then add them.
+ for libdir in $rpath $xrpath; do
+ # This is the magic to use -rpath.
+ case "$finalize_rpath " in
+ *" $libdir "*) ;;
+ *) func_append finalize_rpath " $libdir" ;;
+ esac
+ done
+ fi
+
+ # Now hardcode the library paths
+ rpath=
+ hardcode_libdirs=
+ for libdir in $compile_rpath $finalize_rpath; do
+ if test -n "$hardcode_libdir_flag_spec"; then
+ if test -n "$hardcode_libdir_separator"; then
+ if test -z "$hardcode_libdirs"; then
+ hardcode_libdirs="$libdir"
+ else
+ # Just accumulate the unique libdirs.
+ case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+ *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+ ;;
+ *)
+ func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
+ ;;
+ esac
+ fi
+ else
+ eval flag=\"$hardcode_libdir_flag_spec\"
+ func_append rpath " $flag"
+ fi
+ elif test -n "$runpath_var"; then
+ case "$perm_rpath " in
+ *" $libdir "*) ;;
+ *) func_append perm_rpath " $libdir" ;;
+ esac
+ fi
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
+ testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
+ case :$dllsearchpath: in
+ *":$libdir:"*) ;;
+ ::) dllsearchpath=$libdir;;
+ *) func_append dllsearchpath ":$libdir";;
+ esac
+ case :$dllsearchpath: in
+ *":$testbindir:"*) ;;
+ ::) dllsearchpath=$testbindir;;
+ *) func_append dllsearchpath ":$testbindir";;
+ esac
+ ;;
+ esac
+ done
+ # Substitute the hardcoded libdirs into the rpath.
+ if test -n "$hardcode_libdir_separator" &&
+ test -n "$hardcode_libdirs"; then
+ libdir="$hardcode_libdirs"
+ eval rpath=\" $hardcode_libdir_flag_spec\"
+ fi
+ compile_rpath="$rpath"
+
+ rpath=
+ hardcode_libdirs=
+ for libdir in $finalize_rpath; do
+ if test -n "$hardcode_libdir_flag_spec"; then
+ if test -n "$hardcode_libdir_separator"; then
+ if test -z "$hardcode_libdirs"; then
+ hardcode_libdirs="$libdir"
+ else
+ # Just accumulate the unique libdirs.
+ case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+ *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+ ;;
+ *)
+ func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
+ ;;
+ esac
+ fi
+ else
+ eval flag=\"$hardcode_libdir_flag_spec\"
+ func_append rpath " $flag"
+ fi
+ elif test -n "$runpath_var"; then
+ case "$finalize_perm_rpath " in
+ *" $libdir "*) ;;
+ *) func_append finalize_perm_rpath " $libdir" ;;
+ esac
+ fi
+ done
+ # Substitute the hardcoded libdirs into the rpath.
+ if test -n "$hardcode_libdir_separator" &&
+ test -n "$hardcode_libdirs"; then
+ libdir="$hardcode_libdirs"
+ eval rpath=\" $hardcode_libdir_flag_spec\"
+ fi
+ finalize_rpath="$rpath"
+
+ if test -n "$libobjs" && test "$build_old_libs" = yes; then
+ # Transform all the library objects into standard objects.
+ compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
+ finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
+ fi
+
+ func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
+
+ # template prelinking step
+ if test -n "$prelink_cmds"; then
+ func_execute_cmds "$prelink_cmds" 'exit $?'
+ fi
+
+ wrappers_required=yes
+ case $host in
+ *cegcc* | *mingw32ce*)
+ # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
+ wrappers_required=no
+ ;;
+ *cygwin* | *mingw* )
+ if test "$build_libtool_libs" != yes; then
+ wrappers_required=no
+ fi
+ ;;
+ *)
+ if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
+ wrappers_required=no
+ fi
+ ;;
+ esac
+ if test "$wrappers_required" = no; then
+ # Replace the output file specification.
+ compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
+ link_command="$compile_command$compile_rpath"
+
+ # We have no uninstalled library dependencies, so finalize right now.
+ exit_status=0
+ func_show_eval "$link_command" 'exit_status=$?'
+
+ if test -n "$postlink_cmds"; then
+ func_to_tool_file "$output"
+ postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
+ func_execute_cmds "$postlink_cmds" 'exit $?'
+ fi
+
+ # Delete the generated files.
+ if test -f "$output_objdir/${outputname}S.${objext}"; then
+ func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
+ fi
+
+ exit $exit_status
+ fi
+
+ if test -n "$compile_shlibpath$finalize_shlibpath"; then
+ compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
+ fi
+ if test -n "$finalize_shlibpath"; then
+ finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
+ fi
+
+ compile_var=
+ finalize_var=
+ if test -n "$runpath_var"; then
+ if test -n "$perm_rpath"; then
+ # We should set the runpath_var.
+ rpath=
+ for dir in $perm_rpath; do
+ func_append rpath "$dir:"
+ done
+ compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
+ fi
+ if test -n "$finalize_perm_rpath"; then
+ # We should set the runpath_var.
+ rpath=
+ for dir in $finalize_perm_rpath; do
+ func_append rpath "$dir:"
+ done
+ finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
+ fi
+ fi
+
+ if test "$no_install" = yes; then
+ # We don't need to create a wrapper script.
+ link_command="$compile_var$compile_command$compile_rpath"
+ # Replace the output file specification.
+ link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
+ # Delete the old output file.
+ $opt_dry_run || $RM $output
+ # Link the executable and exit
+ func_show_eval "$link_command" 'exit $?'
+
+ if test -n "$postlink_cmds"; then
+ func_to_tool_file "$output"
+ postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
+ func_execute_cmds "$postlink_cmds" 'exit $?'
+ fi
+
+ exit $EXIT_SUCCESS
+ fi
+
+ if test "$hardcode_action" = relink; then
+ # Fast installation is not supported
+ link_command="$compile_var$compile_command$compile_rpath"
+ relink_command="$finalize_var$finalize_command$finalize_rpath"
+
+ func_warning "this platform does not like uninstalled shared libraries"
+ func_warning "\`$output' will be relinked during installation"
+ else
+ if test "$fast_install" != no; then
+ link_command="$finalize_var$compile_command$finalize_rpath"
+ if test "$fast_install" = yes; then
+ relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
+ else
+ # fast_install is set to needless
+ relink_command=
+ fi
+ else
+ link_command="$compile_var$compile_command$compile_rpath"
+ relink_command="$finalize_var$finalize_command$finalize_rpath"
+ fi
+ fi
+
+ # Replace the output file specification.
+ link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
+
+ # Delete the old output files.
+ $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
+
+ func_show_eval "$link_command" 'exit $?'
+
+ if test -n "$postlink_cmds"; then
+ func_to_tool_file "$output_objdir/$outputname"
+ postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
+ func_execute_cmds "$postlink_cmds" 'exit $?'
+ fi
+
+ # Now create the wrapper script.
+ func_verbose "creating $output"
+
+ # Quote the relink command for shipping.
+ if test -n "$relink_command"; then
+ # Preserve any variables that may affect compiler behavior
+ for var in $variables_saved_for_relink; do
+ if eval test -z \"\${$var+set}\"; then
+ relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
+ elif eval var_value=\$$var; test -z "$var_value"; then
+ relink_command="$var=; export $var; $relink_command"
+ else
+ func_quote_for_eval "$var_value"
+ relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
+ fi
+ done
+ relink_command="(cd `pwd`; $relink_command)"
+ relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
+ fi
+
+ # Only actually do things if not in dry run mode.
+ $opt_dry_run || {
+ # win32 will think the script is a binary if it has
+ # a .exe suffix, so we strip it off here.
+ case $output in
+ *.exe) func_stripname '' '.exe' "$output"
+ output=$func_stripname_result ;;
+ esac
+ # test for cygwin because mv fails w/o .exe extensions
+ case $host in
+ *cygwin*)
+ exeext=.exe
+ func_stripname '' '.exe' "$outputname"
+ outputname=$func_stripname_result ;;
+ *) exeext= ;;
+ esac
+ case $host in
+ *cygwin* | *mingw* )
+ func_dirname_and_basename "$output" "" "."
+ output_name=$func_basename_result
+ output_path=$func_dirname_result
+ cwrappersource="$output_path/$objdir/lt-$output_name.c"
+ cwrapper="$output_path/$output_name.exe"
+ $RM $cwrappersource $cwrapper
+ trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
+
+ func_emit_cwrapperexe_src > $cwrappersource
+
+ # The wrapper executable is built using the $host compiler,
+ # because it contains $host paths and files. If cross-
+ # compiling, it, like the target executable, must be
+ # executed on the $host or under an emulation environment.
+ $opt_dry_run || {
+ $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
+ $STRIP $cwrapper
+ }
+
+ # Now, create the wrapper script for func_source use:
+ func_ltwrapper_scriptname $cwrapper
+ $RM $func_ltwrapper_scriptname_result
+ trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
+ $opt_dry_run || {
+ # note: this script will not be executed, so do not chmod.
+ if test "x$build" = "x$host" ; then
+ $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
+ else
+ func_emit_wrapper no > $func_ltwrapper_scriptname_result
+ fi
+ }
+ ;;
+ * )
+ $RM $output
+ trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
+
+ func_emit_wrapper no > $output
+ chmod +x $output
+ ;;
+ esac
+ }
+ exit $EXIT_SUCCESS
+ ;;
+ esac
+
+ # See if we need to build an old-fashioned archive.
+ for oldlib in $oldlibs; do
+
+ if test "$build_libtool_libs" = convenience; then
+ oldobjs="$libobjs_save $symfileobj"
+ addlibs="$convenience"
+ build_libtool_libs=no
+ else
+ if test "$build_libtool_libs" = module; then
+ oldobjs="$libobjs_save"
+ build_libtool_libs=no
+ else
+ oldobjs="$old_deplibs $non_pic_objects"
+ if test "$preload" = yes && test -f "$symfileobj"; then
+ func_append oldobjs " $symfileobj"
+ fi
+ fi
+ addlibs="$old_convenience"
+ fi
+
+ if test -n "$addlibs"; then
+ gentop="$output_objdir/${outputname}x"
+ func_append generated " $gentop"
+
+ func_extract_archives $gentop $addlibs
+ func_append oldobjs " $func_extract_archives_result"
+ fi
+
+ # Do each command in the archive commands.
+ if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
+ cmds=$old_archive_from_new_cmds
+ else
+
+ # Add any objects from preloaded convenience libraries
+ if test -n "$dlprefiles"; then
+ gentop="$output_objdir/${outputname}x"
+ func_append generated " $gentop"
+
+ func_extract_archives $gentop $dlprefiles
+ func_append oldobjs " $func_extract_archives_result"
+ fi
+
+ # POSIX demands no paths to be encoded in archives. We have
+ # to avoid creating archives with duplicate basenames if we
+ # might have to extract them afterwards, e.g., when creating a
+ # static archive out of a convenience library, or when linking
+ # the entirety of a libtool archive into another (currently
+ # not supported by libtool).
+ if (for obj in $oldobjs
+ do
+ func_basename "$obj"
+ $ECHO "$func_basename_result"
+ done | sort | sort -uc >/dev/null 2>&1); then
+ :
+ else
+ echo "copying selected object files to avoid basename conflicts..."
+ gentop="$output_objdir/${outputname}x"
+ func_append generated " $gentop"
+ func_mkdir_p "$gentop"
+ save_oldobjs=$oldobjs
+ oldobjs=
+ counter=1
+ for obj in $save_oldobjs
+ do
+ func_basename "$obj"
+ objbase="$func_basename_result"
+ case " $oldobjs " in
+ " ") oldobjs=$obj ;;
+ *[\ /]"$objbase "*)
+ while :; do
+ # Make sure we don't pick an alternate name that also
+ # overlaps.
+ newobj=lt$counter-$objbase
+ func_arith $counter + 1
+ counter=$func_arith_result
+ case " $oldobjs " in
+ *[\ /]"$newobj "*) ;;
+ *) if test ! -f "$gentop/$newobj"; then break; fi ;;
+ esac
+ done
+ func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
+ func_append oldobjs " $gentop/$newobj"
+ ;;
+ *) func_append oldobjs " $obj" ;;
+ esac
+ done
+ fi
+ func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
+ tool_oldlib=$func_to_tool_file_result
+ eval cmds=\"$old_archive_cmds\"
+
+ func_len " $cmds"
+ len=$func_len_result
+ if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+ cmds=$old_archive_cmds
+ elif test -n "$archiver_list_spec"; then
+ func_verbose "using command file archive linking..."
+ for obj in $oldobjs
+ do
+ func_to_tool_file "$obj"
+ $ECHO "$func_to_tool_file_result"
+ done > $output_objdir/$libname.libcmd
+ func_to_tool_file "$output_objdir/$libname.libcmd"
+ oldobjs=" $archiver_list_spec$func_to_tool_file_result"
+ cmds=$old_archive_cmds
+ else
+ # the command line is too long to link in one step, link in parts
+ func_verbose "using piecewise archive linking..."
+ save_RANLIB=$RANLIB
+ RANLIB=:
+ objlist=
+ concat_cmds=
+ save_oldobjs=$oldobjs
+ oldobjs=
+ # Is there a better way of finding the last object in the list?
+ for obj in $save_oldobjs
+ do
+ last_oldobj=$obj
+ done
+ eval test_cmds=\"$old_archive_cmds\"
+ func_len " $test_cmds"
+ len0=$func_len_result
+ len=$len0
+ for obj in $save_oldobjs
+ do
+ func_len " $obj"
+ func_arith $len + $func_len_result
+ len=$func_arith_result
+ func_append objlist " $obj"
+ if test "$len" -lt "$max_cmd_len"; then
+ :
+ else
+ # the above command should be used before it gets too long
+ oldobjs=$objlist
+ if test "$obj" = "$last_oldobj" ; then
+ RANLIB=$save_RANLIB
+ fi
+ test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+ eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
+ objlist=
+ len=$len0
+ fi
+ done
+ RANLIB=$save_RANLIB
+ oldobjs=$objlist
+ if test "X$oldobjs" = "X" ; then
+ eval cmds=\"\$concat_cmds\"
+ else
+ eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
+ fi
+ fi
+ fi
+ func_execute_cmds "$cmds" 'exit $?'
+ done
+
+ test -n "$generated" && \
+ func_show_eval "${RM}r$generated"
+
+ # Now create the libtool archive.
+ case $output in
+ *.la)
+ old_library=
+ test "$build_old_libs" = yes && old_library="$libname.$libext"
+ func_verbose "creating $output"
+
+ # Preserve any variables that may affect compiler behavior
+ for var in $variables_saved_for_relink; do
+ if eval test -z \"\${$var+set}\"; then
+ relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
+ elif eval var_value=\$$var; test -z "$var_value"; then
+ relink_command="$var=; export $var; $relink_command"
+ else
+ func_quote_for_eval "$var_value"
+ relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
+ fi
+ done
+ # Quote the link command for shipping.
+ relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
+ relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
+ if test "$hardcode_automatic" = yes ; then
+ relink_command=
+ fi
+
+ # Only create the output if not a dry run.
+ $opt_dry_run || {
+ for installed in no yes; do
+ if test "$installed" = yes; then
+ if test -z "$install_libdir"; then
+ break
+ fi
+ output="$output_objdir/$outputname"i
+ # Replace all uninstalled libtool libraries with the installed ones
+ newdependency_libs=
+ for deplib in $dependency_libs; do
+ case $deplib in
+ *.la)
+ func_basename "$deplib"
+ name="$func_basename_result"
+ func_resolve_sysroot "$deplib"
+ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
+ test -z "$libdir" && \
+ func_fatal_error "\`$deplib' is not a valid libtool archive"
+ func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
+ ;;
+ -L*)
+ func_stripname -L '' "$deplib"
+ func_replace_sysroot "$func_stripname_result"
+ func_append newdependency_libs " -L$func_replace_sysroot_result"
+ ;;
+ -R*)
+ func_stripname -R '' "$deplib"
+ func_replace_sysroot "$func_stripname_result"
+ func_append newdependency_libs " -R$func_replace_sysroot_result"
+ ;;
+ *) func_append newdependency_libs " $deplib" ;;
+ esac
+ done
+ dependency_libs="$newdependency_libs"
+ newdlfiles=
+
+ for lib in $dlfiles; do
+ case $lib in
+ *.la)
+ func_basename "$lib"
+ name="$func_basename_result"
+ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+ test -z "$libdir" && \
+ func_fatal_error "\`$lib' is not a valid libtool archive"
+ func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
+ ;;
+ *) func_append newdlfiles " $lib" ;;
+ esac
+ done
+ dlfiles="$newdlfiles"
+ newdlprefiles=
+ for lib in $dlprefiles; do
+ case $lib in
+ *.la)
+ # Only pass preopened files to the pseudo-archive (for
+ # eventual linking with the app. that links it) if we
+ # didn't already link the preopened objects directly into
+ # the library:
+ func_basename "$lib"
+ name="$func_basename_result"
+ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+ test -z "$libdir" && \
+ func_fatal_error "\`$lib' is not a valid libtool archive"
+ func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
+ ;;
+ esac
+ done
+ dlprefiles="$newdlprefiles"
+ else
+ newdlfiles=
+ for lib in $dlfiles; do
+ case $lib in
+ [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+ *) abs=`pwd`"/$lib" ;;
+ esac
+ func_append newdlfiles " $abs"
+ done
+ dlfiles="$newdlfiles"
+ newdlprefiles=
+ for lib in $dlprefiles; do
+ case $lib in
+ [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+ *) abs=`pwd`"/$lib" ;;
+ esac
+ func_append newdlprefiles " $abs"
+ done
+ dlprefiles="$newdlprefiles"
+ fi
+ $RM $output
+ # place dlname in correct position for cygwin
+ # In fact, it would be nice if we could use this code for all target
+ # systems that can't hard-code library paths into their executables
+ # and that have no shared library path variable independent of PATH,
+ # but it turns out we can't easily determine that from inspecting
+ # libtool variables, so we have to hard-code the OSs to which it
+ # applies here; at the moment, that means platforms that use the PE
+ # object format with DLL files. See the long comment at the top of
+ # tests/bindir.at for full details.
+ tdlname=$dlname
+ case $host,$output,$installed,$module,$dlname in
+ *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
+ # If a -bindir argument was supplied, place the dll there.
+ if test "x$bindir" != x ;
+ then
+ func_relative_path "$install_libdir" "$bindir"
+ tdlname=$func_relative_path_result$dlname
+ else
+ # Otherwise fall back on heuristic.
+ tdlname=../bin/$dlname
+ fi
+ ;;
+ esac
+ $ECHO > $output "\
+# $outputname - a libtool library file
+# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# The name that we can dlopen(3).
+dlname='$tdlname'
+
+# Names of this library.
+library_names='$library_names'
+
+# The name of the static archive.
+old_library='$old_library'
+
+# Linker flags that can not go in dependency_libs.
+inherited_linker_flags='$new_inherited_linker_flags'
+
+# Libraries that this one depends upon.
+dependency_libs='$dependency_libs'
+
+# Names of additional weak libraries provided by this library
+weak_library_names='$weak_libs'
+
+# Version information for $libname.
+current=$current
+age=$age
+revision=$revision
+
+# Is this an already installed library?
+installed=$installed
+
+# Should we warn about portability when linking against -modules?
+shouldnotlink=$module
+
+# Files to dlopen/dlpreopen
+dlopen='$dlfiles'
+dlpreopen='$dlprefiles'
+
+# Directory that this library needs to be installed in:
+libdir='$install_libdir'"
+ if test "$installed" = no && test "$need_relink" = yes; then
+ $ECHO >> $output "\
+relink_command=\"$relink_command\""
+ fi
+ done
+ }
+
+ # Do a symbolic link so that the libtool archive can be found in
+ # LD_LIBRARY_PATH before the program is installed.
+ func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
+ ;;
+ esac
+ exit $EXIT_SUCCESS
+}
+
+{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
+ func_mode_link ${1+"$@"}
+
+
+# func_mode_uninstall arg...
+func_mode_uninstall ()
+{
+ $opt_debug
+ RM="$nonopt"
+ files=
+ rmforce=
+ exit_status=0
+
+ # This variable tells wrapper scripts just to set variables rather
+ # than running their programs.
+ libtool_install_magic="$magic"
+
+ for arg
+ do
+ case $arg in
+ -f) func_append RM " $arg"; rmforce=yes ;;
+ -*) func_append RM " $arg" ;;
+ *) func_append files " $arg" ;;
+ esac
+ done
+
+ test -z "$RM" && \
+ func_fatal_help "you must specify an RM program"
+
+ rmdirs=
+
+ for file in $files; do
+ func_dirname "$file" "" "."
+ dir="$func_dirname_result"
+ if test "X$dir" = X.; then
+ odir="$objdir"
+ else
+ odir="$dir/$objdir"
+ fi
+ func_basename "$file"
+ name="$func_basename_result"
+ test "$opt_mode" = uninstall && odir="$dir"
+
+ # Remember odir for removal later, being careful to avoid duplicates
+ if test "$opt_mode" = clean; then
+ case " $rmdirs " in
+ *" $odir "*) ;;
+ *) func_append rmdirs " $odir" ;;
+ esac
+ fi
+
+ # Don't error if the file doesn't exist and rm -f was used.
+ if { test -L "$file"; } >/dev/null 2>&1 ||
+ { test -h "$file"; } >/dev/null 2>&1 ||
+ test -f "$file"; then
+ :
+ elif test -d "$file"; then
+ exit_status=1
+ continue
+ elif test "$rmforce" = yes; then
+ continue
+ fi
+
+ rmfiles="$file"
+
+ case $name in
+ *.la)
+ # Possibly a libtool archive, so verify it.
+ if func_lalib_p "$file"; then
+ func_source $dir/$name
+
+ # Delete the libtool libraries and symlinks.
+ for n in $library_names; do
+ func_append rmfiles " $odir/$n"
+ done
+ test -n "$old_library" && func_append rmfiles " $odir/$old_library"
+
+ case "$opt_mode" in
+ clean)
+ case " $library_names " in
+ *" $dlname "*) ;;
+ *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
+ esac
+ test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
+ ;;
+ uninstall)
+ if test -n "$library_names"; then
+ # Do each command in the postuninstall commands.
+ func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
+ fi
+
+ if test -n "$old_library"; then
+ # Do each command in the old_postuninstall commands.
+ func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
+ fi
+ # FIXME: should reinstall the best remaining shared library.
+ ;;
+ esac
+ fi
+ ;;
+
+ *.lo)
+ # Possibly a libtool object, so verify it.
+ if func_lalib_p "$file"; then
+
+ # Read the .lo file
+ func_source $dir/$name
+
+ # Add PIC object to the list of files to remove.
+ if test -n "$pic_object" &&
+ test "$pic_object" != none; then
+ func_append rmfiles " $dir/$pic_object"
+ fi
+
+ # Add non-PIC object to the list of files to remove.
+ if test -n "$non_pic_object" &&
+ test "$non_pic_object" != none; then
+ func_append rmfiles " $dir/$non_pic_object"
+ fi
+ fi
+ ;;
+
+ *)
+ if test "$opt_mode" = clean ; then
+ noexename=$name
+ case $file in
+ *.exe)
+ func_stripname '' '.exe' "$file"
+ file=$func_stripname_result
+ func_stripname '' '.exe' "$name"
+ noexename=$func_stripname_result
+ # $file with .exe has already been added to rmfiles,
+ # add $file without .exe
+ func_append rmfiles " $file"
+ ;;
+ esac
+ # Do a test to see if this is a libtool program.
+ if func_ltwrapper_p "$file"; then
+ if func_ltwrapper_executable_p "$file"; then
+ func_ltwrapper_scriptname "$file"
+ relink_command=
+ func_source $func_ltwrapper_scriptname_result
+ func_append rmfiles " $func_ltwrapper_scriptname_result"
+ else
+ relink_command=
+ func_source $dir/$noexename
+ fi
+
+ # note $name still contains .exe if it was in $file originally
+ # as does the version of $file that was added into $rmfiles
+ func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
+ if test "$fast_install" = yes && test -n "$relink_command"; then
+ func_append rmfiles " $odir/lt-$name"
+ fi
+ if test "X$noexename" != "X$name" ; then
+ func_append rmfiles " $odir/lt-${noexename}.c"
+ fi
+ fi
+ fi
+ ;;
+ esac
+ func_show_eval "$RM $rmfiles" 'exit_status=1'
+ done
+
+ # Try to remove the ${objdir}s in the directories where we deleted files
+ for dir in $rmdirs; do
+ if test -d "$dir"; then
+ func_show_eval "rmdir $dir >/dev/null 2>&1"
+ fi
+ done
+
+ exit $exit_status
+}
+
+{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
+ func_mode_uninstall ${1+"$@"}
+
+test -z "$opt_mode" && {
+ help="$generic_help"
+ func_fatal_help "you must specify a MODE"
+}
+
+test -z "$exec_cmd" && \
+ func_fatal_help "invalid operation mode \`$opt_mode'"
+
+if test -n "$exec_cmd"; then
+ eval exec "$exec_cmd"
+ exit $EXIT_FAILURE
+fi
+
+exit $exit_status
+
+
+# The TAGs below are defined such that we never get into a situation
+# in which we disable both kinds of libraries. Given conflicting
+# choices, we go for a static library, that is the most portable,
+# since we can't tell whether shared libraries were disabled because
+# the user asked for that or because the platform doesn't support
+# them. This is particularly important on AIX, because we don't
+# support having both static and shared libraries enabled at the same
+# time on that platform, so we default to a shared-only configuration.
+# If a disable-shared tag is given, we'll fallback to a static-only
+# configuration. But we'll never go from static-only to shared-only.
+
+# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
+build_libtool_libs=no
+build_old_libs=yes
+# ### END LIBTOOL TAG CONFIG: disable-shared
+
+# ### BEGIN LIBTOOL TAG CONFIG: disable-static
+build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
+# ### END LIBTOOL TAG CONFIG: disable-static
+
+# Local Variables:
+# mode:shell-script
+# sh-indentation:2
+# End:
+# vi:sw=2
+
diff --git a/thirdparty/glog/glog-0.3.4/m4/ac_have_attribute.m4 b/thirdparty/glog/glog-0.3.5/m4/ac_have_attribute.m4
index 19f4021..19f4021 100644
--- a/thirdparty/glog/glog-0.3.4/m4/ac_have_attribute.m4
+++ b/thirdparty/glog/glog-0.3.5/m4/ac_have_attribute.m4
diff --git a/thirdparty/glog/glog-0.3.4/m4/ac_have_builtin_expect.m4 b/thirdparty/glog/glog-0.3.5/m4/ac_have_builtin_expect.m4
index e91b6fd..e91b6fd 100644
--- a/thirdparty/glog/glog-0.3.4/m4/ac_have_builtin_expect.m4
+++ b/thirdparty/glog/glog-0.3.5/m4/ac_have_builtin_expect.m4
diff --git a/thirdparty/glog/glog-0.3.4/m4/ac_have_sync_val_compare_and_swap.m4 b/thirdparty/glog/glog-0.3.5/m4/ac_have_sync_val_compare_and_swap.m4
index 88b027e..88b027e 100644
--- a/thirdparty/glog/glog-0.3.4/m4/ac_have_sync_val_compare_and_swap.m4
+++ b/thirdparty/glog/glog-0.3.5/m4/ac_have_sync_val_compare_and_swap.m4
diff --git a/thirdparty/glog/glog-0.3.4/m4/ac_rwlock.m4 b/thirdparty/glog/glog-0.3.5/m4/ac_rwlock.m4
index 5065bcc..5065bcc 100644
--- a/thirdparty/glog/glog-0.3.4/m4/ac_rwlock.m4
+++ b/thirdparty/glog/glog-0.3.5/m4/ac_rwlock.m4
diff --git a/thirdparty/glog/glog-0.3.4/m4/acx_pthread.m4 b/thirdparty/glog/glog-0.3.5/m4/acx_pthread.m4
index 2cf20de..2cf20de 100644
--- a/thirdparty/glog/glog-0.3.4/m4/acx_pthread.m4
+++ b/thirdparty/glog/glog-0.3.5/m4/acx_pthread.m4
diff --git a/thirdparty/glog/glog-0.3.4/m4/google_namespace.m4 b/thirdparty/glog/glog-0.3.5/m4/google_namespace.m4
index 79e0a6d..79e0a6d 100644
--- a/thirdparty/glog/glog-0.3.4/m4/google_namespace.m4
+++ b/thirdparty/glog/glog-0.3.5/m4/google_namespace.m4
diff --git a/thirdparty/glog/glog-0.3.5/m4/libtool.m4 b/thirdparty/glog/glog-0.3.5/m4/libtool.m4
new file mode 100644
index 0000000..828104c
--- /dev/null
+++ b/thirdparty/glog/glog-0.3.5/m4/libtool.m4
@@ -0,0 +1,8001 @@
+# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
+#
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
+# 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
+# Written by Gordon Matzigkeit, 1996
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+m4_define([_LT_COPYING], [dnl
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
+# 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
+# Written by Gordon Matzigkeit, 1996
+#
+# This file is part of GNU Libtool.
+#
+# GNU Libtool is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# As a special exception to the GNU General Public License,
+# if you distribute this file as part of a program or library that
+# is built using GNU Libtool, you may include this file under the
+# same distribution terms that you use for the rest of that program.
+#
+# GNU Libtool is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Libtool; see the file COPYING. If not, a copy
+# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
+# obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+])
+
+# serial 57 LT_INIT
+
+
+# LT_PREREQ(VERSION)
+# ------------------
+# Complain and exit if this libtool version is less that VERSION.
+m4_defun([LT_PREREQ],
+[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1,
+ [m4_default([$3],
+ [m4_fatal([Libtool version $1 or higher is required],
+ 63)])],
+ [$2])])
+
+
+# _LT_CHECK_BUILDDIR
+# ------------------
+# Complain if the absolute build directory name contains unusual characters
+m4_defun([_LT_CHECK_BUILDDIR],
+[case `pwd` in
+ *\ * | *\ *)
+ AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;;
+esac
+])
+
+
+# LT_INIT([OPTIONS])
+# ------------------
+AC_DEFUN([LT_INIT],
+[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT
+AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
+AC_BEFORE([$0], [LT_LANG])dnl
+AC_BEFORE([$0], [LT_OUTPUT])dnl
+AC_BEFORE([$0], [LTDL_INIT])dnl
+m4_require([_LT_CHECK_BUILDDIR])dnl
+
+dnl Autoconf doesn't catch unexpanded LT_ macros by default:
+m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl
+m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl
+dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4
+dnl unless we require an AC_DEFUNed macro:
+AC_REQUIRE([LTOPTIONS_VERSION])dnl
+AC_REQUIRE([LTSUGAR_VERSION])dnl
+AC_REQUIRE([LTVERSION_VERSION])dnl
+AC_REQUIRE([LTOBSOLETE_VERSION])dnl
+m4_require([_LT_PROG_LTMAIN])dnl
+
+_LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}])
+
+dnl Parse OPTIONS
+_LT_SET_OPTIONS([$0], [$1])
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ltmain"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+AC_SUBST(LIBTOOL)dnl
+
+_LT_SETUP
+
+# Only expand once:
+m4_define([LT_INIT])
+])# LT_INIT
+
+# Old names:
+AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT])
+AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_PROG_LIBTOOL], [])
+dnl AC_DEFUN([AM_PROG_LIBTOOL], [])
+
+
+# _LT_CC_BASENAME(CC)
+# -------------------
+# Calculate cc_basename. Skip known compiler wrappers and cross-prefix.
+m4_defun([_LT_CC_BASENAME],
+[for cc_temp in $1""; do
+ case $cc_temp in
+ compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
+ distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
+ \-*) ;;
+ *) break;;
+ esac
+done
+cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+])
+
+
+# _LT_FILEUTILS_DEFAULTS
+# ----------------------
+# It is okay to use these file commands and assume they have been set
+# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'.
+m4_defun([_LT_FILEUTILS_DEFAULTS],
+[: ${CP="cp -f"}
+: ${MV="mv -f"}
+: ${RM="rm -f"}
+])# _LT_FILEUTILS_DEFAULTS
+
+
+# _LT_SETUP
+# ---------
+m4_defun([_LT_SETUP],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl
+AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl
+
+_LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl
+dnl
+_LT_DECL([], [host_alias], [0], [The host system])dnl
+_LT_DECL([], [host], [0])dnl
+_LT_DECL([], [host_os], [0])dnl
+dnl
+_LT_DECL([], [build_alias], [0], [The build system])dnl
+_LT_DECL([], [build], [0])dnl
+_LT_DECL([], [build_os], [0])dnl
+dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([LT_PATH_LD])dnl
+AC_REQUIRE([LT_PATH_NM])dnl
+dnl
+AC_REQUIRE([AC_PROG_LN_S])dnl
+test -z "$LN_S" && LN_S="ln -s"
+_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl
+dnl
+AC_REQUIRE([LT_CMD_MAX_LEN])dnl
+_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl
+_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl
+dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_CHECK_SHELL_FEATURES])dnl
+m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl
+m4_require([_LT_CMD_RELOAD])dnl
+m4_require([_LT_CHECK_MAGIC_METHOD])dnl
+m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl
+m4_require([_LT_CMD_OLD_ARCHIVE])dnl
+m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
+m4_require([_LT_WITH_SYSROOT])dnl
+
+_LT_CONFIG_LIBTOOL_INIT([
+# See if we are running on zsh, and set the options which allow our
+# commands through without removal of \ escapes INIT.
+if test -n "\${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+fi
+])
+if test -n "${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+fi
+
+_LT_CHECK_OBJDIR
+
+m4_require([_LT_TAG_COMPILER])dnl
+
+case $host_os in
+aix3*)
+ # AIX sometimes has problems with the GCC collect2 program. For some
+ # reason, if we set the COLLECT_NAMES environment variable, the problems
+ # vanish in a puff of smoke.
+ if test "X${COLLECT_NAMES+set}" != Xset; then
+ COLLECT_NAMES=
+ export COLLECT_NAMES
+ fi
+ ;;
+esac
+
+# Global variables:
+ofile=libtool
+can_build_shared=yes
+
+# All known linkers require a `.a' archive for static linking (except MSVC,
+# which needs '.lib').
+libext=a
+
+with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+old_CC="$CC"
+old_CFLAGS="$CFLAGS"
+
+# Set sane defaults for various variables
+test -z "$CC" && CC=cc
+test -z "$LTCC" && LTCC=$CC
+test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
+test -z "$LD" && LD=ld
+test -z "$ac_objext" && ac_objext=o
+
+_LT_CC_BASENAME([$compiler])
+
+# Only perform the check for file, if the check method requires it
+test -z "$MAGIC_CMD" && MAGIC_CMD=file
+case $deplibs_check_method in
+file_magic*)
+ if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+ _LT_PATH_MAGIC
+ fi
+ ;;
+esac
+
+# Use C for the default configuration in the libtool script
+LT_SUPPORTED_TAG([CC])
+_LT_LANG_C_CONFIG
+_LT_LANG_DEFAULT_CONFIG
+_LT_CONFIG_COMMANDS
+])# _LT_SETUP
+
+
+# _LT_PREPARE_SED_QUOTE_VARS
+# --------------------------
+# Define a few sed substitution that help us do robust quoting.
+m4_defun([_LT_PREPARE_SED_QUOTE_VARS],
+[# Backslashify metacharacters that are still active within
+# double-quoted strings.
+sed_quote_subst='s/\([["`$\\]]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\([["`\\]]\)/\\\1/g'
+
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
+# Sed substitution to delay expansion of an escaped single quote.
+delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
+
+# Sed substitution to avoid accidental globbing in evaled expressions
+no_glob_subst='s/\*/\\\*/g'
+])
+
+# _LT_PROG_LTMAIN
+# ---------------
+# Note that this code is called both from `configure', and `config.status'
+# now that we use AC_CONFIG_COMMANDS to generate libtool. Notably,
+# `config.status' has no value for ac_aux_dir unless we are using Automake,
+# so we pass a copy along to make sure it has a sensible value anyway.
+m4_defun([_LT_PROG_LTMAIN],
+[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl
+_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir'])
+ltmain="$ac_aux_dir/ltmain.sh"
+])# _LT_PROG_LTMAIN
+
+
+## ------------------------------------- ##
+## Accumulate code for creating libtool. ##
+## ------------------------------------- ##
+
+# So that we can recreate a full libtool script including additional
+# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS
+# in macros and then make a single call at the end using the `libtool'
+# label.
+
+
+# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS])
+# ----------------------------------------
+# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later.
+m4_define([_LT_CONFIG_LIBTOOL_INIT],
+[m4_ifval([$1],
+ [m4_append([_LT_OUTPUT_LIBTOOL_INIT],
+ [$1
+])])])
+
+# Initialize.
+m4_define([_LT_OUTPUT_LIBTOOL_INIT])
+
+
+# _LT_CONFIG_LIBTOOL([COMMANDS])
+# ------------------------------
+# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later.
+m4_define([_LT_CONFIG_LIBTOOL],
+[m4_ifval([$1],
+ [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS],
+ [$1
+])])])
+
+# Initialize.
+m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS])
+
+
+# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS])
+# -----------------------------------------------------
+m4_defun([_LT_CONFIG_SAVE_COMMANDS],
+[_LT_CONFIG_LIBTOOL([$1])
+_LT_CONFIG_LIBTOOL_INIT([$2])
+])
+
+
+# _LT_FORMAT_COMMENT([COMMENT])
+# -----------------------------
+# Add leading comment marks to the start of each line, and a trailing
+# full-stop to the whole comment if one is not present already.
+m4_define([_LT_FORMAT_COMMENT],
+[m4_ifval([$1], [
+m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])],
+ [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.])
+)])
+
+
+
+## ------------------------ ##
+## FIXME: Eliminate VARNAME ##
+## ------------------------ ##
+
+
+# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?])
+# -------------------------------------------------------------------
+# CONFIGNAME is the name given to the value in the libtool script.
+# VARNAME is the (base) name used in the configure script.
+# VALUE may be 0, 1 or 2 for a computed quote escaped value based on
+# VARNAME. Any other value will be used directly.
+m4_define([_LT_DECL],
+[lt_if_append_uniq([lt_decl_varnames], [$2], [, ],
+ [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name],
+ [m4_ifval([$1], [$1], [$2])])
+ lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3])
+ m4_ifval([$4],
+ [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])])
+ lt_dict_add_subkey([lt_decl_dict], [$2],
+ [tagged?], [m4_ifval([$5], [yes], [no])])])
+])
+
+
+# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION])
+# --------------------------------------------------------
+m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])])
+
+
+# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...])
+# ------------------------------------------------
+m4_define([lt_decl_tag_varnames],
+[_lt_decl_filter([tagged?], [yes], $@)])
+
+
+# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..])
+# ---------------------------------------------------------
+m4_define([_lt_decl_filter],
+[m4_case([$#],
+ [0], [m4_fatal([$0: too few arguments: $#])],
+ [1], [m4_fatal([$0: too few arguments: $#: $1])],
+ [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)],
+ [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)],
+ [lt_dict_filter([lt_decl_dict], $@)])[]dnl
+])
+
+
+# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...])
+# --------------------------------------------------
+m4_define([lt_decl_quote_varnames],
+[_lt_decl_filter([value], [1], $@)])
+
+
+# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...])
+# ---------------------------------------------------
+m4_define([lt_decl_dquote_varnames],
+[_lt_decl_filter([value], [2], $@)])
+
+
+# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...])
+# ---------------------------------------------------
+m4_define([lt_decl_varnames_tagged],
+[m4_assert([$# <= 2])dnl
+_$0(m4_quote(m4_default([$1], [[, ]])),
+ m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]),
+ m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))])
+m4_define([_lt_decl_varnames_tagged],
+[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])])
+
+
+# lt_decl_all_varnames([SEPARATOR], [VARNAME1...])
+# ------------------------------------------------
+m4_define([lt_decl_all_varnames],
+[_$0(m4_quote(m4_default([$1], [[, ]])),
+ m4_if([$2], [],
+ m4_quote(lt_decl_varnames),
+ m4_quote(m4_shift($@))))[]dnl
+])
+m4_define([_lt_decl_all_varnames],
+[lt_join($@, lt_decl_varnames_tagged([$1],
+ lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl
+])
+
+
+# _LT_CONFIG_STATUS_DECLARE([VARNAME])
+# ------------------------------------
+# Quote a variable value, and forward it to `config.status' so that its
+# declaration there will have the same value as in `configure'. VARNAME
+# must have a single quote delimited value for this to work.
+m4_define([_LT_CONFIG_STATUS_DECLARE],
+[$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`'])
+
+
+# _LT_CONFIG_STATUS_DECLARATIONS
+# ------------------------------
+# We delimit libtool config variables with single quotes, so when
+# we write them to config.status, we have to be sure to quote all
+# embedded single quotes properly. In configure, this macro expands
+# each variable declared with _LT_DECL (and _LT_TAGDECL) into:
+#
+# <var>='`$ECHO "$<var>" | $SED "$delay_single_quote_subst"`'
+m4_defun([_LT_CONFIG_STATUS_DECLARATIONS],
+[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames),
+ [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])])
+
+
+# _LT_LIBTOOL_TAGS
+# ----------------
+# Output comment and list of tags supported by the script
+m4_defun([_LT_LIBTOOL_TAGS],
+[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl
+available_tags="_LT_TAGS"dnl
+])
+
+
+# _LT_LIBTOOL_DECLARE(VARNAME, [TAG])
+# -----------------------------------
+# Extract the dictionary values for VARNAME (optionally with TAG) and
+# expand to a commented shell variable setting:
+#
+# # Some comment about what VAR is for.
+# visible_name=$lt_internal_name
+m4_define([_LT_LIBTOOL_DECLARE],
+[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1],
+ [description])))[]dnl
+m4_pushdef([_libtool_name],
+ m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl
+m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])),
+ [0], [_libtool_name=[$]$1],
+ [1], [_libtool_name=$lt_[]$1],
+ [2], [_libtool_name=$lt_[]$1],
+ [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl
+m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl
+])
+
+
+# _LT_LIBTOOL_CONFIG_VARS
+# -----------------------
+# Produce commented declarations of non-tagged libtool config variables
+# suitable for insertion in the LIBTOOL CONFIG section of the `libtool'
+# script. Tagged libtool config variables (even for the LIBTOOL CONFIG
+# section) are produced by _LT_LIBTOOL_TAG_VARS.
+m4_defun([_LT_LIBTOOL_CONFIG_VARS],
+[m4_foreach([_lt_var],
+ m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)),
+ [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])])
+
+
+# _LT_LIBTOOL_TAG_VARS(TAG)
+# -------------------------
+m4_define([_LT_LIBTOOL_TAG_VARS],
+[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames),
+ [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])])
+
+
+# _LT_TAGVAR(VARNAME, [TAGNAME])
+# ------------------------------
+m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])])
+
+
+# _LT_CONFIG_COMMANDS
+# -------------------
+# Send accumulated output to $CONFIG_STATUS. Thanks to the lists of
+# variables for single and double quote escaping we saved from calls
+# to _LT_DECL, we can put quote escaped variables declarations
+# into `config.status', and then the shell code to quote escape them in
+# for loops in `config.status'. Finally, any additional code accumulated
+# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded.
+m4_defun([_LT_CONFIG_COMMANDS],
+[AC_PROVIDE_IFELSE([LT_OUTPUT],
+ dnl If the libtool generation code has been placed in $CONFIG_LT,
+ dnl instead of duplicating it all over again into config.status,
+ dnl then we will have config.status run $CONFIG_LT later, so it
+ dnl needs to know what name is stored there:
+ [AC_CONFIG_COMMANDS([libtool],
+ [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])],
+ dnl If the libtool generation code is destined for config.status,
+ dnl expand the accumulated commands and init code now:
+ [AC_CONFIG_COMMANDS([libtool],
+ [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])])
+])#_LT_CONFIG_COMMANDS
+
+
+# Initialize.
+m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT],
+[
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+sed_quote_subst='$sed_quote_subst'
+double_quote_subst='$double_quote_subst'
+delay_variable_subst='$delay_variable_subst'
+_LT_CONFIG_STATUS_DECLARATIONS
+LTCC='$LTCC'
+LTCFLAGS='$LTCFLAGS'
+compiler='$compiler_DEFAULT'
+
+# A function that is used when there is no print builtin or printf.
+func_fallback_echo ()
+{
+ eval 'cat <<_LTECHO_EOF
+\$[]1
+_LTECHO_EOF'
+}
+
+# Quote evaled strings.
+for var in lt_decl_all_varnames([[ \
+]], lt_decl_quote_varnames); do
+ case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
+ *[[\\\\\\\`\\"\\\$]]*)
+ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+ ;;
+ *)
+ eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+ ;;
+ esac
+done
+
+# Double-quote double-evaled strings.
+for var in lt_decl_all_varnames([[ \
+]], lt_decl_dquote_varnames); do
+ case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
+ *[[\\\\\\\`\\"\\\$]]*)
+ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+ ;;
+ *)
+ eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+ ;;
+ esac
+done
+
+_LT_OUTPUT_LIBTOOL_INIT
+])
+
+# _LT_GENERATED_FILE_INIT(FILE, [COMMENT])
+# ------------------------------------
+# Generate a child script FILE with all initialization necessary to
+# reuse the environment learned by the parent script, and make the
+# file executable. If COMMENT is supplied, it is inserted after the
+# `#!' sequence but before initialization text begins. After this
+# macro, additional text can be appended to FILE to form the body of
+# the child script. The macro ends with non-zero status if the
+# file could not be fully written (such as if the disk is full).
+m4_ifdef([AS_INIT_GENERATED],
+[m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])],
+[m4_defun([_LT_GENERATED_FILE_INIT],
+[m4_require([AS_PREPARE])]dnl
+[m4_pushdef([AS_MESSAGE_LOG_FD])]dnl
+[lt_write_fail=0
+cat >$1 <<_ASEOF || lt_write_fail=1
+#! $SHELL
+# Generated by $as_me.
+$2
+SHELL=\${CONFIG_SHELL-$SHELL}
+export SHELL
+_ASEOF
+cat >>$1 <<\_ASEOF || lt_write_fail=1
+AS_SHELL_SANITIZE
+_AS_PREPARE
+exec AS_MESSAGE_FD>&1
+_ASEOF
+test $lt_write_fail = 0 && chmod +x $1[]dnl
+m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT
+
+# LT_OUTPUT
+# ---------
+# This macro allows early generation of the libtool script (before
+# AC_OUTPUT is called), incase it is used in configure for compilation
+# tests.
+AC_DEFUN([LT_OUTPUT],
+[: ${CONFIG_LT=./config.lt}
+AC_MSG_NOTICE([creating $CONFIG_LT])
+_LT_GENERATED_FILE_INIT(["$CONFIG_LT"],
+[# Run this file to recreate a libtool stub with the current configuration.])
+
+cat >>"$CONFIG_LT" <<\_LTEOF
+lt_cl_silent=false
+exec AS_MESSAGE_LOG_FD>>config.log
+{
+ echo
+ AS_BOX([Running $as_me.])
+} >&AS_MESSAGE_LOG_FD
+
+lt_cl_help="\
+\`$as_me' creates a local libtool stub from the current configuration,
+for use in further configure time tests before the real libtool is
+generated.
+
+Usage: $[0] [[OPTIONS]]
+
+ -h, --help print this help, then exit
+ -V, --version print version number, then exit
+ -q, --quiet do not print progress messages
+ -d, --debug don't remove temporary files
+
+Report bugs to <bug-libtool@gnu.org>."
+
+lt_cl_version="\
+m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl
+m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION])
+configured by $[0], generated by m4_PACKAGE_STRING.
+
+Copyright (C) 2011 Free Software Foundation, Inc.
+This config.lt script is free software; the Free Software Foundation
+gives unlimited permision to copy, distribute and modify it."
+
+while test $[#] != 0
+do
+ case $[1] in
+ --version | --v* | -V )
+ echo "$lt_cl_version"; exit 0 ;;
+ --help | --h* | -h )
+ echo "$lt_cl_help"; exit 0 ;;
+ --debug | --d* | -d )
+ debug=: ;;
+ --quiet | --q* | --silent | --s* | -q )
+ lt_cl_silent=: ;;
+
+ -*) AC_MSG_ERROR([unrecognized option: $[1]
+Try \`$[0] --help' for more information.]) ;;
+
+ *) AC_MSG_ERROR([unrecognized argument: $[1]
+Try \`$[0] --help' for more information.]) ;;
+ esac
+ shift
+done
+
+if $lt_cl_silent; then
+ exec AS_MESSAGE_FD>/dev/null
+fi
+_LTEOF
+
+cat >>"$CONFIG_LT" <<_LTEOF
+_LT_OUTPUT_LIBTOOL_COMMANDS_INIT
+_LTEOF
+
+cat >>"$CONFIG_LT" <<\_LTEOF
+AC_MSG_NOTICE([creating $ofile])
+_LT_OUTPUT_LIBTOOL_COMMANDS
+AS_EXIT(0)
+_LTEOF
+chmod +x "$CONFIG_LT"
+
+# configure is writing to config.log, but config.lt does its own redirection,
+# appending to config.log, which fails on DOS, as config.log is still kept
+# open by configure. Here we exec the FD to /dev/null, effectively closing
+# config.log, so it can be properly (re)opened and appended to by config.lt.
+lt_cl_success=:
+test "$silent" = yes &&
+ lt_config_lt_args="$lt_config_lt_args --quiet"
+exec AS_MESSAGE_LOG_FD>/dev/null
+$SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false
+exec AS_MESSAGE_LOG_FD>>config.log
+$lt_cl_success || AS_EXIT(1)
+])# LT_OUTPUT
+
+
+# _LT_CONFIG(TAG)
+# ---------------
+# If TAG is the built-in tag, create an initial libtool script with a
+# default configuration from the untagged config vars. Otherwise add code
+# to config.status for appending the configuration named by TAG from the
+# matching tagged config vars.
+m4_defun([_LT_CONFIG],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+_LT_CONFIG_SAVE_COMMANDS([
+ m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl
+ m4_if(_LT_TAG, [C], [
+ # See if we are running on zsh, and set the options which allow our
+ # commands through without removal of \ escapes.
+ if test -n "${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+ fi
+
+ cfgfile="${ofile}T"
+ trap "$RM \"$cfgfile\"; exit 1" 1 2 15
+ $RM "$cfgfile"
+
+ cat <<_LT_EOF >> "$cfgfile"
+#! $SHELL
+
+# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+# NOTE: Changes made to this file will be lost: look at ltmain.sh.
+#
+_LT_COPYING
+_LT_LIBTOOL_TAGS
+
+# ### BEGIN LIBTOOL CONFIG
+_LT_LIBTOOL_CONFIG_VARS
+_LT_LIBTOOL_TAG_VARS
+# ### END LIBTOOL CONFIG
+
+_LT_EOF
+
+ case $host_os in
+ aix3*)
+ cat <<\_LT_EOF >> "$cfgfile"
+# AIX sometimes has problems with the GCC collect2 program. For some
+# reason, if we set the COLLECT_NAMES environment variable, the problems
+# vanish in a puff of smoke.
+if test "X${COLLECT_NAMES+set}" != Xset; then
+ COLLECT_NAMES=
+ export COLLECT_NAMES
+fi
+_LT_EOF
+ ;;
+ esac
+
+ _LT_PROG_LTMAIN
+
+ # We use sed instead of cat because bash on DJGPP gets confused if
+ # if finds mixed CR/LF and LF-only lines. Since sed operates in
+ # text mode, it properly converts lines to CR/LF. This bash problem
+ # is reportedly fixed, but why not run on old versions too?
+ sed '$q' "$ltmain" >> "$cfgfile" \
+ || (rm -f "$cfgfile"; exit 1)
+
+ _LT_PROG_REPLACE_SHELLFNS
+
+ mv -f "$cfgfile" "$ofile" ||
+ (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
+ chmod +x "$ofile"
+],
+[cat <<_LT_EOF >> "$ofile"
+
+dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded
+dnl in a comment (ie after a #).
+# ### BEGIN LIBTOOL TAG CONFIG: $1
+_LT_LIBTOOL_TAG_VARS(_LT_TAG)
+# ### END LIBTOOL TAG CONFIG: $1
+_LT_EOF
+])dnl /m4_if
+],
+[m4_if([$1], [], [
+ PACKAGE='$PACKAGE'
+ VERSION='$VERSION'
+ TIMESTAMP='$TIMESTAMP'
+ RM='$RM'
+ ofile='$ofile'], [])
+])dnl /_LT_CONFIG_SAVE_COMMANDS
+])# _LT_CONFIG
+
+
+# LT_SUPPORTED_TAG(TAG)
+# ---------------------
+# Trace this macro to discover what tags are supported by the libtool
+# --tag option, using:
+# autoconf --trace 'LT_SUPPORTED_TAG:$1'
+AC_DEFUN([LT_SUPPORTED_TAG], [])
+
+
+# C support is built-in for now
+m4_define([_LT_LANG_C_enabled], [])
+m4_define([_LT_TAGS], [])
+
+
+# LT_LANG(LANG)
+# -------------
+# Enable libtool support for the given language if not already enabled.
+AC_DEFUN([LT_LANG],
+[AC_BEFORE([$0], [LT_OUTPUT])dnl
+m4_case([$1],
+ [C], [_LT_LANG(C)],
+ [C++], [_LT_LANG(CXX)],
+ [Go], [_LT_LANG(GO)],
+ [Java], [_LT_LANG(GCJ)],
+ [Fortran 77], [_LT_LANG(F77)],
+ [Fortran], [_LT_LANG(FC)],
+ [Windows Resource], [_LT_LANG(RC)],
+ [m4_ifdef([_LT_LANG_]$1[_CONFIG],
+ [_LT_LANG($1)],
+ [m4_fatal([$0: unsupported language: "$1"])])])dnl
+])# LT_LANG
+
+
+# _LT_LANG(LANGNAME)
+# ------------------
+m4_defun([_LT_LANG],
+[m4_ifdef([_LT_LANG_]$1[_enabled], [],
+ [LT_SUPPORTED_TAG([$1])dnl
+ m4_append([_LT_TAGS], [$1 ])dnl
+ m4_define([_LT_LANG_]$1[_enabled], [])dnl
+ _LT_LANG_$1_CONFIG($1)])dnl
+])# _LT_LANG
+
+
+m4_ifndef([AC_PROG_GO], [
+############################################################
+# NOTE: This macro has been submitted for inclusion into #
+# GNU Autoconf as AC_PROG_GO. When it is available in #
+# a released version of Autoconf we should remove this #
+# macro and use it instead. #
+############################################################
+m4_defun([AC_PROG_GO],
+[AC_LANG_PUSH(Go)dnl
+AC_ARG_VAR([GOC], [Go compiler command])dnl
+AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl
+_AC_ARG_VAR_LDFLAGS()dnl
+AC_CHECK_TOOL(GOC, gccgo)
+if test -z "$GOC"; then
+ if test -n "$ac_tool_prefix"; then
+ AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo])
+ fi
+fi
+if test -z "$GOC"; then
+ AC_CHECK_PROG(GOC, gccgo, gccgo, false)
+fi
+])#m4_defun
+])#m4_ifndef
+
+
+# _LT_LANG_DEFAULT_CONFIG
+# -----------------------
+m4_defun([_LT_LANG_DEFAULT_CONFIG],
+[AC_PROVIDE_IFELSE([AC_PROG_CXX],
+ [LT_LANG(CXX)],
+ [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])])
+
+AC_PROVIDE_IFELSE([AC_PROG_F77],
+ [LT_LANG(F77)],
+ [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])])
+
+AC_PROVIDE_IFELSE([AC_PROG_FC],
+ [LT_LANG(FC)],
+ [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])])
+
+dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal
+dnl pulling things in needlessly.
+AC_PROVIDE_IFELSE([AC_PROG_GCJ],
+ [LT_LANG(GCJ)],
+ [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
+ [LT_LANG(GCJ)],
+ [AC_PROVIDE_IFELSE([LT_PROG_GCJ],
+ [LT_LANG(GCJ)],
+ [m4_ifdef([AC_PROG_GCJ],
+ [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])])
+ m4_ifdef([A][M_PROG_GCJ],
+ [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])])
+ m4_ifdef([LT_PROG_GCJ],
+ [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])])
+
+AC_PROVIDE_IFELSE([AC_PROG_GO],
+ [LT_LANG(GO)],
+ [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])])
+
+AC_PROVIDE_IFELSE([LT_PROG_RC],
+ [LT_LANG(RC)],
+ [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])])
+])# _LT_LANG_DEFAULT_CONFIG
+
+# Obsolete macros:
+AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)])
+AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)])
+AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)])
+AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)])
+AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_CXX], [])
+dnl AC_DEFUN([AC_LIBTOOL_F77], [])
+dnl AC_DEFUN([AC_LIBTOOL_FC], [])
+dnl AC_DEFUN([AC_LIBTOOL_GCJ], [])
+dnl AC_DEFUN([AC_LIBTOOL_RC], [])
+
+
+# _LT_TAG_COMPILER
+# ----------------
+m4_defun([_LT_TAG_COMPILER],
+[AC_REQUIRE([AC_PROG_CC])dnl
+
+_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl
+_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl
+_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl
+_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+])# _LT_TAG_COMPILER
+
+
+# _LT_COMPILER_BOILERPLATE
+# ------------------------
+# Check for compiler boilerplate output or warnings with
+# the simple compiler test code.
+m4_defun([_LT_COMPILER_BOILERPLATE],
+[m4_require([_LT_DECL_SED])dnl
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$RM conftest*
+])# _LT_COMPILER_BOILERPLATE
+
+
+# _LT_LINKER_BOILERPLATE
+# ----------------------
+# Check for linker boilerplate output or warnings with
+# the simple link test code.
+m4_defun([_LT_LINKER_BOILERPLATE],
+[m4_require([_LT_DECL_SED])dnl
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$RM -r conftest*
+])# _LT_LINKER_BOILERPLATE
+
+# _LT_REQUIRED_DARWIN_CHECKS
+# -------------------------
+m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
+ case $host_os in
+ rhapsody* | darwin*)
+ AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:])
+ AC_CHECK_TOOL([NMEDIT], [nmedit], [:])
+ AC_CHECK_TOOL([LIPO], [lipo], [:])
+ AC_CHECK_TOOL([OTOOL], [otool], [:])
+ AC_CHECK_TOOL([OTOOL64], [otool64], [:])
+ _LT_DECL([], [DSYMUTIL], [1],
+ [Tool to manipulate archived DWARF debug symbol files on Mac OS X])
+ _LT_DECL([], [NMEDIT], [1],
+ [Tool to change global to local symbols on Mac OS X])
+ _LT_DECL([], [LIPO], [1],
+ [Tool to manipulate fat objects and archives on Mac OS X])
+ _LT_DECL([], [OTOOL], [1],
+ [ldd/readelf like tool for Mach-O binaries on Mac OS X])
+ _LT_DECL([], [OTOOL64], [1],
+ [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4])
+
+ AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],
+ [lt_cv_apple_cc_single_mod=no
+ if test -z "${LT_MULTI_MODULE}"; then
+ # By default we will add the -single_module flag. You can override
+ # by either setting the environment variable LT_MULTI_MODULE
+ # non-empty at configure time, or by adding -multi_module to the
+ # link flags.
+ rm -rf libconftest.dylib*
+ echo "int foo(void){return 1;}" > conftest.c
+ echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+-dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD
+ $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
+ _lt_result=$?
+ # If there is a non-empty error log, and "single_module"
+ # appears in it, assume the flag caused a linker warning
+ if test -s conftest.err && $GREP single_module conftest.err; then
+ cat conftest.err >&AS_MESSAGE_LOG_FD
+ # Otherwise, if the output was created with a 0 exit code from
+ # the compiler, it worked.
+ elif test -f libconftest.dylib && test $_lt_result -eq 0; then
+ lt_cv_apple_cc_single_mod=yes
+ else
+ cat conftest.err >&AS_MESSAGE_LOG_FD
+ fi
+ rm -rf libconftest.dylib*
+ rm -f conftest.*
+ fi])
+
+ AC_CACHE_CHECK([for -exported_symbols_list linker flag],
+ [lt_cv_ld_exported_symbols_list],
+ [lt_cv_ld_exported_symbols_list=no
+ save_LDFLAGS=$LDFLAGS
+ echo "_main" > conftest.sym
+ LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
+ [lt_cv_ld_exported_symbols_list=yes],
+ [lt_cv_ld_exported_symbols_list=no])
+ LDFLAGS="$save_LDFLAGS"
+ ])
+
+ AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load],
+ [lt_cv_ld_force_load=no
+ cat > conftest.c << _LT_EOF
+int forced_loaded() { return 2;}
+_LT_EOF
+ echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD
+ $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD
+ echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD
+ $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD
+ echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD
+ $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD
+ cat > conftest.c << _LT_EOF
+int main() { return 0;}
+_LT_EOF
+ echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD
+ $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err
+ _lt_result=$?
+ if test -s conftest.err && $GREP force_load conftest.err; then
+ cat conftest.err >&AS_MESSAGE_LOG_FD
+ elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then
+ lt_cv_ld_force_load=yes
+ else
+ cat conftest.err >&AS_MESSAGE_LOG_FD
+ fi
+ rm -f conftest.err libconftest.a conftest conftest.c
+ rm -rf conftest.dSYM
+ ])
+ case $host_os in
+ rhapsody* | darwin1.[[012]])
+ _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+ darwin1.*)
+ _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+ darwin*) # darwin 5.x on
+ # if running on 10.5 or later, the deployment target defaults
+ # to the OS version, if on x86, and 10.4, the deployment
+ # target defaults to 10.4. Don't you love it?
+ case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
+ 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
+ _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+ 10.[[012]]*)
+ _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+ 10.*)
+ _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+ esac
+ ;;
+ esac
+ if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+ _lt_dar_single_mod='$single_module'
+ fi
+ if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
+ _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+ else
+ _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ fi
+ if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then
+ _lt_dsymutil='~$DSYMUTIL $lib || :'
+ else
+ _lt_dsymutil=
+ fi
+ ;;
+ esac
+])
+
+
+# _LT_DARWIN_LINKER_FEATURES([TAG])
+# ---------------------------------
+# Checks for linker and compiler features on darwin
+m4_defun([_LT_DARWIN_LINKER_FEATURES],
+[
+ m4_require([_LT_REQUIRED_DARWIN_CHECKS])
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_automatic, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+ if test "$lt_cv_ld_force_load" = "yes"; then
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
+ m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes],
+ [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes])
+ else
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=''
+ fi
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
+ case $cc_basename in
+ ifort*) _lt_dar_can_shared=yes ;;
+ *) _lt_dar_can_shared=$GCC ;;
+ esac
+ if test "$_lt_dar_can_shared" = "yes"; then
+ output_verbose_link_cmd=func_echo_all
+ _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+ _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+ _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+ _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+ m4_if([$1], [CXX],
+[ if test "$lt_cv_apple_cc_single_mod" != "yes"; then
+ _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
+ _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
+ fi
+],[])
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+])
+
+# _LT_SYS_MODULE_PATH_AIX([TAGNAME])
+# ----------------------------------
+# Links a minimal program and checks the executable
+# for the system default hardcoded library path. In most cases,
+# this is /usr/lib:/lib, but when the MPI compilers are used
+# the location of the communication and MPI libs are included too.
+# If we don't find anything, use the default library path according
+# to the aix ld manual.
+# Store the results from the different compilers for each TAGNAME.
+# Allow to override them for all tags through lt_cv_aix_libpath.
+m4_defun([_LT_SYS_MODULE_PATH_AIX],
+[m4_require([_LT_DECL_SED])dnl
+if test "${lt_cv_aix_libpath+set}" = set; then
+ aix_libpath=$lt_cv_aix_libpath
+else
+ AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])],
+ [AC_LINK_IFELSE([AC_LANG_PROGRAM],[
+ lt_aix_libpath_sed='[
+ /Import File Strings/,/^$/ {
+ /^0/ {
+ s/^0 *\([^ ]*\) *$/\1/
+ p
+ }
+ }]'
+ _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+ # Check for a 64-bit object if we didn't find anything.
+ if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then
+ _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+ fi],[])
+ if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then
+ _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib"
+ fi
+ ])
+ aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])
+fi
+])# _LT_SYS_MODULE_PATH_AIX
+
+
+# _LT_SHELL_INIT(ARG)
+# -------------------
+m4_define([_LT_SHELL_INIT],
+[m4_divert_text([M4SH-INIT], [$1
+])])# _LT_SHELL_INIT
+
+
+
+# _LT_PROG_ECHO_BACKSLASH
+# -----------------------
+# Find how we can fake an echo command that does not interpret backslash.
+# In particular, with Autoconf 2.60 or later we add some code to the start
+# of the generated configure script which will find a shell with a builtin
+# printf (which we can use as an echo command).
+m4_defun([_LT_PROG_ECHO_BACKSLASH],
+[ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
+ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
+
+AC_MSG_CHECKING([how to print strings])
+# Test print first, because it will be a builtin if present.
+if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \
+ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then
+ ECHO='print -r --'
+elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then
+ ECHO='printf %s\n'
+else
+ # Use this function as a fallback that always works.
+ func_fallback_echo ()
+ {
+ eval 'cat <<_LTECHO_EOF
+$[]1
+_LTECHO_EOF'
+ }
+ ECHO='func_fallback_echo'
+fi
+
+# func_echo_all arg...
+# Invoke $ECHO with all args, space-separated.
+func_echo_all ()
+{
+ $ECHO "$*"
+}
+
+case "$ECHO" in
+ printf*) AC_MSG_RESULT([printf]) ;;
+ print*) AC_MSG_RESULT([print -r]) ;;
+ *) AC_MSG_RESULT([cat]) ;;
+esac
+
+m4_ifdef([_AS_DETECT_SUGGESTED],
+[_AS_DETECT_SUGGESTED([
+ test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || (
+ ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+ ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
+ ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
+ PATH=/empty FPATH=/empty; export PATH FPATH
+ test "X`printf %s $ECHO`" = "X$ECHO" \
+ || test "X`print -r -- $ECHO`" = "X$ECHO" )])])
+
+_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts])
+_LT_DECL([], [ECHO], [1], [An echo program that protects backslashes])
+])# _LT_PROG_ECHO_BACKSLASH
+
+
+# _LT_WITH_SYSROOT
+# ----------------
+AC_DEFUN([_LT_WITH_SYSROOT],
+[AC_MSG_CHECKING([for sysroot])
+AC_ARG_WITH([sysroot],
+[ --with-sysroot[=DIR] Search for dependent libraries within DIR
+ (or the compiler's sysroot if not specified).],
+[], [with_sysroot=no])
+
+dnl lt_sysroot will always be passed unquoted. We quote it here
+dnl in case the user passed a directory name.
+lt_sysroot=
+case ${with_sysroot} in #(
+ yes)
+ if test "$GCC" = yes; then
+ lt_sysroot=`$CC --print-sysroot 2>/dev/null`
+ fi
+ ;; #(
+ /*)
+ lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"`
+ ;; #(
+ no|'')
+ ;; #(
+ *)
+ AC_MSG_RESULT([${with_sysroot}])
+ AC_MSG_ERROR([The sysroot must be an absolute path.])
+ ;;
+esac
+
+ AC_MSG_RESULT([${lt_sysroot:-no}])
+_LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl
+[dependent libraries, and in which our libraries should be installed.])])
+
+# _LT_ENABLE_LOCK
+# ---------------
+m4_defun([_LT_ENABLE_LOCK],
+[AC_ARG_ENABLE([libtool-lock],
+ [AS_HELP_STRING([--disable-libtool-lock],
+ [avoid locking (might break parallel builds)])])
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case $host in
+ia64-*-hpux*)
+ # Find out which ABI we are using.
+ echo 'int i;' > conftest.$ac_ext
+ if AC_TRY_EVAL(ac_compile); then
+ case `/usr/bin/file conftest.$ac_objext` in
+ *ELF-32*)
+ HPUX_IA64_MODE="32"
+ ;;
+ *ELF-64*)
+ HPUX_IA64_MODE="64"
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+*-*-irix6*)
+ # Find out which ABI we are using.
+ echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext
+ if AC_TRY_EVAL(ac_compile); then
+ if test "$lt_cv_prog_gnu_ld" = yes; then
+ case `/usr/bin/file conftest.$ac_objext` in
+ *32-bit*)
+ LD="${LD-ld} -melf32bsmip"
+ ;;
+ *N32*)
+ LD="${LD-ld} -melf32bmipn32"
+ ;;
+ *64-bit*)
+ LD="${LD-ld} -melf64bmip"
+ ;;
+ esac
+ else
+ case `/usr/bin/file conftest.$ac_objext` in
+ *32-bit*)
+ LD="${LD-ld} -32"
+ ;;
+ *N32*)
+ LD="${LD-ld} -n32"
+ ;;
+ *64-bit*)
+ LD="${LD-ld} -64"
+ ;;
+ esac
+ fi
+ fi
+ rm -rf conftest*
+ ;;
+
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
+s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
+ # Find out which ABI we are using.
+ echo 'int i;' > conftest.$ac_ext
+ if AC_TRY_EVAL(ac_compile); then
+ case `/usr/bin/file conftest.o` in
+ *32-bit*)
+ case $host in
+ x86_64-*kfreebsd*-gnu)
+ LD="${LD-ld} -m elf_i386_fbsd"
+ ;;
+ x86_64-*linux*)
+ LD="${LD-ld} -m elf_i386"
+ ;;
+ ppc64-*linux*|powerpc64-*linux*)
+ LD="${LD-ld} -m elf32ppclinux"
+ ;;
+ s390x-*linux*)
+ LD="${LD-ld} -m elf_s390"
+ ;;
+ sparc64-*linux*)
+ LD="${LD-ld} -m elf32_sparc"
+ ;;
+ esac
+ ;;
+ *64-bit*)
+ case $host in
+ x86_64-*kfreebsd*-gnu)
+ LD="${LD-ld} -m elf_x86_64_fbsd"
+ ;;
+ x86_64-*linux*)
+ LD="${LD-ld} -m elf_x86_64"
+ ;;
+ ppc*-*linux*|powerpc*-*linux*)
+ LD="${LD-ld} -m elf64ppc"
+ ;;
+ s390*-*linux*|s390*-*tpf*)
+ LD="${LD-ld} -m elf64_s390"
+ ;;
+ sparc*-*linux*)
+ LD="${LD-ld} -m elf64_sparc"
+ ;;
+ esac
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+
+*-*-sco3.2v5*)
+ # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+ SAVE_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -belf"
+ AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
+ [AC_LANG_PUSH(C)
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
+ AC_LANG_POP])
+ if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+ # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+ CFLAGS="$SAVE_CFLAGS"
+ fi
+ ;;
+*-*solaris*)
+ # Find out which ABI we are using.
+ echo 'int i;' > conftest.$ac_ext
+ if AC_TRY_EVAL(ac_compile); then
+ case `/usr/bin/file conftest.o` in
+ *64-bit*)
+ case $lt_cv_prog_gnu_ld in
+ yes*)
+ case $host in
+ i?86-*-solaris*)
+ LD="${LD-ld} -m elf_x86_64"
+ ;;
+ sparc*-*-solaris*)
+ LD="${LD-ld} -m elf64_sparc"
+ ;;
+ esac
+ # GNU ld 2.21 introduced _sol2 emulations. Use them if available.
+ if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then
+ LD="${LD-ld}_sol2"
+ fi
+ ;;
+ *)
+ if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
+ LD="${LD-ld} -64"
+ fi
+ ;;
+ esac
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+esac
+
+need_locks="$enable_libtool_lock"
+])# _LT_ENABLE_LOCK
+
+
+# _LT_PROG_AR
+# -----------
+m4_defun([_LT_PROG_AR],
+[AC_CHECK_TOOLS(AR, [ar], false)
+: ${AR=ar}
+: ${AR_FLAGS=cru}
+_LT_DECL([], [AR], [1], [The archiver])
+_LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive])
+
+AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file],
+ [lt_cv_ar_at_file=no
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM],
+ [echo conftest.$ac_objext > conftest.lst
+ lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD'
+ AC_TRY_EVAL([lt_ar_try])
+ if test "$ac_status" -eq 0; then
+ # Ensure the archiver fails upon bogus file names.
+ rm -f conftest.$ac_objext libconftest.a
+ AC_TRY_EVAL([lt_ar_try])
+ if test "$ac_status" -ne 0; then
+ lt_cv_ar_at_file=@
+ fi
+ fi
+ rm -f conftest.* libconftest.a
+ ])
+ ])
+
+if test "x$lt_cv_ar_at_file" = xno; then
+ archiver_list_spec=
+else
+ archiver_list_spec=$lt_cv_ar_at_file
+fi
+_LT_DECL([], [archiver_list_spec], [1],
+ [How to feed a file listing to the archiver])
+])# _LT_PROG_AR
+
+
+# _LT_CMD_OLD_ARCHIVE
+# -------------------
+m4_defun([_LT_CMD_OLD_ARCHIVE],
+[_LT_PROG_AR
+
+AC_CHECK_TOOL(STRIP, strip, :)
+test -z "$STRIP" && STRIP=:
+_LT_DECL([], [STRIP], [1], [A symbol stripping program])
+
+AC_CHECK_TOOL(RANLIB, ranlib, :)
+test -z "$RANLIB" && RANLIB=:
+_LT_DECL([], [RANLIB], [1],
+ [Commands used to install an old-style archive])
+
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
+
+if test -n "$RANLIB"; then
+ case $host_os in
+ openbsd*)
+ old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib"
+ ;;
+ *)
+ old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib"
+ ;;
+ esac
+ old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib"
+fi
+
+case $host_os in
+ darwin*)
+ lock_old_archive_extraction=yes ;;
+ *)
+ lock_old_archive_extraction=no ;;
+esac
+_LT_DECL([], [old_postinstall_cmds], [2])
+_LT_DECL([], [old_postuninstall_cmds], [2])
+_LT_TAGDECL([], [old_archive_cmds], [2],
+ [Commands used to build an old-style archive])
+_LT_DECL([], [lock_old_archive_extraction], [0],
+ [Whether to use a lock for old archive extraction])
+])# _LT_CMD_OLD_ARCHIVE
+
+
+# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
+# ----------------------------------------------------------------
+# Check whether the given compiler option works
+AC_DEFUN([_LT_COMPILER_OPTION],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_SED])dnl
+AC_CACHE_CHECK([$1], [$2],
+ [$2=no
+ m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+ lt_compiler_flag="$3"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ # The option is referenced via a variable to avoid confusing sed.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+ (eval "$lt_compile" 2>conftest.err)
+ ac_status=$?
+ cat conftest.err >&AS_MESSAGE_LOG_FD
+ echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+ if (exit $ac_status) && test -s "$ac_outfile"; then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings other than the usual output.
+ $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+ if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+ $2=yes
+ fi
+ fi
+ $RM conftest*
+])
+
+if test x"[$]$2" = xyes; then
+ m4_if([$5], , :, [$5])
+else
+ m4_if([$6], , :, [$6])
+fi
+])# _LT_COMPILER_OPTION
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], [])
+
+
+# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+# [ACTION-SUCCESS], [ACTION-FAILURE])
+# ----------------------------------------------------
+# Check whether the given linker option works
+AC_DEFUN([_LT_LINKER_OPTION],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_SED])dnl
+AC_CACHE_CHECK([$1], [$2],
+ [$2=no
+ save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS $3"
+ echo "$lt_simple_link_test_code" > conftest.$ac_ext
+ if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+ # The linker can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ if test -s conftest.err; then
+ # Append any errors to the config.log.
+ cat conftest.err 1>&AS_MESSAGE_LOG_FD
+ $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+ if diff conftest.exp conftest.er2 >/dev/null; then
+ $2=yes
+ fi
+ else
+ $2=yes
+ fi
+ fi
+ $RM -r conftest*
+ LDFLAGS="$save_LDFLAGS"
+])
+
+if test x"[$]$2" = xyes; then
+ m4_if([$4], , :, [$4])
+else
+ m4_if([$5], , :, [$5])
+fi
+])# _LT_LINKER_OPTION
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], [])
+
+
+# LT_CMD_MAX_LEN
+#---------------
+AC_DEFUN([LT_CMD_MAX_LEN],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+# find the maximum length of command line arguments
+AC_MSG_CHECKING([the maximum length of command line arguments])
+AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
+ i=0
+ teststring="ABCD"
+
+ case $build_os in
+ msdosdjgpp*)
+ # On DJGPP, this test can blow up pretty badly due to problems in libc
+ # (any single argument exceeding 2000 bytes causes a buffer overrun
+ # during glob expansion). Even if it were fixed, the result of this
+ # check would be larger than it should be.
+ lt_cv_sys_max_cmd_len=12288; # 12K is about right
+ ;;
+
+ gnu*)
+ # Under GNU Hurd, this test is not required because there is
+ # no limit to the length of command line arguments.
+ # Libtool will interpret -1 as no limit whatsoever
+ lt_cv_sys_max_cmd_len=-1;
+ ;;
+
+ cygwin* | mingw* | cegcc*)
+ # On Win9x/ME, this test blows up -- it succeeds, but takes
+ # about 5 minutes as the teststring grows exponentially.
+ # Worse, since 9x/ME are not pre-emptively multitasking,
+ # you end up with a "frozen" computer, even though with patience
+ # the test eventually succeeds (with a max line length of 256k).
+ # Instead, let's just punt: use the minimum linelength reported by
+ # all of the supported platforms: 8192 (on NT/2K/XP).
+ lt_cv_sys_max_cmd_len=8192;
+ ;;
+
+ mint*)
+ # On MiNT this can take a long time and run out of memory.
+ lt_cv_sys_max_cmd_len=8192;
+ ;;
+
+ amigaos*)
+ # On AmigaOS with pdksh, this test takes hours, literally.
+ # So we just punt and use a minimum line length of 8192.
+ lt_cv_sys_max_cmd_len=8192;
+ ;;
+
+ netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+ # This has been around since 386BSD, at least. Likely further.
+ if test -x /sbin/sysctl; then
+ lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
+ elif test -x /usr/sbin/sysctl; then
+ lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+ else
+ lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs
+ fi
+ # And add a safety zone
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+ ;;
+
+ interix*)
+ # We know the value 262144 and hardcode it with a safety zone (like BSD)
+ lt_cv_sys_max_cmd_len=196608
+ ;;
+
+ os2*)
+ # The test takes a long time on OS/2.
+ lt_cv_sys_max_cmd_len=8192
+ ;;
+
+ osf*)
+ # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
+ # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
+ # nice to cause kernel panics so lets avoid the loop below.
+ # First set a reasonable default.
+ lt_cv_sys_max_cmd_len=16384
+ #
+ if test -x /sbin/sysconfig; then
+ case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
+ *1*) lt_cv_sys_max_cmd_len=-1 ;;
+ esac
+ fi
+ ;;
+ sco3.2v5*)
+ lt_cv_sys_max_cmd_len=102400
+ ;;
+ sysv5* | sco5v6* | sysv4.2uw2*)
+ kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
+ if test -n "$kargmax"; then
+ lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'`
+ else
+ lt_cv_sys_max_cmd_len=32768
+ fi
+ ;;
+ *)
+ lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
+ if test -n "$lt_cv_sys_max_cmd_len"; then
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+ else
+ # Make teststring a little bigger before we do anything with it.
+ # a 1K string should be a reasonable start.
+ for i in 1 2 3 4 5 6 7 8 ; do
+ teststring=$teststring$teststring
+ done
+ SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+ # If test is not a shell built-in, we'll probably end up computing a
+ # maximum length that is only half of the actual maximum length, but
+ # we can't tell.
+ while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \
+ = "X$teststring$teststring"; } >/dev/null 2>&1 &&
+ test $i != 17 # 1/2 MB should be enough
+ do
+ i=`expr $i + 1`
+ teststring=$teststring$teststring
+ done
+ # Only check the string length outside the loop.
+ lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
+ teststring=
+ # Add a significant safety factor because C++ compilers can tack on
+ # massive amounts of additional arguments before passing them to the
+ # linker. It appears as though 1/2 is a usable value.
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+ fi
+ ;;
+ esac
+])
+if test -n $lt_cv_sys_max_cmd_len ; then
+ AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
+else
+ AC_MSG_RESULT(none)
+fi
+max_cmd_len=$lt_cv_sys_max_cmd_len
+_LT_DECL([], [max_cmd_len], [0],
+ [What is the maximum length of a command?])
+])# LT_CMD_MAX_LEN
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], [])
+
+
+# _LT_HEADER_DLFCN
+# ----------------
+m4_defun([_LT_HEADER_DLFCN],
+[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl
+])# _LT_HEADER_DLFCN
+
+
+# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
+# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
+# ----------------------------------------------------------------
+m4_defun([_LT_TRY_DLOPEN_SELF],
+[m4_require([_LT_HEADER_DLFCN])dnl
+if test "$cross_compiling" = yes; then :
+ [$4]
+else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<_LT_EOF
+[#line $LINENO "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+# define LT_DLGLOBAL RTLD_GLOBAL
+#else
+# ifdef DL_GLOBAL
+# define LT_DLGLOBAL DL_GLOBAL
+# else
+# define LT_DLGLOBAL 0
+# endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+ find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+# ifdef RTLD_LAZY
+# define LT_DLLAZY_OR_NOW RTLD_LAZY
+# else
+# ifdef DL_LAZY
+# define LT_DLLAZY_OR_NOW DL_LAZY
+# else
+# ifdef RTLD_NOW
+# define LT_DLLAZY_OR_NOW RTLD_NOW
+# else
+# ifdef DL_NOW
+# define LT_DLLAZY_OR_NOW DL_NOW
+# else
+# define LT_DLLAZY_OR_NOW 0
+# endif
+# endif
+# endif
+# endif
+#endif
+
+/* When -fvisbility=hidden is used, assume the code has been annotated
+ correspondingly for the symbols needed. */
+#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+int fnord () __attribute__((visibility("default")));
+#endif
+
+int fnord () { return 42; }
+int main ()
+{
+ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+ int status = $lt_dlunknown;
+
+ if (self)
+ {
+ if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
+ else
+ {
+ if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+ else puts (dlerror ());
+ }
+ /* dlclose (self); */
+ }
+ else
+ puts (dlerror ());
+
+ return status;
+}]
+_LT_EOF
+ if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
+ (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
+ lt_status=$?
+ case x$lt_status in
+ x$lt_dlno_uscore) $1 ;;
+ x$lt_dlneed_uscore) $2 ;;
+ x$lt_dlunknown|x*) $3 ;;
+ esac
+ else :
+ # compilation failed
+ $3
+ fi
+fi
+rm -fr conftest*
+])# _LT_TRY_DLOPEN_SELF
+
+
+# LT_SYS_DLOPEN_SELF
+# ------------------
+AC_DEFUN([LT_SYS_DLOPEN_SELF],
+[m4_require([_LT_HEADER_DLFCN])dnl
+if test "x$enable_dlopen" != xyes; then
+ enable_dlopen=unknown
+ enable_dlopen_self=unknown
+ enable_dlopen_self_static=unknown
+else
+ lt_cv_dlopen=no
+ lt_cv_dlopen_libs=
+
+ case $host_os in
+ beos*)
+ lt_cv_dlopen="load_add_on"
+ lt_cv_dlopen_libs=
+ lt_cv_dlopen_self=yes
+ ;;
+
+ mingw* | pw32* | cegcc*)
+ lt_cv_dlopen="LoadLibrary"
+ lt_cv_dlopen_libs=
+ ;;
+
+ cygwin*)
+ lt_cv_dlopen="dlopen"
+ lt_cv_dlopen_libs=
+ ;;
+
+ darwin*)
+ # if libdl is installed we need to link against it
+ AC_CHECK_LIB([dl], [dlopen],
+ [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
+ lt_cv_dlopen="dyld"
+ lt_cv_dlopen_libs=
+ lt_cv_dlopen_self=yes
+ ])
+ ;;
+
+ *)
+ AC_CHECK_FUNC([shl_load],
+ [lt_cv_dlopen="shl_load"],
+ [AC_CHECK_LIB([dld], [shl_load],
+ [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"],
+ [AC_CHECK_FUNC([dlopen],
+ [lt_cv_dlopen="dlopen"],
+ [AC_CHECK_LIB([dl], [dlopen],
+ [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
+ [AC_CHECK_LIB([svld], [dlopen],
+ [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
+ [AC_CHECK_LIB([dld], [dld_link],
+ [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"])
+ ])
+ ])
+ ])
+ ])
+ ])
+ ;;
+ esac
+
+ if test "x$lt_cv_dlopen" != xno; then
+ enable_dlopen=yes
+ else
+ enable_dlopen=no
+ fi
+
+ case $lt_cv_dlopen in
+ dlopen)
+ save_CPPFLAGS="$CPPFLAGS"
+ test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+ save_LDFLAGS="$LDFLAGS"
+ wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+ save_LIBS="$LIBS"
+ LIBS="$lt_cv_dlopen_libs $LIBS"
+
+ AC_CACHE_CHECK([whether a program can dlopen itself],
+ lt_cv_dlopen_self, [dnl
+ _LT_TRY_DLOPEN_SELF(
+ lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
+ lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
+ ])
+
+ if test "x$lt_cv_dlopen_self" = xyes; then
+ wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
+ AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
+ lt_cv_dlopen_self_static, [dnl
+ _LT_TRY_DLOPEN_SELF(
+ lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
+ lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross)
+ ])
+ fi
+
+ CPPFLAGS="$save_CPPFLAGS"
+ LDFLAGS="$save_LDFLAGS"
+ LIBS="$save_LIBS"
+ ;;
+ esac
+
+ case $lt_cv_dlopen_self in
+ yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+ *) enable_dlopen_self=unknown ;;
+ esac
+
+ case $lt_cv_dlopen_self_static in
+ yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+ *) enable_dlopen_self_static=unknown ;;
+ esac
+fi
+_LT_DECL([dlopen_support], [enable_dlopen], [0],
+ [Whether dlopen is supported])
+_LT_DECL([dlopen_self], [enable_dlopen_self], [0],
+ [Whether dlopen of programs is supported])
+_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0],
+ [Whether dlopen of statically linked programs is supported])
+])# LT_SYS_DLOPEN_SELF
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], [])
+
+
+# _LT_COMPILER_C_O([TAGNAME])
+# ---------------------------
+# Check to see if options -c and -o are simultaneously supported by compiler.
+# This macro does not hard code the compiler like AC_PROG_CC_C_O.
+m4_defun([_LT_COMPILER_C_O],
+[m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_TAG_COMPILER])dnl
+AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
+ [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
+ [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
+ $RM -r conftest 2>/dev/null
+ mkdir conftest
+ cd conftest
+ mkdir out
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ lt_compiler_flag="-o out/conftest2.$ac_objext"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+ (eval "$lt_compile" 2>out/conftest.err)
+ ac_status=$?
+ cat out/conftest.err >&AS_MESSAGE_LOG_FD
+ echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+ if (exit $ac_status) && test -s out/conftest2.$ac_objext
+ then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
+ $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+ if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+ _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+ fi
+ fi
+ chmod u+w . 2>&AS_MESSAGE_LOG_FD
+ $RM conftest*
+ # SGI C++ compiler will create directory out/ii_files/ for
+ # template instantiation
+ test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+ $RM out/* && rmdir out
+ cd ..
+ $RM -r conftest
+ $RM conftest*
+])
+_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1],
+ [Does compiler simultaneously support -c and -o options?])
+])# _LT_COMPILER_C_O
+
+
+# _LT_COMPILER_FILE_LOCKS([TAGNAME])
+# ----------------------------------
+# Check to see if we can do hard links to lock some files if needed
+m4_defun([_LT_COMPILER_FILE_LOCKS],
+[m4_require([_LT_ENABLE_LOCK])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+_LT_COMPILER_C_O([$1])
+
+hard_links="nottested"
+if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
+ # do not overwrite the value of need_locks provided by the user
+ AC_MSG_CHECKING([if we can lock with hard links])
+ hard_links=yes
+ $RM conftest*
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ touch conftest.a
+ ln conftest.a conftest.b 2>&5 || hard_links=no
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ AC_MSG_RESULT([$hard_links])
+ if test "$hard_links" = no; then
+ AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
+ need_locks=warn
+ fi
+else
+ need_locks=no
+fi
+_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?])
+])# _LT_COMPILER_FILE_LOCKS
+
+
+# _LT_CHECK_OBJDIR
+# ----------------
+m4_defun([_LT_CHECK_OBJDIR],
+[AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
+[rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+ lt_cv_objdir=.libs
+else
+ # MS-DOS does not allow filenames that begin with a dot.
+ lt_cv_objdir=_libs
+fi
+rmdir .libs 2>/dev/null])
+objdir=$lt_cv_objdir
+_LT_DECL([], [objdir], [0],
+ [The name of the directory that contains temporary libtool files])dnl
+m4_pattern_allow([LT_OBJDIR])dnl
+AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/",
+ [Define to the sub-directory in which libtool stores uninstalled libraries.])
+])# _LT_CHECK_OBJDIR
+
+
+# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME])
+# --------------------------------------
+# Check hardcoding attributes.
+m4_defun([_LT_LINKER_HARDCODE_LIBPATH],
+[AC_MSG_CHECKING([how to hardcode library paths into programs])
+_LT_TAGVAR(hardcode_action, $1)=
+if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" ||
+ test -n "$_LT_TAGVAR(runpath_var, $1)" ||
+ test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
+
+ # We can hardcode non-existent directories.
+ if test "$_LT_TAGVAR(hardcode_direct, $1)" != no &&
+ # If the only mechanism to avoid hardcoding is shlibpath_var, we
+ # have to relink, otherwise we might link with an installed library
+ # when we should be linking with a yet-to-be-installed one
+ ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
+ test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then
+ # Linking always hardcodes the temporary library directory.
+ _LT_TAGVAR(hardcode_action, $1)=relink
+ else
+ # We can link without hardcoding, and we can hardcode nonexisting dirs.
+ _LT_TAGVAR(hardcode_action, $1)=immediate
+ fi
+else
+ # We cannot hardcode anything, or else we can only hardcode existing
+ # directories.
+ _LT_TAGVAR(hardcode_action, $1)=unsupported
+fi
+AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)])
+
+if test "$_LT_TAGVAR(hardcode_action, $1)" = relink ||
+ test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then
+ # Fast installation is not supported
+ enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+ test "$enable_shared" = no; then
+ # Fast installation is not necessary
+ enable_fast_install=needless
+fi
+_LT_TAGDECL([], [hardcode_action], [0],
+ [How to hardcode a shared library path into an executable])
+])# _LT_LINKER_HARDCODE_LIBPATH
+
+
+# _LT_CMD_STRIPLIB
+# ----------------
+m4_defun([_LT_CMD_STRIPLIB],
+[m4_require([_LT_DECL_EGREP])
+striplib=
+old_striplib=
+AC_MSG_CHECKING([whether stripping libraries is possible])
+if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
+ test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+ test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+ AC_MSG_RESULT([yes])
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+ case $host_os in
+ darwin*)
+ if test -n "$STRIP" ; then
+ striplib="$STRIP -x"
+ old_striplib="$STRIP -S"
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ fi
+ ;;
+ *)
+ AC_MSG_RESULT([no])
+ ;;
+ esac
+fi
+_LT_DECL([], [old_striplib], [1], [Commands to strip libraries])
+_LT_DECL([], [striplib], [1])
+])# _LT_CMD_STRIPLIB
+
+
+# _LT_SYS_DYNAMIC_LINKER([TAG])
+# -----------------------------
+# PORTME Fill in your ld.so characteristics
+m4_defun([_LT_SYS_DYNAMIC_LINKER],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_OBJDUMP])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_CHECK_SHELL_FEATURES])dnl
+AC_MSG_CHECKING([dynamic linker characteristics])
+m4_if([$1],
+ [], [
+if test "$GCC" = yes; then
+ case $host_os in
+ darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
+ *) lt_awk_arg="/^libraries:/" ;;
+ esac
+ case $host_os in
+ mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;;
+ *) lt_sed_strip_eq="s,=/,/,g" ;;
+ esac
+ lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
+ case $lt_search_path_spec in
+ *\;*)
+ # if the path contains ";" then we assume it to be the separator
+ # otherwise default to the standard path separator (i.e. ":") - it is
+ # assumed that no part of a normal pathname contains ";" but that should
+ # okay in the real world where ";" in dirpaths is itself problematic.
+ lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'`
+ ;;
+ *)
+ lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"`
+ ;;
+ esac
+ # Ok, now we have the path, separated by spaces, we can step through it
+ # and add multilib dir if necessary.
+ lt_tmp_lt_search_path_spec=
+ lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+ for lt_sys_path in $lt_search_path_spec; do
+ if test -d "$lt_sys_path/$lt_multi_os_dir"; then
+ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
+ else
+ test -d "$lt_sys_path" && \
+ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
+ fi
+ done
+ lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '
+BEGIN {RS=" "; FS="/|\n";} {
+ lt_foo="";
+ lt_count=0;
+ for (lt_i = NF; lt_i > 0; lt_i--) {
+ if ($lt_i != "" && $lt_i != ".") {
+ if ($lt_i == "..") {
+ lt_count++;
+ } else {
+ if (lt_count == 0) {
+ lt_foo="/" $lt_i lt_foo;
+ } else {
+ lt_count--;
+ }
+ }
+ }
+ }
+ if (lt_foo != "") { lt_freq[[lt_foo]]++; }
+ if (lt_freq[[lt_foo]] == 1) { print lt_foo; }
+}'`
+ # AWK program above erroneously prepends '/' to C:/dos/paths
+ # for these hosts.
+ case $host_os in
+ mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\
+ $SED 's,/\([[A-Za-z]]:\),\1,g'` ;;
+ esac
+ sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`
+else
+ sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi])
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+ shlibpath_var=LIBPATH
+
+ # AIX 3 has no versioning support, so we append a major version to the name.
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+
+aix[[4-9]]*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ hardcode_into_libs=yes
+ if test "$host_cpu" = ia64; then
+ # AIX 5 supports IA64
+ library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ else
+ # With GCC up to 2.95.x, collect2 would create an import file
+ # for dependence libraries. The import file would start with
+ # the line `#! .'. This would cause the generated library to
+ # depend on `.', always an invalid library. This was fixed in
+ # development snapshots of GCC prior to 3.0.
+ case $host_os in
+ aix4 | aix4.[[01]] | aix4.[[01]].*)
+ if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+ echo ' yes '
+ echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+ :
+ else
+ can_build_shared=no
+ fi
+ ;;
+ esac
+ # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+ # soname into executable. Probably we can add versioning support to
+ # collect2, so additional links can be useful in future.
+ if test "$aix_use_runtimelinking" = yes; then
+ # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+ # instead of lib<name>.a to let people know that these are not
+ # typical AIX shared libraries.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ else
+ # We preserve .a as extension for shared libraries through AIX4.2
+ # and later when we are not doing run time linking.
+ library_names_spec='${libname}${release}.a $libname.a'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ fi
+ shlibpath_var=LIBPATH
+ fi
+ ;;
+
+amigaos*)
+ case $host_cpu in
+ powerpc)
+ # Since July 2007 AmigaOS4 officially supports .so libraries.
+ # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ ;;
+ m68k)
+ library_names_spec='$libname.ixlibrary $libname.a'
+ # Create ${libname}_ixlibrary.a entries in /sys/libs.
+ finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+ ;;
+ esac
+ ;;
+
+beos*)
+ library_names_spec='${libname}${shared_ext}'
+ dynamic_linker="$host_os ld.so"
+ shlibpath_var=LIBRARY_PATH
+ ;;
+
+bsdi[[45]]*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+ sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+ # the default ld.so.conf also contains /usr/contrib/lib and
+ # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+ # libtool to hard-code these into programs
+ ;;
+
+cygwin* | mingw* | pw32* | cegcc*)
+ version_type=windows
+ shrext_cmds=".dll"
+ need_version=no
+ need_lib_prefix=no
+
+ case $GCC,$cc_basename in
+ yes,*)
+ # gcc
+ library_names_spec='$libname.dll.a'
+ # DLL is installed to $(libdir)/../bin by postinstall_cmds
+ postinstall_cmds='base_file=`basename \${file}`~
+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+ dldir=$destdir/`dirname \$dlpath`~
+ test -d \$dldir || mkdir -p \$dldir~
+ $install_prog $dir/$dlname \$dldir/$dlname~
+ chmod a+x \$dldir/$dlname~
+ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+ eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+ fi'
+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+ dlpath=$dir/\$dldll~
+ $RM \$dlpath'
+ shlibpath_overrides_runpath=yes
+
+ case $host_os in
+ cygwin*)
+ # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+ soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+m4_if([$1], [],[
+ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"])
+ ;;
+ mingw* | cegcc*)
+ # MinGW DLLs use traditional 'lib' prefix
+ soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+ ;;
+ pw32*)
+ # pw32 DLLs use 'pw' prefix rather than 'lib'
+ library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+ ;;
+ esac
+ dynamic_linker='Win32 ld.exe'
+ ;;
+
+ *,cl*)
+ # Native MSVC
+ libname_spec='$name'
+ soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+ library_names_spec='${libname}.dll.lib'
+
+ case $build_os in
+ mingw*)
+ sys_lib_search_path_spec=
+ lt_save_ifs=$IFS
+ IFS=';'
+ for lt_path in $LIB
+ do
+ IFS=$lt_save_ifs
+ # Let DOS variable expansion print the short 8.3 style file name.
+ lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"`
+ sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path"
+ done
+ IFS=$lt_save_ifs
+ # Convert to MSYS style.
+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'`
+ ;;
+ cygwin*)
+ # Convert to unix form, then to dos form, then back to unix form
+ # but this time dos style (no spaces!) so that the unix form looks
+ # like /cygdrive/c/PROGRA~1:/cygdr...
+ sys_lib_search_path_spec=`cygpath --path --unix "$LIB"`
+ sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null`
+ sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ ;;
+ *)
+ sys_lib_search_path_spec="$LIB"
+ if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then
+ # It is most probably a Windows format PATH.
+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+ else
+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ fi
+ # FIXME: find the short name or the path components, as spaces are
+ # common. (e.g. "Program Files" -> "PROGRA~1")
+ ;;
+ esac
+
+ # DLL is installed to $(libdir)/../bin by postinstall_cmds
+ postinstall_cmds='base_file=`basename \${file}`~
+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+ dldir=$destdir/`dirname \$dlpath`~
+ test -d \$dldir || mkdir -p \$dldir~
+ $install_prog $dir/$dlname \$dldir/$dlname'
+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+ dlpath=$dir/\$dldll~
+ $RM \$dlpath'
+ shlibpath_overrides_runpath=yes
+ dynamic_linker='Win32 link.exe'
+ ;;
+
+ *)
+ # Assume MSVC wrapper
+ library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
+ dynamic_linker='Win32 ld.exe'
+ ;;
+ esac
+ # FIXME: first we should search . and the directory the executable is in
+ shlibpath_var=PATH
+ ;;
+
+darwin* | rhapsody*)
+ dynamic_linker="$host_os dyld"
+ version_type=darwin
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+ soname_spec='${libname}${release}${major}$shared_ext'
+ shlibpath_overrides_runpath=yes
+ shlibpath_var=DYLD_LIBRARY_PATH
+ shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+m4_if([$1], [],[
+ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"])
+ sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+ ;;
+
+dgux*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+freebsd* | dragonfly*)
+ # DragonFly does not have aout. When/if they implement a new
+ # versioning mechanism, adjust this.
+ if test -x /usr/bin/objformat; then
+ objformat=`/usr/bin/objformat`
+ else
+ case $host_os in
+ freebsd[[23]].*) objformat=aout ;;
+ *) objformat=elf ;;
+ esac
+ fi
+ version_type=freebsd-$objformat
+ case $version_type in
+ freebsd-elf*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+ need_version=no
+ need_lib_prefix=no
+ ;;
+ freebsd-*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+ need_version=yes
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_os in
+ freebsd2.*)
+ shlibpath_overrides_runpath=yes
+ ;;
+ freebsd3.[[01]]* | freebsdelf3.[[01]]*)
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+ freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
+ freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+ *) # from 4.6 on, and DragonFly
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+ esac
+ ;;
+
+gnu*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+
+haiku*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ dynamic_linker="$host_os runtime_loader"
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
+ hardcode_into_libs=yes
+ ;;
+
+hpux9* | hpux10* | hpux11*)
+ # Give a soname corresponding to the major version so that dld.sl refuses to
+ # link against other versions.
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ case $host_cpu in
+ ia64*)
+ shrext_cmds='.so'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.so"
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ if test "X$HPUX_IA64_MODE" = X32; then
+ sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+ else
+ sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+ fi
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ hppa*64*)
+ shrext_cmds='.sl'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ *)
+ shrext_cmds='.sl'
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=SHLIB_PATH
+ shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+ esac
+ # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
+ postinstall_cmds='chmod 555 $lib'
+ # or fails outright, so override atomically:
+ install_override_mode=555
+ ;;
+
+interix[[3-9]]*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+
+irix5* | irix6* | nonstopux*)
+ case $host_os in
+ nonstopux*) version_type=nonstopux ;;
+ *)
+ if test "$lt_cv_prog_gnu_ld" = yes; then
+ version_type=linux # correct to gnu/linux during the next big refactor
+ else
+ version_type=irix
+ fi ;;
+ esac
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+ case $host_os in
+ irix5* | nonstopux*)
+ libsuff= shlibsuff=
+ ;;
+ *)
+ case $LD in # libtool.m4 will add one of these switches to LD
+ *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+ libsuff= shlibsuff= libmagic=32-bit;;
+ *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+ libsuff=32 shlibsuff=N32 libmagic=N32;;
+ *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+ libsuff=64 shlibsuff=64 libmagic=64-bit;;
+ *) libsuff= shlibsuff= libmagic=never-match;;
+ esac
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+ sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+ hardcode_into_libs=yes
+ ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+ dynamic_linker=no
+ ;;
+
+# This must be glibc/ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+
+ # Some binutils ld are patched to set DT_RUNPATH
+ AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath],
+ [lt_cv_shlibpath_overrides_runpath=no
+ save_LDFLAGS=$LDFLAGS
+ save_libdir=$libdir
+ eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \
+ LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\""
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
+ [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null],
+ [lt_cv_shlibpath_overrides_runpath=yes])])
+ LDFLAGS=$save_LDFLAGS
+ libdir=$save_libdir
+ ])
+ shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath
+
+ # This implies no fast_install, which is unacceptable.
+ # Some rework will be needed to allow for fast_install
+ # before this can be enabled.
+ hardcode_into_libs=yes
+
+ # Append ld.so.conf contents to the search path
+ if test -f /etc/ld.so.conf; then
+ lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
+ sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+ fi
+
+ # We used to test for /lib/ld.so.1 and disable shared libraries on
+ # powerpc, because MkLinux only supported shared libraries with the
+ # GNU dynamic linker. Since this was broken with cross compilers,
+ # most powerpc-linux boxes support dynamic linking these days and
+ # people can always --disable-shared, the test was removed, and we
+ # assume the GNU/Linux dynamic linker is in use.
+ dynamic_linker='GNU/Linux ld.so'
+ ;;
+
+netbsdelf*-gnu)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ dynamic_linker='NetBSD ld.elf_so'
+ ;;
+
+netbsd*)
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ dynamic_linker='NetBSD (a.out) ld.so'
+ else
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ dynamic_linker='NetBSD ld.elf_so'
+ fi
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+
+newsos6)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ ;;
+
+*nto* | *qnx*)
+ version_type=qnx
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ dynamic_linker='ldqnx.so'
+ ;;
+
+openbsd*)
+ version_type=sunos
+ sys_lib_dlsearch_path_spec="/usr/lib"
+ need_lib_prefix=no
+ # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+ case $host_os in
+ openbsd3.3 | openbsd3.3.*) need_version=yes ;;
+ *) need_version=no ;;
+ esac
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ case $host_os in
+ openbsd2.[[89]] | openbsd2.[[89]].*)
+ shlibpath_overrides_runpath=no
+ ;;
+ *)
+ shlibpath_overrides_runpath=yes
+ ;;
+ esac
+ else
+ shlibpath_overrides_runpath=yes
+ fi
+ ;;
+
+os2*)
+ libname_spec='$name'
+ shrext_cmds=".dll"
+ need_lib_prefix=no
+ library_names_spec='$libname${shared_ext} $libname.a'
+ dynamic_linker='OS/2 ld.exe'
+ shlibpath_var=LIBPATH
+ ;;
+
+osf3* | osf4* | osf5*)
+ version_type=osf
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+ sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+ ;;
+
+rdos*)
+ dynamic_linker=no
+ ;;
+
+solaris*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ # ldd complains unless libraries are executable
+ postinstall_cmds='chmod +x $lib'
+ ;;
+
+sunos4*)
+ version_type=sunos
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ if test "$with_gnu_ld" = yes; then
+ need_lib_prefix=no
+ fi
+ need_version=yes
+ ;;
+
+sysv4 | sysv4.3*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_vendor in
+ sni)
+ shlibpath_overrides_runpath=no
+ need_lib_prefix=no
+ runpath_var=LD_RUN_PATH
+ ;;
+ siemens)
+ need_lib_prefix=no
+ ;;
+ motorola)
+ need_lib_prefix=no
+ need_version=no
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+ ;;
+ esac
+ ;;
+
+sysv4*MP*)
+ if test -d /usr/nec ;then
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+ soname_spec='$libname${shared_ext}.$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ fi
+ ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+ version_type=freebsd-elf
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ if test "$with_gnu_ld" = yes; then
+ sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+ else
+ sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+ case $host_os in
+ sco3.2v5*)
+ sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+ ;;
+ esac
+ fi
+ sys_lib_dlsearch_path_spec='/usr/lib'
+ ;;
+
+tpf*)
+ # TPF is a cross-target only. Preferred cross-host = GNU/Linux.
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+
+uts4*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+*)
+ dynamic_linker=no
+ ;;
+esac
+AC_MSG_RESULT([$dynamic_linker])
+test "$dynamic_linker" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+ variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+ sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+fi
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+ sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+fi
+
+_LT_DECL([], [variables_saved_for_relink], [1],
+ [Variables whose values should be saved in libtool wrapper scripts and
+ restored at link time])
+_LT_DECL([], [need_lib_prefix], [0],
+ [Do we need the "lib" prefix for modules?])
+_LT_DECL([], [need_version], [0], [Do we need a version for libraries?])
+_LT_DECL([], [version_type], [0], [Library versioning type])
+_LT_DECL([], [runpath_var], [0], [Shared library runtime path variable])
+_LT_DECL([], [shlibpath_var], [0],[Shared library path variable])
+_LT_DECL([], [shlibpath_overrides_runpath], [0],
+ [Is shlibpath searched before the hard-coded library search path?])
+_LT_DECL([], [libname_spec], [1], [Format of library name prefix])
+_LT_DECL([], [library_names_spec], [1],
+ [[List of archive names. First name is the real one, the rest are links.
+ The last name is the one that the linker finds with -lNAME]])
+_LT_DECL([], [soname_spec], [1],
+ [[The coded name of the library, if different from the real name]])
+_LT_DECL([], [install_override_mode], [1],
+ [Permission mode override for installation of shared libraries])
+_LT_DECL([], [postinstall_cmds], [2],
+ [Command to use after installation of a shared archive])
+_LT_DECL([], [postuninstall_cmds], [2],
+ [Command to use after uninstallation of a shared archive])
+_LT_DECL([], [finish_cmds], [2],
+ [Commands used to finish a libtool library installation in a directory])
+_LT_DECL([], [finish_eval], [1],
+ [[As "finish_cmds", except a single script fragment to be evaled but
+ not shown]])
+_LT_DECL([], [hardcode_into_libs], [0],
+ [Whether we should hardcode library paths into libraries])
+_LT_DECL([], [sys_lib_search_path_spec], [2],
+ [Compile-time system search path for libraries])
+_LT_DECL([], [sys_lib_dlsearch_path_spec], [2],
+ [Run-time system search path for libraries])
+])# _LT_SYS_DYNAMIC_LINKER
+
+
+# _LT_PATH_TOOL_PREFIX(TOOL)
+# --------------------------
+# find a file program which can recognize shared library
+AC_DEFUN([_LT_PATH_TOOL_PREFIX],
+[m4_require([_LT_DECL_EGREP])dnl
+AC_MSG_CHECKING([for $1])
+AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
+[case $MAGIC_CMD in
+[[\\/*] | ?:[\\/]*])
+ lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+ ;;
+*)
+ lt_save_MAGIC_CMD="$MAGIC_CMD"
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+dnl $ac_dummy forces splitting on constant user-supplied paths.
+dnl POSIX.2 word splitting is done only on the output of word expansions,
+dnl not every word. This closes a longstanding sh security hole.
+ ac_dummy="m4_if([$2], , $PATH, [$2])"
+ for ac_dir in $ac_dummy; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$1; then
+ lt_cv_path_MAGIC_CMD="$ac_dir/$1"
+ if test -n "$file_magic_test_file"; then
+ case $deplibs_check_method in
+ "file_magic "*)
+ file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+ MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+ if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+ $EGREP "$file_magic_regex" > /dev/null; then
+ :
+ else
+ cat <<_LT_EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such. This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem. Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+_LT_EOF
+ fi ;;
+ esac
+ fi
+ break
+ fi
+ done
+ IFS="$lt_save_ifs"
+ MAGIC_CMD="$lt_save_MAGIC_CMD"
+ ;;
+esac])
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+ AC_MSG_RESULT($MAGIC_CMD)
+else
+ AC_MSG_RESULT(no)
+fi
+_LT_DECL([], [MAGIC_CMD], [0],
+ [Used to examine libraries when file_magic_cmd begins with "file"])dnl
+])# _LT_PATH_TOOL_PREFIX
+
+# Old name:
+AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], [])
+
+
+# _LT_PATH_MAGIC
+# --------------
+# find a file program which can recognize a shared library
+m4_defun([_LT_PATH_MAGIC],
+[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
+if test -z "$lt_cv_path_MAGIC_CMD"; then
+ if test -n "$ac_tool_prefix"; then
+ _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
+ else
+ MAGIC_CMD=:
+ fi
+fi
+])# _LT_PATH_MAGIC
+
+
+# LT_PATH_LD
+# ----------
+# find the pathname to the GNU or non-GNU linker
+AC_DEFUN([LT_PATH_LD],
+[AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_PROG_ECHO_BACKSLASH])dnl
+
+AC_ARG_WITH([gnu-ld],
+ [AS_HELP_STRING([--with-gnu-ld],
+ [assume the C compiler uses GNU ld @<:@default=no@:>@])],
+ [test "$withval" = no || with_gnu_ld=yes],
+ [with_gnu_ld=no])dnl
+
+ac_prog=ld
+if test "$GCC" = yes; then
+ # Check if gcc -print-prog-name=ld gives a path.
+ AC_MSG_CHECKING([for ld used by $CC])
+ case $host in
+ *-*-mingw*)
+ # gcc leaves a trailing carriage return which upsets mingw
+ ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+ *)
+ ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+ esac
+ case $ac_prog in
+ # Accept absolute paths.
+ [[\\/]]* | ?:[[\\/]]*)
+ re_direlt='/[[^/]][[^/]]*/\.\./'
+ # Canonicalize the pathname of ld
+ ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
+ while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
+ ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
+ done
+ test -z "$LD" && LD="$ac_prog"
+ ;;
+ "")
+ # If it fails, then pretend we aren't using GCC.
+ ac_prog=ld
+ ;;
+ *)
+ # If it is relative, then search for the first ld in PATH.
+ with_gnu_ld=unknown
+ ;;
+ esac
+elif test "$with_gnu_ld" = yes; then
+ AC_MSG_CHECKING([for GNU ld])
+else
+ AC_MSG_CHECKING([for non-GNU ld])
+fi
+AC_CACHE_VAL(lt_cv_path_LD,
+[if test -z "$LD"; then
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ for ac_dir in $PATH; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+ lt_cv_path_LD="$ac_dir/$ac_prog"
+ # Check to see if the program is GNU ld. I'd rather use --version,
+ # but apparently some variants of GNU ld only accept -v.
+ # Break only if it was the GNU/non-GNU ld that we prefer.
+ case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+ *GNU* | *'with BFD'*)
+ test "$with_gnu_ld" != no && break
+ ;;
+ *)
+ test "$with_gnu_ld" != yes && break
+ ;;
+ esac
+ fi
+ done
+ IFS="$lt_save_ifs"
+else
+ lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi])
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+ AC_MSG_RESULT($LD)
+else
+ AC_MSG_RESULT(no)
+fi
+test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
+_LT_PATH_LD_GNU
+AC_SUBST([LD])
+
+_LT_TAGDECL([], [LD], [1], [The linker used to build libraries])
+])# LT_PATH_LD
+
+# Old names:
+AU_ALIAS([AM_PROG_LD], [LT_PATH_LD])
+AU_ALIAS([AC_PROG_LD], [LT_PATH_LD])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_PROG_LD], [])
+dnl AC_DEFUN([AC_PROG_LD], [])
+
+
+# _LT_PATH_LD_GNU
+#- --------------
+m4_defun([_LT_PATH_LD_GNU],
+[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
+[# I'd rather use --version here, but apparently some GNU lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+ lt_cv_prog_gnu_ld=yes
+ ;;
+*)
+ lt_cv_prog_gnu_ld=no
+ ;;
+esac])
+with_gnu_ld=$lt_cv_prog_gnu_ld
+])# _LT_PATH_LD_GNU
+
+
+# _LT_CMD_RELOAD
+# --------------
+# find reload flag for linker
+# -- PORTME Some linkers may need a different reload flag.
+m4_defun([_LT_CMD_RELOAD],
+[AC_CACHE_CHECK([for $LD option to reload object files],
+ lt_cv_ld_reload_flag,
+ [lt_cv_ld_reload_flag='-r'])
+reload_flag=$lt_cv_ld_reload_flag
+case $reload_flag in
+"" | " "*) ;;
+*) reload_flag=" $reload_flag" ;;
+esac
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+case $host_os in
+ cygwin* | mingw* | pw32* | cegcc*)
+ if test "$GCC" != yes; then
+ reload_cmds=false
+ fi
+ ;;
+ darwin*)
+ if test "$GCC" = yes; then
+ reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
+ else
+ reload_cmds='$LD$reload_flag -o $output$reload_objs'
+ fi
+ ;;
+esac
+_LT_TAGDECL([], [reload_flag], [1], [How to create reloadable object files])dnl
+_LT_TAGDECL([], [reload_cmds], [2])dnl
+])# _LT_CMD_RELOAD
+
+
+# _LT_CHECK_MAGIC_METHOD
+# ----------------------
+# how to check for library dependencies
+# -- PORTME fill in with the dynamic library characteristics
+m4_defun([_LT_CHECK_MAGIC_METHOD],
+[m4_require([_LT_DECL_EGREP])
+m4_require([_LT_DECL_OBJDUMP])
+AC_CACHE_CHECK([how to recognize dependent libraries],
+lt_cv_deplibs_check_method,
+[lt_cv_file_magic_cmd='$MAGIC_CMD'
+lt_cv_file_magic_test_file=
+lt_cv_deplibs_check_method='unknown'
+# Need to set the preceding variable on all platforms that support
+# interlibrary dependencies.
+# 'none' -- dependencies not supported.
+# `unknown' -- same as none, but documents that we really don't know.
+# 'pass_all' -- all dependencies passed with no checks.
+# 'test_compile' -- check by making test program.
+# 'file_magic [[regex]]' -- check by looking for files in library path
+# which responds to the $file_magic_cmd with a given extended regex.
+# If you have `file' or equivalent on your system and you're not sure
+# whether `pass_all' will *always* work, you probably want this one.
+
+case $host_os in
+aix[[4-9]]*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+beos*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+bsdi[[45]]*)
+ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
+ lt_cv_file_magic_cmd='/usr/bin/file -L'
+ lt_cv_file_magic_test_file=/shlib/libc.so
+ ;;
+
+cygwin*)
+ # func_win32_libid is a shell function defined in ltmain.sh
+ lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+ lt_cv_file_magic_cmd='func_win32_libid'
+ ;;
+
+mingw* | pw32*)
+ # Base MSYS/MinGW do not provide the 'file' command needed by
+ # func_win32_libid shell function, so use a weaker test based on 'objdump',
+ # unless we find 'file', for example because we are cross-compiling.
+ # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.
+ if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then
+ lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+ lt_cv_file_magic_cmd='func_win32_libid'
+ else
+ # Keep this pattern in sync with the one in func_win32_libid.
+ lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)'
+ lt_cv_file_magic_cmd='$OBJDUMP -f'
+ fi
+ ;;
+
+cegcc*)
+ # use the weaker test based on 'objdump'. See mingw*.
+ lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'
+ lt_cv_file_magic_cmd='$OBJDUMP -f'
+ ;;
+
+darwin* | rhapsody*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+freebsd* | dragonfly*)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+ case $host_cpu in
+ i*86 )
+ # Not sure whether the presence of OpenBSD here was a mistake.
+ # Let's accept both of them until this is cleared up.
+ lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
+ lt_cv_file_magic_cmd=/usr/bin/file
+ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
+ ;;
+ esac
+ else
+ lt_cv_deplibs_check_method=pass_all
+ fi
+ ;;
+
+gnu*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+haiku*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+hpux10.20* | hpux11*)
+ lt_cv_file_magic_cmd=/usr/bin/file
+ case $host_cpu in
+ ia64*)
+ lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
+ lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+ ;;
+ hppa*64*)
+ [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]']
+ lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+ ;;
+ *)
+ lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library'
+ lt_cv_file_magic_test_file=/usr/lib/libc.sl
+ ;;
+ esac
+ ;;
+
+interix[[3-9]]*)
+ # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
+ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
+ ;;
+
+irix5* | irix6* | nonstopux*)
+ case $LD in
+ *-32|*"-32 ") libmagic=32-bit;;
+ *-n32|*"-n32 ") libmagic=N32;;
+ *-64|*"-64 ") libmagic=64-bit;;
+ *) libmagic=never-match;;
+ esac
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+# This must be glibc/ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+netbsd* | netbsdelf*-gnu)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
+ else
+ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
+ fi
+ ;;
+
+newos6*)
+ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
+ lt_cv_file_magic_cmd=/usr/bin/file
+ lt_cv_file_magic_test_file=/usr/lib/libnls.so
+ ;;
+
+*nto* | *qnx*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+openbsd*)
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
+ else
+ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
+ fi
+ ;;
+
+osf3* | osf4* | osf5*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+rdos*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+solaris*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+sysv4 | sysv4.3*)
+ case $host_vendor in
+ motorola)
+ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
+ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
+ ;;
+ ncr)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+ sequent)
+ lt_cv_file_magic_cmd='/bin/file'
+ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
+ ;;
+ sni)
+ lt_cv_file_magic_cmd='/bin/file'
+ lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
+ lt_cv_file_magic_test_file=/lib/libc.so
+ ;;
+ siemens)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+ pc)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+ esac
+ ;;
+
+tpf*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+esac
+])
+
+file_magic_glob=
+want_nocaseglob=no
+if test "$build" = "$host"; then
+ case $host_os in
+ mingw* | pw32*)
+ if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then
+ want_nocaseglob=yes
+ else
+ file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"`
+ fi
+ ;;
+ esac
+fi
+
+file_magic_cmd=$lt_cv_file_magic_cmd
+deplibs_check_method=$lt_cv_deplibs_check_method
+test -z "$deplibs_check_method" && deplibs_check_method=unknown
+
+_LT_DECL([], [deplibs_check_method], [1],
+ [Method to check whether dependent libraries are shared objects])
+_LT_DECL([], [file_magic_cmd], [1],
+ [Command to use when deplibs_check_method = "file_magic"])
+_LT_DECL([], [file_magic_glob], [1],
+ [How to find potential files when deplibs_check_method = "file_magic"])
+_LT_DECL([], [want_nocaseglob], [1],
+ [Find potential files using nocaseglob when deplibs_check_method = "file_magic"])
+])# _LT_CHECK_MAGIC_METHOD
+
+
+# LT_PATH_NM
+# ----------
+# find the pathname to a BSD- or MS-compatible name lister
+AC_DEFUN([LT_PATH_NM],
+[AC_REQUIRE([AC_PROG_CC])dnl
+AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,
+[if test -n "$NM"; then
+ # Let the user override the test.
+ lt_cv_path_NM="$NM"
+else
+ lt_nm_to_check="${ac_tool_prefix}nm"
+ if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+ lt_nm_to_check="$lt_nm_to_check nm"
+ fi
+ for lt_tmp_nm in $lt_nm_to_check; do
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ tmp_nm="$ac_dir/$lt_tmp_nm"
+ if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+ # Check to see if the nm accepts a BSD-compat flag.
+ # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+ # nm: unknown option "B" ignored
+ # Tru64's nm complains that /dev/null is an invalid object file
+ case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+ */dev/null* | *'Invalid file or object type'*)
+ lt_cv_path_NM="$tmp_nm -B"
+ break
+ ;;
+ *)
+ case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+ */dev/null*)
+ lt_cv_path_NM="$tmp_nm -p"
+ break
+ ;;
+ *)
+ lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+ continue # so that we can try to find one that supports BSD flags
+ ;;
+ esac
+ ;;
+ esac
+ fi
+ done
+ IFS="$lt_save_ifs"
+ done
+ : ${lt_cv_path_NM=no}
+fi])
+if test "$lt_cv_path_NM" != "no"; then
+ NM="$lt_cv_path_NM"
+else
+ # Didn't find any BSD compatible name lister, look for dumpbin.
+ if test -n "$DUMPBIN"; then :
+ # Let the user override the test.
+ else
+ AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :)
+ case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in
+ *COFF*)
+ DUMPBIN="$DUMPBIN -symbols"
+ ;;
+ *)
+ DUMPBIN=:
+ ;;
+ esac
+ fi
+ AC_SUBST([DUMPBIN])
+ if test "$DUMPBIN" != ":"; then
+ NM="$DUMPBIN"
+ fi
+fi
+test -z "$NM" && NM=nm
+AC_SUBST([NM])
+_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl
+
+AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface],
+ [lt_cv_nm_interface="BSD nm"
+ echo "int some_variable = 0;" > conftest.$ac_ext
+ (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD)
+ (eval "$ac_compile" 2>conftest.err)
+ cat conftest.err >&AS_MESSAGE_LOG_FD
+ (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD)
+ (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
+ cat conftest.err >&AS_MESSAGE_LOG_FD
+ (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD)
+ cat conftest.out >&AS_MESSAGE_LOG_FD
+ if $GREP 'External.*some_variable' conftest.out > /dev/null; then
+ lt_cv_nm_interface="MS dumpbin"
+ fi
+ rm -f conftest*])
+])# LT_PATH_NM
+
+# Old names:
+AU_ALIAS([AM_PROG_NM], [LT_PATH_NM])
+AU_ALIAS([AC_PROG_NM], [LT_PATH_NM])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_PROG_NM], [])
+dnl AC_DEFUN([AC_PROG_NM], [])
+
+# _LT_CHECK_SHAREDLIB_FROM_LINKLIB
+# --------------------------------
+# how to determine the name of the shared library
+# associated with a specific link library.
+# -- PORTME fill in with the dynamic library characteristics
+m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB],
+[m4_require([_LT_DECL_EGREP])
+m4_require([_LT_DECL_OBJDUMP])
+m4_require([_LT_DECL_DLLTOOL])
+AC_CACHE_CHECK([how to associate runtime and link libraries],
+lt_cv_sharedlib_from_linklib_cmd,
+[lt_cv_sharedlib_from_linklib_cmd='unknown'
+
+case $host_os in
+cygwin* | mingw* | pw32* | cegcc*)
+ # two different shell functions defined in ltmain.sh
+ # decide which to use based on capabilities of $DLLTOOL
+ case `$DLLTOOL --help 2>&1` in
+ *--identify-strict*)
+ lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib
+ ;;
+ *)
+ lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback
+ ;;
+ esac
+ ;;
+*)
+ # fallback: assume linklib IS sharedlib
+ lt_cv_sharedlib_from_linklib_cmd="$ECHO"
+ ;;
+esac
+])
+sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd
+test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO
+
+_LT_DECL([], [sharedlib_from_linklib_cmd], [1],
+ [Command to associate shared and link libraries])
+])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB
+
+
+# _LT_PATH_MANIFEST_TOOL
+# ----------------------
+# locate the manifest tool
+m4_defun([_LT_PATH_MANIFEST_TOOL],
+[AC_CHECK_TOOL(MANIFEST_TOOL, mt, :)
+test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt
+AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool],
+ [lt_cv_path_mainfest_tool=no
+ echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD
+ $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out
+ cat conftest.err >&AS_MESSAGE_LOG_FD
+ if $GREP 'Manifest Tool' conftest.out > /dev/null; then
+ lt_cv_path_mainfest_tool=yes
+ fi
+ rm -f conftest*])
+if test "x$lt_cv_path_mainfest_tool" != xyes; then
+ MANIFEST_TOOL=:
+fi
+_LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl
+])# _LT_PATH_MANIFEST_TOOL
+
+
+# LT_LIB_M
+# --------
+# check for math library
+AC_DEFUN([LT_LIB_M],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+LIBM=
+case $host in
+*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*)
+ # These system don't have libm, or don't need it
+ ;;
+*-ncr-sysv4.3*)
+ AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
+ AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
+ ;;
+*)
+ AC_CHECK_LIB(m, cos, LIBM="-lm")
+ ;;
+esac
+AC_SUBST([LIBM])
+])# LT_LIB_M
+
+# Old name:
+AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_CHECK_LIBM], [])
+
+
+# _LT_COMPILER_NO_RTTI([TAGNAME])
+# -------------------------------
+m4_defun([_LT_COMPILER_NO_RTTI],
+[m4_require([_LT_TAG_COMPILER])dnl
+
+_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+
+if test "$GCC" = yes; then
+ case $cc_basename in
+ nvcc*)
+ _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;;
+ esac
+
+ _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
+ lt_cv_prog_compiler_rtti_exceptions,
+ [-fno-rtti -fno-exceptions], [],
+ [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
+fi
+_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1],
+ [Compiler flag to turn off builtin functions])
+])# _LT_COMPILER_NO_RTTI
+
+
+# _LT_CMD_GLOBAL_SYMBOLS
+# ----------------------
+m4_defun([_LT_CMD_GLOBAL_SYMBOLS],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_PROG_AWK])dnl
+AC_REQUIRE([LT_PATH_NM])dnl
+AC_REQUIRE([LT_PATH_LD])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_TAG_COMPILER])dnl
+
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+AC_MSG_CHECKING([command to parse $NM output from $compiler object])
+AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
+[
+# These are sane defaults that work on at least a few old systems.
+# [They come from Ultrix. What could be older than Ultrix?!! ;)]
+
+# Character class describing NM global symbol codes.
+symcode='[[BCDEGRST]]'
+
+# Regexp to match symbols that can be accessed directly from C.
+sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
+
+# Define system-specific variables.
+case $host_os in
+aix*)
+ symcode='[[BCDT]]'
+ ;;
+cygwin* | mingw* | pw32* | cegcc*)
+ symcode='[[ABCDGISTW]]'
+ ;;
+hpux*)
+ if test "$host_cpu" = ia64; then
+ symcode='[[ABCDEGRST]]'
+ fi
+ ;;
+irix* | nonstopux*)
+ symcode='[[BCDEGRST]]'
+ ;;
+osf*)
+ symcode='[[BCDEGQRST]]'
+ ;;
+solaris*)
+ symcode='[[BDRT]]'
+ ;;
+sco3.2v5*)
+ symcode='[[DT]]'
+ ;;
+sysv4.2uw2*)
+ symcode='[[DT]]'
+ ;;
+sysv5* | sco5v6* | unixware* | OpenUNIX*)
+ symcode='[[ABDT]]'
+ ;;
+sysv4)
+ symcode='[[DFNSTU]]'
+ ;;
+esac
+
+# If we're using GNU nm, then use its standard symbol codes.
+case `$NM -V 2>&1` in
+*GNU* | *'with BFD'*)
+ symcode='[[ABCDGIRSTW]]' ;;
+esac
+
+# Transform an extracted symbol line into a proper C declaration.
+# Some systems (esp. on ia64) link data and code symbols differently,
+# so use this general approach.
+lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+
+# Transform an extracted symbol line into symbol name and symbol address
+lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'"
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'"
+
+# Handle CRLF in mingw tool chain
+opt_cr=
+case $build_os in
+mingw*)
+ opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
+ ;;
+esac
+
+# Try without a prefix underscore, then with it.
+for ac_symprfx in "" "_"; do
+
+ # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
+ symxfrm="\\1 $ac_symprfx\\2 \\2"
+
+ # Write the raw and C identifiers.
+ if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+ # Fake it for dumpbin and say T for any non-static function
+ # and D for any global variable.
+ # Also find C++ and __fastcall symbols from MSVC++,
+ # which start with @ or ?.
+ lt_cv_sys_global_symbol_pipe="$AWK ['"\
+" {last_section=section; section=\$ 3};"\
+" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\
+" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
+" \$ 0!~/External *\|/{next};"\
+" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
+" {if(hide[section]) next};"\
+" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
+" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
+" s[1]~/^[@?]/{print s[1], s[1]; next};"\
+" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
+" ' prfx=^$ac_symprfx]"
+ else
+ lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+ fi
+ lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'"
+
+ # Check to see that the pipe works correctly.
+ pipe_works=no
+
+ rm -f conftest*
+ cat > conftest.$ac_ext <<_LT_EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(void);
+void nm_test_func(void){}
+#ifdef __cplusplus
+}
+#endif
+int main(){nm_test_var='a';nm_test_func();return(0);}
+_LT_EOF
+
+ if AC_TRY_EVAL(ac_compile); then
+ # Now try to grab the symbols.
+ nlist=conftest.nm
+ if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then
+ # Try sorting and uniquifying the output.
+ if sort "$nlist" | uniq > "$nlist"T; then
+ mv -f "$nlist"T "$nlist"
+ else
+ rm -f "$nlist"T
+ fi
+
+ # Make sure that we snagged all the symbols we need.
+ if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
+ if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
+ cat <<_LT_EOF > conftest.$ac_ext
+/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */
+#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
+/* DATA imports from DLLs on WIN32 con't be const, because runtime
+ relocations are performed -- see ld's documentation on pseudo-relocs. */
+# define LT@&t@_DLSYM_CONST
+#elif defined(__osf__)
+/* This system does not cope well with relocations in const data. */
+# define LT@&t@_DLSYM_CONST
+#else
+# define LT@&t@_DLSYM_CONST const
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+_LT_EOF
+ # Now generate the symbol file.
+ eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
+
+ cat <<_LT_EOF >> conftest.$ac_ext
+
+/* The mapping between symbol names and symbols. */
+LT@&t@_DLSYM_CONST struct {
+ const char *name;
+ void *address;
+}
+lt__PROGRAM__LTX_preloaded_symbols[[]] =
+{
+ { "@PROGRAM@", (void *) 0 },
+_LT_EOF
+ $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+ cat <<\_LT_EOF >> conftest.$ac_ext
+ {0, (void *) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+ return lt__PROGRAM__LTX_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+_LT_EOF
+ # Now try linking the two files.
+ mv conftest.$ac_objext conftstm.$ac_objext
+ lt_globsym_save_LIBS=$LIBS
+ lt_globsym_save_CFLAGS=$CFLAGS
+ LIBS="conftstm.$ac_objext"
+ CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
+ if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
+ pipe_works=yes
+ fi
+ LIBS=$lt_globsym_save_LIBS
+ CFLAGS=$lt_globsym_save_CFLAGS
+ else
+ echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
+ fi
+ else
+ echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
+ fi
+ else
+ echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
+ fi
+ else
+ echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
+ cat conftest.$ac_ext >&5
+ fi
+ rm -rf conftest* conftst*
+
+ # Do not use the global_symbol_pipe unless it works.
+ if test "$pipe_works" = yes; then
+ break
+ else
+ lt_cv_sys_global_symbol_pipe=
+ fi
+done
+])
+if test -z "$lt_cv_sys_global_symbol_pipe"; then
+ lt_cv_sys_global_symbol_to_cdecl=
+fi
+if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
+ AC_MSG_RESULT(failed)
+else
+ AC_MSG_RESULT(ok)
+fi
+
+# Response file support.
+if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+ nm_file_list_spec='@'
+elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then
+ nm_file_list_spec='@'
+fi
+
+_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1],
+ [Take the output of nm and produce a listing of raw symbols and C names])
+_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1],
+ [Transform the output of nm in a proper C declaration])
+_LT_DECL([global_symbol_to_c_name_address],
+ [lt_cv_sys_global_symbol_to_c_name_address], [1],
+ [Transform the output of nm in a C name address pair])
+_LT_DECL([global_symbol_to_c_name_address_lib_prefix],
+ [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1],
+ [Transform the output of nm in a C name address pair when lib prefix is needed])
+_LT_DECL([], [nm_file_list_spec], [1],
+ [Specify filename containing input files for $NM])
+]) # _LT_CMD_GLOBAL_SYMBOLS
+
+
+# _LT_COMPILER_PIC([TAGNAME])
+# ---------------------------
+m4_defun([_LT_COMPILER_PIC],
+[m4_require([_LT_TAG_COMPILER])dnl
+_LT_TAGVAR(lt_prog_compiler_wl, $1)=
+_LT_TAGVAR(lt_prog_compiler_pic, $1)=
+_LT_TAGVAR(lt_prog_compiler_static, $1)=
+
+m4_if([$1], [CXX], [
+ # C++ specific cases for pic, static, wl, etc.
+ if test "$GXX" = yes; then
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+ case $host_os in
+ aix*)
+ # All AIX code is PIC.
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ fi
+ ;;
+
+ amigaos*)
+ case $host_cpu in
+ powerpc)
+ # see comment about AmigaOS4 .so support
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ m68k)
+ # FIXME: we need at least 68020 code to build shared libraries, but
+ # adding the `-m68020' flag to GCC prevents building anything better,
+ # like `-m68040'.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+ ;;
+ esac
+ ;;
+
+ beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+ # PIC is the default for these OSes.
+ ;;
+ mingw* | cygwin* | os2* | pw32* | cegcc*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ # Although the cygwin gcc ignores -fPIC, still need this for old-style
+ # (--disable-auto-import) libraries
+ m4_if([$1], [GCJ], [],
+ [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+ ;;
+ darwin* | rhapsody*)
+ # PIC is the default on this platform
+ # Common symbols not allowed in MH_DYLIB files
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+ ;;
+ *djgpp*)
+ # DJGPP does not support shared libraries at all
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+ ;;
+ haiku*)
+ # PIC is the default for Haiku.
+ # The "-static" flag exists, but is broken.
+ _LT_TAGVAR(lt_prog_compiler_static, $1)=
+ ;;
+ interix[[3-9]]*)
+ # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+ # Instead, we relocate shared libraries at runtime.
+ ;;
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
+ fi
+ ;;
+ hpux*)
+ # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
+ # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag
+ # sets the default TLS model and affects inlining.
+ case $host_cpu in
+ hppa*64*)
+ ;;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ esac
+ ;;
+ *qnx* | *nto*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+ ;;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ esac
+ else
+ case $host_os in
+ aix[[4-9]]*)
+ # All AIX code is PIC.
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ else
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+ fi
+ ;;
+ chorus*)
+ case $cc_basename in
+ cxch68*)
+ # Green Hills C++ Compiler
+ # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
+ ;;
+ esac
+ ;;
+ mingw* | cygwin* | os2* | pw32* | cegcc*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ m4_if([$1], [GCJ], [],
+ [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+ ;;
+ dgux*)
+ case $cc_basename in
+ ec++*)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ ;;
+ ghcx*)
+ # Green Hills C++ Compiler
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ freebsd* | dragonfly*)
+ # FreeBSD uses GNU C++
+ ;;
+ hpux9* | hpux10* | hpux11*)
+ case $cc_basename in
+ CC*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+ if test "$host_cpu" != ia64; then
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+ fi
+ ;;
+ aCC*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+ case $host_cpu in
+ hppa*64*|ia64*)
+ # +Z the default
+ ;;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+ ;;
+ esac
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ interix*)
+ # This is c89, which is MS Visual C++ (no shared libs)
+ # Anyone wants to do a port?
+ ;;
+ irix5* | irix6* | nonstopux*)
+ case $cc_basename in
+ CC*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ # CC pic flag -KPIC is the default.
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ case $cc_basename in
+ KCC*)
+ # KAI C++ Compiler
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ ecpc* )
+ # old Intel C++ for x86_64 which still supported -KPIC.
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+ ;;
+ icpc* )
+ # Intel C++, used to be incompatible with GCC.
+ # ICC 10 doesn't accept -KPIC any more.
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+ ;;
+ pgCC* | pgcpp*)
+ # Portland Group C++ compiler
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+ cxx*)
+ # Compaq C++
+ # Make sure the PIC flag is empty. It appears that all Alpha
+ # Linux and Compaq Tru64 Unix objects are PIC.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+ xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*)
+ # IBM XL 8.0, 9.0 on PPC and BlueGene
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
+ ;;
+ *)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*)
+ # Sun C++ 5.9
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+ lynxos*)
+ ;;
+ m88k*)
+ ;;
+ mvs*)
+ case $cc_basename in
+ cxx*)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ netbsd* | netbsdelf*-gnu)
+ ;;
+ *qnx* | *nto*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+ ;;
+ osf3* | osf4* | osf5*)
+ case $cc_basename in
+ KCC*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+ ;;
+ RCC*)
+ # Rational C++ 2.4.1
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+ ;;
+ cxx*)
+ # Digital/Compaq C++
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ # Make sure the PIC flag is empty. It appears that all Alpha
+ # Linux and Compaq Tru64 Unix objects are PIC.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ psos*)
+ ;;
+ solaris*)
+ case $cc_basename in
+ CC* | sunCC*)
+ # Sun C++ 4.2, 5.x and Centerline C++
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+ ;;
+ gcx*)
+ # Green Hills C++ Compiler
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ sunos4*)
+ case $cc_basename in
+ CC*)
+ # Sun C++ 4.x
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+ lcc*)
+ # Lucid
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+ case $cc_basename in
+ CC*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+ esac
+ ;;
+ tandem*)
+ case $cc_basename in
+ NCC*)
+ # NonStop-UX NCC 3.20
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ vxworks*)
+ ;;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+ ;;
+ esac
+ fi
+],
+[
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+ case $host_os in
+ aix*)
+ # All AIX code is PIC.
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ fi
+ ;;
+
+ amigaos*)
+ case $host_cpu in
+ powerpc)
+ # see comment about AmigaOS4 .so support
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ m68k)
+ # FIXME: we need at least 68020 code to build shared libraries, but
+ # adding the `-m68020' flag to GCC prevents building anything better,
+ # like `-m68040'.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+ ;;
+ esac
+ ;;
+
+ beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+ # PIC is the default for these OSes.
+ ;;
+
+ mingw* | cygwin* | pw32* | os2* | cegcc*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ # Although the cygwin gcc ignores -fPIC, still need this for old-style
+ # (--disable-auto-import) libraries
+ m4_if([$1], [GCJ], [],
+ [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+ ;;
+
+ darwin* | rhapsody*)
+ # PIC is the default on this platform
+ # Common symbols not allowed in MH_DYLIB files
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+ ;;
+
+ haiku*)
+ # PIC is the default for Haiku.
+ # The "-static" flag exists, but is broken.
+ _LT_TAGVAR(lt_prog_compiler_static, $1)=
+ ;;
+
+ hpux*)
+ # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
+ # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag
+ # sets the default TLS model and affects inlining.
+ case $host_cpu in
+ hppa*64*)
+ # +Z the default
+ ;;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ esac
+ ;;
+
+ interix[[3-9]]*)
+ # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+ # Instead, we relocate shared libraries at runtime.
+ ;;
+
+ msdosdjgpp*)
+ # Just because we use GCC doesn't mean we suddenly get shared libraries
+ # on systems that don't support them.
+ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+ enable_shared=no
+ ;;
+
+ *nto* | *qnx*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
+ fi
+ ;;
+
+ *)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ esac
+
+ case $cc_basename in
+ nvcc*) # Cuda Compiler Driver 2.2
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker '
+ if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)"
+ fi
+ ;;
+ esac
+ else
+ # PORTME Check for flag to pass linker flags through the system compiler.
+ case $host_os in
+ aix*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ else
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+ fi
+ ;;
+
+ mingw* | cygwin* | pw32* | os2* | cegcc*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ m4_if([$1], [GCJ], [],
+ [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+ ;;
+
+ hpux9* | hpux10* | hpux11*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+ # not for PA HP-UX.
+ case $host_cpu in
+ hppa*64*|ia64*)
+ # +Z the default
+ ;;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+ ;;
+ esac
+ # Is there a better lt_prog_compiler_static that works with the bundled CC?
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+ ;;
+
+ irix5* | irix6* | nonstopux*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ # PIC (with -KPIC) is the default.
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+
+ linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ case $cc_basename in
+ # old Intel for x86_64 which still supported -KPIC.
+ ecc*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+ ;;
+ # icc used to be incompatible with GCC.
+ # ICC 10 doesn't accept -KPIC any more.
+ icc* | ifort*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+ ;;
+ # Lahey Fortran 8.1.
+ lf95*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='--static'
+ ;;
+ nagfor*)
+ # NAG Fortran compiler
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+ pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
+ # Portland Group compilers (*not* the Pentium gcc compiler,
+ # which looks to be a dead project)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+ ccc*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ # All Alpha code is PIC.
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+ xl* | bgxl* | bgf* | mpixl*)
+ # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
+ ;;
+ *)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*)
+ # Sun Fortran 8.3 passes all unrecognized flags to the linker
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)=''
+ ;;
+ *Sun\ F* | *Sun*Fortran*)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+ ;;
+ *Sun\ C*)
+ # Sun C 5.9
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ ;;
+ *Intel*\ [[CF]]*Compiler*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+ ;;
+ *Portland\ Group*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+
+ newsos6)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+
+ *nto* | *qnx*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+ ;;
+
+ osf3* | osf4* | osf5*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ # All OSF/1 code is PIC.
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+
+ rdos*)
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+
+ solaris*)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ case $cc_basename in
+ f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
+ esac
+ ;;
+
+ sunos4*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+
+ sysv4 | sysv4.2uw2* | sysv4.3*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec ;then
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ fi
+ ;;
+
+ sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+
+ unicos*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+ ;;
+
+ uts4*)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+
+ *)
+ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+ ;;
+ esac
+ fi
+])
+case $host_os in
+ # For platforms which do not support PIC, -DPIC is meaningless:
+ *djgpp*)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+ ;;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])"
+ ;;
+esac
+
+AC_CACHE_CHECK([for $compiler option to produce PIC],
+ [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)],
+ [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)])
+_LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then
+ _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works],
+ [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)],
+ [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [],
+ [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in
+ "" | " "*) ;;
+ *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;;
+ esac],
+ [_LT_TAGVAR(lt_prog_compiler_pic, $1)=
+ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
+fi
+_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1],
+ [Additional compiler flags for building library objects])
+
+_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1],
+ [How to pass a linker flag through the compiler])
+#
+# Check to make sure the static flag actually works.
+#
+wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\"
+_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
+ _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1),
+ $lt_tmp_static_flag,
+ [],
+ [_LT_TAGVAR(lt_prog_compiler_static, $1)=])
+_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1],
+ [Compiler flag to prevent dynamic linking])
+])# _LT_COMPILER_PIC
+
+
+# _LT_LINKER_SHLIBS([TAGNAME])
+# ----------------------------
+# See if the linker supports building shared libraries.
+m4_defun([_LT_LINKER_SHLIBS],
+[AC_REQUIRE([LT_PATH_LD])dnl
+AC_REQUIRE([LT_PATH_NM])dnl
+m4_require([_LT_PATH_MANIFEST_TOOL])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
+m4_require([_LT_TAG_COMPILER])dnl
+AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+m4_if([$1], [CXX], [
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
+ case $host_os in
+ aix[[4-9]]*)
+ # If we're using GNU nm, then we don't want the "-C" option.
+ # -C means demangle to AIX nm, but means don't demangle with GNU nm
+ # Also, AIX nm treats weak defined symbols like other global defined
+ # symbols, whereas GNU nm marks them as "W".
+ if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ else
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ fi
+ ;;
+ pw32*)
+ _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
+ ;;
+ cygwin* | mingw* | cegcc*)
+ case $cc_basename in
+ cl*)
+ _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
+ ;;
+ *)
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols'
+ _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname']
+ ;;
+ esac
+ ;;
+ linux* | k*bsd*-gnu | gnu*)
+ _LT_TAGVAR(link_all_deplibs, $1)=no
+ ;;
+ *)
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ ;;
+ esac
+], [
+ runpath_var=
+ _LT_TAGVAR(allow_undefined_flag, $1)=
+ _LT_TAGVAR(always_export_symbols, $1)=no
+ _LT_TAGVAR(archive_cmds, $1)=
+ _LT_TAGVAR(archive_expsym_cmds, $1)=
+ _LT_TAGVAR(compiler_needs_object, $1)=no
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)=
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ _LT_TAGVAR(hardcode_automatic, $1)=no
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=no
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=
+ _LT_TAGVAR(hardcode_minus_L, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+ _LT_TAGVAR(inherit_rpath, $1)=no
+ _LT_TAGVAR(link_all_deplibs, $1)=unknown
+ _LT_TAGVAR(module_cmds, $1)=
+ _LT_TAGVAR(module_expsym_cmds, $1)=
+ _LT_TAGVAR(old_archive_from_new_cmds, $1)=
+ _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)=
+ _LT_TAGVAR(thread_safe_flag_spec, $1)=
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=
+ # include_expsyms should be a list of space-separated symbols to be *always*
+ # included in the symbol list
+ _LT_TAGVAR(include_expsyms, $1)=
+ # exclude_expsyms can be an extended regexp of symbols to exclude
+ # it will be wrapped by ` (' and `)$', so one must not match beginning or
+ # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+ # as well as any symbol that contains `d'.
+ _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
+ # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+ # platforms (ab)use it in PIC code, but their linkers get confused if
+ # the symbol is explicitly referenced. Since portable code cannot
+ # rely on this symbol name, it's probably fine to never include it in
+ # preloaded symbol tables.
+ # Exclude shared library initialization/finalization symbols.
+dnl Note also adjust exclude_expsyms for C++ above.
+ extract_expsyms_cmds=
+
+ case $host_os in
+ cygwin* | mingw* | pw32* | cegcc*)
+ # FIXME: the MSVC++ port hasn't been tested in a loooong time
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ if test "$GCC" != yes; then
+ with_gnu_ld=no
+ fi
+ ;;
+ interix*)
+ # we just hope/assume this is gcc and not c89 (= MSVC++)
+ with_gnu_ld=yes
+ ;;
+ openbsd*)
+ with_gnu_ld=no
+ ;;
+ linux* | k*bsd*-gnu | gnu*)
+ _LT_TAGVAR(link_all_deplibs, $1)=no
+ ;;
+ esac
+
+ _LT_TAGVAR(ld_shlibs, $1)=yes
+
+ # On some targets, GNU ld is compatible enough with the native linker
+ # that we're better off using the native interface for both.
+ lt_use_gnu_ld_interface=no
+ if test "$with_gnu_ld" = yes; then
+ case $host_os in
+ aix*)
+ # The AIX port of GNU ld has always aspired to compatibility
+ # with the native linker. However, as the warning in the GNU ld
+ # block says, versions before 2.19.5* couldn't really create working
+ # shared libraries, regardless of the interface used.
+ case `$LD -v 2>&1` in
+ *\ \(GNU\ Binutils\)\ 2.19.5*) ;;
+ *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;;
+ *\ \(GNU\ Binutils\)\ [[3-9]]*) ;;
+ *)
+ lt_use_gnu_ld_interface=yes
+ ;;
+ esac
+ ;;
+ *)
+ lt_use_gnu_ld_interface=yes
+ ;;
+ esac
+ fi
+
+ if test "$lt_use_gnu_ld_interface" = yes; then
+ # If archive_cmds runs LD, not CC, wlarc should be empty
+ wlarc='${wl}'
+
+ # Set some defaults for GNU ld with shared library support. These
+ # are reset later if shared libraries are not supported. Putting them
+ # here allows them to be overridden if necessary.
+ runpath_var=LD_RUN_PATH
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+ # ancient GNU ld didn't support --whole-archive et. al.
+ if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
+ _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ else
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=
+ fi
+ supports_anon_versioning=no
+ case `$LD -v 2>&1` in
+ *GNU\ gold*) supports_anon_versioning=yes ;;
+ *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
+ *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+ *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+ *\ 2.11.*) ;; # other 2.11 versions
+ *) supports_anon_versioning=yes ;;
+ esac
+
+ # See if GNU ld supports shared libraries.
+ case $host_os in
+ aix[[3-9]]*)
+ # On AIX/PPC, the GNU linker is very broken
+ if test "$host_cpu" != ia64; then
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ cat <<_LT_EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.19, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support. If you
+*** really care for shared libraries, you may want to install binutils
+*** 2.20 or above, or modify your PATH so that a non-GNU linker is found.
+*** You will then need to restart the configuration process.
+
+_LT_EOF
+ fi
+ ;;
+
+ amigaos*)
+ case $host_cpu in
+ powerpc)
+ # see comment about AmigaOS4 .so support
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)=''
+ ;;
+ m68k)
+ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ ;;
+ esac
+ ;;
+
+ beos*)
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+ # support --undefined. This deserves some investigation. FIXME
+ _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ cygwin* | mingw* | pw32* | cegcc*)
+ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+ # as there is no search path for DLLs.
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols'
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ _LT_TAGVAR(always_export_symbols, $1)=no
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols'
+ _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname']
+
+ if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ # If the export-symbols file already is a .def file (1st line
+ # is EXPORTS), use it as is; otherwise, prepend...
+ _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+ cp $export_symbols $output_objdir/$soname.def;
+ else
+ echo EXPORTS > $output_objdir/$soname.def;
+ cat $export_symbols >> $output_objdir/$soname.def;
+ fi~
+ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ haiku*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ ;;
+
+ interix[[3-9]]*)
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+ # Instead, shared libraries are loaded at an image base (0x10000000 by
+ # default) and relocated if they conflict, which is a slow very memory
+ # consuming and fragmenting process. To avoid this, we pick a random,
+ # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+ # time. Moving up from 0x10000000 also allows more sbrk(2) space.
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ ;;
+
+ gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
+ tmp_diet=no
+ if test "$host_os" = linux-dietlibc; then
+ case $cc_basename in
+ diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn)
+ esac
+ fi
+ if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
+ && test "$tmp_diet" = no
+ then
+ tmp_addflag=' $pic_flag'
+ tmp_sharedflag='-shared'
+ case $cc_basename,$host_cpu in
+ pgcc*) # Portland Group C compiler
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+ tmp_addflag=' $pic_flag'
+ ;;
+ pgf77* | pgf90* | pgf95* | pgfortran*)
+ # Portland Group f77 and f90 compilers
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+ tmp_addflag=' $pic_flag -Mnomain' ;;
+ ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
+ tmp_addflag=' -i_dynamic' ;;
+ efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
+ tmp_addflag=' -i_dynamic -nofor_main' ;;
+ ifc* | ifort*) # Intel Fortran compiler
+ tmp_addflag=' -nofor_main' ;;
+ lf95*) # Lahey Fortran 8.1
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=
+ tmp_sharedflag='--shared' ;;
+ xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below)
+ tmp_sharedflag='-qmkshrobj'
+ tmp_addflag= ;;
+ nvcc*) # Cuda Compiler Driver 2.2
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+ _LT_TAGVAR(compiler_needs_object, $1)=yes
+ ;;
+ esac
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*) # Sun C 5.9
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+ _LT_TAGVAR(compiler_needs_object, $1)=yes
+ tmp_sharedflag='-G' ;;
+ *Sun\ F*) # Sun Fortran 8.3
+ tmp_sharedflag='-G' ;;
+ esac
+ _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+ if test "x$supports_anon_versioning" = xyes; then
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
+ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+ echo "local: *; };" >> $output_objdir/$libname.ver~
+ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+ fi
+
+ case $cc_basename in
+ xlf* | bgf* | bgxlf* | mpixlf*)
+ # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
+ if test "x$supports_anon_versioning" = xyes; then
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
+ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+ echo "local: *; };" >> $output_objdir/$libname.ver~
+ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+ fi
+ ;;
+ esac
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ netbsd* | netbsdelf*-gnu)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+ wlarc=
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ fi
+ ;;
+
+ solaris*)
+ if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ cat <<_LT_EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems. Therefore, libtool
+*** is disabling shared libraries support. We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer. Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+ elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+ case `$LD -v 2>&1` in
+ *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*)
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ cat <<_LT_EOF 1>&2
+
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** reliably create shared libraries on SCO systems. Therefore, libtool
+*** is disabling shared libraries support. We urge you to upgrade GNU
+*** binutils to release 2.16.91.0.3 or newer. Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+ ;;
+ *)
+ # For security reasons, it is highly recommended that you always
+ # use absolute paths for naming shared libraries, and exclude the
+ # DT_RUNPATH tag from executables and libraries. But doing so
+ # requires that you compile everything twice, which is a pain.
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ esac
+ ;;
+
+ sunos4*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ wlarc=
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ *)
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ esac
+
+ if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then
+ runpath_var=
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)=
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=
+ fi
+ else
+ # PORTME fill in a description of your system's linker (not GNU ld)
+ case $host_os in
+ aix3*)
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ _LT_TAGVAR(always_export_symbols, $1)=yes
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+ # Note: this linker hardcodes the directories in LIBPATH if there
+ # are no directories specified by -L.
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+ # Neither direct hardcoding nor static linking is supported with a
+ # broken collect2.
+ _LT_TAGVAR(hardcode_direct, $1)=unsupported
+ fi
+ ;;
+
+ aix[[4-9]]*)
+ if test "$host_cpu" = ia64; then
+ # On IA64, the linker does run time linking by default, so we don't
+ # have to do anything special.
+ aix_use_runtimelinking=no
+ exp_sym_flag='-Bexport'
+ no_entry_flag=""
+ else
+ # If we're using GNU nm, then we don't want the "-C" option.
+ # -C means demangle to AIX nm, but means don't demangle with GNU nm
+ # Also, AIX nm treats weak defined symbols like other global
+ # defined symbols, whereas GNU nm marks them as "W".
+ if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ else
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ fi
+ aix_use_runtimelinking=no
+
+ # Test if we are trying to use run time linking or normal
+ # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+ # need to do runtime linking.
+ case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
+ for ld_flag in $LDFLAGS; do
+ if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+ aix_use_runtimelinking=yes
+ break
+ fi
+ done
+ ;;
+ esac
+
+ exp_sym_flag='-bexport'
+ no_entry_flag='-bnoentry'
+ fi
+
+ # When large executables or shared objects are built, AIX ld can
+ # have problems creating the table of contents. If linking a library
+ # or program results in "error TOC overflow" add -mminimal-toc to
+ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
+ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+ _LT_TAGVAR(archive_cmds, $1)=''
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+
+ if test "$GCC" = yes; then
+ case $host_os in aix4.[[012]]|aix4.[[012]].*)
+ # We only want to do this on AIX 4.2 and lower, the check
+ # below for broken collect2 doesn't work under 4.3+
+ collect2name=`${CC} -print-prog-name=collect2`
+ if test -f "$collect2name" &&
+ strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+ then
+ # We have reworked collect2
+ :
+ else
+ # We have old collect2
+ _LT_TAGVAR(hardcode_direct, $1)=unsupported
+ # It fails to find uninstalled libraries when the uninstalled
+ # path is not listed in the libpath. Setting hardcode_minus_L
+ # to unsupported forces relinking
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=
+ fi
+ ;;
+ esac
+ shared_flag='-shared'
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag="$shared_flag "'${wl}-G'
+ fi
+ _LT_TAGVAR(link_all_deplibs, $1)=no
+ else
+ # not using gcc
+ if test "$host_cpu" = ia64; then
+ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+ # chokes on -Wl,-G. The following line is correct:
+ shared_flag='-G'
+ else
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag='${wl}-G'
+ else
+ shared_flag='${wl}-bM:SRE'
+ fi
+ fi
+ fi
+
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
+ # It seems that -bexpall does not export symbols beginning with
+ # underscore (_), so it is better to generate a list of symbols to export.
+ _LT_TAGVAR(always_export_symbols, $1)=yes
+ if test "$aix_use_runtimelinking" = yes; then
+ # Warning - without using the other runtime loading flags (-brtl),
+ # -berok will link without error, but may produce a broken library.
+ _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
+ # Determine the default libpath from the value encoded in an
+ # empty executable.
+ _LT_SYS_MODULE_PATH_AIX([$1])
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+ else
+ if test "$host_cpu" = ia64; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+ _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+ else
+ # Determine the default libpath from the value encoded in an
+ # empty executable.
+ _LT_SYS_MODULE_PATH_AIX([$1])
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+ # Warning - without using the other run time loading flags,
+ # -berok will link without error, but may produce a broken library.
+ _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+ if test "$with_gnu_ld" = yes; then
+ # We only use this code for GNU lds that support --whole-archive.
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+ else
+ # Exported symbols can be pulled into shared objects from archives
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+ fi
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+ # This is similar to how AIX traditionally builds its shared libraries.
+ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+ fi
+ fi
+ ;;
+
+ amigaos*)
+ case $host_cpu in
+ powerpc)
+ # see comment about AmigaOS4 .so support
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)=''
+ ;;
+ m68k)
+ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ ;;
+ esac
+ ;;
+
+ bsdi[[45]]*)
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
+ ;;
+
+ cygwin* | mingw* | pw32* | cegcc*)
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ # hardcode_libdir_flag_spec is actually meaningless, as there is
+ # no search path for DLLs.
+ case $cc_basename in
+ cl*)
+ # Native MSVC
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ _LT_TAGVAR(always_export_symbols, $1)=yes
+ _LT_TAGVAR(file_list_spec, $1)='@'
+ # Tell ltmain to make .lib files, not .a files.
+ libext=lib
+ # Tell ltmain to make .dll files, not .so files.
+ shrext_cmds=".dll"
+ # FIXME: Setting linknames here is a bad hack.
+ _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
+ _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+ sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
+ else
+ sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
+ fi~
+ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+ linknames='
+ # The linker will not automatically build a static lib if we build a DLL.
+ # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+ _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols'
+ # Don't use ranlib
+ _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
+ _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~
+ lt_tool_outputfile="@TOOL_OUTPUT@"~
+ case $lt_outputfile in
+ *.exe|*.EXE) ;;
+ *)
+ lt_outputfile="$lt_outputfile.exe"
+ lt_tool_outputfile="$lt_tool_outputfile.exe"
+ ;;
+ esac~
+ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
+ $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+ $RM "$lt_outputfile.manifest";
+ fi'
+ ;;
+ *)
+ # Assume MSVC wrapper
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ # Tell ltmain to make .lib files, not .a files.
+ libext=lib
+ # Tell ltmain to make .dll files, not .so files.
+ shrext_cmds=".dll"
+ # FIXME: Setting linknames here is a bad hack.
+ _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='
+ # The linker will automatically build a .lib file if we build a DLL.
+ _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
+ # FIXME: Should let the user specify the lib program.
+ _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs'
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+ ;;
+ esac
+ ;;
+
+ darwin* | rhapsody*)
+ _LT_DARWIN_LINKER_FEATURES($1)
+ ;;
+
+ dgux*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+ # support. Future versions do this automatically, but an explicit c++rt0.o
+ # does not break anything, and helps significantly (at the cost of a little
+ # extra space).
+ freebsd2.2*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+ freebsd2.*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+ freebsd* | dragonfly*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ hpux9*)
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ fi
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ ;;
+
+ hpux10*)
+ if test "$GCC" = yes && test "$with_gnu_ld" = no; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+ fi
+ if test "$with_gnu_ld" = no; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ fi
+ ;;
+
+ hpux11*)
+ if test "$GCC" = yes && test "$with_gnu_ld" = no; then
+ case $host_cpu in
+ hppa*64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ ia64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ else
+ case $host_cpu in
+ hppa*64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ ia64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ m4_if($1, [], [
+ # Older versions of the 11.00 compiler do not understand -b yet
+ # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does)
+ _LT_LINKER_OPTION([if $CC understands -b],
+ _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b],
+ [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'],
+ [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])],
+ [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'])
+ ;;
+ esac
+ fi
+ if test "$with_gnu_ld" = no; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ case $host_cpu in
+ hppa*64*|ia64*)
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+ *)
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ ;;
+ esac
+ fi
+ ;;
+
+ irix5* | irix6* | nonstopux*)
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ # Try to use the -exported_symbol ld option, if it does not
+ # work, assume that -exports_file does not work either and
+ # implicitly export all symbols.
+ # This should be the same for all languages, so no per-tag cache variable.
+ AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol],
+ [lt_cv_irix_exported_symbol],
+ [save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
+ AC_LINK_IFELSE(
+ [AC_LANG_SOURCE(
+ [AC_LANG_CASE([C], [[int foo (void) { return 0; }]],
+ [C++], [[int foo (void) { return 0; }]],
+ [Fortran 77], [[
+ subroutine foo
+ end]],
+ [Fortran], [[
+ subroutine foo
+ end]])])],
+ [lt_cv_irix_exported_symbol=yes],
+ [lt_cv_irix_exported_symbol=no])
+ LDFLAGS="$save_LDFLAGS"])
+ if test "$lt_cv_irix_exported_symbol" = yes; then
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
+ fi
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+ fi
+ _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_TAGVAR(inherit_rpath, $1)=yes
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ ;;
+
+ netbsd* | netbsdelf*-gnu)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
+ fi
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ newsos6)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ *nto* | *qnx*)
+ ;;
+
+ openbsd*)
+ if test -f /usr/libexec/ld.so; then
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ else
+ case $host_os in
+ openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ ;;
+ *)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ ;;
+ esac
+ fi
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ os2*)
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+ _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+ ;;
+
+ osf3*)
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ else
+ _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+ fi
+ _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ ;;
+
+ osf4* | osf5*) # as osf3* with the addition of -msym flag
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ else
+ _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
+ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+
+ # Both c and cxx compiler support -rpath directly
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+ fi
+ _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ ;;
+
+ solaris*)
+ _LT_TAGVAR(no_undefined_flag, $1)=' -z defs'
+ if test "$GCC" = yes; then
+ wlarc='${wl}'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+ else
+ case `$CC -V 2>&1` in
+ *"Compilers 5.0"*)
+ wlarc=''
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+ ;;
+ *)
+ wlarc='${wl}'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+ ;;
+ esac
+ fi
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ case $host_os in
+ solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+ *)
+ # The compiler driver will combine and reorder linker options,
+ # but understands `-z linker_flag'. GCC discards it without `$wl',
+ # but is careful enough not to reorder.
+ # Supported since Solaris 2.6 (maybe 2.5.1?)
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+ else
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
+ fi
+ ;;
+ esac
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ ;;
+
+ sunos4*)
+ if test "x$host_vendor" = xsequent; then
+ # Use $CC to link under sequent, because it throws in some extra .o
+ # files that make .init and .fini sections work.
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+ fi
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ sysv4)
+ case $host_vendor in
+ sni)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true???
+ ;;
+ siemens)
+ ## LD is ld it makes a PLAMLIB
+ ## CC just makes a GrossModule.
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ ;;
+ motorola)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie
+ ;;
+ esac
+ runpath_var='LD_RUN_PATH'
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ sysv4.3*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ runpath_var=LD_RUN_PATH
+ hardcode_runpath_var=yes
+ _LT_TAGVAR(ld_shlibs, $1)=yes
+ fi
+ ;;
+
+ sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
+ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ runpath_var='LD_RUN_PATH'
+
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ fi
+ ;;
+
+ sysv5* | sco3.2v5* | sco5v6*)
+ # Note: We can NOT use -z defs as we might desire, because we do not
+ # link with -lc, and that would cause any symbols used from libc to
+ # always be unresolved, which means just about no library would
+ # ever link correctly. If we're not using GNU ld we use -z text
+ # though, which does catch some bad symbols but isn't as heavy-handed
+ # as -z defs.
+ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+ _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+ runpath_var='LD_RUN_PATH'
+
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ fi
+ ;;
+
+ uts4*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ *)
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+
+ if test x$host_vendor = xsni; then
+ case $host in
+ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym'
+ ;;
+ esac
+ fi
+ fi
+])
+AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
+test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld
+
+_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl
+_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl
+_LT_DECL([], [extract_expsyms_cmds], [2],
+ [The commands to extract the exported symbol list from a shared archive])
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in
+x|xyes)
+ # Assume -lc should be added
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+
+ if test "$enable_shared" = yes && test "$GCC" = yes; then
+ case $_LT_TAGVAR(archive_cmds, $1) in
+ *'~'*)
+ # FIXME: we may have to deal with multi-command sequences.
+ ;;
+ '$CC '*)
+ # Test whether the compiler implicitly links with -lc since on some
+ # systems, -lgcc has to come before -lc. If gcc already passes -lc
+ # to ld, don't add -lc before -lgcc.
+ AC_CACHE_CHECK([whether -lc should be explicitly linked in],
+ [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1),
+ [$RM conftest*
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
+ soname=conftest
+ lib=conftest
+ libobjs=conftest.$ac_objext
+ deplibs=
+ wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1)
+ pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1)
+ compiler_flags=-v
+ linker_flags=-v
+ verstring=
+ output_objdir=.
+ libname=conftest
+ lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1)
+ _LT_TAGVAR(allow_undefined_flag, $1)=
+ if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1)
+ then
+ lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ else
+ lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+ fi
+ _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
+ else
+ cat conftest.err 1>&5
+ fi
+ $RM conftest*
+ ])
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)
+ ;;
+ esac
+ fi
+ ;;
+esac
+
+_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0],
+ [Whether or not to add -lc for building shared libraries])
+_LT_TAGDECL([allow_libtool_libs_with_static_runtimes],
+ [enable_shared_with_static_runtimes], [0],
+ [Whether or not to disallow shared libs when runtime libs are static])
+_LT_TAGDECL([], [export_dynamic_flag_spec], [1],
+ [Compiler flag to allow reflexive dlopens])
+_LT_TAGDECL([], [whole_archive_flag_spec], [1],
+ [Compiler flag to generate shared objects directly from archives])
+_LT_TAGDECL([], [compiler_needs_object], [1],
+ [Whether the compiler copes with passing no objects directly])
+_LT_TAGDECL([], [old_archive_from_new_cmds], [2],
+ [Create an old-style archive from a shared archive])
+_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2],
+ [Create a temporary old-style archive to link instead of a shared archive])
+_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive])
+_LT_TAGDECL([], [archive_expsym_cmds], [2])
+_LT_TAGDECL([], [module_cmds], [2],
+ [Commands used to build a loadable module if different from building
+ a shared archive.])
+_LT_TAGDECL([], [module_expsym_cmds], [2])
+_LT_TAGDECL([], [with_gnu_ld], [1],
+ [Whether we are building with GNU ld or not])
+_LT_TAGDECL([], [allow_undefined_flag], [1],
+ [Flag that allows shared libraries with undefined symbols to be built])
+_LT_TAGDECL([], [no_undefined_flag], [1],
+ [Flag that enforces no undefined symbols])
+_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1],
+ [Flag to hardcode $libdir into a binary during linking.
+ This must work even if $libdir does not exist])
+_LT_TAGDECL([], [hardcode_libdir_separator], [1],
+ [Whether we need a single "-rpath" flag with a separated argument])
+_LT_TAGDECL([], [hardcode_direct], [0],
+ [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
+ DIR into the resulting binary])
+_LT_TAGDECL([], [hardcode_direct_absolute], [0],
+ [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
+ DIR into the resulting binary and the resulting library dependency is
+ "absolute", i.e impossible to change by setting ${shlibpath_var} if the
+ library is relocated])
+_LT_TAGDECL([], [hardcode_minus_L], [0],
+ [Set to "yes" if using the -LDIR flag during linking hardcodes DIR
+ into the resulting binary])
+_LT_TAGDECL([], [hardcode_shlibpath_var], [0],
+ [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
+ into the resulting binary])
+_LT_TAGDECL([], [hardcode_automatic], [0],
+ [Set to "yes" if building a shared library automatically hardcodes DIR
+ into the library and all subsequent libraries and executables linked
+ against it])
+_LT_TAGDECL([], [inherit_rpath], [0],
+ [Set to yes if linker adds runtime paths of dependent libraries
+ to runtime path list])
+_LT_TAGDECL([], [link_all_deplibs], [0],
+ [Whether libtool must link a program against all its dependency libraries])
+_LT_TAGDECL([], [always_export_symbols], [0],
+ [Set to "yes" if exported symbols are required])
+_LT_TAGDECL([], [export_symbols_cmds], [2],
+ [The commands to list exported symbols])
+_LT_TAGDECL([], [exclude_expsyms], [1],
+ [Symbols that should not be listed in the preloaded symbols])
+_LT_TAGDECL([], [include_expsyms], [1],
+ [Symbols that must always be exported])
+_LT_TAGDECL([], [prelink_cmds], [2],
+ [Commands necessary for linking programs (against libraries) with templates])
+_LT_TAGDECL([], [postlink_cmds], [2],
+ [Commands necessary for finishing linking programs])
+_LT_TAGDECL([], [file_list_spec], [1],
+ [Specify filename containing input files])
+dnl FIXME: Not yet implemented
+dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1],
+dnl [Compiler flag to generate thread safe objects])
+])# _LT_LINKER_SHLIBS
+
+
+# _LT_LANG_C_CONFIG([TAG])
+# ------------------------
+# Ensure that the configuration variables for a C compiler are suitably
+# defined. These variables are subsequently used by _LT_CONFIG to write
+# the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_C_CONFIG],
+[m4_require([_LT_DECL_EGREP])dnl
+lt_save_CC="$CC"
+AC_LANG_PUSH(C)
+
+# Source file extension for C test sources.
+ac_ext=c
+
+# Object file extension for compiled C test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(){return(0);}'
+
+_LT_TAG_COMPILER
+# Save the default compiler, since it gets overwritten when the other
+# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
+compiler_DEFAULT=$CC
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+## CAVEAT EMPTOR:
+## There is no encapsulation within the following macros, do not change
+## the running order or otherwise move them around unless you know exactly
+## what you are doing...
+if test -n "$compiler"; then
+ _LT_COMPILER_NO_RTTI($1)
+ _LT_COMPILER_PIC($1)
+ _LT_COMPILER_C_O($1)
+ _LT_COMPILER_FILE_LOCKS($1)
+ _LT_LINKER_SHLIBS($1)
+ _LT_SYS_DYNAMIC_LINKER($1)
+ _LT_LINKER_HARDCODE_LIBPATH($1)
+ LT_SYS_DLOPEN_SELF
+ _LT_CMD_STRIPLIB
+
+ # Report which library types will actually be built
+ AC_MSG_CHECKING([if libtool supports shared libraries])
+ AC_MSG_RESULT([$can_build_shared])
+
+ AC_MSG_CHECKING([whether to build shared libraries])
+ test "$can_build_shared" = "no" && enable_shared=no
+
+ # On AIX, shared libraries and static libraries use the same namespace, and
+ # are all built from PIC.
+ case $host_os in
+ aix3*)
+ test "$enable_shared" = yes && enable_static=no
+ if test -n "$RANLIB"; then
+ archive_cmds="$archive_cmds~\$RANLIB \$lib"
+ postinstall_cmds='$RANLIB $lib'
+ fi
+ ;;
+
+ aix[[4-9]]*)
+ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+ test "$enable_shared" = yes && enable_static=no
+ fi
+ ;;
+ esac
+ AC_MSG_RESULT([$enable_shared])
+
+ AC_MSG_CHECKING([whether to build static libraries])
+ # Make sure either enable_shared or enable_static is yes.
+ test "$enable_shared" = yes || enable_static=yes
+ AC_MSG_RESULT([$enable_static])
+
+ _LT_CONFIG($1)
+fi
+AC_LANG_POP
+CC="$lt_save_CC"
+])# _LT_LANG_C_CONFIG
+
+
+# _LT_LANG_CXX_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for a C++ compiler are suitably
+# defined. These variables are subsequently used by _LT_CONFIG to write
+# the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_CXX_CONFIG],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_PATH_MANIFEST_TOOL])dnl
+if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+ ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+ (test "X$CXX" != "Xg++"))) ; then
+ AC_PROG_CXXCPP
+else
+ _lt_caught_CXX_error=yes
+fi
+
+AC_LANG_PUSH(C++)
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_TAGVAR(allow_undefined_flag, $1)=
+_LT_TAGVAR(always_export_symbols, $1)=no
+_LT_TAGVAR(archive_expsym_cmds, $1)=
+_LT_TAGVAR(compiler_needs_object, $1)=no
+_LT_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_TAGVAR(hardcode_direct, $1)=no
+_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_TAGVAR(hardcode_minus_L, $1)=no
+_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+_LT_TAGVAR(hardcode_automatic, $1)=no
+_LT_TAGVAR(inherit_rpath, $1)=no
+_LT_TAGVAR(module_cmds, $1)=
+_LT_TAGVAR(module_expsym_cmds, $1)=
+_LT_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(reload_flag, $1)=$reload_flag
+_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
+_LT_TAGVAR(no_undefined_flag, $1)=
+_LT_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Source file extension for C++ test sources.
+ac_ext=cpp
+
+# Object file extension for compiled C++ test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# No sense in running all these tests if we already determined that
+# the CXX compiler isn't working. Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_caught_CXX_error" != yes; then
+ # Code to be used in simple compile tests
+ lt_simple_compile_test_code="int some_variable = 0;"
+
+ # Code to be used in simple link tests
+ lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }'
+
+ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+ _LT_TAG_COMPILER
+
+ # save warnings/boilerplate of simple test code
+ _LT_COMPILER_BOILERPLATE
+ _LT_LINKER_BOILERPLATE
+
+ # Allow CC to be a program name with arguments.
+ lt_save_CC=$CC
+ lt_save_CFLAGS=$CFLAGS
+ lt_save_LD=$LD
+ lt_save_GCC=$GCC
+ GCC=$GXX
+ lt_save_with_gnu_ld=$with_gnu_ld
+ lt_save_path_LD=$lt_cv_path_LD
+ if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
+ lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
+ else
+ $as_unset lt_cv_prog_gnu_ld
+ fi
+ if test -n "${lt_cv_path_LDCXX+set}"; then
+ lt_cv_path_LD=$lt_cv_path_LDCXX
+ else
+ $as_unset lt_cv_path_LD
+ fi
+ test -z "${LDCXX+set}" || LD=$LDCXX
+ CC=${CXX-"c++"}
+ CFLAGS=$CXXFLAGS
+ compiler=$CC
+ _LT_TAGVAR(compiler, $1)=$CC
+ _LT_CC_BASENAME([$compiler])
+
+ if test -n "$compiler"; then
+ # We don't want -fno-exception when compiling C++ code, so set the
+ # no_builtin_flag separately
+ if test "$GXX" = yes; then
+ _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+ else
+ _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+ fi
+
+ if test "$GXX" = yes; then
+ # Set up default GNU C++ configuration
+
+ LT_PATH_LD
+
+ # Check if GNU C++ uses GNU ld as the underlying linker, since the
+ # archiving commands below assume that GNU ld is being used.
+ if test "$with_gnu_ld" = yes; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+
+ # If archive_cmds runs LD, not CC, wlarc should be empty
+ # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
+ # investigate it a little bit more. (MM)
+ wlarc='${wl}'
+
+ # ancient GNU ld didn't support --whole-archive et. al.
+ if eval "`$CC -print-prog-name=ld` --help 2>&1" |
+ $GREP 'no-whole-archive' > /dev/null; then
+ _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ else
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=
+ fi
+ else
+ with_gnu_ld=no
+ wlarc=
+
+ # A generic and very simple default shared library creation
+ # command for GNU C++ for the case where it uses the native
+ # linker, instead of GNU ld. If possible, this setting should
+ # overridden to take advantage of the native linker features on
+ # the platform it is being used on.
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+ fi
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+
+ else
+ GXX=no
+ with_gnu_ld=no
+ wlarc=
+ fi
+
+ # PORTME: fill in a description of your system's C++ link characteristics
+ AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+ _LT_TAGVAR(ld_shlibs, $1)=yes
+ case $host_os in
+ aix3*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ aix[[4-9]]*)
+ if test "$host_cpu" = ia64; then
+ # On IA64, the linker does run time linking by default, so we don't
+ # have to do anything special.
+ aix_use_runtimelinking=no
+ exp_sym_flag='-Bexport'
+ no_entry_flag=""
+ else
+ aix_use_runtimelinking=no
+
+ # Test if we are trying to use run time linking or normal
+ # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+ # need to do runtime linking.
+ case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
+ for ld_flag in $LDFLAGS; do
+ case $ld_flag in
+ *-brtl*)
+ aix_use_runtimelinking=yes
+ break
+ ;;
+ esac
+ done
+ ;;
+ esac
+
+ exp_sym_flag='-bexport'
+ no_entry_flag='-bnoentry'
+ fi
+
+ # When large executables or shared objects are built, AIX ld can
+ # have problems creating the table of contents. If linking a library
+ # or program results in "error TOC overflow" add -mminimal-toc to
+ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
+ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+ _LT_TAGVAR(archive_cmds, $1)=''
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+
+ if test "$GXX" = yes; then
+ case $host_os in aix4.[[012]]|aix4.[[012]].*)
+ # We only want to do this on AIX 4.2 and lower, the check
+ # below for broken collect2 doesn't work under 4.3+
+ collect2name=`${CC} -print-prog-name=collect2`
+ if test -f "$collect2name" &&
+ strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+ then
+ # We have reworked collect2
+ :
+ else
+ # We have old collect2
+ _LT_TAGVAR(hardcode_direct, $1)=unsupported
+ # It fails to find uninstalled libraries when the uninstalled
+ # path is not listed in the libpath. Setting hardcode_minus_L
+ # to unsupported forces relinking
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=
+ fi
+ esac
+ shared_flag='-shared'
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag="$shared_flag "'${wl}-G'
+ fi
+ else
+ # not using gcc
+ if test "$host_cpu" = ia64; then
+ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+ # chokes on -Wl,-G. The following line is correct:
+ shared_flag='-G'
+ else
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag='${wl}-G'
+ else
+ shared_flag='${wl}-bM:SRE'
+ fi
+ fi
+ fi
+
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
+ # It seems that -bexpall does not export symbols beginning with
+ # underscore (_), so it is better to generate a list of symbols to
+ # export.
+ _LT_TAGVAR(always_export_symbols, $1)=yes
+ if test "$aix_use_runtimelinking" = yes; then
+ # Warning - without using the other runtime loading flags (-brtl),
+ # -berok will link without error, but may produce a broken library.
+ _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
+ # Determine the default libpath from the value encoded in an empty
+ # executable.
+ _LT_SYS_MODULE_PATH_AIX([$1])
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+ else
+ if test "$host_cpu" = ia64; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+ _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+ else
+ # Determine the default libpath from the value encoded in an
+ # empty executable.
+ _LT_SYS_MODULE_PATH_AIX([$1])
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+ # Warning - without using the other run time loading flags,
+ # -berok will link without error, but may produce a broken library.
+ _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+ if test "$with_gnu_ld" = yes; then
+ # We only use this code for GNU lds that support --whole-archive.
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+ else
+ # Exported symbols can be pulled into shared objects from archives
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+ fi
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+ # This is similar to how AIX traditionally builds its shared
+ # libraries.
+ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+ fi
+ fi
+ ;;
+
+ beos*)
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+ # support --undefined. This deserves some investigation. FIXME
+ _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ chorus*)
+ case $cc_basename in
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+
+ cygwin* | mingw* | pw32* | cegcc*)
+ case $GXX,$cc_basename in
+ ,cl* | no,cl*)
+ # Native MSVC
+ # hardcode_libdir_flag_spec is actually meaningless, as there is
+ # no search path for DLLs.
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ _LT_TAGVAR(always_export_symbols, $1)=yes
+ _LT_TAGVAR(file_list_spec, $1)='@'
+ # Tell ltmain to make .lib files, not .a files.
+ libext=lib
+ # Tell ltmain to make .dll files, not .so files.
+ shrext_cmds=".dll"
+ # FIXME: Setting linknames here is a bad hack.
+ _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
+ _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+ $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
+ else
+ $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
+ fi~
+ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+ linknames='
+ # The linker will not automatically build a static lib if we build a DLL.
+ # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+ # Don't use ranlib
+ _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
+ _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~
+ lt_tool_outputfile="@TOOL_OUTPUT@"~
+ case $lt_outputfile in
+ *.exe|*.EXE) ;;
+ *)
+ lt_outputfile="$lt_outputfile.exe"
+ lt_tool_outputfile="$lt_tool_outputfile.exe"
+ ;;
+ esac~
+ func_to_tool_file "$lt_outputfile"~
+ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
+ $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+ $RM "$lt_outputfile.manifest";
+ fi'
+ ;;
+ *)
+ # g++
+ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+ # as there is no search path for DLLs.
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols'
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ _LT_TAGVAR(always_export_symbols, $1)=no
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+
+ if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ # If the export-symbols file already is a .def file (1st line
+ # is EXPORTS), use it as is; otherwise, prepend...
+ _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+ cp $export_symbols $output_objdir/$soname.def;
+ else
+ echo EXPORTS > $output_objdir/$soname.def;
+ cat $export_symbols >> $output_objdir/$soname.def;
+ fi~
+ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ esac
+ ;;
+ darwin* | rhapsody*)
+ _LT_DARWIN_LINKER_FEATURES($1)
+ ;;
+
+ dgux*)
+ case $cc_basename in
+ ec++*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ ghcx*)
+ # Green Hills C++ Compiler
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+
+ freebsd2.*)
+ # C++ shared libraries reported to be fairly broken before
+ # switch to ELF
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ freebsd-elf*)
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ ;;
+
+ freebsd* | dragonfly*)
+ # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
+ # conventions
+ _LT_TAGVAR(ld_shlibs, $1)=yes
+ ;;
+
+ gnu*)
+ ;;
+
+ haiku*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ ;;
+
+ hpux9*)
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+ # but as the default
+ # location of the library.
+
+ case $cc_basename in
+ CC*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ aCC*)
+ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+ ;;
+ *)
+ if test "$GXX" = yes; then
+ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ else
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ esac
+ ;;
+
+ hpux10*|hpux11*)
+ if test $with_gnu_ld = no; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ case $host_cpu in
+ hppa*64*|ia64*)
+ ;;
+ *)
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ ;;
+ esac
+ fi
+ case $host_cpu in
+ hppa*64*|ia64*)
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+ *)
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+ # but as the default
+ # location of the library.
+ ;;
+ esac
+
+ case $cc_basename in
+ CC*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ aCC*)
+ case $host_cpu in
+ hppa*64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ ia64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ *)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ esac
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+ ;;
+ *)
+ if test "$GXX" = yes; then
+ if test $with_gnu_ld = no; then
+ case $host_cpu in
+ hppa*64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ ia64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ *)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ esac
+ fi
+ else
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ esac
+ ;;
+
+ interix[[3-9]]*)
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+ # Instead, shared libraries are loaded at an image base (0x10000000 by
+ # default) and relocated if they conflict, which is a slow very memory
+ # consuming and fragmenting process. To avoid this, we pick a random,
+ # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+ # time. Moving up from 0x10000000 also allows more sbrk(2) space.
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ ;;
+ irix5* | irix6*)
+ case $cc_basename in
+ CC*)
+ # SGI C++
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+
+ # Archives containing C++ object files must be created using
+ # "CC -ar", where "CC" is the IRIX C++ compiler. This is
+ # necessary to make sure instantiated templates are included
+ # in the archive.
+ _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
+ ;;
+ *)
+ if test "$GXX" = yes; then
+ if test "$with_gnu_ld" = no; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib'
+ fi
+ fi
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ ;;
+ esac
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_TAGVAR(inherit_rpath, $1)=yes
+ ;;
+
+ linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ case $cc_basename in
+ KCC*)
+ # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+ # KCC will only create a shared library if the output file
+ # ends with ".so" (or ".sl" for HP-UX), so rename the library
+ # to its proper name (with version) after linking.
+ _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+
+ # Archives containing C++ object files must be created using
+ # "CC -Bstatic", where "CC" is the KAI C++ compiler.
+ _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
+ ;;
+ icpc* | ecpc* )
+ # Intel C++
+ with_gnu_ld=yes
+ # version 8.0 and above of icpc choke on multiply defined symbols
+ # if we add $predep_objects and $postdep_objects, however 7.1 and
+ # earlier do not add the objects themselves.
+ case `$CC -V 2>&1` in
+ *"Version 7."*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ ;;
+ *) # Version 8.0 or newer
+ tmp_idyn=
+ case $host_cpu in
+ ia64*) tmp_idyn=' -i_dynamic';;
+ esac
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ ;;
+ esac
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+ ;;
+ pgCC* | pgcpp*)
+ # Portland Group C++ compiler
+ case `$CC -V` in
+ *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*)
+ _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
+ compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
+ _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
+ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
+ $RANLIB $oldlib'
+ _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+ ;;
+ *) # Version 6 and above use weak symbols
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+ ;;
+ esac
+
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+ ;;
+ cxx*)
+ # Compaq C++
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+
+ runpath_var=LD_RUN_PATH
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
+ ;;
+ xl* | mpixl* | bgxl*)
+ # IBM XL 8.0 on PPC, with GNU ld
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ if test "x$supports_anon_versioning" = xyes; then
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
+ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+ echo "local: *; };" >> $output_objdir/$libname.ver~
+ $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+ fi
+ ;;
+ *)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*)
+ # Sun C++ 5.9
+ _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+ _LT_TAGVAR(compiler_needs_object, $1)=yes
+
+ # Not sure whether something based on
+ # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
+ # would be better.
+ output_verbose_link_cmd='func_echo_all'
+
+ # Archives containing C++ object files must be created using
+ # "CC -xar", where "CC" is the Sun C++ compiler. This is
+ # necessary to make sure instantiated templates are included
+ # in the archive.
+ _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+
+ lynxos*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ m88k*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ mvs*)
+ case $cc_basename in
+ cxx*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+
+ netbsd*)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
+ wlarc=
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ fi
+ # Workaround some broken pre-1.5 toolchains
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
+ ;;
+
+ *nto* | *qnx*)
+ _LT_TAGVAR(ld_shlibs, $1)=yes
+ ;;
+
+ openbsd2*)
+ # C++ shared libraries are fairly broken
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ openbsd*)
+ if test -f /usr/libexec/ld.so; then
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ fi
+ output_verbose_link_cmd=func_echo_all
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ osf3* | osf4* | osf5*)
+ case $cc_basename in
+ KCC*)
+ # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+ # KCC will only create a shared library if the output file
+ # ends with ".so" (or ".sl" for HP-UX), so rename the library
+ # to its proper name (with version) after linking.
+ _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ # Archives containing C++ object files must be created using
+ # the KAI C++ compiler.
+ case $host in
+ osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;;
+ *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;;
+ esac
+ ;;
+ RCC*)
+ # Rational C++ 2.4.1
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ cxx*)
+ case $host in
+ osf3*)
+ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ ;;
+ *)
+ _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
+ echo "-hidden">> $lib.exp~
+ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~
+ $RM $lib.exp'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+ ;;
+ esac
+
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+ ;;
+ *)
+ if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+ case $host in
+ osf3*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ ;;
+ *)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ ;;
+ esac
+
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+
+ else
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ esac
+ ;;
+
+ psos*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ sunos4*)
+ case $cc_basename in
+ CC*)
+ # Sun C++ 4.x
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ lcc*)
+ # Lucid
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+
+ solaris*)
+ case $cc_basename in
+ CC* | sunCC*)
+ # Sun C++ 4.2, 5.x and Centerline C++
+ _LT_TAGVAR(archive_cmds_need_lc,$1)=yes
+ _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ case $host_os in
+ solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+ *)
+ # The compiler driver will combine and reorder linker options,
+ # but understands `-z linker_flag'.
+ # Supported since Solaris 2.6 (maybe 2.5.1?)
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
+ ;;
+ esac
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+
+ output_verbose_link_cmd='func_echo_all'
+
+ # Archives containing C++ object files must be created using
+ # "CC -xar", where "CC" is the Sun C++ compiler. This is
+ # necessary to make sure instantiated templates are included
+ # in the archive.
+ _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+ ;;
+ gcx*)
+ # Green Hills C++ Compiler
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+
+ # The C++ compiler must be used to create the archive.
+ _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
+ ;;
+ *)
+ # GNU C++ compiler with Solaris linker
+ if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+ _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
+ if $CC --version | $GREP -v '^2\.7' > /dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+ else
+ # g++ 2.7 appears to require `-G' NOT `-shared' on this
+ # platform.
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+ fi
+
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
+ case $host_os in
+ solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+ *)
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+ ;;
+ esac
+ fi
+ ;;
+ esac
+ ;;
+
+ sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
+ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ runpath_var='LD_RUN_PATH'
+
+ case $cc_basename in
+ CC*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ ;;
+
+ sysv5* | sco3.2v5* | sco5v6*)
+ # Note: We can NOT use -z defs as we might desire, because we do not
+ # link with -lc, and that would cause any symbols used from libc to
+ # always be unresolved, which means just about no library would
+ # ever link correctly. If we're not using GNU ld we use -z text
+ # though, which does catch some bad symbols but isn't as heavy-handed
+ # as -z defs.
+ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+ _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+ runpath_var='LD_RUN_PATH'
+
+ case $cc_basename in
+ CC*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~
+ '"$_LT_TAGVAR(old_archive_cmds, $1)"
+ _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~
+ '"$_LT_TAGVAR(reload_cmds, $1)"
+ ;;
+ *)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ ;;
+
+ tandem*)
+ case $cc_basename in
+ NCC*)
+ # NonStop-UX NCC 3.20
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+
+ vxworks*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+
+ AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
+ test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+ _LT_TAGVAR(GCC, $1)="$GXX"
+ _LT_TAGVAR(LD, $1)="$LD"
+
+ ## CAVEAT EMPTOR:
+ ## There is no encapsulation within the following macros, do not change
+ ## the running order or otherwise move them around unless you know exactly
+ ## what you are doing...
+ _LT_SYS_HIDDEN_LIBDEPS($1)
+ _LT_COMPILER_PIC($1)
+ _LT_COMPILER_C_O($1)
+ _LT_COMPILER_FILE_LOCKS($1)
+ _LT_LINKER_SHLIBS($1)
+ _LT_SYS_DYNAMIC_LINKER($1)
+ _LT_LINKER_HARDCODE_LIBPATH($1)
+
+ _LT_CONFIG($1)
+ fi # test -n "$compiler"
+
+ CC=$lt_save_CC
+ CFLAGS=$lt_save_CFLAGS
+ LDCXX=$LD
+ LD=$lt_save_LD
+ GCC=$lt_save_GCC
+ with_gnu_ld=$lt_save_with_gnu_ld
+ lt_cv_path_LDCXX=$lt_cv_path_LD
+ lt_cv_path_LD=$lt_save_path_LD
+ lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
+ lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
+fi # test "$_lt_caught_CXX_error" != yes
+
+AC_LANG_POP
+])# _LT_LANG_CXX_CONFIG
+
+
+# _LT_FUNC_STRIPNAME_CNF
+# ----------------------
+# func_stripname_cnf prefix suffix name
+# strip PREFIX and SUFFIX off of NAME.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+#
+# This function is identical to the (non-XSI) version of func_stripname,
+# except this one can be used by m4 code that may be executed by configure,
+# rather than the libtool script.
+m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl
+AC_REQUIRE([_LT_DECL_SED])
+AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])
+func_stripname_cnf ()
+{
+ case ${2} in
+ .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
+ *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
+ esac
+} # func_stripname_cnf
+])# _LT_FUNC_STRIPNAME_CNF
+
+# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME])
+# ---------------------------------
+# Figure out "hidden" library dependencies from verbose
+# compiler output when linking a shared library.
+# Parse the compiler output and extract the necessary
+# objects, libraries and library flags.
+m4_defun([_LT_SYS_HIDDEN_LIBDEPS],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl
+# Dependencies to place before and after the object being linked:
+_LT_TAGVAR(predep_objects, $1)=
+_LT_TAGVAR(postdep_objects, $1)=
+_LT_TAGVAR(predeps, $1)=
+_LT_TAGVAR(postdeps, $1)=
+_LT_TAGVAR(compiler_lib_search_path, $1)=
+
+dnl we can't use the lt_simple_compile_test_code here,
+dnl because it contains code intended for an executable,
+dnl not a library. It's possible we should let each
+dnl tag define a new lt_????_link_test_code variable,
+dnl but it's only used here...
+m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF
+int a;
+void foo (void) { a = 0; }
+_LT_EOF
+], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF
+class Foo
+{
+public:
+ Foo (void) { a = 0; }
+private:
+ int a;
+};
+_LT_EOF
+], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF
+ subroutine foo
+ implicit none
+ integer*4 a
+ a=0
+ return
+ end
+_LT_EOF
+], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF
+ subroutine foo
+ implicit none
+ integer a
+ a=0
+ return
+ end
+_LT_EOF
+], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF
+public class foo {
+ private int a;
+ public void bar (void) {
+ a = 0;
+ }
+};
+_LT_EOF
+], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF
+package foo
+func foo() {
+}
+_LT_EOF
+])
+
+_lt_libdeps_save_CFLAGS=$CFLAGS
+case "$CC $CFLAGS " in #(
+*\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;;
+*\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;;
+*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;;
+esac
+
+dnl Parse the compiler output and extract the necessary
+dnl objects, libraries and library flags.
+if AC_TRY_EVAL(ac_compile); then
+ # Parse the compiler output and extract the necessary
+ # objects, libraries and library flags.
+
+ # Sentinel used to keep track of whether or not we are before
+ # the conftest object file.
+ pre_test_object_deps_done=no
+
+ for p in `eval "$output_verbose_link_cmd"`; do
+ case ${prev}${p} in
+
+ -L* | -R* | -l*)
+ # Some compilers place space between "-{L,R}" and the path.
+ # Remove the space.
+ if test $p = "-L" ||
+ test $p = "-R"; then
+ prev=$p
+ continue
+ fi
+
+ # Expand the sysroot to ease extracting the directories later.
+ if test -z "$prev"; then
+ case $p in
+ -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;;
+ -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;;
+ -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;;
+ esac
+ fi
+ case $p in
+ =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;;
+ esac
+ if test "$pre_test_object_deps_done" = no; then
+ case ${prev} in
+ -L | -R)
+ # Internal compiler library paths should come after those
+ # provided the user. The postdeps already come after the
+ # user supplied libs so there is no need to process them.
+ if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then
+ _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
+ else
+ _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
+ fi
+ ;;
+ # The "-l" case would never come before the object being
+ # linked, so don't bother handling this case.
+ esac
+ else
+ if test -z "$_LT_TAGVAR(postdeps, $1)"; then
+ _LT_TAGVAR(postdeps, $1)="${prev}${p}"
+ else
+ _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}"
+ fi
+ fi
+ prev=
+ ;;
+
+ *.lto.$objext) ;; # Ignore GCC LTO objects
+ *.$objext)
+ # This assumes that the test object file only shows up
+ # once in the compiler output.
+ if test "$p" = "conftest.$objext"; then
+ pre_test_object_deps_done=yes
+ continue
+ fi
+
+ if test "$pre_test_object_deps_done" = no; then
+ if test -z "$_LT_TAGVAR(predep_objects, $1)"; then
+ _LT_TAGVAR(predep_objects, $1)="$p"
+ else
+ _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p"
+ fi
+ else
+ if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then
+ _LT_TAGVAR(postdep_objects, $1)="$p"
+ else
+ _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p"
+ fi
+ fi
+ ;;
+
+ *) ;; # Ignore the rest.
+
+ esac
+ done
+
+ # Clean up.
+ rm -f a.out a.exe
+else
+ echo "libtool.m4: error: problem compiling $1 test program"
+fi
+
+$RM -f confest.$objext
+CFLAGS=$_lt_libdeps_save_CFLAGS
+
+# PORTME: override above test on systems where it is broken
+m4_if([$1], [CXX],
+[case $host_os in
+interix[[3-9]]*)
+ # Interix 3.5 installs completely hosed .la files for C++, so rather than
+ # hack all around it, let's just trust "g++" to DTRT.
+ _LT_TAGVAR(predep_objects,$1)=
+ _LT_TAGVAR(postdep_objects,$1)=
+ _LT_TAGVAR(postdeps,$1)=
+ ;;
+
+linux*)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*)
+ # Sun C++ 5.9
+
+ # The more standards-conforming stlport4 library is
+ # incompatible with the Cstd library. Avoid specifying
+ # it if it's in CXXFLAGS. Ignore libCrun as
+ # -library=stlport4 depends on it.
+ case " $CXX $CXXFLAGS " in
+ *" -library=stlport4 "*)
+ solaris_use_stlport4=yes
+ ;;
+ esac
+
+ if test "$solaris_use_stlport4" != yes; then
+ _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
+ fi
+ ;;
+ esac
+ ;;
+
+solaris*)
+ case $cc_basename in
+ CC* | sunCC*)
+ # The more standards-conforming stlport4 library is
+ # incompatible with the Cstd library. Avoid specifying
+ # it if it's in CXXFLAGS. Ignore libCrun as
+ # -library=stlport4 depends on it.
+ case " $CXX $CXXFLAGS " in
+ *" -library=stlport4 "*)
+ solaris_use_stlport4=yes
+ ;;
+ esac
+
+ # Adding this requires a known-good setup of shared libraries for
+ # Sun compiler versions before 5.6, else PIC objects from an old
+ # archive will be linked into the output, leading to subtle bugs.
+ if test "$solaris_use_stlport4" != yes; then
+ _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
+ fi
+ ;;
+ esac
+ ;;
+esac
+])
+
+case " $_LT_TAGVAR(postdeps, $1) " in
+*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;;
+esac
+ _LT_TAGVAR(compiler_lib_search_dirs, $1)=
+if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then
+ _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+fi
+_LT_TAGDECL([], [compiler_lib_search_dirs], [1],
+ [The directories searched by this compiler when creating a shared library])
+_LT_TAGDECL([], [predep_objects], [1],
+ [Dependencies to place before and after the objects being linked to
+ create a shared library])
+_LT_TAGDECL([], [postdep_objects], [1])
+_LT_TAGDECL([], [predeps], [1])
+_LT_TAGDECL([], [postdeps], [1])
+_LT_TAGDECL([], [compiler_lib_search_path], [1],
+ [The library search path used internally by the compiler when linking
+ a shared library])
+])# _LT_SYS_HIDDEN_LIBDEPS
+
+
+# _LT_LANG_F77_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for a Fortran 77 compiler are
+# suitably defined. These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_F77_CONFIG],
+[AC_LANG_PUSH(Fortran 77)
+if test -z "$F77" || test "X$F77" = "Xno"; then
+ _lt_disable_F77=yes
+fi
+
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_TAGVAR(allow_undefined_flag, $1)=
+_LT_TAGVAR(always_export_symbols, $1)=no
+_LT_TAGVAR(archive_expsym_cmds, $1)=
+_LT_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_TAGVAR(hardcode_direct, $1)=no
+_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_TAGVAR(hardcode_minus_L, $1)=no
+_LT_TAGVAR(hardcode_automatic, $1)=no
+_LT_TAGVAR(inherit_rpath, $1)=no
+_LT_TAGVAR(module_cmds, $1)=
+_LT_TAGVAR(module_expsym_cmds, $1)=
+_LT_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(reload_flag, $1)=$reload_flag
+_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
+_LT_TAGVAR(no_undefined_flag, $1)=
+_LT_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Source file extension for f77 test sources.
+ac_ext=f
+
+# Object file extension for compiled f77 test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# No sense in running all these tests if we already determined that
+# the F77 compiler isn't working. Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_disable_F77" != yes; then
+ # Code to be used in simple compile tests
+ lt_simple_compile_test_code="\
+ subroutine t
+ return
+ end
+"
+
+ # Code to be used in simple link tests
+ lt_simple_link_test_code="\
+ program t
+ end
+"
+
+ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+ _LT_TAG_COMPILER
+
+ # save warnings/boilerplate of simple test code
+ _LT_COMPILER_BOILERPLATE
+ _LT_LINKER_BOILERPLATE
+
+ # Allow CC to be a program name with arguments.
+ lt_save_CC="$CC"
+ lt_save_GCC=$GCC
+ lt_save_CFLAGS=$CFLAGS
+ CC=${F77-"f77"}
+ CFLAGS=$FFLAGS
+ compiler=$CC
+ _LT_TAGVAR(compiler, $1)=$CC
+ _LT_CC_BASENAME([$compiler])
+ GCC=$G77
+ if test -n "$compiler"; then
+ AC_MSG_CHECKING([if libtool supports shared libraries])
+ AC_MSG_RESULT([$can_build_shared])
+
+ AC_MSG_CHECKING([whether to build shared libraries])
+ test "$can_build_shared" = "no" && enable_shared=no
+
+ # On AIX, shared libraries and static libraries use the same namespace, and
+ # are all built from PIC.
+ case $host_os in
+ aix3*)
+ test "$enable_shared" = yes && enable_static=no
+ if test -n "$RANLIB"; then
+ archive_cmds="$archive_cmds~\$RANLIB \$lib"
+ postinstall_cmds='$RANLIB $lib'
+ fi
+ ;;
+ aix[[4-9]]*)
+ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+ test "$enable_shared" = yes && enable_static=no
+ fi
+ ;;
+ esac
+ AC_MSG_RESULT([$enable_shared])
+
+ AC_MSG_CHECKING([whether to build static libraries])
+ # Make sure either enable_shared or enable_static is yes.
+ test "$enable_shared" = yes || enable_static=yes
+ AC_MSG_RESULT([$enable_static])
+
+ _LT_TAGVAR(GCC, $1)="$G77"
+ _LT_TAGVAR(LD, $1)="$LD"
+
+ ## CAVEAT EMPTOR:
+ ## There is no encapsulation within the following macros, do not change
+ ## the running order or otherwise move them around unless you know exactly
+ ## what you are doing...
+ _LT_COMPILER_PIC($1)
+ _LT_COMPILER_C_O($1)
+ _LT_COMPILER_FILE_LOCKS($1)
+ _LT_LINKER_SHLIBS($1)
+ _LT_SYS_DYNAMIC_LINKER($1)
+ _LT_LINKER_HARDCODE_LIBPATH($1)
+
+ _LT_CONFIG($1)
+ fi # test -n "$compiler"
+
+ GCC=$lt_save_GCC
+ CC="$lt_save_CC"
+ CFLAGS="$lt_save_CFLAGS"
+fi # test "$_lt_disable_F77" != yes
+
+AC_LANG_POP
+])# _LT_LANG_F77_CONFIG
+
+
+# _LT_LANG_FC_CONFIG([TAG])
+# -------------------------
+# Ensure that the configuration variables for a Fortran compiler are
+# suitably defined. These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_FC_CONFIG],
+[AC_LANG_PUSH(Fortran)
+
+if test -z "$FC" || test "X$FC" = "Xno"; then
+ _lt_disable_FC=yes
+fi
+
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_TAGVAR(allow_undefined_flag, $1)=
+_LT_TAGVAR(always_export_symbols, $1)=no
+_LT_TAGVAR(archive_expsym_cmds, $1)=
+_LT_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_TAGVAR(hardcode_direct, $1)=no
+_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_TAGVAR(hardcode_minus_L, $1)=no
+_LT_TAGVAR(hardcode_automatic, $1)=no
+_LT_TAGVAR(inherit_rpath, $1)=no
+_LT_TAGVAR(module_cmds, $1)=
+_LT_TAGVAR(module_expsym_cmds, $1)=
+_LT_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(reload_flag, $1)=$reload_flag
+_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
+_LT_TAGVAR(no_undefined_flag, $1)=
+_LT_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Source file extension for fc test sources.
+ac_ext=${ac_fc_srcext-f}
+
+# Object file extension for compiled fc test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# No sense in running all these tests if we already determined that
+# the FC compiler isn't working. Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_disable_FC" != yes; then
+ # Code to be used in simple compile tests
+ lt_simple_compile_test_code="\
+ subroutine t
+ return
+ end
+"
+
+ # Code to be used in simple link tests
+ lt_simple_link_test_code="\
+ program t
+ end
+"
+
+ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+ _LT_TAG_COMPILER
+
+ # save warnings/boilerplate of simple test code
+ _LT_COMPILER_BOILERPLATE
+ _LT_LINKER_BOILERPLATE
+
+ # Allow CC to be a program name with arguments.
+ lt_save_CC="$CC"
+ lt_save_GCC=$GCC
+ lt_save_CFLAGS=$CFLAGS
+ CC=${FC-"f95"}
+ CFLAGS=$FCFLAGS
+ compiler=$CC
+ GCC=$ac_cv_fc_compiler_gnu
+
+ _LT_TAGVAR(compiler, $1)=$CC
+ _LT_CC_BASENAME([$compiler])
+
+ if test -n "$compiler"; then
+ AC_MSG_CHECKING([if libtool supports shared libraries])
+ AC_MSG_RESULT([$can_build_shared])
+
+ AC_MSG_CHECKING([whether to build shared libraries])
+ test "$can_build_shared" = "no" && enable_shared=no
+
+ # On AIX, shared libraries and static libraries use the same namespace, and
+ # are all built from PIC.
+ case $host_os in
+ aix3*)
+ test "$enable_shared" = yes && enable_static=no
+ if test -n "$RANLIB"; then
+ archive_cmds="$archive_cmds~\$RANLIB \$lib"
+ postinstall_cmds='$RANLIB $lib'
+ fi
+ ;;
+ aix[[4-9]]*)
+ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+ test "$enable_shared" = yes && enable_static=no
+ fi
+ ;;
+ esac
+ AC_MSG_RESULT([$enable_shared])
+
+ AC_MSG_CHECKING([whether to build static libraries])
+ # Make sure either enable_shared or enable_static is yes.
+ test "$enable_shared" = yes || enable_static=yes
+ AC_MSG_RESULT([$enable_static])
+
+ _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu"
+ _LT_TAGVAR(LD, $1)="$LD"
+
+ ## CAVEAT EMPTOR:
+ ## There is no encapsulation within the following macros, do not change
+ ## the running order or otherwise move them around unless you know exactly
+ ## what you are doing...
+ _LT_SYS_HIDDEN_LIBDEPS($1)
+ _LT_COMPILER_PIC($1)
+ _LT_COMPILER_C_O($1)
+ _LT_COMPILER_FILE_LOCKS($1)
+ _LT_LINKER_SHLIBS($1)
+ _LT_SYS_DYNAMIC_LINKER($1)
+ _LT_LINKER_HARDCODE_LIBPATH($1)
+
+ _LT_CONFIG($1)
+ fi # test -n "$compiler"
+
+ GCC=$lt_save_GCC
+ CC=$lt_save_CC
+ CFLAGS=$lt_save_CFLAGS
+fi # test "$_lt_disable_FC" != yes
+
+AC_LANG_POP
+])# _LT_LANG_FC_CONFIG
+
+
+# _LT_LANG_GCJ_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for the GNU Java Compiler compiler
+# are suitably defined. These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_GCJ_CONFIG],
+[AC_REQUIRE([LT_PROG_GCJ])dnl
+AC_LANG_SAVE
+
+# Source file extension for Java test sources.
+ac_ext=java
+
+# Object file extension for compiled Java test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="class foo {}"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_TAG_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC=$CC
+lt_save_CFLAGS=$CFLAGS
+lt_save_GCC=$GCC
+GCC=yes
+CC=${GCJ-"gcj"}
+CFLAGS=$GCJFLAGS
+compiler=$CC
+_LT_TAGVAR(compiler, $1)=$CC
+_LT_TAGVAR(LD, $1)="$LD"
+_LT_CC_BASENAME([$compiler])
+
+# GCJ did not exist at the time GCC didn't implicitly link libc in.
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(reload_flag, $1)=$reload_flag
+_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
+
+## CAVEAT EMPTOR:
+## There is no encapsulation within the following macros, do not change
+## the running order or otherwise move them around unless you know exactly
+## what you are doing...
+if test -n "$compiler"; then
+ _LT_COMPILER_NO_RTTI($1)
+ _LT_COMPILER_PIC($1)
+ _LT_COMPILER_C_O($1)
+ _LT_COMPILER_FILE_LOCKS($1)
+ _LT_LINKER_SHLIBS($1)
+ _LT_LINKER_HARDCODE_LIBPATH($1)
+
+ _LT_CONFIG($1)
+fi
+
+AC_LANG_RESTORE
+
+GCC=$lt_save_GCC
+CC=$lt_save_CC
+CFLAGS=$lt_save_CFLAGS
+])# _LT_LANG_GCJ_CONFIG
+
+
+# _LT_LANG_GO_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for the GNU Go compiler
+# are suitably defined. These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_GO_CONFIG],
+[AC_REQUIRE([LT_PROG_GO])dnl
+AC_LANG_SAVE
+
+# Source file extension for Go test sources.
+ac_ext=go
+
+# Object file extension for compiled Go test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="package main; func main() { }"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='package main; func main() { }'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_TAG_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC=$CC
+lt_save_CFLAGS=$CFLAGS
+lt_save_GCC=$GCC
+GCC=yes
+CC=${GOC-"gccgo"}
+CFLAGS=$GOFLAGS
+compiler=$CC
+_LT_TAGVAR(compiler, $1)=$CC
+_LT_TAGVAR(LD, $1)="$LD"
+_LT_CC_BASENAME([$compiler])
+
+# Go did not exist at the time GCC didn't implicitly link libc in.
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(reload_flag, $1)=$reload_flag
+_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
+
+## CAVEAT EMPTOR:
+## There is no encapsulation within the following macros, do not change
+## the running order or otherwise move them around unless you know exactly
+## what you are doing...
+if test -n "$compiler"; then
+ _LT_COMPILER_NO_RTTI($1)
+ _LT_COMPILER_PIC($1)
+ _LT_COMPILER_C_O($1)
+ _LT_COMPILER_FILE_LOCKS($1)
+ _LT_LINKER_SHLIBS($1)
+ _LT_LINKER_HARDCODE_LIBPATH($1)
+
+ _LT_CONFIG($1)
+fi
+
+AC_LANG_RESTORE
+
+GCC=$lt_save_GCC
+CC=$lt_save_CC
+CFLAGS=$lt_save_CFLAGS
+])# _LT_LANG_GO_CONFIG
+
+
+# _LT_LANG_RC_CONFIG([TAG])
+# -------------------------
+# Ensure that the configuration variables for the Windows resource compiler
+# are suitably defined. These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_RC_CONFIG],
+[AC_REQUIRE([LT_PROG_RC])dnl
+AC_LANG_SAVE
+
+# Source file extension for RC test sources.
+ac_ext=rc
+
+# Object file extension for compiled RC test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }'
+
+# Code to be used in simple link tests
+lt_simple_link_test_code="$lt_simple_compile_test_code"
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_TAG_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+lt_save_CFLAGS=$CFLAGS
+lt_save_GCC=$GCC
+GCC=
+CC=${RC-"windres"}
+CFLAGS=
+compiler=$CC
+_LT_TAGVAR(compiler, $1)=$CC
+_LT_CC_BASENAME([$compiler])
+_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+
+if test -n "$compiler"; then
+ :
+ _LT_CONFIG($1)
+fi
+
+GCC=$lt_save_GCC
+AC_LANG_RESTORE
+CC=$lt_save_CC
+CFLAGS=$lt_save_CFLAGS
+])# _LT_LANG_RC_CONFIG
+
+
+# LT_PROG_GCJ
+# -----------
+AC_DEFUN([LT_PROG_GCJ],
+[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ],
+ [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ],
+ [AC_CHECK_TOOL(GCJ, gcj,)
+ test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
+ AC_SUBST(GCJFLAGS)])])[]dnl
+])
+
+# Old name:
+AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([LT_AC_PROG_GCJ], [])
+
+
+# LT_PROG_GO
+# ----------
+AC_DEFUN([LT_PROG_GO],
+[AC_CHECK_TOOL(GOC, gccgo,)
+])
+
+
+# LT_PROG_RC
+# ----------
+AC_DEFUN([LT_PROG_RC],
+[AC_CHECK_TOOL(RC, windres,)
+])
+
+# Old name:
+AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([LT_AC_PROG_RC], [])
+
+
+# _LT_DECL_EGREP
+# --------------
+# If we don't have a new enough Autoconf to choose the best grep
+# available, choose the one first in the user's PATH.
+m4_defun([_LT_DECL_EGREP],
+[AC_REQUIRE([AC_PROG_EGREP])dnl
+AC_REQUIRE([AC_PROG_FGREP])dnl
+test -z "$GREP" && GREP=grep
+_LT_DECL([], [GREP], [1], [A grep program that handles long lines])
+_LT_DECL([], [EGREP], [1], [An ERE matcher])
+_LT_DECL([], [FGREP], [1], [A literal string matcher])
+dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too
+AC_SUBST([GREP])
+])
+
+
+# _LT_DECL_OBJDUMP
+# --------------
+# If we don't have a new enough Autoconf to choose the best objdump
+# available, choose the one first in the user's PATH.
+m4_defun([_LT_DECL_OBJDUMP],
+[AC_CHECK_TOOL(OBJDUMP, objdump, false)
+test -z "$OBJDUMP" && OBJDUMP=objdump
+_LT_DECL([], [OBJDUMP], [1], [An object symbol dumper])
+AC_SUBST([OBJDUMP])
+])
+
+# _LT_DECL_DLLTOOL
+# ----------------
+# Ensure DLLTOOL variable is set.
+m4_defun([_LT_DECL_DLLTOOL],
+[AC_CHECK_TOOL(DLLTOOL, dlltool, false)
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+_LT_DECL([], [DLLTOOL], [1], [DLL creation program])
+AC_SUBST([DLLTOOL])
+])
+
+# _LT_DECL_SED
+# ------------
+# Check for a fully-functional sed program, that truncates
+# as few characters as possible. Prefer GNU sed if found.
+m4_defun([_LT_DECL_SED],
+[AC_PROG_SED
+test -z "$SED" && SED=sed
+Xsed="$SED -e 1s/^X//"
+_LT_DECL([], [SED], [1], [A sed program that does not truncate output])
+_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"],
+ [Sed that helps us avoid accidentally triggering echo(1) options like -n])
+])# _LT_DECL_SED
+
+m4_ifndef([AC_PROG_SED], [
+############################################################
+# NOTE: This macro has been submitted for inclusion into #
+# GNU Autoconf as AC_PROG_SED. When it is available in #
+# a released version of Autoconf we should remove this #
+# macro and use it instead. #
+############################################################
+
+m4_defun([AC_PROG_SED],
+[AC_MSG_CHECKING([for a sed that does not truncate output])
+AC_CACHE_VAL(lt_cv_path_SED,
+[# Loop through the user's path and test for sed and gsed.
+# Then use that list of sed's as ones to test for truncation.
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for lt_ac_prog in sed gsed; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then
+ lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
+ fi
+ done
+ done
+done
+IFS=$as_save_IFS
+lt_ac_max=0
+lt_ac_count=0
+# Add /usr/xpg4/bin/sed as it is typically found on Solaris
+# along with /bin/sed that truncates output.
+for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
+ test ! -f $lt_ac_sed && continue
+ cat /dev/null > conftest.in
+ lt_ac_count=0
+ echo $ECHO_N "0123456789$ECHO_C" >conftest.in
+ # Check for GNU sed and select it if it is found.
+ if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
+ lt_cv_path_SED=$lt_ac_sed
+ break
+ fi
+ while true; do
+ cat conftest.in conftest.in >conftest.tmp
+ mv conftest.tmp conftest.in
+ cp conftest.in conftest.nl
+ echo >>conftest.nl
+ $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
+ cmp -s conftest.out conftest.nl || break
+ # 10000 chars as input seems more than enough
+ test $lt_ac_count -gt 10 && break
+ lt_ac_count=`expr $lt_ac_count + 1`
+ if test $lt_ac_count -gt $lt_ac_max; then
+ lt_ac_max=$lt_ac_count
+ lt_cv_path_SED=$lt_ac_sed
+ fi
+ done
+done
+])
+SED=$lt_cv_path_SED
+AC_SUBST([SED])
+AC_MSG_RESULT([$SED])
+])#AC_PROG_SED
+])#m4_ifndef
+
+# Old name:
+AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([LT_AC_PROG_SED], [])
+
+
+# _LT_CHECK_SHELL_FEATURES
+# ------------------------
+# Find out whether the shell is Bourne or XSI compatible,
+# or has some other useful features.
+m4_defun([_LT_CHECK_SHELL_FEATURES],
+[AC_MSG_CHECKING([whether the shell understands some XSI constructs])
+# Try some XSI features
+xsi_shell=no
+( _lt_dummy="a/b/c"
+ test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \
+ = c,a/b,b/c, \
+ && eval 'test $(( 1 + 1 )) -eq 2 \
+ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
+ && xsi_shell=yes
+AC_MSG_RESULT([$xsi_shell])
+_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell'])
+
+AC_MSG_CHECKING([whether the shell understands "+="])
+lt_shell_append=no
+( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \
+ >/dev/null 2>&1 \
+ && lt_shell_append=yes
+AC_MSG_RESULT([$lt_shell_append])
+_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append'])
+
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+ lt_unset=unset
+else
+ lt_unset=false
+fi
+_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl
+
+# test EBCDIC or ASCII
+case `echo X|tr X '\101'` in
+ A) # ASCII based system
+ # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
+ lt_SP2NL='tr \040 \012'
+ lt_NL2SP='tr \015\012 \040\040'
+ ;;
+ *) # EBCDIC based system
+ lt_SP2NL='tr \100 \n'
+ lt_NL2SP='tr \r\n \100\100'
+ ;;
+esac
+_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl
+_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl
+])# _LT_CHECK_SHELL_FEATURES
+
+
+# _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY)
+# ------------------------------------------------------
+# In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and
+# '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY.
+m4_defun([_LT_PROG_FUNCTION_REPLACE],
+[dnl {
+sed -e '/^$1 ()$/,/^} # $1 /c\
+$1 ()\
+{\
+m4_bpatsubsts([$2], [$], [\\], [^\([ ]\)], [\\\1])
+} # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+])
+
+
+# _LT_PROG_REPLACE_SHELLFNS
+# -------------------------
+# Replace existing portable implementations of several shell functions with
+# equivalent extended shell implementations where those features are available..
+m4_defun([_LT_PROG_REPLACE_SHELLFNS],
+[if test x"$xsi_shell" = xyes; then
+ _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl
+ case ${1} in
+ */*) func_dirname_result="${1%/*}${2}" ;;
+ * ) func_dirname_result="${3}" ;;
+ esac])
+
+ _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl
+ func_basename_result="${1##*/}"])
+
+ _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl
+ case ${1} in
+ */*) func_dirname_result="${1%/*}${2}" ;;
+ * ) func_dirname_result="${3}" ;;
+ esac
+ func_basename_result="${1##*/}"])
+
+ _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl
+ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
+ # positional parameters, so assign one to ordinary parameter first.
+ func_stripname_result=${3}
+ func_stripname_result=${func_stripname_result#"${1}"}
+ func_stripname_result=${func_stripname_result%"${2}"}])
+
+ _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl
+ func_split_long_opt_name=${1%%=*}
+ func_split_long_opt_arg=${1#*=}])
+
+ _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl
+ func_split_short_opt_arg=${1#??}
+ func_split_short_opt_name=${1%"$func_split_short_opt_arg"}])
+
+ _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl
+ case ${1} in
+ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
+ *) func_lo2o_result=${1} ;;
+ esac])
+
+ _LT_PROG_FUNCTION_REPLACE([func_xform], [ func_xform_result=${1%.*}.lo])
+
+ _LT_PROG_FUNCTION_REPLACE([func_arith], [ func_arith_result=$(( $[*] ))])
+
+ _LT_PROG_FUNCTION_REPLACE([func_len], [ func_len_result=${#1}])
+fi
+
+if test x"$lt_shell_append" = xyes; then
+ _LT_PROG_FUNCTION_REPLACE([func_append], [ eval "${1}+=\\${2}"])
+
+ _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl
+ func_quote_for_eval "${2}"
+dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \
+ eval "${1}+=\\\\ \\$func_quote_for_eval_result"])
+
+ # Save a `func_append' function call where possible by direct use of '+='
+ sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+ test 0 -eq $? || _lt_function_replace_fail=:
+else
+ # Save a `func_append' function call even when '+=' is not available
+ sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+ test 0 -eq $? || _lt_function_replace_fail=:
+fi
+
+if test x"$_lt_function_replace_fail" = x":"; then
+ AC_MSG_WARN([Unable to substitute extended shell functions in $ofile])
+fi
+])
+
+# _LT_PATH_CONVERSION_FUNCTIONS
+# -----------------------------
+# Determine which file name conversion functions should be used by
+# func_to_host_file (and, implicitly, by func_to_host_path). These are needed
+# for certain cross-compile configurations and native mingw.
+m4_defun([_LT_PATH_CONVERSION_FUNCTIONS],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+AC_MSG_CHECKING([how to convert $build file names to $host format])
+AC_CACHE_VAL(lt_cv_to_host_file_cmd,
+[case $host in
+ *-*-mingw* )
+ case $build in
+ *-*-mingw* ) # actually msys
+ lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32
+ ;;
+ *-*-cygwin* )
+ lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32
+ ;;
+ * ) # otherwise, assume *nix
+ lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32
+ ;;
+ esac
+ ;;
+ *-*-cygwin* )
+ case $build in
+ *-*-mingw* ) # actually msys
+ lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin
+ ;;
+ *-*-cygwin* )
+ lt_cv_to_host_file_cmd=func_convert_file_noop
+ ;;
+ * ) # otherwise, assume *nix
+ lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin
+ ;;
+ esac
+ ;;
+ * ) # unhandled hosts (and "normal" native builds)
+ lt_cv_to_host_file_cmd=func_convert_file_noop
+ ;;
+esac
+])
+to_host_file_cmd=$lt_cv_to_host_file_cmd
+AC_MSG_RESULT([$lt_cv_to_host_file_cmd])
+_LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd],
+ [0], [convert $build file names to $host format])dnl
+
+AC_MSG_CHECKING([how to convert $build file names to toolchain format])
+AC_CACHE_VAL(lt_cv_to_tool_file_cmd,
+[#assume ordinary cross tools, or native build.
+lt_cv_to_tool_file_cmd=func_convert_file_noop
+case $host in
+ *-*-mingw* )
+ case $build in
+ *-*-mingw* ) # actually msys
+ lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32
+ ;;
+ esac
+ ;;
+esac
+])
+to_tool_file_cmd=$lt_cv_to_tool_file_cmd
+AC_MSG_RESULT([$lt_cv_to_tool_file_cmd])
+_LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd],
+ [0], [convert $build files to toolchain format])dnl
+])# _LT_PATH_CONVERSION_FUNCTIONS
diff --git a/thirdparty/glog/glog-0.3.4/m4/ltoptions.m4 b/thirdparty/glog/glog-0.3.5/m4/ltoptions.m4
index 5d9acd8..5d9acd8 100644
--- a/thirdparty/glog/glog-0.3.4/m4/ltoptions.m4
+++ b/thirdparty/glog/glog-0.3.5/m4/ltoptions.m4
diff --git a/thirdparty/glog/glog-0.3.4/m4/ltsugar.m4 b/thirdparty/glog/glog-0.3.5/m4/ltsugar.m4
index 9000a05..9000a05 100644
--- a/thirdparty/glog/glog-0.3.4/m4/ltsugar.m4
+++ b/thirdparty/glog/glog-0.3.5/m4/ltsugar.m4
diff --git a/thirdparty/glog/glog-0.3.4/m4/ltversion.m4 b/thirdparty/glog/glog-0.3.5/m4/ltversion.m4
index 07a8602..07a8602 100644
--- a/thirdparty/glog/glog-0.3.4/m4/ltversion.m4
+++ b/thirdparty/glog/glog-0.3.5/m4/ltversion.m4
diff --git a/thirdparty/glog/glog-0.3.4/m4/lt~obsolete.m4 b/thirdparty/glog/glog-0.3.5/m4/lt~obsolete.m4
index c573da9..c573da9 100644
--- a/thirdparty/glog/glog-0.3.4/m4/lt~obsolete.m4
+++ b/thirdparty/glog/glog-0.3.5/m4/lt~obsolete.m4
diff --git a/thirdparty/glog/glog-0.3.4/m4/namespaces.m4 b/thirdparty/glog/glog-0.3.5/m4/namespaces.m4
index d78dbe4..d78dbe4 100644
--- a/thirdparty/glog/glog-0.3.4/m4/namespaces.m4
+++ b/thirdparty/glog/glog-0.3.5/m4/namespaces.m4
diff --git a/thirdparty/glog/glog-0.3.4/m4/pc_from_ucontext.m4 b/thirdparty/glog/glog-0.3.5/m4/pc_from_ucontext.m4
index daffddb..daffddb 100644
--- a/thirdparty/glog/glog-0.3.4/m4/pc_from_ucontext.m4
+++ b/thirdparty/glog/glog-0.3.5/m4/pc_from_ucontext.m4
diff --git a/thirdparty/glog/glog-0.3.4/m4/stl_namespace.m4 b/thirdparty/glog/glog-0.3.5/m4/stl_namespace.m4
index 989ad80..989ad80 100644
--- a/thirdparty/glog/glog-0.3.4/m4/stl_namespace.m4
+++ b/thirdparty/glog/glog-0.3.5/m4/stl_namespace.m4
diff --git a/thirdparty/glog/glog-0.3.4/m4/using_operator.m4 b/thirdparty/glog/glog-0.3.5/m4/using_operator.m4
index 95a9951..95a9951 100644
--- a/thirdparty/glog/glog-0.3.4/m4/using_operator.m4
+++ b/thirdparty/glog/glog-0.3.5/m4/using_operator.m4
diff --git a/thirdparty/glog/glog-0.3.5/missing b/thirdparty/glog/glog-0.3.5/missing
new file mode 100644
index 0000000..1c8ff70
--- /dev/null
+++ b/thirdparty/glog/glog-0.3.5/missing
@@ -0,0 +1,367 @@
+#! /bin/sh
+# Common stub for a few missing GNU programs while installing.
+
+scriptversion=2006-05-10.23
+
+# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
+# Free Software Foundation, Inc.
+# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+if test $# -eq 0; then
+ echo 1>&2 "Try \`$0 --help' for more information"
+ exit 1
+fi
+
+run=:
+sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
+sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
+
+# In the cases where this matters, `missing' is being run in the
+# srcdir already.
+if test -f configure.ac; then
+ configure_ac=configure.ac
+else
+ configure_ac=configure.in
+fi
+
+msg="missing on your system"
+
+case $1 in
+--run)
+ # Try to run requested program, and just exit if it succeeds.
+ run=
+ shift
+ "$@" && exit 0
+ # Exit code 63 means version mismatch. This often happens
+ # when the user try to use an ancient version of a tool on
+ # a file that requires a minimum version. In this case we
+ # we should proceed has if the program had been absent, or
+ # if --run hadn't been passed.
+ if test $? = 63; then
+ run=:
+ msg="probably too old"
+ fi
+ ;;
+
+ -h|--h|--he|--hel|--help)
+ echo "\
+$0 [OPTION]... PROGRAM [ARGUMENT]...
+
+Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
+error status if there is no known handling for PROGRAM.
+
+Options:
+ -h, --help display this help and exit
+ -v, --version output version information and exit
+ --run try to run the given command, and emulate it if it fails
+
+Supported PROGRAM values:
+ aclocal touch file \`aclocal.m4'
+ autoconf touch file \`configure'
+ autoheader touch file \`config.h.in'
+ autom4te touch the output file, or create a stub one
+ automake touch all \`Makefile.in' files
+ bison create \`y.tab.[ch]', if possible, from existing .[ch]
+ flex create \`lex.yy.c', if possible, from existing .c
+ help2man touch the output file
+ lex create \`lex.yy.c', if possible, from existing .c
+ makeinfo touch the output file
+ tar try tar, gnutar, gtar, then tar without non-portable flags
+ yacc create \`y.tab.[ch]', if possible, from existing .[ch]
+
+Send bug reports to <bug-automake@gnu.org>."
+ exit $?
+ ;;
+
+ -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
+ echo "missing $scriptversion (GNU Automake)"
+ exit $?
+ ;;
+
+ -*)
+ echo 1>&2 "$0: Unknown \`$1' option"
+ echo 1>&2 "Try \`$0 --help' for more information"
+ exit 1
+ ;;
+
+esac
+
+# Now exit if we have it, but it failed. Also exit now if we
+# don't have it and --version was passed (most likely to detect
+# the program).
+case $1 in
+ lex|yacc)
+ # Not GNU programs, they don't have --version.
+ ;;
+
+ tar)
+ if test -n "$run"; then
+ echo 1>&2 "ERROR: \`tar' requires --run"
+ exit 1
+ elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+ exit 1
+ fi
+ ;;
+
+ *)
+ if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+ # We have it, but it failed.
+ exit 1
+ elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+ # Could not run --version or --help. This is probably someone
+ # running `$TOOL --version' or `$TOOL --help' to check whether
+ # $TOOL exists and not knowing $TOOL uses missing.
+ exit 1
+ fi
+ ;;
+esac
+
+# If it does not exist, or fails to run (possibly an outdated version),
+# try to emulate it.
+case $1 in
+ aclocal*)
+ echo 1>&2 "\
+WARNING: \`$1' is $msg. You should only need it if
+ you modified \`acinclude.m4' or \`${configure_ac}'. You might want
+ to install the \`Automake' and \`Perl' packages. Grab them from
+ any GNU archive site."
+ touch aclocal.m4
+ ;;
+
+ autoconf)
+ echo 1>&2 "\
+WARNING: \`$1' is $msg. You should only need it if
+ you modified \`${configure_ac}'. You might want to install the
+ \`Autoconf' and \`GNU m4' packages. Grab them from any GNU
+ archive site."
+ touch configure
+ ;;
+
+ autoheader)
+ echo 1>&2 "\
+WARNING: \`$1' is $msg. You should only need it if
+ you modified \`acconfig.h' or \`${configure_ac}'. You might want
+ to install the \`Autoconf' and \`GNU m4' packages. Grab them
+ from any GNU archive site."
+ files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
+ test -z "$files" && files="config.h"
+ touch_files=
+ for f in $files; do
+ case $f in
+ *:*) touch_files="$touch_files "`echo "$f" |
+ sed -e 's/^[^:]*://' -e 's/:.*//'`;;
+ *) touch_files="$touch_files $f.in";;
+ esac
+ done
+ touch $touch_files
+ ;;
+
+ automake*)
+ echo 1>&2 "\
+WARNING: \`$1' is $msg. You should only need it if
+ you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
+ You might want to install the \`Automake' and \`Perl' packages.
+ Grab them from any GNU archive site."
+ find . -type f -name Makefile.am -print |
+ sed 's/\.am$/.in/' |
+ while read f; do touch "$f"; done
+ ;;
+
+ autom4te)
+ echo 1>&2 "\
+WARNING: \`$1' is needed, but is $msg.
+ You might have modified some files without having the
+ proper tools for further handling them.
+ You can get \`$1' as part of \`Autoconf' from any GNU
+ archive site."
+
+ file=`echo "$*" | sed -n "$sed_output"`
+ test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+ if test -f "$file"; then
+ touch $file
+ else
+ test -z "$file" || exec >$file
+ echo "#! /bin/sh"
+ echo "# Created by GNU Automake missing as a replacement of"
+ echo "# $ $@"
+ echo "exit 0"
+ chmod +x $file
+ exit 1
+ fi
+ ;;
+
+ bison|yacc)
+ echo 1>&2 "\
+WARNING: \`$1' $msg. You should only need it if
+ you modified a \`.y' file. You may need the \`Bison' package
+ in order for those modifications to take effect. You can get
+ \`Bison' from any GNU archive site."
+ rm -f y.tab.c y.tab.h
+ if test $# -ne 1; then
+ eval LASTARG="\${$#}"
+ case $LASTARG in
+ *.y)
+ SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
+ if test -f "$SRCFILE"; then
+ cp "$SRCFILE" y.tab.c
+ fi
+ SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
+ if test -f "$SRCFILE"; then
+ cp "$SRCFILE" y.tab.h
+ fi
+ ;;
+ esac
+ fi
+ if test ! -f y.tab.h; then
+ echo >y.tab.h
+ fi
+ if test ! -f y.tab.c; then
+ echo 'main() { return 0; }' >y.tab.c
+ fi
+ ;;
+
+ lex|flex)
+ echo 1>&2 "\
+WARNING: \`$1' is $msg. You should only need it if
+ you modified a \`.l' file. You may need the \`Flex' package
+ in order for those modifications to take effect. You can get
+ \`Flex' from any GNU archive site."
+ rm -f lex.yy.c
+ if test $# -ne 1; then
+ eval LASTARG="\${$#}"
+ case $LASTARG in
+ *.l)
+ SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
+ if test -f "$SRCFILE"; then
+ cp "$SRCFILE" lex.yy.c
+ fi
+ ;;
+ esac
+ fi
+ if test ! -f lex.yy.c; then
+ echo 'main() { return 0; }' >lex.yy.c
+ fi
+ ;;
+
+ help2man)
+ echo 1>&2 "\
+WARNING: \`$1' is $msg. You should only need it if
+ you modified a dependency of a manual page. You may need the
+ \`Help2man' package in order for those modifications to take
+ effect. You can get \`Help2man' from any GNU archive site."
+
+ file=`echo "$*" | sed -n "$sed_output"`
+ test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+ if test -f "$file"; then
+ touch $file
+ else
+ test -z "$file" || exec >$file
+ echo ".ab help2man is required to generate this page"
+ exit 1
+ fi
+ ;;
+
+ makeinfo)
+ echo 1>&2 "\
+WARNING: \`$1' is $msg. You should only need it if
+ you modified a \`.texi' or \`.texinfo' file, or any other file
+ indirectly affecting the aspect of the manual. The spurious
+ call might also be the consequence of using a buggy \`make' (AIX,
+ DU, IRIX). You might want to install the \`Texinfo' package or
+ the \`GNU make' package. Grab either from any GNU archive site."
+ # The file to touch is that specified with -o ...
+ file=`echo "$*" | sed -n "$sed_output"`
+ test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+ if test -z "$file"; then
+ # ... or it is the one specified with @setfilename ...
+ infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
+ file=`sed -n '
+ /^@setfilename/{
+ s/.* \([^ ]*\) *$/\1/
+ p
+ q
+ }' $infile`
+ # ... or it is derived from the source name (dir/f.texi becomes f.info)
+ test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
+ fi
+ # If the file does not exist, the user really needs makeinfo;
+ # let's fail without touching anything.
+ test -f $file || exit 1
+ touch $file
+ ;;
+
+ tar)
+ shift
+
+ # We have already tried tar in the generic part.
+ # Look for gnutar/gtar before invocation to avoid ugly error
+ # messages.
+ if (gnutar --version > /dev/null 2>&1); then
+ gnutar "$@" && exit 0
+ fi
+ if (gtar --version > /dev/null 2>&1); then
+ gtar "$@" && exit 0
+ fi
+ firstarg="$1"
+ if shift; then
+ case $firstarg in
+ *o*)
+ firstarg=`echo "$firstarg" | sed s/o//`
+ tar "$firstarg" "$@" && exit 0
+ ;;
+ esac
+ case $firstarg in
+ *h*)
+ firstarg=`echo "$firstarg" | sed s/h//`
+ tar "$firstarg" "$@" && exit 0
+ ;;
+ esac
+ fi
+
+ echo 1>&2 "\
+WARNING: I can't seem to be able to run \`tar' with the given arguments.
+ You may want to install GNU tar or Free paxutils, or check the
+ command line arguments."
+ exit 1
+ ;;
+
+ *)
+ echo 1>&2 "\
+WARNING: \`$1' is needed, and is $msg.
+ You might have modified some files without having the
+ proper tools for further handling them. Check the \`README' file,
+ it often tells you about the needed prerequisites for installing
+ this package. You may also peek at any GNU archive site, in case
+ some other package would contain this missing \`$1' program."
+ exit 1
+ ;;
+esac
+
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/thirdparty/glog/glog-0.3.5/mkinstalldirs b/thirdparty/glog/glog-0.3.5/mkinstalldirs
new file mode 100644
index 0000000..ef7e16f
--- /dev/null
+++ b/thirdparty/glog/glog-0.3.5/mkinstalldirs
@@ -0,0 +1,161 @@
+#! /bin/sh
+# mkinstalldirs --- make directory hierarchy
+
+scriptversion=2006-05-11.19
+
+# Original author: Noah Friedman <friedman@prep.ai.mit.edu>
+# Created: 1993-05-16
+# Public domain.
+#
+# This file is maintained in Automake, please report
+# bugs to <bug-automake@gnu.org> or send patches to
+# <automake-patches@gnu.org>.
+
+nl='
+'
+IFS=" "" $nl"
+errstatus=0
+dirmode=
+
+usage="\
+Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
+
+Create each directory DIR (with mode MODE, if specified), including all
+leading file name components.
+
+Report bugs to <bug-automake@gnu.org>."
+
+# process command line arguments
+while test $# -gt 0 ; do
+ case $1 in
+ -h | --help | --h*) # -h for help
+ echo "$usage"
+ exit $?
+ ;;
+ -m) # -m PERM arg
+ shift
+ test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
+ dirmode=$1
+ shift
+ ;;
+ --version)
+ echo "$0 $scriptversion"
+ exit $?
+ ;;
+ --) # stop option processing
+ shift
+ break
+ ;;
+ -*) # unknown option
+ echo "$usage" 1>&2
+ exit 1
+ ;;
+ *) # first non-opt arg
+ break
+ ;;
+ esac
+done
+
+for file
+do
+ if test -d "$file"; then
+ shift
+ else
+ break
+ fi
+done
+
+case $# in
+ 0) exit 0 ;;
+esac
+
+# Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and
+# mkdir -p a/c at the same time, both will detect that a is missing,
+# one will create a, then the other will try to create a and die with
+# a "File exists" error. This is a problem when calling mkinstalldirs
+# from a parallel make. We use --version in the probe to restrict
+# ourselves to GNU mkdir, which is thread-safe.
+case $dirmode in
+ '')
+ if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
+ echo "mkdir -p -- $*"
+ exec mkdir -p -- "$@"
+ else
+ # On NextStep and OpenStep, the `mkdir' command does not
+ # recognize any option. It will interpret all options as
+ # directories to create, and then abort because `.' already
+ # exists.
+ test -d ./-p && rmdir ./-p
+ test -d ./--version && rmdir ./--version
+ fi
+ ;;
+ *)
+ if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 &&
+ test ! -d ./--version; then
+ echo "mkdir -m $dirmode -p -- $*"
+ exec mkdir -m "$dirmode" -p -- "$@"
+ else
+ # Clean up after NextStep and OpenStep mkdir.
+ for d in ./-m ./-p ./--version "./$dirmode";
+ do
+ test -d $d && rmdir $d
+ done
+ fi
+ ;;
+esac
+
+for file
+do
+ case $file in
+ /*) pathcomp=/ ;;
+ *) pathcomp= ;;
+ esac
+ oIFS=$IFS
+ IFS=/
+ set fnord $file
+ shift
+ IFS=$oIFS
+
+ for d
+ do
+ test "x$d" = x && continue
+
+ pathcomp=$pathcomp$d
+ case $pathcomp in
+ -*) pathcomp=./$pathcomp ;;
+ esac
+
+ if test ! -d "$pathcomp"; then
+ echo "mkdir $pathcomp"
+
+ mkdir "$pathcomp" || lasterr=$?
+
+ if test ! -d "$pathcomp"; then
+ errstatus=$lasterr
+ else
+ if test ! -z "$dirmode"; then
+ echo "chmod $dirmode $pathcomp"
+ lasterr=
+ chmod "$dirmode" "$pathcomp" || lasterr=$?
+
+ if test ! -z "$lasterr"; then
+ errstatus=$lasterr
+ fi
+ fi
+ fi
+ fi
+
+ pathcomp=$pathcomp/
+ done
+done
+
+exit $errstatus
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/thirdparty/glog/glog-0.3.4/packages/deb.sh b/thirdparty/glog/glog-0.3.5/packages/deb.sh
index a1cdf32..a1cdf32 100644
--- a/thirdparty/glog/glog-0.3.4/packages/deb.sh
+++ b/thirdparty/glog/glog-0.3.5/packages/deb.sh
diff --git a/thirdparty/glog/glog-0.3.4/packages/deb/README b/thirdparty/glog/glog-0.3.5/packages/deb/README
index 57becfd..57becfd 100644
--- a/thirdparty/glog/glog-0.3.4/packages/deb/README
+++ b/thirdparty/glog/glog-0.3.5/packages/deb/README
diff --git a/thirdparty/glog/glog-0.3.4/packages/deb/changelog b/thirdparty/glog/glog-0.3.5/packages/deb/changelog
index 0d730a6..261cfd5 100644
--- a/thirdparty/glog/glog-0.3.4/packages/deb/changelog
+++ b/thirdparty/glog/glog-0.3.5/packages/deb/changelog
@@ -1,3 +1,9 @@
+google-glog (0.3.5-1) unstable; urgency=low
+
+ * New upstream release.
+
+ -- Google Inc. <opensource@google.com> Tue, 09 May 2017 16:22:12 +0900
+
google-glog (0.3.4-1) unstable; urgency=low
* New upstream release.
diff --git a/thirdparty/glog/glog-0.3.4/packages/deb/compat b/thirdparty/glog/glog-0.3.5/packages/deb/compat
index b8626c4..b8626c4 100644
--- a/thirdparty/glog/glog-0.3.4/packages/deb/compat
+++ b/thirdparty/glog/glog-0.3.5/packages/deb/compat
diff --git a/thirdparty/glog/glog-0.3.4/packages/deb/control b/thirdparty/glog/glog-0.3.5/packages/deb/control
index 110a72c..110a72c 100644
--- a/thirdparty/glog/glog-0.3.4/packages/deb/control
+++ b/thirdparty/glog/glog-0.3.5/packages/deb/control
diff --git a/thirdparty/glog/glog-0.3.4/packages/deb/copyright b/thirdparty/glog/glog-0.3.5/packages/deb/copyright
index b2ce8e8..b2ce8e8 100644
--- a/thirdparty/glog/glog-0.3.4/packages/deb/copyright
+++ b/thirdparty/glog/glog-0.3.5/packages/deb/copyright
diff --git a/thirdparty/glog/glog-0.3.4/packages/deb/docs b/thirdparty/glog/glog-0.3.5/packages/deb/docs
index c3d0789..c3d0789 100644
--- a/thirdparty/glog/glog-0.3.4/packages/deb/docs
+++ b/thirdparty/glog/glog-0.3.5/packages/deb/docs
diff --git a/thirdparty/glog/glog-0.3.4/packages/deb/libgoogle-glog-dev.dirs b/thirdparty/glog/glog-0.3.5/packages/deb/libgoogle-glog-dev.dirs
index bddfbf5..bddfbf5 100644
--- a/thirdparty/glog/glog-0.3.4/packages/deb/libgoogle-glog-dev.dirs
+++ b/thirdparty/glog/glog-0.3.5/packages/deb/libgoogle-glog-dev.dirs
diff --git a/thirdparty/glog/glog-0.3.4/packages/deb/libgoogle-glog-dev.install b/thirdparty/glog/glog-0.3.5/packages/deb/libgoogle-glog-dev.install
index 9c61e86..9c61e86 100644
--- a/thirdparty/glog/glog-0.3.4/packages/deb/libgoogle-glog-dev.install
+++ b/thirdparty/glog/glog-0.3.5/packages/deb/libgoogle-glog-dev.install
diff --git a/thirdparty/glog/glog-0.3.4/packages/deb/libgoogle-glog0.dirs b/thirdparty/glog/glog-0.3.5/packages/deb/libgoogle-glog0.dirs
index 6845771..6845771 100644
--- a/thirdparty/glog/glog-0.3.4/packages/deb/libgoogle-glog0.dirs
+++ b/thirdparty/glog/glog-0.3.5/packages/deb/libgoogle-glog0.dirs
diff --git a/thirdparty/glog/glog-0.3.4/packages/deb/libgoogle-glog0.install b/thirdparty/glog/glog-0.3.5/packages/deb/libgoogle-glog0.install
index 704ea87..704ea87 100644
--- a/thirdparty/glog/glog-0.3.4/packages/deb/libgoogle-glog0.install
+++ b/thirdparty/glog/glog-0.3.5/packages/deb/libgoogle-glog0.install
diff --git a/thirdparty/glog/glog-0.3.4/packages/deb/rules b/thirdparty/glog/glog-0.3.5/packages/deb/rules
index f520bef..f520bef 100644
--- a/thirdparty/glog/glog-0.3.4/packages/deb/rules
+++ b/thirdparty/glog/glog-0.3.5/packages/deb/rules
diff --git a/thirdparty/glog/glog-0.3.4/packages/rpm.sh b/thirdparty/glog/glog-0.3.5/packages/rpm.sh
index e5649a2..e5649a2 100644
--- a/thirdparty/glog/glog-0.3.4/packages/rpm.sh
+++ b/thirdparty/glog/glog-0.3.5/packages/rpm.sh
diff --git a/thirdparty/glog/glog-0.3.4/packages/rpm/rpm.spec b/thirdparty/glog/glog-0.3.5/packages/rpm/rpm.spec
index 6d58657..6d58657 100644
--- a/thirdparty/glog/glog-0.3.4/packages/rpm/rpm.spec
+++ b/thirdparty/glog/glog-0.3.5/packages/rpm/rpm.spec
diff --git a/thirdparty/glog/glog-0.3.4/src/base/commandlineflags.h b/thirdparty/glog/glog-0.3.5/src/base/commandlineflags.h
index c0979d4..11c3992 100644
--- a/thirdparty/glog/glog-0.3.4/src/base/commandlineflags.h
+++ b/thirdparty/glog/glog-0.3.5/src/base/commandlineflags.h
@@ -1,9 +1,9 @@
-// This file has been modified by Huawei.
-// Copyright (C) 2018£¬ Huawei.
-//
// Copyright (c) 2008, Google Inc.
// All rights reserved.
-//
+//
+// This file has been modified by Huawei.
+// Copyright (C) 2018-2019, Huawei.
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -64,6 +64,9 @@
#include "glog/logging.h"
+/*modify namespace fL to fL_ns,fLS to fLS_ns,
+ avoid conflict with other PDT using glog. */
+
#define DECLARE_VARIABLE(type, shorttype, name, tn) \
namespace fL_ns##shorttype { \
extern GOOGLE_GLOG_DLL_DECL type FLAGS_##name; \
@@ -124,6 +127,8 @@
// These macros (could be functions, but I don't want to bother with a .cc
// file), make it easier to initialize flags from the environment.
+/*close the env variable,
+ avoid conflict with other PDT using glog. */
#define EnvToString(envname, dflt) (dflt)
diff --git a/thirdparty/glog/glog-0.3.4/src/base/googleinit.h b/thirdparty/glog/glog-0.3.5/src/base/googleinit.h
index 5a8b515..5a8b515 100644
--- a/thirdparty/glog/glog-0.3.4/src/base/googleinit.h
+++ b/thirdparty/glog/glog-0.3.5/src/base/googleinit.h
diff --git a/thirdparty/glog/glog-0.3.4/src/base/mutex.h b/thirdparty/glog/glog-0.3.5/src/base/mutex.h
index 7a45516..ac96f9c 100644
--- a/thirdparty/glog/glog-0.3.4/src/base/mutex.h
+++ b/thirdparty/glog/glog-0.3.5/src/base/mutex.h
@@ -1,9 +1,9 @@
-// This file has been modified by Huawei.
-// Copyright (C) 2018£¬ Huawei.
-//
// Copyright (c) 2007, Google Inc.
// All rights reserved.
-//
+//
+// This file has been modified by Huawei.
+// Copyright (C) 2018-2019, Huawei.
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -111,7 +111,8 @@
/* open the trylock */
#define GMUTEX_TRYLOCK 1
-
+/* implement the rwlock which coming from rtp for app
+ don't change other processes log lock, Begin*/
#define USE_USR_GM_TIME 1
#define MPLOCKED "lock ; "
@@ -285,7 +286,6 @@ nstack_rwlock_write_unlock(nstack_rwlock_t *rwl)
nstack_atomic32_inc((nstack_atomic32_t *)(intptr_t)&rwl->cnt);
}
-
#if defined(NO_THREADS)
typedef int MutexType; // to keep a lock-count
#elif defined(_WIN32) || defined(__CYGWIN32__) || defined(__CYGWIN64__)
@@ -315,6 +315,9 @@ nstack_rwlock_write_unlock(nstack_rwlock_t *rwl)
// out, but then you'd have to unset HAVE_RWLOCK (at least on linux -- it
// *does* cause problems for FreeBSD, or MacOSX, but isn't needed
// for locking there.)
+
+/*linux define _XOPEN_SOURCE 700,
+ conflict, need add check. */
# ifdef __linux__
# ifndef _XOPEN_SOURCE
# define _XOPEN_SOURCE 500 // may be needed to get the rwlock calls
@@ -334,7 +337,8 @@ nstack_rwlock_write_unlock(nstack_rwlock_t *rwl)
#include <assert.h>
#include <stdlib.h> // for abort()
-
+/*modify namespace glog_internal_namespace_ to glog_ns_internal_namespace_,
+ avoid conflict with other PDT using glog. */
#define MUTEX_NAMESPACE glog_ns_internal_namespace_
@@ -353,9 +357,8 @@ class Mutex {
inline void Lock(); // Block if needed until free then acquire exclusively
inline void Unlock(); // Release a lock acquired via Lock()
-
+ /* force unlock the rwlock, Begin*/
inline void ForceUnlock(); // Release a lock acquired via Lock()
-
#ifdef GMUTEX_TRYLOCK
inline bool TryLock(); // If free, Lock() and return true, else return false
#endif
@@ -377,10 +380,9 @@ class Mutex {
// when we tell it to, and never makes assumptions is_safe_ is
// always true. volatile is the most reliable way to do that.
volatile bool is_safe_;
-
+ /* rwlock implement self, Begin*/
nstack_rwlock_t rwlock_;
-
inline void SetIsSafe() { is_safe_ = true; }
// Catch the error of writing Mutex when intending MutexLock.
@@ -432,19 +434,15 @@ void Mutex::ReaderUnlock() { Unlock(); }
if (is_safe_ && fncall(&mutex_) != 0) abort(); \
} while (0)
+/* reload the rwlock which coming from rtp for app
+ don't change other processes log lock, Begin*/
Mutex::Mutex() {
SetIsSafe();
if (is_safe_){
- if (glogCtrlOpt == USE_USR_GM_TIME) {
nstack_rwlock_lock_init(&rwlock_);
- }
- else
- {
if(pthread_rwlock_init(&mutex_, NULL) != 0)
abort();
- }
-
}
}
Mutex::~Mutex(){
@@ -479,7 +477,7 @@ void Mutex::ForceUnlock(){
}
else
{
-
+ //may fail,before sys relock variable cannot access, may has strange issue.
Mutex::TryLock();
Mutex::Unlock();
}
@@ -516,6 +514,7 @@ void Mutex::ReaderUnlock() {
SAFE_PTHREAD(pthread_rwlock_unlock);
}
}
+
#undef SAFE_PTHREAD
#elif defined(HAVE_PTHREAD)
diff --git a/thirdparty/glog/glog-0.3.5/src/config.h.cmake.in b/thirdparty/glog/glog-0.3.5/src/config.h.cmake.in
new file mode 100644
index 0000000..6635df1
--- /dev/null
+++ b/thirdparty/glog/glog-0.3.5/src/config.h.cmake.in
@@ -0,0 +1,184 @@
+/* define if glog doesn't use RTTI */
+#cmakedefine DISABLE_RTTI
+
+/* Namespace for Google classes */
+#cmakedefine GOOGLE_NAMESPACE ${GOOGLE_NAMESPACE}
+
+/* Define if you have the `dladdr' function */
+#cmakedefine HAVE_DLADDR
+
+/* Define if you have the `snprintf' function */
+#cmakedefine HAVE_SNPRINTF
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#cmakedefine HAVE_DLFCN_H
+
+/* Define to 1 if you have the <execinfo.h> header file. */
+#cmakedefine HAVE_EXECINFO_H
+
+/* Define if you have the `fcntl' function */
+#cmakedefine HAVE_FCNTL
+
+/* Define to 1 if you have the <glob.h> header file. */
+#cmakedefine HAVE_GLOB_H
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#cmakedefine HAVE_INTTYPES_H ${HAVE_INTTYPES_H}
+
+/* Define to 1 if you have the `pthread' library (-lpthread). */
+#cmakedefine HAVE_LIBPTHREAD
+
+/* Define to 1 if you have the <libunwind.h> header file. */
+#cmakedefine HAVE_LIBUNWIND_H
+
+/* define if you have google gflags library */
+#cmakedefine HAVE_LIB_GFLAGS
+
+/* define if you have google gmock library */
+#cmakedefine HAVE_LIB_GMOCK
+
+/* define if you have google gtest library */
+#cmakedefine HAVE_LIB_GTEST
+
+/* define if you have libunwind */
+#cmakedefine HAVE_LIB_UNWIND
+
+/* Define to 1 if you have the <memory.h> header file. */
+#cmakedefine HAVE_MEMORY_H
+
+/* define to disable multithreading support. */
+#cmakedefine NO_THREADS
+
+/* define if the compiler implements namespaces */
+#cmakedefine HAVE_NAMESPACES
+
+/* Define if you have the 'pread' function */
+#cmakedefine HAVE_PREAD
+
+/* Define if you have POSIX threads libraries and header files. */
+#cmakedefine HAVE_PTHREAD
+
+/* Define to 1 if you have the <pwd.h> header file. */
+#cmakedefine HAVE_PWD_H
+
+/* Define if you have the 'pwrite' function */
+#cmakedefine HAVE_PWRITE
+
+/* define if the compiler implements pthread_rwlock_* */
+#cmakedefine HAVE_RWLOCK
+
+/* Define if you have the 'sigaction' function */
+#cmakedefine HAVE_SIGACTION
+
+/* Define if you have the `sigaltstack' function */
+#cmakedefine HAVE_SIGALTSTACK
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#cmakedefine HAVE_STDINT_H ${HAVE_STDINT_H}
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#cmakedefine HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#cmakedefine HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#cmakedefine HAVE_STRING_H
+
+/* Define to 1 if you have the <syscall.h> header file. */
+#cmakedefine HAVE_SYSCALL_H
+
+/* Define to 1 if you have the <syslog.h> header file. */
+#cmakedefine HAVE_SYSLOG_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#cmakedefine HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/syscall.h> header file. */
+#cmakedefine HAVE_SYS_SYSCALL_H
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#cmakedefine HAVE_SYS_TIME_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#cmakedefine HAVE_SYS_TYPES_H ${HAVE_SYS_TYPES_H}
+
+/* Define to 1 if you have the <sys/ucontext.h> header file. */
+#cmakedefine HAVE_SYS_UCONTEXT_H
+
+/* Define to 1 if you have the <sys/utsname.h> header file. */
+#cmakedefine HAVE_SYS_UTSNAME_H
+
+/* Define to 1 if you have the <ucontext.h> header file. */
+#cmakedefine HAVE_UCONTEXT_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#cmakedefine HAVE_UNISTD_H ${HAVE_UNISTD_H}
+
+/* Define to 1 if you have the <unwind.h> header file. */
+#cmakedefine HAVE_UNWIND_H ${HAVE_UNWIND_H}
+
+/* define if the compiler supports using expression for operator */
+#cmakedefine HAVE_USING_OPERATOR
+
+/* define if your compiler has __attribute__ */
+#cmakedefine HAVE___ATTRIBUTE__
+
+/* define if your compiler has __builtin_expect */
+#cmakedefine HAVE___BUILTIN_EXPECT ${HAVE___BUILTIN_EXPECT}
+
+/* define if your compiler has __sync_val_compare_and_swap */
+#cmakedefine HAVE___SYNC_VAL_COMPARE_AND_SWAP
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+ */
+#cmakedefine LT_OBJDIR
+
+/* Name of package */
+#cmakedefine PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#cmakedefine PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#cmakedefine PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#cmakedefine PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#cmakedefine PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#cmakedefine PACKAGE_URL
+
+/* Define to the version of this package. */
+#cmakedefine PACKAGE_VERSION
+
+/* How to access the PC from a struct ucontext */
+#cmakedefine PC_FROM_UCONTEXT
+
+/* Define to necessary symbol if this constant uses a non-standard name on
+ your system. */
+#cmakedefine PTHREAD_CREATE_JOINABLE
+
+/* The size of `void *', as computed by sizeof. */
+#cmakedefine SIZEOF_VOID_P ${SIZEOF_VOID_P}
+
+/* Define to 1 if you have the ANSI C header files. */
+#cmakedefine STDC_HEADERS
+
+/* the namespace where STL code like vector<> is defined */
+#cmakedefine STL_NAMESPACE ${STL_NAMESPACE}
+
+/* location of source code */
+#cmakedefine TEST_SRC_DIR ${TEST_SRC_DIR}
+
+/* Version number of package */
+#cmakedefine VERSION
+
+/* Stops putting the code inside the Google namespace */
+#cmakedefine _END_GOOGLE_NAMESPACE_ ${_END_GOOGLE_NAMESPACE_}
+
+/* Puts following code inside the Google namespace */
+#cmakedefine _START_GOOGLE_NAMESPACE_ ${_START_GOOGLE_NAMESPACE_}
diff --git a/thirdparty/glog/glog-0.3.5/src/config.h.in b/thirdparty/glog/glog-0.3.5/src/config.h.in
new file mode 100644
index 0000000..8190f23
--- /dev/null
+++ b/thirdparty/glog/glog-0.3.5/src/config.h.in
@@ -0,0 +1,180 @@
+/* src/config.h.in. Generated from configure.ac by autoheader. */
+
+/* define if glog doesn't use RTTI */
+#undef DISABLE_RTTI
+
+/* Namespace for Google classes */
+#undef GOOGLE_NAMESPACE
+
+/* Define if you have the `dladdr' function */
+#undef HAVE_DLADDR
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Define to 1 if you have the <execinfo.h> header file. */
+#undef HAVE_EXECINFO_H
+
+/* Define if you have the `fcntl' function */
+#undef HAVE_FCNTL
+
+/* Define to 1 if you have the <glob.h> header file. */
+#undef HAVE_GLOB_H
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the `pthread' library (-lpthread). */
+#undef HAVE_LIBPTHREAD
+
+/* Define to 1 if you have the <libunwind.h> header file. */
+#undef HAVE_LIBUNWIND_H
+
+/* define if you have google gflags library */
+#undef HAVE_LIB_GFLAGS
+
+/* define if you have google gmock library */
+#undef HAVE_LIB_GMOCK
+
+/* define if you have google gtest library */
+#undef HAVE_LIB_GTEST
+
+/* define if you have libunwind */
+#undef HAVE_LIB_UNWIND
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* define if the compiler implements namespaces */
+#undef HAVE_NAMESPACES
+
+/* Define if you have the 'pread' function */
+#undef HAVE_PREAD
+
+/* Define if you have POSIX threads libraries and header files. */
+#undef HAVE_PTHREAD
+
+/* Define to 1 if you have the <pwd.h> header file. */
+#undef HAVE_PWD_H
+
+/* Define if you have the 'pwrite' function */
+#undef HAVE_PWRITE
+
+/* define if the compiler implements pthread_rwlock_* */
+#undef HAVE_RWLOCK
+
+/* Define if you have the 'sigaction' function */
+#undef HAVE_SIGACTION
+
+/* Define if you have the `sigaltstack' function */
+#undef HAVE_SIGALTSTACK
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the <syscall.h> header file. */
+#undef HAVE_SYSCALL_H
+
+/* Define to 1 if you have the <syslog.h> header file. */
+#undef HAVE_SYSLOG_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/syscall.h> header file. */
+#undef HAVE_SYS_SYSCALL_H
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#undef HAVE_SYS_TIME_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <sys/ucontext.h> header file. */
+#undef HAVE_SYS_UCONTEXT_H
+
+/* Define to 1 if you have the <sys/utsname.h> header file. */
+#undef HAVE_SYS_UTSNAME_H
+
+/* Define to 1 if you have the <ucontext.h> header file. */
+#undef HAVE_UCONTEXT_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to 1 if you have the <unwind.h> header file. */
+#undef HAVE_UNWIND_H
+
+/* define if the compiler supports using expression for operator */
+#undef HAVE_USING_OPERATOR
+
+/* define if your compiler has __attribute__ */
+#undef HAVE___ATTRIBUTE__
+
+/* define if your compiler has __builtin_expect */
+#undef HAVE___BUILTIN_EXPECT
+
+/* define if your compiler has __sync_val_compare_and_swap */
+#undef HAVE___SYNC_VAL_COMPARE_AND_SWAP
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+ */
+#undef LT_OBJDIR
+
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* How to access the PC from a struct ucontext */
+#undef PC_FROM_UCONTEXT
+
+/* Define to necessary symbol if this constant uses a non-standard name on
+ your system. */
+#undef PTHREAD_CREATE_JOINABLE
+
+/* The size of `void *', as computed by sizeof. */
+#undef SIZEOF_VOID_P
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* the namespace where STL code like vector<> is defined */
+#undef STL_NAMESPACE
+
+/* location of source code */
+#undef TEST_SRC_DIR
+
+/* Version number of package */
+#undef VERSION
+
+/* Stops putting the code inside the Google namespace */
+#undef _END_GOOGLE_NAMESPACE_
+
+/* Puts following code inside the Google namespace */
+#undef _START_GOOGLE_NAMESPACE_
diff --git a/thirdparty/glog/glog-0.3.4/src/config_for_unittests.h b/thirdparty/glog/glog-0.3.5/src/config_for_unittests.h
index 13ea8ea..13ea8ea 100644
--- a/thirdparty/glog/glog-0.3.4/src/config_for_unittests.h
+++ b/thirdparty/glog/glog-0.3.5/src/config_for_unittests.h
diff --git a/thirdparty/glog/glog-0.3.4/src/demangle.cc b/thirdparty/glog/glog-0.3.5/src/demangle.cc
index a90916c..c8a005e 100644
--- a/thirdparty/glog/glog-0.3.4/src/demangle.cc
+++ b/thirdparty/glog/glog-0.3.5/src/demangle.cc
@@ -1,9 +1,9 @@
-// This file has been modified by Huawei.
-// Copyright (C) 2018£¬ Huawei.
-//
// Copyright (c) 2006, Google Inc.
// All rights reserved.
//
+// This file has been modified by Huawei.
+// Copyright (C) 2018-2019, Huawei.
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -100,7 +100,7 @@ static const AbbrevPair kOperatorList[] = {
{ "sz", "sizeof" },
{ NULL, NULL },
};
-
+/**/
// List of builtin types from Itanium C++ ABI.
static const AbbrevPair kBuiltinTypeList[] = {
{ "v", "void" },
@@ -142,6 +142,7 @@ static const AbbrevPair kSubstitutionList[] = {
{ "Sd", "iostream" },
{ NULL, NULL }
};
+/**/
// State needed for demangling.
typedef struct {
@@ -153,7 +154,9 @@ typedef struct {
int prev_name_length; // For constructors/destructors.
short nest_level; // For nested names.
bool append; // Append flag.
- bool overflowed; // True if output gets overflowed.
+ /**/
+ bool overflowed; //// True if output gets overflowed.
+ /**/
} State;
// We don't use strlen() in libc since it's not guaranteed to be async
@@ -390,6 +393,7 @@ static void MaybeAppendSeparator(State *state) {
}
}
+/**/
// Cancel the last separator if necessary.
static void MaybeCancelLastSeparator(State *state) {
if (state->nest_level >= 1 && state->append &&
@@ -398,6 +402,7 @@ static void MaybeCancelLastSeparator(State *state) {
*state->out_cur = '\0';
}
}
+/**/
// Returns true if the identifier of the given length pointed to by
// "mangled_cur" is anonymous namespace.
@@ -619,7 +624,7 @@ static bool ParseSourceName(State *state) {
// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31775
// http://gcc.gnu.org/viewcvs?view=rev&revision=124467
static bool ParseLocalSourceName(State *state) {
- State copy = *state;
+ State copy = *state; //
if (ParseOneCharToken(state, 'L') && ParseSourceName(state) &&
Optional(ParseDiscriminator(state))) {
return true;
@@ -769,7 +774,7 @@ static bool ParseOperatorName(State *state) {
// Note: we don't care much about them since they don't appear in
// stack traces. The are special data.
static bool ParseSpecialName(State *state) {
- State copy = *state;
+ State copy = *state; //
if (ParseOneCharToken(state, 'T') &&
ParseCharClass(state, "VTIS") &&
ParseType(state)) {
@@ -855,7 +860,7 @@ static bool ParseNVOffset(State *state) {
// <v-offset> ::= <(offset) number> _ <(virtual offset) number>
static bool ParseVOffset(State *state) {
- State copy = *state;
+ State copy = *state; //
if (ParseNumber(state, NULL) && ParseOneCharToken(state, '_') &&
ParseNumber(state, NULL)) {
return true;
@@ -1007,7 +1012,7 @@ static bool ParseFunctionType(State *state) {
// <bare-function-type> ::= <(signature) type>+
static bool ParseBareFunctionType(State *state) {
- State copy = *state;
+ State copy = *state; //
DisableAppend(state);
if (OneOrMore(ParseType, state)) {
RestoreAppend(state, copy.append);
@@ -1043,7 +1048,7 @@ static bool ParseArrayType(State *state) {
// <pointer-to-member-type> ::= M <(class) type> <(member) type>
static bool ParsePointerToMemberType(State *state) {
- State copy = *state;
+ State copy = *state; //
if (ParseOneCharToken(state, 'M') && ParseType(state) &&
ParseType(state)) {
return true;
@@ -1080,7 +1085,7 @@ static bool ParseTemplateTemplateParam(State *state) {
// <template-args> ::= I <template-arg>+ E
static bool ParseTemplateArgs(State *state) {
- State copy = *state;
+ State copy = *state; //
DisableAppend(state);
if (ParseOneCharToken(state, 'I') &&
OneOrMore(ParseTemplateArg, state) &&
@@ -1182,7 +1187,7 @@ static bool ParseExpression(State *state) {
// // A bug in g++'s C++ ABI version 2 (-fabi-version=2).
// ::= LZ <encoding> E
static bool ParseExprPrimary(State *state) {
- State copy = *state;
+ State copy = *state; //
if (ParseOneCharToken(state, 'L') && ParseType(state) &&
ParseNumber(state, NULL) &&
ParseOneCharToken(state, 'E')) {
diff --git a/thirdparty/glog/glog-0.3.4/src/demangle.h b/thirdparty/glog/glog-0.3.5/src/demangle.h
index 9c75915..991b6ff 100644
--- a/thirdparty/glog/glog-0.3.4/src/demangle.h
+++ b/thirdparty/glog/glog-0.3.5/src/demangle.h
@@ -71,13 +71,14 @@
#define BASE_DEMANGLE_H_
#include "config.h"
+#include "glog/logging.h"
_START_GOOGLE_NAMESPACE_
// Demangle "mangled". On success, return true and write the
// demangled symbol name to "out". Otherwise, return false.
// "out" is modified even if demangling is unsuccessful.
-bool Demangle(const char *mangled, char *out, int out_size);
+bool GOOGLE_GLOG_DLL_DECL Demangle(const char *mangled, char *out, int out_size);
_END_GOOGLE_NAMESPACE_
diff --git a/thirdparty/glog/glog-0.3.4/src/demangle_unittest.cc b/thirdparty/glog/glog-0.3.5/src/demangle_unittest.cc
index 9d219e6..32f3221 100644
--- a/thirdparty/glog/glog-0.3.4/src/demangle_unittest.cc
+++ b/thirdparty/glog/glog-0.3.5/src/demangle_unittest.cc
@@ -41,6 +41,11 @@
#include "googletest.h"
#include "config.h"
+#ifdef HAVE_LIB_GFLAGS
+#include <gflags/gflags.h>
+using namespace GFLAGS_NAMESPACE;
+#endif
+
GLOG_DEFINE_bool(demangle_filter, false,
"Run demangle_unittest in filter mode");
diff --git a/thirdparty/glog/glog-0.3.4/src/demangle_unittest.sh b/thirdparty/glog/glog-0.3.5/src/demangle_unittest.sh
index 91deee2..91deee2 100644
--- a/thirdparty/glog/glog-0.3.4/src/demangle_unittest.sh
+++ b/thirdparty/glog/glog-0.3.5/src/demangle_unittest.sh
diff --git a/thirdparty/glog/glog-0.3.4/src/demangle_unittest.txt b/thirdparty/glog/glog-0.3.5/src/demangle_unittest.txt
index 4e23c65..4e23c65 100644
--- a/thirdparty/glog/glog-0.3.4/src/demangle_unittest.txt
+++ b/thirdparty/glog/glog-0.3.5/src/demangle_unittest.txt
diff --git a/thirdparty/glog/glog-0.3.4/src/glog/log_severity.h b/thirdparty/glog/glog-0.3.5/src/glog/log_severity.h
index 99945a4..99945a4 100644
--- a/thirdparty/glog/glog-0.3.4/src/glog/log_severity.h
+++ b/thirdparty/glog/glog-0.3.5/src/glog/log_severity.h
diff --git a/thirdparty/glog/glog-0.3.4/src/glog/logging.h.in b/thirdparty/glog/glog-0.3.5/src/glog/logging.h.in
index 9d13916..bef3be4 100644
--- a/thirdparty/glog/glog-0.3.4/src/glog/logging.h.in
+++ b/thirdparty/glog/glog-0.3.5/src/glog/logging.h.in
@@ -1,9 +1,9 @@
-// This file has been modified by Huawei.
-// Copyright (C) 2018£¬ Huawei.
-//
// Copyright (c) 1999, Google Inc.
// All rights reserved.
//
+// This file has been modified by Huawei.
+// Copyright (C) 2018-2019, Huawei.
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -51,14 +51,6 @@
#endif
#include <vector>
-// Annoying stuff for windows -- makes sure clients can import these functions
-#ifndef GOOGLE_GLOG_DLL_DECL
-# if defined(_WIN32) && !defined(__CYGWIN__)
-# define GOOGLE_GLOG_DLL_DECL __declspec(dllimport)
-# else
-# define GOOGLE_GLOG_DLL_DECL
-# endif
-#endif
#if defined(_MSC_VER)
#define GLOG_MSVC_PUSH_DISABLE_WARNING(n) __pragma(warning(push)) \
__pragma(warning(disable:n))
@@ -68,6 +60,15 @@
#define GLOG_MSVC_POP_WARNING()
#endif
+// Annoying stuff for windows -- makes sure clients can import these functions
+#ifndef GOOGLE_GLOG_DLL_DECL
+# if defined(_WIN32) && !defined(__CYGWIN__)
+# define GOOGLE_GLOG_DLL_DECL __declspec(dllimport)
+# else
+# define GOOGLE_GLOG_DLL_DECL
+# endif
+#endif
+
// We care a lot about number of bits things take up. Unfortunately,
// systems define their bit-specific ints in a lot of different ways.
// We use our own way, and have a typedef to get there.
@@ -88,7 +89,10 @@
#include <gflags/gflags.h>
#endif
-
+/*modify namespace google to google_ns,
+ fL to fL_ns,fLS to fLS_ns,base to base_ns, internal to internal_ns,
+ glog_internal_namespace_ to glog_ns_internal_namespace_,base_logging to base_ns_logging,
+ avoid conflict with other PDT using glog. */
namespace google_ns {
@@ -134,15 +138,28 @@ typedef unsigned __int64 uint64;
#ifndef GOOGLE_PREDICT_BRANCH_NOT_TAKEN
#if @ac_cv_have___builtin_expect@
#define GOOGLE_PREDICT_BRANCH_NOT_TAKEN(x) (__builtin_expect(x, 0))
-#define GOOGLE_PREDICT_FALSE(x) (__builtin_expect(x, 0))
-#define GOOGLE_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1))
#else
#define GOOGLE_PREDICT_BRANCH_NOT_TAKEN(x) x
+#endif
+#endif
+
+#ifndef GOOGLE_PREDICT_FALSE
+#if @ac_cv_have___builtin_expect@
+#define GOOGLE_PREDICT_FALSE(x) (__builtin_expect(x, 0))
+#else
#define GOOGLE_PREDICT_FALSE(x) x
+#endif
+#endif
+
+#ifndef GOOGLE_PREDICT_TRUE
+#if @ac_cv_have___builtin_expect@
+#define GOOGLE_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1))
+#else
#define GOOGLE_PREDICT_TRUE(x) x
#endif
#endif
+
// Make a bunch of macros for logging. The way to log things is to stream
// things to LOG(<a particular severity level>). E.g.,
//
@@ -352,6 +369,9 @@ DECLARE_int32(minloglevel);
// default logging directory.
DECLARE_string(log_dir);
+// Set the log file mode.
+DECLARE_int32(logfile_mode);
+
// Sets the path of the directory into which to put additional links
// to the log files.
DECLARE_string(log_link);
@@ -419,9 +439,15 @@ DECLARE_bool(stop_logging_if_full_disk);
#define LOG_TO_STRING_FATAL(message) @ac_google_namespace@::NullStreamFatal()
#endif
+#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
+#define DCHECK_IS_ON() 0
+#else
+#define DCHECK_IS_ON() 1
+#endif
+
// For DFATAL, we want to use LogMessage (as opposed to
// LogMessageFatal), to be consistent with the original behavior.
-#ifdef NDEBUG
+#if !DCHECK_IS_ON()
#define COMPACT_GOOGLE_LOG_DFATAL COMPACT_GOOGLE_LOG_ERROR
#elif GOOGLE_STRIP_LOG <= 3
#define COMPACT_GOOGLE_LOG_DFATAL @ac_google_namespace@::LogMessage( \
@@ -559,7 +585,7 @@ class LogSink; // defined below
// vector<string> *outvec;
// The cast is to disambiguate NULL arguments.
#define LOG_STRING(severity, outvec) \
- LOG_TO_STRING_##severity(static_cast<vector<string>*>(outvec)).stream()
+ LOG_TO_STRING_##severity(static_cast<std::vector<std::string>*>(outvec)).stream()
#define LOG_IF(severity, condition) \
!(condition) ? (void) 0 : @ac_google_namespace@::LogMessageVoidify() & LOG(severity)
@@ -572,7 +598,7 @@ class LogSink; // defined below
SYSLOG_IF(FATAL, !(condition)) << "Assert failed: " #condition
// CHECK dies with a fatal error if condition is not true. It is *not*
-// controlled by NDEBUG, so the check will be executed regardless of
+// controlled by DCHECK_IS_ON(), so the check will be executed regardless of
// compilation mode. Therefore, it is safe to do things like:
// CHECK(fp->Write(x) == 4)
#define CHECK(condition) \
@@ -619,7 +645,7 @@ struct DummyClassToDefineOperator {};
// This declaration will allow use to use CHECK macros for user
// defined classes which have operator<< (e.g., stl_logging.h).
inline std::ostream& operator<<(
- std::ostream& out, const google_ns::DummyClassToDefineOperator&) {
+ std::ostream& out, const google_ns::DummyClassToDefineOperator&) { //False Positive
return out;
}
@@ -722,15 +748,15 @@ DEFINE_CHECK_OP_IMPL(Check_GT, > )
#if defined(STATIC_ANALYSIS)
// Only for static analysis tool to know that it is equivalent to assert
#define CHECK_OP_LOG(name, op, val1, val2, log) CHECK((val1) op (val2))
-#elif !defined(NDEBUG)
+#elif DCHECK_IS_ON()
// In debug mode, avoid constructing CheckOpStrings if possible,
// to reduce the overhead of CHECK statments by 2x.
// Real DCHECK-heavy tests have seen 1.5x speedups.
-// The meaning of "string" might be different between now and
+// The meaning of "string" might be different between now and
// when this macro gets invoked (e.g., if someone is experimenting
// with other string implementations that get defined after this
-// file is included). Save the current meaning now and use it
+// file is included). Save the current meaning now and use it
// in the macro.
typedef std::string _Check_string;
#define CHECK_OP_LOG(name, op, val1, val2, log) \
@@ -751,7 +777,7 @@ typedef std::string _Check_string;
@ac_google_namespace@::GetReferenceableValue(val2), \
#val1 " " #op " " #val2)) \
log(__FILE__, __LINE__, _result).stream()
-#endif // STATIC_ANALYSIS, !NDEBUG
+#endif // STATIC_ANALYSIS, DCHECK_IS_ON()
#if GOOGLE_STRIP_LOG <= 3
#define CHECK_OP(name, op, val1, val2) \
@@ -923,11 +949,16 @@ template <bool>
struct CompileAssert {
};
struct CrashReason;
+
+// Returns true if FailureSignalHandler is installed.
+bool IsFailureSignalHandlerInstalled();
} // namespace glog_ns_internal_namespace_
#define GOOGLE_GLOG_COMPILE_ASSERT(expr, msg) \
typedef @ac_google_namespace@::glog_ns_internal_namespace_::CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
+/*INVALID_REQUESTED_LOG_SEVERITY unused,
+ so add __attribute__((unused))*/
#define LOG_EVERY_N(severity, n) \
__attribute__((unused)) GOOGLE_GLOG_COMPILE_ASSERT(@ac_google_namespace@::GLOG_ ## severity < \
@@ -974,7 +1005,7 @@ const LogSeverity GLOG_0 = GLOG_ERROR;
// Plus some debug-logging macros that get compiled to nothing for production
-#ifndef NDEBUG
+#if DCHECK_IS_ON()
#define DLOG(severity) LOG(severity)
#define DVLOG(verboselevel) VLOG(verboselevel)
@@ -984,7 +1015,7 @@ const LogSeverity GLOG_0 = GLOG_ERROR;
LOG_IF_EVERY_N(severity, condition, n)
#define DLOG_ASSERT(condition) LOG_ASSERT(condition)
-// debug-only checking. not executed in NDEBUG mode.
+// debug-only checking. executed if DCHECK_IS_ON().
#define DCHECK(condition) CHECK(condition)
#define DCHECK_EQ(val1, val2) CHECK_EQ(val1, val2)
#define DCHECK_NE(val1, val2) CHECK_NE(val1, val2)
@@ -998,7 +1029,7 @@ const LogSeverity GLOG_0 = GLOG_ERROR;
#define DCHECK_STRNE(str1, str2) CHECK_STRNE(str1, str2)
#define DCHECK_STRCASENE(str1, str2) CHECK_STRCASENE(str1, str2)
-#else // NDEBUG
+#else // !DCHECK_IS_ON()
#define DLOG(severity) \
true ? (void) 0 : @ac_google_namespace@::LogMessageVoidify() & LOG(severity)
@@ -1079,7 +1110,7 @@ const LogSeverity GLOG_0 = GLOG_ERROR;
while (false) \
GLOG_MSVC_POP_WARNING() CHECK_STRCASENE(str1, str2)
-#endif // NDEBUG
+#endif // DCHECK_IS_ON()
// Log only in verbose mode.
@@ -1169,6 +1200,8 @@ public:
char* str() const { return pbase(); }
private:
+ LogStream(const LogStream&);
+ LogStream& operator=(const LogStream&);
base_ns_logging::LogStreamBuf streambuf_;
int ctr_; // Counter hack (for the LOG_EVERY_X() macro)
LogStream *self_; // Consistency check hack
@@ -1203,6 +1236,10 @@ public:
//to replace LogMessage(const char* file, int line, LogSeverity severity);
LogMessage(const char* file, int line, LogSeverity severity, int level);
+ /*reload the construct for print log directly,
+ no need assemble the log, Begin*/
+ LogMessage(LogSeverity severity);
+
// Constructor to log this message to a specified sink (if not NULL).
// Implied are: ctr = 0, send_method = &LogMessage::SendToSinkAndLog if
// also_send_to_log is true, send_method = &LogMessage::SendToSink otherwise.
@@ -1241,7 +1278,7 @@ public:
void SendToSyslogAndLog(); // Actually dispatch to syslog and the logs
// Call abort() or similar to perform LOG(FATAL) crash.
- static void Fail() @ac_cv___attribute___noreturn@;
+ static void @ac_cv___attribute___noreturn@ Fail();
std::ostream& stream();
@@ -1267,6 +1304,10 @@ private:
void Init(const char* file, int line, LogSeverity severity,int level,
void (LogMessage::*send_method)());
+
+ /*reload the function for print log directly,
+ no need assemble the log, Begin*/
+ void Init(LogSeverity severity, void (LogMessage::*send_method)());
// Used to fill in crash information during LOG(FATAL) failures.
void RecordCrashReason(glog_ns_internal_namespace_::CrashReason* reason);
@@ -1292,7 +1333,7 @@ class GOOGLE_GLOG_DLL_DECL LogMessageFatal : public LogMessage {
public:
LogMessageFatal(const char* file, int line);
LogMessageFatal(const char* file, int line, const CheckOpString& result);
- ~LogMessageFatal() @ac_cv___attribute___noreturn@;
+ @ac_cv___attribute___noreturn@ ~LogMessageFatal();
};
// A non-macro interface to the log facility; (useful
@@ -1307,6 +1348,35 @@ inline void LogAtLevel(int const severity, std::string const &msg) {
// LOG macros, 2. this macro can be used as C++ stream.
#define LOG_AT_LEVEL(severity) @ac_google_namespace@::LogMessage(__FILE__, __LINE__, severity).stream()
+// Check if it's compiled in C++11 mode.
+//
+// GXX_EXPERIMENTAL_CXX0X is defined by gcc and clang up to at least
+// gcc-4.7 and clang-3.1 (2011-12-13). __cplusplus was defined to 1
+// in gcc before 4.7 (Crosstool 16) and clang before 3.1, but is
+// defined according to the language version in effect thereafter.
+// Microsoft Visual Studio 14 (2015) sets __cplusplus==199711 despite
+// reasonably good C++11 support, so we set LANG_CXX for it and
+// newer versions (_MSC_VER >= 1900).
+#if (defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L || \
+ (defined(_MSC_VER) && _MSC_VER >= 1900))
+// Helper for CHECK_NOTNULL().
+//
+// In C++11, all cases can be handled by a single function. Since the value
+// category of the argument is preserved (also for rvalue references),
+// member initializer lists like the one below will compile correctly:
+//
+// Foo()
+// : x_(CHECK_NOTNULL(MethodReturningUniquePtr())) {}
+template <typename T>
+T CheckNotNull(const char* file, int line, const char* names, T&& t) {
+ if (t == nullptr) {
+ LogMessageFatal(file, line, new std::string(names));
+ }
+ return std::forward<T>(t);
+}
+
+#else
+
// A small helper for CHECK_NOTNULL().
template <typename T>
T* CheckNotNull(const char *file, int line, const char *names, T* t) {
@@ -1315,6 +1385,7 @@ T* CheckNotNull(const char *file, int line, const char *names, T* t) {
}
return t;
}
+#endif
// Allow folks to put a counter in the LOG_EVERY_X()'ed messages. This
// only works if ostream is a LogStream. If the ostream is not a
@@ -1351,7 +1422,7 @@ class GOOGLE_GLOG_DLL_DECL LogMessageVoidify {
void operator&(std::ostream&) { }
};
-
+/**/
// Flushes all log files that contains messages that are at least of
// the specified severity level. Thread-safe.
GOOGLE_GLOG_DLL_DECL void FlushLogFiles(LogSeverity min_severity);
@@ -1361,8 +1432,11 @@ GOOGLE_GLOG_DLL_DECL void FlushLogFiles(LogSeverity min_severity);
// locking -- used for catastrophic failures.
GOOGLE_GLOG_DLL_DECL void FlushLogFilesUnsafe(LogSeverity min_severity);
+/* release Mutex rwlock of sink_lock_, Begin*/
GOOGLE_GLOG_DLL_DECL void RleaseLogSinkLock(LogSeverity min_severity);
+/**/
+
//
// Set the destination to which a particular severity level of log
// messages is sent. If base_filename is "", it means "don't log this
@@ -1444,7 +1518,7 @@ GOOGLE_GLOG_DLL_DECL void SetStderrLogging(LogSeverity min_severity);
//
GOOGLE_GLOG_DLL_DECL void LogToStderr();
-
+/**/
//
// Make it so that all log messages of at least a particular severity are
// logged via email to a list of addresses (in addition to logging to the
@@ -1453,7 +1527,7 @@ GOOGLE_GLOG_DLL_DECL void LogToStderr();
//
GOOGLE_GLOG_DLL_DECL void SetEmailLogging(LogSeverity min_severity,
const char* addresses);
-
+/**/
// A simple function that sends email. dest is a commma-separated
// list of addressess. Thread-safe.
@@ -1601,7 +1675,7 @@ class GOOGLE_GLOG_DLL_DECL NullStreamFatal : public NullStream {
NullStreamFatal() { }
NullStreamFatal(const char* file, int line, const CheckOpString& result) :
NullStream(file, line, result) { }
- @ac_cv___attribute___noreturn@ ~NullStreamFatal() { _exit(1); }
+ @ac_cv___attribute___noreturn@ ~NullStreamFatal() throw () { _exit(1); }
};
// Install a signal handler that will dump signal information and a stack
diff --git a/thirdparty/glog/glog-0.3.4/src/glog/nstack_adapter.ph b/thirdparty/glog/glog-0.3.5/src/glog/nstack_adapter.ph
index 28aede0..f5c1d69 100644
--- a/thirdparty/glog/glog-0.3.4/src/glog/nstack_adapter.ph
+++ b/thirdparty/glog/glog-0.3.5/src/glog/nstack_adapter.ph
@@ -1,3 +1,14 @@
+// This file has been modified by Huawei.
+// Copyright (C) 2018-2019, Huawei.
+
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the BSD 2.0 and BSD License.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// BSD 2.0 and BSD License for more details.
+
#ifndef __NSTACK_ADAPTER_H__
#define __NSTACK_ADAPTER_H__
diff --git a/thirdparty/glog/glog-0.3.4/src/glog/nstack_glog.ph b/thirdparty/glog/glog-0.3.5/src/glog/nstack_glog.ph
index a78585c..3e5365c 100644
--- a/thirdparty/glog/glog-0.3.4/src/glog/nstack_glog.ph
+++ b/thirdparty/glog/glog-0.3.5/src/glog/nstack_glog.ph
@@ -1,3 +1,14 @@
+// This file has been modified by Huawei.
+// Copyright (C) 2018-2019, Huawei.
+
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the BSD 2.0 and BSD License.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// BSD 2.0 and BSD License for more details.
+
/**
* @file nstack_glog.ph
*
@@ -140,9 +151,8 @@ static inline void glogAtomicInc(glog_atomic_t *v)
*
* @return NA
* @par dependency:
-* <li>nstack_glog.ph£ºThis interface declares the header file.</li></ul>
- * @see NA¡£
-* @since V100R002C00
+* <li>nstack_glog.ph: This interface declares the header file.</li></ul>
+ * @see NA.
*/
void glog_print(unsigned int type,
@@ -156,6 +166,23 @@ void glog_print(unsigned int type,
...);
/*****************************************************************************
+* Prototype : glog_print_buffer
+* Description : print the assembled buffer to the log, no need add the prefix.
+* Input : unsigned int type,
+* : const char *buffer,
+* : unsigned int len
+* ...
+* Output : None
+* Return Value : None
+* issue : print the log direct, no need assemble
+* the header of the log
+*
+*****************************************************************************/
+void glog_print_buffer(unsigned int type,
+ const char *buffer,
+ unsigned int len);
+
+/*****************************************************************************
Function name: glogInit
Function description: Hlog initialization.
Input parameters: param incoming parameters that can make module ID and so on
@@ -265,7 +292,6 @@ void nstack_modify_log_dir(char *log_dir);
Enter the parameters: NA
Output parameters: NA
Return Value: NA
- issue: DTS2017110709083
*****************************************************************************/
void nstack_log_lock_release(void);
@@ -412,7 +438,6 @@ Return Value: NA
*****************************************************************************/
void glogFree(void *pointer);
-/* [DTS2017122008920][2012-12-21] */
void SetGlogCtrlOpt(int opt);
#ifdef __cplusplus
diff --git a/thirdparty/glog/glog-0.3.4/src/glog/nstack_glog_in.h b/thirdparty/glog/glog-0.3.5/src/glog/nstack_glog_in.h
index 52eb747..f0358f0 100644
--- a/thirdparty/glog/glog-0.3.4/src/glog/nstack_glog_in.h
+++ b/thirdparty/glog/glog-0.3.5/src/glog/nstack_glog_in.h
@@ -1,3 +1,14 @@
+// This file has been modified by Huawei.
+// Copyright (C) 2018-2019, Huawei.
+
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the BSD 2.0 and BSD License.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// BSD 2.0 and BSD License for more details.
+
/**
* @file nstack_glog_in.h
*
@@ -44,13 +55,14 @@ extern "C" {
<br/> upgrade effects: no.
*/
-typedef enum tagLogLevel
+typedef enum tagnStackLevel
{
GLOG_LEVEL_DEBUG = 0, /**< Debug*/
GLOG_LEVEL_INFO = 1, /**< INFO,google_ns::INFO */
GLOG_LEVEL_WARNING = 2, /**< WARNING,google_ns::WARNING */
GLOG_LEVEL_ERROR = 3, /**< ERROR,google_ns::ERROR */
GLOG_LEVEL_FATAL = 4, /**< FATAL,google_ns::FATAL */
+ GLOG_LEVEL_CUSTOM = 5,
GLOG_LEVEL_BUTT
} nstack_log_level;
@@ -74,9 +86,8 @@ typedef enum tagLogLevel
*
* @return NA
* @par dependency: product registration
-* <li>nstack_glog_in.h£ºThe interface declares the header file</li></ul>
- * @see NA¡£
-* @since V100R002C00
+* <li>nstack_glog_in.h: The interface declares the header file</li></ul>
+ * @see NA.
*/
typedef void (*nstack_log_hook)(unsigned int logCode,
unsigned int logLevel,
@@ -117,8 +128,7 @@ extern log_hook_tag_t g_log_hook_tag;
* @return 1 parameter passed in error: empty, or re-registered
* @par dependency: Requires product call
* <li>nstack_glog_in.h The interface declares the header file. </li></ul>
-* @see NA¡£
-* @since V100R002C00
+* @see NA.
*/
int nstack_log_hook_set(nstack_log_hook log_hook);
@@ -128,7 +138,7 @@ int nstack_log_hook_set(nstack_log_hook log_hook);
*
* @verbatim
Function Description: Set the log level to be printed.Support for reading environment variables:
- NSTACK_LOG_HOOK_LEVEL = DBG / INF / WAR / ERR / FTL,If the value of NSTACK_LOG_HOOK_LEVEL is set
+ NSTACK_LOG_HOOK_LEVEL = DBG / INF / WAR / ERR / EMG,If the value of NSTACK_LOG_HOOK_LEVEL is set
incorrectly, the log level is unchanged Dynamically set the level
Target users: users who use NSTACK to print logs
Use constraint: log level See nstack_log_level.
@@ -144,17 +154,15 @@ int nstack_log_hook_set(nstack_log_hook log_hook);
* @return 0 The function returns success
* @return 1 parameter passed in error: level is not in the range, before the log level unchanged
* @par dependency:NA
-* @see NA¡£
-* @since V100R002C00
+* @see NA.
*/
int nstack_log_hook_level_set(unsigned int log_level);
/**
-* @ingroup NSTACK_LOG£¬init the hook
+* @ingroup NSTACK_LOG, init the hook
-* @see NA¡£
-* @since V100R002C00
+* @see NA.
*/
void nstack_log_hook_init();
@@ -174,8 +182,7 @@ void nstack_log_hook_init();
*
* @return NA
* @par dependency:NA
-* @see NA¡£
-* @since V100R002C00
+* @see NA.
*/
void nstack_log_count_set(unsigned int count);
@@ -199,9 +206,8 @@ void nstack_log_count_set(unsigned int count);
* @return 0 The function returns success
* @return 1 parameter passed in error: the rank is not in range
* @par dependency:
-* <li>nstack_glog_in.h£ºThe interface declares the header file.</li></ul>
- * @see NA¡£
-* @since V100R002C00
+* <li>nstack_glog_in.h: The interface declares the header file.</li></ul>
+ * @see NA.
*/
int glogLevelSet(unsigned int logLevel);
diff --git a/thirdparty/glog/glog-0.3.4/src/glog/raw_logging.h.in b/thirdparty/glog/glog-0.3.5/src/glog/raw_logging.h.in
index 65076df..9f6735a 100644
--- a/thirdparty/glog/glog-0.3.4/src/glog/raw_logging.h.in
+++ b/thirdparty/glog/glog-0.3.5/src/glog/raw_logging.h.in
@@ -1,9 +1,9 @@
-// This file has been modified by Huawei.
-// Copyright (C) 2018£¬ Huawei.
-//
// Copyright (c) 2006, Google Inc.
// All rights reserved.
//
+// This file has been modified by Huawei.
+// Copyright (C) 2018-2019, Huawei.
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -91,7 +91,7 @@
// The following STRIP_LOG testing is performed in the header file so that it's
// possible to completely compile out the logging code and the log messages.
-#if STRIP_LOG == 0 //lint !e553 config.h.in Configuration
+#if STRIP_LOG == 0 //config.h.in Configuration
#define RAW_VLOG(verboselevel, ...) \
do { \
if (VLOG_IS_ON(verboselevel)) { \
@@ -102,31 +102,31 @@
#define RAW_VLOG(verboselevel, ...) RawLogStub__(0, __VA_ARGS__)
#endif // STRIP_LOG == 0
-/*[DTS2017102309930][2017-10-23][l00349752][VPP OR] modify namespace google to google_ns,
+/*modify namespace google to google_ns,
avoid conflict with other PDT using glog. */
-#if STRIP_LOG == 0 //lint !e553 config.h.in Configuration
+#if STRIP_LOG == 0 //config.h.in Configuration
#define RAW_LOG_INFO(...) google_ns::RawLog__(google_ns::GLOG_INFO, \
__FILE__, __LINE__, __VA_ARGS__)
#else
#define RAW_LOG_INFO(...) @ac_google_namespace@::RawLogStub__(0, __VA_ARGS__)
#endif // STRIP_LOG == 0
-#if STRIP_LOG <= 1 //lint !e553 config.h.in Configuration
+#if STRIP_LOG <= 1 //config.h.in Configuration
#define RAW_LOG_WARNING(...) google_ns::RawLog__(google_ns::GLOG_WARNING, \
__FILE__, __LINE__, __VA_ARGS__)
#else
#define RAW_LOG_WARNING(...) @ac_google_namespace@::RawLogStub__(0, __VA_ARGS__)
#endif // STRIP_LOG <= 1
-#if STRIP_LOG <= 2 //lint !e553 config.h.in Configuration
+#if STRIP_LOG <= 2 //config.h.in Configuration
#define RAW_LOG_ERROR(...) google_ns::RawLog__(google_ns::GLOG_ERROR, \
__FILE__, __LINE__, __VA_ARGS__)
#else
#define RAW_LOG_ERROR(...) @ac_google_namespace@::RawLogStub__(0, __VA_ARGS__)
#endif // STRIP_LOG <= 2
-#if STRIP_LOG <= 3 //lint !e553 config.h.in Configuration
+#if STRIP_LOG <= 3 //config.h.in Configuration
#define RAW_LOG_FATAL(...) google_ns::RawLog__(google_ns::GLOG_FATAL, \
__FILE__, __LINE__, __VA_ARGS__)
#else
diff --git a/thirdparty/glog/glog-0.3.4/src/glog/stl_logging.h.in b/thirdparty/glog/glog-0.3.5/src/glog/stl_logging.h.in
index 600945d..c5231f2 100644
--- a/thirdparty/glog/glog-0.3.4/src/glog/stl_logging.h.in
+++ b/thirdparty/glog/glog-0.3.5/src/glog/stl_logging.h.in
@@ -1,6 +1,9 @@
// Copyright (c) 2003, Google Inc.
// All rights reserved.
//
+// This file has been modified by Huawei.
+// Copyright (C) 2018-2019, Huawei.
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -80,8 +83,10 @@
// Forward declare these two, and define them after all the container streams
// operators so that we can recurse from pair -> container -> container -> pair
// properly.
+/*False Positive */
template<class First, class Second>
std::ostream& operator<<(std::ostream& out, const std::pair<First, Second>& p);
+/**/
@ac_google_start_namespace@
@@ -90,6 +95,7 @@ void PrintSequence(std::ostream& out, Iter begin, Iter end);
@ac_google_end_namespace@
+/*-esym(101,OUTPUT_TWO_ARG_CONTAINER) False Positive */
#define OUTPUT_TWO_ARG_CONTAINER(Sequence) \
template<class T1, class T2> \
inline std::ostream& operator<<(std::ostream& out, \
@@ -106,6 +112,7 @@ OUTPUT_TWO_ARG_CONTAINER(__gnu_cxx::slist)
#endif
#undef OUTPUT_TWO_ARG_CONTAINER
+/*+esym(101,OUTPUT_TWO_ARG_CONTAINER) */
#define OUTPUT_THREE_ARG_CONTAINER(Sequence) \
template<class T1, class T2, class T3> \
diff --git a/thirdparty/glog/glog-0.3.4/src/glog/vlog_is_on.h.in b/thirdparty/glog/glog-0.3.5/src/glog/vlog_is_on.h.in
index 3f4c4a3..3f4c4a3 100644
--- a/thirdparty/glog/glog-0.3.4/src/glog/vlog_is_on.h.in
+++ b/thirdparty/glog/glog-0.3.5/src/glog/vlog_is_on.h.in
diff --git a/thirdparty/glog/glog-0.3.4/src/googletest.h b/thirdparty/glog/glog-0.3.5/src/googletest.h
index ca99c8d..9562cfe 100644
--- a/thirdparty/glog/glog-0.3.4/src/googletest.h
+++ b/thirdparty/glog/glog-0.3.5/src/googletest.h
@@ -1,9 +1,9 @@
-// This file has been modified by Huawei.
-// Copyright (C) 2018£¬ Huawei.
-//
// Copyright (c) 2009, Google Inc.
// All rights reserved.
//
+// This file has been modified by Huawei.
+// Copyright (C) 2018-2019, Huawei.
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -72,7 +72,7 @@ extern GOOGLE_GLOG_DLL_DECL void (*g_logging_fail_func)();
_END_GOOGLE_NAMESPACE_
#undef GOOGLE_GLOG_DLL_DECL
-#define GOOGLE_GLOG_DLL_DECL
+#define GOOGLE_GLOG_DLL_DECL //
static inline string GetTempDir() {
#ifndef OS_WINDOWS
@@ -84,7 +84,7 @@ static inline string GetTempDir() {
#endif
}
-#if defined(OS_WINDOWS) && defined(_MSC_VER)
+#if defined(OS_WINDOWS) && defined(_MSC_VER) && !defined(TEST_SRC_DIR)
// The test will run in glog/vsproject/<project name>
// (e.g., glog/vsproject/logging_unittest).
static const char TEST_SRC_DIR[] = "../..";
@@ -172,7 +172,7 @@ void InitGoogleTest(int*, char**) {}
} \
} while (0)
-vector<void (*)()> g_testlist; // the tests to run
+vector<void (*)()> g_testlist; //// the tests to run
#define TEST(a, b) \
struct Test_##a##_##b { \
@@ -183,7 +183,7 @@ vector<void (*)()> g_testlist; // the tests to run
static Test_##a##_##b g_test_##a##_##b; \
void Test_##a##_##b::RunTest()
-
+/**/
static inline int RUN_ALL_TESTS() {
vector<void (*)()>::const_iterator it;
for (it = g_testlist.begin(); it != g_testlist.end(); ++it) {
@@ -192,7 +192,7 @@ static inline int RUN_ALL_TESTS() {
fprintf(stderr, "Passed %d tests\n\nPASS\n", (int)g_testlist.size());
return 0;
}
-
+/**/
_END_GOOGLE_NAMESPACE_
#endif // ! HAVE_LIB_GTEST
@@ -201,10 +201,12 @@ _START_GOOGLE_NAMESPACE_
static bool g_called_abort;
static jmp_buf g_jmp_buf;
+/**/
static inline void CalledAbort() {
g_called_abort = true;
longjmp(g_jmp_buf, 1);
}
+/**/
#ifdef OS_WINDOWS
// TODO(hamaji): Death test somehow doesn't work in Windows.
@@ -236,7 +238,7 @@ static inline void CalledAbort() {
#define BENCHMARK(n) static BenchmarkRegisterer __benchmark_ ## n (#n, &n);
-map<string, void (*)(int)> g_benchlist; // the benchmarks to run
+map<string, void (*)(int)> g_benchlist; //// the benchmarks to run
class BenchmarkRegisterer {
public:
@@ -258,9 +260,9 @@ static inline void RunSpecifiedBenchmarks() {
clock_t start = clock();
iter->second(iter_cnt);
double elapsed_ns =
- ((double)clock() - start) / CLOCKS_PER_SEC * 1000*1000*1000;
+ ((double)clock() - start) / CLOCKS_PER_SEC * 1000*1000*1000; //
printf("%s\t%8.2lf\t%10d\n",
- iter->first.c_str(), elapsed_ns / iter_cnt, iter_cnt);
+ iter->first.c_str(), elapsed_ns / iter_cnt, iter_cnt); //
}
puts("");
}
@@ -325,17 +327,20 @@ static CapturedStream * s_captured_streams[STDERR_FILENO+1];
// filename - File where output should be stored
static inline void CaptureTestOutput(int fd, const string & filename) {
CHECK((fd == STDOUT_FILENO) || (fd == STDERR_FILENO));
- CHECK(s_captured_streams[fd] == NULL);
- s_captured_streams[fd] = new CapturedStream(fd, filename);
+ CHECK(s_captured_streams[fd] == NULL); //
+ s_captured_streams[fd] = new CapturedStream(fd, filename); //
}
-static inline void CaptureTestStderr() {
+/**/
+static inline void CaptureTestStderr() { //
CaptureTestOutput(STDERR_FILENO, FLAGS_test_tmpdir + "/captured.err");
}
+
// Return the size (in bytes) of a file
static inline size_t GetFileSize(FILE * file) {
fseek(file, 0, SEEK_END);
return static_cast<size_t>(ftell(file));
}
+/**/
// Read the entire content of a file as a string
static inline string ReadEntireFile(FILE * file) {
const size_t file_size = GetFileSize(file);
@@ -384,6 +389,7 @@ static inline string GetCapturedTestStderr() {
return GetCapturedTestOutput(STDERR_FILENO);
}
+/**/
// Check if the string is [IWEF](\d{4}|DATE)
static inline bool IsLoggingPrefix(const string& s) {
if (s.size() != 5) return false;
@@ -393,6 +399,7 @@ static inline bool IsLoggingPrefix(const string& s) {
}
return true;
}
+/**/
// Convert log output into normalized form.
//
@@ -433,7 +440,7 @@ static inline string MungeLine(const string& line) {
static inline void StringReplace(string* str,
const string& oldsub,
- const string& newsub) {
+ const string& newsub) { //
size_t pos = str->find(oldsub);
if (pos != string::npos) {
str->replace(pos, oldsub.size(), newsub.c_str());
@@ -471,8 +478,8 @@ static inline void WriteToFile(const string& body, const string& file) {
}
static inline bool MungeAndDiffTestStderr(const string& golden_filename) {
- CapturedStream* cap = s_captured_streams[STDERR_FILENO];
- CHECK(cap) << ": did you forget CaptureTestStderr()?";
+ CapturedStream* cap = s_captured_streams[STDERR_FILENO]; //
+ CHECK(cap) << ": did you forget CaptureTestStderr()?"; //
cap->StopCapture();
@@ -502,10 +509,10 @@ static inline bool MungeAndDiffTestStderr(const string& golden_filename) {
#ifndef HAVE_LIB_GFLAGS
struct FlagSaver {
FlagSaver()
- : v_(FLAGS_v),
- stderrthreshold_(FLAGS_stderrthreshold),
- logtostderr_(FLAGS_logtostderr),
- alsologtostderr_(FLAGS_alsologtostderr) {}
+ : v_(FLAGS_v), //
+ stderrthreshold_(FLAGS_stderrthreshold), //
+ logtostderr_(FLAGS_logtostderr), //
+ alsologtostderr_(FLAGS_alsologtostderr) {} //
~FlagSaver() {
FLAGS_v = v_;
FLAGS_stderrthreshold = stderrthreshold_;
@@ -565,6 +572,7 @@ class Thread {
#endif
};
+/**/
static inline void SleepForMilliseconds(int t) {
#ifndef OS_WINDOWS
usleep(t * 1000);
@@ -572,6 +580,7 @@ static inline void SleepForMilliseconds(int t) {
Sleep(t);
#endif
}
+/**/
// Add hook for operator new to ensure there are no memory allocation.
diff --git a/thirdparty/glog/glog-0.3.4/src/logging.cc b/thirdparty/glog/glog-0.3.5/src/logging.cc
index 6245ebf..97c4b0b 100644
--- a/thirdparty/glog/glog-0.3.4/src/logging.cc
+++ b/thirdparty/glog/glog-0.3.5/src/logging.cc
@@ -1,9 +1,9 @@
-// This file has been modified by Huawei.
-// Copyright (C) 2018£¬ Huawei.
-//
// Copyright (c) 1999, Google Inc.
// All rights reserved.
//
+// This file has been modified by Huawei.
+// Copyright (C) 2018-2019, Huawei.
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -92,6 +92,10 @@ using std::perror;
using std::fdopen;
#endif
+#ifdef _WIN32
+#define fdopen _fdopen
+#endif
+
// There is no thread annotation support.
#define EXCLUSIVE_LOCKS_REQUIRED(mu)
@@ -114,7 +118,6 @@ unsigned int log_file_count = 10;
*/
unsigned int modify_path_count = 0;
-
int glogCtrlOpt = 0;
@@ -127,8 +130,6 @@ int glogCtrlOpt = 0;
* Return Value : char *
* Calls :
* Called By :
-*
-*
*****************************************************************************/
char * get_date_time(char *old_file, const char *log_name)
{
@@ -162,7 +163,6 @@ char * get_date_time(char *old_file, const char *log_name)
* Return Value : int
* Calls :
* Called By :
-*
*****************************************************************************/
static int remove_old_file(const char *log_path, const char *log_name)
{
@@ -336,21 +336,13 @@ GLOG_DEFINE_int32(logemaillevel, 999,
" ...)");
GLOG_DEFINE_string(logmailer, "/bin/mail",
"Mailer used to send logging email");
-
+/* */
// Compute the default value for --log_dir
static const char* DefaultLogDir() {
- const char* env;
- env = getenv("GOOGLE_LOG_DIR");
- if (env != NULL && env[0] != '\0') {
- return env;
- }
- env = getenv("TEST_TMPDIR");
- if (env != NULL && env[0] != '\0') {
- return env;
- }
return "";
}
-
+/**/
+GLOG_DEFINE_int32(logfile_mode, 0664, "Log file mode/permissions.");
GLOG_DEFINE_string(log_dir, DefaultLogDir(),
"If specified, logfiles are written into this directory instead "
@@ -371,7 +363,7 @@ GLOG_DEFINE_string(log_backtrace_at, "",
// TODO(hamaji): consider windows
#define PATH_SEPARATOR '/'
-
+/* */
#ifndef HAVE_PREAD
#if defined(OS_WINDOWS)
#include <BaseTsd.h>
@@ -407,7 +399,7 @@ static ssize_t pwrite(int fd, void* buf, size_t count, off_t offset) {
return len;
}
#endif // !HAVE_PWRITE
-static void GetHostName(string* hostname) {
+static void GetHostName(string* hostname) { // False Positive & call by LogDestination::hostname()
#if defined(HAVE_SYS_UTSNAME_H)
struct utsname buf;
if (0 != uname(&buf)) {
@@ -428,7 +420,7 @@ static void GetHostName(string* hostname) {
*hostname = "(unknown)";
#endif
}
-
+/**/
// Returns true iff terminal supports using colors in output.
static bool TerminalSupportsColor() {
@@ -445,6 +437,7 @@ static bool TerminalSupportsColor() {
!strcmp(term, "xterm") ||
!strcmp(term, "xterm-color") ||
!strcmp(term, "xterm-256color") ||
+ !strcmp(term, "screen-256color") ||
!strcmp(term, "screen") ||
!strcmp(term, "linux") ||
!strcmp(term, "cygwin");
@@ -462,7 +455,7 @@ enum GLogColor {
COLOR_YELLOW
};
-static GLogColor SeverityToColor(LogSeverity severity) {
+static GLogColor SeverityToColor(LogSeverity severity) {
assert(severity >= 0 && severity < NUM_SEVERITIES);
GLogColor color = COLOR_DEFAULT;
switch (severity) {
@@ -486,7 +479,7 @@ static GLogColor SeverityToColor(LogSeverity severity) {
#ifdef OS_WINDOWS
// Returns the character attribute for the given color.
-WORD GetColorAttribute(GLogColor color) {
+WORD GetColorAttribute(GLogColor color) {
switch (color) {
case COLOR_RED: return FOREGROUND_RED;
case COLOR_GREEN: return FOREGROUND_GREEN;
@@ -510,12 +503,12 @@ const char* GetAnsiColorCode(GLogColor color) {
#endif // OS_WINDOWS
-
+/* */
// Safely get max_log_size, overriding to 1 if it somehow gets defined as 0
static int32 MaxLogSize() {
return (FLAGS_max_log_size > 0 ? FLAGS_max_log_size : 1);
}
-
+/**/
// An arbitrary limit on the length of a single log message. This
// is so that streaming can be done more efficiently.
const size_t LogMessage::kMaxLogMessageLen = 30000;
@@ -528,7 +521,7 @@ struct LogMessage::LogMessageData {
char message_text_[LogMessage::kMaxLogMessageLen+1];
LogStream stream_;
char severity_; // What level is this LogMessage logged at?
- int level_;
+ int level_; //real message log level send in by nstack
int line_; // line number where logging call is.
void (LogMessage::*send_method_)(); // Call this in destructor to send
union { // At most one of these is used: union to keep the size low.
@@ -572,6 +565,7 @@ void glog_release_rw_lock()
{
#if defined(HAVE_PTHREAD) && defined(HAVE_RWLOCK)
if (glog_ns_internal_namespace_::IsGoogleLoggingInitialized()) {
+ /* force unlock the static rwlock*/
log_mutex.ForceUnlock();
fatal_msg_lock.ForceUnlock();
}
@@ -590,12 +584,14 @@ const char*const LogSeverityNames[NUM_SEVERITIES] = {
"INFO", "WARNING", "ERROR", "FATAL"
};
-
+/* add the debug level for print */
const char*const nstack_level_names[NUM_SEVERITIES+1] = {
"DEBUG", "INFO", "WARNING", "ERROR", "FATAL"
};
+
+
// Has the user called SetExitOnDFatal(true)?
static bool exit_on_dfatal = true;
@@ -633,7 +629,7 @@ class LogFileObject : public base_ns::Logger {
// It is the actual file length for the system loggers,
// i.e., INFO, ERROR, etc.
virtual uint32 LogSize() {
- MutexLock l(&lock_);
+ MutexLock l(&lock_); // False Positive
return file_length_;
}
@@ -641,10 +637,9 @@ class LogFileObject : public base_ns::Logger {
// can avoid grabbing a lock. Usually Flush() calls it after
// acquiring lock_.
void FlushUnlocked();
-
+ /* force unlock the LogFileObject rwlock lock_, */
void ReleaseObjectlock();
-
private:
static const uint32 kRolloverAttemptFrequency = 0x20;
@@ -691,10 +686,9 @@ class LogDestination {
static void FlushLogFiles(int min_severity);
static void FlushLogFilesUnsafe(int min_severity);
-
+ /* force unlock the class static rwlock sink_mutex_ and lock_, */
static void RleaseLogSinkLock(int min_severity);
-
// we set the maximum size of our packet to be 1400, the logic being
// to prevent fragmentation.
// Really this number is arbitrary.
@@ -774,7 +768,7 @@ LogSeverity LogDestination::email_logging_severity_ = 99999;
string LogDestination::addresses_;
string LogDestination::hostname_;
-vector<LogSink*>* LogDestination::sinks_ = NULL;
+vector<LogSink*>* LogDestination::sinks_ = NULL;
Mutex LogDestination::sink_mutex_;
bool LogDestination::terminal_supports_color_ = TerminalSupportsColor();
@@ -799,7 +793,7 @@ inline void LogDestination::FlushLogFilesUnsafe(int min_severity) {
// assume we have the log_mutex or we simply don't care
// about it
for (int i = min_severity; i < NUM_SEVERITIES; i++) {
- LogDestination* log = log_destination(i);
+ LogDestination* log = log_destinations_[i];
if (log != NULL) {
// Flush the base fileobject_ logger directly instead of going
// through any wrappers to reduce chance of deadlock.
@@ -807,11 +801,11 @@ inline void LogDestination::FlushLogFilesUnsafe(int min_severity) {
}
}
}
-
+/* */
inline void LogDestination::FlushLogFiles(int min_severity) {
// Prevent any subtle race conditions by wrapping a mutex lock around
// all this stuff.
- MutexLock l(&log_mutex);
+ MutexLock l(&log_mutex); // False Positive
for (int i = min_severity; i < NUM_SEVERITIES; i++) {
LogDestination* log = log_destination(i);
if (log != NULL) {
@@ -820,6 +814,8 @@ inline void LogDestination::FlushLogFiles(int min_severity) {
}
}
+/* force unlock the class static rwlock sink_mutex_ and lock_, */
+
inline void LogDestination::RleaseLogSinkLock(int min_severity) {
// release the class static lock sink_lock_
#if defined(HAVE_PTHREAD) && defined(HAVE_RWLOCK)
@@ -836,41 +832,40 @@ inline void LogDestination::RleaseLogSinkLock(int min_severity) {
return;
}
-
inline void LogDestination::SetLogDestination(LogSeverity severity,
- const char* base_filename) {
+ const char* base_filename) {
assert(severity >= 0 && severity < NUM_SEVERITIES);
// Prevent any subtle race conditions by wrapping a mutex lock around
// all this stuff.
- MutexLock l(&log_mutex);
+ MutexLock l(&log_mutex); // False Positive
log_destination(severity)->fileobject_.SetBasename(base_filename);
}
inline void LogDestination::SetLogSymlink(LogSeverity severity,
- const char* symlink_basename) {
+ const char* symlink_basename) {
CHECK_GE(severity, 0);
CHECK_LT(severity, NUM_SEVERITIES);
- MutexLock l(&log_mutex);
+ MutexLock l(&log_mutex); // False Positive
log_destination(severity)->fileobject_.SetSymlinkBasename(symlink_basename);
}
-inline void LogDestination::AddLogSink(LogSink *destination) {
+inline void LogDestination::AddLogSink(LogSink *destination) {
// Prevent any subtle race conditions by wrapping a mutex lock around
// all this stuff.
- MutexLock l(&sink_mutex_);
+ MutexLock l(&sink_mutex_); // False Positive
if (!sinks_) sinks_ = new vector<LogSink*>;
sinks_->push_back(destination);
}
-inline void LogDestination::RemoveLogSink(LogSink *destination) {
+inline void LogDestination::RemoveLogSink(LogSink *destination) {
// Prevent any subtle race conditions by wrapping a mutex lock around
// all this stuff.
- MutexLock l(&sink_mutex_);
+ MutexLock l(&sink_mutex_); // False Positive
// This doesn't keep the sinks in order, but who cares?
if (sinks_) {
for (int i = sinks_->size() - 1; i >= 0; i--) {
- if ((*sinks_)[i] == destination) {
- (*sinks_)[i] = (*sinks_)[sinks_->size() - 1];
+ if ((*sinks_)[i] == destination) {
+ (*sinks_)[i] = (*sinks_)[sinks_->size() - 1];
sinks_->pop_back();
break;
}
@@ -881,7 +876,7 @@ inline void LogDestination::RemoveLogSink(LogSink *destination) {
inline void LogDestination::SetLogFilenameExtension(const char* ext) {
// Prevent any subtle race conditions by wrapping a mutex lock around
// all this stuff.
- MutexLock l(&log_mutex);
+ MutexLock l(&log_mutex); // False Positive
for ( int severity = 0; severity < NUM_SEVERITIES; ++severity ) {
log_destination(severity)->fileobject_.SetExtension(ext);
}
@@ -891,7 +886,7 @@ inline void LogDestination::SetStderrLogging(LogSeverity min_severity) {
assert(min_severity >= 0 && min_severity < NUM_SEVERITIES);
// Prevent any subtle race conditions by wrapping a mutex lock around
// all this stuff.
- MutexLock l(&log_mutex);
+ MutexLock l(&log_mutex); // False Positive
FLAGS_stderrthreshold = min_severity;
}
@@ -905,19 +900,20 @@ inline void LogDestination::LogToStderr() {
}
inline void LogDestination::SetEmailLogging(LogSeverity min_severity,
- const char* addresses) {
+ const char* addresses) {
assert(min_severity >= 0 && min_severity < NUM_SEVERITIES);
// Prevent any subtle race conditions by wrapping a mutex lock around
// all this stuff.
- MutexLock l(&log_mutex);
+ MutexLock l(&log_mutex); // False Positive
LogDestination::email_logging_severity_ = min_severity;
LogDestination::addresses_ = addresses;
}
-
+/* nstack test use stdout redirect to log file,
+ consider the project, change to dtout*/
static void ColoredWriteToStderr(LogSeverity severity,
- const char* message, size_t len) {
+ const char* message, size_t len) {
const GLogColor color =
(LogDestination::terminal_supports_color() && FLAGS_colorlogtostderr) ?
SeverityToColor(severity) : COLOR_DEFAULT;
@@ -960,9 +956,8 @@ static void WriteToStderr(const char* message, size_t len) {
}
-
inline void LogDestination::MaybeLogToStderr(LogSeverity severity,
- const char* message, size_t len) {
+ const char* message, size_t len) {
if ((severity >= FLAGS_stderrthreshold) || FLAGS_alsologtostderr) {
ColoredWriteToStderr(severity, message, len);
#ifdef OS_WINDOWS
@@ -974,7 +969,7 @@ inline void LogDestination::MaybeLogToStderr(LogSeverity severity,
inline void LogDestination::MaybeLogToEmail(LogSeverity severity,
- const char* message, size_t len) {
+ const char* message, size_t len) {
if (severity >= email_logging_severity_ ||
severity >= FLAGS_logemaillevel) {
string to(FLAGS_alsologtoemail);
@@ -1002,18 +997,19 @@ inline void LogDestination::MaybeLogToEmail(LogSeverity severity,
inline void LogDestination::MaybeLogToLogfile(LogSeverity severity,
time_t timestamp,
const char* message,
- size_t len) {
+ size_t len) {
const bool should_flush = severity > FLAGS_logbuflevel;
LogDestination* destination = log_destination(severity);
destination->logger_->Write(should_flush, timestamp, message, len);
}
-
+/* just print one file,
+ so delete for (int i = severity; i >= 0; --i), */
inline void LogDestination::LogToAllLogfiles(LogSeverity severity,
time_t timestamp,
const char* message,
- size_t len) {
+ size_t len) {
if ( FLAGS_logtostderr ) { // global flag: never log to file
ColoredWriteToStderr(severity, message, len);
@@ -1029,18 +1025,18 @@ inline void LogDestination::LogToSinks(LogSeverity severity,
int line,
const struct ::tm* tm_time,
const char* message,
- size_t message_len) {
- ReaderMutexLock l(&sink_mutex_);
+ size_t message_len) {
+ ReaderMutexLock l(&sink_mutex_); // False Positive
if (sinks_) {
for (int i = sinks_->size() - 1; i >= 0; i--) {
- (*sinks_)[i]->send(severity, full_filename, base_filename,
+ (*sinks_)[i]->send(severity, full_filename, base_filename,
line, tm_time, message, message_len);
}
}
}
-inline void LogDestination::WaitForSinks(LogMessage::LogMessageData* data) {
- ReaderMutexLock l(&sink_mutex_);
+inline void LogDestination::WaitForSinks(LogMessage::LogMessageData* data) {
+ ReaderMutexLock l(&sink_mutex_); // False Positive
if (sinks_) {
for (int i = sinks_->size() - 1; i >= 0; i--) {
(*sinks_)[i]->WaitTillSent();
@@ -1053,22 +1049,25 @@ inline void LogDestination::WaitForSinks(LogMessage::LogMessageData* data) {
data->sink_->WaitTillSent();
}
}
-/*lint +e695 */
+/**/
LogDestination* LogDestination::log_destinations_[NUM_SEVERITIES];
-inline LogDestination* LogDestination::log_destination(LogSeverity severity) {
+inline LogDestination* LogDestination::log_destination(LogSeverity severity) {
assert(severity >=0 && severity < NUM_SEVERITIES);
- if (!log_destinations_[severity]) {
- log_destinations_[severity] = new LogDestination(severity, NULL);
+ if (!log_destinations_[severity]) {
+ log_destinations_[severity] = new LogDestination(severity, NULL);
}
- return log_destinations_[severity];
+ return log_destinations_[severity];
}
void LogDestination::DeleteLogDestinations() {
for (int severity = 0; severity < NUM_SEVERITIES; ++severity) {
delete log_destinations_[severity];
- log_destinations_[severity] = NULL;
+ log_destinations_[severity] = NULL;
}
+ MutexLock l(&sink_mutex_);
+ delete sinks_;
+ sinks_ = NULL;
}
namespace {
@@ -1091,7 +1090,7 @@ LogFileObject::LogFileObject(LogSeverity severity,
}
LogFileObject::~LogFileObject() {
- MutexLock l(&lock_);
+ MutexLock l(&lock_); // False Positive
if (file_ != NULL) {
fclose(file_);
file_ = NULL;
@@ -1099,7 +1098,7 @@ LogFileObject::~LogFileObject() {
}
void LogFileObject::SetBasename(const char* basename) {
- MutexLock l(&lock_);
+ MutexLock l(&lock_); // False Positive
base_filename_selected_ = true;
if (base_filename_ != basename) {
// Get rid of old log file since we are changing names
@@ -1113,7 +1112,7 @@ void LogFileObject::SetBasename(const char* basename) {
}
void LogFileObject::SetExtension(const char* ext) {
- MutexLock l(&lock_);
+ MutexLock l(&lock_); // False Positive
if (filename_extension_ != ext) {
// Get rid of old log file since we are changing names
if (file_ != NULL) {
@@ -1126,12 +1125,12 @@ void LogFileObject::SetExtension(const char* ext) {
}
void LogFileObject::SetSymlinkBasename(const char* symlink_basename) {
- MutexLock l(&lock_);
+ MutexLock l(&lock_); // False Positive
symlink_basename_ = symlink_basename;
}
void LogFileObject::Flush() {
- MutexLock l(&lock_);
+ MutexLock l(&lock_); // False Positive
FlushUnlocked();
}
@@ -1146,7 +1145,7 @@ void LogFileObject::FlushUnlocked(){
next_flush_time_ = CycleClock_Now() + UsecToCycles(next);
}
-
+/* force unlock the LogFileObject rwlock lock_, */
void LogFileObject::ReleaseObjectlock(){
// release the file object lock lock_
#if defined(HAVE_PTHREAD) && defined(HAVE_RWLOCK)
@@ -1155,9 +1154,7 @@ void LogFileObject::ReleaseObjectlock(){
return;
}
-
-/*
- 1. the writing log file don't has timestamp,no need input time string,
+/* 1. the writing log file don't has timestamp,no need input time string,
2. the string_filename diff with running and operation file which
in one process;
3. add a new member whole_filename_ which will use in Write;
@@ -1169,7 +1166,7 @@ bool LogFileObject::CreateLogfile( ) {
time_pid_string; */
string string_filename = "";
uint32 last_file_len = 0;
- /* segregate the dump info, Begin */
+ /* segregate the dump info */
if(severity_ == GLOG_WARNING)
{
string_filename = base_filename_+"operation.log";
@@ -1182,11 +1179,10 @@ bool LogFileObject::CreateLogfile( ) {
{
string_filename = base_filename_+filename_extension_;
}
- /* End */
whole_filename_ = string_filename;
const char* filename = string_filename.c_str();
-
- int fd = open(filename, O_WRONLY | O_CREAT | O_APPEND | O_CLOEXEC , 0664);
+ /* use O_CLOEXEC to replace fcntl FD_CLOEXEC flag*/
+ int fd = open(filename, O_WRONLY | O_CREAT | O_APPEND | O_CLOEXEC , FLAGS_logfile_mode);
if (fd == -1) return false;
//when restart the stack,it can add on same file unreach the Max log size.
@@ -1250,8 +1246,7 @@ bool LogFileObject::CreateLogfile( ) {
return true; // Everything worked
}
-/*
- 1. no need new pid use a new file writing log,
+/* 1. no need new pid use a new file writing log,
2. add the modify_path_count,if log num exceed modify_path_count, remove old new;
3. if log file exceed max_size or log file num , flues , bytes_since_flush_ = 1000000;
4. remove the no useful fields in log file name;
@@ -1261,7 +1256,7 @@ void LogFileObject::Write(bool force_flush,
time_t timestamp,
const char* message,
int message_len) {
- MutexLock l(&lock_);
+ MutexLock l(&lock_); // False Positive
// We don't log if the base_name_ is "" (which means "don't write")
if (base_filename_selected_ && base_filename_.empty()) {
@@ -1275,15 +1270,14 @@ void LogFileObject::Write(bool force_flush,
unsigned int same_file_count = 1;
char fileno[2];
struct ::tm postfix_time;
-
+ /* Use my_gmtime_r to avoid deadlock in child process when printing log for APP */
if (glogCtrlOpt == USE_USR_GM_TIME) {
my_gmtime_r(&timestamp, &postfix_time);
}
else {
- localtime_r(&timestamp, &postfix_time);
+ gmtime_r(&timestamp, &postfix_time);
}
-
// The logfile's filename will have the date/time & pid in it
ostringstream time_stream;
time_stream.fill('0');
@@ -1301,7 +1295,7 @@ void LogFileObject::Write(bool force_flush,
while ((same_file_count < log_file_count)
&& (0 == access(new_filename.c_str(), W_OK)))
{
- retVal = snprintf(fileno, sizeof(fileno), "%d",same_file_count);
+ retVal = snprintf(fileno, sizeof(fileno), "%u",same_file_count);
if (-1 == retVal)
{
return;
@@ -1310,7 +1304,7 @@ void LogFileObject::Write(bool force_flush,
same_file_count++;
}
- (void)rename(whole_filename_.c_str(), new_filename.c_str());
+ (void)rename(whole_filename_.c_str(), new_filename.c_str()); //
(void)remove(whole_filename_.c_str());
// We're going to (potentially) try to put logs in several different dirs
@@ -1378,7 +1372,7 @@ void LogFileObject::Write(bool force_flush,
for (vector<string>::const_iterator dir = log_dirs.begin();
dir != log_dirs.end();
++dir) {
-
+ /* remove the level prefix of log file, */
base_filename_ = *dir + "/";
if ( CreateLogfile() ) {
success = true;
@@ -1394,15 +1388,14 @@ void LogFileObject::Write(bool force_flush,
}
struct ::tm tm_time;
-
+ /* Use my_gmtime_r to avoid deadlock in child process when printing log for APP */
if (glogCtrlOpt == USE_USR_GM_TIME) {
my_gmtime_r(&timestamp, &tm_time);
}
else {
- localtime_r(&timestamp, &tm_time);
+ gmtime_r(&timestamp, &tm_time);
}
-
// Write a header message into the log file
ostringstream file_header_stream;
file_header_stream.fill('0');
@@ -1451,11 +1444,10 @@ void LogFileObject::Write(bool force_flush,
// See important msgs *now*. Also, flush logs at least every 10^6 chars,
// or every "FLAGS_logbufsecs" seconds.
-
-
- if(force_flush) {
+ if ( force_flush ||
+ (bytes_since_flush_ >= 1000000) ||
+ (CycleClock_Now() >= next_flush_time_) ) {
FlushUnlocked();
-
#ifdef OS_LINUX
if (FLAGS_drop_log_memory) {
if (file_length_ >= logging::kPageSize) {
@@ -1471,7 +1463,7 @@ void LogFileObject::Write(bool force_flush,
} // namespace
-
+/* */
// Static log data space to avoid alloc failures in a LOG(FATAL)
//
// Since multiple threads may call LOG(FATAL), and we want to preserve
@@ -1482,7 +1474,7 @@ static CrashReason crash_reason;
static bool fatal_msg_exclusive = true;
static LogMessage::LogMessageData fatal_msg_data_exclusive;
static LogMessage::LogMessageData fatal_msg_data_shared;
-
+/**/
LogMessage::LogMessageData::LogMessageData()
: stream_(message_text_, LogMessage::kMaxLogMessageLen, 0) {
}
@@ -1496,8 +1488,8 @@ LogMessage::LogMessage(const char* file, int line, LogSeverity severity,
LogMessage::LogMessage(const char* file, int line,
const CheckOpString& result)
- : allocated_(NULL) {
- Init(file, line, GLOG_FATAL, &LogMessage::SendToLog);
+ : allocated_(NULL) {
+ Init(file, line, GLOG_FATAL, &LogMessage::SendToLog);
stream() << "Check failed: " << (*result.str_) << " ";
}
@@ -1508,50 +1500,56 @@ LogMessage::LogMessage(const char* file, int line)
LogMessage::LogMessage(const char* file, int line, LogSeverity severity)
: allocated_(NULL) {
- Init(file, line, severity, &LogMessage::SendToLog);
+ Init(file, line, severity, &LogMessage::SendToLog);
}
-
+/* overload construct, add a member level which is real level , Begin */
LogMessage::LogMessage(const char* file, int line, LogSeverity severity, int level)
- : allocated_(NULL) {
- Init(file, line, severity,level, &LogMessage::SendToLog);
+ : allocated_(NULL) {
+ Init(file, line, severity,level, &LogMessage::SendToLog);
}
+/*reload the function for print log directly,
+ no need assemble the log */
+LogMessage::LogMessage(LogSeverity severity)
+ : allocated_(NULL) {
+ Init(severity, &LogMessage::SendToLog);
+}
LogMessage::LogMessage(const char* file, int line, LogSeverity severity,
LogSink* sink, bool also_send_to_log)
- : allocated_(NULL) {
- Init(file, line, severity, also_send_to_log ? &LogMessage::SendToSinkAndLog :
+ : allocated_(NULL) {
+ Init(file, line, severity, also_send_to_log ? &LogMessage::SendToSinkAndLog ://
&LogMessage::SendToSink);
data_->sink_ = sink; // override Init()'s setting to NULL
}
LogMessage::LogMessage(const char* file, int line, LogSeverity severity,
vector<string> *outvec)
- : allocated_(NULL) {
- Init(file, line, severity, &LogMessage::SaveOrSendToLog);
+ : allocated_(NULL) {
+ Init(file, line, severity, &LogMessage::SaveOrSendToLog);
data_->outvec_ = outvec; // override Init()'s setting to NULL
}
LogMessage::LogMessage(const char* file, int line, LogSeverity severity,
string *message)
- : allocated_(NULL) {
- Init(file, line, severity, &LogMessage::WriteToStringAndLog);
+ : allocated_(NULL) {
+ Init(file, line, severity, &LogMessage::WriteToStringAndLog);
data_->message_ = message; // override Init()'s setting to NULL
}
void LogMessage::Init(const char* file,
int line,
LogSeverity severity,
- void (LogMessage::*send_method)()) {
+ void (LogMessage::*send_method)()) {
allocated_ = NULL;
if (severity != GLOG_FATAL || !exit_on_dfatal) {
allocated_ = new LogMessageData();
data_ = allocated_;
data_->first_fatal_ = false;
} else {
- MutexLock l(&fatal_msg_lock);
+ MutexLock l(&fatal_msg_lock); // False Positive
if (fatal_msg_exclusive) {
fatal_msg_exclusive = false;
data_ = &fatal_msg_data_exclusive;
@@ -1571,14 +1569,13 @@ void LogMessage::Init(const char* file,
data_->outvec_ = NULL;
WallTime now = WallTime_Now();
data_->timestamp_ = static_cast<time_t>(now);
-
+ /* Use my_gmtime_r to avoid deadlock in child process when printing log for APP -Begin */
if (glogCtrlOpt == USE_USR_GM_TIME) {
my_gmtime_r(&data_->timestamp_, &data_->tm_time_);
}
else {
- localtime_r(&data_->timestamp_, &data_->tm_time_);
+ gmtime_r(&data_->timestamp_, &data_->tm_time_);
}
-
int usecs = static_cast<int>((now - data_->timestamp_) * 1000000);
RawLog__SetLastTime(data_->tm_time_, usecs);
@@ -1593,7 +1590,7 @@ void LogMessage::Init(const char* file,
// (log level, GMT month, date, time, thread_id, file basename, line)
// We exclude the thread_id for the default thread.
if (FLAGS_log_prefix && (line != kNoLogPrefix)) {
- stream() << LogSeverityNames[severity][0]
+ stream() << LogSeverityNames[severity][0]
<< setw(2) << 1+data_->tm_time_.tm_mon
<< setw(2) << data_->tm_time_.tm_mday
<< ' '
@@ -1607,7 +1604,7 @@ void LogMessage::Init(const char* file,
<< ' '
<< data_->basename_ << ':' << data_->line_ << "] ";
}
- data_->num_prefix_chars_ = data_->stream_.pcount();
+ data_->num_prefix_chars_ = data_->stream_.pcount();
if (!FLAGS_log_backtrace_at.empty()) {
char fileline[128];
@@ -1622,20 +1619,20 @@ void LogMessage::Init(const char* file,
}
}
-
+/* add a init overload function for init, Begin */
void LogMessage::Init(const char* file,
int line,
LogSeverity severity,
int level,
- void (LogMessage::*send_method)()) {
+ void (LogMessage::*send_method)()) {
allocated_ = NULL;
if (severity != GLOG_FATAL || !exit_on_dfatal) {
allocated_ = new LogMessageData();
data_ = allocated_;
data_->first_fatal_ = false;
} else {
- MutexLock l(&fatal_msg_lock);
+ MutexLock l(&fatal_msg_lock); // False Positive
if (fatal_msg_exclusive) {
fatal_msg_exclusive = false;
data_ = &fatal_msg_data_exclusive;
@@ -1656,14 +1653,13 @@ void LogMessage::Init(const char* file,
data_->outvec_ = NULL;
WallTime now = WallTime_Now();
data_->timestamp_ = static_cast<time_t>(now);
-
+ /* Use my_gmtime_r to avoid deadlock in child process when printing log for APP -Begin */
if (glogCtrlOpt == USE_USR_GM_TIME) {
my_gmtime_r(&data_->timestamp_, &data_->tm_time_);
}
else {
- localtime_r(&data_->timestamp_, &data_->tm_time_);
+ gmtime_r(&data_->timestamp_, &data_->tm_time_);
}
-
int usecs = static_cast<int>((now - data_->timestamp_) * 1000000);
RawLog__SetLastTime(data_->tm_time_, usecs);
@@ -1673,9 +1669,12 @@ void LogMessage::Init(const char* file,
data_->fullname_ = file;
data_->has_been_flushed_ = false;
-
+ // If specified, prepend a prefix to each line. For example:
+ // I1018 160715 f5d4fbb0 logging.cc:1153]
+ // (log level, GMT month, date, time, thread_id, file basename, line)
+ // We exclude the thread_id for the default thread.
if (FLAGS_log_prefix && (line != kNoLogPrefix)) {
- stream() << nstack_level_names[level][0]
+ stream() << nstack_level_names[level][0]
<< setw(2) << 1+data_->tm_time_.tm_mon
<< setw(2) << data_->tm_time_.tm_mday
<< ' '
@@ -1689,7 +1688,7 @@ void LogMessage::Init(const char* file,
<< ' '
<< data_->basename_ << ':' << data_->line_ << "] ";
}
- data_->num_prefix_chars_ = data_->stream_.pcount();
+ data_->num_prefix_chars_ = data_->stream_.pcount();
if (!FLAGS_log_backtrace_at.empty()) {
char fileline[128];
@@ -1704,20 +1703,60 @@ void LogMessage::Init(const char* file,
}
}
+/* reload the function for print log directly,
+ no need assemble the log */
+void LogMessage::Init(LogSeverity severity,
+ void (LogMessage::*send_method)())
+{
+ allocated_ = NULL;
+ allocated_ = new LogMessageData();
+ data_ = allocated_;
+ data_->first_fatal_ = false;
+
+ stream().fill('0');
+ data_->preserved_errno_ = errno;
+ data_->severity_ = severity;
+ data_->level_ = 0;
+ data_->line_ = 0;
+ data_->send_method_ = send_method;
+ data_->sink_ = NULL;
+ data_->outvec_ = NULL;
+ WallTime now = WallTime_Now();
+ data_->timestamp_ = static_cast<time_t>(now);
+ /* Use my_gmtime_r to avoid deadlock in child process when printing log for APP */
+ if (glogCtrlOpt == USE_USR_GM_TIME) {
+ my_gmtime_r(&data_->timestamp_, &data_->tm_time_);
+ }
+ else {
+ gmtime_r(&data_->timestamp_, &data_->tm_time_);
+ }
+ int usecs = static_cast<int>((now - data_->timestamp_) * 1000000);
+ RawLog__SetLastTime(data_->tm_time_, usecs);
+
+ data_->num_chars_to_log_ = 0;
+ data_->num_chars_to_syslog_ = 0;
+ data_->basename_ = NULL;
+ data_->fullname_ = NULL;
+ data_->has_been_flushed_ = false;
+
+ data_->num_prefix_chars_ = data_->stream_.pcount();
+
+}
+
LogMessage::~LogMessage() {
Flush();
delete allocated_;
}
-int LogMessage::preserved_errno() const {
+int LogMessage::preserved_errno() const {
return data_->preserved_errno_;
}
ostream& LogMessage::stream() {
-
- return data_->stream_;
-
+ /* */
+ return data_->stream_;
+ /**/
}
// Flush buffered message, called by the destructor, or any other function
@@ -1741,18 +1780,18 @@ void LogMessage::Flush() {
// would be preferable not to do things this way, but it seems to be
// the best way to deal with this.
if (append_newline) {
- original_final_char = data_->message_text_[data_->num_chars_to_log_];
- data_->message_text_[data_->num_chars_to_log_++] = '\n';
+ original_final_char = data_->message_text_[data_->num_chars_to_log_];
+ data_->message_text_[data_->num_chars_to_log_++] = '\n';
}
// Prevent any subtle race conditions by wrapping a mutex lock around
// the actual logging action per se.
{
- MutexLock l(&log_mutex);
+ MutexLock l(&log_mutex); // False Positive
(this->*(data_->send_method_))();
-
+ /* */
++num_messages_[static_cast<int>(data_->severity_)];
-
+ /**/
}
LogDestination::WaitForSinks(data_);
@@ -1800,7 +1839,7 @@ void LogMessage::SendToLog() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) {
log_mutex.AssertHeld();
RAW_DCHECK(data_->num_chars_to_log_ > 0 &&
- data_->message_text_[data_->num_chars_to_log_-1] == '\n', "");
+ data_->message_text_[data_->num_chars_to_log_-1] == '\n', "");
// Messages of a given severity get logged to lower severity logs, too
@@ -1891,7 +1930,7 @@ void LogMessage::SendToLog() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) {
}
void LogMessage::RecordCrashReason(
- glog_ns_internal_namespace_::CrashReason* reason) {
+ glog_ns_internal_namespace_::CrashReason* reason) {
reason->filename = fatal_msg_data_exclusive.fullname_;
reason->line_number = fatal_msg_data_exclusive.line_;
reason->message = fatal_msg_data_exclusive.message_text_ +
@@ -1916,7 +1955,7 @@ static void logging_fail() {
#if defined(_DEBUG) && defined(_MSC_VER)
// When debugging on windows, avoid the obnoxious dialog and make
// it possible to continue past a LOG(FATAL) in the debugger
- _asm int 3
+ __debugbreak();
#else
abort();
#endif
@@ -1925,7 +1964,7 @@ static void logging_fail() {
typedef void (*logging_fail_func_t)() ATTRIBUTE_NORETURN;
GOOGLE_GLOG_DLL_DECL
-logging_fail_func_t g_logging_fail_func = &logging_fail;
+logging_fail_func_t g_logging_fail_func = &logging_fail;
void InstallFailureFunction(void (*fail_func)()) {
g_logging_fail_func = (logging_fail_func_t)fail_func;
@@ -1939,7 +1978,7 @@ void LogMessage::Fail() {
void LogMessage::SendToSink() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) {
if (data_->sink_ != NULL) {
RAW_DCHECK(data_->num_chars_to_log_ > 0 &&
- data_->message_text_[data_->num_chars_to_log_-1] == '\n', "");
+ data_->message_text_[data_->num_chars_to_log_-1] == '\n', "");
data_->sink_->send(data_->severity_, data_->fullname_, data_->basename_,
data_->line_, &data_->tm_time_,
data_->message_text_ + data_->num_prefix_chars_,
@@ -1958,7 +1997,7 @@ void LogMessage::SendToSinkAndLog() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) {
void LogMessage::SaveOrSendToLog() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) {
if (data_->outvec_ != NULL) {
RAW_DCHECK(data_->num_chars_to_log_ > 0 &&
- data_->message_text_[data_->num_chars_to_log_-1] == '\n', "");
+ data_->message_text_[data_->num_chars_to_log_-1] == '\n', "");
// Omit prefix of message and trailing newline when recording in outvec_.
const char *start = data_->message_text_ + data_->num_prefix_chars_;
int len = data_->num_chars_to_log_ - data_->num_prefix_chars_ - 1;
@@ -2003,25 +2042,25 @@ void LogMessage::SendToSyslogAndLog() {
#endif
}
-base_ns::Logger* base_ns::GetLogger(LogSeverity severity) {
- MutexLock l(&log_mutex);
+base_ns::Logger* base_ns::GetLogger(LogSeverity severity) {
+ MutexLock l(&log_mutex); // False Positive
return LogDestination::log_destination(severity)->logger_;
}
void base_ns::SetLogger(LogSeverity severity, base_ns::Logger* logger) {
- MutexLock l(&log_mutex);
+ MutexLock l(&log_mutex); // False Positive
LogDestination::log_destination(severity)->logger_ = logger;
}
// L < log_mutex. Acquires and releases mutex_.
int64 LogMessage::num_messages(int severity) {
- MutexLock l(&log_mutex);
- return num_messages_[severity];
+ MutexLock l(&log_mutex); // False Positive
+ return num_messages_[severity];
}
// Output the COUNTER value. This is only valid if ostream is a
// LogStream.
-ostream& operator<<(ostream &os, const PRIVATE_Counter&) {
+ostream& operator<<(ostream &os, const PRIVATE_Counter&) {
#ifdef DISABLE_RTTI
LogMessage::LogStream *log = static_cast<LogMessage::LogStream*>(&os);
#else
@@ -2046,25 +2085,29 @@ ErrnoLogMessage::~ErrnoLogMessage() {
<< preserved_errno() << "]";
}
-
-void FlushLogFiles(LogSeverity min_severity) {
+/* */
+void FlushLogFiles(LogSeverity min_severity) {
LogDestination::FlushLogFiles(min_severity);
}
-void FlushLogFilesUnsafe(LogSeverity min_severity) {
+void FlushLogFilesUnsafe(LogSeverity min_severity) {
LogDestination::FlushLogFilesUnsafe(min_severity);
}
+/* force unlock the class static rwlock sink_mutex_ and lock_,
+ and provide a outside function, Begin*/
-void RleaseLogSinkLock(LogSeverity min_severity) {
+void RleaseLogSinkLock(LogSeverity min_severity) {
LogDestination::RleaseLogSinkLock(min_severity);
}
-void SetLogDestination(LogSeverity severity, const char* base_filename) {
+/**/
+
+void SetLogDestination(LogSeverity severity, const char* base_filename) {
LogDestination::SetLogDestination(severity, base_filename);
}
-void SetLogSymlink(LogSeverity severity, const char* symlink_basename) {
+void SetLogSymlink(LogSeverity severity, const char* symlink_basename) {
LogDestination::SetLogSymlink(severity, symlink_basename);
}
@@ -2077,7 +2120,7 @@ void LogSink::WaitTillSent() {
string LogSink::ToString(LogSeverity severity, const char* file, int line,
const struct ::tm* tm_time,
- const char* message, size_t message_len) {
+ const char* message, size_t message_len) {
ostringstream stream(string(message, message_len));
stream.fill('0');
@@ -2087,7 +2130,7 @@ string LogSink::ToString(LogSeverity severity, const char* file, int line,
// so subclasses of LogSink can be updated at the same time.
int usecs = 0;
- stream << LogSeverityNames[severity][0]
+ stream << LogSeverityNames[severity][0]
<< setw(2) << 1+tm_time->tm_mon
<< setw(2) << tm_time->tm_mday
<< ' '
@@ -2120,7 +2163,7 @@ void SetStderrLogging(LogSeverity min_severity) {
LogDestination::SetStderrLogging(min_severity);
}
-void SetEmailLogging(LogSeverity min_severity, const char* addresses) {
+void SetEmailLogging(LogSeverity min_severity, const char* addresses) {
LogDestination::SetEmailLogging(min_severity, addresses);
}
@@ -2132,7 +2175,7 @@ namespace base_ns {
namespace internal_ns {
bool GetExitOnDFatal() {
- MutexLock l(&log_mutex);
+ MutexLock l(&log_mutex); // False Positive
return exit_on_dfatal;
}
@@ -2147,7 +2190,7 @@ bool GetExitOnDFatal() {
// exit the program. Since this function is used only in testing,
// these differences are acceptable.
void SetExitOnDFatal(bool value) {
- MutexLock l(&log_mutex);
+ MutexLock l(&log_mutex); // False Positive
exit_on_dfatal = value;
}
@@ -2158,14 +2201,14 @@ void SetExitOnDFatal(bool value) {
// to log errors. It should be set to false when the caller holds the
// log_mutex.
static bool SendEmailInternal(const char*dest, const char *subject,
- const char*body, bool use_logging) {
+ const char*body, bool use_logging) {
if (dest && *dest) {
if ( use_logging ) {
VLOG(1) << "Trying to send TITLE:" << subject
<< " BODY:" << body << " to " << dest;
} else {
fprintf(stderr, "Trying to send TITLE: %s BODY: %s to %s\n",
- subject, body, dest);
+ subject, body, dest);
}
string cmd =
@@ -2219,14 +2262,8 @@ static void GetTempDirectories(vector<string>* list) {
// Directories, in order of preference. If we find a dir that
// exists, we stop adding other less-preferred dirs
const char * candidates[] = {
- // Non-null only during unittest/regtest
- getenv("TEST_TMPDIR"),
-
- // Explicitly-supplied temp dirs
- getenv("TMPDIR"), getenv("TMP"),
-
// If all else fails
- "/tmp",
+ "/tmp"
};
for (size_t i = 0; i < ARRAYSIZE(candidates); i++) {
@@ -2246,13 +2283,12 @@ static void GetTempDirectories(vector<string>* list) {
return;
}
}
-
#endif
}
-
+/* */
static vector<string>* logging_directories_list;
-
+/**/
const vector<string>& GetLoggingDirectories() {
// Not strictly thread-safe but we're called early in InitGoogle().
@@ -2306,7 +2342,7 @@ void TestOnly_ClearLoggingDirectoriesList() {
logging_directories_list = NULL;
}
-void GetExistingTempDirectories(vector<string>* list) {
+void GetExistingTempDirectories(vector<string>* list) {
GetTempDirectories(list);
vector<string>::iterator i_dir = list->begin();
while( i_dir != list->end() ) {
@@ -2489,11 +2525,11 @@ string StrError(int err) {
return buf;
}
-LogMessageFatal::LogMessageFatal(const char* file, int line) :
+LogMessageFatal::LogMessageFatal(const char* file, int line) :
LogMessage(file, line, GLOG_FATAL) {}
LogMessageFatal::LogMessageFatal(const char* file, int line,
- const CheckOpString& result) :
+ const CheckOpString& result) :
LogMessage(file, line, result) {}
LogMessageFatal::~LogMessageFatal() {
@@ -2525,7 +2561,7 @@ string* CheckOpMessageBuilder::NewString() {
} // namespace base_ns
template <>
-void MakeCheckOpValueString(std::ostream* os, const char& v) {
+void MakeCheckOpValueString(std::ostream* os, const char& v) {
if (v >= 32 && v <= 126) {
(*os) << "'" << v << "'";
} else {
@@ -2534,7 +2570,7 @@ void MakeCheckOpValueString(std::ostream* os, const char& v) {
}
template <>
-void MakeCheckOpValueString(std::ostream* os, const signed char& v) {
+void MakeCheckOpValueString(std::ostream* os, const signed char& v) {
if (v >= 32 && v <= 126) {
(*os) << "'" << v << "'";
} else {
@@ -2543,7 +2579,7 @@ void MakeCheckOpValueString(std::ostream* os, const signed char& v) {
}
template <>
-void MakeCheckOpValueString(std::ostream* os, const unsigned char& v) {
+void MakeCheckOpValueString(std::ostream* os, const unsigned char& v) {
if (v >= 32 && v <= 126) {
(*os) << "'" << v << "'";
} else {
@@ -2551,7 +2587,7 @@ void MakeCheckOpValueString(std::ostream* os, const unsigned char& v) {
}
}
-
+/*add check if init or shutdown repeat.*/
void InitGoogleLogging(const char* argv0) {
// Add: Protect to repeat init glog
diff --git a/thirdparty/glog/glog-0.3.4/src/logging_striplog_test.sh b/thirdparty/glog/glog-0.3.5/src/logging_striplog_test.sh
index 73492bd..73492bd 100644
--- a/thirdparty/glog/glog-0.3.4/src/logging_striplog_test.sh
+++ b/thirdparty/glog/glog-0.3.5/src/logging_striplog_test.sh
diff --git a/thirdparty/glog/glog-0.3.4/src/logging_striptest10.cc b/thirdparty/glog/glog-0.3.5/src/logging_striptest10.cc
index f6e1078..f6e1078 100644
--- a/thirdparty/glog/glog-0.3.4/src/logging_striptest10.cc
+++ b/thirdparty/glog/glog-0.3.5/src/logging_striptest10.cc
diff --git a/thirdparty/glog/glog-0.3.4/src/logging_striptest2.cc b/thirdparty/glog/glog-0.3.5/src/logging_striptest2.cc
index a64685c..a64685c 100644
--- a/thirdparty/glog/glog-0.3.4/src/logging_striptest2.cc
+++ b/thirdparty/glog/glog-0.3.5/src/logging_striptest2.cc
diff --git a/thirdparty/glog/glog-0.3.4/src/logging_striptest_main.cc b/thirdparty/glog/glog-0.3.5/src/logging_striptest_main.cc
index 006584f..486e861 100644
--- a/thirdparty/glog/glog-0.3.4/src/logging_striptest_main.cc
+++ b/thirdparty/glog/glog-0.3.5/src/logging_striptest_main.cc
@@ -1,9 +1,9 @@
-// This file has been modified by Huawei.
-// Copyright (C) 2018£¬ Huawei.
-//
// Copyright (c) 2007, Google Inc.
// All rights reserved.
//
+// This file has been modified by Huawei.
+// Copyright (C) 2018-2019, Huawei.
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -49,7 +49,7 @@ using namespace GOOGLE_NAMESPACE;
struct A { };
-std::ostream &operator<<(std::ostream &str, const A&) {return str;}
+std::ostream &operator<<(std::ostream &str, const A&) {return str;} //
int main(int, char* argv[]) {
FLAGS_logtostderr = true;
@@ -63,6 +63,6 @@ int main(int, char* argv[]) {
<< 1 << 'c' << A() << std::endl;
LOG(ERROR) << "TESTMESSAGE ERROR";
bool flag = true;
- (flag ? LOG(INFO) : LOG(ERROR)) << "TESTMESSAGE COND";
+ (flag ? LOG(INFO) : LOG(ERROR)) << "TESTMESSAGE COND"; //
LOG(FATAL) << "TESTMESSAGE FATAL";
}
diff --git a/thirdparty/glog/glog-0.3.4/src/logging_unittest.cc b/thirdparty/glog/glog-0.3.5/src/logging_unittest.cc
index 3c1283e..655b473 100644
--- a/thirdparty/glog/glog-0.3.4/src/logging_unittest.cc
+++ b/thirdparty/glog/glog-0.3.5/src/logging_unittest.cc
@@ -1,9 +1,9 @@
-// This file has been modified by Huawei.
-// Copyright (C) 2018£¬ Huawei.
-//
// Copyright (c) 2002, Google Inc.
// All rights reserved.
//
+// This file has been modified by Huawei.
+// Copyright (C) 2018-2019, Huawei.
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -64,8 +64,14 @@ DECLARE_string(log_backtrace_at); // logging.cc
#ifdef HAVE_LIB_GFLAGS
#include <gflags/gflags.h>
+using namespace GFLAGS_NAMESPACE;
#endif
+/*modify namespace
+ base to base_ns, internal to internal_ns, glog_testing to glog_ns_testing
+ glog_internal_namespace_ to glog_ns_internal_namespace_,
+ avoid conflict with other PDT using glog. */
+
#ifdef HAVE_LIB_GMOCK
#include <gmock/gmock.h>
#include "mock-log.h"
@@ -89,8 +95,8 @@ namespace base_ns {
namespace internal_ns {
bool GetExitOnDFatal();
void SetExitOnDFatal(bool value);
-} // namespace internal
-} // namespace base
+} // namespace internal_ns
+} // namespace base_ns
_END_GOOGLE_NAMESPACE_
static void TestLogging(bool check_counts);
@@ -630,14 +636,15 @@ static void GetFiles(const string& pattern, vector<string>* files) {
LOG(FATAL) << "No directory separator.";
}
const string dirname = pattern.substr(0, index + 1);
- if (FAILED(handle)) {
+ if (handle == INVALID_HANDLE_VALUE) {
// Finding no files is OK.
return;
}
do {
files->push_back(dirname + data.cFileName);
} while (FindNextFileA(handle, &data));
- LOG_SYSRESULT(FindClose(handle));
+ BOOL result = FindClose(handle);
+ LOG_SYSRESULT(result);
#else
# error There is no way to do glob.
#endif
@@ -855,7 +862,7 @@ namespace glog_ns_internal_namespace_ {
extern // in logging.cc
bool SafeFNMatch_(const char* pattern, size_t patt_len,
const char* str, size_t str_len);
-} // namespace glog_internal_namespace_
+} // namespace glog_ns_internal_namespace_
using glog_ns_internal_namespace_::SafeFNMatch_;
_END_GOOGLE_NAMESPACE_
diff --git a/thirdparty/glog/glog-0.3.4/src/logging_unittest.err b/thirdparty/glog/glog-0.3.5/src/logging_unittest.err
index 4f80bf5..4f80bf5 100644
--- a/thirdparty/glog/glog-0.3.4/src/logging_unittest.err
+++ b/thirdparty/glog/glog-0.3.5/src/logging_unittest.err
diff --git a/thirdparty/glog/glog-0.3.4/src/mock-log.h b/thirdparty/glog/glog-0.3.5/src/mock-log.h
index 8d0234a..e0b3e9c 100644
--- a/thirdparty/glog/glog-0.3.4/src/mock-log.h
+++ b/thirdparty/glog/glog-0.3.5/src/mock-log.h
@@ -1,9 +1,9 @@
-// This file has been modified by Huawei.
-// Copyright (C) 2018£¬ Huawei.
-//
// Copyright (c) 2007, Google Inc.
// All rights reserved.
//
+// This file has been modified by Huawei.
+// Copyright (C) 2018-2019, Huawei.
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -118,7 +118,8 @@ class ScopedMockLog : public GOOGLE_NAMESPACE::LogSink {
// WaitTillSent() and Log() are executed in the same thread.
virtual void send(GOOGLE_NAMESPACE::LogSeverity severity,
const char* full_filename,
- const char* base_filename, int line, const tm* tm_time,
+ const char* /*base_filename*/, int /*line*/,
+ const tm* /*tm_time*/,
const char* message, size_t message_len) {
// We are only interested in the log severity, full file name, and
// log message.
@@ -152,7 +153,7 @@ class ScopedMockLog : public GOOGLE_NAMESPACE::LogSink {
MessageInfo message_info_;
};
-} // namespace glog_testing
+} // namespace glog_ns_testing
_END_GOOGLE_NAMESPACE_
#endif // GLOG_SRC_MOCK_LOG_H_
diff --git a/thirdparty/glog/glog-0.3.4/src/mock-log_test.cc b/thirdparty/glog/glog-0.3.5/src/mock-log_test.cc
index dedb0ce..f0159ef 100644
--- a/thirdparty/glog/glog-0.3.4/src/mock-log_test.cc
+++ b/thirdparty/glog/glog-0.3.5/src/mock-log_test.cc
@@ -1,9 +1,9 @@
-// This file has been modified by Huawei.
-// Copyright (C) 2018£¬ Huawei.
-//
// Copyright (c) 2007, Google Inc.
// All rights reserved.
//
+// This file has been modified by Huawei.
+// Copyright (C) 2018-2019, Huawei.
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
diff --git a/thirdparty/glog/glog-0.3.4/src/nstack_logging.cc b/thirdparty/glog/glog-0.3.5/src/nstack_logging.cc
index 40b4a7c..7ba8586 100644
--- a/thirdparty/glog/glog-0.3.4/src/nstack_logging.cc
+++ b/thirdparty/glog/glog-0.3.5/src/nstack_logging.cc
@@ -1,3 +1,14 @@
+// This file has been modified by Huawei.
+// Copyright (C) 2018-2019, Huawei.
+
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the BSD 2.0 and BSD License.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// BSD 2.0 and BSD License for more details.
+
/*
* @file nstack_logging.cc
* Copyright(C), Huawei Tech. Co., Ltd. ALL RIGHTS RESERVED. \n
@@ -103,6 +114,20 @@ static const int glogLevelMapping[GLOG_LEVEL_BUTT]
GLOG_ERROR,
GLOG_FATAL};
+/*check the file type, Begin*/
+//Note: need match with _LOG_TYPE
+enum _NLOG_TYPE
+{
+ TYPE_NSTACK = 0,
+ TYPE_OPERATION,
+ TYPE_MASTER,
+ TYPE_CTRL,
+ TYPE_SEGMENT,
+ TYPE_APP,
+ TYPE_UNRECOGNIZED,
+ MAX_TYPE
+};
+
/**
* @ingroup GLOG
* @brief ROSA log level in env
@@ -113,7 +138,7 @@ static const char* const glogLevelName[GLOG_LEVEL_BUTT] = {"DBG",
"INF",
"WAR",
"ERR",
- "FTL"};
+ "EMG"};
/**
* @ingroup NSTACK_LOG
* @brief product to NSTACK registration log hook.
@@ -131,16 +156,14 @@ static const char* const glogLevelName[GLOG_LEVEL_BUTT] = {"DBG",
* @return 1 parameter passed in error: empty, or re-registered
* @par dependency: Requires product call
* <li>nstack_glog_in.h The interface declares the header file. </li></ul>
-* @see NA¡£
+* @see NA.
*/
int nstack_log_hook_set(nstack_log_hook log_hook)
{
-#ifndef MPTCP_SUPPORT
if (NULL == log_hook || g_log_hook_tag.register_cnt > 0) {
return 1;
}
-#endif
g_log_hook_tag.log_hook = log_hook;
g_log_hook_tag.register_cnt++;
@@ -154,7 +177,7 @@ int nstack_log_hook_set(nstack_log_hook log_hook)
*
* @verbatim
Function Description: Set the log level to be printed.Support for reading environment variables:
- NSTACK_LOG_HOOK_LEVEL = DBG / INF / WAR / ERR / FTL,If the value of NSTACK_LOG_HOOK_LEVEL is set
+ NSTACK_LOG_HOOK_LEVEL = DBG / INF / WAR / ERR / EMG,If the value of NSTACK_LOG_HOOK_LEVEL is set
incorrectly, the log level is unchanged Dynamically set the level
Target users: users who use NSTACK to print logs
Use constraint: log level See nstack_log_level.
@@ -170,7 +193,7 @@ int nstack_log_hook_set(nstack_log_hook log_hook)
* @return 0 The function returns success
* @return 1 parameter passed in error: level is not in the range, before the log level unchanged
* @par dependency:NA
-* @see NA
+* @see NA.
*/
@@ -190,9 +213,9 @@ int nstack_log_hook_level_set(unsigned int log_level)
}
/**
-* @ingroup NSTACK_LOG£¬init the hook
+* @ingroup NSTACK_LOG, init the hook
-* @see NA
+* @see NA.
*/
void nstack_log_hook_init()
@@ -206,8 +229,8 @@ void nstack_log_hook_init()
}
for(i = 0; i < GLOG_LEVEL_BUTT; i++) {
- if ((glogLevelName[i][0] == pst_temp[0])
- && (0 == strncmp(pst_temp,
+ if (glogLevelName[i] /* fix potential segfault */
+ && (0 == strncmp(pst_temp,
glogLevelName[i],
strlen(glogLevelName[i])))) {
g_log_hook_tag.level = i;
@@ -233,6 +256,7 @@ void nstack_log_hook_init()
*
* @return NA
* @par dependency:NA
+* @see NA.
*/
void nstack_log_count_set(unsigned int count)
{
@@ -259,7 +283,8 @@ void nstack_log_count_set(unsigned int count)
* @return 0 The function returns success
* @return 1 parameter passed in error: the rank is not in range
* @par dependency:
-* <li>nstack_glog_in.h£ºThe interface declares the header file. </li></ul>
+* <li>nstack_glog_in.h: The interface declares the header file. </li></ul>
+ * @see NA.
*/
int glogLevelSet(unsigned int logLevel)
{
@@ -272,7 +297,9 @@ int glogLevelSet(unsigned int logLevel)
levelEnable = glogLevelGet();
g_LogLevelPrint = (GLOG_LEVEL_BUTT == levelEnable) ? logLevel : levelEnable;
-
+ /**
+ * control GLOG original LOG(INFO/WARNING/ERROR/FATAL) printing
+ */
n_glogLevelSet(g_LogLevelPrint);
return 0;
@@ -328,8 +355,8 @@ int glogLevelGet(void)
}
for(i = 0; i < GLOG_LEVEL_BUTT; i++) {
- if ((glogLevelName[i][0] == enableLevel[0])
- && (0 == strncmp(enableLevel,
+ if (glogLevelName[i] /* fix potential segfault */
+ && (0 == strncmp(enableLevel,
glogLevelName[i],
strlen(glogLevelName[i])))) {
return i;
@@ -397,7 +424,8 @@ void glogDestinationSet(unsigned int logLevel, const char* base_filename)
*
* @return NA
* @par dependency:
-* <li>nstack_glog.ph£º This interface declares the header file. </li></ul>
+* <li>nstack_glog.ph: This interface declares the header file. </li></ul>
+ * @see NA.
*/
void n_glogLevelSet(unsigned int logLevel)
{
@@ -468,10 +496,10 @@ void glogDir(char *logDir)
@endverbatim
* @param logLevel [input] log level, see nstack_log_level
*
-* DTS2017110310251
* @return NA
* @par dependency:
-* <li>nstack_glog.ph£º This interface declares the header file. </li></ul>
+* <li>nstack_glog.ph: This interface declares the header file. </li></ul>
+ * @see NA.
*/
void glogBufLevelSet(unsigned int logLevel)
{
@@ -788,7 +816,8 @@ void glogRavage(char *fileName,
*
* @return NA
* @par dependency:
-* <li>nstack_glog.ph£ºThis interface declares the header file.</li></ul>
+* <li>nstack_glog.ph: This interface declares the header file.</li></ul>
+ * @see NA.
*/
void glog_print(unsigned int type,
@@ -813,7 +842,7 @@ void glog_print(unsigned int type,
/**
* default is GLOG_LEVEL_INFO
*/
- if((type > GLOG_LEVEL_FATAL) || (level > GLOG_LEVEL_FATAL)){
+ if((type >= GLOG_LEVEL_BUTT) || (level >= GLOG_LEVEL_BUTT)){
return;
}
if (GLOG_LEVEL_BUTT == g_LogLevelPrint) {
@@ -826,6 +855,9 @@ void glog_print(unsigned int type,
snprintf(baseFile, MAX_ROSA_LOG_LEN, "%s", fileName);
}
+ /* add the protection of the pointer */
+ /* use to count the repeated log */
+
if((NULL != prestr) && (0 != strlen(prestr))){
if(count < 0){
snprintf(premodule, MAX_ROSA_LOG_LEN - 1, "<%s>", prestr);
@@ -847,7 +879,7 @@ void glog_print(unsigned int type,
*/
prebuffLen = snprintf(pMsgBuf,
MAX_LOG_TRANSITIONAL_LEN,
- "%ld %s:%d]%d,%s]",
+ "%ld %s:%u]%d,%s]",
syscall(__NR_gettid),
baseFile,
fileLine,
@@ -878,6 +910,9 @@ void glog_print(unsigned int type,
va_end(ap);
buffLen = (buffLen +prebuffLen >= MAX_LOG_TRANSITIONAL_LEN) ? (MAX_LOG_TRANSITIONAL_LEN -prebuffLen -1) : buffLen;
+ if (GLOG_LEVEL_CUSTOM == level)
+ level = GLOG_LEVEL_INFO;
+
switch (print_type) {
case HLOG_PRINT_TYPE_HOOK: {
@@ -917,6 +952,44 @@ void glog_print(unsigned int type,
}
+
+/*****************************************************************************
+* Prototype : glog_print_buffer
+* Description : print the assembled buffer to the log, no need add the prefix.
+* Input : unsigned int type,
+* : const char *buffer,
+* : unsigned int len
+* ...
+* Output : None
+* Return Value : None
+* Calls :
+* Called By :
+*****************************************************************************/
+void glog_print_buffer(unsigned int type,
+ const char *buffer,
+ unsigned int len)
+{
+ if ((NULL == buffer) || (len == 0) || (strlen(buffer) > len))
+ {
+ return ;
+ }
+
+ int severity = GLOG_INFO;
+
+ if (type == TYPE_OPERATION)
+ {
+ severity = GLOG_WARNING;
+ }
+
+ LogMessage(severity).stream()
+ << buffer;
+
+ return;
+
+}
+
+
+
// overload new: use ram management of user
void *LogMessageAdapter::LogRamMgnt::operator new(size_t size)
{
@@ -1020,6 +1093,10 @@ LogMessageAdapter::~LogMessageAdapter()
return;
}
+ /* LOG Macro will enter the class,
+ the destruction will print info, default is INFO level, data->level + 1 because
+ GLOG_ERROR smaller 1 with GLOG_LEVEL_ERROR*/
+
unsigned int printType = (g_log_hook_tag.log_hook != NULL) ? HLOG_PRINT_TYPE_HOOK : HLOG_PRINT_TYPE_GLOG;
if (HLOG_PRINT_TYPE_GLOG != printType) {
glog_print(GLOG_LEVEL_INFO,
@@ -1043,16 +1120,17 @@ LogMessageAdapter::~LogMessageAdapter()
allocated = NULL;
}
+/* */
static ostream glogNullStream(NULL);
ostream& LogMessageAdapter::stream()
{
if((NULL == data) || (NULL == data->stream_)) {
- return glogNullStream;
+ return glogNullStream; // False Positive static ostream glogNullStream(NULL)
}
- return *(data->stream_);
+ return *(data->stream_); // False Positive static ostream glogNullStream(NULL)
}
-
+/**/
void SetGlogCtrlOpt(int opt)
{
diff --git a/thirdparty/glog/glog-0.3.4/src/raw_logging.cc b/thirdparty/glog/glog-0.3.5/src/raw_logging.cc
index 7a7409b..bfe77c6 100644
--- a/thirdparty/glog/glog-0.3.4/src/raw_logging.cc
+++ b/thirdparty/glog/glog-0.3.5/src/raw_logging.cc
@@ -1,6 +1,9 @@
// Copyright (c) 2006, Google Inc.
// All rights reserved.
//
+// This file has been modified by Huawei.
+// Copyright (C) 2018-2019, Huawei.
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -107,14 +110,14 @@ inline static bool VADoRawLog(char** buf, int* size,
*buf += n;
return true;
}
-
+/**/
static const int kLogBufSize = 3000;
static bool crashed = false;
static CrashReason crash_reason;
static char crash_buf[kLogBufSize + 1] = { 0 }; // Will end in '\0'
-
+/**/
void RawLog__(LogSeverity severity, const char* file, int line,
- const char* format, ...) {
+ const char* format, ...) { //
if (!(FLAGS_logtostderr || severity >= FLAGS_stderrthreshold ||
FLAGS_alsologtostderr || !IsGoogleLoggingInitialized())) {
return; // this stderr log message is suppressed
@@ -127,7 +130,7 @@ void RawLog__(LogSeverity severity, const char* file, int line,
// NOTE: this format should match the specification in base/logging.h
DoRawLog(&buf, &size, "%c%02d%02d %02d:%02d:%02d.%06d %5u %s:%d] RAW: ",
- LogSeverityNames[severity][0],
+ LogSeverityNames[severity][0], //
1 + t.tm_mon, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec,
last_usecs_for_raw_log,
static_cast<unsigned int>(GetTID()),
diff --git a/thirdparty/glog/glog-0.3.4/src/signalhandler.cc b/thirdparty/glog/glog-0.3.5/src/signalhandler.cc
index 3759580..f3254a3 100644
--- a/thirdparty/glog/glog-0.3.4/src/signalhandler.cc
+++ b/thirdparty/glog/glog-0.3.5/src/signalhandler.cc
@@ -1,9 +1,9 @@
-// This file has been modified by Huawei.
-// Copyright (C) 2018£¬ Huawei.
-//
// Copyright (c) 2008, Google Inc.
// All rights reserved.
//
+// This file has been modified by Huawei.
+// Copyright (C) 2018-2019, Huawei.
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -338,6 +338,22 @@ void FailureSignalHandler(int signal_number,
#endif // HAVE_SIGACTION
+namespace glog_ns_internal_namespace_ {
+
+bool IsFailureSignalHandlerInstalled() {
+#ifdef HAVE_SIGACTION
+ struct sigaction sig_action;
+ memset(&sig_action, 0, sizeof(sig_action));
+ sigemptyset(&sig_action.sa_mask);
+ sigaction(SIGABRT, NULL, &sig_action);
+ if (sig_action.sa_sigaction == &FailureSignalHandler)
+ return true;
+#endif // HAVE_SIGACTION
+ return false;
+}
+
+} // namespace glog_ns_internal_namespace_
+
void InstallFailureSignalHandler() {
#ifdef HAVE_SIGACTION
// Build the sigaction struct.
@@ -348,7 +364,7 @@ void InstallFailureSignalHandler() {
sig_action.sa_sigaction = &FailureSignalHandler;
for (size_t i = 0; i < ARRAYSIZE(kFailureSignals); ++i) {
- CHECK_ERR(sigaction(kFailureSignals[i].number, &sig_action, NULL));
+ CHECK_ERR(sigaction(kFailureSignals[i].number, &sig_action, NULL)); //
}
#endif // HAVE_SIGACTION
}
diff --git a/thirdparty/glog/glog-0.3.4/src/signalhandler_unittest.cc b/thirdparty/glog/glog-0.3.5/src/signalhandler_unittest.cc
index 1cd0fa0..e223c06 100644
--- a/thirdparty/glog/glog-0.3.4/src/signalhandler_unittest.cc
+++ b/thirdparty/glog/glog-0.3.5/src/signalhandler_unittest.cc
@@ -1,6 +1,9 @@
// Copyright (c) 2008, Google Inc.
// All rights reserved.
//
+// This file has been modified by Huawei.
+// Copyright (C) 2018-2019, Huawei.
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -41,6 +44,11 @@
#include <string>
#include "glog/logging.h"
+#ifdef HAVE_LIB_GFLAGS
+#include <gflags/gflags.h>
+using namespace GFLAGS_NAMESPACE;
+#endif
+
using namespace GOOGLE_NAMESPACE;
void* DieInThread(void*) {
@@ -52,7 +60,7 @@ void* DieInThread(void*) {
fprintf(stderr, "0x%lx is dying\n", (long)pthread_self());
// Use volatile to prevent from these to be optimized away.
volatile int a = 0;
- volatile int b = 1 / a;
+ volatile int b = 1 / a; //
fprintf(stderr, "We should have died: b=%d\n", b);
return NULL;
}
diff --git a/thirdparty/glog/glog-0.3.4/src/signalhandler_unittest.sh b/thirdparty/glog/glog-0.3.5/src/signalhandler_unittest.sh
index 265cd45..265cd45 100644
--- a/thirdparty/glog/glog-0.3.4/src/signalhandler_unittest.sh
+++ b/thirdparty/glog/glog-0.3.5/src/signalhandler_unittest.sh
diff --git a/thirdparty/glog/glog-0.3.4/src/stacktrace.h b/thirdparty/glog/glog-0.3.5/src/stacktrace.h
index 8c3e8fe..8c3e8fe 100644
--- a/thirdparty/glog/glog-0.3.4/src/stacktrace.h
+++ b/thirdparty/glog/glog-0.3.5/src/stacktrace.h
diff --git a/thirdparty/glog/glog-0.3.4/src/stacktrace_generic-inl.h b/thirdparty/glog/glog-0.3.5/src/stacktrace_generic-inl.h
index fad81d3..fad81d3 100644
--- a/thirdparty/glog/glog-0.3.4/src/stacktrace_generic-inl.h
+++ b/thirdparty/glog/glog-0.3.5/src/stacktrace_generic-inl.h
diff --git a/thirdparty/glog/glog-0.3.4/src/stacktrace_libunwind-inl.h b/thirdparty/glog/glog-0.3.5/src/stacktrace_libunwind-inl.h
index 0dc14c6..ada9acd 100644
--- a/thirdparty/glog/glog-0.3.4/src/stacktrace_libunwind-inl.h
+++ b/thirdparty/glog/glog-0.3.5/src/stacktrace_libunwind-inl.h
@@ -1,6 +1,9 @@
// Copyright (c) 2005 - 2007, Google Inc.
// All rights reserved.
//
+// This file has been modified by Huawei.
+// Copyright (C) 2018-2019, Huawei.
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -49,7 +52,7 @@ _START_GOOGLE_NAMESPACE_
// recursive request, we'd end up with infinite recursion or deadlock.
// Luckily, it's safe to ignore those subsequent traces. In such
// cases, we return 0 to indicate the situation.
-static bool g_now_entering = false;
+static bool g_now_entering = false; //
// If you change this function, also change GetStackFrames below.
int GetStackTrace(void** result, int max_depth, int skip_count) {
diff --git a/thirdparty/glog/glog-0.3.4/src/stacktrace_powerpc-inl.h b/thirdparty/glog/glog-0.3.5/src/stacktrace_powerpc-inl.h
index 83f6cf2..685d015 100644
--- a/thirdparty/glog/glog-0.3.4/src/stacktrace_powerpc-inl.h
+++ b/thirdparty/glog/glog-0.3.5/src/stacktrace_powerpc-inl.h
@@ -1,9 +1,9 @@
-// This file has been modified by Huawei.
-// Copyright (C) 2018£¬ Huawei.
-//
// Copyright (c) 2007, Google Inc.
// All rights reserved.
//
+// This file has been modified by Huawei.
+// Copyright (C) 2018-2019, Huawei.
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -121,7 +121,7 @@ int GetStackTrace(void** result, int max_depth, int skip_count) {
// This check is in case the compiler doesn't define _CALL_SYSV.
result[n++] = *(sp+1);
#else
-#error Need to specify the PPC ABI for your archiecture.
+#error Need to specify the PPC ABI for your archiecture. //
#endif
}
// Use strict unwinding rules.
diff --git a/thirdparty/glog/glog-0.3.4/src/stacktrace_unittest.cc b/thirdparty/glog/glog-0.3.5/src/stacktrace_unittest.cc
index c1b3b36..a84a52b 100644
--- a/thirdparty/glog/glog-0.3.4/src/stacktrace_unittest.cc
+++ b/thirdparty/glog/glog-0.3.5/src/stacktrace_unittest.cc
@@ -1,6 +1,9 @@
// Copyright (c) 2004, Google Inc.
// All rights reserved.
//
+// This file has been modified by Huawei.
+// Copyright (C) 2018-2019, Huawei.
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -40,6 +43,7 @@
# include <execinfo.h>
#endif
+/*test case */
using namespace GOOGLE_NAMESPACE;
#ifdef HAVE_STACKTRACE
@@ -58,7 +62,7 @@ struct AddressRange {
// Expected function [start,end] range.
AddressRange expected_range[BACKTRACE_STEPS];
-#if __GNUC__
+#if __GNUC__ //
// Using GCC extension: address of a label can be taken with '&&label'.
// Start should be a label somewhere before recursive call, end somewhere
// after it.
@@ -131,13 +135,13 @@ void ATTRIBUTE_NOINLINE CheckStackTraceLeaf(void) {
printf("Obtained %d stack frames.\n", size);
for (int i = 0; i < size; i++)
printf("%s %p\n", strings[i], stack[i]);
- printf("CheckStackTrace() addr: %p\n", &CheckStackTrace);
+ printf("CheckStackTrace() addr: %p\n", &CheckStackTrace); //
free(strings);
#endif
}
for (int i = 0; i < BACKTRACE_STEPS; i++) {
printf("Backtrace %d: expected: %p..%p actual: %p ... ",
- i, expected_range[i].start, expected_range[i].end, stack[i]);
+ i, expected_range[i].start, expected_range[i].end, stack[i]); //
fflush(stdout);
CheckRetAddrIsInFunction(stack[i], expected_range[i]);
printf("OK\n");
@@ -205,4 +209,6 @@ int main() {
printf("PASS (no stacktrace support)\n");
return 0;
}
+/*test case */
+
#endif // HAVE_STACKTRACE
diff --git a/thirdparty/glog/glog-0.3.4/src/stacktrace_x86-inl.h b/thirdparty/glog/glog-0.3.5/src/stacktrace_x86-inl.h
index cfd31f7..cfd31f7 100644
--- a/thirdparty/glog/glog-0.3.4/src/stacktrace_x86-inl.h
+++ b/thirdparty/glog/glog-0.3.5/src/stacktrace_x86-inl.h
diff --git a/thirdparty/glog/glog-0.3.4/src/stacktrace_x86_64-inl.h b/thirdparty/glog/glog-0.3.5/src/stacktrace_x86_64-inl.h
index f7d1dca..f771528 100644
--- a/thirdparty/glog/glog-0.3.4/src/stacktrace_x86_64-inl.h
+++ b/thirdparty/glog/glog-0.3.5/src/stacktrace_x86_64-inl.h
@@ -1,6 +1,9 @@
// Copyright (c) 2005 - 2007, Google Inc.
// All rights reserved.
//
+// This file has been modified by Huawei.
+// Copyright (C) 2018-2019, Huawei.
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -46,12 +49,12 @@ typedef struct {
int count;
} trace_arg_t;
-
+/**/
// Workaround for the malloc() in _Unwind_Backtrace() issue.
static _Unwind_Reason_Code nop_backtrace(struct _Unwind_Context *uc, void *opq) {
return _URC_NO_REASON;
}
-
+/**/
// This code is not considered ready to run until
// static initializers run so that we are guaranteed
@@ -69,7 +72,7 @@ class StackTraceInit {
static StackTraceInit module_initializer; // Force initialization
static _Unwind_Reason_Code GetOneFrame(struct _Unwind_Context *uc, void *opq) {
- trace_arg_t *targ = (trace_arg_t *) opq;
+ trace_arg_t *targ = (trace_arg_t *) opq; //
if (targ->skip_count > 0) {
targ->skip_count--;
diff --git a/thirdparty/glog/glog-0.3.4/src/stl_logging_unittest.cc b/thirdparty/glog/glog-0.3.5/src/stl_logging_unittest.cc
index 20f23b3..89fd6a1 100644
--- a/thirdparty/glog/glog-0.3.4/src/stl_logging_unittest.cc
+++ b/thirdparty/glog/glog-0.3.5/src/stl_logging_unittest.cc
@@ -31,6 +31,7 @@
#ifdef HAVE_USING_OPERATOR
+#include <functional>
#include <iostream>
#include <map>
#include <ostream>
@@ -41,11 +42,19 @@
// C++0x isn't enabled by default in GCC and libc++ does not have
// non-standard ext/* and tr1/unordered_*.
# if defined(_LIBCPP_VERSION)
+# ifndef GLOG_STL_LOGGING_FOR_UNORDERED
# define GLOG_STL_LOGGING_FOR_UNORDERED
+# endif
# else
+# ifndef GLOG_STL_LOGGING_FOR_EXT_HASH
# define GLOG_STL_LOGGING_FOR_EXT_HASH
+# endif
+# ifndef GLOG_STL_LOGGING_FOR_EXT_SLIST
# define GLOG_STL_LOGGING_FOR_EXT_SLIST
+# endif
+# ifndef GLOG_STL_LOGGING_FOR_TR1_UNORDERED
# define GLOG_STL_LOGGING_FOR_TR1_UNORDERED
+# endif
# endif
#endif
diff --git a/thirdparty/glog/glog-0.3.4/src/symbolize.cc b/thirdparty/glog/glog-0.3.5/src/symbolize.cc
index 901ba98..e242777 100644
--- a/thirdparty/glog/glog-0.3.4/src/symbolize.cc
+++ b/thirdparty/glog/glog-0.3.5/src/symbolize.cc
@@ -1,9 +1,9 @@
-// This file has been modified by Huawei.
-// Copyright (C) 2018£¬ Huawei.
-//
// Copyright (c) 2006, Google Inc.
// All rights reserved.
//
+// This file has been modified by Huawei.
+// Copyright (C) 2018-2019, Huawei.
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -330,7 +330,7 @@ FindSymbol(uint64_t pc, const int fd, char *out, int out_size,
// false.
static bool GetSymbolFromObjectFile(const int fd, uint64_t pc,
char *out, int out_size,
- uint64_t map_start_address) {
+ uint64_t map_base_address) {
// Read the ELF header.
ElfW(Ehdr) elf_header;
if (!ReadFromOffsetExact(fd, &elf_header, sizeof(elf_header), 0)) {
@@ -339,7 +339,28 @@ static bool GetSymbolFromObjectFile(const int fd, uint64_t pc,
uint64_t symbol_offset = 0;
if (elf_header.e_type == ET_DYN) { // DSO needs offset adjustment.
- symbol_offset = map_start_address;
+ ElfW(Phdr) phdr;
+ // We need to find the PT_LOAD segment corresponding to the read-execute
+ // file mapping in order to correctly perform the offset adjustment.
+ for (unsigned i = 0; i != elf_header.e_phnum; ++i) {
+ if (!ReadFromOffsetExact(fd, &phdr, sizeof(phdr),
+ elf_header.e_phoff + i * sizeof(phdr)))
+ return false;
+ if (phdr.p_type == PT_LOAD &&
+ (phdr.p_flags & (PF_R | PF_X)) == (PF_R | PF_X)) {
+ // Find the mapped address corresponding to virtual address zero. We do
+ // this by first adding p_offset. This gives us the mapped address of
+ // the start of the segment, or in other words the mapped address
+ // corresponding to the virtual address of the segment. (Note that this
+ // is distinct from the start address, as p_offset is not guaranteed to
+ // be page aligned.) We then subtract p_vaddr, which takes us to virtual
+ // address zero.
+ symbol_offset = map_base_address + phdr.p_offset - phdr.p_vaddr;
+ break;
+ }
+ }
+ if (symbol_offset == 0)
+ return false;
}
ElfW(Shdr) symtab, strtab;
@@ -572,8 +593,8 @@ OpenObjectFileContainingPcAndGetStartAddress(uint64_t pc,
return -1; // Malformed line.
}
- // Check flags. We are only interested in "r-x" maps.
- if (memcmp(flags_start, "r-x", 3) != 0) { // Not a "r-x" map.
+ // Check flags. We are only interested in "r*x" maps.
+ if (flags_start[0] != 'r' || flags_start[2] != 'x') {
continue; // We skip this map.
}
++cursor; // Skip ' '.
@@ -785,7 +806,7 @@ static ATTRIBUTE_NOINLINE bool SymbolizeAndDemangle(void *pc, char *out,
}
}
if (!GetSymbolFromObjectFile(wrapped_object_fd.get(), pc0,
- out, out_size, start_address)) {
+ out, out_size, base_address)) {
return false;
}
diff --git a/thirdparty/glog/glog-0.3.4/src/symbolize.h b/thirdparty/glog/glog-0.3.5/src/symbolize.h
index f617184..f617184 100644
--- a/thirdparty/glog/glog-0.3.4/src/symbolize.h
+++ b/thirdparty/glog/glog-0.3.5/src/symbolize.h
diff --git a/thirdparty/glog/glog-0.3.4/src/symbolize_unittest.cc b/thirdparty/glog/glog-0.3.5/src/symbolize_unittest.cc
index f25909d..05cb8a1 100644
--- a/thirdparty/glog/glog-0.3.4/src/symbolize_unittest.cc
+++ b/thirdparty/glog/glog-0.3.5/src/symbolize_unittest.cc
@@ -41,6 +41,11 @@
#include "googletest.h"
#include "config.h"
+#ifdef HAVE_LIB_GFLAGS
+#include <gflags/gflags.h>
+using namespace GFLAGS_NAMESPACE;
+#endif
+
using namespace std;
using namespace GOOGLE_NAMESPACE;
diff --git a/thirdparty/glog/glog-0.3.4/src/utilities.cc b/thirdparty/glog/glog-0.3.5/src/utilities.cc
index ab6aaea..c6ca0be 100644
--- a/thirdparty/glog/glog-0.3.4/src/utilities.cc
+++ b/thirdparty/glog/glog-0.3.5/src/utilities.cc
@@ -1,9 +1,9 @@
-// This file has been modified by Huawei.
-// Copyright (C) 2018£¬ Huawei.
-//
// Copyright (c) 2008, Google Inc.
// All rights reserved.
//
+// This file has been modified by Huawei.
+// Copyright (C) 2018-2019, Huawei.
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -56,10 +56,10 @@
using std::string;
_START_GOOGLE_NAMESPACE_
-
+/**/
static const char* g_program_invocation_short_name = NULL;
static pthread_t g_main_thread_id;
-
+/**/
_END_GOOGLE_NAMESPACE_
@@ -142,13 +142,15 @@ static void DumpStackTraceAndExit() {
// TOOD(hamaji): Use signal instead of sigaction?
#ifdef HAVE_SIGACTION
- // Set the default signal handler for SIGABRT, to avoid invoking our
- // own signal handler installed by InstallFailedSignalHandler().
- struct sigaction sig_action;
- memset(&sig_action, 0, sizeof(sig_action));
- sigemptyset(&sig_action.sa_mask);
- sig_action.sa_handler = SIG_DFL;
- sigaction(SIGABRT, &sig_action, NULL);
+ if (IsFailureSignalHandlerInstalled()) {
+ // Set the default signal handler for SIGABRT, to avoid invoking our
+ // own signal handler installed by InstallFailureSignalHandler().
+ struct sigaction sig_action;
+ memset(&sig_action, 0, sizeof(sig_action));
+ sigemptyset(&sig_action.sa_mask);
+ sig_action.sa_handler = SIG_DFL;
+ sigaction(SIGABRT, &sig_action, NULL);
+ }
#endif // HAVE_SIGACTION
abort();
@@ -346,7 +348,7 @@ void ShutdownGoogleLoggingUtilities() {
-
+/* Called only by my_gmtime_r() */
inline int get_day_of_month(int mon, int is_leap);
inline int get_day_of_month(int mon, int is_leap)
{
@@ -357,6 +359,11 @@ inline int get_day_of_month(int mon, int is_leap)
return table[mon];
}
+inline int is_leap_year(int year)
+{
+ return ((year%4 == 0 && year%100 != 0) || year%400 == 0) ? 1 : 0;
+}
+
/* Implement glibc's gmtime_r function with no locks what so ever */
struct tm *my_gmtime_r(const time_t *timep, struct tm *result)
{
@@ -379,13 +386,13 @@ struct tm *my_gmtime_r(const time_t *timep, struct tm *result)
int is_leap;
/* cheat first */
- if (t > 1483228800) // 2017-01-01 00:00:00
+ if (t >= 17532) // 2017-01-01 00:00:00
{
- t -= 1483228800;
- year = 2017;
+ t -= 17532;
+ year = 2018;
}
for (;;year++) {
- is_leap = ((year%4 == 0 && year%100 != 0) || year%400 == 0);
+ is_leap = is_leap_year(year);
if (t < 365 + is_leap) {
break;
}
@@ -396,7 +403,7 @@ struct tm *my_gmtime_r(const time_t *timep, struct tm *result)
int yday = t;
int mon = 0;
- for (;;mon++) {
+ for (; mon < 12;mon++) { //CodeDEX 212279
if (t < get_day_of_month(mon, is_leap)) {
break;
}
@@ -421,7 +428,8 @@ struct tm *my_gmtime_r(const time_t *timep, struct tm *result)
}
-} // namespace glog_internal_namespace_
+
+} // namespace glog_ns_internal_namespace_
_END_GOOGLE_NAMESPACE_
diff --git a/thirdparty/glog/glog-0.3.4/src/utilities.h b/thirdparty/glog/glog-0.3.5/src/utilities.h
index c500a0b..1f834b2 100644
--- a/thirdparty/glog/glog-0.3.4/src/utilities.h
+++ b/thirdparty/glog/glog-0.3.5/src/utilities.h
@@ -1,9 +1,9 @@
-// This file has been modified by Huawei.
-// Copyright (C) 2018£¬ Huawei.
-//
// Copyright (c) 2008, Google Inc.
// All rights reserved.
//
+// This file has been modified by Huawei.
+// Copyright (C) 2018-2019, Huawei.
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -221,7 +221,7 @@ void SetCrashReason(const CrashReason* r);
void InitGoogleLoggingUtilities(const char* argv0);
void ShutdownGoogleLoggingUtilities();
-} // namespace glog_internal_namespace_
+} // namespace glog_ns_internal_namespace_
_END_GOOGLE_NAMESPACE_
diff --git a/thirdparty/glog/glog-0.3.4/src/utilities_unittest.cc b/thirdparty/glog/glog-0.3.5/src/utilities_unittest.cc
index 7b79619..38e847d 100644
--- a/thirdparty/glog/glog-0.3.4/src/utilities_unittest.cc
+++ b/thirdparty/glog/glog-0.3.5/src/utilities_unittest.cc
@@ -28,11 +28,15 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: Shinichiro Hamaji
-
#include "utilities.h"
#include "googletest.h"
#include "glog/logging.h"
+#ifdef HAVE_LIB_GFLAGS
+#include <gflags/gflags.h>
+using namespace GFLAGS_NAMESPACE;
+#endif
+
using namespace GOOGLE_NAMESPACE;
TEST(utilities, sync_val_compare_and_swap) {
diff --git a/thirdparty/glog/glog-0.3.4/src/vlog_is_on.cc b/thirdparty/glog/glog-0.3.5/src/vlog_is_on.cc
index 23741e8..698e128 100644
--- a/thirdparty/glog/glog-0.3.4/src/vlog_is_on.cc
+++ b/thirdparty/glog/glog-0.3.5/src/vlog_is_on.cc
@@ -1,9 +1,9 @@
-// This file has been modified by Huawei.
-// Copyright (C) 2018£¬ Huawei.
-//
// Copyright (c) 1999, 2007, Google Inc.
// All rights reserved.
//
+// This file has been modified by Huawei.
+// Copyright (C) 2018-2019, Huawei.
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -98,7 +98,7 @@ GOOGLE_GLOG_DLL_DECL bool SafeFNMatch_(const char* pattern,
}
}
-} // namespace glog_internal_namespace_
+} // namespace glog_ns_internal_namespace_
using glog_ns_internal_namespace_::SafeFNMatch_;
@@ -118,9 +118,10 @@ struct VModuleInfo {
// w/o much actual benefit.
const VModuleInfo* next;
};
-
+/**/
// This protects the following global variables.
static Mutex vmodule_lock;
+/**/
// Pointer to head of the VModuleInfo list.
// It's a map from module pattern to logging level for those module(s).
static VModuleInfo* vmodule_list = 0;
@@ -165,30 +166,32 @@ int SetVLOGLevel(const char* module_pattern, int log_level) {
int result = FLAGS_v;
int const pattern_len = strlen(module_pattern);
bool found = false;
- MutexLock l(&vmodule_lock); // protect whole read-modify-write
- for (const VModuleInfo* info = vmodule_list;
- info != NULL; info = info->next) {
- if (info->module_pattern == module_pattern) {
- if (!found) {
+ {
+ MutexLock l(&vmodule_lock); //False Positive // protect whole read-modify-write
+ for (const VModuleInfo* info = vmodule_list;
+ info != NULL; info = info->next) {
+ if (info->module_pattern == module_pattern) {
+ if (!found) {
+ result = info->vlog_level;
+ found = true;
+ }
+ info->vlog_level = log_level;
+ } else if (!found &&
+ SafeFNMatch_(info->module_pattern.c_str(),
+ info->module_pattern.size(),
+ module_pattern, pattern_len)) {
result = info->vlog_level;
found = true;
}
+ }
+ if (!found) {
+ VModuleInfo* info = new VModuleInfo;
+ info->module_pattern = module_pattern;
info->vlog_level = log_level;
- } else if (!found &&
- SafeFNMatch_(info->module_pattern.c_str(),
- info->module_pattern.size(),
- module_pattern, pattern_len)) {
- result = info->vlog_level;
- found = true;
+ info->next = vmodule_list;
+ vmodule_list = info;
}
}
- if (!found) {
- VModuleInfo* info = new VModuleInfo;
- info->module_pattern = module_pattern;
- info->vlog_level = log_level;
- info->next = vmodule_list;
- vmodule_list = info;
- }
RAW_VLOG(1, "Set VLOG level for \"%s\" to %d", module_pattern, log_level);
return result;
}
@@ -196,8 +199,8 @@ int SetVLOGLevel(const char* module_pattern, int log_level) {
// NOTE: Individual VLOG statements cache the integer log level pointers.
// NOTE: This function must not allocate memory or require any locks.
bool InitVLOG3__(int32** site_flag, int32* site_default,
- const char* fname, int32 verbose_level) {
- MutexLock l(&vmodule_lock);
+ const char* fname, int32 verbose_level) { //
+ MutexLock l(&vmodule_lock); //False Positive
bool read_vmodule_flag = inited_vmodule;
if (!read_vmodule_flag) {
VLOG2Initializer();
diff --git a/thirdparty/glog/glog-0.3.4/src/windows/config.h b/thirdparty/glog/glog-0.3.5/src/windows/config.h
index 2d23fb0..2d23fb0 100644
--- a/thirdparty/glog/glog-0.3.4/src/windows/config.h
+++ b/thirdparty/glog/glog-0.3.5/src/windows/config.h
diff --git a/thirdparty/glog/glog-0.3.4/src/windows/glog/log_severity.h b/thirdparty/glog/glog-0.3.5/src/windows/glog/log_severity.h
index 22a4191..22a4191 100644
--- a/thirdparty/glog/glog-0.3.4/src/windows/glog/log_severity.h
+++ b/thirdparty/glog/glog-0.3.5/src/windows/glog/log_severity.h
diff --git a/thirdparty/glog/glog-0.3.4/src/windows/glog/logging.h b/thirdparty/glog/glog-0.3.5/src/windows/glog/logging.h
index bab8c61..f521a2b 100644
--- a/thirdparty/glog/glog-0.3.4/src/windows/glog/logging.h
+++ b/thirdparty/glog/glog-0.3.5/src/windows/glog/logging.h
@@ -52,14 +52,6 @@
#endif
#include <vector>
-// Annoying stuff for windows -- makes sure clients can import these functions
-#ifndef GOOGLE_GLOG_DLL_DECL
-# if defined(_WIN32) && !defined(__CYGWIN__)
-# define GOOGLE_GLOG_DLL_DECL __declspec(dllimport)
-# else
-# define GOOGLE_GLOG_DLL_DECL
-# endif
-#endif
#if defined(_MSC_VER)
#define GLOG_MSVC_PUSH_DISABLE_WARNING(n) __pragma(warning(push)) \
__pragma(warning(disable:n))
@@ -69,6 +61,15 @@
#define GLOG_MSVC_POP_WARNING()
#endif
+// Annoying stuff for windows -- makes sure clients can import these functions
+#ifndef GOOGLE_GLOG_DLL_DECL
+# if defined(_WIN32) && !defined(__CYGWIN__)
+# define GOOGLE_GLOG_DLL_DECL __declspec(dllimport)
+# else
+# define GOOGLE_GLOG_DLL_DECL
+# endif
+#endif
+
// We care a lot about number of bits things take up. Unfortunately,
// systems define their bit-specific ints in a lot of different ways.
// We use our own way, and have a typedef to get there.
@@ -133,15 +134,28 @@ typedef unsigned __int64 uint64;
#ifndef GOOGLE_PREDICT_BRANCH_NOT_TAKEN
#if 0
#define GOOGLE_PREDICT_BRANCH_NOT_TAKEN(x) (__builtin_expect(x, 0))
-#define GOOGLE_PREDICT_FALSE(x) (__builtin_expect(x, 0))
-#define GOOGLE_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1))
#else
#define GOOGLE_PREDICT_BRANCH_NOT_TAKEN(x) x
+#endif
+#endif
+
+#ifndef GOOGLE_PREDICT_FALSE
+#if 0
+#define GOOGLE_PREDICT_FALSE(x) (__builtin_expect(x, 0))
+#else
#define GOOGLE_PREDICT_FALSE(x) x
+#endif
+#endif
+
+#ifndef GOOGLE_PREDICT_TRUE
+#if 0
+#define GOOGLE_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1))
+#else
#define GOOGLE_PREDICT_TRUE(x) x
#endif
#endif
+
// Make a bunch of macros for logging. The way to log things is to stream
// things to LOG(<a particular severity level>). E.g.,
//
@@ -351,6 +365,9 @@ DECLARE_int32(minloglevel);
// default logging directory.
DECLARE_string(log_dir);
+// Set the log file mode.
+DECLARE_int32(logfile_mode);
+
// Sets the path of the directory into which to put additional links
// to the log files.
DECLARE_string(log_link);
@@ -418,9 +435,15 @@ DECLARE_bool(stop_logging_if_full_disk);
#define LOG_TO_STRING_FATAL(message) google::NullStreamFatal()
#endif
+#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
+#define DCHECK_IS_ON() 0
+#else
+#define DCHECK_IS_ON() 1
+#endif
+
// For DFATAL, we want to use LogMessage (as opposed to
// LogMessageFatal), to be consistent with the original behavior.
-#ifdef NDEBUG
+#if !DCHECK_IS_ON()
#define COMPACT_GOOGLE_LOG_DFATAL COMPACT_GOOGLE_LOG_ERROR
#elif GOOGLE_STRIP_LOG <= 3
#define COMPACT_GOOGLE_LOG_DFATAL google::LogMessage( \
@@ -546,7 +569,7 @@ class LogSink; // defined below
// vector<string> *outvec;
// The cast is to disambiguate NULL arguments.
#define LOG_STRING(severity, outvec) \
- LOG_TO_STRING_##severity(static_cast<vector<string>*>(outvec)).stream()
+ LOG_TO_STRING_##severity(static_cast<std::vector<std::string>*>(outvec)).stream()
#define LOG_IF(severity, condition) \
!(condition) ? (void) 0 : google::LogMessageVoidify() & LOG(severity)
@@ -559,7 +582,7 @@ class LogSink; // defined below
SYSLOG_IF(FATAL, !(condition)) << "Assert failed: " #condition
// CHECK dies with a fatal error if condition is not true. It is *not*
-// controlled by NDEBUG, so the check will be executed regardless of
+// controlled by DCHECK_IS_ON(), so the check will be executed regardless of
// compilation mode. Therefore, it is safe to do things like:
// CHECK(fp->Write(x) == 4)
#define CHECK(condition) \
@@ -709,15 +732,15 @@ DEFINE_CHECK_OP_IMPL(Check_GT, > )
#if defined(STATIC_ANALYSIS)
// Only for static analysis tool to know that it is equivalent to assert
#define CHECK_OP_LOG(name, op, val1, val2, log) CHECK((val1) op (val2))
-#elif !defined(NDEBUG)
+#elif DCHECK_IS_ON()
// In debug mode, avoid constructing CheckOpStrings if possible,
// to reduce the overhead of CHECK statments by 2x.
// Real DCHECK-heavy tests have seen 1.5x speedups.
-// The meaning of "string" might be different between now and
+// The meaning of "string" might be different between now and
// when this macro gets invoked (e.g., if someone is experimenting
// with other string implementations that get defined after this
-// file is included). Save the current meaning now and use it
+// file is included). Save the current meaning now and use it
// in the macro.
typedef std::string _Check_string;
#define CHECK_OP_LOG(name, op, val1, val2, log) \
@@ -738,7 +761,7 @@ typedef std::string _Check_string;
google::GetReferenceableValue(val2), \
#val1 " " #op " " #val2)) \
log(__FILE__, __LINE__, _result).stream()
-#endif // STATIC_ANALYSIS, !NDEBUG
+#endif // STATIC_ANALYSIS, DCHECK_IS_ON()
#if GOOGLE_STRIP_LOG <= 3
#define CHECK_OP(name, op, val1, val2) \
@@ -910,6 +933,9 @@ template <bool>
struct CompileAssert {
};
struct CrashReason;
+
+// Returns true if FailureSignalHandler is installed.
+bool IsFailureSignalHandlerInstalled();
} // namespace glog_internal_namespace_
#define GOOGLE_GLOG_COMPILE_ASSERT(expr, msg) \
@@ -960,7 +986,7 @@ const LogSeverity GLOG_0 = GLOG_ERROR;
// Plus some debug-logging macros that get compiled to nothing for production
-#ifndef NDEBUG
+#if DCHECK_IS_ON()
#define DLOG(severity) LOG(severity)
#define DVLOG(verboselevel) VLOG(verboselevel)
@@ -970,7 +996,7 @@ const LogSeverity GLOG_0 = GLOG_ERROR;
LOG_IF_EVERY_N(severity, condition, n)
#define DLOG_ASSERT(condition) LOG_ASSERT(condition)
-// debug-only checking. not executed in NDEBUG mode.
+// debug-only checking. executed if DCHECK_IS_ON().
#define DCHECK(condition) CHECK(condition)
#define DCHECK_EQ(val1, val2) CHECK_EQ(val1, val2)
#define DCHECK_NE(val1, val2) CHECK_NE(val1, val2)
@@ -984,7 +1010,7 @@ const LogSeverity GLOG_0 = GLOG_ERROR;
#define DCHECK_STRNE(str1, str2) CHECK_STRNE(str1, str2)
#define DCHECK_STRCASENE(str1, str2) CHECK_STRCASENE(str1, str2)
-#else // NDEBUG
+#else // !DCHECK_IS_ON()
#define DLOG(severity) \
true ? (void) 0 : google::LogMessageVoidify() & LOG(severity)
@@ -1065,7 +1091,7 @@ const LogSeverity GLOG_0 = GLOG_ERROR;
while (false) \
GLOG_MSVC_POP_WARNING() CHECK_STRCASENE(str1, str2)
-#endif // NDEBUG
+#endif // DCHECK_IS_ON()
// Log only in verbose mode.
@@ -1155,6 +1181,8 @@ public:
char* str() const { return pbase(); }
private:
+ LogStream(const LogStream&);
+ LogStream& operator=(const LogStream&);
base_logging::LogStreamBuf streambuf_;
int ctr_; // Counter hack (for the LOG_EVERY_X() macro)
LogStream *self_; // Consistency check hack
@@ -1222,7 +1250,7 @@ public:
void SendToSyslogAndLog(); // Actually dispatch to syslog and the logs
// Call abort() or similar to perform LOG(FATAL) crash.
- static void Fail() ;
+ static void __declspec(noreturn) Fail();
std::ostream& stream();
@@ -1270,7 +1298,7 @@ class GOOGLE_GLOG_DLL_DECL LogMessageFatal : public LogMessage {
public:
LogMessageFatal(const char* file, int line);
LogMessageFatal(const char* file, int line, const CheckOpString& result);
- ~LogMessageFatal() ;
+ __declspec(noreturn) ~LogMessageFatal();
};
// A non-macro interface to the log facility; (useful
@@ -1285,6 +1313,35 @@ inline void LogAtLevel(int const severity, std::string const &msg) {
// LOG macros, 2. this macro can be used as C++ stream.
#define LOG_AT_LEVEL(severity) google::LogMessage(__FILE__, __LINE__, severity).stream()
+// Check if it's compiled in C++11 mode.
+//
+// GXX_EXPERIMENTAL_CXX0X is defined by gcc and clang up to at least
+// gcc-4.7 and clang-3.1 (2011-12-13). __cplusplus was defined to 1
+// in gcc before 4.7 (Crosstool 16) and clang before 3.1, but is
+// defined according to the language version in effect thereafter.
+// Microsoft Visual Studio 14 (2015) sets __cplusplus==199711 despite
+// reasonably good C++11 support, so we set LANG_CXX for it and
+// newer versions (_MSC_VER >= 1900).
+#if (defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L || \
+ (defined(_MSC_VER) && _MSC_VER >= 1900))
+// Helper for CHECK_NOTNULL().
+//
+// In C++11, all cases can be handled by a single function. Since the value
+// category of the argument is preserved (also for rvalue references),
+// member initializer lists like the one below will compile correctly:
+//
+// Foo()
+// : x_(CHECK_NOTNULL(MethodReturningUniquePtr())) {}
+template <typename T>
+T CheckNotNull(const char* file, int line, const char* names, T&& t) {
+ if (t == nullptr) {
+ LogMessageFatal(file, line, new std::string(names));
+ }
+ return std::forward<T>(t);
+}
+
+#else
+
// A small helper for CHECK_NOTNULL().
template <typename T>
T* CheckNotNull(const char *file, int line, const char *names, T* t) {
@@ -1293,6 +1350,7 @@ T* CheckNotNull(const char *file, int line, const char *names, T* t) {
}
return t;
}
+#endif
// Allow folks to put a counter in the LOG_EVERY_X()'ed messages. This
// only works if ostream is a LogStream. If the ostream is not a
@@ -1574,7 +1632,7 @@ class GOOGLE_GLOG_DLL_DECL NullStreamFatal : public NullStream {
NullStreamFatal() { }
NullStreamFatal(const char* file, int line, const CheckOpString& result) :
NullStream(file, line, result) { }
- ~NullStreamFatal() { _exit(1); }
+ __declspec(noreturn) ~NullStreamFatal() throw () { _exit(1); }
};
// Install a signal handler that will dump signal information and a stack
diff --git a/thirdparty/glog/glog-0.3.4/src/windows/glog/raw_logging.h b/thirdparty/glog/glog-0.3.5/src/windows/glog/raw_logging.h
index 4757a71..4757a71 100644
--- a/thirdparty/glog/glog-0.3.4/src/windows/glog/raw_logging.h
+++ b/thirdparty/glog/glog-0.3.5/src/windows/glog/raw_logging.h
diff --git a/thirdparty/glog/glog-0.3.4/src/windows/glog/stl_logging.h b/thirdparty/glog/glog-0.3.5/src/windows/glog/stl_logging.h
index a97a908..a97a908 100644
--- a/thirdparty/glog/glog-0.3.4/src/windows/glog/stl_logging.h
+++ b/thirdparty/glog/glog-0.3.5/src/windows/glog/stl_logging.h
diff --git a/thirdparty/glog/glog-0.3.4/src/windows/glog/vlog_is_on.h b/thirdparty/glog/glog-0.3.5/src/windows/glog/vlog_is_on.h
index 409a401..409a401 100644
--- a/thirdparty/glog/glog-0.3.4/src/windows/glog/vlog_is_on.h
+++ b/thirdparty/glog/glog-0.3.5/src/windows/glog/vlog_is_on.h
diff --git a/thirdparty/glog/glog-0.3.4/src/windows/port.cc b/thirdparty/glog/glog-0.3.5/src/windows/port.cc
index bfa6e70..5b0332d 100644
--- a/thirdparty/glog/glog-0.3.4/src/windows/port.cc
+++ b/thirdparty/glog/glog-0.3.5/src/windows/port.cc
@@ -1,6 +1,9 @@
/* Copyright (c) 2008, Google Inc.
* All rights reserved.
- *
+ *
+ * This file has been modified by Huawei.
+ * Copyright (C) 2018-2019, Huawei.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
@@ -51,10 +54,11 @@ using std::vector;
int safe_vsnprintf(char *str, size_t size, const char *format, va_list ap) {
if (size == 0) // not even room for a \0?
return -1; // not what C99 says to do, but what windows does
- str[size-1] = '\0';
+ str[size-1] = '\0'; //False positive
return _vsnprintf(str, size-1, format, ap);
}
+#ifndef HAVE_SNPRINTF
int snprintf(char *str, size_t size, const char *format, ...) {
va_list ap;
va_start(ap, format);
@@ -62,3 +66,4 @@ int snprintf(char *str, size_t size, const char *format, ...) {
va_end(ap);
return r;
}
+#endif
diff --git a/thirdparty/glog/glog-0.3.4/src/windows/port.h b/thirdparty/glog/glog-0.3.5/src/windows/port.h
index 24d7677..8198461 100644
--- a/thirdparty/glog/glog-0.3.4/src/windows/port.h
+++ b/thirdparty/glog/glog-0.3.5/src/windows/port.h
@@ -111,12 +111,16 @@ enum { STDIN_FILENO = 0, STDOUT_FILENO = 1, STDERR_FILENO = 2 };
* because they don't always NUL-terminate. :-( We also can't use the
* name vsnprintf, since windows defines that (but not snprintf (!)).
*/
-extern int snprintf(char *str, size_t size,
+#ifndef HAVE_SNPRINTF
+extern int GOOGLE_GLOG_DLL_DECL snprintf(char *str, size_t size,
const char *format, ...);
-extern int safe_vsnprintf(char *str, size_t size,
+#endif
+extern int GOOGLE_GLOG_DLL_DECL safe_vsnprintf(char *str, size_t size,
const char *format, va_list ap);
#define vsnprintf(str, size, format, ap) safe_vsnprintf(str, size, format, ap)
+#ifndef va_copy
#define va_copy(dst, src) (dst) = (src)
+#endif
/* Windows doesn't support specifying the number of buckets as a
* hash_map constructor arg, so we leave this blank.
@@ -132,6 +136,7 @@ typedef int pid_t;
#endif // _MSC_VER
// ----------------------------------- THREADS
+#ifndef __MINGW32__
typedef DWORD pthread_t;
typedef DWORD pthread_key_t;
typedef LONG pthread_once_t;
@@ -143,6 +148,7 @@ inline struct tm* localtime_r(const time_t* timep, struct tm* result) {
localtime_s(result, timep);
return result;
}
+#endif
inline char* strerror_r(int errnum, char* buf, size_t buflen) {
strerror_s(buf, buflen, errnum);
diff --git a/thirdparty/glog/glog-0.3.4/src/windows/preprocess.sh b/thirdparty/glog/glog-0.3.5/src/windows/preprocess.sh
index 5398988..c35e929 100644
--- a/thirdparty/glog/glog-0.3.4/src/windows/preprocess.sh
+++ b/thirdparty/glog/glog-0.3.5/src/windows/preprocess.sh
@@ -95,7 +95,7 @@ DLLDEF_DEFINES="\
-e "s!@ac_cv_have_libgflags@!0!g" \
-e "s!@ac_cv_have___builtin_expect@!0!g" \
-e "s!@ac_cv_cxx_using_operator@!1!g" \
- -e "s!@ac_cv___attribute___noreturn@!!g" \
+ -e "s!@ac_cv___attribute___noreturn@!__declspec(noreturn)!g" \
-e "s!@ac_cv___attribute___noinline@!!g" \
-e "s!@ac_cv___attribute___printf_4_5@!!g" \
-e "s!@ac_google_attribute@!${HAVE___ATTRIBUTE__:-0}!g" \
diff --git a/thirdparty/glog/glog-0.3.5/test-driver b/thirdparty/glog/glog-0.3.5/test-driver
new file mode 100644
index 0000000..84e7d90
--- /dev/null
+++ b/thirdparty/glog/glog-0.3.5/test-driver
@@ -0,0 +1 @@
+/usr/share/automake-1.14/test-driver \ No newline at end of file
diff --git a/thirdparty/glog/glog-0.3.4/vsprojects/libglog/libglog.vcproj b/thirdparty/glog/glog-0.3.5/vsprojects/libglog/libglog.vcproj
index 7d15075..67aeaac 100644
--- a/thirdparty/glog/glog-0.3.4/vsprojects/libglog/libglog.vcproj
+++ b/thirdparty/glog/glog-0.3.5/vsprojects/libglog/libglog.vcproj
@@ -1,249 +1,249 @@
-<?xml version="1.0" encoding="shift_jis"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9.00"
- Name="libglog"
- ProjectGUID="{34BD04BD-BC1D-4BFC-AAFC-ED02D9E960F1}"
- RootNamespace="libglog"
- Keyword="Win32Proj"
- TargetFrameworkVersion="196613"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="2"
- CharacterSet="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\..\src\windows"
- PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBGLOG_EXPORTS"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- LinkIncremental="2"
- GenerateDebugInformation="true"
- SubSystem="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="2"
- CharacterSet="1"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- EnableIntrinsicFunctions="true"
- AdditionalIncludeDirectories="..\..\src\windows"
- PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBGLOG_EXPORTS"
- RuntimeLibrary="2"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- LinkIncremental="1"
- GenerateDebugInformation="true"
- SubSystem="2"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath="..\..\src\logging.cc"
- >
- </File>
- <File
- RelativePath="..\..\src\windows\port.cc"
- >
- </File>
- <File
- RelativePath="..\..\src\raw_logging.cc"
- >
- </File>
- <File
- RelativePath="..\..\src\utilities.cc"
- >
- </File>
- <File
- RelativePath="..\..\src\vlog_is_on.cc"
- >
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc;xsd"
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
- >
- <File
- RelativePath="..\..\src\base\commandlineflags.h"
- >
- </File>
- <File
- RelativePath="..\..\src\windows\config.h"
- >
- </File>
- <File
- RelativePath="..\..\src\base\googleinit.h"
- >
- </File>
- <File
- RelativePath="..\..\src\windows\glog\log_severity.h"
- >
- </File>
- <File
- RelativePath="..\..\src\windows\glog\logging.h"
- >
- </File>
- <File
- RelativePath="..\..\src\base\mutex.h"
- >
- </File>
- <File
- RelativePath="..\..\src\windows\port.h"
- >
- </File>
- <File
- RelativePath="..\..\src\windows\glog\raw_logging.h"
- >
- </File>
- <File
- RelativePath="..\..\src\windows\glog\stl_logging.h"
- >
- </File>
- <File
- RelativePath="..\..\src\utilities.h"
- >
- </File>
- <File
- RelativePath="..\..\src\windows\glog\vlog_is_on.h"
- >
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
+<?xml version="1.0" encoding="shift_jis"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="libglog"
+ ProjectGUID="{34BD04BD-BC1D-4BFC-AAFC-ED02D9E960F1}"
+ RootNamespace="libglog"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="..\..\src\windows"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBGLOG_EXPORTS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories="..\..\src\windows"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBGLOG_EXPORTS"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath="..\..\src\logging.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\windows\port.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\raw_logging.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\utilities.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\vlog_is_on.cc"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\..\src\base\commandlineflags.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\windows\config.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\base\googleinit.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\windows\glog\log_severity.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\windows\glog\logging.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\base\mutex.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\windows\port.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\windows\glog\raw_logging.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\windows\glog\stl_logging.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\utilities.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\windows\glog\vlog_is_on.h"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/thirdparty/glog/glog-0.3.4/vsprojects/libglog_static/libglog_static.vcproj b/thirdparty/glog/glog-0.3.5/vsprojects/libglog_static/libglog_static.vcproj
index 66e9337..ea66936 100644
--- a/thirdparty/glog/glog-0.3.4/vsprojects/libglog_static/libglog_static.vcproj
+++ b/thirdparty/glog/glog-0.3.5/vsprojects/libglog_static/libglog_static.vcproj
@@ -1,220 +1,220 @@
-<?xml version="1.0" encoding="shift_jis"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9.00"
- Name="libglog_static"
- ProjectGUID="{772C2111-BBBF-49E6-B912-198A7F7A88E5}"
- RootNamespace="libglog_static"
- TargetFrameworkVersion="196613"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="4"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\..\src\windows"
- PreprocessorDefinitions="GOOGLE_GLOG_DLL_DECL="
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="4"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- EnableIntrinsicFunctions="true"
- AdditionalIncludeDirectories="..\..\src\windows"
- PreprocessorDefinitions="GOOGLE_GLOG_DLL_DECL="
- RuntimeLibrary="2"
- EnableFunctionLevelLinking="true"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- >
- <File
- RelativePath="..\..\src\logging.cc"
- >
- </File>
- <File
- RelativePath="..\..\src\windows\port.cc"
- >
- </File>
- <File
- RelativePath="..\..\src\raw_logging.cc"
- >
- </File>
- <File
- RelativePath="..\..\src\utilities.cc"
- >
- </File>
- <File
- RelativePath="..\..\src\vlog_is_on.cc"
- >
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- >
- <File
- RelativePath="..\..\src\base\commandlineflags.h"
- >
- </File>
- <File
- RelativePath="..\..\src\windows\config.h"
- >
- </File>
- <File
- RelativePath="..\..\src\base\googleinit.h"
- >
- </File>
- <File
- RelativePath="..\..\src\windows\glog\log_severity.h"
- >
- </File>
- <File
- RelativePath="..\..\src\windows\glog\logging.h"
- >
- </File>
- <File
- RelativePath="..\..\src\base\mutex.h"
- >
- </File>
- <File
- RelativePath="..\..\src\windows\port.h"
- >
- </File>
- <File
- RelativePath="..\..\src\windows\glog\raw_logging.h"
- >
- </File>
- <File
- RelativePath="..\..\src\windows\glog\stl_logging.h"
- >
- </File>
- <File
- RelativePath="..\..\src\utilities.h"
- >
- </File>
- <File
- RelativePath="..\..\src\windows\glog\vlog_is_on.h"
- >
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
+<?xml version="1.0" encoding="shift_jis"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="libglog_static"
+ ProjectGUID="{772C2111-BBBF-49E6-B912-198A7F7A88E5}"
+ RootNamespace="libglog_static"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="4"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="..\..\src\windows"
+ PreprocessorDefinitions="GOOGLE_GLOG_DLL_DECL="
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="4"
+ CharacterSet="2"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories="..\..\src\windows"
+ PreprocessorDefinitions="GOOGLE_GLOG_DLL_DECL="
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ >
+ <File
+ RelativePath="..\..\src\logging.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\windows\port.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\raw_logging.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\utilities.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\vlog_is_on.cc"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ >
+ <File
+ RelativePath="..\..\src\base\commandlineflags.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\windows\config.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\base\googleinit.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\windows\glog\log_severity.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\windows\glog\logging.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\base\mutex.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\windows\port.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\windows\glog\raw_logging.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\windows\glog\stl_logging.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\utilities.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\windows\glog\vlog_is_on.h"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/thirdparty/glog/glog-0.3.4/vsprojects/logging_unittest/logging_unittest.vcproj b/thirdparty/glog/glog-0.3.5/vsprojects/logging_unittest/logging_unittest.vcproj
index 1756ce0..649a234 100644
--- a/thirdparty/glog/glog-0.3.4/vsprojects/logging_unittest/logging_unittest.vcproj
+++ b/thirdparty/glog/glog-0.3.5/vsprojects/logging_unittest/logging_unittest.vcproj
@@ -1,193 +1,193 @@
-<?xml version="1.0" encoding="utf-8"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9.00"
- Name="logging_unittest"
- ProjectGUID="{DD0690AA-5E09-46B5-83FD-4B28604CABA8}"
- RootNamespace="logging_unittest"
- Keyword="Win32Proj"
- TargetFrameworkVersion="196613"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- CharacterSet="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\..\src\windows"
- PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- LinkIncremental="2"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- CharacterSet="1"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- EnableIntrinsicFunctions="true"
- AdditionalIncludeDirectories="..\..\src\windows"
- PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
- RuntimeLibrary="2"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- LinkIncremental="1"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath="..\..\src\logging_unittest.cc"
- >
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc;xsd"
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
- >
- <File
- RelativePath="..\..\src\googletest.h"
- >
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
+<?xml version="1.0" encoding="utf-8"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="logging_unittest"
+ ProjectGUID="{DD0690AA-5E09-46B5-83FD-4B28604CABA8}"
+ RootNamespace="logging_unittest"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="..\..\src\windows"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories="..\..\src\windows"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath="..\..\src\logging_unittest.cc"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\..\src\googletest.h"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/thirdparty/glog/glog-0.3.4/vsprojects/logging_unittest_static/logging_unittest_static.vcproj b/thirdparty/glog/glog-0.3.5/vsprojects/logging_unittest_static/logging_unittest_static.vcproj
index 244542a..0d33aaf 100644
--- a/thirdparty/glog/glog-0.3.4/vsprojects/logging_unittest_static/logging_unittest_static.vcproj
+++ b/thirdparty/glog/glog-0.3.5/vsprojects/logging_unittest_static/logging_unittest_static.vcproj
@@ -1,182 +1,182 @@
-<?xml version="1.0" encoding="shift_jis"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9.00"
- Name="logging_unittest_static"
- ProjectGUID="{9B239B45-84A9-4E06-AC46-8E220CD43974}"
- RootNamespace="logging_unittest_static"
- TargetFrameworkVersion="196613"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\..\src\windows"
- PreprocessorDefinitions="GOOGLE_GLOG_DLL_DECL="
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- EnableIntrinsicFunctions="true"
- AdditionalIncludeDirectories="..\..\src\windows"
- PreprocessorDefinitions="GOOGLE_GLOG_DLL_DECL="
- RuntimeLibrary="2"
- EnableFunctionLevelLinking="true"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Header Files"
- >
- <File
- RelativePath="..\..\src\googletest.h"
- >
- </File>
- </Filter>
- <Filter
- Name="Source Files"
- >
- <File
- RelativePath="..\..\src\logging_unittest.cc"
- >
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
+<?xml version="1.0" encoding="shift_jis"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="logging_unittest_static"
+ ProjectGUID="{9B239B45-84A9-4E06-AC46-8E220CD43974}"
+ RootNamespace="logging_unittest_static"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="..\..\src\windows"
+ PreprocessorDefinitions="GOOGLE_GLOG_DLL_DECL="
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ GenerateDebugInformation="true"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories="..\..\src\windows"
+ PreprocessorDefinitions="GOOGLE_GLOG_DLL_DECL="
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ GenerateDebugInformation="true"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Header Files"
+ >
+ <File
+ RelativePath="..\..\src\googletest.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Source Files"
+ >
+ <File
+ RelativePath="..\..\src\logging_unittest.cc"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>