mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-24 10:41:35 +01:00
19 lines
327 B
C
19 lines
327 B
C
/* Increment a variable in inline assembly.
|
|
*
|
|
* https://cirosantilli.com/linux-kernel-module-cheat#gcc-inline-assembly
|
|
*/
|
|
|
|
#include <assert.h>
|
|
#include <inttypes.h>
|
|
|
|
int main(void) {
|
|
uint64_t io = 1;
|
|
__asm__ (
|
|
"add %[io], %[io], 1;"
|
|
: [io] "+r" (io)
|
|
:
|
|
:
|
|
);
|
|
assert(io == 2);
|
|
}
|