<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><DIV><SPAN></SPAN></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR><DIV><DIV>On Feb 24, 2008, at 11:24 PM, Evan Cheng wrote:</DIV><BLOCKQUOTE type="cite"><DIV>1. __LTO__ -> LLVM_C_LTO</DIV></BLOCKQUOTE><BLOCKQUOTE type="cite"><DIV style="">3. Rather than using underscore in function names, e.g. lt_foo_bar, use capital letters and also start with prefix LLVM. e.g. LLVMLTOFooBar.</DIV></BLOCKQUOTE><DIV>As we discussed, this is interface is llvm independent.  It may even migrate out of include/llvm-c at some point.</DIV><BR><BLOCKQUOTE type="cite"><DIV>2. Do we need those #include's?</DIV></BLOCKQUOTE>We need stddef.h for size_t and stdbool.h for bool.</DIV><DIV><BR><BLOCKQUOTE type="cite"><DIV>4. <FONT class="Apple-style-span" face="Monaco" size="1"><SPAN class="Apple-style-span" style="font-size: 9px;">lto_codegen_release -> lto_codegen_release_memory to be clearer and more consistent.</SPAN></FONT></DIV></BLOCKQUOTE><DIV>Renamed to lto_codegen_dispose()</DIV><BR><BLOCKQUOTE type="cite"><DIV>5. Use C comments /* ... */?</DIV></BLOCKQUOTE>Fixed.</DIV><DIV><BR><BLOCKQUOTE type="cite"><DIV>6. Please start comments with capital letters and end sentences with periods! Or perhaps not since it'll drive Chris nuts. :-)</DIV></BLOCKQUOTE></DIV>Fixed.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><BR><DIV><DIV>On Feb 24, 2008, at 6:10 PM, Gordon Henriksen wrote:</DIV><BLOCKQUOTE type="cite"><DIV><DIV><BLOCKQUOTE type="cite"><DIV style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><DIV><SPAN class="Apple-style-span" style="-webkit-text-stroke-width: -1; "><FONT class="Apple-style-span" color="#004FAF" face="Monaco" size="1"><SPAN class="Apple-style-span" style="background-color: transparent; font-size: 9px;">#include <stdint.h></SPAN></FONT></SPAN></DIV><DIV><DIV><FONT class="Apple-style-span" face="Monaco" size="1"><SPAN class="Apple-style-span" style="font-size: 9px;">#include <stdbool.h></SPAN></FONT></DIV></DIV></DIV></BLOCKQUOTE><DIV><FONT class="Apple-style-span" color="#000000"><SPAN class="Apple-style-span" style="background-color: transparent;"><BR class="webkit-block-placeholder"></SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" color="#000000"><SPAN class="Apple-style-span" style="background-color: transparent;">Note that MSVC++ still doesn't support C99, and is a target for LLVM. I'd suggest </SPAN><FONT class="Apple-style-span" color="#000000" face="Monaco" size="1"><SPAN class="Apple-style-span" style="background-color: transparent; font-size: 9px;">bool</SPAN></FONT><SPAN class="Apple-style-span" style="background-color: transparent;"> -> </SPAN><FONT class="Apple-style-span" color="#000000" face="Monaco" size="1"><SPAN class="Apple-style-span" style="background-color: transparent; font-size: 9px;">int</SPAN></FONT><SPAN class="Apple-style-span" style="background-color: transparent;"> and </SPAN><FONT class="Apple-style-span" color="#000000" face="Monaco" size="1"><SPAN class="Apple-style-span" style="background-color: transparent; font-size: 9px;">uint8_t*</SPAN></FONT><FONT class="Apple-style-span" color="#000000" face="Monaco" size="1"><SPAN class="Apple-style-span" style="background-color: transparent; font-size: 9px;"><SPAN class="Apple-style-span" style="font-family: 'Trebuchet MS'; font-size: 12px; "> -> </SPAN>void*</SPAN></FONT><SPAN class="Apple-style-span" style="background-color: transparent;"> to resolve the dependency.</SPAN></FONT></DIV></DIV></DIV></BLOCKQUOTE><DIV>I've change all the uint8_t to void.  I'm going to leave the use of bool.  The implementation of lto is all in C++, so it will build with MSVC++.  The only thing that might get tripped up by the use of bool in the interface is if someone tries to write a C (not C++) client (meaning a linker) using MSVC.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><BLOCKQUOTE type="cite"><DIV><DIV><BLOCKQUOTE type="cite"><DIV style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><DIV><DIV><FONT class="Apple-style-span" face="Monaco" size="1"><SPAN class="Apple-style-span" style="font-size: 9px;">#include <stddef.h></SPAN></FONT></DIV></DIV></DIV></BLOCKQUOTE><BLOCKQUOTE type="cite"><BR></BLOCKQUOTE><BLOCKQUOTE type="cite"><DIV style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><DIV><DIV><SPAN class="Apple-style-span" style="-webkit-text-stroke-width: -1; "><FONT class="Apple-style-span" color="#004FAF" face="Monaco" size="1"><SPAN class="Apple-style-span" style="background-color: transparent; font-size: 9px;">extern const char*</SPAN></FONT></SPAN></DIV><DIV><FONT class="Apple-style-span" face="Monaco" size="1"><SPAN class="Apple-style-span" style="font-size: 9px;">lto_get_error_message();</SPAN></FONT></DIV></DIV></DIV></BLOCKQUOTE><DIV style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><DIV><DIV><FONT class="Apple-style-span" color="#000000"><SPAN class="Apple-style-span" style="background-color: transparent;"><BR class="webkit-block-placeholder"></SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" color="#000000"><SPAN class="Apple-style-span" style="background-color: transparent;">I've tried not to create thread-unsafe designs in the rest of the bindings. I return a malloced error message by optional output parameters and provide a generic dispose function (<FONT class="Apple-style-span" face="Monaco" size="1"><SPAN class="Apple-style-span" style="font-size: 9px;">LLVMDisposeMessage</SPAN></FONT>). Copying <FONT class="Apple-style-span" face="Monaco" size="1"><SPAN class="Apple-style-span" style="font-size: 9px;">CFError</SPAN></FONT>'s design might be smarter still.</SPAN></FONT></DIV></DIV></DIV></DIV></DIV></BLOCKQUOTE><DIV>There are other things not thread safe about the API.  Adding a string return would complicate the API.  And it is possible to make the API thread safe in the future by making lto_get_error_message() return a per-thread string.  </DIV><DIV><BR class="khtml-block-placeholder"></DIV><BR><BLOCKQUOTE type="cite"><DIV><DIV><DIV style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><DIV><DIV><FONT class="Apple-style-span" color="#000000"><SPAN class="Apple-style-span" style="background-color: transparent;"><BR class="webkit-block-placeholder"></SPAN></FONT></DIV></DIV></DIV><BLOCKQUOTE type="cite"><DIV style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><DIV><DIV><SPAN class="Apple-style-span" style="-webkit-text-stroke-width: -1; "><FONT class="Apple-style-span" color="#004FB0" face="Monaco" size="1"><SPAN class="Apple-style-span" style="background-color: transparent; font-size: 9px;">extern bool</SPAN></FONT></SPAN></DIV><DIV><FONT class="Apple-style-span" color="#004FAF" face="Monaco" size="1"><SPAN class="Apple-style-span" style="background-color: transparent; font-size: 9px;">lto_module_is_object_file_in_memory(const uint8_t* mem, size_t length);</SPAN></FONT></DIV></DIV></DIV></BLOCKQUOTE><DIV style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><DIV><DIV><BLOCKQUOTE type="cite"><FONT class="Apple-style-span" color="#004FAF" face="Monaco" size="1"><SPAN class="Apple-style-span" style="background-color: transparent; font-size: 9px;"><BR class="webkit-block-placeholder"></SPAN></FONT></BLOCKQUOTE><BLOCKQUOTE type="cite"><DIV><SPAN class="Apple-style-span" style="-webkit-text-stroke-width: -1; "><FONT class="Apple-style-span" color="#004FAF" face="Monaco" size="1"><SPAN class="Apple-style-span" style="background-color: transparent; font-size: 9px;">extern bool</SPAN></FONT></SPAN></DIV><DIV><FONT class="Apple-style-span" color="#004FAF" face="Monaco" size="1"><SPAN class="Apple-style-span" style="background-color: transparent; font-size: 9px;">lto_module_is_object_file_in_memory_for_target(const uint8_t* mem, size_t length, </SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" color="#004FAF" face="Monaco" size="1"><SPAN class="Apple-style-span" style="background-color: transparent; font-size: 9px;">                                               const char* target_triplet_prefix);</SPAN></FONT></DIV></BLOCKQUOTE><BLOCKQUOTE type="cite"><FONT class="Apple-style-span" color="#004FAF" face="Monaco" size="1"><SPAN class="Apple-style-span" style="background-color: transparent; font-size: 9px;"><BR></SPAN></FONT></BLOCKQUOTE><BLOCKQUOTE type="cite"><DIV style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><DIV><DIV><SPAN class="Apple-style-span" style="-webkit-text-stroke-width: -1; "><FONT class="Apple-style-span" color="#004FAF" face="Monaco" size="1"><SPAN class="Apple-style-span" style="background-color: transparent; font-size: 9px;">extern lto_module_t</SPAN></FONT></SPAN></DIV><DIV><FONT class="Apple-style-span" color="#004FAF" face="Monaco" size="1"><SPAN class="Apple-style-span" style="background-color: transparent; font-size: 9px;">lto_module_create_from_memory(const uint8_t* mem, size_t length);</SPAN></FONT></DIV></DIV></DIV></BLOCKQUOTE><DIV style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><DIV></DIV></DIV><DIV><FONT class="Apple-style-span" face="Monaco" size="1"><BR class="webkit-block-placeholder"></FONT></DIV></DIV><DIV><FONT class="Apple-style-span" color="#000000"><SPAN class="Apple-style-span" style="background-color: transparent;">Why not </SPAN><FONT class="Apple-style-span" color="#000000" face="Monaco" size="1"><SPAN class="Apple-style-span" style="background-color: transparent; font-size: 9px;">void*</SPAN></FONT><SPAN class="Apple-style-span" style="background-color: transparent;">? Saves casting.</SPAN></FONT></DIV></DIV></DIV></DIV></DIV></BLOCKQUOTE><DIV>Fixed.</DIV><BR><BLOCKQUOTE type="cite"><DIV><DIV><DIV style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><DIV><DIV><BLOCKQUOTE type="cite"><SPAN class="Apple-style-span" style="-webkit-text-stroke-width: -1; "><DIV><FONT class="Apple-style-span" face="Monaco" size="1">//</FONT></DIV><DIV><FONT class="Apple-style-span" face="Monaco" size="1">// generates code for all added modules into one object file</FONT></DIV><DIV><FONT class="Apple-style-span" face="Monaco" size="1">// On sucess returns a pointer to a generated mach-o buffer and</FONT></DIV><DIV><FONT class="Apple-style-span" face="Monaco" size="1">// length set to the buffer size.  Client must free() the buffer</FONT></DIV><DIV><FONT class="Apple-style-span" face="Monaco" size="1">// when done.</FONT></DIV><DIV><FONT class="Apple-style-span" face="Monaco" size="1">// On failure, returns NULL (check lto_get_error_message() for details)</FONT></DIV><DIV><FONT class="Apple-style-span" face="Monaco" size="1">//</FONT></DIV></SPAN><DIV><FONT class="Apple-style-span" face="Monaco" size="1">extern const uint8_t*</FONT></DIV><DIV><FONT class="Apple-style-span" face="Monaco" size="1">lto_codegen_compile(lto_code_gen_t cg, size_t* length);</FONT></DIV></BLOCKQUOTE><BR></DIV><DIV>The return value should be non-const. <FONT class="Apple-style-span" face="Monaco" size="1"><SPAN class="Apple-style-span" style="font-size: 9px;">free</SPAN></FONT> takes a <FONT class="Apple-style-span" face="Monaco" size="1"><SPAN class="Apple-style-span" style="font-size: 9px;">void*</SPAN></FONT>, not a <FONT class="Apple-style-span" color="#000000" face="Monaco" size="1"><SPAN class="Apple-style-span" style="background-color: transparent; font-size: 9px;">const void*</SPAN></FONT>.</DIV></DIV></DIV></DIV></DIV></BLOCKQUOTE><DIV>Fixed.</DIV><BR><BLOCKQUOTE type="cite"><DIV><DIV><DIV style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><DIV></DIV></DIV><BLOCKQUOTE type="cite"><DIV style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><DIV><DIV><SPAN class="Apple-style-span" style="-webkit-text-stroke-width: -1; "><FONT class="Apple-style-span" color="#004FAF" face="Monaco" size="1"><SPAN class="Apple-style-span" style="background-color: transparent; font-size: 9px;">extern const char*</SPAN></FONT></SPAN></DIV></DIV></DIV></BLOCKQUOTE><DIV style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><DIV><DIV><BLOCKQUOTE type="cite"><DIV><FONT class="Apple-style-span" color="#004FAF" face="Monaco" size="1">lto_module_get_target_triplet(lto_module_t mod);</FONT></DIV></BLOCKQUOTE></DIV></DIV></DIV><BR><DIV style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><DIV><DIV><FONT class="Apple-style-span" color="#000000"><SPAN class="Apple-style-span" style="background-color: transparent;">LLVM nomenclature is triple, not triplet.</SPAN></FONT></DIV></DIV></DIV></DIV></DIV></BLOCKQUOTE><DIV>Fixed.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><BR><BLOCKQUOTE type="cite"><DIV><DIV><DIV style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><DIV><DIV><FONT class="Apple-style-span" color="#000000"><SPAN class="Apple-style-span" style="background-color: transparent;"><BR class="webkit-block-placeholder"></SPAN></FONT></DIV></DIV></DIV><BLOCKQUOTE type="cite"><DIV style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><DIV><DIV><SPAN class="Apple-style-span" style="-webkit-text-stroke-width: -1; "><FONT class="Apple-style-span" color="#004FAF" face="Monaco" size="1"><SPAN class="Apple-style-span" style="background-color: transparent; font-size: 9px;">extern uint32_t</SPAN></FONT></SPAN></DIV><DIV><FONT class="Apple-style-span" color="#004FAF" face="Monaco" size="1"><SPAN class="Apple-style-span" style="background-color: transparent; font-size: 9px;">lto_module_get_num_symbols(lto_module_t mod);</SPAN></FONT></DIV></DIV></DIV></BLOCKQUOTE><DIV style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><DIV><DIV><BLOCKQUOTE type="cite"><FONT class="Apple-style-span" color="#004FAF" face="Monaco" size="1"><SPAN class="Apple-style-span" style="background-color: transparent; font-size: 9px;"><BR class="webkit-block-placeholder"></SPAN></FONT></BLOCKQUOTE><BLOCKQUOTE type="cite"><DIV><SPAN class="Apple-style-span" style="-webkit-text-stroke-width: -1px; "><FONT class="Apple-style-span" color="#004FAF" face="Monaco" size="1"><SPAN class="Apple-style-span" style="background-color: transparent; font-size: 9px;">extern const char*</SPAN></FONT></SPAN></DIV><DIV><FONT class="Apple-style-span" color="#004FAF" face="Monaco" size="1"><SPAN class="Apple-style-span" style="background-color: transparent; font-size: 9px;">lto_module_get_symbol_name(lto_module_t mod, uint32_t index);</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" color="#004FAF" face="Monaco" size="1"><SPAN class="Apple-style-span" style="background-color: transparent; font-size: 9px;"><BR class="webkit-block-placeholder"></SPAN></FONT></DIV><DIV><SPAN class="Apple-style-span" style="-webkit-text-stroke-width: -1px; "><FONT class="Apple-style-span" color="#004FAF" face="Monaco" size="1"><SPAN class="Apple-style-span" style="background-color: transparent; font-size: 9px;">extern lto_symbol_attributes</SPAN></FONT></SPAN></DIV><DIV><FONT class="Apple-style-span" color="#004FAF" face="Monaco" size="1"><SPAN class="Apple-style-span" style="background-color: transparent; font-size: 9px;">lto_module_get_symbol_attribute(lto_module_t mod, uint32_t index);</SPAN></FONT></DIV></BLOCKQUOTE></DIV><DIV><FONT class="Apple-style-span" color="#000000"><SPAN class="Apple-style-span" style="background-color: transparent;"><BR class="webkit-block-placeholder"></SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" color="#000000"><SPAN class="Apple-style-span" style="background-color: transparent;">Why <FONT class="Apple-style-span" face="Monaco" size="1"><SPAN class="Apple-style-span" style="font-size: 9px;">uint32_t</SPAN></FONT> instead of <FONT class="Apple-style-span" face="Monaco" size="1"><SPAN class="Apple-style-span" style="font-size: 9px;">size_t</SPAN></FONT>?</SPAN></FONT></DIV></DIV></DIV></DIV></DIV></BLOCKQUOTE><DIV>I changed it to unsigned int.  It is not pointer size dependent.</DIV><BR><BLOCKQUOTE type="cite"><DIV><DIV><DIV style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><DIV><DIV><FONT class="Apple-style-span" color="#000000"><SPAN class="Apple-style-span" style="background-color: transparent;"><BR class="webkit-block-placeholder"></SPAN></FONT></DIV></DIV></DIV><BLOCKQUOTE type="cite"><DIV style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><DIV><DIV><SPAN class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">//</SPAN></DIV><DIV><FONT class="Apple-style-span" face="Monaco" size="1"><SPAN class="Apple-style-span" style="font-size: 9px;">// frees all memory for a code generator</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Monaco" size="1"><SPAN class="Apple-style-span" style="font-size: 9px;">// upon return the lto_code_gen_t is no longer valid</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Monaco" size="1"><SPAN class="Apple-style-span" style="font-size: 9px;">//</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Monaco" size="1"><SPAN class="Apple-style-span" style="font-size: 9px;">extern void</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Monaco" size="1"><SPAN class="Apple-style-span" style="font-size: 9px;">lto_codegen_release(lto_code_gen_t);</SPAN></FONT></DIV></DIV></DIV></BLOCKQUOTE><DIV style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><DIV><DIV><FONT class="Apple-style-span" color="#000000"><SPAN class="Apple-style-span" style="background-color: transparent;"><BR class="webkit-block-placeholder"></SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" color="#000000"><SPAN class="Apple-style-span" style="background-color: transparent;">Existing bindings use the term dispose to avoid any possible retain/release confusion.</SPAN></FONT></DIV></DIV></DIV></DIV></DIV></BLOCKQUOTE>Changed both _release functions to _dispose.<BR></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>-Nick</DIV><DIV><BR class="khtml-block-placeholder"></DIV></BODY></HTML>