From 66741d321c38328bb4ae01baa716841afb78fc9e Mon Sep 17 00:00:00 2001 From: Karel Kočí Date: Sat, 4 Oct 2025 12:47:24 +0200 Subject: Add presentation: 2026-linuxdays --- 2026-linuxdays/simple.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 2026-linuxdays/simple.c (limited to '2026-linuxdays/simple.c') diff --git a/2026-linuxdays/simple.c b/2026-linuxdays/simple.c new file mode 100644 index 0000000..75c5de2 --- /dev/null +++ b/2026-linuxdays/simple.c @@ -0,0 +1,31 @@ +#define CHAR_BIT 8 + +unsigned loop(unsigned x) { + while (x > 0) + x--; + return x; +} + +int add2(int a, int b) { return a + b; } +int add9(int a, int b, int c, int d, int e, int f, int g, int h, int i) { + return a + b + c + d + e + f + g + h + i; +} + +void call_add(void) { + add2(1, 2); + add9(1, 2, 3, 4, 5, 6, 7, 8, 9); +} + +struct px { + int x, y; +}; +int x_plus_y(struct px *p) { return p->x + p->y; } + +int div2_a(unsigned x) { return x / 2; } +int div2_b(unsigned x) { return x >> 1; } + +int abs_a(int x) { return x < 0 ? -x : x; } +int abs_b(int x) { + int m = x >> (sizeof(x) * CHAR_BIT - 1); + return (x + m) ^ m; +} -- cgit v1.3.1