|
I came across these 2 macros in Linux kernel code. I know they are instructions to compiler (gcc) for optimizations in case of branching. My question is, can we use these macros in user space code? Will it give any optimization? Any example will be very...
Started by vinit dhatrak on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
The likely() and unlikely() macros are pretty names defined in the kernel headers for something) __builtin_expect((x),1) #define unlikely(x) __builtin_expect((x),0)
The __builtinexpect macros are GCC specific macros that use....
|
|
Hi,
I was reading some code written in C this evening, and at the top of the file was the function-like macro HASH:
#define HASH(fp) (((unsigned long)fp)%NHASH)
This left me wondering, why would somebody choose to implement a function this way using a...
Started by Ralph on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
Some problems I ....
But in your example, the macro turns into 1-2 machine language instructions of.
It might not seem like much.
Introduces call-stack setup and restore Macros like that avoid the overhead of a function call.
|
|
Hi, I don't know how to call a macro inside another macro avoiding the ring bell stop of the inner macro, because that stops the external macro. In particular, I have to make two searches , and I've defined one in one macro and the other have to search...
Started by salva on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
The macro system is great, but it is limited in power, and it sounds like you are trying to do bet is to write the inner loop in Lisp and run the outer loop as a macro (or write it in Lisp as well searches in a macro easily....
|
Ask your Facebook Friends
|
Hello,
gcc 4.4.2 c89
I have this code snippet that I have to repeat in a lot of my code. I am just wondering is there a way to make it short by using a macro function?
There is the code I would like to change.
ERR_INFO error_info; /* create error object...
Started by robUK on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Used often enough, you might be still be better off with a real functionAre you trying... .
DISPLAY(message) // Pass an argument to macro
You need to make it work like a function call, so it can having the function-like macro.
|
|
I've been digging through some parts of the Linux kernel, and found calls like this:
if (unlikely(fd < 0)) { /* Do something */ }
or
if (likely(!err)) { /* Do something */ }
I've found the definition of them:
#define likely(x) __builtin_expect((x),...
Started by terminus on
, 9 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
These are macros that give hints to the compiler about which way a branch may go.
Like all such performance for platforms that do not support static branch hints.
Is correct most of the time, this will tend to be good for performance .
|
|
I really want to learn Scheme macros. I glanced over the content of "On Lisp" and a lot of the chapters have been devoted to Lisp macros. However I do not know common lisp. Can I use it to learn Scheme Macros?
Started by kunjaan on
, 4 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Some implementations of Scheme offer Lisp....
Google shows many pages offeringScheme macros ("hygienic macros") are completely different from traditional Lisp macros.
If you would like to learn about that style of macro.
|
|
Many macros users got banned lately - for GAME HACK #89246 and GAME HACK #89296, if I not wrong with numbers.
This is AutoHotKey software users. PunkBuster ban for using AHK and AHK-compiled .exe scripts.
Off cource, I see whine like "I`m fair player,...
Started by -Zlodey-ru on
, 25 posts
by 19 people.
Answer Snippets (Read the full thread at electronicarts):
You know the difference of innocent macros like that, and shaky-hand macros!
Quote....
Friday morning why use ahk when most of us have keyboard with macro like g-15 that are in whitelist!
Nah, don't pull it out of context.
|
|
20 years old, 6"4, 201lbs, ~20-21% BF, Lift 3-4 days a week (currently NO cardio)
Just briefly, my metabolism was shot for a while because of losing a lot of weight in a pretty low calorie diet. I increased my diet to do a mini-bulk to see if I could ...
Started by vnr on
, 14 posts
by 7 people.
Answer Snippets (Read the full thread at bodybuilding):
Keep your macros....
Add cardio if you like (Although it's not needed, I personally wish I added it earlier though, makes me feel great).
It seems like you should know what your maintenance is (Or at least pretty close) - Subtract calories.
|
|
Hello,
I've got a pretty complicated macro inside my (unmanaged) C++ code. Is there any way to expand macros in VS debugger? Or maybe there is another way to debug macros there?
F.e. I'd like to place a breakpoint inside it.
(Yes, I know macros are bad...
Started by liori on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
No....
Have I said that the macros are very complicated? I'd like to expand one or two layers only into them.
Recompile and you should be able to step of it .
Insert the expanded macro into your code.
With the macros expanded.
|
|
I'd like to get the C preprocessor to generate macros for me (i.e., I'm using C99 only). I'd write a macro
#define make_macro(in) <...magic here...>
and when I put
make_macro(name1) make_macro(name2)
later in the code, it would expand to
#define...
Started by afluff on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
Use like this:
make_macro(name1) make_macro(name2,1)
and this would generate
name1_fn you could not use other macros in your macro but you could not do
#define TEST #define HALLO 33 int with my default compiler....
|