mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-07 00:29:15 +00:00
LibCore: Fix SocketAddress.h compilation errors on Windows
This commit is contained in:
parent
9b8120d8e8
commit
eb650798d0
Notes:
github-actions[bot]
2025-02-05 23:09:13 +00:00
Author: https://github.com/stasoid
Commit: eb650798d0
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2673
Reviewed-by: https://github.com/ADKaster ✅
Reviewed-by: https://github.com/gmta
Reviewed-by: https://github.com/konradekk
2 changed files with 91 additions and 5 deletions
|
@ -9,11 +9,15 @@
|
||||||
|
|
||||||
#include <AK/IPv4Address.h>
|
#include <AK/IPv4Address.h>
|
||||||
#include <AK/IPv6Address.h>
|
#include <AK/IPv6Address.h>
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <netinet/in.h>
|
#ifndef AK_OS_WINDOWS
|
||||||
#include <string.h>
|
# include <arpa/inet.h>
|
||||||
#include <sys/socket.h>
|
# include <netinet/in.h>
|
||||||
#include <sys/un.h>
|
# include <sys/socket.h>
|
||||||
|
# include <sys/un.h>
|
||||||
|
#else
|
||||||
|
# include "SocketAddressWindows.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
|
|
82
Libraries/LibCore/SocketAddressWindows.h
Normal file
82
Libraries/LibCore/SocketAddressWindows.h
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2025, stasoid <stasoid@yahoo.com>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
// This header is needed because winsock2.h and windows.h are banned from including from headers and SocketAddress.h needs some struct definitions from those headers.
|
||||||
|
// These definitions were copied from Windows SDK headers. Comments, #ifdefs and special annotations like _Field_size_bytes_ were removed. This is fair use, see Oracle v. Google.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
typedef unsigned long ULONG;
|
||||||
|
typedef unsigned short USHORT;
|
||||||
|
typedef char CHAR;
|
||||||
|
typedef unsigned char UCHAR;
|
||||||
|
typedef USHORT ADDRESS_FAMILY;
|
||||||
|
|
||||||
|
#define WINAPI_FAMILY_PARTITION(x) 1
|
||||||
|
#define FAR
|
||||||
|
#include <inaddr.h>
|
||||||
|
#undef WINAPI_FAMILY_PARTITION
|
||||||
|
#undef FAR
|
||||||
|
|
||||||
|
#include <afunix.h>
|
||||||
|
|
||||||
|
#define AF_UNSPEC 0
|
||||||
|
#define AF_LOCAL 1 // AF_UNIX
|
||||||
|
#define AF_INET 2
|
||||||
|
#define AF_INET6 23
|
||||||
|
|
||||||
|
struct in6_addr {
|
||||||
|
union {
|
||||||
|
UCHAR Byte[16];
|
||||||
|
USHORT Word[8];
|
||||||
|
} u;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SCOPE_ID {
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
ULONG Zone : 28;
|
||||||
|
ULONG Level : 4;
|
||||||
|
} u;
|
||||||
|
ULONG Value;
|
||||||
|
} u;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct sockaddr_in6 {
|
||||||
|
ADDRESS_FAMILY sin6_family;
|
||||||
|
USHORT sin6_port;
|
||||||
|
ULONG sin6_flowinfo;
|
||||||
|
in6_addr sin6_addr;
|
||||||
|
union {
|
||||||
|
ULONG sin6_scope_id;
|
||||||
|
SCOPE_ID sin6_scope_struct;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
struct sockaddr_in {
|
||||||
|
ADDRESS_FAMILY sin_family;
|
||||||
|
USHORT sin_port;
|
||||||
|
IN_ADDR sin_addr;
|
||||||
|
CHAR sin_zero[8];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct sockaddr {
|
||||||
|
ADDRESS_FAMILY sa_family;
|
||||||
|
CHAR sa_data[14];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct addrinfo {
|
||||||
|
int ai_flags;
|
||||||
|
int ai_family;
|
||||||
|
int ai_socktype;
|
||||||
|
int ai_protocol;
|
||||||
|
size_t ai_addrlen;
|
||||||
|
char* ai_canonname;
|
||||||
|
sockaddr* ai_addr;
|
||||||
|
addrinfo* ai_next;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern "C" USHORT __stdcall htons(USHORT hostshort);
|
Loading…
Add table
Add a link
Reference in a new issue