memory-alignment Questions
1
Solved
I am studying the issue of alignment check. But I don't know whether the processor is checking on effective addresses, linear addresses or physical addresses, or all checks.
For example, the effect...
Narrows asked 16/6, 2021 at 10:38
5
Is there any standardized function in GCC or glibc to allocate memory block at aligned pointer?
Like _align_malloc() in MSVC?
Route asked 1/10, 2010 at 14:8
2
Do the memory alignment issues with Eigen listed in the documentation still apply with C++11? It seems that C++11 can already take care of properly aligning objects on the stack and on the heap, wi...
Adeliaadelice asked 9/4, 2015 at 10:44
3
Solved
Edit: Thanks for everyone's answer and replies. Language Lawyer's answer is technically the correct one so that's accepted, but Human-Compiler's answer is the only one that meets the criteria (get...
Nullifidian asked 9/3, 2021 at 12:29
3
Solved
I've just stumbled upon the std::alignment_of type trait, and its soon-to-be friend std::alignment_of_v. They seem to have been specifically designed to be equivalent to a plain call to alignof, an...
Fulmination asked 2/5, 2016 at 12:2
2
Solved
I am compiling this code for a Cortex M7 using GCC:
// copy manually
void write_test_plain(uint8_t * ptr, uint32_t value)
{
*ptr++ = (u8)(value);
*ptr++ = (u8)(value >> 8);
*ptr++ = (u8)(...
Eller asked 14/6, 2018 at 22:35
3
Solved
I write an image processing app that needs to do multiple things and it has to do them as much real-time as possible.
Acquisition of the data and their processing runs in separate processes (mainl...
Anthology asked 27/3, 2012 at 18:53
4
Solved
I want to emulate the system with prohibited unaligned memory accesses on the x86/x86_64.
Is there some debugging tool or special mode to do this?
I want to run many (CPU-intensive) tests on the s...
Quiz asked 6/8, 2012 at 23:57
2
Solved
Is there a linux equivalent of _aligned_realloc?
I want to use realloc so I don't have to memcpy the data every time I resize it. Am I stuck with mmap? I only used mmap once is there a recommended ...
Camp asked 17/11, 2020 at 23:12
4
Solved
I know why GCC doesn't re-order members of a structure by default, but I seldom write code that relies on the order of the structure, so is there some way I can flag my structures to be automaticly...
Deckle asked 3/2, 2013 at 9:52
5
Solved
These structs, align1 and align2, contain the same data, but align1 has more padding due to the nested layout.
How can I get the memory saving alignment of align2 while also using a nested struct l...
Dougald asked 2/11, 2020 at 14:19
3
Many C/C++ compilers (including gcc and clang) have a feature called packed structures. It comes in handy for a number of reasons, but it has to be used with caution. One potential pitfall is that ...
Nostoc asked 4/3, 2015 at 16:3
1
Solved
Overview
When browsing operator new, operator new[] - cppreference.com, it seems we have a number of options for allocating arrays of objects with specific alignment requirements. However, it is no...
Cytology asked 28/10, 2020 at 20:35
0
I tried to create a smart pointer that has only one pointer to a block of memory, which starts with a reference counter (control block), and a value stored immediately after it. And after reading s...
Shin asked 8/10, 2020 at 19:3
1
I'm not used to post any question on the internet so please tell me if I'm doing something wrong.
In short
How to correctly prevent false sharing on a 64bits architecture with a CPU cacheline size...
Extreme asked 2/9, 2020 at 13:31
1
Solved
Aim: To understand the motivation why C++17 introduced std::aligned_alloc for dynamic memory management.
Problem: For the memory allocation in C++, using std::malloc is virtually always discouraged...
Canterbury asked 13/9, 2020 at 14:16
3
I was learning about structure padding, and read that the reason behind structure padding is that if the members of the struct are not aligned, the processor won't be able to read/write them in onl...
Overdo asked 7/8, 2020 at 2:29
3
Solved
I just learnt about alignof and alignas C++ keywords but I can't think about any practical case where a developer would want to use these keywords.
Does somebody know any practical use case for the...
Starrstarred asked 20/6, 2020 at 17:12
1
Solved
Because of a lack of PUSH and POP instructions in ARM64, I'm having a problem with understanding how SP work in ARM64.
If I were to PUSH/POP, does the SP decrement/increment by 4, 8 or 16 bytes?
I'...
Alluring asked 20/7, 2020 at 20:20
0
Suppose I have the following simple class:
struct employee{
std::string name;
short salary;
std::size_t age;
employee(std::string name, short salary, std::size_t age) : name{name}, salary{sal...
Oddson asked 11/6, 2020 at 5:53
2
Suppose that I am in a 64-bit machine compiling a C program with gcc. I'm assuming that sizeof(int) is 8 bytes, and sizeof(char) is 1 byte.
Because of memory alignment, the following struct:
stru...
Willwilla asked 10/6, 2017 at 1:25
2
Solved
I ran the following program on my computer (64-bit Intel running Linux).
#include <stdio.h>
void test(int argc, char **argv) {
printf("[test] Argc Pointer: %p\n", &argc);
printf("[tes...
Edik asked 8/2, 2020 at 15:34
1
Solved
I have the following data segment
.data
a: .byte 0x11
.align 1
b: .word 0x22334455
Assuming that address "a" is 0x10010000, then the expected address for the word at b is 0x10010002, but MARS s...
Anzac asked 27/1, 2020 at 7:5
1
Solved
i'm new to C++ so i'm trying some leetcode problems. i'm currently attempting the min stack problem. i think i've solved it correctly, except i get the following runtime error from leetcode:
Line ...
Disapprove asked 3/1, 2020 at 22:21
6
I wrote a simple example:
#include <iostream>
int main() {
void* byte1 = ::operator new(1);
void* byte2 = ::operator new(1);
void* byte3 = malloc(1);
std::cout << "byte1: " <&l...
Sportive asked 29/11, 2019 at 2:58
© 2022 - 2024 — McMap. All rights reserved.