How to use immintrin.h without malloc and stdlib gcc

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
rannnnnddiddddd
Posts: 3
Joined: Fri Dec 20, 2024 7:30 pm

How to use immintrin.h without malloc and stdlib gcc

Post 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?
nullplan
Member
Member
Posts: 1840
Joined: Wed Aug 30, 2017 8:24 am

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

Post 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.
Carpe diem!
Post Reply