Page 1 of 1

How to use immintrin.h without malloc and stdlib gcc

Posted: Sat Feb 01, 2025 7:37 am
by rannnnnddiddddd
If I want to use immintrin.h in my hobby os, i get this error:

Code: Select all

gcc/x86_64-elf/14.2.0/include/xmmintrin.h:34
gcc/x86_64-elf/14.2.0/include/immintrin.h:31
gcc/x86_64-elf/14.2.0/include/mm_malloc.h:27:10: fatal error: stdlib.h: No such file or directory
   27 | #include <stdlib.h>
      |          ^~~~~~~~~~
Is there a way to use simd headers without having to implement full stdlib to gcc liking?

Re: How to use immintrin.h without malloc and stdlib gcc

Posted: Sat Feb 01, 2025 8:03 am
by nullplan
Apparently not. I just looked through those headers myself, and saw that including immintrin.h will always include stdlib.h. This header is apparently not meant for freestanding environments. It makes sense given that Linux and most other kernels cannot use SSE in the kernel, and the only other use for a freestanding environment I know is for implementing a libc.

Well, guess you have to just raw-dog the builtins or go with inline assembler.