From f4cd99f1b183c3b471eb29da9b19a78dc842ac91 Mon Sep 17 00:00:00 2001 From: Maschell Date: Wed, 28 Apr 2021 22:12:07 +0200 Subject: [PATCH] libwutsocket: Add __wut_socket_init_devoptab() and __wut_socket_fini_devoptab() --- libraries/wutsocket/wut_socket_common.c | 50 ++++++++++++++----------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/libraries/wutsocket/wut_socket_common.c b/libraries/wutsocket/wut_socket_common.c index c0ac2ae..fe50384 100644 --- a/libraries/wutsocket/wut_socket_common.c +++ b/libraries/wutsocket/wut_socket_common.c @@ -4,9 +4,6 @@ int h_errno; -static uint32_t -__wut_socket_refcount = 0; - static devoptab_t __wut_socket_devoptab = { @@ -76,43 +73,52 @@ __wut_nsysnet_error_code_map[] = }; void +__wut_socket_init_devoptab() +{ + AddDevice(&__wut_socket_devoptab); +} + +void +__wut_socket_fini_devoptab() +{ + RemoveDevice("soc:"); +} + +__attribute__ ((deprecated)) +static inline void +WHBInitializeSocketLibrary() {} + +__attribute__ ((deprecated)) +static inline void +WHBDeinitializeSocketLibrary() {} + +inline void socket_lib_init() { - if (0 == __wut_socket_refcount++) { - RPLWRAP(socket_lib_init)(); - AddDevice(&__wut_socket_devoptab); - } + RPLWRAP(socket_lib_init)(); } -void +inline void socket_lib_finish() { - if (0 == --__wut_socket_refcount) { - RemoveDevice("soc:"); - RPLWRAP(socket_lib_finish)(); - } + RPLWRAP(socket_lib_finish)(); } -void -WHBInitializeSocketLibrary() __attribute__((alias("socket_lib_init"))); - -void -WHBDeinitializeSocketLibrary() __attribute__((alias("socket_lib_finish"))); - void __attribute__((weak)) __init_wut_socket() { - socket_lib_init(); + RPLWRAP(socket_lib_init)(); + __wut_socket_init_devoptab(); ACInitialize(); ACConnectAsync(); } void __attribute__((weak)) -__fini_wut_socket() -{ +__fini_wut_socket() { ACClose(); ACFinalize(); - socket_lib_finish(); + __wut_socket_fini_devoptab(); + RPLWRAP(socket_lib_finish)(); } int