projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Tests: Introduce gen-ust-events-constructor test application
[lttng-tools.git]
/
src
/
common
/
bytecode
/
bytecode.cpp
diff --git
a/src/common/bytecode/bytecode.cpp
b/src/common/bytecode/bytecode.cpp
index 064f2bfe203d92c8e1b0c14f1e1fa5282f8f69c8..00b4f5e7bca300cb6d513b38a7c640b016978cc1 100644
(file)
--- a/
src/common/bytecode/bytecode.cpp
+++ b/
src/common/bytecode/bytecode.cpp
@@
-1,21
+1,19
@@
/*
* Copyright 2020 EfficiOS, Inc.
*
/*
* Copyright 2020 EfficiOS, Inc.
*
- * SPDX-License-Identifier:
GPL-2.0
-only
+ * SPDX-License-Identifier:
LGPL-2.1
-only
*
*/
*
*/
-#include "bytecode.h"
+#include "bytecode.hpp"
+#include "common/align.hpp"
-#include <errno.h>
#include <algorithm>
#include <algorithm>
-
-#include "common/align.h"
+#include <errno.h>
#define INIT_ALLOC_SIZE 4
#define INIT_ALLOC_SIZE 4
-static inline
-int get_count_order(unsigned int count)
+static inline int get_count_order(unsigned int count)
{
int order;
{
int order;
@@
-39,8
+37,7
@@
int bytecode_init(struct lttng_bytecode_alloc **fb)
}
}
}
}
-static
-int32_t bytecode_reserve(struct lttng_bytecode_alloc **fb, uint32_t align, uint32_t len)
+static int32_t bytecode_reserve(struct lttng_bytecode_alloc **fb, uint32_t align, uint32_t len)
{
int32_t ret;
uint32_t padding = lttng_offset_align((*fb)->b.len, align);
{
int32_t ret;
uint32_t padding = lttng_offset_align((*fb)->b.len, align);
@@
-54,8
+51,7
@@
int32_t bytecode_reserve(struct lttng_bytecode_alloc **fb, uint32_t align, uint3
if (new_alloc_len > old_alloc_len) {
struct lttng_bytecode_alloc *newptr;
if (new_alloc_len > old_alloc_len) {
struct lttng_bytecode_alloc *newptr;
- new_alloc_len =
- std::max(1U << get_count_order(new_alloc_len), old_alloc_len << 1);
+ new_alloc_len = std::max(1U << get_count_order(new_alloc_len), old_alloc_len << 1);
newptr = (lttng_bytecode_alloc *) realloc(*fb, new_alloc_len);
if (!newptr)
return -ENOMEM;
newptr = (lttng_bytecode_alloc *) realloc(*fb, new_alloc_len);
if (!newptr)
return -ENOMEM;
@@
-70,8
+66,7
@@
int32_t bytecode_reserve(struct lttng_bytecode_alloc **fb, uint32_t align, uint3
return ret;
}
return ret;
}
-int bytecode_push(struct lttng_bytecode_alloc **fb, const void *data,
- uint32_t align, uint32_t len)
+int bytecode_push(struct lttng_bytecode_alloc **fb, const void *data, uint32_t align, uint32_t len)
{
int32_t offset;
{
int32_t offset;
@@
-83,9
+78,10
@@
int bytecode_push(struct lttng_bytecode_alloc **fb, const void *data,
}
int bytecode_push_logical(struct lttng_bytecode_alloc **fb,
}
int bytecode_push_logical(struct lttng_bytecode_alloc **fb,
- struct logical_op *data,
- uint32_t align, uint32_t len,
- uint16_t *skip_offset)
+ struct logical_op *data,
+ uint32_t align,
+ uint32_t len,
+ uint16_t *skip_offset)
{
int32_t offset;
{
int32_t offset;
@@
-93,9
+89,8
@@
int bytecode_push_logical(struct lttng_bytecode_alloc **fb,
if (offset < 0)
return offset;
memcpy(&(*fb)->b.data[offset], data, len);
if (offset < 0)
return offset;
memcpy(&(*fb)->b.data[offset], data, len);
- *skip_offset =
- (char *) &((struct logical_op *) &(*fb)->b.data[offset])->skip_offset
- - (char *) &(*fb)->b.data[0];
+ *skip_offset = (char *) &((struct logical_op *) &(*fb)->b.data[offset])->skip_offset -
+ (char *) &(*fb)->b.data[0];
return 0;
}
return 0;
}
@@
-156,14
+151,12
@@
end:
return ret;
}
return ret;
}
-int bytecode_push_get_index_u64(struct lttng_bytecode_alloc **bytecode,
- uint64_t index)
+int bytecode_push_get_index_u64(struct lttng_bytecode_alloc **bytecode, uint64_t index)
{
int ret;
struct load_op *insn;
struct get_index_u64 index_op_data;
{
int ret;
struct load_op *insn;
struct get_index_u64 index_op_data;
- const uint32_t insn_len =
- sizeof(struct load_op) + sizeof(struct get_index_u64);
+ const uint32_t insn_len = sizeof(struct load_op) + sizeof(struct get_index_u64);
insn = (load_op *) calloc(insn_len, 1);
if (!insn) {
insn = (load_op *) calloc(insn_len, 1);
if (!insn) {
@@
-182,8
+175,8
@@
end:
}
int bytecode_push_get_symbol(struct lttng_bytecode_alloc **bytecode,
}
int bytecode_push_get_symbol(struct lttng_bytecode_alloc **bytecode,
- struct lttng_bytecode_alloc **bytecode_reloc,
- const char *symbol)
+
struct lttng_bytecode_alloc **bytecode_reloc,
+
const char *symbol)
{
int ret;
struct load_op *insn;
{
int ret;
struct load_op *insn;
@@
-191,8
+184,7
@@
int bytecode_push_get_symbol(struct lttng_bytecode_alloc **bytecode,
uint32_t reloc_offset_u32;
uint16_t reloc_offset;
uint32_t bytecode_reloc_offset_u32;
uint32_t reloc_offset_u32;
uint16_t reloc_offset;
uint32_t bytecode_reloc_offset_u32;
- const uint32_t insn_len =
- sizeof(struct load_op) + sizeof(struct get_symbol);
+ const uint32_t insn_len = sizeof(struct load_op) + sizeof(struct get_symbol);
insn = (load_op *) calloc(insn_len, 1);
if (!insn) {
insn = (load_op *) calloc(insn_len, 1);
if (!insn) {
@@
-206,8
+198,7
@@
int bytecode_push_get_symbol(struct lttng_bytecode_alloc **bytecode,
* Get offset in the reloc portion at which the symbol name
* will end up at (GET_SYMBOL's operand points there).
*/
* Get offset in the reloc portion at which the symbol name
* will end up at (GET_SYMBOL's operand points there).
*/
- bytecode_reloc_offset_u32 = bytecode_get_len(&(*bytecode_reloc)->b) +
- sizeof(reloc_offset);
+ bytecode_reloc_offset_u32 = bytecode_get_len(&(*bytecode_reloc)->b) + sizeof(reloc_offset);
symbol_offset.offset = (uint16_t) bytecode_reloc_offset_u32;
memcpy(insn->data, &symbol_offset, sizeof(symbol_offset));
symbol_offset.offset = (uint16_t) bytecode_reloc_offset_u32;
memcpy(insn->data, &symbol_offset, sizeof(symbol_offset));
@@
-229,8
+220,7
@@
int bytecode_push_get_symbol(struct lttng_bytecode_alloc **bytecode,
}
/* Append reloc offset. */
}
/* Append reloc offset. */
- ret = bytecode_push(bytecode_reloc, &reloc_offset,
- 1, sizeof(reloc_offset));
+ ret = bytecode_push(bytecode_reloc, &reloc_offset, 1, sizeof(reloc_offset));
if (ret) {
goto end;
}
if (ret) {
goto end;
}
@@
-248,12
+238,9
@@
end:
*
* Return allocated bytecode or NULL on error.
*/
*
* Return allocated bytecode or NULL on error.
*/
-struct lttng_bytecode *lttng_bytecode_copy(
- const struct lttng_bytecode *orig_f)
+struct lttng_bytecode *lttng_bytecode_copy(const struct lttng_bytecode *orig_f)
{
{
- struct lttng_bytecode *bytecode = NULL;
-
- bytecode = (lttng_bytecode *) zmalloc(sizeof(*bytecode) + orig_f->len);
+ lttng_bytecode *bytecode = zmalloc<lttng_bytecode>(sizeof(*bytecode) + orig_f->len);
if (!bytecode) {
goto error;
}
if (!bytecode) {
goto error;
}
This page took
0.02512 seconds
and
4
git commands to generate.