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
2
votes
1 answer

Perl XS: create and return array of strings (char*) taken from calling a C function or undef on failure

I have Perl XS code which calls a function from an external C library which returns char ** (array of strings). The XS code will eventually return back to Perl an array ref with all the string results in there. Or undef on failure. I have 2…
bliako
  • 977
  • 1
  • 5
  • 16
2
votes
1 answer

How to avoid warning [-Wpointer-sign] of SvPV() versus utf8n_to_uvchr() - bug of XS?

This is the relevant part of XS, which should convert an Perl string from UTF-8 to codepoints (unsigned 32-bit integers): UV * text2UV (SV *sv, STRLEN *lenp) { STRLEN len; // char *str = SvPV(foo_sv, strlen); // char *s = SvPV (sv, len);…
2
votes
1 answer

How to get named matches XS?

So I'm calling C code from inside mid pattern (using (?{ and sometimes (??{) from Perl. Anyway I want to get the values of named captures the same way as using $+{name}. Is this possible?
AnArrayOfFunctions
  • 3,452
  • 2
  • 29
  • 66
2
votes
1 answer

How to tell MakeMaker to add exactly the libraries I want?

I'm using XS to create a Perl Module which uses a C library. For testing purposes, I've created a test library which has two simple functions: void kzA() (does a simple printf) void kzB(int i, char *str) (does a printf of the received…
Kzwix
  • 161
  • 7
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
2 answers

How to encapsulate library handle in Perl XS

I wanted to send/receive MQTT messages from Perl. For various reasons (MQTT 5 support, TLS) I don't want to use existing Perl libraries. So I tried to create XS bindings to Paho MQTT C Library. I somehow adapted provided example to link Perl module…
ico
  • 25
  • 5
2
votes
1 answer

Printing to stdout from a Perl XS extension

I recently started playing around with writing Perl (v5.8.8) extensions using XS. One of the methods I am writing collects a bunch of data and splats it to the client. I want to write some unit tests that make assertions against the output, but I'm…
Nycto
  • 1,670
  • 2
  • 14
  • 18
2
votes
1 answer

Sharing C functions between two XS Perl modues

I have a Perl module A that is a XS based module. I have an A.xs file, and an aux_A.c file, where I have some standard C functions. I use DynaLoader, and it works file. Now, I have a new module B, that is also a XS module. I also have the B.xs file,…
Alberto
  • 499
  • 4
  • 23
2
votes
1 answer

Perl, C, XS - unpack float array

I have Perl Code and C Code and I am calling C functions in my Perl Code. I have passed a float array from Perl to C by packing it (like this http://www.perlmonks.org/?node_id=39697) and it works nicely! my $p_angle = pack("f*", @angle); But now I…
Jen Mer
  • 101
  • 1
  • 3
  • 10
2
votes
1 answer

How to pass C NULL to XS based function?

I am trying to use Crypt::OpenSSL::EC::EC_POINT::mul() function from Crypt::OpenSSL::EC module. It has such C prototype: int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx) And I…
Oleg G
  • 925
  • 4
  • 12
2
votes
1 answer

"…/auto/List/Util/Util.so: undefined symbol: PL_stack_sp at …/XSLoader.pm" only when running test suite with CGI::Test _and_ on Travis CI

I have a Perl module called CGI::Github::Webhook whose test suite works fine on Travis CI so far on the branch master. But since it's a module for writing CGI scripts, I wanted to test it with CGI::Test as this would be closer to real-life…
Axel Beckert
  • 6,814
  • 1
  • 22
  • 23
2
votes
1 answer

Can`t install perl module Crypt::TEA

When I try to install Crypt::TEA module to perl 5.18 on Windows 7, displayed error: TEA.xs: In function 'XS_Crypt__TEA_crypt': TEA.xs:58:9: error: invalid use of void expression
Artem
  • 517
  • 1
  • 7
  • 24
2
votes
0 answers

Makefile.PL check if source directory found

I am using ExtUtils::MakeMaker to create Makefile.PL I added the following function to the makefile.PL to check if source directory is exist sub check_directory { my ($argv) = @_; unless (defined $argv->{'source'} and -d $argv->{'source'}) { …
user3019319
  • 326
  • 3
  • 9
2
votes
3 answers

exposing c function on perl using XS

I have multiple c functions on this format : int function(const char* input, size_t len, char result[]) ; where int is the return type; result[] contains string which the function fill what is the best to write such function as XS and expose it on…
smith
  • 3,232
  • 26
  • 55
2
votes
0 answers

Loading a DLL in Perl

I have a given 32-bit DLL (dds.dll) and a header file (dds.h, C++ style). I do have the source, but I don't want to change it. I'm on Windows using cygwin. I want to access functions in the DLL through XS, not directly through Perl. I am new to…
1 2 3
8 9