From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 927FAA051C; Sat, 20 Jun 2020 23:06:01 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4D6451BFE9; Sat, 20 Jun 2020 23:05:28 +0200 (CEST) Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) by dpdk.org (Postfix) with ESMTP id 224021BFC1 for ; Sat, 20 Jun 2020 23:05:24 +0200 (CEST) Received: by mail-lj1-f194.google.com with SMTP id x18so15253072lji.1 for ; Sat, 20 Jun 2020 14:05:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gTLG786xFivQ5GmDWx/v/yz2lXwdNb6DlgX07r/LV1E=; b=K273KsdwfKr4h8+akFX0s5nL4Vhz5b05DbinlXV73zcPTCnmbjR3JsmPlJzpQr46WE 20tqdjvgRmBTUDvO8ElqasXDgxld/xau86Td7yJfhBbG0BoQCgPQTjtTVtXSCyF4KruP 7IkPn56LMU+ToFocTDyVypVLugzOIOvg+3i8xw048ycsUZzT6lX1KtTTnZy9uZyXG4jj l841ndqjIcARq0Bl3lspr5RMOuzw/D3N3J8D/8+Rw8iMx+SmK2wGZ0AZcF5fT7z8AE3a X3lBqA0s30ASLjqgDkGHi0JT0mJuHl1fo3g6vCSgfeEDWZAWrgBYktWNkoAjFBJShShQ G7IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gTLG786xFivQ5GmDWx/v/yz2lXwdNb6DlgX07r/LV1E=; b=paqOZiR3K+d+0aTnqVBCHwqspOzQ6yT5ChTprTLu8AhnEDxY0+R52yAKFX73SDo7na ZnDOd00TDNYOSsH6l0cFEAMl+pRXzliMcRpII1HEZcB+/kA+LIO2s5jvL8A9VPgmhT/S wD2wq1At5DOowqnm5ow0zsoty4ty+yWympaYAvpTPpe/EaASukmIXSB8vCKkVQ/w9QZ3 2uY+/R+ziSkHTw05AybJjA6FzzZpEHkPzQJpR4WHkxfaktwaa7p2e4ZTrCkkE37xMSkB tSwZ6nDfMu8S9RxOPbkwWE3OE8l8TNU5OEUhhyMW6vmC+CZ5YY2Cg5xZbBKFNegF3yI8 RcAQ== X-Gm-Message-State: AOAM5326AxeHrAiKwhsKS42bSjQ+CiyeO9c3Xa6IxAs48J7u5387NxfJ fZ1kiB/+k9TdEIQW9KwDf+ghKY2fm8UCdA== X-Google-Smtp-Source: ABdhPJzUyfjDS5P9Ac80b3I7jyI/9fIfF99PGhtUy+muRq2lrIPFVZ8CjIzGi6KxY/3mS9Am49rEnw== X-Received: by 2002:a2e:8e85:: with SMTP id z5mr4659302ljk.330.1592687123442; Sat, 20 Jun 2020 14:05:23 -0700 (PDT) Received: from localhost.localdomain (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.gmail.com with ESMTPSA id d8sm2653359lfk.27.2020.06.20.14.05.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jun 2020 14:05:22 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Malloy , Narcisa Ana Maria Vasile , Fady Bader , Tal Shnaiderman , Dmitry Kozlyuk , Harini Ramakrishnan , Omar Cardona , Pallavi Kadam , Ranjit Menon Date: Sun, 21 Jun 2020 00:05:08 +0300 Message-Id: <20200620210511.13134-6-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200620210511.13134-1-dmitry.kozliuk@gmail.com> References: <20200620210511.13134-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 5/7] eal/windows: improve compatibility networking headers X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Extend compatibility header system to support librte_cmdline. pthread.h has to include windows.h, which exposes struct in_addr, etc. conflicting with compatibility headers. WIN32_LEAN_AND_MEAN macro is required to disable this behavior. Use rte_windows.h to define WIN32_LEAN_AND_MEAN for pthread library. Signed-off-by: Dmitry Kozlyuk --- Assumming __attribute__((stdcall)) is rare enough so that the following checkpatch complaint can be ignored: Warning in /lib/librte_eal/windows/include/arpa/inet.h: Using compiler attribute directly lib/librte_eal/windows/include/arpa/inet.h | 30 +++++++++++++++++++++ lib/librte_eal/windows/include/netinet/in.h | 11 ++++++++ lib/librte_eal/windows/include/pthread.h | 2 +- lib/librte_eal/windows/include/sys/socket.h | 24 +++++++++++++++++ 4 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 lib/librte_eal/windows/include/arpa/inet.h create mode 100644 lib/librte_eal/windows/include/sys/socket.h diff --git a/lib/librte_eal/windows/include/arpa/inet.h b/lib/librte_eal/windows/include/arpa/inet.h new file mode 100644 index 000000000..96b698438 --- /dev/null +++ b/lib/librte_eal/windows/include/arpa/inet.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2020 Dmitry Kozlyuk + */ + +#ifndef _ARPA_INET_H_ +#define _ARPA_INET_H_ + +/** + * @file + * + * Compatibility header + * + * Although symbols declared here are present on Windows, + * including would expose too much macros breaking common code. + */ + +#include +#include + +/* defined in ws2_32.dll */ +__attribute__((stdcall)) +int +inet_pton(int af, const char *src, void *dst); + +/* defined in ws2_32.dll */ +__attribute__((stdcall)) +const char * +inet_ntop(int af, const void *src, char *dst, socklen_t size); + +#endif /* _ARPA_INET_H_ */ diff --git a/lib/librte_eal/windows/include/netinet/in.h b/lib/librte_eal/windows/include/netinet/in.h index 489b587c3..ed46163b5 100644 --- a/lib/librte_eal/windows/include/netinet/in.h +++ b/lib/librte_eal/windows/include/netinet/in.h @@ -5,6 +5,8 @@ #ifndef _IN_H_ #define _IN_H_ +#include + #define IPPROTO_IP 0 #define IPPROTO_HOPOPTS 0 #define IPPROTO_IPV4 4 /* IPv4 encapsulation */ @@ -21,5 +23,14 @@ #define IPPROTO_DSTOPTS 60 /* IP6 destination option */ #define IPPROTO_SCTP 132 /* Stream Control Transmission Protocol */ +#define INET6_ADDRSTRLEN 46 + +struct in_addr { + uint32_t s_addr; +}; + +struct in6_addr { + uint8_t s6_addr[16]; +}; #endif diff --git a/lib/librte_eal/windows/include/pthread.h b/lib/librte_eal/windows/include/pthread.h index e2274cf4e..b4dbee9d8 100644 --- a/lib/librte_eal/windows/include/pthread.h +++ b/lib/librte_eal/windows/include/pthread.h @@ -16,8 +16,8 @@ extern "C" { #endif -#include #include +#include #define PTHREAD_BARRIER_SERIAL_THREAD TRUE diff --git a/lib/librte_eal/windows/include/sys/socket.h b/lib/librte_eal/windows/include/sys/socket.h new file mode 100644 index 000000000..9536cf8e6 --- /dev/null +++ b/lib/librte_eal/windows/include/sys/socket.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2020 Dmitry Kozlyuk + */ + +#ifndef _SYS_SOCKET_H_ +#define _SYS_SOCKET_H_ + +/** + * @file + * + * Compatibility header + * + * Although symbols declared here are present on Windows, + * including would expose too much macros breaking common code. + */ + +#include + +#define AF_INET 2 +#define AF_INET6 23 + +typedef size_t socklen_t; + +#endif /* _SYS_SOCKET_H_ */ -- 2.25.4