[llvm] r344387 - [BPF] Use cstdint {, u}int*_t instead of linux/types.h __u32 __u16 ...
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 12 10:57:07 PDT 2018
Author: maskray
Date: Fri Oct 12 10:57:07 2018
New Revision: 344387
URL: http://llvm.org/viewvc/llvm-project?rev=344387&view=rev
Log:
[BPF] Use cstdint {,u}int*_t instead of linux/types.h __u32 __u16 ...
Modified:
llvm/trunk/include/llvm/MC/MCBTFContext.h
llvm/trunk/lib/CodeGen/AsmPrinter/Dwarf2BTF.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/Dwarf2BTF.h
Modified: llvm/trunk/include/llvm/MC/MCBTFContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCBTFContext.h?rev=344387&r1=344386&r2=344387&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCBTFContext.h (original)
+++ llvm/trunk/include/llvm/MC/MCBTFContext.h Fri Oct 12 10:57:07 2018
@@ -18,27 +18,20 @@
#include <map>
#include <vector>
-typedef __signed__ char __s8;
-typedef unsigned char __u8;
-typedef __signed__ short __s16;
-typedef unsigned short __u16;
-typedef __signed__ int __s32;
-typedef unsigned int __u32;
-
#define BTF_MAGIC 0xeB9F
#define BTF_VERSION 1
struct btf_header {
- __u16 magic;
- __u8 version;
- __u8 flags;
- __u32 hdr_len;
+ uint16_t magic;
+ uint8_t version;
+ uint8_t flags;
+ uint32_t hdr_len;
/* All offsets are in bytes relative to the end of this header */
- __u32 type_off; /* offset of type section */
- __u32 type_len; /* length of type section */
- __u32 str_off; /* offset of string section */
- __u32 str_len; /* length of string section */
+ uint32_t type_off; // offset of type section
+ uint32_t type_len; // length of type section
+ uint32_t str_off; // offset of string section
+ uint32_t str_len; // length of string section
};
/* Max # of type identifier */
@@ -49,14 +42,14 @@ struct btf_header {
#define BTF_MAX_VLEN 0xffff
struct btf_type {
- __u32 name_off;
+ uint32_t name_off;
/* "info" bits arrangement
* bits 0-15: vlen (e.g. # of struct's members)
* bits 16-23: unused
* bits 24-27: kind (e.g. int, ptr, array...etc)
* bits 28-31: unused
*/
- __u32 info;
+ uint32_t info;
/* "size" is used by INT, ENUM, STRUCT and UNION.
* "size" tells the size of the type it is describing.
*
@@ -65,8 +58,8 @@ struct btf_type {
* "type" is a type_id referring to another type.
*/
union {
- __u32 size;
- __u32 type;
+ uint32_t size;
+ uint32_t type;
};
};
@@ -111,15 +104,15 @@ struct btf_type {
* info in "struct btf_type").
*/
struct btf_enum {
- __u32 name_off;
- __s32 val;
+ uint32_t name_off;
+ int32_t val;
};
/* BTF_KIND_ARRAY is followed by one "struct btf_array" */
struct btf_array {
- __u32 type;
- __u32 index_type;
- __u32 nelems;
+ uint32_t type;
+ uint32_t index_type;
+ uint32_t nelems;
};
/* BTF_KIND_STRUCT and BTF_KIND_UNION are followed
@@ -128,45 +121,45 @@ struct btf_array {
* "struct btf_type").
*/
struct btf_member {
- __u32 name_off;
- __u32 type;
- __u32 offset; /* offset in bits */
+ uint32_t name_off;
+ uint32_t type;
+ uint32_t offset; /* offset in bits */
};
/* .BTF.ext section contains func_info and line_info.
*/
struct btf_ext_header {
- __u16 magic;
- __u8 version;
- __u8 flags;
- __u32 hdr_len;
-
- __u32 func_info_off;
- __u32 func_info_len;
- __u32 line_info_off;
- __u32 line_info_len;
+ uint16_t magic;
+ uint8_t version;
+ uint8_t flags;
+ uint32_t hdr_len;
+
+ uint32_t func_info_off;
+ uint32_t func_info_len;
+ uint32_t line_info_off;
+ uint32_t line_info_len;
};
struct bpf_func_info {
- __u32 insn_offset;
- __u32 type_id;
+ uint32_t insn_offset;
+ uint32_t type_id;
};
struct btf_sec_func_info {
- __u32 sec_name_off;
- __u32 num_func_info;
+ uint32_t sec_name_off;
+ uint32_t num_func_info;
};
struct bpf_line_info {
- __u32 insn_offset;
- __u32 file_name_off;
- __u32 line_off;
- __u32 line_col; /* line num: line_col >> 10, col num: line_col & 0x3ff */
+ uint32_t insn_offset;
+ uint32_t file_name_off;
+ uint32_t line_off;
+ uint32_t line_col; /* line num: line_col >> 10, col num: line_col & 0x3ff */
};
struct btf_sec_line_info {
- __u32 sec_name_off;
- __u32 num_line_info;
+ uint32_t sec_name_off;
+ uint32_t num_line_info;
};
namespace llvm {
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/Dwarf2BTF.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/Dwarf2BTF.cpp?rev=344387&r1=344386&r2=344387&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/Dwarf2BTF.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/Dwarf2BTF.cpp Fri Oct 12 10:57:07 2018
@@ -200,7 +200,7 @@ Die2BTFEntryInt::Die2BTFEntryInt(const D
auto Encoding = Die2BTFEntry::getBaseTypeEncoding(Die);
assert((Encoding != BTF_INVALID_ENCODING) &&
"Invalid Die passed to BTFTypeEntryInt()");
- __u32 IntVal = (Encoding & 0xf) << 24;
+ uint32_t IntVal = (Encoding & 0xf) << 24;
// handle BTF_INT_OFFSET in IntVal
auto V = Die.findAttribute(dwarf::DW_AT_bit_offset);
@@ -209,7 +209,7 @@ Die2BTFEntryInt::Die2BTFEntryInt(const D
// get btf_type.size
V = Die.findAttribute(dwarf::DW_AT_byte_size);
- __u32 Size = V.getDIEInteger().getValue() & 0xffffffff;
+ uint32_t Size = V.getDIEInteger().getValue() & 0xffffffff;
// handle BTF_INT_BITS in IntVal
V = Die.findAttribute(dwarf::DW_AT_bit_size);
@@ -237,7 +237,7 @@ void Die2BTFEntryInt::completeData(class
Die2BTFEntryEnum::Die2BTFEntryEnum(const DIE &Die) : Die2BTFEntry(Die) {
// get btf_type.size
auto V = Die.findAttribute(dwarf::DW_AT_byte_size);
- __u32 Size = V.getDIEInteger().getValue() & 0xffffffff;
+ uint32_t Size = V.getDIEInteger().getValue() & 0xffffffff;
int Vlen = 0;
for (auto &ChildDie : Die.children())
@@ -265,7 +265,7 @@ void Die2BTFEntryEnum::completeData(clas
BTFEnum.name_off = Dwarf2BTF.addBTFString(Str);
auto ChildValueV = ChildDie.findAttribute(dwarf::DW_AT_const_value);
- BTFEnum.val = (__s32)(ChildValueV.getDIEInteger().getValue());
+ BTFEnum.val = (int32_t)(ChildValueV.getDIEInteger().getValue());
EnumValues.push_back(BTFEnum);
}
@@ -308,7 +308,7 @@ void Die2BTFEntryArray::completeData(cla
Nelems = 0;
break;
}
- Nelems *= (__u32)(CountV.getDIEInteger().getValue());
+ Nelems *= (uint32_t)(CountV.getDIEInteger().getValue());
}
}
ArrayInfo.nelems = Nelems;
@@ -320,7 +320,7 @@ void Die2BTFEntryArray::completeData(cla
Die2BTFEntryStruct::Die2BTFEntryStruct(const DIE &Die) : Die2BTFEntry(Die) {
// get btf_type.size
auto V = Die.findAttribute(dwarf::DW_AT_byte_size);
- __u32 Size = V.getDIEInteger().getValue() & 0xffffffff;
+ uint32_t Size = V.getDIEInteger().getValue() & 0xffffffff;
auto Kind = Die2BTFEntry::getDieKind(Die);
int Vlen = 0;
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/Dwarf2BTF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/Dwarf2BTF.h?rev=344387&r1=344386&r2=344387&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/Dwarf2BTF.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/Dwarf2BTF.h Fri Oct 12 10:57:07 2018
@@ -54,7 +54,7 @@ public:
// BTF_KIND_INT
class Die2BTFEntryInt : public Die2BTFEntry {
- __u32 IntVal; // encoding, offset, bits
+ uint32_t IntVal; // encoding, offset, bits
public:
Die2BTFEntryInt(const DIE &Die);
@@ -90,7 +90,7 @@ public:
// BTF_KIND_FUNC and BTF_KIND_FUNC_PROTO
class Die2BTFEntryFunc : public Die2BTFEntry {
- std::vector<__u32> Parameters;
+ std::vector<uint32_t> Parameters;
public:
Die2BTFEntryFunc(const DIE &Die);
@@ -109,7 +109,7 @@ public:
bool isLittleEndian() { return IsLE; }
void addDwarfCU(DwarfUnit *TheU);
void finish();
- __u32 getTypeIndex(DIE &Die) {
+ uint32_t getTypeIndex(DIE &Die) {
DIE *DiePtr = const_cast<DIE *>(&Die);
assert((DieToIdMap.find(DiePtr) != DieToIdMap.end()) &&
"Die not added to in the BTFContext");
More information about the llvm-commits
mailing list