[LLVMdev] How to add a GlobalVariable with type pthread_mutex_t

John McCall rjmccall at apple.com
Wed Jul 21 20:44:30 PDT 2010


On Jul 21, 2010, at 7:52 PM, Guoliang Jin wrote:
> How can I add a GlobalVariable with type pthread_mutex_t into one module?


There's no builtin LLVM abstraction which expands to pthread_mutex_t, so you'll
have to encode its representation somehow:

 - You can run an LLVM-based C frontend (i.e. clang, llvm-gcc, or dragonegg)
   over C code that uses the type, then write code to build up that type manually.
 - You can build up a type based on what you can see in your system headers.
 - If your target is your host system, you can just pretend the type is an
   array of i8s of length sizeof(pthread_mutex_t) and with (say) pointer
   alignment.

John.



More information about the llvm-dev mailing list