view release on metacpan or search on metacpan
dyncall/dyncall/gen-masm.sh
dyncall/dyncall/mkfile
dyncall/dyncallback/CMakeLists.txt
dyncall/dyncallback/DynCallbackConfig.cmake
dyncall/dyncallback/Makefile.embedded
dyncall/dyncallback/Makefile.generic
dyncall/dyncallback/Nmakefile
dyncall/dyncallback/dyncall_alloc_wx.c
dyncall/dyncallback/dyncall_alloc_wx.h
dyncall/dyncallback/dyncall_alloc_wx_malloc.c
dyncall/dyncallback/dyncall_alloc_wx_mmap.c
dyncall/dyncallback/dyncall_alloc_wx_win32.c
dyncall/dyncallback/dyncall_args.c
dyncall/dyncallback/dyncall_args.h
dyncall/dyncallback/dyncall_args_arm32.c
dyncall/dyncallback/dyncall_args_arm32.h
dyncall/dyncallback/dyncall_args_arm64.c
dyncall/dyncallback/dyncall_args_arm64_apple.c
dyncall/dyncallback/dyncall_args_mips.c
dyncall/dyncallback/dyncall_args_mips.h
dyncall/dyncallback/dyncall_args_mips64.c
eg/Cookbook/swap.pl
eg/Cookbook/win32_messagebox.pl
eg/Cookbook/xor_cipher.c
eg/Cookbook/xor_cipher.pl
eg/benchmark.pl
eg/unix_math.pl
eg/win32_msgbox.pl
eg/win32_screenres.pl
lib/Affix.pm
lib/Affix.xs
lib/typemap
minil.toml
t/00_compile.t
t/01_types_and_pointers.t
t/02_affix_wrap_sin.t
t/06_affix_synopsis.t
t/07_affix_locate_lib.t
t/41_affix_argless.t
t/42_affix_simple_args.t
t/43_affix_simple_returns.t
t/44_affix_aggr_args.t
builder/Affix.pm view on Meta::CPAN
# }
#}
#print $response->{content} if length $response->{content};
# https://dyncall.org/r1.2/dyncall-1.2-windows-xp-x64-r.zip
# https://dyncall.org/r1.2/dyncall-1.2-windows-xp-x86-r.zip
# https://dyncall.org/r1.2/dyncall-1.2-windows-10-arm64-r.zip
if ( $opt{config}->get('osname') eq 'MSWin32' ) { # Use prebuilt libs on Windows
my $x64 = $opt{config}->get('ptrsize') == 8;
my $plat = $x64 ? '64' : '86';
my %versions;
for my $url ( map { 'https://dyncall.org/' . $_ }
$response->{content}
=~ m[href="(.+/dyncall-\d\.\d+\-windows-xp-x${plat}(?:-r)?\.zip)"]g ) {
my ($version) = $url =~ m[-(\d+\.\d+)-windows];
$versions{$version} = $url;
}
for my $version ( reverse sort keys %versions ) {
$libver //= $version;
#printf "%s %s => %s\n", ($pick eq $version ? '*': ' '), $version, $versions{$version};
}
builder/Affix.pm view on Meta::CPAN
}
}
}
else {
die sprintf 'Failed to download %s: %s!', $response->{url}, $response->{content}
unless $response->{success};
}
}
else { # Build from source on all other platforms
my %versions;
for my $url ( map { 'https://dyncall.org/' . $_ }
$response->{content} =~ m[href="(.+/dyncall-\d\.\d+\.tar\.gz)"]g ) {
my ($version) = $url =~ m[/r(\d\.\d+)/];
$versions{$version} = $url;
}
for my $version ( reverse sort keys %versions ) {
$libver //= $version;
#printf "%s %s => %s\n", ($pick eq $version ? '*': ' '), $version, $versions{$version};
}
my $filename = Path::Tiny->new( $versions{$libver} )->basename;
builder/Affix.pm view on Meta::CPAN
File::Find::find( sub { push @ret, $File::Find::name if /$pattern/ && -f }, $dir ) if -d $dir;
return @ret;
}
my %actions = (
build => sub {
my %opt = @_;
for my $pl_file ( find( qr/\.PL$/, 'lib' ) ) {
( my $pm = $pl_file ) =~ s/\.PL$//;
system $^X, $pl_file, $pm and die "$pl_file returned $?\n";
}
my %modules = map { $_ => catfile( 'blib', $_ ) } find( qr/\.p(?:m|od)$/, 'lib' );
my %scripts = map { $_ => catfile( 'blib', $_ ) } find( qr//, 'script' );
my %shared = map {
$_ => catfile( qw/blib lib auto share dist/, $opt{meta}->name, abs2rel( $_, 'share' ) )
} find( qr//, 'share' );
pm_to_blib( { %modules, %scripts, %shared }, catdir(qw/blib lib auto/) );
make_executable($_) for values %scripts;
mkpath( catdir(qw/blib arch/), $opt{verbose} );
alien(%opt);
process_xs( $_, %opt ) for find( qr/.xs$/, 'lib' );
if ( $opt{install_paths}->install_destination('bindoc') &&
$opt{install_paths}->is_default_installable('bindoc') ) {
manify(
builder/Affix.pm view on Meta::CPAN
return 0;
},
test => sub {
my %opt = @_;
die "Must run `./Build build` first\n" if not -d 'blib';
require TAP::Harness::Env;
my %test_args = (
( verbosity => $opt{verbose} ) x !!exists $opt{verbose},
( jobs => $opt{jobs} ) x !!exists $opt{jobs},
( color => 1 ) x !!-t STDOUT,
lib => [ map { rel2abs( catdir( qw/blib/, $_ ) ) } qw/arch lib/ ],
);
my $tester = TAP::Harness::Env->create( \%test_args );
return $tester->runtests( sort +find( qr/\.t$/, 't' ) )->has_errors;
},
install => sub {
my %opt = @_;
die "Must run `./Build build` first\n" if not -d 'blib';
install( $opt{install_paths}->install_map, @opt{qw/verbose dry_run uninst/} );
return 0;
},
clean => sub {
my %opt = @_;
rmtree( $_, $opt{verbose} ) for qw/blib temp/;
return 0;
},
realclean => sub {
my %opt = @_;
rmtree( $_, $opt{verbose} ) for qw/blib temp Build _build_params MYMETA.yml MYMETA.json/;
dyncall/ChangeLog view on Meta::CPAN
o fixed status codes of some tests to actually depend on results (for consistency and automation)
Version 1.2 (2021/01/23)
dyncall:
o windows arm64 support (thanks Bernhard!)
o extended signature with more chars for calling convention switching (only for modes
that coexist on a platform with other conventions)
o made "formatted" call interface use calling convention signature chars
o added helper function dcGetModeFromCCSigChar() mapping callconv sig chars to respective mode
o removed some unnecessary headers (only contained internal used forward declarations)
o build fix when using clang's integrated assembler on non-Darwin PPC32 platforms
dyncallback:
o windows arm64 support (thanks Bernhard!)
o build fix when using clang's integrated assembler on non-Darwin PPC32 platforms
dynload:
o fix to build with musl libc
o support for loading macos >= 11.0.1 (Big Sur) dylibs provided by system's "built-in dynamic
linker cache of all system-provided libraries" (those dylibs are no longer present on the fs)
o fix to work on recent Haiku versions (r1 beta versions)
dyncall/ChangeLog view on Meta::CPAN
o MIPS n64 ellipsis call fixes
o ARM32 armhf ellipsis call fixes
o fixed ARM32-THUMB stack alignment issues (found on Cortex-m0, thanks Darren Whobrey!)
o better C++ compiler support (for pointer conversions)
dyncallback:
o PPC64 single-precision float fixes for more than 13 float args (thanks Masanori Mitsugi!)
o MIPS o32 (big- and little-endian), EABI (32 bit, little-endian) and n64 (big-endian) support
o SPARC32 (v7/v8) support
o SPARC64 (v9) support
o PPC32 fixes for (old) Darwin/OS X systems
o POSIX compliance: fallback for wx alloc on systems that don't have mmap()'s MAP_ANON
o allocated space used for thunk now always W^X (req. for e.g. OpenBSD >= 6.0)
dynload:
o major reliability/stability fixes for Mach-O dlSyms* functions to (thanks Stéphane Mons for help):
better handle loading dylibs by symlink, relative path, random casing, etc.
fixes to symbol name lookups that used wrong offsets before
64-bit platform fixes (was broken on x64 and never supported on others)
o allowing Mach-O dlSyms* lib to be used standalone (consistent with ELF and PE impls now)
o simplifications of implemention on Darwin, sharing parts with *nix implementation
o potentially breaking change on macos/Darwin platforms: all functions now consistently accept or
return symbol names as they would appear in C code, instead of the raw ones in object files
dyncall/ToDo view on Meta::CPAN
- fix for NDS:
* ARM:
- callback_plain retval wrong (not only platform), area on stack where
it's stored is probably not zeroed, so half-words, etc., come with garbage
* THUMB:
- ellipsis (might be test itself, not respecting fixed part of args)
- callback_plain retval, see above under ARM
- callf
- support Solaris11 CFLAGS with -D_FILE_OFFSET_BITS=64
- make sure selinux works (esp. regarding NX bits)
Daniel has a patch for it, if needed, implementing allocwx with two memory blocks, one for w^x, mmaped to one for r|x
- support /SAFESEH on cl/win32
- test code functions should be in .so files, optionally, so the suites can directly be used to test dyncall bindings
- pkg-config support?
- add tests using alloca(), as this might depend on the frame pointer being correctly set (we don't
check for this, currently, at all - but might not affect dyncall's stubs, anyways) - verify
portasm:
--------
- add solaris support for x64
dyncall/ToDo view on Meta::CPAN
- investigate issue where if dlGetLibraryPath() is called from within a .so,
passing NULL will return .so name, whereas passing result of
dlLoadLibrary(NULL) returns process' name
- dlGetLibraryPath: dl_iterate_phdr() used on OpenBSD, but not available on version < 3.7
- bug: test/nm crashes on qemu mips linux o32 debian etch
- rename SymsInit to InitSyms and similar for cleanup function to reflect naming
in dyncall
- get rid of Dl_info and friends (_GNU_SOURCE) in dynload/dynload_syms_elf.c
for implementation of dlSymsNameFromValue(..)
- check if PSP can support dynload (missing elf.h, dlfcn.h, etc.); fixup readme if successful
- some functionality like java's System.mapLibraryName('name') might be helpful?
- Failed On Open Solaris 11:
In file included from dynload_syms.c:28:
dynload_syms_elf.c:56: error: syntax error before "Elf_Dyn"
dynload_syms_elf.c:56: warning: data definition has no type or storage class
dynload_syms_elf.c: In function `dlSymsInit':
dynload_syms_elf.c:155: error: `pDyn' undeclared (first use in this function)
dynload_syms_elf.c:155: error: (Each undeclared identifier is reported only once
dynload_syms_elf.c:155: error: for each function it appears in.)
dynload_syms_elf.c:155: error: syntax error before ')' token
dynload_syms_elf.c:160: error: `DT_NULL' undeclared (first use in this function)
dyncall/doc/disas_examples/arm64.aapcs.disas view on Meta::CPAN
; return b.j + b.k + b.m + s.x;
; }
; output from freebsd-13.0_r348764-arm64 w/ clang 8.0.0
0000000000000000 f0:
0: ff 83 00 d1 sub sp, sp, #32 ; |
4: fe 0b 00 f9 str x30, [sp, #16] ; | prolog
8: 08 00 00 90 adrp x8, #0 ; compute addr to storage map (probably to #132)
c: 08 01 00 91 add x8, x8, #0 ; addr offset (pointless)
10: e2 03 40 b2 orr x2, xzr, #0x1 ; @@@ unsure, #1 -> x2
14: e9 3f 00 91 add x9, sp, #15 ; addr to #132 -> x9 @@@?
18: e0 03 09 aa mov x0, x9 ; @@@ unsure
1c: e1 03 08 aa mov x1, x8 ; @@@ unsure
20: e9 03 00 f9 str x9, [sp] ; store addr to #132 to top of stack
24: 00 00 00 94 bl #0 <f0+0x24> ; @@@unsure
28: e8 03 40 f9 ldr x8, [sp] ; *sp -> x8
2c: 0a 01 40 39 ldrb w10, [x8] ; *x8 -> w10
30: e9 03 0a 2a mov w9, w10 ; w10 -> w9
dyncall/doc/manual/Makefile.generic view on Meta::CPAN
)
# Main target dependencies --->
html/manual.html: manual_tex4ht.cfg sources
# The following runs htlatex, but sets up a few things beforehand to control
# it's behavior:
# - create custom, local version of tex4ht.env based on default one, but with
# better bitmaps
# - create empty multirow.4ht file, to simply override tex4ht's default one,
# which produces wrong output in our case - since all the tables where we
# use the multirow package are rendered into .pngs for our html doc, we don't
# need any tex4ht specific version outputing html
cd "${VPATH}" && ( \
:>./multirow.4ht; \
cp $$(dirname $$(which tex4ht))/../share/texmf-dist/tex4ht/base/unix/tex4ht.env ./custom_tex4ht.env; \
sed -E -i '' 's/(Text|Graphics)(AlphaBits)=[1,2,3]([^0-9])/\1\2=4\3/g' custom_tex4ht.env; \
mkdir -p ./html/; \
htlatex manual.tex manual_tex4ht " -cunihtf -e./custom_tex4ht.env -utf8" "-e./custom_tex4ht.env -d./html/"; \
dyncall/doc/manual/manual_bindings.tex view on Meta::CPAN
\end{description}
\pagebreak
\subsubsection{Signatures}
A signature is a character string that represents a function's arguments and
return value types. It is used in the scripting language bindings invoke
functions to perform automatic type-conversion of the languages' types to the
low-level C/C++ data types.
This is an essential part of mapping the more flexible and often abstract data
types provided in scripting languages to the strict machine-level data types
used by C-libraries.
The high-level C interface functions \capi{dcCallF()}, \capi{dcVCallF()},
\capi{dcArgF()} and \capi{dcVArgF()} of the \product{dyncall} library also make
use of this signature string format.\\
\\
The format of a \product{dyncall} signature string is as depicted below:
\paragraph{\product{dyncall} signature string format}
dyncall/doc/manual/manual_bindings.tex view on Meta::CPAN
\end{tabular*}
\caption{Type signature encoding for Erlang bindings}
\label{Erlangsigchar}
\end{center}
\end{table}
\pagebreak
\subsection{Go language bindings}
A Go binding is provided through the {\tt godc} package. Since Go's type system is basically a superset of C's, the type mapping from Go to C is straightforward.
\begin{table}[h]
\begin{center}
\begin{tabular*}{0.75\textwidth}{ll}
Signature character & accepted Go data types\\
\hline
\sigchar{v} & no return type\\
\sigchar{B} & bool\\
\sigchar{c}, \sigchar{C} & int8, uint8\\
\sigchar{s}, \sigchar{S} & int16, uint16\\
dyncall/doc/manual/manual_epilog.tex view on Meta::CPAN
Additionally, C++'s \capi{bool} and C99's \capi{\_Bool} types are supported
across all supported platforms.
Due to the still rare and often incomplete support of the \capi{long double}
type on various platforms, the latter is currently not officially supported.
Also, \capi{\_Complex} is currently not supported.
Passing or returning aggregates (struct, union) by value is supported, but only
on a limited set of platforms (check if the macro DC\_\_Feature\_AggrByVal is
defined).
\subsection{Roadmap}
The \product{dyncall} library should be extended by a wide variety of other
calling conventions and ported to other and more esoteric platforms. With its
low memory footprint it surely comes in handy on embedded systems.
Furthermore, the authors plan to provide more scripting language bindings,
examples, and other projects based on \product{dyncall}.\\
Besides \product{dyncall} and \product{dyncallback}, the \product{dynload}
library needs to be extended with support for other shared library formats
(e.g. AmigaOS .library or GEM \cite{.ldg} files).
dyncall/doc/manual/manual_overview.tex view on Meta::CPAN
be written for nearly every platform/compiler/OS combination.
Unfortunately, there are architectures we just don't have at home or work. If
you want to see \product{dyncall} running on such a platform, feel free to send
in code and patches, or even to donate hardware you don't need anymore.
Check the \textbf{supported platforms} section for an overview of the supported
platforms and the different calling convention sections for details about the
support.
\\
\begin{comment}
@@@
A typical binary library consists of symbolic names that map to variables and
functions, the latter being pre-compiled for a
specific calling convention and architecture. Given \product{dyncall} has been ported to
that binary platform, it is possible to call such a function dynamically
without writing glue code or prototypes or even knowing its C declaration -
all that is needed is a pointer to it.\\
To avoid confusion, note that from the point of view of the library all
parameters are handled the same way, even though the implementation might use
other ways to pass parameters in order to suit specific calling conventions.\\
\end{comment}
dyncall/dyncall/dyncall_callvm_mips_o32.c view on Meta::CPAN
dyncall callvm for mips o32 abi
REVISION
2010/06/03 initial
NOTES:
we need an argument counter for supporting floating point arguments
correctly.
first two (if any) double/float arguments are mapped via a common structure --
code must take care to write the right float argument indices which
differs on C and Assembly-side depending on endianness. (therefore
both sources have two variants 'mipseb' and 'mipsel'.)
(only for the first two float/double arguments) see float/double handling
although, the abi does not expect usage of floats if first argument is
not floating point, the call kernel can be used universal for all cases.
*/
dyncall/dyncall/dyncall_callvm_mips_o32.h view on Meta::CPAN
/* Call-kernel register data:
Details:
The structure holds the argument data for transfering float/double arguments
via registers as well.
The call-kernel on hardfloat platforms implements loads two doubles, which
involves four 32-bit floating pointer registers. It's unused for softfloat
platforms.
Float arguments map as following:
float argument 0 is at u[0][0] for little, u[0][1] for big endian and
float argument 1 is at u[1][0] for little, u[1][1] for big endian of
DCRegData_mips_o32 union.
*/
typedef struct
{
#if defined(DC__ABI_HARDFLOAT)
dyncall/dyncallback/dyncall_alloc_wx.c view on Meta::CPAN
/*
Package: dyncall
Library: dyncallback
File: dyncallback/dyncall_alloc_wx.c
Description: Allocate write/executable memory - Implementation back-end selector (mmap or win32)
License:
Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>,
Tassilo Philipp <tphilipp@potion-studios.com>
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
dyncall/dyncallback/dyncall_alloc_wx.c view on Meta::CPAN
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "../dyncall/dyncall_macros.h"
#if defined(DC_WINDOWS)
#include "dyncall_alloc_wx_win32.c"
#elif defined(DC_UNIX)
#include "dyncall_alloc_wx_mmap.c"
#else
#include "dyncall_alloc_wx_malloc.c"
#endif
dyncall/dyncallback/dyncall_alloc_wx_mmap.c view on Meta::CPAN
/*
Package: dyncall
Library: dyncallback
File: dyncallback/dyncall_alloc_wx_mmap.c
Description: Allocate write/executable memory - Implementation for posix
License:
Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>,
Tassilo Philipp <tphilipp@potion-studios.com>
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
dyncall/dyncallback/dyncall_alloc_wx_mmap.c view on Meta::CPAN
# else
# error "Platform implementation missing for anonymous rwx memory"
# endif
#endif
/* platforms without mprotect */
#if defined(DC__OS_Minix)
# define NO_MPROTECT
#endif
/* if no mprotect() available/wanted, make mmap alloc pages as rwx */
#if defined(NO_MPROTECT)
# define MMAP_PROT_INIT (PROT_READ|PROT_WRITE|PROT_EXEC)
#else
# define MMAP_PROT_INIT (PROT_READ|PROT_WRITE)
#endif
DCerror dcAllocWX(size_t size, void** pp)
{
void* p;
#if !defined(MAP_ANON) && defined(DC_UNIX)
/* Hack around not having POSIX' MAP_ANON by going through /dev/zero; store
file descr to close on dcFreeWX at beginning of memory, as tiny hack */
int fd = open("/dev/zero", O_RDWR);
if(fd == -1)
return -1;
p = mmap(0, size+sizeof(int), MMAP_PROT_INIT, MAP_PRIVATE, fd, 0);
if(p == MAP_FAILED) {
close(fd);
return -1;
}
*(int*)p = fd;
p += sizeof(int);
#else
p = mmap(0, size, MMAP_PROT_INIT, MAP_PRIVATE|MAP_ANON, -1, 0);
if(p == MAP_FAILED)
return -1;
#endif
*pp = p;
return 0;
}
DCerror dcInitExecWX(void* p, size_t size)
{
dyncall/dyncallback/dyncall_alloc_wx_mmap.c view on Meta::CPAN
}
void dcFreeWX(void* p, size_t size)
{
#if !defined(MAP_ANON) && defined(DC_UNIX)
/* Close file descriptor for no-MAP_ANON workaround (see above) */
p -= sizeof(int);
size += sizeof(int);
close(*(int*)p);
#endif
munmap(p, size);
}
dyncall/dynload/README.txt view on Meta::CPAN
As such, the first entry in a symbol table (index 0) is always completely
zeroed (type STT_NOTYPE), and is not used.
2. If the file contains any local symbols, the second entry (index 1)
the symbol table will be a STT_FILE symbol giving the name of the file.
3. Section symbols.
4. Register symbols.
5. Global symbols that have been reduced to local scope via a mapfile.
6. For each input file that supplied local symbols, a STT_FILE symbol
giving the name of the input file is put in the symbol table,
followed by the symbols in question.
7. The global symbols immediately follow the local symbols in the
symbol table. Local and global symbols are always kept separate
in this manner, and cannot be mixed together.
dyncall/dynload/dynload_syms_elf.c view on Meta::CPAN
return NULL;
i = open(libPath, O_RDONLY);
if(i == -1)
return NULL;
pSyms = (DLSyms*)dlAllocMem(sizeof(DLSyms));
memset(pSyms, 0, sizeof(DLSyms));
pSyms->file = i;
pSyms->fileSize = st.st_size;
pSyms->pElf_Ehdr = (Elf_Ehdr*) mmap((void*) NULL, pSyms->fileSize, PROT_READ, MAP_SHARED, pSyms->file, 0);
#ifdef ABI_ELF32
assert(pSyms->pElf_Ehdr->e_ident[EI_CLASS] == ELFCLASS32);
#else
assert(pSyms->pElf_Ehdr->e_ident[EI_CLASS] == ELFCLASS64);
#endif
assert(pSyms->pElf_Ehdr->e_phoff > 0);
assert(pSyms->pElf_Ehdr->e_shoff > 0);
dyncall/dynload/dynload_syms_elf.c view on Meta::CPAN
if (pSyms->pSymTab && pSyms->pStrTab)
break;
}
return pSyms;
}
void dlSymsCleanup(DLSyms* pSyms)
{
if(pSyms) {
munmap((void*) pSyms->pElf_Ehdr, pSyms->fileSize);
close(pSyms->file);
dlFreeMem(pSyms);
}
}
int dlSymsCount(DLSyms* pSyms)
{
return pSyms ? pSyms->nSymbols : 0;
}
dyncall/dynload/dynload_syms_mach-o.c view on Meta::CPAN
return NULL;
/* Loop over all dynamically linked images to find ours. */
for(i = 0, n = _dyld_image_count(); i < n; ++i)
{
const char* name = _dyld_get_image_name(i);
if(name)
{
/* Don't rely on name comparison alone, as libPath might be relative, symlink, differently */
/* cased, use weird osx path placeholders, etc., but compare inode number with the one of the mapped dyld image. */
/* reload already loaded lib to get handle to compare with, should be lightweight and only increase ref count */
DLLib* pLib_ = dlLoadLibrary(name);
if(pLib_)
{
/* free / refcount-- */
dlFreeLibrary(pLib_);
if(pLib == pLib_)
{
dyncall/dynload/dynload_unix.c view on Meta::CPAN
* the handle is valid, thus rendering the returned values useless) check for
* RTLD_DI_LINKMAP and RTLD_SELF, which are #defines used by dlinfo() on most
* supported targets, or specifically check the OS (e.g. dlinfo() is originally
* from Solaris) */
#if ((defined(RTLD_DI_LINKMAP) && defined(RTLD_SELF)) || defined(OS_SunOS)) && !defined(DL_USE_GLIBC_ITER_PHDR)
#include <link.h>
int dlGetLibraryPath(DLLib* pLib, char* sOut, int bufSize)
{
struct link_map* p = NULL;
int l = -1;
if(dlinfo(pLib ? pLib : RTLD_SELF, RTLD_DI_LINKMAP, &p) == 0)
l = dl_strlen_strcpy(sOut, p->l_name, bufSize);
return l+1; /* strlen + '\0' */
}
/* specific implementation needed on Darwin -----> */
#elif defined(OS_Darwin)
dyncall/test/suite2/mkcase.py view on Meta::CPAN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
#//////////////////////////////////////////////////////////////////////////////
import sys
f = file("design.cfg")
sigmap = {
'B':'DCbool'
, 'c':'DCchar'
, 's':'DCshort'
, 'i':'DCint'
, 'l':'DClonglong'
, 'f':'DCfloat'
, 'd':'DCdouble'
, 'p':'DCpointer'
}
apimap = {
'_':''
, 's':'__declspec(stdcall)'
, 'f':'__declspec(fastcall)'
}
id = 0
maxargs = 0
sys.stdout.write("/* auto generated by mkcase.py (on stdout) */\n");
for line in f:
line = line.rstrip().lstrip()
if len(line) == 0 or line[0] == '#': continue
types = [];
# args = len(line)-1
args = len(line)
maxargs = max(maxargs, args)
# api = apimap[ line[0] ]
out = [ "VF",str(args),"(", str(id), "," ];
for i in xrange(0,len(line)):
types += [ sigmap[ line[i] ] ]
out += [ ",".join( types ), ",s_", line, ")\n" ]
out = "".join(out)
sys.stdout.write(out)
id += 1
sys.stderr.write("/* auto generated by mkcase (on stderr) */\n");
sys.stderr.write("".join( ["#define NCASES ",str(id),"\n"] ) )
sys.stderr.write("".join( ["#define MAXARGS ",str(maxargs),"\n"] ) )
dyncall/test/suite2_x86win32fast/mkcase.py view on Meta::CPAN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
#//////////////////////////////////////////////////////////////////////////////
import sys
f = file("design.cfg")
sigmap = {
'B':'DCbool'
, 'c':'DCchar'
, 's':'DCshort'
, 'i':'DCint'
, 'l':'DClonglong'
, 'f':'DCfloat'
, 'd':'DCdouble'
, 'p':'DCpointer'
}
apimap = {
'_':''
, 's':'__declspec(stdcall)'
, 'f':'__declspec(fastcall)'
}
id = 0
maxargs = 0
sys.stdout.write("/* auto generated by mkcase.py (on stdout) */\n");
for line in f:
line = line.rstrip().lstrip()
if len(line) == 0 or line[0] == '#': continue
types = [];
# args = len(line)-1
args = len(line)
maxargs = max(maxargs, args)
# api = apimap[ line[0] ]
out = [ "VF",str(args),"(", str(id), "," ];
for i in xrange(0,len(line)):
types += [ sigmap[ line[i] ] ]
out += [ ",".join( types ), ",s_", line, ")\n" ]
out = "".join(out)
sys.stdout.write(out)
id += 1
sys.stderr.write("/* auto generated by mkcase (on stderr) */\n");
sys.stderr.write("".join( ["#define NCASES ",str(id),"\n"] ) )
sys.stderr.write("".join( ["#define MAXARGS ",str(maxargs),"\n"] ) )
dyncall/test/suite2_x86win32std/mkcase.py view on Meta::CPAN
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
#//////////////////////////////////////////////////////////////////////////////
import sys
f = file("design.cfg")
sigmap = {
'B':'DCbool'
, 'c':'DCchar'
, 's':'DCshort'
, 'i':'DCint'
, 'l':'DClonglong'
, 'f':'DCfloat'
, 'd':'DCdouble'
, 'p':'DCpointer'
}
apimap = {
'_':''
, 's':'__declspec(stdcall)'
, 'f':'__declspec(fastcall)'
}
id = 0
maxargs = 0
sys.stdout.write("/* auto generated by mkcase.py (on stdout) */\n");
for line in f:
line = line.rstrip().lstrip()
if len(line) == 0 or line[0] == '#': continue
types = [];
# args = len(line)-1
args = len(line)
maxargs = max(maxargs, args)
# api = apimap[ line[0] ]
out = [ "VF",str(args),"(", str(id), "," ];
for i in xrange(0,len(line)):
types += [ sigmap[ line[i] ] ]
out += [ ",".join( types ), ",s_", line, ")\n" ]
out = "".join(out)
sys.stdout.write(out)
id += 1
sys.stderr.write("/* auto generated by mkcase (on stderr) */\n");
sys.stderr.write("".join( ["#define NCASES ",str(id),"\n"] ) )
sys.stderr.write("".join( ["#define MAXARGS ",str(maxargs),"\n"] ) )
eg/benchmark.pl view on Meta::CPAN
return $name . '.dylib' if -f $name . '.dylib';
return $name . '.bundle' if -f $name . '.bundle';
return $name if $name =~ /\.so$/;
return $name; # Let 'em work it out
# https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/UsingDynamicLibraries.html
my @dirs = (
dirname( File::Spec->rel2abs($^X) ), # 0. exe dir
File::Spec->rel2abs( File::Spec->curdir ), # 0. cwd
File::Spec->path(), # 0. $ENV{PATH}
map { File::Spec->rel2abs($_) }
grep { -d $_ } qw[~/lib /usr/local/lib /usr/lib],
map { $ENV{$_} // () }
qw[LD_LIBRARY_PATH DYLD_LIBRARY_PATH DYLD_FALLBACK_LIBRARY_PATH]
);
#use Test::More;
#diag join ', ', @dirs;
#warn;
find(
{ wanted => sub {
$File::Find::prune = 1
if !grep { $_ eq $File::Find::name } @dirs; # no depth
eg/benchmark.pl view on Meta::CPAN
#diag join ', ', @retval;
}
else {
return $name . '.so' if -f $name . '.so';
return $name if -f $name;
my $ext = $Config{so};
my @libs;
# warn $name . '.' . $ext . $version;
#\b(?:lib)?${name}(?:-[\d\.]+)?\.${ext}${version}
#my @lines = map { [/^\t(.+)\s\((.+)\)\s+=>\s+(.+)$/] }
# grep {/\b(?:lib)?${name}(?:-[\d\.]+)?\.${ext}(?:\.${version})?$/} `ldconfig -p`;
#push @retval, map { $_->[2] } grep { -f $_->[2] } @lines;
my @dirs = (
dirname( File::Spec->rel2abs($^X) ), # 0. exe dir
File::Spec->rel2abs( File::Spec->curdir ), # 0. cwd
File::Spec->path(), # 0. $ENV{PATH}
map { File::Spec->rel2abs($_) }
grep { -d $_ } qw[~/lib /usr/local/lib /usr/lib],
map { $ENV{$_} // () }
qw[LD_LIBRARY_PATH DYLD_LIBRARY_PATH DYLD_FALLBACK_LIBRARY_PATH]
);
#use Data::Dump;
#ddx \@dirs;
find(
{ wanted => sub {
$File::Find::prune = 1
if !grep { $_ eq $File::Find::name } @dirs; # no depth
push @retval, $_ if /\b(?:lib)?${name}(?:-[\d\.]+)?\.${ext}${version}$/;
lib/Affix.pm view on Meta::CPAN
use Text::ParseWords;
use Carp qw[];
use vars qw[@EXPORT_OK @EXPORT %EXPORT_TAGS];
use XSLoader;
#~ our $VMSize = 2; # defaults to 4096; passed to dcNewCallVM( ... )
my $ok = XSLoader::load();
END { _shutdown() if $ok; }
#
use parent 'Exporter';
@EXPORT_OK = sort map { @$_ = sort @$_; @$_ } values %EXPORT_TAGS;
$EXPORT_TAGS{'all'} = \@EXPORT_OK; # When you want to import everything
#@{ $EXPORT_TAGS{'enum'} } # Merge these under a single tag
# = sort map { defined $EXPORT_TAGS{$_} ? @{ $EXPORT_TAGS{$_} } : () }
# qw[types?]
# if 1 < scalar keys %EXPORT_TAGS;
@EXPORT # Export these tags (if prepended w/ ':') or functions by default
= sort map { m[^:(.+)] ? @{ $EXPORT_TAGS{$1} } : $_ } qw[:default :types]
if keys %EXPORT_TAGS > 1;
@{ $EXPORT_TAGS{all} } = our @EXPORT_OK = map { @{ $EXPORT_TAGS{$_} } } keys %EXPORT_TAGS;
#
my %_delay;
sub AUTOLOAD {
my $self = $_[0]; # Not shift, using goto.
my $sub = our $AUTOLOAD;
if ( defined $_delay{$sub} ) {
#warn 'Wrapping ' . $sub;
#use Data::Dump;
lib/Affix.pm view on Meta::CPAN
else {
require Win32;
# https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order#search-order-for-desktop-applications
my @dirs = grep {-d} (
dirname( rel2abs($^X) ), # 1. exe dir
Win32::GetFolderPath( Win32::CSIDL_SYSTEM() ), # 2. sys dir
Win32::GetFolderPath( Win32::CSIDL_WINDOWS() ), # 4. win dir
rel2abs(curdir), # 5. cwd
path(), # 6. $ENV{PATH}
map { split /[:;]/, ( $ENV{$_} ) } grep { $ENV{$_} } # X. User defined
qw[LD_LIBRARY_PATH DYLD_LIBRARY_PATH DYLD_FALLBACK_LIBRARY_PATH]
);
my @retval;
#warn $_ for sort { lc $a cmp lc $b } @dirs;
find(
{ wanted => sub {
$File::Find::prune = 1
if !grep { $_ eq $File::Find::name } @dirs; # no depth
push @retval, $_ if m{[/\\]${name}(-${version})?\.dll$}i;
lib/Affix.pm view on Meta::CPAN
if ( -f $name . '.so' ) { $p = rel2abs $name . '.so' }
elsif ( -f $name . '.dylib' ) { $p = rel2abs $name . '.dylib' }
elsif ( -f $name . '.bundle' ) { $p = rel2abs $name . '.bundle' }
elsif ( $name =~ /\.so$/ ) { $p = rel2abs $name }
else {
# https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/UsingDynamicLibraries.html
my @dirs = grep { -d $_ } (
dirname( rel2abs($^X) ), # 0. exe dir
rel2abs(curdir), # 0. cwd
path(), # 0. $ENV{PATH}
map { rel2abs($_) }
qw[. ./lib/ ~/lib /usr/local/lib /usr/lib /System/Library/dyld/],
map { split /[:;]/, ( $ENV{$_} ) }
grep { $ENV{$_} }
qw[LD_LIBRARY_PATH LC_LOAD_DYLIB DYLD_LIBRARY_PATH DYLD_FALLBACK_LIBRARY_PATH]
);
my @retval;
find(
{ wanted => sub {
$File::Find::prune = 1
if !grep { $_ eq $File::Find::name } @dirs; # no depth
push @retval, $_
if /\b(?:lib)?${name}${version}\.(so|bundle|dylib)$/;
lib/Affix.pm view on Meta::CPAN
else {
my $p;
if ( -f $name ) { $p = rel2abs $name }
elsif ( -f $name . '.' . $Config{so} ) { $p = rel2abs $name . '.' . $Config{so} }
else {
my $ext = $Config{so};
my @libs;
# warn $name . '.' . $ext . $version;
#\b(?:lib)?${name}(?:-[\d\.]+)?\.${ext}${version}
#my @lines = map { [/^\t(.+)\s\((.+)\)\s+=>\s+(.+)$/] }
# grep {/\b(?:lib)?${name}(?:-[\d\.]+)?\.${ext}(?:\.${version})?$/} `ldconfig -p`;
#push @retval, map { $_->[2] } grep { -f $_->[2] } @lines;
my @dirs = grep { -d $_ } (
dirname( rel2abs($^X) ), # 0. exe dir
rel2abs(curdir), # 0. cwd
path(), # 0. $ENV{PATH}
map { rel2abs($_) }
qw[. ./lib ~/lib /usr/local/lib /usr/lib /lib64 /lib /System/Library/dyld],
map { split /[:;]/, ( $ENV{$_} ) }
grep { $ENV{$_} }
qw[LD_LIBRARY_PATH DYLD_LIBRARY_PATH DYLD_FALLBACK_LIBRARY_PATH]
);
my @retval;
find(
{ wanted => sub {
$File::Find::prune = 1
if !grep { $_ eq $File::Find::name } @dirs; # no depth
push @retval, $_
if /\b(?:lib)?${name}(?:-[\d\.]+)?\.${ext}${version}$/;
lib/Affix.pm view on Meta::CPAN
my $vp = 0; # void *
sub _mangle_name ($$) {
my ( $func, $name ) = @_;
if ( grep { $_ eq $name } @cache ) {
return join '', 'S', ( grep { $cache[$_] eq $name } 0 .. $#cache ), '_';
}
push @cache, $name;
$name =~ s[^$func][S0_];
sprintf $name =~ '::' ? 'N%sE' : '%s',
join( '', ( map { length($_) . $_ } split '::', $name ) );
}
sub _mangle_type {
my ( $func, $type ) = @_;
return #'A'
'P' . _mangle_type( $func, $type->{type} ) if $type->isa('Affix::Type::ArrayRef');
if ( $type->isa('Affix::Type::Pointer') && $type->{type}->isa('Affix::Type::Void') ) {
return $vp++ ? 'S_' : 'Pv';
}
return 'P' . _mangle_type( $func, $type->{type} ) if $type->isa('Affix::Type::Pointer');
lib/Affix.pm view on Meta::CPAN
WChar(), 'w', LongLong(), 'x', ULongLong(), 'y', '_', '', # Calling conventions
};
$types->{$type} // die 'Unknown type: ' . $type;
}
sub Itanium_mangle {
my ( $lib, $name, $affix ) = @_;
@cache = ();
$vp = 0;
my $ret = '_Z' . sprintf $name =~ '::' ? 'N%sE' : '%s',
join( '', ( map { length($_) . $_ } split '::', $name ) );
#~ for my $arg ( scalar @{ $affix->{args} } ? @{ $affix->{args} } : Void() ) {
my @args = scalar @{$affix} ? @{$affix} : Void();
while (@args) {
my $arg = shift @args;
$ret .= _mangle_type( $name, $arg );
if ( $arg eq '_' ) {
shift @args;
push @args, Void() if !@args; # skip calling conventions
}
lib/Affix.pm view on Meta::CPAN
# legacy
sub Rust_legacy_mangle {
my ( $lib, $name, $affix ) = @_;
CORE::state $symbol_cache //= ();
$symbol_cache->{$lib} //= Affix::_list_symbols($lib);
@cache = ();
$vp = 0;
return $name if grep { $name eq $_ } grep { defined $_ } @{ $symbol_cache->{$lib} };
my $ret = qr'^_ZN(?:\d+\w+?)?' . sprintf $name =~ '::' ? '%sE' : '%s17h\w{16}E$',
join( '', ( map { length($_) . $_ } split '::', $name ) );
my @symbols = grep { $_ =~ $ret } grep { defined $_ } @{ $symbol_cache->{$lib} };
return shift @symbols;
}
}
};
1;
__END__
=encoding utf-8
lib/Affix.xs view on Meta::CPAN
else {
retval = POPp;
// SvSetMagicSV(type, retval);
}
// FREETMPS;
LEAVE;
}
return retval;
}
// Lazy load actual type from typemap and InstanceOf[]
SV *_instanceof(pTHX_ SV *type) {
SV *retval;
char *name = SvPV_nolen(*hv_fetchs(MUTABLE_HV(SvRV(type)), "package", 0));
{
dSP;
int count;
SV *err_tmp;
ENTER;
SAVETMPS;
PUSHMARK(SP);
lib/Affix.xs view on Meta::CPAN
}
#define CLEANUP(NAME) \
cv = get_cv(form("Affix::%s", #NAME), 0); \
if (cv != NULL) safefree(XSANY.any_ptr);
// clang-format off
MODULE = Affix PACKAGE = Affix
# Override default typemap
TYPEMAP: <<HERE
DCpointer T_DCPOINTER
INPUT
T_DCPOINTER
if (sv_derived_from($arg, \"Affix::Pointer\")){
IV tmp = SvIV((SV*)SvRV($arg));
$var = INT2PTR($type, tmp);
}