musllvm

musl and LLVM cross-toolchain build system
git clone https://git.daat.foo/repos/musllvm.git
Log | Files | Refs | README | LICENSE

hello.c (676B)


      1 #include <pthread.h>
      2 #include <stdio.h>
      3 
      4 static volatile unsigned __int128 numerator = (unsigned __int128)1 << 100;
      5 static volatile unsigned __int128 denominator = (unsigned __int128)1 << 40;
      6 
      7 static void *
      8 worker(void *argument)
      9 {
     10 	return argument;
     11 }
     12 
     13 int
     14 main(void)
     15 {
     16 	pthread_t thread;
     17 	void *result;
     18 	int value;
     19 	unsigned __int128 quotient;
     20 
     21 	value = 42;
     22 	quotient = numerator / denominator;
     23 	if (quotient != (unsigned __int128)1 << 60)
     24 		return 1;
     25 	if (pthread_create(&thread, NULL, worker, &value) != 0)
     26 		return 1;
     27 	if (pthread_join(thread, &result) != 0 || result != &value)
     28 		return 1;
     29 	if (puts("musllvm C OK") < 0 || fflush(stdout) == EOF)
     30 		return 1;
     31 	return 0;
     32 }