Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libc/config/linux/aarch64/headers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ set(TARGET_PUBLIC_HEADERS
libc.include.locale
libc.include.malloc
libc.include.math
libc.include.netinet_in
libc.include.poll
libc.include.pthread
libc.include.sched
Expand Down
1 change: 1 addition & 0 deletions libc/config/linux/riscv/headers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ set(TARGET_PUBLIC_HEADERS
libc.include.locale
libc.include.malloc
libc.include.math
libc.include.netinet_in
libc.include.poll
libc.include.pthread
libc.include.sched
Expand Down
1 change: 1 addition & 0 deletions libc/config/linux/x86_64/headers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ set(TARGET_PUBLIC_HEADERS
libc.include.locale
libc.include.malloc
libc.include.math
libc.include.netinet_in
libc.include.poll
libc.include.pthread
libc.include.sched
Expand Down
11 changes: 11 additions & 0 deletions libc/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,17 @@ add_header_macro(
.inttypes
)

file(MAKE_DIRECTORY ${LIBC_INCLUDE_DIR}/netinet)

add_header_macro(
netinet_in
../libc/include/netinet/in.yaml
netinet/in.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-macros.netinet_in_macros
)

add_header_macro(
assert
../libc/include/assert.yaml
Expand Down
6 changes: 6 additions & 0 deletions libc/include/llvm-libc-macros/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ add_macro_header(
.math_macros
)

add_macro_header(
netinet_in_macros
HDR
netinet-in-macros.h
)

add_macro_header(
offsetof_macro
HDR
Expand Down
19 changes: 19 additions & 0 deletions libc/include/llvm-libc-macros/netinet-in-macros.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//===-- Definition of macros from netinet/in.h ----------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIBC_MACROS_NETINET_IN_MACROS_H
#define LLVM_LIBC_MACROS_NETINET_IN_MACROS_H

#define IPPROTO_IP 0
#define IPPROTO_ICMP 1
#define IPPROTO_TCP 6
#define IPPROTO_UDP 17
#define IPPROTO_IPV6 41
#define IPPROTO_RAW 255

#endif // LLVM_LIBC_MACROS_NETINET_IN_MACROS_H
18 changes: 18 additions & 0 deletions libc/include/netinet/in.h.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- C standard library header in.h ------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIBC_NETINET_IN_H
#define LLVM_LIBC_NETINET_IN_H

#include "__llvm-libc-common.h"

#include "../llvm-libc-macros/netinet-in-macros.h"

%%public_api()

#endif // LLVM_LIBC_NETINET_IN_H
7 changes: 7 additions & 0 deletions libc/include/netinet/in.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
header: netinet/in.h
header_template: in.h.def
macros: []
types: []
enums: []
objects: []
functions: []
10 changes: 10 additions & 0 deletions libc/test/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,16 @@ add_libc_test(
libc.include.llvm-libc-macros.math_function_macros
)

add_libc_test(
netinet_in_test
SUITE
libc_include_tests
SRCS
netinet_in_test.cpp
DEPENDS
libc.include.llvm-libc-macros.netinet_in_macros
)

add_libc_test(
signbit_test
SUITE
Expand Down
19 changes: 19 additions & 0 deletions libc/test/include/netinet_in_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//===-- Unittests for netinet/in macro ------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "include/llvm-libc-macros/netinet-in-macros.h"
#include "test/UnitTest/Test.h"

TEST(LlvmLibcNetinetInTest, IPPROTOMacro) {
EXPECT_EQ(IPPROTO_IP, 0);
EXPECT_EQ(IPPROTO_ICMP, 1);
EXPECT_EQ(IPPROTO_TCP, 6);
EXPECT_EQ(IPPROTO_UDP, 17);
EXPECT_EQ(IPPROTO_IPV6, 41);
EXPECT_EQ(IPPROTO_RAW, 255);
}
Loading