Island C source file import question, handling C inline functions

Hi @ck thank you for the advice. I’ll try the suggested approach.

P.S. what do you mean “I only added stuff on demand”? Do you meant - you can add a particulary C lib function, upon user request? If so, would it be possible that you might consider adding that function
_byteswap_ulong (for windows), and __builtin_bswap32 (for Linux), to to island rtl?

Once it works, we’d be happy to accept them as contribution to Island RTL.

We added them as we found them so far yes.

Yes. I can add them, but to get past this we really need to have a list of them functions that are needed (and tested), if you can implement them that’d be great, you are in a better position than we are to test this as the semantics of these low level functions aren’t always 100% clear.

Oh I see. Let me try it first, and see if I could contribute my first little piece of code to Island RTL.

1 Like

I took some time looking into Island RTL (for the purpose of learning and see if I am able to contribute)

Then the good news - I found _byteswap_ulong is already part of Island RTL - it was added as committ fb7b1e1c6d3d79dca92e8f9b618366cd18831784 on Apr 25, 2017

Since IslandRTL already has _byteswap_ulong - then why the Header Importer cannot see it? Did I miss anything in the import project setting?

Hmm. does the import project have a reference to Island.fx r or only rtl.fx?

The import project only references libElement

Should I reference Island or/and rtl? I thought they are implicitly referenced? Otherwise the Importer should complain memset/memcpy too, since they are also part of the RTL but the importer didn’t complain any missing symbols of them as part of the C inline functions being inported?

To add extra references, I need to edit the project file directly, right?

I’m not sure. Water should show all the references, implicit and explicit. you can edit references from the ID was you would in any other project.

that said, a new Import project from template has island.fx referenced, so that’s probably not the issue.

image

Hi marc - sorry I mis-informed. The IMPORT project indeed has Island.fx and rtl.fx referenced.
But still the question remains: why the IMPORTER can not see _byteswap_ulong, which is part of IslandRTL?

That I cant tell you, thats Carlos area. I just wanted to rule out anything else before bothering him with this :wink:

@ck?

I think it’s because it’s in ExternalTypes, not as a global method. Moving it out of that as a global method should fix it. I can try that monday.

1 Like

Fixed for the next build.

1 Like

Yes - the importer no longer complains. But the imported C inline functions, does NOT seem to work.

For example the following C inline function (which calls another complex inline function TF_TString_ResizeUninitialized) - it does NOT work. See this test projectInlineImportTest.zip (101.1 KB)

I guess Island Importer has certain limit on the “levels of calling depths”, when importing C Inline functions while those inline functions are calling each other in a convoluted way?

static inline void TF_TString_Copy(TF_TString *dst, const char *src,
                                   size_t size) {
  char *dst_c = TF_TString_ResizeUninitialized(dst, size);

  if (size) memcpy(dst_c, src, size);
}

Thanks, logged as bugs://85839

Maybe. It’s hard to check for me as I have no real idea what these are supposed to do :slight_smile: But i’ll take a look at your testcase.

bugs://85839 got closed with status fixed.

tensorflow_strlen_after_copy  12, it should be 12
tensorflow_str_after_copy 123456789012, it should be 123456789012
1 Like