Affix

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN


## `DumpHex( ... )`

```
DumpHex( $ptr, $length );
```

Dumps `$length` bytes of raw data from a given point in memory.

This is a debugging function that probably shouldn't find its way into your
code and might not be public in the future.

# Types

Raku offers a set of native types with a fixed, and known, representation in
memory but this is Perl so we need to do the work ourselves with a pseudo-type
system. Affix supports the fundamental types (void, int, etc.), aggregates
(struct, array, union), and .

## Fundamental Types with Native Representation

dyncall/ChangeLog  view on Meta::CPAN

  o based more sources on portasm generation
dyncall:
  o fix for ARMv7 Thumb-2 code (tested on iPhone 4 CDMA / iOS 6.0.1)
  o bugfixes for -O2 builds for SPARC-v9 and SPARC-v7
  o new optimized call kernel for SPARC-v9 without conditionals
  o bigger refactoring and optimization of MIPS o32
  o x64 optimizations
dyncallback:
  o added callback support for plan9
  o big cleanup, removal of duplicate files after introduction of portasm
  o include path fixes for public facing APIs (removed relative paths)
doc:
  o cleanup of manual and corrections
  o added info about newly supported and/or tested platforms (e.g. FreeBSD on ARM)
  o restructured folder layout for documentation
  o added API doc for dyncallback and dynload
  o added manpages for dyncallback and dynload
tests:
  o added arm/thumb interwork test suite
bindings:
  o godc: added bindings for Go

dyncall/doc/README.embedded  view on Meta::CPAN

Useful variables are AR, CC, CFLAGS and ASFLAGS.

The test/Makefile.embedded file controls for building the tests.
The tests currently involve sometimes C++ and some platforms need
to link with the math library. Others need the dynamic linker.
Useful variables are CXX, CC, CCC (Sun), CFLAGS, CCFLAGS (Sun), 
CXXFLAGS andLDFLAGS.

Background
----------
During the preparation for the public release of the R package 'rdyncall' I was 
looking for a way to get DynCall integrated into an existing Make system such 
as offered by R for build R packages. 

It was inspired by the make files of Lua which are damn simple and
don't need a configure but a user that knows the target platform name.

The source package can be configured automatically during compilation and
does not require explicit configuration anymore using "*.S" files that
are Assembly files which are preprocessed by the C Preprocessor.

dyncall/doc/disas_examples/x86.cdecl.disas  view on Meta::CPAN

1c000982:       8d 45 f4                lea    0xfffffff4(%ebp),%eax ; |
1c000985:       83 28 0c                subl   $0xc,(%eax)           ; | a -= 12
1c000988:       c9                      leave                        ;
1c000989:       c3                      ret                          ;



; ---------- cdecl-declared (explicit) C++ thiscall w/ msvc ---------->
;
; class C {
; public:
;     float __cdecl m(int i) const { return float(i + 123); }
; };
;
; extern "C" {
;     float f()
;     {
;         C c;
;         return c.m(27);
;     }
; }

dyncall/doc/disas_examples/x86.thiscall.disas  view on Meta::CPAN

; ---------- simple C++ thiscall ---------->
;
; class C {
; public:
;     float m(int i) const { return float(i + 123); }
; };
;
; extern "C" {
;     float f()
;     {
;         C c;
;         return c.m(27);
;     }
; }

dyncall/doc/disas_examples/x86.thiscall_ms.disas  view on Meta::CPAN

; class C {
; public:
;     float m(int i) const { return float(i + 123); }
; };
;
; extern "C" {
;     float f()
;     {
;         C c;
;         return c.m(27);
;     }
; }

dyncall/doc/manual/callconvs/callconv_ppc32.tex  view on Meta::CPAN


\paragraph{Overview}

\begin{itemize}
\item Word size is 32 bits
\item Big endian (MSB) and litte endian (LSB) operating modes.
\item Processor operates on floats in double precision floating point arithmetc (IEEE-754) values directly (single precision is converted on the fly)
\item Apple macos/Mac OS X/Darwin PPC is specified in "Mac OS X ABI Function Call Guide"\cite{ppcMacOSX}. It uses Big Endian (MSB)
\item Linux PPC 32-bit ABI is specified in "LSB for PPC"\cite{ppc32LSB} which is based on "System V ABI". It uses Big Endian (MSB)
\item PowerPC EABI is defined in the "PowerPC Embedded Application Binary Interface 32-Bit Implementation"\cite{ppceabi}
\item There is also the "PowerOpen ABI"\cite{poabi}, a nearly identical version of it is used in AIX % more info: http://www.ingallegri.com/public/ppc.html
\end{itemize}

\paragraph{\product{dyncall} support}

