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
2 answers

Perl XS : What is the meaning of this dumped value for object - t_obj is - $VAR1 = bless( do{\(my $o = 41032464)}, 'Math::Test1' );

I tried to write the perl code which use C APIs using Perl XS. I was getting the Dump output of object as - t_obj is - $VAR1 = bless( do{(my $o = 41032464)}, 'Math::Test1' ); I wrote the simple library called Math::Test1 for practice though my…
CodeQuestor
  • 881
  • 1
  • 11
  • 25
2
votes
1 answer

How to work with pseudo-filehandles in Perl XS code?

I am trying to write XS glue code for a serialization/deserialization library that is able to work with anything that provides a write(ctx, buffer, count)/read(ctx, buffer, count) interface. I'd like to be able to use pseudo-filehandles that I get…
hillu
  • 9,423
  • 4
  • 26
  • 30
2
votes
2 answers

Linker dependencies when mixing static and shared libraries

I have a following question about linking on Linux: Suppose I have a class Foo that uses Qt. To build this class I'd have to use qmake to generate Makefile. Later on I want to use this class Foo for a Perl module, which is a shared library. However,…
eyevan
  • 1,475
  • 8
  • 20
1
vote
2 answers

How to get threads->tid() value in XS code?

I need to get current perl thread id in a C function inside *.XS part of a perl module. In pure perl (*.pm part) I would simply do: $id = threads->tid(); But what is a recommended way to get this value in XS? Unfortunately…
kmx
  • 7,912
  • 1
  • 15
  • 9
1
vote
2 answers

perl build module with c source from other module

I am working on a module that I would like to have two backends, a Module(::PerlArray) and Module::PDL (which can will depend on Module). Both need access to a functions.c/.h file for building. This file has the rather complicated logic needed for…
Joel Berger
  • 20,180
  • 5
  • 49
  • 104
1
vote
1 answer

Perl: force Spreadsheet::Read to use Text::CSV_XS

I have an 8MB CSV file. Using Spreadsheet::Read it takes 10 seconds to read: my $book = ReadData ( 'file.csv' ); my @rows = Spreadsheet::Read::rows($book->[1]); # first sheet foreach my $i (2 .. scalar @rows) { # ignore first header row my…
h q
  • 1,168
  • 2
  • 10
  • 23
1
vote
0 answers

how to pass perl EV::Loop object to your C library

I need to pass loop object which is contained in perl EV::Loop module (EV::default_loop) to my C library. I have a test library written on C that has a function test that takes struct ev_loop* object as input…
Mjöllnir
  • 11
  • 2
1
vote
0 answers

Embedded Perl FREETMPS not cleaning up array of hash references properly

I have a project with several macros to help me write Perl functions, and basically "convert" C structs into Perl hashes. Some of these hashes nest each other, but I'll get to the point. My program's memory usage rises drastically over time, it's a…
Nekobit
  • 11
  • 1
1
vote
1 answer

How to use perlapi/ XS in an XSUB for array element insertion and removal

I would like to insert and remove elements into an existing Perl array passed into a XSUB. perlapi has av_push, av_pop, av_fetch, av_store and friends for array manipulation. I was hoping for av_insert or av_splice or similar functions, but these…
drclaw
  • 2,463
  • 9
  • 23
1
vote
1 answer

Is it possible to write an XS module when the shared library is already mapped into the process space?

This is on the limits of what I know, please correct any confusion here. In this question I ask why functionality provided by libm isn't already exposed to the user with a Perl interface. Now I want to know how it's done. There is a module on CPAN…
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
1
vote
1 answer

Does perl Inline::C support multiple dependent C files?

This question is based on: Perl: how can I put all my inline C code into a separate file?, but for multiple files. Suppose you want to include C file in perl named foo.c: #include "bar.h" int foo(... As you can see, foo.c depends on bar.h which is…
jinawee
  • 492
  • 5
  • 16
1
vote
0 answers

Unable to build Perl module XString on Windows

I am attempting to build this code on a Windows Server 2019 Datacenter machine. I have Visual Studio 2019 with the Microsoft c++ toolset installed, gcc version 9.2.0 installed via MinGW. Here is the log output from when I run nmake all: Microsoft…
noaoh
  • 127
  • 1
  • 1
  • 7
1
vote
1 answer

Check if array elements are undefined from an XSUB

I am trying to check if an array element is undef from an XSUB like this: void print_array(array) AV *array PREINIT: int len; SV **sv_ptr; SV *sv; int i; CODE: len = av_len(array) + 1; …
Håkon Hægland
  • 39,012
  • 21
  • 81
  • 174
1
vote
1 answer

How to set a Perl environment variable from an XSUB?

I am trying to set a Perl environment variable from an XSUB. I want it to take immediate effect before the XSUB exits. Here is my XS file, Module.xs: #define PERL_NO_GET_CONTEXT #include "EXTERN.h" #include "perl.h" #include "XSUB.h" MODULE =…
Håkon Hægland
  • 39,012
  • 21
  • 81
  • 174
1
vote
3 answers

How to export symbols defined in a C library as Perl constants using XS?

I am working on an XS wrapper module for some functions in the GNU scientific library. Instead of using the library directly here, I have simpilfied the problem by creating my own library: mylib/mylib.h: typedef struct { int foo; double…
Håkon Hægland
  • 39,012
  • 21
  • 81
  • 174
1 2 3
8 9