[LLVMdev] Portable I/O

Michael Ness mike at liquido2.com
Fri Feb 12 14:02:24 PST 2010


Thanks everyone, a set of wrapper routines it will be then.

Dustin, are the routines you wrote open source or do you know if there is 
already a project that provides such a portable interface to libc for LLVM? 
If not, I'll write my own routines, but if there is a way to adopt a common 
standard or avoid reinventing the wheel I'm all for it.

Mike
--------------------------------------------------
From: "Dustin Laurence" <dllaurence at dslextreme.com>
Sent: Friday, February 12, 2010 12:10 PM
To: "LLVM Developers Mailing List" <llvmdev at cs.uiuc.edu>
Subject: Re: [LLVMdev] Portable I/O

> On 02/12/2010 09:51 AM, Chris Lattner wrote:
>
>> I think that the point is that you can define your own standard runtime 
>> interfaces:
>>
>> void *myopen(const char*path) {
>>    return fopen(path, ...);
>> }
>
> Maybe my experience hand-coding LLVM will actually be of some help.
> What I did for this case is what I think Chris is suggesting--I have a
> .c file with functions that return whatever FILE* I need as a void* (I
> think--could have been a char), and a .ll file that declares the
> function as returning an i8*.
>
> Perhaps there is a more sophisticated way, but that seems to work just
> fine.  Basically anything that is not guaranteed to be a symbol the
> linker can see gets a wrapper function written in C.  I think I also did
> this for some of libc's many types (ptrdiff_t and size_t, for example)
> that I shouldn't technically assume anything about.  I didn't *need*
> portability, but I tried to work in that direction anyway.
>
> I have some other tricks, but they depend on the fact that I actually
> run LLVM code through CPP, which I assume most people have too much good
> taste to do.
>
> 7x57
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev 




More information about the llvm-dev mailing list