Initial
This commit is contained in:
		
						commit
						5069b41630
					
				
					 7 changed files with 69 additions and 0 deletions
				
			
		
							
								
								
									
										2
									
								
								.gitignore
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
										
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,2 @@ | ||||||
|  | *.tar.gz | ||||||
|  | build | ||||||
							
								
								
									
										39
									
								
								Justfile
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								Justfile
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,39 @@ | ||||||
|  | run: build | ||||||
|  |     ./build/main | ||||||
|  | 
 | ||||||
|  | build: mkdir objects | ||||||
|  |     gcc build/*.o -o build/main -O3 | ||||||
|  |     du -h build/main | ||||||
|  | 
 | ||||||
|  | objects: mkdir | ||||||
|  |     cd build && gcc -c -I ../lib -Wall -Werror -fpic ../src/*.c -O3 | ||||||
|  |     du -h build/*.o | ||||||
|  | 
 | ||||||
|  | asm: mkdir | ||||||
|  |     cd build && gcc -S -masm=intel -I ../lib -Wall -Werror -fpic ../src/*.c -O3 | ||||||
|  | 
 | ||||||
|  | release: mkdir build | ||||||
|  |     strip build/main | ||||||
|  |     tar -czvf build.tar.gz build | ||||||
|  | 
 | ||||||
|  | mkdir: | ||||||
|  |     mkdir build -p | ||||||
|  | 
 | ||||||
|  | clean: | ||||||
|  |     rm *.tar.gz -f | ||||||
|  |     rm -rf build | ||||||
|  | 
 | ||||||
|  | hex: build | ||||||
|  |     objdump -M intel -d build/main | ||||||
|  | 
 | ||||||
|  | symbols: build | ||||||
|  |     nm build/main | ||||||
|  | 
 | ||||||
|  | symbols2: build | ||||||
|  |     readelf -s build/main | ||||||
|  | 
 | ||||||
|  | rodata: build | ||||||
|  |     objdump -s -j .rodata build/main | ||||||
|  | 
 | ||||||
|  | fmt: | ||||||
|  |     fd -e c -e h -x clang-format --verbose -i {} | ||||||
							
								
								
									
										3
									
								
								lib/fib.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								lib/fib.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,3 @@ | ||||||
|  | #pragma once | ||||||
|  | 
 | ||||||
|  | int fib(int n); | ||||||
							
								
								
									
										3
									
								
								lib/greet.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								lib/greet.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,3 @@ | ||||||
|  | #pragma once | ||||||
|  | 
 | ||||||
|  | void greet(const char *name); | ||||||
							
								
								
									
										7
									
								
								src/fib.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								src/fib.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,7 @@ | ||||||
|  | #include "fib.h" | ||||||
|  | 
 | ||||||
|  | int fib(int n) { | ||||||
|  |   if (n < 2) | ||||||
|  |     return n; | ||||||
|  |   return fib(n - 1) + fib(n - 2); | ||||||
|  | } | ||||||
							
								
								
									
										8
									
								
								src/greet.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								src/greet.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,8 @@ | ||||||
|  | #include "greet.h" | ||||||
|  | #include "fib.h" | ||||||
|  | #include <stdio.h> | ||||||
|  | 
 | ||||||
|  | void greet(const char *name) { | ||||||
|  |   printf("Hello %s!\n", name); | ||||||
|  |   printf("Fibonacci of 10 is %d\n", fib(10)); | ||||||
|  | } | ||||||
							
								
								
									
										7
									
								
								src/main.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								src/main.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,7 @@ | ||||||
|  | #include "greet.h" | ||||||
|  | #include <stdio.h> | ||||||
|  | 
 | ||||||
|  | int main(void) { | ||||||
|  |   greet("Template"); | ||||||
|  |   return 0; | ||||||
|  | } | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Imbus
						Imbus