What is the value for this built-in assembly (: "0" (THREAD_SIZE - 1)) in linux kernel 2.6.11 for i386

in do_IRQ you can find the following code!

#ifdef CONFIG_DEBUG_STACKOVERFLOW
   /* Debugging check for stack overflow: is there less than 1KB free? */
    {
       long esp;

        __asm__ __volatile__("andl %%esp,%0" :
                "=r" (esp) : "0" (THREAD_SIZE - 1));
       if (unlikely(esp < (sizeof(struct thread_info) + STACK_WARN))) {
           printk("do_IRQ: stack overflow: %ld\n",
                esp - sizeof(struct thread_info));
            dump_stack();
        }
    }
#endif

I did not understand the meaning of this assembly asm
 asm _volatile _ ("andl %% esp,% 0": "= r" (esp): "0" (THREAD_SIZE - 1)); THREAD_SIZE - 1 means what? I remember the character in the parenthesis should be a C variable, like esp in the output part, but in the input part it looks like an integer, but not the C character, could there be any help

+4
source share
1 answer

"0" : , 0- (http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html#ss6.1, 6.1.3 Matching (Digit) ).

, THREAD_SIZE - 1 anded . esp .

+3

Source: https://habr.com/ru/post/1527867/


All Articles