diff options
author | vvvv <vvvv@yandex-team.ru> | 2022-03-03 23:09:11 +0300 |
---|---|---|
committer | vvvv <vvvv@yandex-team.ru> | 2022-03-03 23:09:11 +0300 |
commit | 8dbdbab054b6eb352cfffdad09991052008062fc (patch) | |
tree | 71befed92d327f2cc409bff4986ec510d0530d92 /contrib/libs/libc_compat | |
parent | ed3f4e21f3a3837059607ec2606e1dc910269ac0 (diff) | |
download | ydb-8dbdbab054b6eb352cfffdad09991052008062fc.tar.gz |
YQL-13710 try to switch to new shiny PG
ref:2bed0445c8e8bd6c575883632adf19445f0a72a7
Diffstat (limited to 'contrib/libs/libc_compat')
-rw-r--r-- | contrib/libs/libc_compat/.yandex_meta/devtools.copyrights.report | 173 | ||||
-rw-r--r-- | contrib/libs/libc_compat/.yandex_meta/devtools.licenses.report | 97 | ||||
-rw-r--r-- | contrib/libs/libc_compat/.yandex_meta/licenses.list.txt | 139 | ||||
-rw-r--r-- | contrib/libs/libc_compat/include/ifaddrs/ifaddrs.h | 54 | ||||
-rw-r--r-- | contrib/libs/libc_compat/include/link/link.h | 15 | ||||
-rw-r--r-- | contrib/libs/libc_compat/include/uchar/uchar.h | 30 | ||||
-rw-r--r-- | contrib/libs/libc_compat/include/windows/sys/queue.h | 631 | ||||
-rw-r--r-- | contrib/libs/libc_compat/include/windows/sys/uio.h | 25 | ||||
-rw-r--r-- | contrib/libs/libc_compat/patches/getrandom.patch | 24 | ||||
-rw-r--r-- | contrib/libs/libc_compat/patches/glob.patch | 112 | ||||
-rw-r--r-- | contrib/libs/libc_compat/patches/memfd_create.patch | 13 | ||||
-rw-r--r-- | contrib/libs/libc_compat/patches/readpassphrase.patch | 43 | ||||
-rw-r--r-- | contrib/libs/libc_compat/patches/sys-queue.patch | 11 | ||||
-rw-r--r-- | contrib/libs/libc_compat/patches/uchar.patch | 19 | ||||
-rw-r--r-- | contrib/libs/libc_compat/src/windows/sys/uio.c | 36 |
15 files changed, 1422 insertions, 0 deletions
diff --git a/contrib/libs/libc_compat/.yandex_meta/devtools.copyrights.report b/contrib/libs/libc_compat/.yandex_meta/devtools.copyrights.report new file mode 100644 index 0000000000..f3f8c187ff --- /dev/null +++ b/contrib/libs/libc_compat/.yandex_meta/devtools.copyrights.report @@ -0,0 +1,173 @@ +# File format ($ symbol means the beginning of a line): +# +# $ # this message +# $ # ======================= +# $ # comments (all commentaries should starts with some number of spaces and # symbol) +# ${action} {license id} {license text hash} +# $BELONGS ./ya/make/file/relative/path/1/ya.make ./ya/make/2/ya.make +# ${all_file_action} filename +# $ # user commentaries (many lines) +# $ generated description - files with this license, license text... (some number of lines that starts with some number of spaces, do not modify) +# ${action} {license spdx} {license text hash} +# $BELONGS ./ya/make/file/relative/path/3/ya.make +# ${all_file_action} filename +# $ # user commentaries +# $ generated description +# $ ... +# +# You can modify action, all_file_action and add commentaries +# Available actions: +# keep - keep license in contrib and use in credits +# skip - skip license +# remove - remove all files with this license +# rename - save license text/links into licenses texts file, but not store SPDX into LINCENSE macro. You should store correct license id into devtools.license.spdx.txt file +# +# {all file action} records will be generated when license text contains filename that exists on filesystem (in contrib directory) +# We suppose that that files can contain some license info +# Available all file actions: +# FILE_IGNORE - ignore file (do nothing) +# FILE_INCLUDE - include all file data into licenses text file +# ======================= + +KEEP COPYRIGHT_SERVICE_LABEL 08bbe4fd1b231eb966c974f99c49d52f +BELONGS ya.make + License text: + * Copyright (c) 2000, 2002 Todd C. Miller <millert@openbsd.org> + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + include/readpassphrase/readpassphrase.h [4:4] + +KEEP COPYRIGHT_SERVICE_LABEL 16ed76d63a9c46131af23245e9ca696b +BELONGS ya.make + License text: + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + include/windows/sys/queue.h [5:6] + +KEEP COPYRIGHT_SERVICE_LABEL 6756ba5d0351dfed8384f4b6fabcda9a +BELONGS ya.make + License text: + * Copyright (c) 1998, 2015 Todd C. Miller <millert@openbsd.org> + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + strlcat.c [4:4] + strlcpy.c [4:4] + +KEEP COPYRIGHT_SERVICE_LABEL 7d1bea1f4b3740390787ad95188cd1ef +BELONGS ya.make + License text: + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + glob.c [4:5] + glob.h [4:5] + +KEEP COPYRIGHT_SERVICE_LABEL 87418e105a8e02f5df41c4fb7ae8a844 +BELONGS ya.make + License text: + * Copyright (c) 1988 Regents of the University of California. + * All rights reserved. + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + stpcpy.c [4:5] + +KEEP COPYRIGHT_SERVICE_LABEL 91ed2a52abb6d4174e5a50147be44f81 +BELONGS ya.make + License text: + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + strcasestr.c [5:6] + strsep.c [4:5] + +KEEP COPYRIGHT_SERVICE_LABEL bb09280c32d31495b4855e76725fab5a +BELONGS ya.make + License text: + * Copyright (c) 2008 Otto Moerbeek <otto@drijf.net> + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + reallocarray.c [3:3] + +KEEP COPYRIGHT_SERVICE_LABEL c0273399b7c5a90deded3ad328b55549 +BELONGS ya.make + License text: + Copyright (c) 2013, Kenneth MacKay + All rights reserved. + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + ifaddrs.c [2:3] + +KEEP COPYRIGHT_SERVICE_LABEL c295c50e76f3eb82c4e3effae8638599 +BELONGS ya.make + License text: + * Copyright (c) 1995, 1999 + * Berkeley Software Design, Inc. All rights reserved. + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + include/ifaddrs/ifaddrs.h [2:3] + +KEEP COPYRIGHT_SERVICE_LABEL cc6fac7a30f259c206a6dcac7b905a1a +BELONGS ya.make + License text: + * Copyright (c) 2007 Todd C. Miller <millert@openbsd.org> + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + memrchr.c [4:4] + +KEEP COPYRIGHT_SERVICE_LABEL df3d3ca746fea6578433a08d4abde6f4 +BELONGS ya.make + License text: + * Copyright (c) 2000-2002, 2007, 2010 + * Todd C. Miller <millert@openbsd.org> + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + readpassphrase.c [4:5] + +KEEP COPYRIGHT_SERVICE_LABEL f528f9ebef217bea871ce3500196c784 +BELONGS ya.make + License text: + * Copyright (c) 2011 The FreeBSD Foundation + * All rights reserved. + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + glob.c [10:11] diff --git a/contrib/libs/libc_compat/.yandex_meta/devtools.licenses.report b/contrib/libs/libc_compat/.yandex_meta/devtools.licenses.report new file mode 100644 index 0000000000..22b117056e --- /dev/null +++ b/contrib/libs/libc_compat/.yandex_meta/devtools.licenses.report @@ -0,0 +1,97 @@ +# File format ($ symbol means the beginning of a line): +# +# $ # this message +# $ # ======================= +# $ # comments (all commentaries should starts with some number of spaces and # symbol) +# ${action} {license spdx} {license text hash} +# $BELONGS ./ya/make/file/relative/path/1/ya.make ./ya/make/2/ya.make +# ${all_file_action} filename +# $ # user commentaries (many lines) +# $ generated description - files with this license, license text... (some number of lines that starts with some number of spaces, do not modify) +# ${action} {license spdx} {license text hash} +# $BELONGS ./ya/make/file/relative/path/3/ya.make +# ${all_file_action} filename +# $ # user commentaries +# $ generated description +# $ ... +# +# You can modify action, all_file_action and add commentaries +# Available actions: +# keep - keep license in contrib and use in credits +# skip - skip license +# remove - remove all files with this license +# rename - save license text/links into licenses texts file, but not store SPDX into LINCENSE macro. You should store correct license id into devtools.license.spdx.txt file +# +# {all file action} records will be generated when license text contains filename that exists on filesystem (in contrib directory) +# We suppose that that files can contain some license info +# Available all file actions: +# FILE_IGNORE - ignore file (do nothing) +# FILE_INCLUDE - include all file data into licenses text file +# ======================= + +KEEP BSD-1-Clause 0dd0e77e3302ccf52f9e408a5800d1a8 +BELONGS ya.make + Note: matched license text is too long. Read it in the source files. + Scancode info: + Original SPDX id: BSD-1-Clause + Score : 96.08 + Match type : TEXT + Links : https://spdx.org/licenses/BSD-1-Clause, https://svnweb.freebsd.org/base/head/include/ifaddrs.h?revision=326823 + Files with this license: + include/ifaddrs/ifaddrs.h [5:21] + +KEEP BSD-2-Clause 632814d5887b08580bbc8f83b13fb546 +BELONGS ya.make + Note: matched license text is too long. Read it in the source files. + Scancode info: + Original SPDX id: BSD-2-Clause + Score : 100.00 + Match type : TEXT + Links : http://opensource.org/licenses/bsd-license.php, http://www.opensource.org/licenses/BSD-2-Clause, https://spdx.org/licenses/BSD-2-Clause + Files with this license: + ifaddrs.c [5:22] + +KEEP BSD-3-Clause 6daffccbe81cc81cf1b75435c1342138 +BELONGS ya.make + Note: matched license text is too long. Read it in the source files. + Scancode info: + Original SPDX id: BSD-3-Clause + Score : 100.00 + Match type : TEXT + Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause + Files with this license: + glob.c [15:37] + glob.h [10:32] + include/windows/sys/queue.h [8:30] + stpcpy.c [7:29] + strcasestr.c [11:33] + strsep.c [7:29] + +KEEP BSD-3-Clause bcd96bf495243cd22767952d056c373c +BELONGS ya.make + License text: + * SPDX-License-Identifier: BSD-3-Clause + Scancode info: + Original SPDX id: BSD-3-Clause + Score : 100.00 + Match type : TAG + Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause + Files with this license: + glob.c [2:2] + glob.h [2:2] + +KEEP ISC e6a382fc7564fdd1a5e46b2d97b3221f +BELONGS ya.make + Note: matched license text is too long. Read it in the source files. + Scancode info: + Original SPDX id: ISC + Score : 100.00 + Match type : TEXT + Links : http://fedoraproject.org/wiki/Licensing:MIT#Old_Style_with_legal_disclaimer_2, https://spdx.org/licenses/ISC, https://www.isc.org/software/license + Files with this license: + include/readpassphrase/readpassphrase.h [6:16] + memrchr.c [6:16] + readpassphrase.c [7:17] + reallocarray.c [5:15] + strlcat.c [6:16] + strlcpy.c [6:16] diff --git a/contrib/libs/libc_compat/.yandex_meta/licenses.list.txt b/contrib/libs/libc_compat/.yandex_meta/licenses.list.txt new file mode 100644 index 0000000000..46468caf18 --- /dev/null +++ b/contrib/libs/libc_compat/.yandex_meta/licenses.list.txt @@ -0,0 +1,139 @@ +====================BSD-1-Clause==================== + * 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. + * + * THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``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 Berkeley Software Design, Inc. BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + + +====================BSD-2-Clause==================== +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +====================BSD-3-Clause==================== + * 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. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + + +====================BSD-3-Clause==================== + * SPDX-License-Identifier: BSD-3-Clause + + +====================COPYRIGHT==================== + * Copyright (c) 1988 Regents of the University of California. + * All rights reserved. + + +====================COPYRIGHT==================== + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + + +====================COPYRIGHT==================== + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + + +====================COPYRIGHT==================== + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + + +====================COPYRIGHT==================== + * Copyright (c) 1995, 1999 + * Berkeley Software Design, Inc. All rights reserved. + + +====================COPYRIGHT==================== + * Copyright (c) 1998, 2015 Todd C. Miller <millert@openbsd.org> + + +====================COPYRIGHT==================== + * Copyright (c) 2000, 2002 Todd C. Miller <millert@openbsd.org> + + +====================COPYRIGHT==================== + * Copyright (c) 2000-2002, 2007, 2010 + * Todd C. Miller <millert@openbsd.org> + + +====================COPYRIGHT==================== + * Copyright (c) 2007 Todd C. Miller <millert@openbsd.org> + + +====================COPYRIGHT==================== + * Copyright (c) 2008 Otto Moerbeek <otto@drijf.net> + + +====================COPYRIGHT==================== + * Copyright (c) 2011 The FreeBSD Foundation + * All rights reserved. + + +====================COPYRIGHT==================== +Copyright (c) 2013, Kenneth MacKay +All rights reserved. + + +====================ISC==================== + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/contrib/libs/libc_compat/include/ifaddrs/ifaddrs.h b/contrib/libs/libc_compat/include/ifaddrs/ifaddrs.h new file mode 100644 index 0000000000..9cd19fec12 --- /dev/null +++ b/contrib/libs/libc_compat/include/ifaddrs/ifaddrs.h @@ -0,0 +1,54 @@ +/* + * Copyright (c) 1995, 1999 + * Berkeley Software Design, Inc. 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. + * + * THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``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 Berkeley Software Design, Inc. BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * BSDI ifaddrs.h,v 2.5 2000/02/23 14:51:59 dab Exp + */ + +#ifndef _IFADDRS_H_ +#define _IFADDRS_H_ + +struct ifaddrs { + struct ifaddrs *ifa_next; + char *ifa_name; + unsigned int ifa_flags; + struct sockaddr *ifa_addr; + struct sockaddr *ifa_netmask; + struct sockaddr *ifa_dstaddr; + void *ifa_data; +}; + +/* + * This may have been defined in <net/if.h>. Note that if <net/if.h> is + * to be included it must be included before this header file. + */ +#ifndef ifa_broadaddr +#define ifa_broadaddr ifa_dstaddr /* broadcast address interface */ +#endif + +#include <sys/cdefs.h> + +__BEGIN_DECLS +extern int getifaddrs(struct ifaddrs **ifap); +extern void freeifaddrs(struct ifaddrs *ifa); +__END_DECLS + +#endif diff --git a/contrib/libs/libc_compat/include/link/link.h b/contrib/libs/libc_compat/include/link/link.h new file mode 100644 index 0000000000..7352c26166 --- /dev/null +++ b/contrib/libs/libc_compat/include/link/link.h @@ -0,0 +1,15 @@ +#pragma once + +#ifdef _MSC_VER + +#ifdef _cplusplus +extern "C" { +#endif + +int link(const char *oldpath, const char *newpath); + +#ifdef _cplusplus +} +#endif + +#endif diff --git a/contrib/libs/libc_compat/include/uchar/uchar.h b/contrib/libs/libc_compat/include/uchar/uchar.h new file mode 100644 index 0000000000..5315bc5f41 --- /dev/null +++ b/contrib/libs/libc_compat/include/uchar/uchar.h @@ -0,0 +1,30 @@ +#ifndef _UCHAR_H +#define _UCHAR_H + +#ifdef __cplusplus +extern "C" { +#endif + +#if __cplusplus < 201103L +typedef unsigned short char16_t; +typedef unsigned char32_t; +#endif + +#include <features.h> + +#define __need_size_t +#include <stddef.h> + +#include <wchar.h> + +size_t c16rtomb(char *__restrict, char16_t, mbstate_t *__restrict); +size_t mbrtoc16(char16_t *__restrict, const char *__restrict, size_t, mbstate_t *__restrict); + +size_t c32rtomb(char *__restrict, char32_t, mbstate_t *__restrict); +size_t mbrtoc32(char32_t *__restrict, const char *__restrict, size_t, mbstate_t *__restrict); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/libs/libc_compat/include/windows/sys/queue.h b/contrib/libs/libc_compat/include/windows/sys/queue.h new file mode 100644 index 0000000000..bc1568be67 --- /dev/null +++ b/contrib/libs/libc_compat/include/windows/sys/queue.h @@ -0,0 +1,631 @@ +/* $OpenBSD: queue.h,v 1.46 2020/12/30 13:33:12 millert Exp $ */ +/* $NetBSD: queue.h,v 1.11 1996/05/16 05:17:14 mycroft Exp $ */ + +/* + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)queue.h 8.5 (Berkeley) 8/20/94 + */ + +#ifndef _SYS_QUEUE_H_ +#define _SYS_QUEUE_H_ + +/* + * This file defines five types of data structures: singly-linked lists, + * lists, simple queues, tail queues and XOR simple queues. + * + * + * A singly-linked list is headed by a single forward pointer. The elements + * are singly linked for minimum space and pointer manipulation overhead at + * the expense of O(n) removal for arbitrary elements. New elements can be + * added to the list after an existing element or at the head of the list. + * Elements being removed from the head of the list should use the explicit + * macro for this purpose for optimum efficiency. A singly-linked list may + * only be traversed in the forward direction. Singly-linked lists are ideal + * for applications with large datasets and few or no removals or for + * implementing a LIFO queue. + * + * A list is headed by a single forward pointer (or an array of forward + * pointers for a hash table header). The elements are doubly linked + * so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before + * or after an existing element or at the head of the list. A list + * may only be traversed in the forward direction. + * + * A simple queue is headed by a pair of pointers, one to the head of the + * list and the other to the tail of the list. The elements are singly + * linked to save space, so elements can only be removed from the + * head of the list. New elements can be added to the list before or after + * an existing element, at the head of the list, or at the end of the + * list. A simple queue may only be traversed in the forward direction. + * + * A tail queue is headed by a pair of pointers, one to the head of the + * list and the other to the tail of the list. The elements are doubly + * linked so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before or + * after an existing element, at the head of the list, or at the end of + * the list. A tail queue may be traversed in either direction. + * + * An XOR simple queue is used in the same way as a regular simple queue. + * The difference is that the head structure also includes a "cookie" that + * is XOR'd with the queue pointer (first, last or next) to generate the + * real pointer value. + * + * For details on the use of these macros, see the queue(3) manual page. + */ + +#if defined(QUEUE_MACRO_DEBUG) || (defined(_KERNEL) && defined(DIAGNOSTIC)) +#define _Q_INVALID ((void *)-1) +#define _Q_INVALIDATE(a) (a) = _Q_INVALID +#else +#define _Q_INVALIDATE(a) +#endif + +/* + * Singly-linked List definitions. + */ +#define SLIST_HEAD(name, type) \ +struct name { \ + struct type *slh_first; /* first element */ \ +} + +#define SLIST_HEAD_INITIALIZER(head) \ + { NULL } + +#define SLIST_ENTRY(type) \ +struct { \ + struct type *sle_next; /* next element */ \ +} + +/* + * Singly-linked List access methods. + */ +#define SLIST_FIRST(head) ((head)->slh_first) +#define SLIST_END(head) NULL +#define SLIST_EMPTY(head) (SLIST_FIRST(head) == SLIST_END(head)) +#define SLIST_NEXT(elm, field) ((elm)->field.sle_next) + +#define SLIST_FOREACH(var, head, field) \ + for((var) = SLIST_FIRST(head); \ + (var) != SLIST_END(head); \ + (var) = SLIST_NEXT(var, field)) + +#define SLIST_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = SLIST_FIRST(head); \ + (var) && ((tvar) = SLIST_NEXT(var, field), 1); \ + (var) = (tvar)) + +/* + * Singly-linked List functions. + */ +#define SLIST_INIT(head) { \ + SLIST_FIRST(head) = SLIST_END(head); \ +} + +#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ + (elm)->field.sle_next = (slistelm)->field.sle_next; \ + (slistelm)->field.sle_next = (elm); \ +} while (0) + +#define SLIST_INSERT_HEAD(head, elm, field) do { \ + (elm)->field.sle_next = (head)->slh_first; \ + (head)->slh_first = (elm); \ +} while (0) + +#define SLIST_REMOVE_AFTER(elm, field) do { \ + (elm)->field.sle_next = (elm)->field.sle_next->field.sle_next; \ +} while (0) + +#define SLIST_REMOVE_HEAD(head, field) do { \ + (head)->slh_first = (head)->slh_first->field.sle_next; \ +} while (0) + +#define SLIST_REMOVE(head, elm, type, field) do { \ + if ((head)->slh_first == (elm)) { \ + SLIST_REMOVE_HEAD((head), field); \ + } else { \ + struct type *curelm = (head)->slh_first; \ + \ + while (curelm->field.sle_next != (elm)) \ + curelm = curelm->field.sle_next; \ + curelm->field.sle_next = \ + curelm->field.sle_next->field.sle_next; \ + } \ + _Q_INVALIDATE((elm)->field.sle_next); \ +} while (0) + +/* + * List definitions. + */ +#define LIST_HEAD(name, type) \ +struct name { \ + struct type *lh_first; /* first element */ \ +} + +#define LIST_HEAD_INITIALIZER(head) \ + { NULL } + +#define LIST_ENTRY(type) \ +struct { \ + struct type *le_next; /* next element */ \ + struct type **le_prev; /* address of previous next element */ \ +} + +/* + * List access methods. + */ +#define LIST_FIRST(head) ((head)->lh_first) +#define LIST_END(head) NULL +#define LIST_EMPTY(head) (LIST_FIRST(head) == LIST_END(head)) +#define LIST_NEXT(elm, field) ((elm)->field.le_next) + +#define LIST_FOREACH(var, head, field) \ + for((var) = LIST_FIRST(head); \ + (var)!= LIST_END(head); \ + (var) = LIST_NEXT(var, field)) + +#define LIST_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = LIST_FIRST(head); \ + (var) && ((tvar) = LIST_NEXT(var, field), 1); \ + (var) = (tvar)) + +/* + * List functions. + */ +#define LIST_INIT(head) do { \ + LIST_FIRST(head) = LIST_END(head); \ +} while (0) + +#define LIST_INSERT_AFTER(listelm, elm, field) do { \ + if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \ + (listelm)->field.le_next->field.le_prev = \ + &(elm)->field.le_next; \ + (listelm)->field.le_next = (elm); \ + (elm)->field.le_prev = &(listelm)->field.le_next; \ +} while (0) + +#define LIST_INSERT_BEFORE(listelm, elm, field) do { \ + (elm)->field.le_prev = (listelm)->field.le_prev; \ + (elm)->field.le_next = (listelm); \ + *(listelm)->field.le_prev = (elm); \ + (listelm)->field.le_prev = &(elm)->field.le_next; \ +} while (0) + +#define LIST_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.le_next = (head)->lh_first) != NULL) \ + (head)->lh_first->field.le_prev = &(elm)->field.le_next;\ + (head)->lh_first = (elm); \ + (elm)->field.le_prev = &(head)->lh_first; \ +} while (0) + +#define LIST_REMOVE(elm, field) do { \ + if ((elm)->field.le_next != NULL) \ + (elm)->field.le_next->field.le_prev = \ + (elm)->field.le_prev; \ + *(elm)->field.le_prev = (elm)->field.le_next; \ + _Q_INVALIDATE((elm)->field.le_prev); \ + _Q_INVALIDATE((elm)->field.le_next); \ +} while (0) + +#define LIST_REPLACE(elm, elm2, field) do { \ + if (((elm2)->field.le_next = (elm)->field.le_next) != NULL) \ + (elm2)->field.le_next->field.le_prev = \ + &(elm2)->field.le_next; \ + (elm2)->field.le_prev = (elm)->field.le_prev; \ + *(elm2)->field.le_prev = (elm2); \ + _Q_INVALIDATE((elm)->field.le_prev); \ + _Q_INVALIDATE((elm)->field.le_next); \ +} while (0) + +/* + * Simple queue definitions. + */ +#define SIMPLEQ_HEAD(name, type) \ +struct name { \ + struct type *sqh_first; /* first element */ \ + struct type **sqh_last; /* addr of last next element */ \ +} + +#define SIMPLEQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).sqh_first } + +#define SIMPLEQ_ENTRY(type) \ +struct { \ + struct type *sqe_next; /* next element */ \ +} + +/* + * Simple queue access methods. + */ +#define SIMPLEQ_FIRST(head) ((head)->sqh_first) +#define SIMPLEQ_END(head) NULL +#define SIMPLEQ_EMPTY(head) (SIMPLEQ_FIRST(head) == SIMPLEQ_END(head)) +#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next) + +#define SIMPLEQ_FOREACH(var, head, field) \ + for((var) = SIMPLEQ_FIRST(head); \ + (var) != SIMPLEQ_END(head); \ + (var) = SIMPLEQ_NEXT(var, field)) + +#define SIMPLEQ_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = SIMPLEQ_FIRST(head); \ + (var) && ((tvar) = SIMPLEQ_NEXT(var, field), 1); \ + (var) = (tvar)) + +/* + * Simple queue functions. + */ +#define SIMPLEQ_INIT(head) do { \ + (head)->sqh_first = NULL; \ + (head)->sqh_last = &(head)->sqh_first; \ +} while (0) + +#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \ + (head)->sqh_last = &(elm)->field.sqe_next; \ + (head)->sqh_first = (elm); \ +} while (0) + +#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \ + (elm)->field.sqe_next = NULL; \ + *(head)->sqh_last = (elm); \ + (head)->sqh_last = &(elm)->field.sqe_next; \ +} while (0) + +#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ + if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\ + (head)->sqh_last = &(elm)->field.sqe_next; \ + (listelm)->field.sqe_next = (elm); \ +} while (0) + +#define SIMPLEQ_REMOVE_HEAD(head, field) do { \ + if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \ + (head)->sqh_last = &(head)->sqh_first; \ +} while (0) + +#define SIMPLEQ_REMOVE_AFTER(head, elm, field) do { \ + if (((elm)->field.sqe_next = (elm)->field.sqe_next->field.sqe_next) \ + == NULL) \ + (head)->sqh_last = &(elm)->field.sqe_next; \ +} while (0) + +#define SIMPLEQ_CONCAT(head1, head2) do { \ + if (!SIMPLEQ_EMPTY((head2))) { \ + *(head1)->sqh_last = (head2)->sqh_first; \ + (head1)->sqh_last = (head2)->sqh_last; \ + SIMPLEQ_INIT((head2)); \ + } \ +} while (0) + +/* + * XOR Simple queue definitions. + */ +#define XSIMPLEQ_HEAD(name, type) \ +struct name { \ + struct type *sqx_first; /* first element */ \ + struct type **sqx_last; /* addr of last next element */ \ + unsigned long sqx_cookie; \ +} + +#define XSIMPLEQ_ENTRY(type) \ +struct { \ + struct type *sqx_next; /* next element */ \ +} + +/* + * XOR Simple queue access methods. + */ +#define XSIMPLEQ_XOR(head, ptr) ((__typeof(ptr))((head)->sqx_cookie ^ \ + (unsigned long)(ptr))) +#define XSIMPLEQ_FIRST(head) XSIMPLEQ_XOR(head, ((head)->sqx_first)) +#define XSIMPLEQ_END(head) NULL +#define XSIMPLEQ_EMPTY(head) (XSIMPLEQ_FIRST(head) == XSIMPLEQ_END(head)) +#define XSIMPLEQ_NEXT(head, elm, field) XSIMPLEQ_XOR(head, ((elm)->field.sqx_next)) + + +#define XSIMPLEQ_FOREACH(var, head, field) \ + for ((var) = XSIMPLEQ_FIRST(head); \ + (var) != XSIMPLEQ_END(head); \ + (var) = XSIMPLEQ_NEXT(head, var, field)) + +#define XSIMPLEQ_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = XSIMPLEQ_FIRST(head); \ + (var) && ((tvar) = XSIMPLEQ_NEXT(head, var, field), 1); \ + (var) = (tvar)) + +/* + * XOR Simple queue functions. + */ +#define XSIMPLEQ_INIT(head) do { \ + arc4random_buf(&(head)->sqx_cookie, sizeof((head)->sqx_cookie)); \ + (head)->sqx_first = XSIMPLEQ_XOR(head, NULL); \ + (head)->sqx_last = XSIMPLEQ_XOR(head, &(head)->sqx_first); \ +} while (0) + +#define XSIMPLEQ_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.sqx_next = (head)->sqx_first) == \ + XSIMPLEQ_XOR(head, NULL)) \ + (head)->sqx_last = XSIMPLEQ_XOR(head, &(elm)->field.sqx_next); \ + (head)->sqx_first = XSIMPLEQ_XOR(head, (elm)); \ +} while (0) + +#define XSIMPLEQ_INSERT_TAIL(head, elm, field) do { \ + (elm)->field.sqx_next = XSIMPLEQ_XOR(head, NULL); \ + *(XSIMPLEQ_XOR(head, (head)->sqx_last)) = XSIMPLEQ_XOR(head, (elm)); \ + (head)->sqx_last = XSIMPLEQ_XOR(head, &(elm)->field.sqx_next); \ +} while (0) + +#define XSIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ + if (((elm)->field.sqx_next = (listelm)->field.sqx_next) == \ + XSIMPLEQ_XOR(head, NULL)) \ + (head)->sqx_last = XSIMPLEQ_XOR(head, &(elm)->field.sqx_next); \ + (listelm)->field.sqx_next = XSIMPLEQ_XOR(head, (elm)); \ +} while (0) + +#define XSIMPLEQ_REMOVE_HEAD(head, field) do { \ + if (((head)->sqx_first = XSIMPLEQ_XOR(head, \ + (head)->sqx_first)->field.sqx_next) == XSIMPLEQ_XOR(head, NULL)) \ + (head)->sqx_last = XSIMPLEQ_XOR(head, &(head)->sqx_first); \ +} while (0) + +#define XSIMPLEQ_REMOVE_AFTER(head, elm, field) do { \ + if (((elm)->field.sqx_next = XSIMPLEQ_XOR(head, \ + (elm)->field.sqx_next)->field.sqx_next) \ + == XSIMPLEQ_XOR(head, NULL)) \ + (head)->sqx_last = \ + XSIMPLEQ_XOR(head, &(elm)->field.sqx_next); \ +} while (0) + + +/* + * Tail queue definitions. + */ +#define TAILQ_HEAD(name, type) \ +struct name { \ + struct type *tqh_first; /* first element */ \ + struct type **tqh_last; /* addr of last next element */ \ +} + +#define TAILQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).tqh_first } + +#define TAILQ_ENTRY(type) \ +struct { \ + struct type *tqe_next; /* next element */ \ + struct type **tqe_prev; /* address of previous next element */ \ +} + +/* + * Tail queue access methods. + */ +#define TAILQ_FIRST(head) ((head)->tqh_first) +#define TAILQ_END(head) NULL +#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) +#define TAILQ_LAST(head, headname) \ + (*(((struct headname *)((head)->tqh_last))->tqh_last)) +/* XXX */ +#define TAILQ_PREV(elm, headname, field) \ + (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) +#define TAILQ_EMPTY(head) \ + (TAILQ_FIRST(head) == TAILQ_END(head)) + +#define TAILQ_FOREACH(var, head, field) \ + for((var) = TAILQ_FIRST(head); \ + (var) != TAILQ_END(head); \ + (var) = TAILQ_NEXT(var, field)) + +#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = TAILQ_FIRST(head); \ + (var) != TAILQ_END(head) && \ + ((tvar) = TAILQ_NEXT(var, field), 1); \ + (var) = (tvar)) + + +#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ + for((var) = TAILQ_LAST(head, headname); \ + (var) != TAILQ_END(head); \ + (var) = TAILQ_PREV(var, headname, field)) + +#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \ + for ((var) = TAILQ_LAST(head, headname); \ + (var) != TAILQ_END(head) && \ + ((tvar) = TAILQ_PREV(var, headname, field), 1); \ + (var) = (tvar)) + +/* + * Tail queue functions. + */ +#define TAILQ_INIT(head) do { \ + (head)->tqh_first = NULL; \ + (head)->tqh_last = &(head)->tqh_first; \ +} while (0) + +#define TAILQ_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \ + (head)->tqh_first->field.tqe_prev = \ + &(elm)->field.tqe_next; \ + else \ + (head)->tqh_last = &(elm)->field.tqe_next; \ + (head)->tqh_first = (elm); \ + (elm)->field.tqe_prev = &(head)->tqh_first; \ +} while (0) + +#define TAILQ_INSERT_TAIL(head, elm, field) do { \ + (elm)->field.tqe_next = NULL; \ + (elm)->field.tqe_prev = (head)->tqh_last; \ + *(head)->tqh_last = (elm); \ + (head)->tqh_last = &(elm)->field.tqe_next; \ +} while (0) + +#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ + if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\ + (elm)->field.tqe_next->field.tqe_prev = \ + &(elm)->field.tqe_next; \ + else \ + (head)->tqh_last = &(elm)->field.tqe_next; \ + (listelm)->field.tqe_next = (elm); \ + (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ +} while (0) + +#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ + (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ + (elm)->field.tqe_next = (listelm); \ + *(listelm)->field.tqe_prev = (elm); \ + (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ +} while (0) + +#define TAILQ_REMOVE(head, elm, field) do { \ + if (((elm)->field.tqe_next) != NULL) \ + (elm)->field.tqe_next->field.tqe_prev = \ + (elm)->field.tqe_prev; \ + else \ + (head)->tqh_last = (elm)->field.tqe_prev; \ + *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ + _Q_INVALIDATE((elm)->field.tqe_prev); \ + _Q_INVALIDATE((elm)->field.tqe_next); \ +} while (0) + +#define TAILQ_REPLACE(head, elm, elm2, field) do { \ + if (((elm2)->field.tqe_next = (elm)->field.tqe_next) != NULL) \ + (elm2)->field.tqe_next->field.tqe_prev = \ + &(elm2)->field.tqe_next; \ + else \ + (head)->tqh_last = &(elm2)->field.tqe_next; \ + (elm2)->field.tqe_prev = (elm)->field.tqe_prev; \ + *(elm2)->field.tqe_prev = (elm2); \ + _Q_INVALIDATE((elm)->field.tqe_prev); \ + _Q_INVALIDATE((elm)->field.tqe_next); \ +} while (0) + +#define TAILQ_CONCAT(head1, head2, field) do { \ + if (!TAILQ_EMPTY(head2)) { \ + *(head1)->tqh_last = (head2)->tqh_first; \ + (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \ + (head1)->tqh_last = (head2)->tqh_last; \ + TAILQ_INIT((head2)); \ + } \ +} while (0) + +/* + * Singly-linked Tail queue declarations. + */ +#define STAILQ_HEAD(name, type) \ +struct name { \ + struct type *stqh_first; /* first element */ \ + struct type **stqh_last; /* addr of last next element */ \ +} + +#define STAILQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).stqh_first } + +#define STAILQ_ENTRY(type) \ +struct { \ + struct type *stqe_next; /* next element */ \ +} + +/* + * Singly-linked Tail queue access methods. + */ +#define STAILQ_FIRST(head) ((head)->stqh_first) +#define STAILQ_END(head) NULL +#define STAILQ_EMPTY(head) (STAILQ_FIRST(head) == STAILQ_END(head)) +#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) + +#define STAILQ_FOREACH(var, head, field) \ + for ((var) = STAILQ_FIRST(head); \ + (var) != STAILQ_END(head); \ + (var) = STAILQ_NEXT(var, field)) + +#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = STAILQ_FIRST(head); \ + (var) && ((tvar) = STAILQ_NEXT(var, field), 1); \ + (var) = (tvar)) + +/* + * Singly-linked Tail queue functions. + */ +#define STAILQ_INIT(head) do { \ + STAILQ_FIRST((head)) = NULL; \ + (head)->stqh_last = &STAILQ_FIRST((head)); \ +} while (0) + +#define STAILQ_INSERT_HEAD(head, elm, field) do { \ + if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \ + (head)->stqh_last = &STAILQ_NEXT((elm), field); \ + STAILQ_FIRST((head)) = (elm); \ +} while (0) + +#define STAILQ_INSERT_TAIL(head, elm, field) do { \ + STAILQ_NEXT((elm), field) = NULL; \ + *(head)->stqh_last = (elm); \ + (head)->stqh_last = &STAILQ_NEXT((elm), field); \ +} while (0) + +#define STAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ + if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((elm), field)) == NULL)\ + (head)->stqh_last = &STAILQ_NEXT((elm), field); \ + STAILQ_NEXT((elm), field) = (elm); \ +} while (0) + +#define STAILQ_REMOVE_HEAD(head, field) do { \ + if ((STAILQ_FIRST((head)) = \ + STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \ + (head)->stqh_last = &STAILQ_FIRST((head)); \ +} while (0) + +#define STAILQ_REMOVE_AFTER(head, elm, field) do { \ + if ((STAILQ_NEXT(elm, field) = \ + STAILQ_NEXT(STAILQ_NEXT(elm, field), field)) == NULL) \ + (head)->stqh_last = &STAILQ_NEXT((elm), field); \ +} while (0) + +#define STAILQ_REMOVE(head, elm, type, field) do { \ + if (STAILQ_FIRST((head)) == (elm)) { \ + STAILQ_REMOVE_HEAD((head), field); \ + } else { \ + struct type *curelm = (head)->stqh_first; \ + while (STAILQ_NEXT(curelm, field) != (elm)) \ + curelm = STAILQ_NEXT(curelm, field); \ + STAILQ_REMOVE_AFTER(head, curelm, field); \ + } \ +} while (0) + +#define STAILQ_CONCAT(head1, head2) do { \ + if (!STAILQ_EMPTY((head2))) { \ + *(head1)->stqh_last = (head2)->stqh_first; \ + (head1)->stqh_last = (head2)->stqh_last; \ + STAILQ_INIT((head2)); \ + } \ +} while (0) + +#define STAILQ_LAST(head, type, field) \ + (STAILQ_EMPTY((head)) ? NULL : \ + ((struct type *)(void *) \ + ((char *)((head)->stqh_last) - offsetof(struct type, field)))) + +#endif /* !_SYS_QUEUE_H_ */ diff --git a/contrib/libs/libc_compat/include/windows/sys/uio.h b/contrib/libs/libc_compat/include/windows/sys/uio.h new file mode 100644 index 0000000000..47cc77784a --- /dev/null +++ b/contrib/libs/libc_compat/include/windows/sys/uio.h @@ -0,0 +1,25 @@ +#pragma once + +#include <stddef.h> +#include <BaseTsd.h> +#include <WinSock2.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#define IOV_MAX INT_MAX + +typedef SSIZE_T ssize_t; + +struct iovec { + char* iov_base; + size_t iov_len; +}; + +ssize_t readv(SOCKET sock, struct iovec const* iov, int nvecs); +ssize_t writev(SOCKET sock, struct iovec const* iov, int nvecs); + +#ifdef __cplusplus +} +#endif diff --git a/contrib/libs/libc_compat/patches/getrandom.patch b/contrib/libs/libc_compat/patches/getrandom.patch new file mode 100644 index 0000000000..ba0f2b7220 --- /dev/null +++ b/contrib/libs/libc_compat/patches/getrandom.patch @@ -0,0 +1,24 @@ +--- a/include/random/sys/random.h (index) ++++ b/include/random/sys/random.h (working tree) +@@ -4,9 +4,9 @@ + extern "C" { + #endif + +-#define __NEED_size_t +-#define __NEED_ssize_t +-#include <bits/alltypes.h> ++#include <sys/types.h> ++ ++#define SYS_getrandom 318 + + #define GRND_NONBLOCK 0x0001 + #define GRND_RANDOM 0x0002 +--- a/getrandom.c (index) ++++ b/getrandom.c (working tree) +@@ -3,5 +3,5 @@ + + ssize_t getrandom(void *buf, size_t buflen, unsigned flags) + { +- return syscall_cp(SYS_getrandom, buf, buflen, flags); ++ return syscall(SYS_getrandom, buf, buflen, flags); + } diff --git a/contrib/libs/libc_compat/patches/glob.patch b/contrib/libs/libc_compat/patches/glob.patch new file mode 100644 index 0000000000..4228fb7e20 --- /dev/null +++ b/contrib/libs/libc_compat/patches/glob.patch @@ -0,0 +1,112 @@ +--- a/glob.c (index) ++++ b/glob.c (working tree) +@@ -82,17 +82,19 @@ __FBSDID("$FreeBSD$"); + #include <ctype.h> + #include <dirent.h> + #include <errno.h> +-#include <glob.h> ++#include "glob.h" + #include <limits.h> + #include <pwd.h> + #include <stdint.h> + #include <stdio.h> +-#include <stdlib.h> ++#include "stdlib.h" + #include <string.h> +-#include <unistd.h> ++#include "unistd.h" + #include <wchar.h> + ++#ifdef USE_LOCALE_COLLATE + #include "collate.h" ++#endif + + /* + * glob(3) expansion limits. Stop the expansion if any of these limits +@@ -911,8 +913,10 @@ match(Char *name, Char *pat, Char *patend) + { + int ok, negate_range; + Char c, k, *nextp, *nextn; ++#ifdef USE_LOCALE_COLLATE + struct xlocale_collate *table = + (struct xlocale_collate*)__get_locale()->components[XLC_COLLATE]; ++#endif + + nextn = NULL; + nextp = NULL; +@@ -942,6 +946,7 @@ match(Char *name, Char *pat, Char *patend) + ++pat; + while (((c = *pat++) & M_MASK) != M_END) + if ((*pat & M_MASK) == M_RNG) { ++#ifdef USE_LOCALE_COLLATE + if (table->__collate_load_error ? + CHAR(c) <= CHAR(k) && + CHAR(k) <= CHAR(pat[1]) : +@@ -949,6 +954,9 @@ match(Char *name, Char *pat, Char *patend) + CHAR(k)) <= 0 && + __wcollate_range_cmp(CHAR(k), + CHAR(pat[1])) <= 0) ++#else ++ if (c <= k && k <= pat[1]) ++#endif + ok = 1; + pat += 2; + } else if (c == k) +--- a/stdlib.h (index) ++++ b/stdlib.h (working tree) +@@ -0,0 +1,3 @@ ++#include <stdlib.h> ++ ++void* reallocarray(void*, size_t, size_t); +--- a/unistd.h (index) ++++ b/unistd.h (working tree) +@@ -0,0 +1,3 @@ ++#include <unistd.h> ++ ++#define issetugid() 0 +--- a/glob.h (index) ++++ b/glob.h (working tree) +@@ -39,12 +39,8 @@ + #define _GLOB_H_ + + #include <sys/cdefs.h> +-#include <sys/_types.h> ++#include <sys/types.h> + +-#ifndef _SIZE_T_DECLARED +-typedef __size_t size_t; +-#define _SIZE_T_DECLARED +-#endif + + struct stat; + typedef struct { +@@ -68,7 +64,7 @@ typedef struct { + int (*gl_stat)(const char *, struct stat *); + } glob_t; + +-#if __POSIX_VISIBLE >= 199209 ++// #if __POSIX_VISIBLE >= 199209 + /* Believed to have been introduced in 1003.2-1992 */ + #define GLOB_APPEND 0x0001 /* Append to output from previous call. */ + #define GLOB_DOOFFS 0x0002 /* Use gl_offs. */ +@@ -83,9 +79,9 @@ typedef struct { + #define GLOB_ABORTED (-2) /* Unignored error. */ + #define GLOB_NOMATCH (-3) /* No match and GLOB_NOCHECK was not set. */ + #define GLOB_NOSYS (-4) /* Obsolete: source comptability only. */ +-#endif /* __POSIX_VISIBLE >= 199209 */ ++// #endif /* __POSIX_VISIBLE >= 199209 */ + +-#if __BSD_VISIBLE ++// #if __BSD_VISIBLE + #define GLOB_ALTDIRFUNC 0x0040 /* Use alternately specified directory funcs. */ + #define GLOB_BRACE 0x0080 /* Expand braces ala csh. */ + #define GLOB_MAGCHAR 0x0100 /* Pattern had globbing characters. */ +@@ -97,7 +93,7 @@ typedef struct { + /* source compatibility, these are the old names */ + #define GLOB_MAXPATH GLOB_LIMIT + #define GLOB_ABEND GLOB_ABORTED +-#endif /* __BSD_VISIBLE */ ++// #endif /* __BSD_VISIBLE */ + + __BEGIN_DECLS + int glob(const char * __restrict, int, diff --git a/contrib/libs/libc_compat/patches/memfd_create.patch b/contrib/libs/libc_compat/patches/memfd_create.patch new file mode 100644 index 0000000000..6bd11eee09 --- /dev/null +++ b/contrib/libs/libc_compat/patches/memfd_create.patch @@ -0,0 +1,13 @@ +--- a/memfd_create.c (index) ++++ b/memfd_create.c (working tree) +@@ -1,8 +1,9 @@ + #define _GNU_SOURCE 1 + #include <sys/mman.h> + #include "syscall.h" ++#include <linux/unistd.h> + + int memfd_create(const char *name, unsigned flags) + { +- return syscall(SYS_memfd_create, name, flags); ++ return syscall(__NR_memfd_create, name, flags); + } diff --git a/contrib/libs/libc_compat/patches/readpassphrase.patch b/contrib/libs/libc_compat/patches/readpassphrase.patch new file mode 100644 index 0000000000..876b7306b3 --- /dev/null +++ b/contrib/libs/libc_compat/patches/readpassphrase.patch @@ -0,0 +1,43 @@ +--- a/readpassphrase.c (index) ++++ b/readpassphrase.c (working tree) +@@ -32,6 +32,16 @@ + #include <unistd.h> + #include <readpassphrase.h> + ++#ifndef TCSASOFT ++/* If we don't have TCSASOFT define it so that ORing it it below is a no-op. */ ++# define TCSASOFT 0 ++#endif ++ ++/* SunOS 4.x which lacks _POSIX_VDISABLE, but has VDISABLE */ ++#if !defined(_POSIX_VDISABLE) && defined(VDISABLE) ++# define _POSIX_VDISABLE VDISABLE ++#endif ++ + static volatile sig_atomic_t signo[_NSIG]; + + static void handler(int); +@@ -91,8 +91,6 @@ restart: + memcpy(&term, &oterm, sizeof(term)); + if (!(flags & RPP_ECHO_ON)) + term.c_lflag &= ~(ECHO | ECHONL); +- if (term.c_cc[VSTATUS] != _POSIX_VDISABLE) +- term.c_cc[VSTATUS] = _POSIX_VDISABLE; + (void)tcsetattr(input, TCSAFLUSH|TCSASOFT, &term); + } else { + memset(&term, 0, sizeof(term)); +@@ -177,14 +187,6 @@ restart: + } + + +-char * +-getpass(const char *prompt) +-{ +- static char buf[_PASSWORD_LEN + 1]; +- +- return(readpassphrase(prompt, buf, sizeof(buf), RPP_ECHO_OFF)); +-} +- + static void handler(int s) + { + diff --git a/contrib/libs/libc_compat/patches/sys-queue.patch b/contrib/libs/libc_compat/patches/sys-queue.patch new file mode 100644 index 0000000000..652dc18b29 --- /dev/null +++ b/contrib/libs/libc_compat/patches/sys-queue.patch @@ -0,0 +1,11 @@ +--- a/include/windows/sys/queue.h (index) ++++ b/include/windows/sys/queue.h (working tree) +@@ -35,8 +35,6 @@ + #ifndef _SYS_QUEUE_H_ + #define _SYS_QUEUE_H_ + +-#include <sys/_null.h> +- + /* + * This file defines five types of data structures: singly-linked lists, + * lists, simple queues, tail queues and XOR simple queues. diff --git a/contrib/libs/libc_compat/patches/uchar.patch b/contrib/libs/libc_compat/patches/uchar.patch new file mode 100644 index 0000000000..0341e3cc1f --- /dev/null +++ b/contrib/libs/libc_compat/patches/uchar.patch @@ -0,0 +1,19 @@ +--- a/include/uchar/uchar.h (index) ++++ b/include/uchar/uchar.h (working tree) +@@ -10,11 +10,12 @@ typedef unsigned short char16_t; + typedef unsigned char32_t; + #endif + +-#define __NEED_mbstate_t +-#define __NEED_size_t +- + #include <features.h> +-#include <bits/alltypes.h> ++ ++#define __need_size_t ++#include <stddef.h> ++ ++#include <wchar.h> + + size_t c16rtomb(char *__restrict, char16_t, mbstate_t *__restrict); + size_t mbrtoc16(char16_t *__restrict, const char *__restrict, size_t, mbstate_t *__restrict); diff --git a/contrib/libs/libc_compat/src/windows/sys/uio.c b/contrib/libs/libc_compat/src/windows/sys/uio.c new file mode 100644 index 0000000000..50c9542dc1 --- /dev/null +++ b/contrib/libs/libc_compat/src/windows/sys/uio.c @@ -0,0 +1,36 @@ +#include <contrib/libs/libc_compat/include/windows/sys/uio.h> + +#include <Windows.h> +#include <winsock2.h> +#include <malloc.h> + +ssize_t readv(SOCKET sock, struct iovec const* iov, int iovcnt) { + WSABUF* wsabuf = (WSABUF*)alloca(iovcnt * sizeof(WSABUF)); + for (int i = 0; i < iovcnt; ++i) { + wsabuf[i].buf = iov[i].iov_base; + wsabuf[i].len = (u_long)iov[i].iov_len; + } + DWORD numberOfBytesRecv; + DWORD flags = 0; + int res = WSARecv(sock, wsabuf, iovcnt, &numberOfBytesRecv, &flags, NULL, NULL); + if (res == SOCKET_ERROR) { + errno = EIO; + return -1; + } + return numberOfBytesRecv; +} + +ssize_t writev(SOCKET sock, struct iovec const* iov, int iovcnt) { + WSABUF* wsabuf = (WSABUF*)alloca(iovcnt * sizeof(WSABUF)); + for (int i = 0; i < iovcnt; ++i) { + wsabuf[i].buf = iov[i].iov_base; + wsabuf[i].len = (u_long)iov[i].iov_len; + } + DWORD numberOfBytesSent; + int res = WSASend(sock, wsabuf, iovcnt, &numberOfBytesSent, 0, NULL, NULL); + if (res == SOCKET_ERROR) { + errno = EIO; + return -1; + } + return numberOfBytesSent; +} |