Questions tagged [inline-c]

Inline::C is a module that allows you to write Perl subroutines in C.

Inline::C is a module that allows you to write Perl subroutines in C.

12 questions
13
votes
3 answers

Perl Inline C: Passing Arrayref to C Function

I can't get arrayrefs passed into a C function using Inline C. I would like some help, please. First, just to prove I can get Inline C to work, I'll pass a scalar value to a C function: #!/usr/bin/perl -I. # # try1.pl # use Inline C; my $c =…
AndyFroncioni
  • 181
  • 1
  • 8
7
votes
1 answer

Perl Inline::C default flags

I made a module using Inline::C and I noticed some unexpected performance discrepancies between running it on the host MacOS vs a guest Linux VM. Looking into it, it was due to the default C compiler flags being different. On MacOS they appear to…
Ecuador
  • 1,014
  • 9
  • 26
7
votes
1 answer

Perl Inline::C: Are Inline_Stack_Vars etc. needed to avoid memory leaks (biosequence character matching)

My question(s) relates to working inline C code: is it necessary to use the inline stack functions (Inline_Stack_Vars) to pass variables in and out, or is it appropriate in this context to just modify a variable in place? For display of biosequence…
5
votes
2 answers

would it be worth it to use inline::C to speed up math

i have been working on a perl program to process large amounts of dna. It outputs exactly what i need however it takes much longer than i would like using NYTprof i have narrowed down the major problem areas to be the loop that adds my values…
Orion
  • 207
  • 2
  • 9
5
votes
1 answer

How to return a list or array from C block in Haskell's inline-c?

How can I get a list or array from C block in Haskell's inline-c? In other words, how to construct complex data in C and work with it in Haskell. Something like this: foo :: IO [Int] foo = do what? <- [C.block| { ints = calloc(10,…
user933161
4
votes
2 answers

Can Haskell's inline-C return a typedef to a function pointer?

I'm working with a C code base for which typedef void(* wl_notify_func_t) (struct wl_listener *listener, void *data) //... struct wl_listener { struct wl_list link; wl_notify_func_t notify; //<-- I'd like to return this }; and have used the…
George
  • 6,927
  • 4
  • 34
  • 67
3
votes
2 answers

Need to convert Perl unpack to Inline::C AV*

I am struggling a bit to convert a Perl unpack to Inline::C @array = unpack("C*", $buf); This is what I have so far, but I am an Inline::C novice so I am having trouble of what to do next: STRLEN len; char* test = SvPVbyte(buf, len); ... AV* arr =…
Dan Littlejohn
  • 1,329
  • 4
  • 16
  • 30
3
votes
1 answer

How can I force Inline::C to link to an older library?

I'm dealing with a Perl Module that is only compatible with an older version of a shared system library. It just so happens that I have the older version of the library on my system, but I can't figure out how to force Perl's Inline::C to link up…
roosto
  • 843
  • 8
  • 9
2
votes
1 answer

Where is the memory leak in my Perl XS code?

I have a large program written in C++ and executed from Perl using Inline::CPP. The code seems to be using a lot of memory, so I am assuming there is a leak somehow. I have written the following code that reproduces the same issue, but is much…
Coffee'd Up Hacker
  • 1,356
  • 11
  • 23
2
votes
1 answer

Perl Inline::C return pdl or 0 on failure

I am building a module which connects to a camera, takes a picture, and reads the data into a piddle. All of this takes place in an Inline::C command. Using the procedure in the PDL documentation I can create a pdl * and return it. However the…
Joel Berger
  • 20,180
  • 5
  • 49
  • 104
2
votes
1 answer

Why does replacing Perl's s/// with a dummy function using Inline::C cause a significant slow down?

I have an array of strings of about 100,000 elements. I need to iterate through each element and replace some words with other words. This takes a few seconds in pure perl. I need to speed this up as much as I can. I'm testing using the following…
Zippy1970
  • 601
  • 6
  • 20
0
votes
1 answer

Compare 2 arrays of string for matches in C optimization

I am having a perl script that has 2 arrays, 1 with keys and 1 with substring. I need to check if substring of 1 array have matches in the keys array. The amount of records is huge, something that can be counted in millions so I use Inline:C to…
user2360915
  • 1,100
  • 11
  • 30