# Using LLVM libc

&#x20;`libc` is supported by Valida. This `libc` is a version of [LLVM `libc`](https://libc.llvm.org/). Nothing special needs to be done in order to make use of the included `libc`. The compiler knows how to find the `libc` header files and binaries by default.

There is an example in the release bundle, `examples/c/cat-alpha.c`, which makes use of this `libc`. This example echoes all of the alphabetic characters in its input. It makes use of the `libc` function `isalpha`. The following commands should compile and run this example:

```bash
clang -target valida /valida-toolchain/examples/c/cat-alpha.c -o cat-alpha
valida run cat-alpha log
```

Other C programs using `libc` may be compilable following this pattern, as well.

The following header files are available, and contain the following declarations and macro definitions:

* `ctype.h`
  * `int isalnum(int)`
  * `int isalpha(int)`
  * `int isblank(int)`
  * `int iscntrl(int)`
  * `int isdigit(int)`
  * `int isgraph(int)`
  * `int islower(int)`
  * `int isprint(int)`
  * `int ispunct(int)`
  * `int isspace(int)`
  * `int isupper(int)`
  * `int isxdigit(int)`
  * `int tolower(int)`
  * `int toupper(int)`
* `errno.h`
  * `ERFKILL`
  * `EOWNERDEAD`
  * `EHWPOISON`
  * `ECANCELED`
  * `ENOTSUP`
  * `ENOTRECOVERABLE`
* `inttypes.h`
  * `intmax_t imaxabs(intmax_t)`
  * `imaxdiv_t imaxdiv(intmax_t, intmax_t)`
  * `intmax_t strtoimax(const char *, char **, int)`
  * `uintmax_t strtoumax(const *, char **, int)`
* `math.h`
  * `double fabs(double)`
  * `float fabsf(float)`
  * `long double fabsl(long double)`
  * `double fdim(double, double)`
  * `float fdimf(float, float)`
  * `long double fdiml(long double, long double)`
  * `double fmax(double, double)`
  * `float fmaxf(float, float)`
  * `long double fmaxl(long double, long double)`
  * `double fmin(double, double)`
  * `float fminf(float, float)`
  * `long double fminl(long double, long double)`
* `stdio.h`
  * `int putchar(int)`
  * `int getchar(void)`
* `stdlib.h`
  * `int abs(int)`
  * `int atoi(const char *)`
  * `long atol(const char *)`
  * `void *bsearch(const void *, const void *, size_t, size_t, __bsearchcompare_t)`
  * `div_t div(int, int)`
  * `long labs(long)`
  * `ldiv_t ldiv(long, long)`
  * `long long llabs(long long)`
  * `lldiv_t lldiv(long long, long long)`
  * `void qsort(void *, size_t, size_t, __qsortcompare_t)`
  * `long strtol(const char *, char **, int)`
  * `unsigned long strtoul(const char *, char **, int)`
  * `unsigned long long strtoull(const char *, char **, int)`
  * `void *malloc(size_t)`
  * `void *malloc_wrapped(size_t)`
  * `void *callc(size_t, size_t)`
  * `void *aligned_alloc(size_t, size_t)`
  * `void *realloc(void*, size_t)`
  * `void free(void *)`
  * `int rand(void)`
  * `int putchar(int)`
  * `int getchar()`
* `string.h`
  * `void *memchr(const void *, int, size_t)`
  * `int memcmp(const void *, const void *, size_t)`
  * `void *memcpy(void *, const void *, size_t)`
  * `void *memmove(void *, const void *, size_t)`
  * `void *memset(void *, int, size_t)`
  * `void *strcat(char *, const char *)`
  * `char *strchr(const char *, int)`
  * `int strcmp(const char *, const char *)`
  * `char *strcpy(char *, const char *)`
  * `size_t strcspn(const char *, const char *)`
  * `size_t strlen(const char *)`
  * `char *strncat(char *, const char *, size_t)`
  * `int strncmp(const char *, const char *, size_t)`
  * `char *strncpy(char *, const char *, size_t)`
  * `char *strpbrk(const char *, const char *)`
  * `char *strrchr(const char *, int)`
  * `size_t strspn(const char *, const char *)`
  * `char *strstr(const char *, const char *)`
  * `char *strtok(char *, const char *)`
* `strings.h`