\product{Dyncall} and \product{dyncallback} are supported for PowerPC (32bit)
Big Endian (MSB), for Darwin's and System V's calling convention.\\
\product{Dyncall} can also be used to issue syscalls by using the syscall
number as target parameter and selecting the correct mode.


dyncall/dyncall/dyncall.h  view on Meta::CPAN

/*

 Package: dyncall
 Library: dyncall
 File: dyncall/dyncall.h
 Description: public header for library dyncall
 License:

   Copyright (c) 2007-2022 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/dyncallback.3  view on Meta::CPAN

dcbFreeCallback(cb);
dcFreeAggr(a);
.Ed
.Ss C++
In our next example, let's look at setting up a
.Sy DCCallback
object to call back a simple C++ method (illustrating the need to specify the
thiscall calling convention). If the class and method is declared as:
.Bd -literal -offset indent
class Klass {
public:
	virtual void Method(float, int);
};
.Ed
.Pp
the respective callback handler would be something along the lines of:
.Bd -literal -offset indent
DCsigchar cbHandler(DCCallback* cb,
                    DCArgs*     args,
                    DCValue*    result,
                    void*       userdata)

dyncall/dynload/dynload.h  view on Meta::CPAN

/*

 Package: dyncall
 Library: dynload
 File: dynload/dynload.h
 Description: public header for library dynload
 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/test/plain_c++/test_main.cc  view on Meta::CPAN

#define VTBI_GET_FLOAT VTBI_BASE+9
#define VTBI_SET_DOUBLE VTBI_BASE+10
#define VTBI_GET_DOUBLE VTBI_BASE+11
#define VTBI_SET_POINTER VTBI_BASE+12
#define VTBI_GET_POINTER VTBI_BASE+13
#define VTBI_SUM_3_INTS VTBI_BASE+14

#define TEST_CLASS(NAME, CCONV) \
class NAME \
{ \
public: \
  virtual                  ~NAME()                   { } \
 \
  virtual void       CCONV setBool(DCbool x)         { mValue.B = x; } \
  virtual DCbool     CCONV getBool()                 { return mValue.B; } \
  virtual void       CCONV setInt(DCint x)           { mValue.i = x; } \
  virtual DCint      CCONV getInt()                  { return mValue.i; } \
  virtual void       CCONV setLong(DClong x)         { mValue.j = x; } \
  virtual DClong     CCONV getLong()                 { return mValue.j; } \
  virtual void       CCONV setLongLong(DClonglong x) { mValue.l = x; } \
  virtual DClonglong CCONV getLongLong()             { return mValue.l; } \

dyncall/test/plain_c++/test_main.cc  view on Meta::CPAN

  dcFree(pc);
  return r;
}


#if defined(DC__Feature_AggrByVal)

#define TEST_CLASS_AGGR(NAME, CCONV) \
class NAME \
{ \
public: \
  struct S { int i, j, k, l, m; }; \
 \
  virtual             ~NAME()       { } \
 \
  virtual void  CCONV setAggr(S x)  { mS.i = x.i; mS.j = x.j; mS.k = x.k; mS.l = x.l; mS.m = x.m; } \
  virtual S     CCONV getAggr()     { return mS; } \
 \
  /* ellipsis test w/ this ptr and big (!) aggregate return */ \
  struct Big { int sum; long long dummy[50]; /*dummy to make it not fit in any regs*/ }; \
  virtual struct Big  CCONV sum3RetAggr(DCint x, ...) { va_list va; va_start(va,x); struct Big r = { x + va_arg(va,int) + va_arg(va,int) }; va_end(va); return r; } \

lib/Affix.pm  view on Meta::CPAN

subroutine that returned a pointer, a lvalue pointer to a native subroutine,
or, as part of a C<Struct[ ... ]>.

=head2 C<DumpHex( ... )>

    DumpHex( $ptr, $length );

Dumps C<$length> bytes of raw data from a given point in memory.

This is a debugging function that probably shouldn't find its way into your
code and might not be public in the future.

=head1 Types

Raku offers a set of native types with a fixed, and known, representation in
memory but this is Perl so we need to do the work ourselves with a pseudo-type
system. Affix supports the fundamental types (void, int, etc.), aggregates
(struct, array, union), and .

=head2 Fundamental Types with Native Representation

t/src/82_affix_mangle_itanium.cxx  view on Meta::CPAN

#include "std.h"

class MyClass
{
  public:
    int myNum;
    const char *myString;
    void speed(int maxSpeed);
    int speed();
};

DLLEXPORT
int MyClass::speed() {
    return myNum;
}



( run in 0.942 second using v1.01-cache-2.11-cpan-64827b87656 )