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.
[libc] add headers sys/auxv sys/prctl and sys/time
These headers are uncommonly used, and from extensions, but some basic support is needed. Macros have been added where available. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D135731
- Loading branch information
1 parent
bb70696
commit 35a4fe4
Showing
12 changed files
with
259 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
//===-- Definition of macros from sys/time.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_LINUX_SYS_TIME_MACROS_H | ||
#define __LLVM_LIBC_MACROS_LINUX_SYS_TIME_MACROS_H | ||
|
||
// Add two timevals and put the result in timeval_ptr_result. If the resulting | ||
// usec value is greater than 999,999 then the microseconds are turned into full | ||
// seconds (1,000,000 is subtracted from usec and 1 is added to sec). | ||
#define timeradd(timeval_ptr_a, timeval_ptr_b, timeval_ptr_result) \ | ||
(timeval_ptr_result)->tv_sec = \ | ||
(timeval_ptr_a)->tv_sec + (timeval_ptr_b)->tv_sec + \ | ||
(((timeval_ptr_a)->tv_usec + (timeval_ptr_b)->tv_usec) >= 1000000 ? 1 \ | ||
: 0); \ | ||
(timeval_ptr_result)->tv_usec = \ | ||
(timeval_ptr_a)->tv_usec + (timeval_ptr_b)->tv_usec - \ | ||
(((timeval_ptr_a)->tv_usec + (timeval_ptr_b)->tv_usec) >= 1000000 \ | ||
? 1000000 \ | ||
: 0); | ||
|
||
// Subtract two timevals and put the result in timeval_ptr_result. If the | ||
// resulting usec value is less than 0 then 1,000,000 is added to usec and 1 is | ||
// subtracted from sec. | ||
#define timersub(timeval_ptr_a, timeval_ptr_b, timeval_ptr_result) \ | ||
(timeval_ptr_result)->tv_sec = \ | ||
(timeval_ptr_a)->tv_sec - (timeval_ptr_b)->tv_sec - \ | ||
(((timeval_ptr_a)->tv_usec - (timeval_ptr_b)->tv_usec) < 0 ? 1 : 0); \ | ||
(timeval_ptr_result)->tv_usec = \ | ||
(timeval_ptr_a)->tv_usec - (timeval_ptr_b)->tv_usec + \ | ||
(((timeval_ptr_a)->tv_usec - (timeval_ptr_b)->tv_usec) < 0 ? 1000000 \ | ||
: 0); | ||
|
||
// Reset a timeval to the epoch. | ||
#define timerclear(timeval_ptr) \ | ||
(timeval_ptr)->tv_sec = 0; \ | ||
(timeval_ptr)->tv_usec = 0; | ||
|
||
// Determine if a timeval is set to the epoch. | ||
#define timerisset(timeval_ptr) \ | ||
(timeval_ptr)->tv_sec != 0 || (timeval_ptr)->tv_usec != 0; | ||
|
||
// Compare two timevals using CMP. | ||
#define timercmp(timeval_ptr_a, timeval_ptr_b, CMP) \ | ||
(((timeval_ptr_a)->tv_sec == (timeval_ptr_b)->tv_sec) \ | ||
? ((timeval_ptr_a)->tv_usec CMP(timeval_ptr_b)->tv_usec) \ | ||
: ((timeval_ptr_a)->tv_sec CMP(timeval_ptr_b)->tv_sec)) | ||
|
||
#endif // __LLVM_LIBC_MACROS_LINUX_SYS_TIME_MACROS_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,43 @@ | ||
//===-- Macros defined in sys/auxv.h header file --------------------------===// | ||
// | ||
// 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_AUXV_MACROS_H | ||
#define __LLVM_LIBC_MACROS_AUXV_MACROS_H | ||
|
||
// Macros defining the aux vector indexes. | ||
#define AT_NULL 0 | ||
#define AT_IGNORE 1 | ||
#define AT_EXECFD 2 | ||
#define AT_PHDR 3 | ||
#define AT_PHENT 4 | ||
#define AT_PHNUM 5 | ||
#define AT_PAGESZ 6 | ||
#define AT_BASE 7 | ||
#define AT_FLAGS 8 | ||
#define AT_ENTRY 9 | ||
#define AT_NOTELF 10 | ||
#define AT_UID 11 | ||
#define AT_EUID 12 | ||
#define AT_GID 13 | ||
#define AT_EGID 14 | ||
#define AT_PLATFORM 15 | ||
#define AT_HWCAP 16 | ||
#define AT_CLKTCK 17 | ||
|
||
#define AT_SECURE 23 | ||
#define AT_BASE_PLATFORM 24 | ||
#define AT_RANDOM 25 | ||
#define AT_HWCAP2 26 | ||
|
||
#define AT_EXECFN 31 | ||
|
||
#ifndef AT_MINSIGSTKSZ | ||
#define AT_MINSIGSTKSZ 51 | ||
#endif | ||
|
||
#endif // __LLVM_LIBC_MACROS_AUXV_MACROS_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 @@ | ||
//===-- Macros defined in sys/time.h header file --------------------------===// | ||
// | ||
// 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_SYS_TIME_MACROS_H | ||
#define __LLVM_LIBC_MACROS_SYS_TIME_MACROS_H | ||
|
||
#ifdef __unix__ | ||
#include "linux/sys-time-macros.h" | ||
#endif | ||
|
||
#endif // __LLVM_LIBC_MACROS_SYS_TIME_MACROS_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,18 @@ | ||
//===-- GNU header auxv.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_AUXV_H | ||
#define LLVM_LIBC_SYS_AUXV_H | ||
|
||
#include <__llvm-libc-common.h> | ||
|
||
#include <llvm-libc-macros/sys-auxv-macros.h> | ||
|
||
%%public_api() | ||
|
||
#endif // LLVM_LIBC_SYS_AUXV_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,22 @@ | ||
//===-- Linux header prctl.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_PRCTL_H | ||
#define LLVM_LIBC_SYS_PRCTL_H | ||
|
||
#include <__llvm-libc-common.h> | ||
|
||
// Process control is highly platform specific, so the platform usually defines | ||
// the macros itself. | ||
#include <linux/prctl.h> | ||
|
||
// TODO: Define the prctl macros. | ||
|
||
%%public_api() | ||
|
||
#endif // LLVM_LIBC_SYS_PRCTL_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,20 @@ | ||
//===-- Linux header time.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_TIME_H | ||
#define LLVM_LIBC_SYS_TIME_H | ||
|
||
#include <__llvm-libc-common.h> | ||
|
||
#include <llvm-libc-types/struct_timeval.h> | ||
|
||
#include <llvm-libc-macros/sys-time-macros.h> | ||
|
||
%%public_api() | ||
|
||
#endif // LLVM_LIBC_SYS_TIME_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