[libc] Add byteswap.h header with bswap_16/bswap_32/bswap_64 (#196278)
Added the Linux byteswap.h header providing bswap_16, bswap_32, and
bswap_64 as macros expanding to __builtin_bswap{16,32,64}. These are
always inlined by the compiler to single instructions.
Follows the existing endian.h / endian-macros.h pattern.
Assisted-by: Automated tooling, human reviewed.
This commit is contained in:
1 parent
37f826aa9e
commit
7554007c80
7 files changed
+60
No files matched your search
@@ -42,6 +42,7 @@ if (SPHINX_FOUND)
|
||||
aio
|
||||
arpa/inet
|
||||
assert
|
||||
byteswap
|
||||
cpio
|
||||
ctype
|
||||
dirent
|
||||
|
||||
@@ -7,6 +7,7 @@ Implementation Status
|
||||
aio
|
||||
arpa/inet
|
||||
assert
|
||||
byteswap
|
||||
complex
|
||||
cpio
|
||||
ctype
|
||||
|
||||
@@ -229,6 +229,15 @@ add_header_macro(
|
||||
.llvm-libc-macros.assert_macros
|
||||
)
|
||||
|
||||
add_header_macro(
|
||||
byteswap
|
||||
../libc/include/byteswap.yaml
|
||||
byteswap.h
|
||||
DEPENDS
|
||||
.llvm_libc_common_h
|
||||
.llvm-libc-macros.byteswap_macros
|
||||
)
|
||||
|
||||
add_header_macro(
|
||||
complex
|
||||
../libc/include/complex.yaml
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
header: byteswap.h
|
||||
standards:
|
||||
- linux
|
||||
macros:
|
||||
- macro_name: bswap_16
|
||||
macro_header: byteswap-macros.h
|
||||
- macro_name: bswap_32
|
||||
macro_header: byteswap-macros.h
|
||||
- macro_name: bswap_64
|
||||
macro_header: byteswap-macros.h
|
||||
types: []
|
||||
enums: []
|
||||
objects: []
|
||||
functions: []
|
||||
@@ -48,6 +48,12 @@ add_macro_header(
|
||||
assert-macros.h
|
||||
)
|
||||
|
||||
add_macro_header(
|
||||
byteswap_macros
|
||||
HDR
|
||||
byteswap-macros.h
|
||||
)
|
||||
|
||||
add_macro_header(
|
||||
error_number_macros
|
||||
HDR
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
///
|
||||
/// \file
|
||||
/// Definition of macros from byteswap.h.
|
||||
///
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_LIBC_MACROS_BYTESWAP_MACROS_H
|
||||
#define LLVM_LIBC_MACROS_BYTESWAP_MACROS_H
|
||||
|
||||
#define bswap_16(x) __builtin_bswap16((x))
|
||||
#define bswap_32(x) __builtin_bswap32((x))
|
||||
#define bswap_64(x) __builtin_bswap64((x))
|
||||
|
||||
#endif // LLVM_LIBC_MACROS_BYTESWAP_MACROS_H
|
||||
@@ -0,0 +1,8 @@
|
||||
macros:
|
||||
bswap_16:
|
||||
c-definition: ''
|
||||
bswap_32:
|
||||
c-definition: ''
|
||||
bswap_64:
|
||||
c-definition: ''
|
||||
|
||||
Reference in new issue
Block a user