Answer the question
In order to leave comments, you need to log in
Is there a portable equivalent to __attribute__((noinline))?
Actually, function inlining should be prohibited: together with instruction reordering, it causes crashes. There is a special attribute for gcc, but I would not want to limit myself to gcc, I would like to compile the studio with a clang and an Intel compiler too. Is a subject possible?
So far the solution is:
#if defined(_MSC_VER)
#define NOINLINE __declspec(noinline)
#else
#define NOINLINE __attribute__ ((noinline))
#endif
Answer the question
In order to leave comments, you need to log in
In theory, this thing should be repaired by properly placed barriers ...
You have a problem somewhere else, and this is not a solution, but simply an avoidance of it.
There is no portable analogue in the standard. And Clang understands __attribute__((noinline)).
But if you really have all sorts of non-standard atomics there, then:
1. use standard atomics;
2. use ordered atomics;
3. use barriers (either for the processor, or only for the compiler asm volatile("":::"memory");
);
4. find out why the compiler allows itself to do reordering around your assembler inserts or intrinsics. Compiler bug?
And then some link-time optimization will come and break everything again.
And yes, are you sure that you wrote your critical section correctly? And why?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question