diff options
| author | Karel Kočí <cynerd@email.cz> | 2025-10-04 12:47:24 +0200 |
|---|---|---|
| committer | Karel Kočí <cynerd@email.cz> | 2026-10-04 10:08:07 +0200 |
| commit | 66741d321c38328bb4ae01baa716841afb78fc9e (patch) | |
| tree | 72a837c14396cb262b11c42603a523620a3f694d /2026-linuxdays/simple.c | |
| parent | 6d86e1a8465e2d6a7638dd3532a30f6885e95c20 (diff) | |
| download | presentations-66741d321c38328bb4ae01baa716841afb78fc9e.tar.gz presentations-66741d321c38328bb4ae01baa716841afb78fc9e.tar.bz2 presentations-66741d321c38328bb4ae01baa716841afb78fc9e.zip | |
Add presentation: 2026-linuxdays
Diffstat (limited to '2026-linuxdays/simple.c')
| -rw-r--r-- | 2026-linuxdays/simple.c | 31 |
1 files changed, 31 insertions, 0 deletions
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; +} |
