# Linux Kernel Module Cheat

### 27.2. C

Programs under userland/c/ are examples of ANSI C programming:

- userland/c/empty.c

- userland/c/hello.c

- `main` and environment

  - userland/c/return0.c

  - userland/c/return1.c

  - userland/c/return2.c

  - userland/c/exit0.c

  - userland/c/exit1.c

  - userland/c/exit2.c

  - userland/c/command_line_arguments.c: print one command line argument per line using `argc` and `argv`.

    Good sanity check for user mode: QEMU user mode getting started

- Standard library

  - `assert.h`

    - userland/c/assert_fail.c

  - `stdlib.h`

    - exit

      - userland/c/abort.c

  - `stdio.h`

    - userland/c/getchar.c

    - userland/c/snprintf.c

    - userland/c/stderr.c

    - File IO

      - userland/c/file_write_read.c

        - userland/c/cat.c: a quick and dirty `cat` implementation for interactive User mode simulation tests

      - userland/linux/open_o_tmpfile.c: https://stackoverflow.com/questions/4508998/what-is-an-anonymous-inode-in-linux/44388030#44388030

  - `time.h`

    - userland/c/timespec_get.c `timespec_get` is a C11 for `clock_gettime` http://stackoverflow.com/questions/361363/how-to-measure-time-in-milliseconds-using-ansi-c/36095407#36095407

      Vs `clock()`: http://stackoverflow.com/questions/12392278/measure-time-in-linux-getrusage-vs-clock-gettime-vs-clock-vs-gettimeofday

- Fun

  - userland/c/loop.c

- malloc

- C multithreading

- GCC C extensions