Skip to content

Commit fbb557c

Browse files
add msg tests, also add proxy headers
1 parent ade86ec commit fbb557c

25 files changed

+371
-30
lines changed

libc/hdr/types/CMakeLists.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,30 @@ add_proxy_header_library(
199199
libc.include.setjmp
200200
)
201201

202+
203+
add_proxy_header_library(
204+
struct_msghdr
205+
HDRS
206+
struct_msghdr.h
207+
FULL_BUILD_DEPENDS
208+
libc.include.llvm-libc-types.struct_msghdr
209+
libc.include.sys_socket
210+
)
211+
212+
add_proxy_header_library(
213+
struct_sockaddr
214+
HDRS
215+
struct_sockaddr.h
216+
FULL_BUILD_DEPENDS
217+
libc.include.llvm-libc-types.struct_sockaddr
218+
libc.include.sys_socket
219+
)
220+
221+
add_proxy_header_library(
222+
socklen_t
223+
HDRS
224+
socklen_t.h
225+
FULL_BUILD_DEPENDS
226+
libc.include.llvm-libc-types.socklen_t
227+
libc.include.sys_socket
228+
)

libc/hdr/types/socklen_t.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//===-- Proxy for socklen_t -----------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
#ifndef LLVM_LIBC_HDR_TYPES_SOCKLEN_T_H
9+
#define LLVM_LIBC_HDR_TYPES_SOCKLEN_T_H
10+
11+
#ifdef LIBC_FULL_BUILD
12+
13+
#include "include/llvm-libc-types/socklen_t.h"
14+
15+
#else
16+
17+
#include <signal.h>
18+
19+
#endif // LIBC_FULL_BUILD
20+
21+
#endif // LLVM_LIBC_HDR_TYPES_SOCKLEN_T_H

libc/hdr/types/ssize_t.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//===-- Proxy for ssize_t -------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
#ifndef LLVM_LIBC_HDR_TYPES_SSIZE_T_H
9+
#define LLVM_LIBC_HDR_TYPES_SSIZE_T_H
10+
11+
#ifdef LIBC_FULL_BUILD
12+
13+
#include "include/llvm-libc-types/ssize_t.h"
14+
15+
#else
16+
17+
#define __need_ssize_t
18+
#include <stddef.h>
19+
#undef __need_ssize_t
20+
21+
#endif // LIBC_FULL_BUILD
22+
23+
#endif // LLVM_LIBC_HDR_TYPES_SSIZE_T_H

libc/hdr/types/struct_msghdr.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//===-- Proxy for struct msghdr ------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
#ifndef LLVM_LIBC_HDR_TYPES_STRUCT_MSGHDR_H
9+
#define LLVM_LIBC_HDR_TYPES_STRUCT_MSGHDR_H
10+
11+
#ifdef LIBC_FULL_BUILD
12+
13+
#include "include/llvm-libc-types/struct_msghdr.h"
14+
15+
#else
16+
17+
#include <sys/socket.h>
18+
19+
#endif // LIBC_FULL_BUILD
20+
21+
#endif // LLVM_LIBC_HDR_TYPES_STRUCT_MSGHDR_H

libc/hdr/types/struct_sockaddr.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//===-- Proxy for struct sockaddr ----------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
#ifndef LLVM_LIBC_HDR_TYPES_STRUCT_SOCKADDR_H
9+
#define LLVM_LIBC_HDR_TYPES_STRUCT_SOCKADDR_H
10+
11+
#ifdef LIBC_FULL_BUILD
12+
13+
#include "include/llvm-libc-types/struct_sockaddr.h"
14+
15+
#else
16+
17+
#include <sys/socket.h>
18+
19+
#endif // LIBC_FULL_BUILD
20+
21+
#endif // LLVM_LIBC_HDR_TYPES_STRUCT_SOCKADDR_H

libc/include/llvm-libc-types/struct_iovec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef __LLVM_LIBC_TYPES_STRUCT_IOVEC_H__
1010
#define __LLVM_LIBC_TYPES_STRUCT_IOVEC_H__
1111

12-
#include <llvm-libc-types/size_t.h>
12+
#include "llvm-libc-types/size_t.h"
1313

