forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[reland][libc] add epoll_wait functions (llvm#79635)
The epoll_wait functions are syscall wrappers that were requested by upstream users. This patch adds them, as well as their header and types. The tests are currently incomplete since they require epoll_create to properly test epoll_wait. That will be added in a followup patch since this one is already very large.
- Loading branch information
1 parent
69cb99f
commit 9f3854a
Showing
34 changed files
with
631 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//===-- Definition of epoll_data type -------------------------------------===// | ||
// | ||
// 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_TYPES_EPOLL_DATA_H__ | ||
#define __LLVM_LIBC_TYPES_EPOLL_DATA_H__ | ||
|
||
union epoll_data { | ||
void *ptr; | ||
int fd; | ||
__UINT32_TYPE__ u32; | ||
__UINT64_TYPE__ u64; | ||
}; | ||
|
||
typedef union epoll_data epoll_data_t; | ||
|
||
#endif // __LLVM_LIBC_TYPES_EPOLL_DATA_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//===-- Definition of epoll_event type ------------------------------------===// | ||
// | ||
// 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_TYPES_EPOLL_EVENT_H__ | ||
#define __LLVM_LIBC_TYPES_EPOLL_EVENT_H__ | ||
|
||
#include <llvm-libc-types/struct_epoll_data.h> | ||
|
||
typedef struct epoll_event { | ||
__UINT32_TYPE__ events; | ||
epoll_data_t data; | ||
} epoll_event; | ||
|
||
#endif // __LLVM_LIBC_TYPES_EPOLL_EVENT_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//===-- Linux header epoll.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_SYS_EPOLL_H | ||
#define LLVM_LIBC_SYS_EPOLL_H | ||
|
||
#include <__llvm-libc-common.h> | ||
|
||
%%public_api() | ||
|
||
#endif // LLVM_LIBC_SYS_EPOLL_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS}) | ||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS}) | ||
endif() | ||
|
||
add_entrypoint_object( | ||
epoll_wait | ||
ALIAS | ||
DEPENDS | ||
.${LIBC_TARGET_OS}.epoll_wait | ||
) | ||
|
||
add_entrypoint_object( | ||
epoll_pwait | ||
ALIAS | ||
DEPENDS | ||
.${LIBC_TARGET_OS}.epoll_pwait | ||
) | ||
|
||
add_entrypoint_object( | ||
epoll_pwait2 | ||
ALIAS | ||
DEPENDS | ||
.${LIBC_TARGET_OS}.epoll_pwait2 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//===-- Implementation header for epoll_pwait function ----------*- C++ -*-===// | ||
// | ||
// 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_SRC_SYS_EPOLL_EPOLL_PWAIT_H | ||
#define LLVM_LIBC_SRC_SYS_EPOLL_EPOLL_PWAIT_H | ||
|
||
// TODO: Use this include once the include headers are also using quotes. | ||
// #include "include/llvm-libc-types/sigset_t.h" | ||
// #include "include/llvm-libc-types/struct_epoll_event.h" | ||
|
||
#include <sys/epoll.h> | ||
|
||
namespace LIBC_NAMESPACE { | ||
|
||
// TODO: sigmask should be nullable | ||
int epoll_pwait(int epfd, epoll_event *events, int maxevents, int timeout, | ||
const sigset_t *sigmask); | ||
|
||
} // namespace LIBC_NAMESPACE | ||
|
||
#endif // LLVM_LIBC_SRC_SYS_EPOLL_EPOLL_PWAIT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//===-- Implementation header for epoll_pwait2 function ---------*- C++ -*-===// | ||
// | ||
// 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_SRC_SYS_EPOLL_EPOLL_PWAIT2_H | ||
#define LLVM_LIBC_SRC_SYS_EPOLL_EPOLL_PWAIT2_H | ||
|
||
// TODO: Use this include once the include headers are also using quotes. | ||
// #include "include/llvm-libc-types/sigset_t.h" | ||
// #include "include/llvm-libc-types/struct_epoll_event.h" | ||
// #include "include/llvm-libc-types/struct_timespec.h" | ||
|
||
#include <sys/epoll.h> | ||
|
||
namespace LIBC_NAMESPACE { | ||
|
||
// TODO: sigmask and timeout should be nullable | ||
int epoll_pwait2(int epfd, epoll_event *events, int maxevents, | ||
const timespec *timeout, const sigset_t *sigmask); | ||
|
||
} // namespace LIBC_NAMESPACE | ||
|
||
#endif // LLVM_LIBC_SRC_SYS_EPOLL_EPOLL_PWAIT2_H |
Oops, something went wrong.