Questions tagged [xs]

XS is a language extension for Perl that can wrap a C library to make it a Perl library.

The documentation is available at http://perldoc.perl.org/perlxs.html.

The characters "xs" are also a commonly-used name for the XML Schema namespace. Questions about XML Schema should use .

130 questions
4
votes
2 answers

Accessing value stored in a perl object (blessed hash) from XS

I have a perl object (blessed reference to hash) like this. sub funcname { #some code } my $o = My::Class->new(); $o->{internal_data} = \&funcname; #I know it is not nice At other place somewhere in XS code where I have $o reference I need to…
kmx
  • 7,912
  • 1
  • 15
  • 9
4
votes
1 answer

How to pass length of a string argument to CODE section in XS?

In XS I can pass the length of a string argument to a C function using the length keyword: static int foo(const char *s, size_t len) { return 1; } MODULE = Foo PACKAGE = Foo void foo(char *s, STRLEN length(s)) However how can I get the…
manison
  • 649
  • 6
  • 17
4
votes
2 answers

perl xs module writing - Use another function from within same xs file

I'm a beginner in XS and have spent some time looking for this answer on the web with no luck. The problem is that XS changes the name of the function and when it goes to compile, I will get an undefined reference error. For example consider the…
user2074102
4
votes
1 answer

How do I assign an CV to a package with a list of opcodes?

I have been playing with the new parse_block feature in bleadperl, I can parse several statements into a listop, which would generate the tree below: LISTOP (0x1002a00c0) leave [1] OP (0x1002d6220) enter COP (0x1002a0b80) nextstate OP…
rob
  • 41
  • 1
4
votes
1 answer

XS: Passing an external library's function a Perl XS callback

Disclaimer: asked over at perlmonks. I hope I'm describing and depicting my issue properly... In XS, I'm trying to send a callback into an external library's function, where the callback has Perl specific functions. The XSUB is passed as a function…
stevieb
  • 9,065
  • 3
  • 26
  • 36
4
votes
1 answer

C program keeps crashing when calling perl function newSVpv()

Trying to use perl data structure (partially as a way to support associative array in C), but the following program keep crashing. It compiles fine but will crash on the line with newSVpv(). Not sure why. #include /* from…
packetie
  • 4,839
  • 8
  • 37
  • 72
4
votes
0 answers

when should I #define NO_XSLOCKS

NO_XSLOCKS allows the usage of some error checking macros in XS code when combined with #include XSUB.h. However, its use seems to go beyond that. It was recently suggested that I add it to my XS file for better compatibility with ActiveState perl,…
Nate Glenn
  • 6,455
  • 8
  • 52
  • 95
4
votes
3 answers

Testing an XS module that uses Dist::Zilla

I'm working on a Perl module that has a lot of XS code and also uses Dist::Zilla to manage packaging. What's the best way to test things efficiently? I know about dzil test, but that's pretty slow because it does a full build/compile/test cycle…
Ken Williams
  • 22,756
  • 10
  • 85
  • 147
4
votes
0 answers

Sample C program working but existing multi-thread C++ program is aborting in Perl_sv_upgrade in Perl 5.16.0

In Perl 5.16.0 sample C program is working but the existing multi-thread program is aborting in Perl_sv_upgrade. Multi-thread program works fine with Perl 5.8.8. The same code works on Linux and Solaris with Perl 5.16.0. Comparing the sv argument…
yogishaj
  • 705
  • 5
  • 17
3
votes
1 answer

Perl XSPP - multiple definition of std::string

I'm attempting to expose some of the Google URL Library functionality as a perl module. Based on some posts here and elsewhere, it looks like XSPP might be a good place to start. Here's what I've created so far (starting with a compiled version of…
Mike Ellery
  • 2,054
  • 3
  • 21
  • 30
3
votes
0 answers

PerlXS: Possible crash trying to free()

I am seeing subtle crashes, which I think is down to the following XS code: void tiff_ReadRawStrip (tif, strip, size) TIFF *tif uint32_t strip tmsize_t size INIT: void …
DobbyTheElf
  • 604
  • 6
  • 21
3
votes
1 answer

Looking for a way to call Perl XS C API functions/macros from helper functions

I’ve been experimenting with the Perl XS C API and have hit a roadblock. I have simplified my example below. Assuming an existing struct MyObject then to access property “a” or “b” and create a hash for either one I could use the following…
Brian
  • 33
  • 4
3
votes
0 answers

Faking standard input for an XS function

I'm trying to test a function that reads from standard input by redirecting the standard input to read from a file, more or less as advised here Here's the script: use strict; use warnings; use Term::EditLine qw(CC_EOF); use v5.14; my $el =…
jjmerelo
  • 22,578
  • 8
  • 40
  • 86
3
votes
1 answer

deploying xs module on CPAN

i was looking on different xs cpan modules and they didn't contains the actucal source code of the library they are binding , for example on this library https://st.aticpan.org/source/NANIS/Net-Sharktools-0.009/ the xs module…
jsor
  • 637
  • 4
  • 10
3
votes
1 answer

How to use a module from the local library without installing it?

I have an XS module. After building it with ./Build the Module.so is placed into blib/arch/auto/XS directory. In my Module.pm I have: require XSLoader; XSLoader::load( 'Module', $VERSION ); And I run program as: $ perl -Iblib/lib -MModule -e 'my…
Eugen Konkov
  • 22,193
  • 17
  • 108
  • 158
1 2 3
8 9