1414
struct iovec {
1515
void *iov_base;

libc/include/llvm-libc-types/struct_msghdr.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
#ifndef __LLVM_LIBC_TYPES_STRUCT_MSGHDR_H__
1010
#define __LLVM_LIBC_TYPES_STRUCT_MSGHDR_H__
1111

12-
#include <llvm-libc-types/size_t.h>
13-
#include <llvm-libc-types/socklen_t.h>
14-
#include <llvm-libc-types/struct_iovec.h>
12+
#include "llvm-libc-types/size_t.h"
13+
#include "llvm-libc-types/socklen_t.h"
14+
#include "llvm-libc-types/struct_iovec.h"
1515

1616
struct msghdr {
1717
void *msg_name; /* Optional address */

libc/src/sys/socket/accept.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
#ifndef LLVM_LIBC_SRC_SYS_SOCKET_ACCEPT_H
1010
#define LLVM_LIBC_SRC_SYS_SOCKET_ACCEPT_H
1111

12+
#include "hdr/types/socklen_t.h"
13+
#include "hdr/types/struct_sockaddr.h"
1214
#include "src/__support/macros/config.h"
13-
#include <sys/socket.h>
1415

1516
namespace LIBC_NAMESPACE_DECL {
1617

libc/src/sys/socket/bind.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
#ifndef LLVM_LIBC_SRC_SYS_SOCKET_BIND_H
1010
#define LLVM_LIBC_SRC_SYS_SOCKET_BIND_H
1111

12+
#include "hdr/types/socklen_t.h"
13+
#include "hdr/types/struct_sockaddr.h"
1214
#include "src/__support/macros/config.h"
13-
#include <sys/socket.h>
1415

1516
namespace LIBC_NAMESPACE_DECL {
1617

libc/src/sys/socket/connect.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
#ifndef LLVM_LIBC_SRC_SYS_SOCKET_CONNECT_H
1010
#define LLVM_LIBC_SRC_SYS_SOCKET_CONNECT_H
1111

12+
#include "hdr/types/socklen_t.h"
13+
#include "hdr/types/struct_sockaddr.h"
1214
#include "src/__support/macros/config.h"
13-
#include <sys/socket.h>
1415

1516
namespace LIBC_NAMESPACE_DECL {
1617

libc/src/sys/socket/linux/CMakeLists.txt

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ add_entrypoint_object(
1919
../bind.h
2020
DEPENDS
2121
libc.include.sys_syscall
22-
libc.include.sys_socket
22+
libc.hdr.types.struct_sockaddr
23+
libc.hdr.types.socklen_t
2324
libc.src.__support.OSUtil.osutil
2425
libc.src.errno.errno
2526
)
@@ -32,7 +33,8 @@ add_entrypoint_object(
3233
../send.h
3334
DEPENDS
3435
libc.include.sys_syscall
35-
libc.include.sys_socket
36+
libc.hdr.types.struct_sockaddr
37+
libc.hdr.types.socklen_t
3638
libc.src.__support.OSUtil.osutil
3739
libc.src.errno.errno
3840
)
@@ -45,7 +47,8 @@ add_entrypoint_object(
4547
../sendto.h
4648
DEPENDS
4749
libc.include.sys_syscall
48-
libc.include.sys_socket
50+
libc.hdr.types.struct_sockaddr
51+
libc.hdr.types.socklen_t
4952
libc.src.__support.OSUtil.osutil
5053
libc.src.errno.errno
5154
)
@@ -58,7 +61,7 @@ add_entrypoint_object(
5861
../sendmsg.h
5962
DEPENDS
6063
libc.include.sys_syscall
61-
libc.include.sys_socket
64+
libc.hdr.types.struct_msghdr
6265
libc.src.__support.OSUtil.osutil
6366
libc.src.errno.errno
6467
)
@@ -71,7 +74,8 @@ add_entrypoint_object(
7174
../connect.h
7275
DEPENDS
7376
libc.include.sys_syscall
74-
libc.include.sys_socket
77+
libc.hdr.types.struct_sockaddr
78+
libc.hdr.types.socklen_t
7579
libc.src.__support.OSUtil.osutil
7680
libc.src.errno.errno
7781
)
@@ -84,7 +88,8 @@ add_entrypoint_object(
8488
../recv.h
8589
DEPENDS
8690
libc.include.sys_syscall
87-
libc.include.sys_socket
91+
libc.hdr.types.struct_sockaddr
92+
libc.hdr.types.socklen_t
8893
libc.src.__support.OSUtil.osutil
8994
libc.src.errno.errno
9095
)
@@ -97,7 +102,8 @@ add_entrypoint_object(
97102
../recvfrom.h
98103
DEPENDS
99104
libc.include.sys_syscall
100-
libc.include.sys_socket
105+
libc.hdr.types.struct_sockaddr
106+
libc.hdr.types.socklen_t
101107
libc.src.__support.OSUtil.osutil
102108
libc.src.errno.errno
103109
)
@@ -110,7 +116,7 @@ add_entrypoint_object(
110116
../recvmsg.h
111117
DEPENDS
112118
libc.include.sys_syscall
113-
libc.include.sys_socket
119+
libc.hdr.types.struct_msghdr
114120
libc.src.__support.OSUtil.osutil
115121
libc.src.errno.errno
116122
)
@@ -123,7 +129,8 @@ add_entrypoint_object(
123129
../accept.h
124130
DEPENDS
125131
libc.include.sys_syscall
126-
libc.include.sys_socket
132+
libc.hdr.types.struct_sockaddr
133+
libc.hdr.types.socklen_t
127134
libc.src.__support.OSUtil.osutil
128135
libc.src.errno.errno
129136
)

libc/src/sys/socket/linux/connect.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99

1010
#include "src/sys/socket/connect.h"
1111

12+
#include "hdr/types/socklen_t.h"
13+
#include "hdr/types/struct_sockaddr.h"
1214
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
1315
#include "src/__support/common.h"
1416
#include "src/errno/libc_errno.h"
1517
#include <linux/net.h> // For SYS_SOCKET socketcall number.
16-
#include <sys/socket.h> // For the types
1718
#include <sys/syscall.h> // For syscall numbers.
1819

1920
namespace LIBC_NAMESPACE_DECL {

libc/src/sys/socket/linux/recv.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88

99
#include "src/sys/socket/recv.h"
1010

11+
#include "hdr/types/socklen_t.h"
12+
#include "hdr/types/ssize_t.h"
13+
#include "hdr/types/struct_sockaddr.h"
1114
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
1215
#include "src/__support/common.h"
1316
#include "src/errno/libc_errno.h"
1417
#include <linux/net.h> // For SYS_SOCKET socketcall number.
15-
#include <sys/socket.h> // For the types
1618
#include <sys/syscall.h> // For syscall numbers.
1719

1820
namespace LIBC_NAMESPACE_DECL {

libc/src/sys/socket/linux/recvfrom.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88

99
#include "src/sys/socket/recvfrom.h"
1010

11+
#include "hdr/types/socklen_t.h"
12+
#include "hdr/types/ssize_t.h"
13+
#include "hdr/types/struct_sockaddr.h"
1114
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
1215
#include "src/__support/common.h"
1316
#include "src/errno/libc_errno.h"
1417
#include <linux/net.h> // For SYS_SOCKET socketcall number.
15-
#include <sys/socket.h> // For the types
1618
#include <sys/syscall.h> // For syscall numbers.
1719

1820
namespace LIBC_NAMESPACE_DECL {

libc/src/sys/socket/linux/recvmsg.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88

99
#include "src/sys/socket/recvmsg.h"
1010

11+
#include "hdr/types/ssize_t.h"
12+
#include "hdr/types/struct_msghdr.h"
1113
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
1214
#include "src/__support/common.h"
1315
#include "src/errno/libc_errno.h"
1416
#include <linux/net.h> // For SYS_SOCKET socketcall number.
15-
#include <sys/socket.h> // For the types
1617
#include <sys/syscall.h> // For syscall numbers.
1718

1819
namespace LIBC_NAMESPACE_DECL {

libc/src/sys/socket/linux/send.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88

99
#include "src/sys/socket/send.h"
1010

11+
#include "hdr/types/socklen_t.h"
12+
#include "hdr/types/ssize_t.h"
13+
#include "hdr/types/struct_sockaddr.h"
1114
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
1215
#include "src/__support/common.h"
1316
#include "src/errno/libc_errno.h"
1417
#include <linux/net.h> // For SYS_SOCKET socketcall number.
15-
#include <sys/socket.h> // For the types
1618
#include <sys/syscall.h> // For syscall numbers.
1719

1820
namespace LIBC_NAMESPACE_DECL {

libc/src/sys/socket/linux/sendmsg.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88

99
#include "src/sys/socket/sendmsg.h"
1010

11+
#include "hdr/types/ssize_t.h"
12+
#include "hdr/types/struct_msghdr.h"
1113
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
1214
#include "src/__support/common.h"
1315
#include "src/errno/libc_errno.h"
1416
#include <linux/net.h> // For SYS_SOCKET socketcall number.
15-
#include <sys/socket.h> // For the types
1617
#include <sys/syscall.h> // For syscall numbers.
1718

1819
namespace LIBC_NAMESPACE_DECL {

libc/src/sys/socket/linux/sendto.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88

99
#include "src/sys/socket/sendto.h"
1010

11+
#include "hdr/types/socklen_t.h"
12+
#include "hdr/types/ssize_t.h"
13+
#include "hdr/types/struct_sockaddr.h"
1114
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
1215
#include "src/__support/common.h"
1316
#include "src/errno/libc_errno.h"
1417
#include <linux/net.h> // For SYS_SOCKET socketcall number.
15-
#include <sys/socket.h> // For the types
1618
#include <sys/syscall.h> // For syscall numbers.
1719

1820
namespace LIBC_NAMESPACE_DECL {

libc/src/sys/socket/recvfrom.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
#ifndef LLVM_LIBC_SRC_SYS_SOCKET_RECVFROM_H
1010
#define LLVM_LIBC_SRC_SYS_SOCKET_RECVFROM_H
1111

12+
#include "hdr/types/socklen_t.h"
13+
#include "hdr/types/ssize_t.h"
14+
#include "hdr/types/struct_sockaddr.h"
1215
#include "src/__support/macros/config.h"
13-
#include <sys/socket.h>
16+
#include <stddef.h> // For size_t
1417

1518
namespace LIBC_NAMESPACE_DECL {
1619

libc/src/sys/socket/recvmsg.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
#ifndef LLVM_LIBC_SRC_SYS_SOCKET_RECVMSG_H
1010
#define LLVM_LIBC_SRC_SYS_SOCKET_RECVMSG_H
1111

12+
#include "hdr/types/ssize_t.h"
13+
#include "hdr/types/struct_msghdr.h"
1214
#include "src/__support/macros/config.h"
13-
#include <sys/socket.h>
1415

1516
namespace LIBC_NAMESPACE_DECL {
1617

0 commit comments

Comments
 (0)