"Fossies" - the Fresh Open Source Software Archive

Member "bind-9.17.5/lib/isc/netmgr/uv-compat.h" (4 Sep 2020, 2132 Bytes) of package /linux/misc/dns/bind9/9.17.5/bind-9.17.5.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "uv-compat.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
    3  *
    4  * This Source Code Form is subject to the terms of the Mozilla Public
    5  * License, v. 2.0. If a copy of the MPL was not distributed with this
    6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
    7  *
    8  * See the COPYRIGHT file distributed with this work for additional
    9  * information regarding copyright ownership.
   10  */
   11 
   12 #pragma once
   13 #include <uv.h>
   14 
   15 /*
   16  * These functions were introduced in newer libuv, but we still
   17  * want BIND9 compile on older ones so we emulate them.
   18  * They're inline to avoid conflicts when running with a newer
   19  * library version.
   20  */
   21 
   22 #ifndef HAVE_UV_HANDLE_GET_DATA
   23 static inline void *
   24 uv_handle_get_data(const uv_handle_t *handle) {
   25     return (handle->data);
   26 }
   27 #endif /* ifndef HAVE_UV_HANDLE_GET_DATA */
   28 
   29 #ifndef HAVE_UV_HANDLE_SET_DATA
   30 static inline void
   31 uv_handle_set_data(uv_handle_t *handle, void *data) {
   32     handle->data = data;
   33 }
   34 #endif /* ifndef HAVE_UV_HANDLE_SET_DATA */
   35 
   36 #ifdef HAVE_UV_IMPORT
   37 
   38 #define isc_uv_stream_info_t uv_stream_info_t
   39 #define isc_uv_export        uv_export
   40 #define isc_uv_import        uv_import
   41 
   42 #else
   43 
   44 /*
   45  * These functions are not available in libuv, but they're very internal
   46  * to libuv. We should try to get them merged upstream.
   47  */
   48 
   49 /*
   50  * A sane way to pass listening TCP socket to child threads, without using
   51  * IPC (as the libuv example shows) but a version of the uv_export() and
   52  * uv_import() functions that were unfortunately removed from libuv.
   53  * This is based on the original libuv code.
   54  */
   55 
   56 typedef struct isc_uv_stream_info_s isc_uv_stream_info_t;
   57 
   58 struct isc_uv_stream_info_s {
   59     uv_handle_type type;
   60 #ifdef WIN32
   61     WSAPROTOCOL_INFOW socket_info;
   62 #else  /* ifdef WIN32 */
   63     int fd;
   64 #endif /* ifdef WIN32 */
   65 };
   66 
   67 int
   68 isc_uv_export(uv_stream_t *stream, isc_uv_stream_info_t *info);
   69 /*%<
   70  * Exports uv_stream_t as isc_uv_stream_info_t value, which could
   71  * be used to initialize shared streams within the same process.
   72  */
   73 
   74 int
   75 isc_uv_import(uv_stream_t *stream, isc_uv_stream_info_t *info);
   76 /*%<
   77  * Imports uv_stream_info_t value into uv_stream_t to initialize a
   78  * shared stream.
   79  */
   80 
   81 #endif