New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ffi #22

Open
rurban opened this Issue Sep 11, 2015 · 0 comments

Comments

1 participant
@rurban
Member

rurban commented Sep 11, 2015

probe for libffi and link to it if found. useffi, ffi_targets for the valid :nativconv() ABI args.
parse syntax:

use ffi; # NativeCall already taken and incompatible
extern sub NAME SIG ATTRIB?;
#or
sub NAME SIG :native() ATTRIB?;

The alternative for extern is the perl6-style :native attribute, with optional
arg :native("libname") and optional :symbol("c_name").
Str arg or return types can have optional :encoded('utf8') attributes.
The default return type is :Int.
See https://docs.perl6.org/language/nativecall
Resolve the attribute arguments, safely. See #291. (Not as in Attribute::Handlers)

Use a new op dlcall/enterffi for it, instead of entersub. leaveffi not needed, as no blocks are stored for extern subs, just the call and the sigop. the sigop holds the info for argument and returntype translations, the callop does the translation, call, translation.

Without a :native(libname) the symbol searched in all loaded shared libraries.
So you can preload shared libs via the DynaLoader.

Add and separate a function to DynaLoad a pure shared library, without xs bootstrap, so extern does not need any library name. Other languages do it eg. with use lib ("mysqlclient.so");

Translate args in the optimizer to such a sub, upgrade to native.

Enforce native types for the sub parameters, resp. provide casts (unbox).
ditto for the return value.

A CvEXTERN(cv) needs a temp. libptr for the loaded shared lib (shared with the ffi cif), and an optional PV for the symbolname.
(mangled or unmangled, :symbol() override, _ prefix or not).
It doesn't need a CvSTART, nor a CvROOT, so overload those two.
At runtime libffi needs the XSUB address, and the cif, i.e. the ffi signature.
The symbolname is resolved to the XSUB address via DynaLoader, the sig is converted to a cif at compile-time.

We need a few more Configure probes and keys: useffi (to disable it), d_libffi (if the definition probed ok), i_ffi (if to include <ffi.h>), i_alloca (if to include alloca.h), d_alloca or d__alloca (for fast arg preperation).

Note that Larry had this in his TODO, but p5p removed it later.
Est. 2w

Architecture

parser: extern sub name (sig) :native() :symbol() :nativconv() :encoded();

  • sig is stored as sigop attached to the CvEXTERN sub, not in the block (CvROOT). needed for prep_cif.
  • attrs store the lib and symname in xsutils,
  • NY: add the runtime attributes->import call to the stmt list there. compile-time works fine.

attributes::import (either compile-time or run-time):

  • resolve the lib and name via DynaLoader (i.e. not in miniperl). See #291 for run-time attrs support :native($libname).
  • set libhandle (temp. CvFFILIB) via dl_load_file
  • resolve symbol ptr via dl_find_symbol
  • store ptr at CvXFFI(). CvFFILIB is now unneeded, and re-used for the cif.
  • ffi_prep_cif: prepare sig arity and type translations.
  • set CvFFILIB from lib handle to cif.

compiler:

  • ck_entersub_args_proto_or_list checks for CvEXTERN
  • sets op from ENTERSUB to ENTERFFI (as with ENTERXSSUB)
  • type check the call args

runtime: pp_enterffi

  • prep_sig: copy args from perl stack to arg_values[] via sigop aux info.
  • ffi_call(cif, CvXFFI(cv), &rvalue, argvalues);
  • prep_ret: copy rvalue to perl stack.

@rurban rurban added the enhancement label Sep 11, 2015

@rurban rurban self-assigned this Sep 11, 2015

rurban added a commit that referenced this issue May 22, 2017

ffi: probe in Configure
i_ffi, d_libffi, useffi.
See #22

rurban added a commit that referenced this issue May 22, 2017

ffi: parse extern sub NAME SIG ATTRIB?;
mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

rurban added a commit that referenced this issue May 22, 2017

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

@rurban rurban added the in progress label May 28, 2017

rurban added a commit that referenced this issue May 28, 2017

ffi: probe in Configure
i_ffi, d_libffi, useffi.
See #22

rurban added a commit that referenced this issue May 28, 2017

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

rurban added a commit that referenced this issue May 31, 2017

ffi: probe in Configure
i_ffi, d_libffi, useffi.
See #22

rurban added a commit that referenced this issue May 31, 2017

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

rurban added a commit that referenced this issue Jun 1, 2017

ffi: probe in Configure
i_ffi, d_libffi, useffi.
See #22

rurban added a commit that referenced this issue Jun 1, 2017

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

rurban added a commit that referenced this issue Jun 3, 2017

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

rurban added a commit that referenced this issue Jun 4, 2017

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

rurban added a commit that referenced this issue Jun 5, 2017

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

rurban added a commit that referenced this issue Jun 6, 2017

ffi: probe in Configure
i_ffi, d_libffi, useffi.
See #22

rurban added a commit that referenced this issue Jun 6, 2017

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

rurban added a commit that referenced this issue Jun 9, 2017

ffi: probe in Configure
i_ffi, d_libffi, useffi.
See #22

rurban added a commit that referenced this issue Jun 9, 2017

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

rurban added a commit that referenced this issue Jun 9, 2017

ffi: probe in Configure
i_ffi, d_libffi, useffi.
See #22

rurban added a commit that referenced this issue Jun 9, 2017

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

rurban added a commit that referenced this issue Jun 14, 2017

ffi: probe in Configure
i_ffi, d_libffi, useffi.
See #22

rurban added a commit that referenced this issue Jun 14, 2017

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

rurban added a commit that referenced this issue Jun 14, 2017

ffi: probe in Configure
i_ffi, d_libffi, useffi.
See #22

rurban added a commit that referenced this issue Jun 14, 2017

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

rurban added a commit that referenced this issue Jun 15, 2017

ffi: probe in Configure
i_ffi, d_libffi, useffi.
See #22

rurban added a commit that referenced this issue Jun 15, 2017

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

rurban added a commit that referenced this issue Jun 17, 2017

ffi: probe in Configure
i_ffi, d_libffi, useffi.
See #22

rurban added a commit that referenced this issue Jun 17, 2017

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

rurban added a commit that referenced this issue Jun 18, 2017

ffi: probe in Configure
i_ffi, d_libffi, useffi.
See #22

rurban added a commit that referenced this issue Jun 18, 2017

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

rurban added a commit that referenced this issue Jun 18, 2017

ffi: probe in Configure
i_ffi, d_libffi, useffi.
See #22

rurban added a commit that referenced this issue Jun 18, 2017

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

rurban added a commit that referenced this issue Jun 21, 2017

ffi: probe in Configure
i_ffi, d_libffi, useffi.
See #22

rurban added a commit that referenced this issue Jun 21, 2017

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

rurban added a commit that referenced this issue Jun 22, 2017

ffi: probe in Configure
i_ffi, d_libffi, useffi.
See #22

rurban added a commit that referenced this issue Jun 22, 2017

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

rurban added a commit that referenced this issue Jun 22, 2017

ffi: probe in Configure
i_ffi, d_libffi, useffi.
See #22

rurban added a commit that referenced this issue Jun 22, 2017

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

rurban added a commit that referenced this issue Sep 6, 2018

ffi: probe in Configure
i_ffi, d_libffi, useffi. See #22

findffi: search all the libffi versions, expand
to absolute path as -I../ doesnt work.

vms: add libffi probes (untested)

Probe for the OpenVMS libffi port, also needed for python ctypes.
A 3.0.9 port exists for HP-UX/ia64, VMS/Alpha and VMS/ia64, but not
sure about its status, esp. OpenVMS. VAX should work.

find cygwin libXXX.dll.a libs
esp. for -lffi, which has no static lib.

rurban added a commit that referenced this issue Sep 6, 2018

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

parse attributes :native :symbol
set CvFFILIB via dl_load_file and CvXSUB symbol via dl_find_symbol.
TODO: set from SV values, not just constants.

use sv_chop in toke to advance PL_lex_stuff
use the OOK hack to do SvPVX(PL_lex_stuff)++
otherwise it will fail in sv_free. avoid copies.

add enterffi op to compiler

add and fix core extern tests WIP
not deparsed yet.

Resolve core attribute arguments, runtime setters

Some builtin attributes need to resolve symbolnames :native($libname)
at run-time, not only constants at parse-time, as via apply_attrs(),
which does the import in a BEGIN{} block.

Closes #291
As described in http://perl11.org/blog/attributes-args.html

perldiag: document standalone :symbol warning

add native and symbol() helpers

and fix start_subparse to start the attribute->import call.

skip miniperl, set ENTERFFI type
handle GvCV, SvRV and direct CV in ENTERFFI.
no overloaded object and no LV.

Set the right type already in the ck_subr to have less
op misses in entersub, also for xsub calls.
Note that a compile-time ffi call will not fall back to
a user-sub if redefined. Only done for XS to Perl or Perl to XS/FFI.

Simplify a few builtins.

Change attribute args: "native(" is followed by the arg.

start with the C part: ffi_call
remove unneeded leaveffi, prepare cfi usage.

document the ffi

fix extern sub parsing

and also lexical 'my extern sub name();'.
extern needs to trigger compile-time attributes->import().

checkcfgvar new config vars

cperl Porting/checkcfgvar.pl d_libffi i_ffi useffi  --default=undef --regen
note that vms has a libffi port:
  http://de.openvms.org/OpenVMS-Ports/detail.php?id=141
which needs to be installed/probed for.

add nativeconv() attribute
need a config-time helper for valid ABI values

prepare :encoded() attribute
for Str args or CV rettypes. TODO: attach
the encoding layer to the sig or ret pass.

Unify perldiag warnings. Less memory, same content.

fix prep_cif without USE_FFI
throw a compile-warning libffi not available
via warnings "syntax".
Normally we should suppress such declaration warnings,
as only calling extern subs should be forbidden without libffi.

fix the arg and CvHASSIG handling.
TODO: run-time signature type checks, prep_ffi_ret.

implement prep_ffi_ret
with all new ffi types (see https://docs.perl6.org/language/nativecall)

improve prep_ffi_ret types
change default rettype from :long to :void, analog to perl6.
simplify the type handling, encoded missing for str.

implement prep_ffi_sig

attr parsing: add parser in_sub and lex_attr_state

in_sub is needed to allow attributes not only in my decls.
lex_attr_state is needed to save the subname LEXER state of either
XATTRBLOCK or XATTRTERM over subsignature parsing, which destroyes this state
but is needed afterwards in subattrlist.

fix PL_in_sub state, for pmruntime funcs. fixes t/re/pat.t
my $died=qr/(?{})/;$error=$died?($@||qq(Zombie)):qq(none);
the qr func setting in_sub, and :qq(none) consuming it falsely

silence conversion and nonnull optimizer warnings
one since gcc 6.0. clang not yet checked.

magic ffienc for the :encoded attribute WIP
for string arguments and return type, PAD sv attachments.

Maybe use it also for all string values (as in Perl6), added to Encode when
being used outside of Latin-1/UTF-8.  But then as index into an encoded
array of names.  Now as shared name, attached as new F ffienc magic.

TODO: and add an attributes->import catchall CvEXTERN setter,
for extern sub cases where the parser forgot to call it with
"native".

parse empty extern sub () as sig, not proto

'extern sub name ()' is not an empty prototype, it's an empty signature.
treat 'sub name () :native' also as is_extern (EXTERNSUB token), to
signify () as signature, not as prototype.

attributes::get returns native
not native(lib) or the CvXFFI. Not symbol(name), encoded(name), nativeconv() yet

add warnings ffi
for the compile-time no ffi without DynaLoader warning.
Add the associated run-time error: Null extern sub symbol.

ffi: fix :symbol for slabbed CvFFILIB

also ignore find_symbol dlsym errors.
fix some PADLIST assertions.

attr_runtime: defer SAVEFREEOP(attr)
from new{ATTR,MY}SUB to attrs_runtime.
enhance dup_attrlist for variables to protect from SAVEFREEOP(attrs).

use GVSV, not just GV for the attribute argument. But keep using
REGFGEN, not SREFGEN, because peep and fold_constants rely on the bad
SREFGEN-null-kid format, and cannot deal with SREFGEN-kid.

Closes #291

harmonize diagnostic messages
ffi warnings and errors

fix sub EXISTING_SYM () :native :symbol(OTHERSYM)

use flat lists as attrs argument to attributes->import, not
nested. this was ignore in dup_attrslist().
add a testcase to test for the 2nd :symbol(OTHER) to resolve, not
skip.
Change the :symbol is already resolved warning to redefine, and only
if it's superfluous, resolving to the same symbol.

fix the attrs double-frees
  but still some minor attrs leaks, compile-time only.
  no ffi leaks at run-time though.
fix extern sub :attr
fix the externsub attribute case with import call for native,
fix lexer for several attributes: cv specific,
fix one minor SV leak in attributes::get
allow NULL rvalue in prep_ffi_ret.

windows and travis configs

harmonize prep_ffi_ret decls.

windows passes with the I_DLFCN fix appveypr smokes without libffi.
Need to enable it yet, copying the dlls from somewhere. Best with a
win32/ helper.

improve the tests skips

fix RTLD_DEFAULT logic

on windows it will fail, dl_load_file already did the searches.
on BSDs it is -2, everywhere else 0.
include dlfcn.h

I_DLFCN: not available under MSVC

util.c included this, but skipped on windows
which has no USE_C_BACKTRACE.

The win32 config files were wrong.

handle more type errors
invalid attribute arguments

prepare for more native const ops
not just one

c++ -fpermissive compat

use memcpy() which does a better copy of the wanted size,
and is optimized to the same code as a simple cast.
esp. we don't use a union, when we can use a single and more precise line.

we cannot use void* with C++, use char* instead.

improve the tests to use int, not long.

fix GVSV threaded

On threads a GVSV for the native($n) argument is invalid,
we need to use SVREF(GVOP) which is a PADOP.
This failed in op destruction on the invalid padix.

There is a problem with the padix from the upper scope.
Use the previous padix when copying it to the attributes->import
call.

reindent newGVOP and other overlong calls
no functional changes.

enum parser->lex_attr_state

rurban added a commit that referenced this issue Sep 13, 2018

ffi: probe in Configure
i_ffi, d_libffi, useffi. See #22

findffi: search all the libffi versions, expand
to absolute path as -I../ doesnt work.

vms: add libffi probes (untested)

Probe for the OpenVMS libffi port, also needed for python ctypes.
A 3.0.9 port exists for HP-UX/ia64, VMS/Alpha and VMS/ia64, but not
sure about its status, esp. OpenVMS. VAX should work.

find cygwin libXXX.dll.a libs
esp. for -lffi, which has no static lib.

rurban added a commit that referenced this issue Sep 13, 2018

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

parse attributes :native :symbol
set CvFFILIB via dl_load_file and CvXSUB symbol via dl_find_symbol.
TODO: set from SV values, not just constants.

use sv_chop in toke to advance PL_lex_stuff
use the OOK hack to do SvPVX(PL_lex_stuff)++
otherwise it will fail in sv_free. avoid copies.

add enterffi op to compiler

add and fix core extern tests WIP
not deparsed yet.

Resolve core attribute arguments, runtime setters

Some builtin attributes need to resolve symbolnames :native($libname)
at run-time, not only constants at parse-time, as via apply_attrs(),
which does the import in a BEGIN{} block.

Closes #291
As described in http://perl11.org/blog/attributes-args.html

perldiag: document standalone :symbol warning

add native and symbol() helpers

and fix start_subparse to start the attribute->import call.

skip miniperl, set ENTERFFI type
handle GvCV, SvRV and direct CV in ENTERFFI.
no overloaded object and no LV.

Set the right type already in the ck_subr to have less
op misses in entersub, also for xsub calls.
Note that a compile-time ffi call will not fall back to
a user-sub if redefined. Only done for XS to Perl or Perl to XS/FFI.

Simplify a few builtins.

Change attribute args: "native(" is followed by the arg.

start with the C part: ffi_call
remove unneeded leaveffi, prepare cfi usage.

document the ffi

fix extern sub parsing

and also lexical 'my extern sub name();'.
extern needs to trigger compile-time attributes->import().

checkcfgvar new config vars

cperl Porting/checkcfgvar.pl d_libffi i_ffi useffi  --default=undef --regen
note that vms has a libffi port:
  http://de.openvms.org/OpenVMS-Ports/detail.php?id=141
which needs to be installed/probed for.

add nativeconv() attribute
need a config-time helper for valid ABI values

prepare :encoded() attribute
for Str args or CV rettypes. TODO: attach
the encoding layer to the sig or ret pass.

Unify perldiag warnings. Less memory, same content.

fix prep_cif without USE_FFI
throw a compile-warning libffi not available
via warnings "syntax".
Normally we should suppress such declaration warnings,
as only calling extern subs should be forbidden without libffi.

fix the arg and CvHASSIG handling.
TODO: run-time signature type checks, prep_ffi_ret.

implement prep_ffi_ret
with all new ffi types (see https://docs.perl6.org/language/nativecall)

improve prep_ffi_ret types
change default rettype from :long to :void, analog to perl6.
simplify the type handling, encoded missing for str.

implement prep_ffi_sig

attr parsing: add parser in_sub and lex_attr_state

in_sub is needed to allow attributes not only in my decls.
lex_attr_state is needed to save the subname LEXER state of either
XATTRBLOCK or XATTRTERM over subsignature parsing, which destroyes this state
but is needed afterwards in subattrlist.

fix PL_in_sub state, for pmruntime funcs. fixes t/re/pat.t
my $died=qr/(?{})/;$error=$died?($@||qq(Zombie)):qq(none);
the qr func setting in_sub, and :qq(none) consuming it falsely

silence conversion and nonnull optimizer warnings
one since gcc 6.0. clang not yet checked.

magic ffienc for the :encoded attribute WIP
for string arguments and return type, PAD sv attachments.

Maybe use it also for all string values (as in Perl6), added to Encode when
being used outside of Latin-1/UTF-8.  But then as index into an encoded
array of names.  Now as shared name, attached as new F ffienc magic.

TODO: and add an attributes->import catchall CvEXTERN setter,
for extern sub cases where the parser forgot to call it with
"native".

parse empty extern sub () as sig, not proto

'extern sub name ()' is not an empty prototype, it's an empty signature.
treat 'sub name () :native' also as is_extern (EXTERNSUB token), to
signify () as signature, not as prototype.

attributes::get returns native
not native(lib) or the CvXFFI. Not symbol(name), encoded(name), nativeconv() yet

add warnings ffi
for the compile-time no ffi without DynaLoader warning.
Add the associated run-time error: Null extern sub symbol.

ffi: fix :symbol for slabbed CvFFILIB

also ignore find_symbol dlsym errors.
fix some PADLIST assertions.

attr_runtime: defer SAVEFREEOP(attr)
from new{ATTR,MY}SUB to attrs_runtime.
enhance dup_attrlist for variables to protect from SAVEFREEOP(attrs).

use GVSV, not just GV for the attribute argument. But keep using
REGFGEN, not SREFGEN, because peep and fold_constants rely on the bad
SREFGEN-null-kid format, and cannot deal with SREFGEN-kid.

Closes #291

harmonize diagnostic messages
ffi warnings and errors

fix sub EXISTING_SYM () :native :symbol(OTHERSYM)

use flat lists as attrs argument to attributes->import, not
nested. this was ignore in dup_attrslist().
add a testcase to test for the 2nd :symbol(OTHER) to resolve, not
skip.
Change the :symbol is already resolved warning to redefine, and only
if it's superfluous, resolving to the same symbol.

fix the attrs double-frees
  but still some minor attrs leaks, compile-time only.
  no ffi leaks at run-time though.
fix extern sub :attr
fix the externsub attribute case with import call for native,
fix lexer for several attributes: cv specific,
fix one minor SV leak in attributes::get
allow NULL rvalue in prep_ffi_ret.

windows and travis configs

harmonize prep_ffi_ret decls.

windows passes with the I_DLFCN fix appveypr smokes without libffi.
Need to enable it yet, copying the dlls from somewhere. Best with a
win32/ helper.

improve the tests skips

fix RTLD_DEFAULT logic

on windows it will fail, dl_load_file already did the searches.
on BSDs it is -2, everywhere else 0.
include dlfcn.h

I_DLFCN: not available under MSVC

util.c included this, but skipped on windows
which has no USE_C_BACKTRACE.

The win32 config files were wrong.

handle more type errors
invalid attribute arguments

prepare for more native const ops
not just one

c++ -fpermissive compat

use memcpy() which does a better copy of the wanted size,
and is optimized to the same code as a simple cast.
esp. we don't use a union, when we can use a single and more precise line.

we cannot use void* with C++, use char* instead.

improve the tests to use int, not long.

fix GVSV threaded

On threads a GVSV for the native($n) argument is invalid,
we need to use SVREF(GVOP) which is a PADOP.
This failed in op destruction on the invalid padix.

There is a problem with the padix from the upper scope.
Use the previous padix when copying it to the attributes->import
call.

reindent newGVOP and other overlong calls
no functional changes.

enum parser->lex_attr_state

rurban added a commit that referenced this issue Sep 13, 2018

ffi: probe in Configure
i_ffi, d_libffi, useffi. See #22

findffi: search all the libffi versions, expand
to absolute path as -I../ doesnt work.

vms: add libffi probes (untested)

Probe for the OpenVMS libffi port, also needed for python ctypes.
A 3.0.9 port exists for HP-UX/ia64, VMS/Alpha and VMS/ia64, but not
sure about its status, esp. OpenVMS. VAX should work.

find cygwin libXXX.dll.a libs
esp. for -lffi, which has no static lib.

rurban added a commit that referenced this issue Sep 13, 2018

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

parse attributes :native :symbol
set CvFFILIB via dl_load_file and CvXSUB symbol via dl_find_symbol.
TODO: set from SV values, not just constants.

use sv_chop in toke to advance PL_lex_stuff
use the OOK hack to do SvPVX(PL_lex_stuff)++
otherwise it will fail in sv_free. avoid copies.

add enterffi op to compiler

add and fix core extern tests WIP
not deparsed yet.

Resolve core attribute arguments, runtime setters

Some builtin attributes need to resolve symbolnames :native($libname)
at run-time, not only constants at parse-time, as via apply_attrs(),
which does the import in a BEGIN{} block.

Closes #291
As described in http://perl11.org/blog/attributes-args.html

perldiag: document standalone :symbol warning

add native and symbol() helpers

and fix start_subparse to start the attribute->import call.

skip miniperl, set ENTERFFI type
handle GvCV, SvRV and direct CV in ENTERFFI.
no overloaded object and no LV.

Set the right type already in the ck_subr to have less
op misses in entersub, also for xsub calls.
Note that a compile-time ffi call will not fall back to
a user-sub if redefined. Only done for XS to Perl or Perl to XS/FFI.

Simplify a few builtins.

Change attribute args: "native(" is followed by the arg.

start with the C part: ffi_call
remove unneeded leaveffi, prepare cfi usage.

document the ffi

fix extern sub parsing

and also lexical 'my extern sub name();'.
extern needs to trigger compile-time attributes->import().

checkcfgvar new config vars

cperl Porting/checkcfgvar.pl d_libffi i_ffi useffi  --default=undef --regen
note that vms has a libffi port:
  http://de.openvms.org/OpenVMS-Ports/detail.php?id=141
which needs to be installed/probed for.

add nativeconv() attribute
need a config-time helper for valid ABI values

prepare :encoded() attribute
for Str args or CV rettypes. TODO: attach
the encoding layer to the sig or ret pass.

Unify perldiag warnings. Less memory, same content.

fix prep_cif without USE_FFI
throw a compile-warning libffi not available
via warnings "syntax".
Normally we should suppress such declaration warnings,
as only calling extern subs should be forbidden without libffi.

fix the arg and CvHASSIG handling.
TODO: run-time signature type checks, prep_ffi_ret.

implement prep_ffi_ret
with all new ffi types (see https://docs.perl6.org/language/nativecall)

improve prep_ffi_ret types
change default rettype from :long to :void, analog to perl6.
simplify the type handling, encoded missing for str.

implement prep_ffi_sig

attr parsing: add parser in_sub and lex_attr_state

in_sub is needed to allow attributes not only in my decls.
lex_attr_state is needed to save the subname LEXER state of either
XATTRBLOCK or XATTRTERM over subsignature parsing, which destroyes this state
but is needed afterwards in subattrlist.

fix PL_in_sub state, for pmruntime funcs. fixes t/re/pat.t
my $died=qr/(?{})/;$error=$died?($@||qq(Zombie)):qq(none);
the qr func setting in_sub, and :qq(none) consuming it falsely

silence conversion and nonnull optimizer warnings
one since gcc 6.0. clang not yet checked.

magic ffienc for the :encoded attribute WIP
for string arguments and return type, PAD sv attachments.

Maybe use it also for all string values (as in Perl6), added to Encode when
being used outside of Latin-1/UTF-8.  But then as index into an encoded
array of names.  Now as shared name, attached as new F ffienc magic.

TODO: and add an attributes->import catchall CvEXTERN setter,
for extern sub cases where the parser forgot to call it with
"native".

parse empty extern sub () as sig, not proto

'extern sub name ()' is not an empty prototype, it's an empty signature.
treat 'sub name () :native' also as is_extern (EXTERNSUB token), to
signify () as signature, not as prototype.

attributes::get returns native
not native(lib) or the CvXFFI. Not symbol(name), encoded(name), nativeconv() yet

add warnings ffi
for the compile-time no ffi without DynaLoader warning.
Add the associated run-time error: Null extern sub symbol.

ffi: fix :symbol for slabbed CvFFILIB

also ignore find_symbol dlsym errors.
fix some PADLIST assertions.

attr_runtime: defer SAVEFREEOP(attr)
from new{ATTR,MY}SUB to attrs_runtime.
enhance dup_attrlist for variables to protect from SAVEFREEOP(attrs).

use GVSV, not just GV for the attribute argument. But keep using
REGFGEN, not SREFGEN, because peep and fold_constants rely on the bad
SREFGEN-null-kid format, and cannot deal with SREFGEN-kid.

Closes #291

harmonize diagnostic messages
ffi warnings and errors

fix sub EXISTING_SYM () :native :symbol(OTHERSYM)

use flat lists as attrs argument to attributes->import, not
nested. this was ignore in dup_attrslist().
add a testcase to test for the 2nd :symbol(OTHER) to resolve, not
skip.
Change the :symbol is already resolved warning to redefine, and only
if it's superfluous, resolving to the same symbol.

fix the attrs double-frees
  but still some minor attrs leaks, compile-time only.
  no ffi leaks at run-time though.
fix extern sub :attr
fix the externsub attribute case with import call for native,
fix lexer for several attributes: cv specific,
fix one minor SV leak in attributes::get
allow NULL rvalue in prep_ffi_ret.

windows and travis configs

harmonize prep_ffi_ret decls.

windows passes with the I_DLFCN fix appveypr smokes without libffi.
Need to enable it yet, copying the dlls from somewhere. Best with a
win32/ helper.

improve the tests skips

fix RTLD_DEFAULT logic

on windows it will fail, dl_load_file already did the searches.
on BSDs it is -2, everywhere else 0.
include dlfcn.h

I_DLFCN: not available under MSVC

util.c included this, but skipped on windows
which has no USE_C_BACKTRACE.

The win32 config files were wrong.

handle more type errors
invalid attribute arguments

prepare for more native const ops
not just one

c++ -fpermissive compat

use memcpy() which does a better copy of the wanted size,
and is optimized to the same code as a simple cast.
esp. we don't use a union, when we can use a single and more precise line.

we cannot use void* with C++, use char* instead.

improve the tests to use int, not long.

fix GVSV threaded

On threads a GVSV for the native($n) argument is invalid,
we need to use SVREF(GVOP) which is a PADOP.
This failed in op destruction on the invalid padix.

There is a problem with the padix from the upper scope.
Use the previous padix when copying it to the attributes->import
call.

reindent newGVOP and other overlong calls
no functional changes.

enum parser->lex_attr_state

@rurban rurban added this to the v5.29.0c milestone Sep 14, 2018

rurban added a commit that referenced this issue Sep 14, 2018

ffi: probe in Configure
i_ffi, d_libffi, useffi. See #22

findffi: search all the libffi versions, expand
to absolute path as -I../ doesnt work.

vms: add libffi probes (untested)

Probe for the OpenVMS libffi port, also needed for python ctypes.
A 3.0.9 port exists for HP-UX/ia64, VMS/Alpha and VMS/ia64, but not
sure about its status, esp. OpenVMS. VAX should work.

find cygwin libXXX.dll.a libs
esp. for -lffi, which has no static lib.

rurban added a commit that referenced this issue Sep 14, 2018

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

parse attributes :native :symbol
set CvFFILIB via dl_load_file and CvXSUB symbol via dl_find_symbol.
TODO: set from SV values, not just constants.

use sv_chop in toke to advance PL_lex_stuff
use the OOK hack to do SvPVX(PL_lex_stuff)++
otherwise it will fail in sv_free. avoid copies.

add enterffi op to compiler

add and fix core extern tests WIP
not deparsed yet.

Resolve core attribute arguments, runtime setters

Some builtin attributes need to resolve symbolnames :native($libname)
at run-time, not only constants at parse-time, as via apply_attrs(),
which does the import in a BEGIN{} block.

Closes #291
As described in http://perl11.org/blog/attributes-args.html

perldiag: document standalone :symbol warning

add native and symbol() helpers

and fix start_subparse to start the attribute->import call.

skip miniperl, set ENTERFFI type
handle GvCV, SvRV and direct CV in ENTERFFI.
no overloaded object and no LV.

Set the right type already in the ck_subr to have less
op misses in entersub, also for xsub calls.
Note that a compile-time ffi call will not fall back to
a user-sub if redefined. Only done for XS to Perl or Perl to XS/FFI.

Simplify a few builtins.

Change attribute args: "native(" is followed by the arg.

start with the C part: ffi_call
remove unneeded leaveffi, prepare cfi usage.

document the ffi

fix extern sub parsing

and also lexical 'my extern sub name();'.
extern needs to trigger compile-time attributes->import().

checkcfgvar new config vars

cperl Porting/checkcfgvar.pl d_libffi i_ffi useffi  --default=undef --regen
note that vms has a libffi port:
  http://de.openvms.org/OpenVMS-Ports/detail.php?id=141
which needs to be installed/probed for.

add nativeconv() attribute
need a config-time helper for valid ABI values

prepare :encoded() attribute
for Str args or CV rettypes. TODO: attach
the encoding layer to the sig or ret pass.

Unify perldiag warnings. Less memory, same content.

fix prep_cif without USE_FFI
throw a compile-warning libffi not available
via warnings "syntax".
Normally we should suppress such declaration warnings,
as only calling extern subs should be forbidden without libffi.

fix the arg and CvHASSIG handling.
TODO: run-time signature type checks, prep_ffi_ret.

implement prep_ffi_ret
with all new ffi types (see https://docs.perl6.org/language/nativecall)

improve prep_ffi_ret types
change default rettype from :long to :void, analog to perl6.
simplify the type handling, encoded missing for str.

implement prep_ffi_sig

attr parsing: add parser in_sub and lex_attr_state

in_sub is needed to allow attributes not only in my decls.
lex_attr_state is needed to save the subname LEXER state of either
XATTRBLOCK or XATTRTERM over subsignature parsing, which destroyes this state
but is needed afterwards in subattrlist.

fix PL_in_sub state, for pmruntime funcs. fixes t/re/pat.t
my $died=qr/(?{})/;$error=$died?($@||qq(Zombie)):qq(none);
the qr func setting in_sub, and :qq(none) consuming it falsely

silence conversion and nonnull optimizer warnings
one since gcc 6.0. clang not yet checked.

magic ffienc for the :encoded attribute WIP
for string arguments and return type, PAD sv attachments.

Maybe use it also for all string values (as in Perl6), added to Encode when
being used outside of Latin-1/UTF-8.  But then as index into an encoded
array of names.  Now as shared name, attached as new F ffienc magic.

TODO: and add an attributes->import catchall CvEXTERN setter,
for extern sub cases where the parser forgot to call it with
"native".

parse empty extern sub () as sig, not proto

'extern sub name ()' is not an empty prototype, it's an empty signature.
treat 'sub name () :native' also as is_extern (EXTERNSUB token), to
signify () as signature, not as prototype.

attributes::get returns native
not native(lib) or the CvXFFI. Not symbol(name), encoded(name), nativeconv() yet

add warnings ffi
for the compile-time no ffi without DynaLoader warning.
Add the associated run-time error: Null extern sub symbol.

ffi: fix :symbol for slabbed CvFFILIB

also ignore find_symbol dlsym errors.
fix some PADLIST assertions.

attr_runtime: defer SAVEFREEOP(attr)
from new{ATTR,MY}SUB to attrs_runtime.
enhance dup_attrlist for variables to protect from SAVEFREEOP(attrs).

use GVSV, not just GV for the attribute argument. But keep using
REGFGEN, not SREFGEN, because peep and fold_constants rely on the bad
SREFGEN-null-kid format, and cannot deal with SREFGEN-kid.

Closes #291

harmonize diagnostic messages
ffi warnings and errors

fix sub EXISTING_SYM () :native :symbol(OTHERSYM)

use flat lists as attrs argument to attributes->import, not
nested. this was ignore in dup_attrslist().
add a testcase to test for the 2nd :symbol(OTHER) to resolve, not
skip.
Change the :symbol is already resolved warning to redefine, and only
if it's superfluous, resolving to the same symbol.

fix the attrs double-frees
  but still some minor attrs leaks, compile-time only.
  no ffi leaks at run-time though.
fix extern sub :attr
fix the externsub attribute case with import call for native,
fix lexer for several attributes: cv specific,
fix one minor SV leak in attributes::get
allow NULL rvalue in prep_ffi_ret.

windows and travis configs

harmonize prep_ffi_ret decls.

windows passes with the I_DLFCN fix appveypr smokes without libffi.
Need to enable it yet, copying the dlls from somewhere. Best with a
win32/ helper.

improve the tests skips

fix RTLD_DEFAULT logic

on windows it will fail, dl_load_file already did the searches.
on BSDs it is -2, everywhere else 0.
include dlfcn.h

I_DLFCN: not available under MSVC

util.c included this, but skipped on windows
which has no USE_C_BACKTRACE.

The win32 config files were wrong.

handle more type errors
invalid attribute arguments

prepare for more native const ops
not just one

c++ -fpermissive compat

use memcpy() which does a better copy of the wanted size,
and is optimized to the same code as a simple cast.
esp. we don't use a union, when we can use a single and more precise line.

we cannot use void* with C++, use char* instead.

improve the tests to use int, not long.

fix GVSV threaded

On threads a GVSV for the native($n) argument is invalid,
we need to use SVREF(GVOP) which is a PADOP.
This failed in op destruction on the invalid padix.

There is a problem with the padix from the upper scope.
Use the previous padix when copying it to the attributes->import
call.

reindent newGVOP and other overlong calls
no functional changes.

enum parser->lex_attr_state

rurban added a commit that referenced this issue Sep 14, 2018

ffi: probe in Configure
i_ffi, d_libffi, useffi. See #22

findffi: search all the libffi versions, expand
to absolute path as -I../ doesnt work.

vms: add libffi probes (untested)

Probe for the OpenVMS libffi port, also needed for python ctypes.
A 3.0.9 port exists for HP-UX/ia64, VMS/Alpha and VMS/ia64, but not
sure about its status, esp. OpenVMS. VAX should work.

find cygwin libXXX.dll.a libs
esp. for -lffi, which has no static lib.

rurban added a commit that referenced this issue Sep 14, 2018

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

parse attributes :native :symbol
set CvFFILIB via dl_load_file and CvXSUB symbol via dl_find_symbol.
TODO: set from SV values, not just constants.

use sv_chop in toke to advance PL_lex_stuff
use the OOK hack to do SvPVX(PL_lex_stuff)++
otherwise it will fail in sv_free. avoid copies.

add enterffi op to compiler

add and fix core extern tests WIP
not deparsed yet.

Resolve core attribute arguments, runtime setters

Some builtin attributes need to resolve symbolnames :native($libname)
at run-time, not only constants at parse-time, as via apply_attrs(),
which does the import in a BEGIN{} block.

Closes #291
As described in http://perl11.org/blog/attributes-args.html

perldiag: document standalone :symbol warning

add native and symbol() helpers

and fix start_subparse to start the attribute->import call.

skip miniperl, set ENTERFFI type
handle GvCV, SvRV and direct CV in ENTERFFI.
no overloaded object and no LV.

Set the right type already in the ck_subr to have less
op misses in entersub, also for xsub calls.
Note that a compile-time ffi call will not fall back to
a user-sub if redefined. Only done for XS to Perl or Perl to XS/FFI.

Simplify a few builtins.

Change attribute args: "native(" is followed by the arg.

start with the C part: ffi_call
remove unneeded leaveffi, prepare cfi usage.

document the ffi

fix extern sub parsing

and also lexical 'my extern sub name();'.
extern needs to trigger compile-time attributes->import().

checkcfgvar new config vars

cperl Porting/checkcfgvar.pl d_libffi i_ffi useffi  --default=undef --regen
note that vms has a libffi port:
  http://de.openvms.org/OpenVMS-Ports/detail.php?id=141
which needs to be installed/probed for.

add nativeconv() attribute
need a config-time helper for valid ABI values

prepare :encoded() attribute
for Str args or CV rettypes. TODO: attach
the encoding layer to the sig or ret pass.

Unify perldiag warnings. Less memory, same content.

fix prep_cif without USE_FFI
throw a compile-warning libffi not available
via warnings "syntax".
Normally we should suppress such declaration warnings,
as only calling extern subs should be forbidden without libffi.

fix the arg and CvHASSIG handling.
TODO: run-time signature type checks, prep_ffi_ret.

implement prep_ffi_ret
with all new ffi types (see https://docs.perl6.org/language/nativecall)

improve prep_ffi_ret types
change default rettype from :long to :void, analog to perl6.
simplify the type handling, encoded missing for str.

implement prep_ffi_sig

attr parsing: add parser in_sub and lex_attr_state

in_sub is needed to allow attributes not only in my decls.
lex_attr_state is needed to save the subname LEXER state of either
XATTRBLOCK or XATTRTERM over subsignature parsing, which destroyes this state
but is needed afterwards in subattrlist.

fix PL_in_sub state, for pmruntime funcs. fixes t/re/pat.t
my $died=qr/(?{})/;$error=$died?($@||qq(Zombie)):qq(none);
the qr func setting in_sub, and :qq(none) consuming it falsely

silence conversion and nonnull optimizer warnings
one since gcc 6.0. clang not yet checked.

magic ffienc for the :encoded attribute WIP
for string arguments and return type, PAD sv attachments.

Maybe use it also for all string values (as in Perl6), added to Encode when
being used outside of Latin-1/UTF-8.  But then as index into an encoded
array of names.  Now as shared name, attached as new F ffienc magic.

TODO: and add an attributes->import catchall CvEXTERN setter,
for extern sub cases where the parser forgot to call it with
"native".

parse empty extern sub () as sig, not proto

'extern sub name ()' is not an empty prototype, it's an empty signature.
treat 'sub name () :native' also as is_extern (EXTERNSUB token), to
signify () as signature, not as prototype.

attributes::get returns native
not native(lib) or the CvXFFI. Not symbol(name), encoded(name), nativeconv() yet

add warnings ffi
for the compile-time no ffi without DynaLoader warning.
Add the associated run-time error: Null extern sub symbol.

ffi: fix :symbol for slabbed CvFFILIB

also ignore find_symbol dlsym errors.
fix some PADLIST assertions.

attr_runtime: defer SAVEFREEOP(attr)
from new{ATTR,MY}SUB to attrs_runtime.
enhance dup_attrlist for variables to protect from SAVEFREEOP(attrs).

use GVSV, not just GV for the attribute argument. But keep using
REGFGEN, not SREFGEN, because peep and fold_constants rely on the bad
SREFGEN-null-kid format, and cannot deal with SREFGEN-kid.

Closes #291

harmonize diagnostic messages
ffi warnings and errors

fix sub EXISTING_SYM () :native :symbol(OTHERSYM)

use flat lists as attrs argument to attributes->import, not
nested. this was ignore in dup_attrslist().
add a testcase to test for the 2nd :symbol(OTHER) to resolve, not
skip.
Change the :symbol is already resolved warning to redefine, and only
if it's superfluous, resolving to the same symbol.

fix the attrs double-frees
  but still some minor attrs leaks, compile-time only.
  no ffi leaks at run-time though.
fix extern sub :attr
fix the externsub attribute case with import call for native,
fix lexer for several attributes: cv specific,
fix one minor SV leak in attributes::get
allow NULL rvalue in prep_ffi_ret.

windows and travis configs

harmonize prep_ffi_ret decls.

windows passes with the I_DLFCN fix appveypr smokes without libffi.
Need to enable it yet, copying the dlls from somewhere. Best with a
win32/ helper.

improve the tests skips

fix RTLD_DEFAULT logic

on windows it will fail, dl_load_file already did the searches.
on BSDs it is -2, everywhere else 0.
include dlfcn.h

I_DLFCN: not available under MSVC

util.c included this, but skipped on windows
which has no USE_C_BACKTRACE.

The win32 config files were wrong.

handle more type errors
invalid attribute arguments

prepare for more native const ops
not just one

c++ -fpermissive compat

use memcpy() which does a better copy of the wanted size,
and is optimized to the same code as a simple cast.
esp. we don't use a union, when we can use a single and more precise line.

we cannot use void* with C++, use char* instead.

improve the tests to use int, not long.

fix GVSV threaded

On threads a GVSV for the native($n) argument is invalid,
we need to use SVREF(GVOP) which is a PADOP.
This failed in op destruction on the invalid padix.

There is a problem with the padix from the upper scope.
Use the previous padix when copying it to the attributes->import
call.

reindent newGVOP and other overlong calls
no functional changes.

enum parser->lex_attr_state

rurban added a commit that referenced this issue Sep 14, 2018

ffi: probe in Configure
i_ffi, d_libffi, useffi. See #22

findffi: search all the libffi versions, expand
to absolute path as -I../ doesnt work.

vms: add libffi probes (untested)

Probe for the OpenVMS libffi port, also needed for python ctypes.
A 3.0.9 port exists for HP-UX/ia64, VMS/Alpha and VMS/ia64, but not
sure about its status, esp. OpenVMS. VAX should work.

find cygwin libXXX.dll.a libs
esp. for -lffi, which has no static lib.

rurban added a commit that referenced this issue Sep 14, 2018

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

parse attributes :native :symbol
set CvFFILIB via dl_load_file and CvXSUB symbol via dl_find_symbol.
TODO: set from SV values, not just constants.

use sv_chop in toke to advance PL_lex_stuff
use the OOK hack to do SvPVX(PL_lex_stuff)++
otherwise it will fail in sv_free. avoid copies.

add enterffi op to compiler

add and fix core extern tests WIP
not deparsed yet.

Resolve core attribute arguments, runtime setters

Some builtin attributes need to resolve symbolnames :native($libname)
at run-time, not only constants at parse-time, as via apply_attrs(),
which does the import in a BEGIN{} block.

Closes #291
As described in http://perl11.org/blog/attributes-args.html

perldiag: document standalone :symbol warning

add native and symbol() helpers

and fix start_subparse to start the attribute->import call.

skip miniperl, set ENTERFFI type
handle GvCV, SvRV and direct CV in ENTERFFI.
no overloaded object and no LV.

Set the right type already in the ck_subr to have less
op misses in entersub, also for xsub calls.
Note that a compile-time ffi call will not fall back to
a user-sub if redefined. Only done for XS to Perl or Perl to XS/FFI.

Simplify a few builtins.

Change attribute args: "native(" is followed by the arg.

start with the C part: ffi_call
remove unneeded leaveffi, prepare cfi usage.

document the ffi

fix extern sub parsing

and also lexical 'my extern sub name();'.
extern needs to trigger compile-time attributes->import().

checkcfgvar new config vars

cperl Porting/checkcfgvar.pl d_libffi i_ffi useffi  --default=undef --regen
note that vms has a libffi port:
  http://de.openvms.org/OpenVMS-Ports/detail.php?id=141
which needs to be installed/probed for.

add nativeconv() attribute
need a config-time helper for valid ABI values

prepare :encoded() attribute
for Str args or CV rettypes. TODO: attach
the encoding layer to the sig or ret pass.

Unify perldiag warnings. Less memory, same content.

fix prep_cif without USE_FFI
throw a compile-warning libffi not available
via warnings "syntax".
Normally we should suppress such declaration warnings,
as only calling extern subs should be forbidden without libffi.

fix the arg and CvHASSIG handling.
TODO: run-time signature type checks, prep_ffi_ret.

implement prep_ffi_ret
with all new ffi types (see https://docs.perl6.org/language/nativecall)

improve prep_ffi_ret types
change default rettype from :long to :void, analog to perl6.
simplify the type handling, encoded missing for str.

implement prep_ffi_sig

attr parsing: add parser in_sub and lex_attr_state

in_sub is needed to allow attributes not only in my decls.
lex_attr_state is needed to save the subname LEXER state of either
XATTRBLOCK or XATTRTERM over subsignature parsing, which destroyes this state
but is needed afterwards in subattrlist.

fix PL_in_sub state, for pmruntime funcs. fixes t/re/pat.t
my $died=qr/(?{})/;$error=$died?($@||qq(Zombie)):qq(none);
the qr func setting in_sub, and :qq(none) consuming it falsely

silence conversion and nonnull optimizer warnings
one since gcc 6.0. clang not yet checked.

magic ffienc for the :encoded attribute WIP
for string arguments and return type, PAD sv attachments.

Maybe use it also for all string values (as in Perl6), added to Encode when
being used outside of Latin-1/UTF-8.  But then as index into an encoded
array of names.  Now as shared name, attached as new F ffienc magic.

TODO: and add an attributes->import catchall CvEXTERN setter,
for extern sub cases where the parser forgot to call it with
"native".

parse empty extern sub () as sig, not proto

'extern sub name ()' is not an empty prototype, it's an empty signature.
treat 'sub name () :native' also as is_extern (EXTERNSUB token), to
signify () as signature, not as prototype.

attributes::get returns native
not native(lib) or the CvXFFI. Not symbol(name), encoded(name), nativeconv() yet

add warnings ffi
for the compile-time no ffi without DynaLoader warning.
Add the associated run-time error: Null extern sub symbol.

ffi: fix :symbol for slabbed CvFFILIB

also ignore find_symbol dlsym errors.
fix some PADLIST assertions.

attr_runtime: defer SAVEFREEOP(attr)
from new{ATTR,MY}SUB to attrs_runtime.
enhance dup_attrlist for variables to protect from SAVEFREEOP(attrs).

use GVSV, not just GV for the attribute argument. But keep using
REGFGEN, not SREFGEN, because peep and fold_constants rely on the bad
SREFGEN-null-kid format, and cannot deal with SREFGEN-kid.

Closes #291

harmonize diagnostic messages
ffi warnings and errors

fix sub EXISTING_SYM () :native :symbol(OTHERSYM)

use flat lists as attrs argument to attributes->import, not
nested. this was ignore in dup_attrslist().
add a testcase to test for the 2nd :symbol(OTHER) to resolve, not
skip.
Change the :symbol is already resolved warning to redefine, and only
if it's superfluous, resolving to the same symbol.

fix the attrs double-frees
  but still some minor attrs leaks, compile-time only.
  no ffi leaks at run-time though.
fix extern sub :attr
fix the externsub attribute case with import call for native,
fix lexer for several attributes: cv specific,
fix one minor SV leak in attributes::get
allow NULL rvalue in prep_ffi_ret.

windows and travis configs

harmonize prep_ffi_ret decls.

windows passes with the I_DLFCN fix appveypr smokes without libffi.
Need to enable it yet, copying the dlls from somewhere. Best with a
win32/ helper.

improve the tests skips

fix RTLD_DEFAULT logic

on windows it will fail, dl_load_file already did the searches.
on BSDs it is -2, everywhere else 0.
include dlfcn.h

I_DLFCN: not available under MSVC

util.c included this, but skipped on windows
which has no USE_C_BACKTRACE.

The win32 config files were wrong.

handle more type errors
invalid attribute arguments

prepare for more native const ops
not just one

c++ -fpermissive compat

use memcpy() which does a better copy of the wanted size,
and is optimized to the same code as a simple cast.
esp. we don't use a union, when we can use a single and more precise line.

we cannot use void* with C++, use char* instead.

improve the tests to use int, not long.

fix GVSV threaded

On threads a GVSV for the native($n) argument is invalid,
we need to use SVREF(GVOP) which is a PADOP.
This failed in op destruction on the invalid padix.

There is a problem with the padix from the upper scope.
Use the previous padix when copying it to the attributes->import
call.

reindent newGVOP and other overlong calls
no functional changes.

enum parser->lex_attr_state

rurban added a commit that referenced this issue Sep 14, 2018

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

parse attributes :native :symbol
set CvFFILIB via dl_load_file and CvXSUB symbol via dl_find_symbol.
TODO: set from SV values, not just constants.

use sv_chop in toke to advance PL_lex_stuff
use the OOK hack to do SvPVX(PL_lex_stuff)++
otherwise it will fail in sv_free. avoid copies.

add enterffi op to compiler

add and fix core extern tests WIP
not deparsed yet.

Resolve core attribute arguments, runtime setters

Some builtin attributes need to resolve symbolnames :native($libname)
at run-time, not only constants at parse-time, as via apply_attrs(),
which does the import in a BEGIN{} block.

Closes #291
As described in http://perl11.org/blog/attributes-args.html

perldiag: document standalone :symbol warning

add native and symbol() helpers

and fix start_subparse to start the attribute->import call.

skip miniperl, set ENTERFFI type
handle GvCV, SvRV and direct CV in ENTERFFI.
no overloaded object and no LV.

Set the right type already in the ck_subr to have less
op misses in entersub, also for xsub calls.
Note that a compile-time ffi call will not fall back to
a user-sub if redefined. Only done for XS to Perl or Perl to XS/FFI.

Simplify a few builtins.

Change attribute args: "native(" is followed by the arg.

start with the C part: ffi_call
remove unneeded leaveffi, prepare cfi usage.

document the ffi

fix extern sub parsing

and also lexical 'my extern sub name();'.
extern needs to trigger compile-time attributes->import().

checkcfgvar new config vars

cperl Porting/checkcfgvar.pl d_libffi i_ffi useffi  --default=undef --regen
note that vms has a libffi port:
  http://de.openvms.org/OpenVMS-Ports/detail.php?id=141
which needs to be installed/probed for.

add nativeconv() attribute
need a config-time helper for valid ABI values

prepare :encoded() attribute
for Str args or CV rettypes. TODO: attach
the encoding layer to the sig or ret pass.

Unify perldiag warnings. Less memory, same content.

fix prep_cif without USE_FFI
throw a compile-warning libffi not available
via warnings "syntax".
Normally we should suppress such declaration warnings,
as only calling extern subs should be forbidden without libffi.

fix the arg and CvHASSIG handling.
TODO: run-time signature type checks, prep_ffi_ret.

implement prep_ffi_ret
with all new ffi types (see https://docs.perl6.org/language/nativecall)

improve prep_ffi_ret types
change default rettype from :long to :void, analog to perl6.
simplify the type handling, encoded missing for str.

implement prep_ffi_sig

attr parsing: add parser in_sub and lex_attr_state

in_sub is needed to allow attributes not only in my decls.
lex_attr_state is needed to save the subname LEXER state of either
XATTRBLOCK or XATTRTERM over subsignature parsing, which destroyes this state
but is needed afterwards in subattrlist.

fix PL_in_sub state, for pmruntime funcs. fixes t/re/pat.t
my $died=qr/(?{})/;$error=$died?($@||qq(Zombie)):qq(none);
the qr func setting in_sub, and :qq(none) consuming it falsely

silence conversion and nonnull optimizer warnings
one since gcc 6.0. clang not yet checked.

magic ffienc for the :encoded attribute WIP
for string arguments and return type, PAD sv attachments.

Maybe use it also for all string values (as in Perl6), added to Encode when
being used outside of Latin-1/UTF-8.  But then as index into an encoded
array of names.  Now as shared name, attached as new F ffienc magic.

TODO: and add an attributes->import catchall CvEXTERN setter,
for extern sub cases where the parser forgot to call it with
"native".

parse empty extern sub () as sig, not proto

'extern sub name ()' is not an empty prototype, it's an empty signature.
treat 'sub name () :native' also as is_extern (EXTERNSUB token), to
signify () as signature, not as prototype.

attributes::get returns native
not native(lib) or the CvXFFI. Not symbol(name), encoded(name), nativeconv() yet

add warnings ffi
for the compile-time no ffi without DynaLoader warning.
Add the associated run-time error: Null extern sub symbol.

ffi: fix :symbol for slabbed CvFFILIB

also ignore find_symbol dlsym errors.
fix some PADLIST assertions.

attr_runtime: defer SAVEFREEOP(attr)
from new{ATTR,MY}SUB to attrs_runtime.
enhance dup_attrlist for variables to protect from SAVEFREEOP(attrs).

use GVSV, not just GV for the attribute argument. But keep using
REGFGEN, not SREFGEN, because peep and fold_constants rely on the bad
SREFGEN-null-kid format, and cannot deal with SREFGEN-kid.

Closes #291

harmonize diagnostic messages
ffi warnings and errors

fix sub EXISTING_SYM () :native :symbol(OTHERSYM)

use flat lists as attrs argument to attributes->import, not
nested. this was ignore in dup_attrslist().
add a testcase to test for the 2nd :symbol(OTHER) to resolve, not
skip.
Change the :symbol is already resolved warning to redefine, and only
if it's superfluous, resolving to the same symbol.

fix the attrs double-frees
  but still some minor attrs leaks, compile-time only.
  no ffi leaks at run-time though.
fix extern sub :attr
fix the externsub attribute case with import call for native,
fix lexer for several attributes: cv specific,
fix one minor SV leak in attributes::get
allow NULL rvalue in prep_ffi_ret.

windows and travis configs

harmonize prep_ffi_ret decls.

windows passes with the I_DLFCN fix appveypr smokes without libffi.
Need to enable it yet, copying the dlls from somewhere. Best with a
win32/ helper.

improve the tests skips

fix RTLD_DEFAULT logic

on windows it will fail, dl_load_file already did the searches.
on BSDs it is -2, everywhere else 0.
include dlfcn.h

I_DLFCN: not available under MSVC

util.c included this, but skipped on windows
which has no USE_C_BACKTRACE.

The win32 config files were wrong.

handle more type errors
invalid attribute arguments

prepare for more native const ops
not just one

c++ -fpermissive compat

use memcpy() which does a better copy of the wanted size,
and is optimized to the same code as a simple cast.
esp. we don't use a union, when we can use a single and more precise line.

we cannot use void* with C++, use char* instead.

improve the tests to use int, not long.

fix GVSV threaded

On threads a GVSV for the native($n) argument is invalid,
we need to use SVREF(GVOP) which is a PADOP.
This failed in op destruction on the invalid padix.

There is a problem with the padix from the upper scope.
Use the previous padix when copying it to the attributes->import
call.

reindent newGVOP and other overlong calls
no functional changes.

enum parser->lex_attr_state

rurban added a commit that referenced this issue Sep 14, 2018

ffi: probe in Configure
i_ffi, d_libffi, useffi. See #22

findffi: search all the libffi versions, expand
to absolute path as -I../ doesnt work.

vms: add libffi probes (untested)

Probe for the OpenVMS libffi port, also needed for python ctypes.
A 3.0.9 port exists for HP-UX/ia64, VMS/Alpha and VMS/ia64, but not
sure about its status, esp. OpenVMS. VAX should work.

find cygwin libXXX.dll.a libs
esp. for -lffi, which has no static lib.

rurban added a commit that referenced this issue Sep 14, 2018

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

parse attributes :native :symbol
set CvFFILIB via dl_load_file and CvXSUB symbol via dl_find_symbol.
TODO: set from SV values, not just constants.

use sv_chop in toke to advance PL_lex_stuff
use the OOK hack to do SvPVX(PL_lex_stuff)++
otherwise it will fail in sv_free. avoid copies.

add enterffi op to compiler

add and fix core extern tests WIP
not deparsed yet.

Resolve core attribute arguments, runtime setters

Some builtin attributes need to resolve symbolnames :native($libname)
at run-time, not only constants at parse-time, as via apply_attrs(),
which does the import in a BEGIN{} block.

Closes #291
As described in http://perl11.org/blog/attributes-args.html

perldiag: document standalone :symbol warning

add native and symbol() helpers

and fix start_subparse to start the attribute->import call.

skip miniperl, set ENTERFFI type
handle GvCV, SvRV and direct CV in ENTERFFI.
no overloaded object and no LV.

Set the right type already in the ck_subr to have less
op misses in entersub, also for xsub calls.
Note that a compile-time ffi call will not fall back to
a user-sub if redefined. Only done for XS to Perl or Perl to XS/FFI.

Simplify a few builtins.

Change attribute args: "native(" is followed by the arg.

start with the C part: ffi_call
remove unneeded leaveffi, prepare cfi usage.

document the ffi

fix extern sub parsing

and also lexical 'my extern sub name();'.
extern needs to trigger compile-time attributes->import().

checkcfgvar new config vars

cperl Porting/checkcfgvar.pl d_libffi i_ffi useffi  --default=undef --regen
note that vms has a libffi port:
  http://de.openvms.org/OpenVMS-Ports/detail.php?id=141
which needs to be installed/probed for.

add nativeconv() attribute
need a config-time helper for valid ABI values

prepare :encoded() attribute
for Str args or CV rettypes. TODO: attach
the encoding layer to the sig or ret pass.

Unify perldiag warnings. Less memory, same content.

fix prep_cif without USE_FFI
throw a compile-warning libffi not available
via warnings "syntax".
Normally we should suppress such declaration warnings,
as only calling extern subs should be forbidden without libffi.

fix the arg and CvHASSIG handling.
TODO: run-time signature type checks, prep_ffi_ret.

implement prep_ffi_ret
with all new ffi types (see https://docs.perl6.org/language/nativecall)

improve prep_ffi_ret types
change default rettype from :long to :void, analog to perl6.
simplify the type handling, encoded missing for str.

implement prep_ffi_sig

attr parsing: add parser in_sub and lex_attr_state

in_sub is needed to allow attributes not only in my decls.
lex_attr_state is needed to save the subname LEXER state of either
XATTRBLOCK or XATTRTERM over subsignature parsing, which destroyes this state
but is needed afterwards in subattrlist.

fix PL_in_sub state, for pmruntime funcs. fixes t/re/pat.t
my $died=qr/(?{})/;$error=$died?($@||qq(Zombie)):qq(none);
the qr func setting in_sub, and :qq(none) consuming it falsely

silence conversion and nonnull optimizer warnings
one since gcc 6.0. clang not yet checked.

magic ffienc for the :encoded attribute WIP
for string arguments and return type, PAD sv attachments.

Maybe use it also for all string values (as in Perl6), added to Encode when
being used outside of Latin-1/UTF-8.  But then as index into an encoded
array of names.  Now as shared name, attached as new F ffienc magic.

TODO: and add an attributes->import catchall CvEXTERN setter,
for extern sub cases where the parser forgot to call it with
"native".

parse empty extern sub () as sig, not proto

'extern sub name ()' is not an empty prototype, it's an empty signature.
treat 'sub name () :native' also as is_extern (EXTERNSUB token), to
signify () as signature, not as prototype.

attributes::get returns native
not native(lib) or the CvXFFI. Not symbol(name), encoded(name), nativeconv() yet

add warnings ffi
for the compile-time no ffi without DynaLoader warning.
Add the associated run-time error: Null extern sub symbol.

ffi: fix :symbol for slabbed CvFFILIB

also ignore find_symbol dlsym errors.
fix some PADLIST assertions.

attr_runtime: defer SAVEFREEOP(attr)
from new{ATTR,MY}SUB to attrs_runtime.
enhance dup_attrlist for variables to protect from SAVEFREEOP(attrs).

use GVSV, not just GV for the attribute argument. But keep using
REGFGEN, not SREFGEN, because peep and fold_constants rely on the bad
SREFGEN-null-kid format, and cannot deal with SREFGEN-kid.

Closes #291

harmonize diagnostic messages
ffi warnings and errors

fix sub EXISTING_SYM () :native :symbol(OTHERSYM)

use flat lists as attrs argument to attributes->import, not
nested. this was ignore in dup_attrslist().
add a testcase to test for the 2nd :symbol(OTHER) to resolve, not
skip.
Change the :symbol is already resolved warning to redefine, and only
if it's superfluous, resolving to the same symbol.

fix the attrs double-frees
  but still some minor attrs leaks, compile-time only.
  no ffi leaks at run-time though.
fix extern sub :attr
fix the externsub attribute case with import call for native,
fix lexer for several attributes: cv specific,
fix one minor SV leak in attributes::get
allow NULL rvalue in prep_ffi_ret.

windows and travis configs

harmonize prep_ffi_ret decls.

windows passes with the I_DLFCN fix appveypr smokes without libffi.
Need to enable it yet, copying the dlls from somewhere. Best with a
win32/ helper.

improve the tests skips

fix RTLD_DEFAULT logic

on windows it will fail, dl_load_file already did the searches.
on BSDs it is -2, everywhere else 0.
include dlfcn.h

I_DLFCN: not available under MSVC

util.c included this, but skipped on windows
which has no USE_C_BACKTRACE.

The win32 config files were wrong.

handle more type errors
invalid attribute arguments

prepare for more native const ops
not just one

c++ -fpermissive compat

use memcpy() which does a better copy of the wanted size,
and is optimized to the same code as a simple cast.
esp. we don't use a union, when we can use a single and more precise line.

we cannot use void* with C++, use char* instead.

improve the tests to use int, not long.

fix GVSV threaded

On threads a GVSV for the native($n) argument is invalid,
we need to use SVREF(GVOP) which is a PADOP.
This failed in op destruction on the invalid padix.

There is a problem with the padix from the upper scope.
Use the previous padix when copying it to the attributes->import
call.

reindent newGVOP and other overlong calls
no functional changes.

enum parser->lex_attr_state

rurban added a commit that referenced this issue Sep 15, 2018

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

parse attributes :native :symbol
set CvFFILIB via dl_load_file and CvXSUB symbol via dl_find_symbol.
TODO: set from SV values, not just constants.

use sv_chop in toke to advance PL_lex_stuff
use the OOK hack to do SvPVX(PL_lex_stuff)++
otherwise it will fail in sv_free. avoid copies.

add enterffi op to compiler

add and fix core extern tests WIP
not deparsed yet.

Resolve core attribute arguments, runtime setters

Some builtin attributes need to resolve symbolnames :native($libname)
at run-time, not only constants at parse-time, as via apply_attrs(),
which does the import in a BEGIN{} block.

Closes #291
As described in http://perl11.org/blog/attributes-args.html

perldiag: document standalone :symbol warning

add native and symbol() helpers

and fix start_subparse to start the attribute->import call.

skip miniperl, set ENTERFFI type
handle GvCV, SvRV and direct CV in ENTERFFI.
no overloaded object and no LV.

Set the right type already in the ck_subr to have less
op misses in entersub, also for xsub calls.
Note that a compile-time ffi call will not fall back to
a user-sub if redefined. Only done for XS to Perl or Perl to XS/FFI.

Simplify a few builtins.

Change attribute args: "native(" is followed by the arg.

start with the C part: ffi_call
remove unneeded leaveffi, prepare cfi usage.

document the ffi

fix extern sub parsing

and also lexical 'my extern sub name();'.
extern needs to trigger compile-time attributes->import().

checkcfgvar new config vars

cperl Porting/checkcfgvar.pl d_libffi i_ffi useffi  --default=undef --regen
note that vms has a libffi port:
  http://de.openvms.org/OpenVMS-Ports/detail.php?id=141
which needs to be installed/probed for.

add nativeconv() attribute
need a config-time helper for valid ABI values

prepare :encoded() attribute
for Str args or CV rettypes. TODO: attach
the encoding layer to the sig or ret pass.

Unify perldiag warnings. Less memory, same content.

fix prep_cif without USE_FFI
throw a compile-warning libffi not available
via warnings "syntax".
Normally we should suppress such declaration warnings,
as only calling extern subs should be forbidden without libffi.

fix the arg and CvHASSIG handling.
TODO: run-time signature type checks, prep_ffi_ret.

implement prep_ffi_ret
with all new ffi types (see https://docs.perl6.org/language/nativecall)

improve prep_ffi_ret types
change default rettype from :long to :void, analog to perl6.
simplify the type handling, encoded missing for str.

implement prep_ffi_sig

attr parsing: add parser in_sub and lex_attr_state

in_sub is needed to allow attributes not only in my decls.
lex_attr_state is needed to save the subname LEXER state of either
XATTRBLOCK or XATTRTERM over subsignature parsing, which destroyes this state
but is needed afterwards in subattrlist.

fix PL_in_sub state, for pmruntime funcs. fixes t/re/pat.t
my $died=qr/(?{})/;$error=$died?($@||qq(Zombie)):qq(none);
the qr func setting in_sub, and :qq(none) consuming it falsely

silence conversion and nonnull optimizer warnings
one since gcc 6.0. clang not yet checked.

magic ffienc for the :encoded attribute WIP
for string arguments and return type, PAD sv attachments.

Maybe use it also for all string values (as in Perl6), added to Encode when
being used outside of Latin-1/UTF-8.  But then as index into an encoded
array of names.  Now as shared name, attached as new F ffienc magic.

TODO: and add an attributes->import catchall CvEXTERN setter,
for extern sub cases where the parser forgot to call it with
"native".

parse empty extern sub () as sig, not proto

'extern sub name ()' is not an empty prototype, it's an empty signature.
treat 'sub name () :native' also as is_extern (EXTERNSUB token), to
signify () as signature, not as prototype.

attributes::get returns native
not native(lib) or the CvXFFI. Not symbol(name), encoded(name), nativeconv() yet

add warnings ffi
for the compile-time no ffi without DynaLoader warning.
Add the associated run-time error: Null extern sub symbol.

ffi: fix :symbol for slabbed CvFFILIB

also ignore find_symbol dlsym errors.
fix some PADLIST assertions.

attr_runtime: defer SAVEFREEOP(attr)
from new{ATTR,MY}SUB to attrs_runtime.
enhance dup_attrlist for variables to protect from SAVEFREEOP(attrs).

use GVSV, not just GV for the attribute argument. But keep using
REGFGEN, not SREFGEN, because peep and fold_constants rely on the bad
SREFGEN-null-kid format, and cannot deal with SREFGEN-kid.

Closes #291

harmonize diagnostic messages
ffi warnings and errors

fix sub EXISTING_SYM () :native :symbol(OTHERSYM)

use flat lists as attrs argument to attributes->import, not
nested. this was ignore in dup_attrslist().
add a testcase to test for the 2nd :symbol(OTHER) to resolve, not
skip.
Change the :symbol is already resolved warning to redefine, and only
if it's superfluous, resolving to the same symbol.

fix the attrs double-frees
  but still some minor attrs leaks, compile-time only.
  no ffi leaks at run-time though.
fix extern sub :attr
fix the externsub attribute case with import call for native,
fix lexer for several attributes: cv specific,
fix one minor SV leak in attributes::get
allow NULL rvalue in prep_ffi_ret.

windows and travis configs

harmonize prep_ffi_ret decls.

windows passes with the I_DLFCN fix appveypr smokes without libffi.
Need to enable it yet, copying the dlls from somewhere. Best with a
win32/ helper.

improve the tests skips

fix RTLD_DEFAULT logic

on windows it will fail, dl_load_file already did the searches.
on BSDs it is -2, everywhere else 0.
include dlfcn.h

I_DLFCN: not available under MSVC

util.c included this, but skipped on windows
which has no USE_C_BACKTRACE.

The win32 config files were wrong.

handle more type errors
invalid attribute arguments

prepare for more native const ops
not just one

c++ -fpermissive compat

use memcpy() which does a better copy of the wanted size,
and is optimized to the same code as a simple cast.
esp. we don't use a union, when we can use a single and more precise line.

we cannot use void* with C++, use char* instead.

improve the tests to use int, not long.

fix GVSV threaded

On threads a GVSV for the native($n) argument is invalid,
we need to use SVREF(GVOP) which is a PADOP.
This failed in op destruction on the invalid padix.

There is a problem with the padix from the upper scope.
Use the previous padix when copying it to the attributes->import
call.

reindent newGVOP and other overlong calls
no functional changes.

enum parser->lex_attr_state

rurban added a commit that referenced this issue Sep 15, 2018

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

parse attributes :native :symbol
set CvFFILIB via dl_load_file and CvXSUB symbol via dl_find_symbol.
TODO: set from SV values, not just constants.

use sv_chop in toke to advance PL_lex_stuff
use the OOK hack to do SvPVX(PL_lex_stuff)++
otherwise it will fail in sv_free. avoid copies.

add enterffi op to compiler

add and fix core extern tests WIP
not deparsed yet.

Resolve core attribute arguments, runtime setters

Some builtin attributes need to resolve symbolnames :native($libname)
at run-time, not only constants at parse-time, as via apply_attrs(),
which does the import in a BEGIN{} block.

Closes #291
As described in http://perl11.org/blog/attributes-args.html

perldiag: document standalone :symbol warning

add native and symbol() helpers

and fix start_subparse to start the attribute->import call.

skip miniperl, set ENTERFFI type
handle GvCV, SvRV and direct CV in ENTERFFI.
no overloaded object and no LV.

Set the right type already in the ck_subr to have less
op misses in entersub, also for xsub calls.
Note that a compile-time ffi call will not fall back to
a user-sub if redefined. Only done for XS to Perl or Perl to XS/FFI.

Simplify a few builtins.

Change attribute args: "native(" is followed by the arg.

start with the C part: ffi_call
remove unneeded leaveffi, prepare cfi usage.

document the ffi

fix extern sub parsing

and also lexical 'my extern sub name();'.
extern needs to trigger compile-time attributes->import().

checkcfgvar new config vars

cperl Porting/checkcfgvar.pl d_libffi i_ffi useffi  --default=undef --regen
note that vms has a libffi port:
  http://de.openvms.org/OpenVMS-Ports/detail.php?id=141
which needs to be installed/probed for.

add nativeconv() attribute
need a config-time helper for valid ABI values

prepare :encoded() attribute
for Str args or CV rettypes. TODO: attach
the encoding layer to the sig or ret pass.

Unify perldiag warnings. Less memory, same content.

fix prep_cif without USE_FFI
throw a compile-warning libffi not available
via warnings "syntax".
Normally we should suppress such declaration warnings,
as only calling extern subs should be forbidden without libffi.

fix the arg and CvHASSIG handling.
TODO: run-time signature type checks, prep_ffi_ret.

implement prep_ffi_ret
with all new ffi types (see https://docs.perl6.org/language/nativecall)

improve prep_ffi_ret types
change default rettype from :long to :void, analog to perl6.
simplify the type handling, encoded missing for str.

implement prep_ffi_sig

attr parsing: add parser in_sub and lex_attr_state

in_sub is needed to allow attributes not only in my decls.
lex_attr_state is needed to save the subname LEXER state of either
XATTRBLOCK or XATTRTERM over subsignature parsing, which destroyes this state
but is needed afterwards in subattrlist.

fix PL_in_sub state, for pmruntime funcs. fixes t/re/pat.t
my $died=qr/(?{})/;$error=$died?($@||qq(Zombie)):qq(none);
the qr func setting in_sub, and :qq(none) consuming it falsely

silence conversion and nonnull optimizer warnings
one since gcc 6.0. clang not yet checked.

magic ffienc for the :encoded attribute WIP
for string arguments and return type, PAD sv attachments.

Maybe use it also for all string values (as in Perl6), added to Encode when
being used outside of Latin-1/UTF-8.  But then as index into an encoded
array of names.  Now as shared name, attached as new F ffienc magic.

TODO: and add an attributes->import catchall CvEXTERN setter,
for extern sub cases where the parser forgot to call it with
"native".

parse empty extern sub () as sig, not proto

'extern sub name ()' is not an empty prototype, it's an empty signature.
treat 'sub name () :native' also as is_extern (EXTERNSUB token), to
signify () as signature, not as prototype.

attributes::get returns native
not native(lib) or the CvXFFI. Not symbol(name), encoded(name), nativeconv() yet

add warnings ffi
for the compile-time no ffi without DynaLoader warning.
Add the associated run-time error: Null extern sub symbol.

ffi: fix :symbol for slabbed CvFFILIB

also ignore find_symbol dlsym errors.
fix some PADLIST assertions.

attr_runtime: defer SAVEFREEOP(attr)
from new{ATTR,MY}SUB to attrs_runtime.
enhance dup_attrlist for variables to protect from SAVEFREEOP(attrs).

use GVSV, not just GV for the attribute argument. But keep using
REGFGEN, not SREFGEN, because peep and fold_constants rely on the bad
SREFGEN-null-kid format, and cannot deal with SREFGEN-kid.

Closes #291

harmonize diagnostic messages
ffi warnings and errors

fix sub EXISTING_SYM () :native :symbol(OTHERSYM)

use flat lists as attrs argument to attributes->import, not
nested. this was ignore in dup_attrslist().
add a testcase to test for the 2nd :symbol(OTHER) to resolve, not
skip.
Change the :symbol is already resolved warning to redefine, and only
if it's superfluous, resolving to the same symbol.

fix the attrs double-frees
  but still some minor attrs leaks, compile-time only.
  no ffi leaks at run-time though.
fix extern sub :attr
fix the externsub attribute case with import call for native,
fix lexer for several attributes: cv specific,
fix one minor SV leak in attributes::get
allow NULL rvalue in prep_ffi_ret.

windows and travis configs

harmonize prep_ffi_ret decls.

windows passes with the I_DLFCN fix appveypr smokes without libffi.
Need to enable it yet, copying the dlls from somewhere. Best with a
win32/ helper.

improve the tests skips

fix RTLD_DEFAULT logic

on windows it will fail, dl_load_file already did the searches.
on BSDs it is -2, everywhere else 0.
include dlfcn.h

I_DLFCN: not available under MSVC

util.c included this, but skipped on windows
which has no USE_C_BACKTRACE.

The win32 config files were wrong.

handle more type errors
invalid attribute arguments

prepare for more native const ops
not just one

c++ -fpermissive compat

use memcpy() which does a better copy of the wanted size,
and is optimized to the same code as a simple cast.
esp. we don't use a union, when we can use a single and more precise line.

we cannot use void* with C++, use char* instead.

improve the tests to use int, not long.

fix GVSV threaded

On threads a GVSV for the native($n) argument is invalid,
we need to use SVREF(GVOP) which is a PADOP.
This failed in op destruction on the invalid padix.

There is a problem with the padix from the upper scope.
Use the previous padix when copying it to the attributes->import
call.

reindent newGVOP and other overlong calls
no functional changes.

enum parser->lex_attr_state

rurban added a commit that referenced this issue Sep 15, 2018

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

parse attributes :native :symbol
set CvFFILIB via dl_load_file and CvXSUB symbol via dl_find_symbol.
TODO: set from SV values, not just constants.

use sv_chop in toke to advance PL_lex_stuff
use the OOK hack to do SvPVX(PL_lex_stuff)++
otherwise it will fail in sv_free. avoid copies.

add enterffi op to compiler

add and fix core extern tests WIP
not deparsed yet.

Resolve core attribute arguments, runtime setters

Some builtin attributes need to resolve symbolnames :native($libname)
at run-time, not only constants at parse-time, as via apply_attrs(),
which does the import in a BEGIN{} block.

Closes #291
As described in http://perl11.org/blog/attributes-args.html

perldiag: document standalone :symbol warning

add native and symbol() helpers

and fix start_subparse to start the attribute->import call.

skip miniperl, set ENTERFFI type
handle GvCV, SvRV and direct CV in ENTERFFI.
no overloaded object and no LV.

Set the right type already in the ck_subr to have less
op misses in entersub, also for xsub calls.
Note that a compile-time ffi call will not fall back to
a user-sub if redefined. Only done for XS to Perl or Perl to XS/FFI.

Simplify a few builtins.

Change attribute args: "native(" is followed by the arg.

start with the C part: ffi_call
remove unneeded leaveffi, prepare cfi usage.

document the ffi

fix extern sub parsing

and also lexical 'my extern sub name();'.
extern needs to trigger compile-time attributes->import().

checkcfgvar new config vars

cperl Porting/checkcfgvar.pl d_libffi i_ffi useffi  --default=undef --regen
note that vms has a libffi port:
  http://de.openvms.org/OpenVMS-Ports/detail.php?id=141
which needs to be installed/probed for.

add nativeconv() attribute
need a config-time helper for valid ABI values

prepare :encoded() attribute
for Str args or CV rettypes. TODO: attach
the encoding layer to the sig or ret pass.

Unify perldiag warnings. Less memory, same content.

fix prep_cif without USE_FFI
throw a compile-warning libffi not available
via warnings "syntax".
Normally we should suppress such declaration warnings,
as only calling extern subs should be forbidden without libffi.

fix the arg and CvHASSIG handling.
TODO: run-time signature type checks, prep_ffi_ret.

implement prep_ffi_ret
with all new ffi types (see https://docs.perl6.org/language/nativecall)

improve prep_ffi_ret types
change default rettype from :long to :void, analog to perl6.
simplify the type handling, encoded missing for str.

implement prep_ffi_sig

attr parsing: add parser in_sub and lex_attr_state

in_sub is needed to allow attributes not only in my decls.
lex_attr_state is needed to save the subname LEXER state of either
XATTRBLOCK or XATTRTERM over subsignature parsing, which destroyes this state
but is needed afterwards in subattrlist.

fix PL_in_sub state, for pmruntime funcs. fixes t/re/pat.t
my $died=qr/(?{})/;$error=$died?($@||qq(Zombie)):qq(none);
the qr func setting in_sub, and :qq(none) consuming it falsely

silence conversion and nonnull optimizer warnings
one since gcc 6.0. clang not yet checked.

magic ffienc for the :encoded attribute WIP
for string arguments and return type, PAD sv attachments.

Maybe use it also for all string values (as in Perl6), added to Encode when
being used outside of Latin-1/UTF-8.  But then as index into an encoded
array of names.  Now as shared name, attached as new F ffienc magic.

TODO: and add an attributes->import catchall CvEXTERN setter,
for extern sub cases where the parser forgot to call it with
"native".

parse empty extern sub () as sig, not proto

'extern sub name ()' is not an empty prototype, it's an empty signature.
treat 'sub name () :native' also as is_extern (EXTERNSUB token), to
signify () as signature, not as prototype.

attributes::get returns native
not native(lib) or the CvXFFI. Not symbol(name), encoded(name), nativeconv() yet

add warnings ffi
for the compile-time no ffi without DynaLoader warning.
Add the associated run-time error: Null extern sub symbol.

ffi: fix :symbol for slabbed CvFFILIB

also ignore find_symbol dlsym errors.
fix some PADLIST assertions.

attr_runtime: defer SAVEFREEOP(attr)
from new{ATTR,MY}SUB to attrs_runtime.
enhance dup_attrlist for variables to protect from SAVEFREEOP(attrs).

use GVSV, not just GV for the attribute argument. But keep using
REGFGEN, not SREFGEN, because peep and fold_constants rely on the bad
SREFGEN-null-kid format, and cannot deal with SREFGEN-kid.

Closes #291

harmonize diagnostic messages
ffi warnings and errors

fix sub EXISTING_SYM () :native :symbol(OTHERSYM)

use flat lists as attrs argument to attributes->import, not
nested. this was ignore in dup_attrslist().
add a testcase to test for the 2nd :symbol(OTHER) to resolve, not
skip.
Change the :symbol is already resolved warning to redefine, and only
if it's superfluous, resolving to the same symbol.

fix the attrs double-frees
  but still some minor attrs leaks, compile-time only.
  no ffi leaks at run-time though.
fix extern sub :attr
fix the externsub attribute case with import call for native,
fix lexer for several attributes: cv specific,
fix one minor SV leak in attributes::get
allow NULL rvalue in prep_ffi_ret.

windows and travis configs

harmonize prep_ffi_ret decls.

windows passes with the I_DLFCN fix appveypr smokes without libffi.
Need to enable it yet, copying the dlls from somewhere. Best with a
win32/ helper.

improve the tests skips

fix RTLD_DEFAULT logic

on windows it will fail, dl_load_file already did the searches.
on BSDs it is -2, everywhere else 0.
include dlfcn.h

I_DLFCN: not available under MSVC

util.c included this, but skipped on windows
which has no USE_C_BACKTRACE.

The win32 config files were wrong.

handle more type errors
invalid attribute arguments

prepare for more native const ops
not just one

c++ -fpermissive compat

use memcpy() which does a better copy of the wanted size,
and is optimized to the same code as a simple cast.
esp. we don't use a union, when we can use a single and more precise line.

we cannot use void* with C++, use char* instead.

improve the tests to use int, not long.

fix GVSV threaded

On threads a GVSV for the native($n) argument is invalid,
we need to use SVREF(GVOP) which is a PADOP.
This failed in op destruction on the invalid padix.

There is a problem with the padix from the upper scope.
Use the previous padix when copying it to the attributes->import
call.

reindent newGVOP and other overlong calls
no functional changes.

enum parser->lex_attr_state

rurban added a commit that referenced this issue Sep 15, 2018

ffi: probe in Configure
i_ffi, d_libffi, useffi. See #22

findffi: search all the libffi versions, expand
to absolute path as -I../ doesnt work.

vms: add libffi probes (untested)

Probe for the OpenVMS libffi port, also needed for python ctypes.
A 3.0.9 port exists for HP-UX/ia64, VMS/Alpha and VMS/ia64, but not
sure about its status, esp. OpenVMS. VAX should work.

find cygwin libXXX.dll.a libs
esp. for -lffi, which has no static lib.

rurban added a commit that referenced this issue Sep 15, 2018

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

parse attributes :native :symbol
set CvFFILIB via dl_load_file and CvXSUB symbol via dl_find_symbol.
TODO: set from SV values, not just constants.

use sv_chop in toke to advance PL_lex_stuff
use the OOK hack to do SvPVX(PL_lex_stuff)++
otherwise it will fail in sv_free. avoid copies.

add enterffi op to compiler

add and fix core extern tests WIP
not deparsed yet.

Resolve core attribute arguments, runtime setters

Some builtin attributes need to resolve symbolnames :native($libname)
at run-time, not only constants at parse-time, as via apply_attrs(),
which does the import in a BEGIN{} block.

Closes #291
As described in http://perl11.org/blog/attributes-args.html

perldiag: document standalone :symbol warning

add native and symbol() helpers

and fix start_subparse to start the attribute->import call.

skip miniperl, set ENTERFFI type
handle GvCV, SvRV and direct CV in ENTERFFI.
no overloaded object and no LV.

Set the right type already in the ck_subr to have less
op misses in entersub, also for xsub calls.
Note that a compile-time ffi call will not fall back to
a user-sub if redefined. Only done for XS to Perl or Perl to XS/FFI.

Simplify a few builtins.

Change attribute args: "native(" is followed by the arg.

start with the C part: ffi_call
remove unneeded leaveffi, prepare cfi usage.

document the ffi

fix extern sub parsing

and also lexical 'my extern sub name();'.
extern needs to trigger compile-time attributes->import().

checkcfgvar new config vars

cperl Porting/checkcfgvar.pl d_libffi i_ffi useffi  --default=undef --regen
note that vms has a libffi port:
  http://de.openvms.org/OpenVMS-Ports/detail.php?id=141
which needs to be installed/probed for.

add nativeconv() attribute
need a config-time helper for valid ABI values

prepare :encoded() attribute
for Str args or CV rettypes. TODO: attach
the encoding layer to the sig or ret pass.

Unify perldiag warnings. Less memory, same content.

fix prep_cif without USE_FFI
throw a compile-warning libffi not available
via warnings "syntax".
Normally we should suppress such declaration warnings,
as only calling extern subs should be forbidden without libffi.

fix the arg and CvHASSIG handling.
TODO: run-time signature type checks, prep_ffi_ret.

implement prep_ffi_ret
with all new ffi types (see https://docs.perl6.org/language/nativecall)

improve prep_ffi_ret types
change default rettype from :long to :void, analog to perl6.
simplify the type handling, encoded missing for str.

implement prep_ffi_sig

attr parsing: add parser in_sub and lex_attr_state

in_sub is needed to allow attributes not only in my decls.
lex_attr_state is needed to save the subname LEXER state of either
XATTRBLOCK or XATTRTERM over subsignature parsing, which destroyes this state
but is needed afterwards in subattrlist.

fix PL_in_sub state, for pmruntime funcs. fixes t/re/pat.t
my $died=qr/(?{})/;$error=$died?($@||qq(Zombie)):qq(none);
the qr func setting in_sub, and :qq(none) consuming it falsely

silence conversion and nonnull optimizer warnings
one since gcc 6.0. clang not yet checked.

magic ffienc for the :encoded attribute WIP
for string arguments and return type, PAD sv attachments.

Maybe use it also for all string values (as in Perl6), added to Encode when
being used outside of Latin-1/UTF-8.  But then as index into an encoded
array of names.  Now as shared name, attached as new F ffienc magic.

TODO: and add an attributes->import catchall CvEXTERN setter,
for extern sub cases where the parser forgot to call it with
"native".

parse empty extern sub () as sig, not proto

'extern sub name ()' is not an empty prototype, it's an empty signature.
treat 'sub name () :native' also as is_extern (EXTERNSUB token), to
signify () as signature, not as prototype.

attributes::get returns native
not native(lib) or the CvXFFI. Not symbol(name), encoded(name), nativeconv() yet

add warnings ffi
for the compile-time no ffi without DynaLoader warning.
Add the associated run-time error: Null extern sub symbol.

ffi: fix :symbol for slabbed CvFFILIB

also ignore find_symbol dlsym errors.
fix some PADLIST assertions.

attr_runtime: defer SAVEFREEOP(attr)
from new{ATTR,MY}SUB to attrs_runtime.
enhance dup_attrlist for variables to protect from SAVEFREEOP(attrs).

use GVSV, not just GV for the attribute argument. But keep using
REGFGEN, not SREFGEN, because peep and fold_constants rely on the bad
SREFGEN-null-kid format, and cannot deal with SREFGEN-kid.

Closes #291

harmonize diagnostic messages
ffi warnings and errors

fix sub EXISTING_SYM () :native :symbol(OTHERSYM)

use flat lists as attrs argument to attributes->import, not
nested. this was ignore in dup_attrslist().
add a testcase to test for the 2nd :symbol(OTHER) to resolve, not
skip.
Change the :symbol is already resolved warning to redefine, and only
if it's superfluous, resolving to the same symbol.

fix the attrs double-frees
  but still some minor attrs leaks, compile-time only.
  no ffi leaks at run-time though.
fix extern sub :attr
fix the externsub attribute case with import call for native,
fix lexer for several attributes: cv specific,
fix one minor SV leak in attributes::get
allow NULL rvalue in prep_ffi_ret.

windows and travis configs

harmonize prep_ffi_ret decls.

windows passes with the I_DLFCN fix appveypr smokes without libffi.
Need to enable it yet, copying the dlls from somewhere. Best with a
win32/ helper.

improve the tests skips

fix RTLD_DEFAULT logic

on windows it will fail, dl_load_file already did the searches.
on BSDs it is -2, everywhere else 0.
include dlfcn.h

I_DLFCN: not available under MSVC

util.c included this, but skipped on windows
which has no USE_C_BACKTRACE.

The win32 config files were wrong.

handle more type errors
invalid attribute arguments

prepare for more native const ops
not just one

c++ -fpermissive compat

use memcpy() which does a better copy of the wanted size,
and is optimized to the same code as a simple cast.
esp. we don't use a union, when we can use a single and more precise line.

we cannot use void* with C++, use char* instead.

improve the tests to use int, not long.

fix GVSV threaded

On threads a GVSV for the native($n) argument is invalid,
we need to use SVREF(GVOP) which is a PADOP.
This failed in op destruction on the invalid padix.

There is a problem with the padix from the upper scope.
Use the previous padix when copying it to the attributes->import
call.

reindent newGVOP and other overlong calls
no functional changes.

enum parser->lex_attr_state

rurban added a commit that referenced this issue Sep 16, 2018

ffi: probe in Configure
i_ffi, d_libffi, useffi. See #22

findffi: search all the libffi versions, expand
to absolute path as -I../ doesnt work.

vms: add libffi probes (untested)

Probe for the OpenVMS libffi port, also needed for python ctypes.
A 3.0.9 port exists for HP-UX/ia64, VMS/Alpha and VMS/ia64, but not
sure about its status, esp. OpenVMS. VAX should work.

find cygwin libXXX.dll.a libs
esp. for -lffi, which has no static lib.

rurban added a commit that referenced this issue Sep 16, 2018

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

parse attributes :native :symbol
set CvFFILIB via dl_load_file and CvXSUB symbol via dl_find_symbol.
TODO: set from SV values, not just constants.

use sv_chop in toke to advance PL_lex_stuff
use the OOK hack to do SvPVX(PL_lex_stuff)++
otherwise it will fail in sv_free. avoid copies.

add enterffi op to compiler

add and fix core extern tests WIP
not deparsed yet.

Resolve core attribute arguments, runtime setters

Some builtin attributes need to resolve symbolnames :native($libname)
at run-time, not only constants at parse-time, as via apply_attrs(),
which does the import in a BEGIN{} block.

Closes #291
As described in http://perl11.org/blog/attributes-args.html

perldiag: document standalone :symbol warning

add native and symbol() helpers

and fix start_subparse to start the attribute->import call.

skip miniperl, set ENTERFFI type
handle GvCV, SvRV and direct CV in ENTERFFI.
no overloaded object and no LV.

Set the right type already in the ck_subr to have less
op misses in entersub, also for xsub calls.
Note that a compile-time ffi call will not fall back to
a user-sub if redefined. Only done for XS to Perl or Perl to XS/FFI.

Simplify a few builtins.

Change attribute args: "native(" is followed by the arg.

start with the C part: ffi_call
remove unneeded leaveffi, prepare cfi usage.

document the ffi

fix extern sub parsing

and also lexical 'my extern sub name();'.
extern needs to trigger compile-time attributes->import().

checkcfgvar new config vars

cperl Porting/checkcfgvar.pl d_libffi i_ffi useffi  --default=undef --regen
note that vms has a libffi port:
  http://de.openvms.org/OpenVMS-Ports/detail.php?id=141
which needs to be installed/probed for.

add nativeconv() attribute
need a config-time helper for valid ABI values

prepare :encoded() attribute
for Str args or CV rettypes. TODO: attach
the encoding layer to the sig or ret pass.

Unify perldiag warnings. Less memory, same content.

fix prep_cif without USE_FFI
throw a compile-warning libffi not available
via warnings "syntax".
Normally we should suppress such declaration warnings,
as only calling extern subs should be forbidden without libffi.

fix the arg and CvHASSIG handling.
TODO: run-time signature type checks, prep_ffi_ret.

implement prep_ffi_ret
with all new ffi types (see https://docs.perl6.org/language/nativecall)

improve prep_ffi_ret types
change default rettype from :long to :void, analog to perl6.
simplify the type handling, encoded missing for str.

implement prep_ffi_sig

attr parsing: add parser in_sub and lex_attr_state

in_sub is needed to allow attributes not only in my decls.
lex_attr_state is needed to save the subname LEXER state of either
XATTRBLOCK or XATTRTERM over subsignature parsing, which destroyes this state
but is needed afterwards in subattrlist.

fix PL_in_sub state, for pmruntime funcs. fixes t/re/pat.t
my $died=qr/(?{})/;$error=$died?($@||qq(Zombie)):qq(none);
the qr func setting in_sub, and :qq(none) consuming it falsely

silence conversion and nonnull optimizer warnings
one since gcc 6.0. clang not yet checked.

magic ffienc for the :encoded attribute WIP
for string arguments and return type, PAD sv attachments.

Maybe use it also for all string values (as in Perl6), added to Encode when
being used outside of Latin-1/UTF-8.  But then as index into an encoded
array of names.  Now as shared name, attached as new F ffienc magic.

TODO: and add an attributes->import catchall CvEXTERN setter,
for extern sub cases where the parser forgot to call it with
"native".

parse empty extern sub () as sig, not proto

'extern sub name ()' is not an empty prototype, it's an empty signature.
treat 'sub name () :native' also as is_extern (EXTERNSUB token), to
signify () as signature, not as prototype.

attributes::get returns native
not native(lib) or the CvXFFI. Not symbol(name), encoded(name), nativeconv() yet

add warnings ffi
for the compile-time no ffi without DynaLoader warning.
Add the associated run-time error: Null extern sub symbol.

ffi: fix :symbol for slabbed CvFFILIB

also ignore find_symbol dlsym errors.
fix some PADLIST assertions.

attr_runtime: defer SAVEFREEOP(attr)
from new{ATTR,MY}SUB to attrs_runtime.
enhance dup_attrlist for variables to protect from SAVEFREEOP(attrs).

use GVSV, not just GV for the attribute argument. But keep using
REGFGEN, not SREFGEN, because peep and fold_constants rely on the bad
SREFGEN-null-kid format, and cannot deal with SREFGEN-kid.

Closes #291

harmonize diagnostic messages
ffi warnings and errors

fix sub EXISTING_SYM () :native :symbol(OTHERSYM)

use flat lists as attrs argument to attributes->import, not
nested. this was ignore in dup_attrslist().
add a testcase to test for the 2nd :symbol(OTHER) to resolve, not
skip.
Change the :symbol is already resolved warning to redefine, and only
if it's superfluous, resolving to the same symbol.

fix the attrs double-frees
  but still some minor attrs leaks, compile-time only.
  no ffi leaks at run-time though.
fix extern sub :attr
fix the externsub attribute case with import call for native,
fix lexer for several attributes: cv specific,
fix one minor SV leak in attributes::get
allow NULL rvalue in prep_ffi_ret.

windows and travis configs

harmonize prep_ffi_ret decls.

windows passes with the I_DLFCN fix appveypr smokes without libffi.
Need to enable it yet, copying the dlls from somewhere. Best with a
win32/ helper.

improve the tests skips

fix RTLD_DEFAULT logic

on windows it will fail, dl_load_file already did the searches.
on BSDs it is -2, everywhere else 0.
include dlfcn.h

I_DLFCN: not available under MSVC

util.c included this, but skipped on windows
which has no USE_C_BACKTRACE.

The win32 config files were wrong.

handle more type errors
invalid attribute arguments

prepare for more native const ops
not just one

c++ -fpermissive compat

use memcpy() which does a better copy of the wanted size,
and is optimized to the same code as a simple cast.
esp. we don't use a union, when we can use a single and more precise line.

we cannot use void* with C++, use char* instead.

improve the tests to use int, not long.

fix GVSV threaded

On threads a GVSV for the native($n) argument is invalid,
we need to use SVREF(GVOP) which is a PADOP.
This failed in op destruction on the invalid padix.

There is a problem with the padix from the upper scope.
Use the previous padix when copying it to the attributes->import
call.

reindent newGVOP and other overlong calls
no functional changes.

enum parser->lex_attr_state

rurban added a commit that referenced this issue Sep 16, 2018

ffi: probe in Configure
i_ffi, d_libffi, useffi. See #22

findffi: search all the libffi versions, expand
to absolute path as -I../ doesnt work.

vms: add libffi probes (untested)

Probe for the OpenVMS libffi port, also needed for python ctypes.
A 3.0.9 port exists for HP-UX/ia64, VMS/Alpha and VMS/ia64, but not
sure about its status, esp. OpenVMS. VAX should work.

find cygwin libXXX.dll.a libs
esp. for -lffi, which has no static lib.

rurban added a commit that referenced this issue Sep 16, 2018

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

parse attributes :native :symbol
set CvFFILIB via dl_load_file and CvXSUB symbol via dl_find_symbol.
TODO: set from SV values, not just constants.

use sv_chop in toke to advance PL_lex_stuff
use the OOK hack to do SvPVX(PL_lex_stuff)++
otherwise it will fail in sv_free. avoid copies.

add enterffi op to compiler

add and fix core extern tests WIP
not deparsed yet.

Resolve core attribute arguments, runtime setters

Some builtin attributes need to resolve symbolnames :native($libname)
at run-time, not only constants at parse-time, as via apply_attrs(),
which does the import in a BEGIN{} block.

Closes #291
As described in http://perl11.org/blog/attributes-args.html

perldiag: document standalone :symbol warning

add native and symbol() helpers

and fix start_subparse to start the attribute->import call.

skip miniperl, set ENTERFFI type
handle GvCV, SvRV and direct CV in ENTERFFI.
no overloaded object and no LV.

Set the right type already in the ck_subr to have less
op misses in entersub, also for xsub calls.
Note that a compile-time ffi call will not fall back to
a user-sub if redefined. Only done for XS to Perl or Perl to XS/FFI.

Simplify a few builtins.

Change attribute args: "native(" is followed by the arg.

start with the C part: ffi_call
remove unneeded leaveffi, prepare cfi usage.

document the ffi

fix extern sub parsing

and also lexical 'my extern sub name();'.
extern needs to trigger compile-time attributes->import().

checkcfgvar new config vars

cperl Porting/checkcfgvar.pl d_libffi i_ffi useffi  --default=undef --regen
note that vms has a libffi port:
  http://de.openvms.org/OpenVMS-Ports/detail.php?id=141
which needs to be installed/probed for.

add nativeconv() attribute
need a config-time helper for valid ABI values

prepare :encoded() attribute
for Str args or CV rettypes. TODO: attach
the encoding layer to the sig or ret pass.

Unify perldiag warnings. Less memory, same content.

fix prep_cif without USE_FFI
throw a compile-warning libffi not available
via warnings "syntax".
Normally we should suppress such declaration warnings,
as only calling extern subs should be forbidden without libffi.

fix the arg and CvHASSIG handling.
TODO: run-time signature type checks, prep_ffi_ret.

implement prep_ffi_ret
with all new ffi types (see https://docs.perl6.org/language/nativecall)

improve prep_ffi_ret types
change default rettype from :long to :void, analog to perl6.
simplify the type handling, encoded missing for str.

implement prep_ffi_sig

attr parsing: add parser in_sub and lex_attr_state

in_sub is needed to allow attributes not only in my decls.
lex_attr_state is needed to save the subname LEXER state of either
XATTRBLOCK or XATTRTERM over subsignature parsing, which destroyes this state
but is needed afterwards in subattrlist.

fix PL_in_sub state, for pmruntime funcs. fixes t/re/pat.t
my $died=qr/(?{})/;$error=$died?($@||qq(Zombie)):qq(none);
the qr func setting in_sub, and :qq(none) consuming it falsely

silence conversion and nonnull optimizer warnings
one since gcc 6.0. clang not yet checked.

magic ffienc for the :encoded attribute WIP
for string arguments and return type, PAD sv attachments.

Maybe use it also for all string values (as in Perl6), added to Encode when
being used outside of Latin-1/UTF-8.  But then as index into an encoded
array of names.  Now as shared name, attached as new F ffienc magic.

TODO: and add an attributes->import catchall CvEXTERN setter,
for extern sub cases where the parser forgot to call it with
"native".

parse empty extern sub () as sig, not proto

'extern sub name ()' is not an empty prototype, it's an empty signature.
treat 'sub name () :native' also as is_extern (EXTERNSUB token), to
signify () as signature, not as prototype.

attributes::get returns native
not native(lib) or the CvXFFI. Not symbol(name), encoded(name), nativeconv() yet

add warnings ffi
for the compile-time no ffi without DynaLoader warning.
Add the associated run-time error: Null extern sub symbol.

ffi: fix :symbol for slabbed CvFFILIB

also ignore find_symbol dlsym errors.
fix some PADLIST assertions.

attr_runtime: defer SAVEFREEOP(attr)
from new{ATTR,MY}SUB to attrs_runtime.
enhance dup_attrlist for variables to protect from SAVEFREEOP(attrs).

use GVSV, not just GV for the attribute argument. But keep using
REGFGEN, not SREFGEN, because peep and fold_constants rely on the bad
SREFGEN-null-kid format, and cannot deal with SREFGEN-kid.

Closes #291

harmonize diagnostic messages
ffi warnings and errors

fix sub EXISTING_SYM () :native :symbol(OTHERSYM)

use flat lists as attrs argument to attributes->import, not
nested. this was ignore in dup_attrslist().
add a testcase to test for the 2nd :symbol(OTHER) to resolve, not
skip.
Change the :symbol is already resolved warning to redefine, and only
if it's superfluous, resolving to the same symbol.

fix the attrs double-frees
  but still some minor attrs leaks, compile-time only.
  no ffi leaks at run-time though.
fix extern sub :attr
fix the externsub attribute case with import call for native,
fix lexer for several attributes: cv specific,
fix one minor SV leak in attributes::get
allow NULL rvalue in prep_ffi_ret.

windows and travis configs

harmonize prep_ffi_ret decls.

windows passes with the I_DLFCN fix appveypr smokes without libffi.
Need to enable it yet, copying the dlls from somewhere. Best with a
win32/ helper.

improve the tests skips

fix RTLD_DEFAULT logic

on windows it will fail, dl_load_file already did the searches.
on BSDs it is -2, everywhere else 0.
include dlfcn.h

I_DLFCN: not available under MSVC

util.c included this, but skipped on windows
which has no USE_C_BACKTRACE.

The win32 config files were wrong.

handle more type errors
invalid attribute arguments

prepare for more native const ops
not just one

c++ -fpermissive compat

use memcpy() which does a better copy of the wanted size,
and is optimized to the same code as a simple cast.
esp. we don't use a union, when we can use a single and more precise line.

we cannot use void* with C++, use char* instead.

improve the tests to use int, not long.

fix GVSV threaded

On threads a GVSV for the native($n) argument is invalid,
we need to use SVREF(GVOP) which is a PADOP.
This failed in op destruction on the invalid padix.

There is a problem with the padix from the upper scope.
Use the previous padix when copying it to the attributes->import
call.

reindent newGVOP and other overlong calls
no functional changes.

enum parser->lex_attr_state

rurban added a commit that referenced this issue Sep 16, 2018

ffi: probe in Configure
i_ffi, d_libffi, useffi. See #22

findffi: search all the libffi versions, expand
to absolute path as -I../ doesnt work.

vms: add libffi probes (untested)

Probe for the OpenVMS libffi port, also needed for python ctypes.
A 3.0.9 port exists for HP-UX/ia64, VMS/Alpha and VMS/ia64, but not
sure about its status, esp. OpenVMS. VAX should work.

find cygwin libXXX.dll.a libs
esp. for -lffi, which has no static lib.

rurban added a commit that referenced this issue Sep 16, 2018

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

parse attributes :native :symbol
set CvFFILIB via dl_load_file and CvXSUB symbol via dl_find_symbol.
TODO: set from SV values, not just constants.

use sv_chop in toke to advance PL_lex_stuff
use the OOK hack to do SvPVX(PL_lex_stuff)++
otherwise it will fail in sv_free. avoid copies.

add enterffi op to compiler

add and fix core extern tests WIP
not deparsed yet.

Resolve core attribute arguments, runtime setters

Some builtin attributes need to resolve symbolnames :native($libname)
at run-time, not only constants at parse-time, as via apply_attrs(),
which does the import in a BEGIN{} block.

Closes #291
As described in http://perl11.org/blog/attributes-args.html

perldiag: document standalone :symbol warning

add native and symbol() helpers

and fix start_subparse to start the attribute->import call.

skip miniperl, set ENTERFFI type
handle GvCV, SvRV and direct CV in ENTERFFI.
no overloaded object and no LV.

Set the right type already in the ck_subr to have less
op misses in entersub, also for xsub calls.
Note that a compile-time ffi call will not fall back to
a user-sub if redefined. Only done for XS to Perl or Perl to XS/FFI.

Simplify a few builtins.

Change attribute args: "native(" is followed by the arg.

start with the C part: ffi_call
remove unneeded leaveffi, prepare cfi usage.

document the ffi

fix extern sub parsing

and also lexical 'my extern sub name();'.
extern needs to trigger compile-time attributes->import().

checkcfgvar new config vars

cperl Porting/checkcfgvar.pl d_libffi i_ffi useffi  --default=undef --regen
note that vms has a libffi port:
  http://de.openvms.org/OpenVMS-Ports/detail.php?id=141
which needs to be installed/probed for.

add nativeconv() attribute
need a config-time helper for valid ABI values

prepare :encoded() attribute
for Str args or CV rettypes. TODO: attach
the encoding layer to the sig or ret pass.

Unify perldiag warnings. Less memory, same content.

fix prep_cif without USE_FFI
throw a compile-warning libffi not available
via warnings "syntax".
Normally we should suppress such declaration warnings,
as only calling extern subs should be forbidden without libffi.

fix the arg and CvHASSIG handling.
TODO: run-time signature type checks, prep_ffi_ret.

implement prep_ffi_ret
with all new ffi types (see https://docs.perl6.org/language/nativecall)

improve prep_ffi_ret types
change default rettype from :long to :void, analog to perl6.
simplify the type handling, encoded missing for str.

implement prep_ffi_sig

attr parsing: add parser in_sub and lex_attr_state

in_sub is needed to allow attributes not only in my decls.
lex_attr_state is needed to save the subname LEXER state of either
XATTRBLOCK or XATTRTERM over subsignature parsing, which destroyes this state
but is needed afterwards in subattrlist.

fix PL_in_sub state, for pmruntime funcs. fixes t/re/pat.t
my $died=qr/(?{})/;$error=$died?($@||qq(Zombie)):qq(none);
the qr func setting in_sub, and :qq(none) consuming it falsely

silence conversion and nonnull optimizer warnings
one since gcc 6.0. clang not yet checked.

magic ffienc for the :encoded attribute WIP
for string arguments and return type, PAD sv attachments.

Maybe use it also for all string values (as in Perl6), added to Encode when
being used outside of Latin-1/UTF-8.  But then as index into an encoded
array of names.  Now as shared name, attached as new F ffienc magic.

TODO: and add an attributes->import catchall CvEXTERN setter,
for extern sub cases where the parser forgot to call it with
"native".

parse empty extern sub () as sig, not proto

'extern sub name ()' is not an empty prototype, it's an empty signature.
treat 'sub name () :native' also as is_extern (EXTERNSUB token), to
signify () as signature, not as prototype.

attributes::get returns native
not native(lib) or the CvXFFI. Not symbol(name), encoded(name), nativeconv() yet

add warnings ffi
for the compile-time no ffi without DynaLoader warning.
Add the associated run-time error: Null extern sub symbol.

ffi: fix :symbol for slabbed CvFFILIB

also ignore find_symbol dlsym errors.
fix some PADLIST assertions.

attr_runtime: defer SAVEFREEOP(attr)
from new{ATTR,MY}SUB to attrs_runtime.
enhance dup_attrlist for variables to protect from SAVEFREEOP(attrs).

use GVSV, not just GV for the attribute argument. But keep using
REGFGEN, not SREFGEN, because peep and fold_constants rely on the bad
SREFGEN-null-kid format, and cannot deal with SREFGEN-kid.

Closes #291

harmonize diagnostic messages
ffi warnings and errors

fix sub EXISTING_SYM () :native :symbol(OTHERSYM)

use flat lists as attrs argument to attributes->import, not
nested. this was ignore in dup_attrslist().
add a testcase to test for the 2nd :symbol(OTHER) to resolve, not
skip.
Change the :symbol is already resolved warning to redefine, and only
if it's superfluous, resolving to the same symbol.

fix the attrs double-frees
  but still some minor attrs leaks, compile-time only.
  no ffi leaks at run-time though.
fix extern sub :attr
fix the externsub attribute case with import call for native,
fix lexer for several attributes: cv specific,
fix one minor SV leak in attributes::get
allow NULL rvalue in prep_ffi_ret.

windows and travis configs

harmonize prep_ffi_ret decls.

windows passes with the I_DLFCN fix appveypr smokes without libffi.
Need to enable it yet, copying the dlls from somewhere. Best with a
win32/ helper.

improve the tests skips

fix RTLD_DEFAULT logic

on windows it will fail, dl_load_file already did the searches.
on BSDs it is -2, everywhere else 0.
include dlfcn.h

I_DLFCN: not available under MSVC

util.c included this, but skipped on windows
which has no USE_C_BACKTRACE.

The win32 config files were wrong.

handle more type errors
invalid attribute arguments

prepare for more native const ops
not just one

c++ -fpermissive compat

use memcpy() which does a better copy of the wanted size,
and is optimized to the same code as a simple cast.
esp. we don't use a union, when we can use a single and more precise line.

we cannot use void* with C++, use char* instead.

improve the tests to use int, not long.

fix GVSV threaded

On threads a GVSV for the native($n) argument is invalid,
we need to use SVREF(GVOP) which is a PADOP.
This failed in op destruction on the invalid padix.

There is a problem with the padix from the upper scope.
Use the previous padix when copying it to the attributes->import
call.

reindent newGVOP and other overlong calls
no functional changes.

enum parser->lex_attr_state

rurban added a commit that referenced this issue Sep 16, 2018

ffi: probe in Configure
i_ffi, d_libffi, useffi. See #22

findffi: search all the libffi versions, expand
to absolute path as -I../ doesnt work.

vms: add libffi probes (untested)

Probe for the OpenVMS libffi port, also needed for python ctypes.
A 3.0.9 port exists for HP-UX/ia64, VMS/Alpha and VMS/ia64, but not
sure about its status, esp. OpenVMS. VAX should work.

find cygwin libXXX.dll.a libs
esp. for -lffi, which has no static lib.

rurban added a commit that referenced this issue Sep 16, 2018

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

parse attributes :native :symbol
set CvFFILIB via dl_load_file and CvXSUB symbol via dl_find_symbol.
TODO: set from SV values, not just constants.

use sv_chop in toke to advance PL_lex_stuff
use the OOK hack to do SvPVX(PL_lex_stuff)++
otherwise it will fail in sv_free. avoid copies.

add enterffi op to compiler

add and fix core extern tests WIP
not deparsed yet.

Resolve core attribute arguments, runtime setters

Some builtin attributes need to resolve symbolnames :native($libname)
at run-time, not only constants at parse-time, as via apply_attrs(),
which does the import in a BEGIN{} block.

Closes #291
As described in http://perl11.org/blog/attributes-args.html

perldiag: document standalone :symbol warning

add native and symbol() helpers

and fix start_subparse to start the attribute->import call.

skip miniperl, set ENTERFFI type
handle GvCV, SvRV and direct CV in ENTERFFI.
no overloaded object and no LV.

Set the right type already in the ck_subr to have less
op misses in entersub, also for xsub calls.
Note that a compile-time ffi call will not fall back to
a user-sub if redefined. Only done for XS to Perl or Perl to XS/FFI.

Simplify a few builtins.

Change attribute args: "native(" is followed by the arg.

start with the C part: ffi_call
remove unneeded leaveffi, prepare cfi usage.

document the ffi

fix extern sub parsing

and also lexical 'my extern sub name();'.
extern needs to trigger compile-time attributes->import().

checkcfgvar new config vars

cperl Porting/checkcfgvar.pl d_libffi i_ffi useffi  --default=undef --regen
note that vms has a libffi port:
  http://de.openvms.org/OpenVMS-Ports/detail.php?id=141
which needs to be installed/probed for.

add nativeconv() attribute
need a config-time helper for valid ABI values

prepare :encoded() attribute
for Str args or CV rettypes. TODO: attach
the encoding layer to the sig or ret pass.

Unify perldiag warnings. Less memory, same content.

fix prep_cif without USE_FFI
throw a compile-warning libffi not available
via warnings "syntax".
Normally we should suppress such declaration warnings,
as only calling extern subs should be forbidden without libffi.

fix the arg and CvHASSIG handling.
TODO: run-time signature type checks, prep_ffi_ret.

implement prep_ffi_ret
with all new ffi types (see https://docs.perl6.org/language/nativecall)

improve prep_ffi_ret types
change default rettype from :long to :void, analog to perl6.
simplify the type handling, encoded missing for str.

implement prep_ffi_sig

attr parsing: add parser in_sub and lex_attr_state

in_sub is needed to allow attributes not only in my decls.
lex_attr_state is needed to save the subname LEXER state of either
XATTRBLOCK or XATTRTERM over subsignature parsing, which destroyes this state
but is needed afterwards in subattrlist.

fix PL_in_sub state, for pmruntime funcs. fixes t/re/pat.t
my $died=qr/(?{})/;$error=$died?($@||qq(Zombie)):qq(none);
the qr func setting in_sub, and :qq(none) consuming it falsely

silence conversion and nonnull optimizer warnings
one since gcc 6.0. clang not yet checked.

magic ffienc for the :encoded attribute WIP
for string arguments and return type, PAD sv attachments.

Maybe use it also for all string values (as in Perl6), added to Encode when
being used outside of Latin-1/UTF-8.  But then as index into an encoded
array of names.  Now as shared name, attached as new F ffienc magic.

TODO: and add an attributes->import catchall CvEXTERN setter,
for extern sub cases where the parser forgot to call it with
"native".

parse empty extern sub () as sig, not proto

'extern sub name ()' is not an empty prototype, it's an empty signature.
treat 'sub name () :native' also as is_extern (EXTERNSUB token), to
signify () as signature, not as prototype.

attributes::get returns native
not native(lib) or the CvXFFI. Not symbol(name), encoded(name), nativeconv() yet

add warnings ffi
for the compile-time no ffi without DynaLoader warning.
Add the associated run-time error: Null extern sub symbol.

ffi: fix :symbol for slabbed CvFFILIB

also ignore find_symbol dlsym errors.
fix some PADLIST assertions.

attr_runtime: defer SAVEFREEOP(attr)
from new{ATTR,MY}SUB to attrs_runtime.
enhance dup_attrlist for variables to protect from SAVEFREEOP(attrs).

use GVSV, not just GV for the attribute argument. But keep using
REGFGEN, not SREFGEN, because peep and fold_constants rely on the bad
SREFGEN-null-kid format, and cannot deal with SREFGEN-kid.

Closes #291

harmonize diagnostic messages
ffi warnings and errors

fix sub EXISTING_SYM () :native :symbol(OTHERSYM)

use flat lists as attrs argument to attributes->import, not
nested. this was ignore in dup_attrslist().
add a testcase to test for the 2nd :symbol(OTHER) to resolve, not
skip.
Change the :symbol is already resolved warning to redefine, and only
if it's superfluous, resolving to the same symbol.

fix the attrs double-frees
  but still some minor attrs leaks, compile-time only.
  no ffi leaks at run-time though.
fix extern sub :attr
fix the externsub attribute case with import call for native,
fix lexer for several attributes: cv specific,
fix one minor SV leak in attributes::get
allow NULL rvalue in prep_ffi_ret.

windows and travis configs

harmonize prep_ffi_ret decls.

windows passes with the I_DLFCN fix appveypr smokes without libffi.
Need to enable it yet, copying the dlls from somewhere. Best with a
win32/ helper.

improve the tests skips

fix RTLD_DEFAULT logic

on windows it will fail, dl_load_file already did the searches.
on BSDs it is -2, everywhere else 0.
include dlfcn.h

I_DLFCN: not available under MSVC

util.c included this, but skipped on windows
which has no USE_C_BACKTRACE.

The win32 config files were wrong.

handle more type errors
invalid attribute arguments

prepare for more native const ops
not just one

c++ -fpermissive compat

use memcpy() which does a better copy of the wanted size,
and is optimized to the same code as a simple cast.
esp. we don't use a union, when we can use a single and more precise line.

we cannot use void* with C++, use char* instead.

improve the tests to use int, not long.

fix GVSV threaded

On threads a GVSV for the native($n) argument is invalid,
we need to use SVREF(GVOP) which is a PADOP.
This failed in op destruction on the invalid padix.

There is a problem with the padix from the upper scope.
Use the previous padix when copying it to the attributes->import
call.

reindent newGVOP and other overlong calls
no functional changes.

enum parser->lex_attr_state

rurban added a commit that referenced this issue Sep 16, 2018

ffi: probe in Configure
i_ffi, d_libffi, useffi. See #22

findffi: search all the libffi versions, expand
to absolute path as -I../ doesnt work.

vms: add libffi probes (untested)

Probe for the OpenVMS libffi port, also needed for python ctypes.
A 3.0.9 port exists for HP-UX/ia64, VMS/Alpha and VMS/ia64, but not
sure about its status, esp. OpenVMS. VAX should work.

find cygwin libXXX.dll.a libs
esp. for -lffi, which has no static lib.

rurban added a commit that referenced this issue Sep 16, 2018

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

parse attributes :native :symbol
set CvFFILIB via dl_load_file and CvXSUB symbol via dl_find_symbol.
TODO: set from SV values, not just constants.

use sv_chop in toke to advance PL_lex_stuff
use the OOK hack to do SvPVX(PL_lex_stuff)++
otherwise it will fail in sv_free. avoid copies.

add enterffi op to compiler

add and fix core extern tests WIP
not deparsed yet.

Resolve core attribute arguments, runtime setters

Some builtin attributes need to resolve symbolnames :native($libname)
at run-time, not only constants at parse-time, as via apply_attrs(),
which does the import in a BEGIN{} block.

Closes #291
As described in http://perl11.org/blog/attributes-args.html

perldiag: document standalone :symbol warning

add native and symbol() helpers

and fix start_subparse to start the attribute->import call.

skip miniperl, set ENTERFFI type
handle GvCV, SvRV and direct CV in ENTERFFI.
no overloaded object and no LV.

Set the right type already in the ck_subr to have less
op misses in entersub, also for xsub calls.
Note that a compile-time ffi call will not fall back to
a user-sub if redefined. Only done for XS to Perl or Perl to XS/FFI.

Simplify a few builtins.

Change attribute args: "native(" is followed by the arg.

start with the C part: ffi_call
remove unneeded leaveffi, prepare cfi usage.

document the ffi

fix extern sub parsing

and also lexical 'my extern sub name();'.
extern needs to trigger compile-time attributes->import().

checkcfgvar new config vars

cperl Porting/checkcfgvar.pl d_libffi i_ffi useffi  --default=undef --regen
note that vms has a libffi port:
  http://de.openvms.org/OpenVMS-Ports/detail.php?id=141
which needs to be installed/probed for.

add nativeconv() attribute
need a config-time helper for valid ABI values

prepare :encoded() attribute
for Str args or CV rettypes. TODO: attach
the encoding layer to the sig or ret pass.

Unify perldiag warnings. Less memory, same content.

fix prep_cif without USE_FFI
throw a compile-warning libffi not available
via warnings "syntax".
Normally we should suppress such declaration warnings,
as only calling extern subs should be forbidden without libffi.

fix the arg and CvHASSIG handling.
TODO: run-time signature type checks, prep_ffi_ret.

implement prep_ffi_ret
with all new ffi types (see https://docs.perl6.org/language/nativecall)

improve prep_ffi_ret types
change default rettype from :long to :void, analog to perl6.
simplify the type handling, encoded missing for str.

implement prep_ffi_sig

attr parsing: add parser in_sub and lex_attr_state

in_sub is needed to allow attributes not only in my decls.
lex_attr_state is needed to save the subname LEXER state of either
XATTRBLOCK or XATTRTERM over subsignature parsing, which destroyes this state
but is needed afterwards in subattrlist.

fix PL_in_sub state, for pmruntime funcs. fixes t/re/pat.t
my $died=qr/(?{})/;$error=$died?($@||qq(Zombie)):qq(none);
the qr func setting in_sub, and :qq(none) consuming it falsely

silence conversion and nonnull optimizer warnings
one since gcc 6.0. clang not yet checked.

magic ffienc for the :encoded attribute WIP
for string arguments and return type, PAD sv attachments.

Maybe use it also for all string values (as in Perl6), added to Encode when
being used outside of Latin-1/UTF-8.  But then as index into an encoded
array of names.  Now as shared name, attached as new F ffienc magic.

TODO: and add an attributes->import catchall CvEXTERN setter,
for extern sub cases where the parser forgot to call it with
"native".

parse empty extern sub () as sig, not proto

'extern sub name ()' is not an empty prototype, it's an empty signature.
treat 'sub name () :native' also as is_extern (EXTERNSUB token), to
signify () as signature, not as prototype.

attributes::get returns native
not native(lib) or the CvXFFI. Not symbol(name), encoded(name), nativeconv() yet

add warnings ffi
for the compile-time no ffi without DynaLoader warning.
Add the associated run-time error: Null extern sub symbol.

ffi: fix :symbol for slabbed CvFFILIB

also ignore find_symbol dlsym errors.
fix some PADLIST assertions.

attr_runtime: defer SAVEFREEOP(attr)
from new{ATTR,MY}SUB to attrs_runtime.
enhance dup_attrlist for variables to protect from SAVEFREEOP(attrs).

use GVSV, not just GV for the attribute argument. But keep using
REGFGEN, not SREFGEN, because peep and fold_constants rely on the bad
SREFGEN-null-kid format, and cannot deal with SREFGEN-kid.

Closes #291

harmonize diagnostic messages
ffi warnings and errors

fix sub EXISTING_SYM () :native :symbol(OTHERSYM)

use flat lists as attrs argument to attributes->import, not
nested. this was ignore in dup_attrslist().
add a testcase to test for the 2nd :symbol(OTHER) to resolve, not
skip.
Change the :symbol is already resolved warning to redefine, and only
if it's superfluous, resolving to the same symbol.

fix the attrs double-frees
  but still some minor attrs leaks, compile-time only.
  no ffi leaks at run-time though.
fix extern sub :attr
fix the externsub attribute case with import call for native,
fix lexer for several attributes: cv specific,
fix one minor SV leak in attributes::get
allow NULL rvalue in prep_ffi_ret.

windows and travis configs

harmonize prep_ffi_ret decls.

windows passes with the I_DLFCN fix appveypr smokes without libffi.
Need to enable it yet, copying the dlls from somewhere. Best with a
win32/ helper.

improve the tests skips

fix RTLD_DEFAULT logic

on windows it will fail, dl_load_file already did the searches.
on BSDs it is -2, everywhere else 0.
include dlfcn.h

I_DLFCN: not available under MSVC

util.c included this, but skipped on windows
which has no USE_C_BACKTRACE.

The win32 config files were wrong.

handle more type errors
invalid attribute arguments

prepare for more native const ops
not just one

c++ -fpermissive compat

use memcpy() which does a better copy of the wanted size,
and is optimized to the same code as a simple cast.
esp. we don't use a union, when we can use a single and more precise line.

we cannot use void* with C++, use char* instead.

improve the tests to use int, not long.

fix GVSV threaded

On threads a GVSV for the native($n) argument is invalid,
we need to use SVREF(GVOP) which is a PADOP.
This failed in op destruction on the invalid padix.

There is a problem with the padix from the upper scope.
Use the previous padix when copying it to the attributes->import
call.

reindent newGVOP and other overlong calls
no functional changes.

enum parser->lex_attr_state

rurban added a commit that referenced this issue Sep 17, 2018

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

parse attributes :native :symbol
set CvFFILIB via dl_load_file and CvXSUB symbol via dl_find_symbol.
TODO: set from SV values, not just constants.

use sv_chop in toke to advance PL_lex_stuff
use the OOK hack to do SvPVX(PL_lex_stuff)++
otherwise it will fail in sv_free. avoid copies.

add enterffi op to compiler

add and fix core extern tests WIP
not deparsed yet.

Resolve core attribute arguments, runtime setters

Some builtin attributes need to resolve symbolnames :native($libname)
at run-time, not only constants at parse-time, as via apply_attrs(),
which does the import in a BEGIN{} block.

Closes #291
As described in http://perl11.org/blog/attributes-args.html

perldiag: document standalone :symbol warning

add native and symbol() helpers

and fix start_subparse to start the attribute->import call.

skip miniperl, set ENTERFFI type
handle GvCV, SvRV and direct CV in ENTERFFI.
no overloaded object and no LV.

Set the right type already in the ck_subr to have less
op misses in entersub, also for xsub calls.
Note that a compile-time ffi call will not fall back to
a user-sub if redefined. Only done for XS to Perl or Perl to XS/FFI.

Simplify a few builtins.

Change attribute args: "native(" is followed by the arg.

start with the C part: ffi_call
remove unneeded leaveffi, prepare cfi usage.

document the ffi

fix extern sub parsing

and also lexical 'my extern sub name();'.
extern needs to trigger compile-time attributes->import().

checkcfgvar new config vars

cperl Porting/checkcfgvar.pl d_libffi i_ffi useffi  --default=undef --regen
note that vms has a libffi port:
  http://de.openvms.org/OpenVMS-Ports/detail.php?id=141
which needs to be installed/probed for.

add nativeconv() attribute
need a config-time helper for valid ABI values

prepare :encoded() attribute
for Str args or CV rettypes. TODO: attach
the encoding layer to the sig or ret pass.

Unify perldiag warnings. Less memory, same content.

fix prep_cif without USE_FFI
throw a compile-warning libffi not available
via warnings "syntax".
Normally we should suppress such declaration warnings,
as only calling extern subs should be forbidden without libffi.

fix the arg and CvHASSIG handling.
TODO: run-time signature type checks, prep_ffi_ret.

implement prep_ffi_ret
with all new ffi types (see https://docs.perl6.org/language/nativecall)

improve prep_ffi_ret types
change default rettype from :long to :void, analog to perl6.
simplify the type handling, encoded missing for str.

implement prep_ffi_sig

attr parsing: add parser in_sub and lex_attr_state

in_sub is needed to allow attributes not only in my decls.
lex_attr_state is needed to save the subname LEXER state of either
XATTRBLOCK or XATTRTERM over subsignature parsing, which destroyes this state
but is needed afterwards in subattrlist.

fix PL_in_sub state, for pmruntime funcs. fixes t/re/pat.t
my $died=qr/(?{})/;$error=$died?($@||qq(Zombie)):qq(none);
the qr func setting in_sub, and :qq(none) consuming it falsely

silence conversion and nonnull optimizer warnings
one since gcc 6.0. clang not yet checked.

magic ffienc for the :encoded attribute WIP
for string arguments and return type, PAD sv attachments.

Maybe use it also for all string values (as in Perl6), added to Encode when
being used outside of Latin-1/UTF-8.  But then as index into an encoded
array of names.  Now as shared name, attached as new F ffienc magic.

TODO: and add an attributes->import catchall CvEXTERN setter,
for extern sub cases where the parser forgot to call it with
"native".

parse empty extern sub () as sig, not proto

'extern sub name ()' is not an empty prototype, it's an empty signature.
treat 'sub name () :native' also as is_extern (EXTERNSUB token), to
signify () as signature, not as prototype.

attributes::get returns native
not native(lib) or the CvXFFI. Not symbol(name), encoded(name), nativeconv() yet

add warnings ffi
for the compile-time no ffi without DynaLoader warning.
Add the associated run-time error: Null extern sub symbol.

ffi: fix :symbol for slabbed CvFFILIB

also ignore find_symbol dlsym errors.
fix some PADLIST assertions.

attr_runtime: defer SAVEFREEOP(attr)
from new{ATTR,MY}SUB to attrs_runtime.
enhance dup_attrlist for variables to protect from SAVEFREEOP(attrs).

use GVSV, not just GV for the attribute argument. But keep using
REGFGEN, not SREFGEN, because peep and fold_constants rely on the bad
SREFGEN-null-kid format, and cannot deal with SREFGEN-kid.

Closes #291

harmonize diagnostic messages
ffi warnings and errors

fix sub EXISTING_SYM () :native :symbol(OTHERSYM)

use flat lists as attrs argument to attributes->import, not
nested. this was ignore in dup_attrslist().
add a testcase to test for the 2nd :symbol(OTHER) to resolve, not
skip.
Change the :symbol is already resolved warning to redefine, and only
if it's superfluous, resolving to the same symbol.

fix the attrs double-frees
  but still some minor attrs leaks, compile-time only.
  no ffi leaks at run-time though.
fix extern sub :attr
fix the externsub attribute case with import call for native,
fix lexer for several attributes: cv specific,
fix one minor SV leak in attributes::get
allow NULL rvalue in prep_ffi_ret.

windows and travis configs

harmonize prep_ffi_ret decls.

windows passes with the I_DLFCN fix appveypr smokes without libffi.
Need to enable it yet, copying the dlls from somewhere. Best with a
win32/ helper.

improve the tests skips

fix RTLD_DEFAULT logic

on windows it will fail, dl_load_file already did the searches.
on BSDs it is -2, everywhere else 0.
include dlfcn.h

I_DLFCN: not available under MSVC

util.c included this, but skipped on windows
which has no USE_C_BACKTRACE.

The win32 config files were wrong.

handle more type errors
invalid attribute arguments

prepare for more native const ops
not just one

c++ -fpermissive compat

use memcpy() which does a better copy of the wanted size,
and is optimized to the same code as a simple cast.
esp. we don't use a union, when we can use a single and more precise line.

we cannot use void* with C++, use char* instead.

improve the tests to use int, not long.

fix GVSV threaded

On threads a GVSV for the native($n) argument is invalid,
we need to use SVREF(GVOP) which is a PADOP.
This failed in op destruction on the invalid padix.

There is a problem with the padix from the upper scope.
Use the previous padix when copying it to the attributes->import
call.

reindent newGVOP and other overlong calls
no functional changes.

enum parser->lex_attr_state

rurban added a commit that referenced this issue Sep 17, 2018

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

parse attributes :native :symbol
set CvFFILIB via dl_load_file and CvXSUB symbol via dl_find_symbol.
TODO: set from SV values, not just constants.

use sv_chop in toke to advance PL_lex_stuff
use the OOK hack to do SvPVX(PL_lex_stuff)++
otherwise it will fail in sv_free. avoid copies.

add enterffi op to compiler

add and fix core extern tests WIP
not deparsed yet.

Resolve core attribute arguments, runtime setters

Some builtin attributes need to resolve symbolnames :native($libname)
at run-time, not only constants at parse-time, as via apply_attrs(),
which does the import in a BEGIN{} block.

Closes #291
As described in http://perl11.org/blog/attributes-args.html

perldiag: document standalone :symbol warning

add native and symbol() helpers

and fix start_subparse to start the attribute->import call.

skip miniperl, set ENTERFFI type
handle GvCV, SvRV and direct CV in ENTERFFI.
no overloaded object and no LV.

Set the right type already in the ck_subr to have less
op misses in entersub, also for xsub calls.
Note that a compile-time ffi call will not fall back to
a user-sub if redefined. Only done for XS to Perl or Perl to XS/FFI.

Simplify a few builtins.

Change attribute args: "native(" is followed by the arg.

start with the C part: ffi_call
remove unneeded leaveffi, prepare cfi usage.

document the ffi

fix extern sub parsing

and also lexical 'my extern sub name();'.
extern needs to trigger compile-time attributes->import().

checkcfgvar new config vars

cperl Porting/checkcfgvar.pl d_libffi i_ffi useffi  --default=undef --regen
note that vms has a libffi port:
  http://de.openvms.org/OpenVMS-Ports/detail.php?id=141
which needs to be installed/probed for.

add nativeconv() attribute
need a config-time helper for valid ABI values

prepare :encoded() attribute
for Str args or CV rettypes. TODO: attach
the encoding layer to the sig or ret pass.

Unify perldiag warnings. Less memory, same content.

fix prep_cif without USE_FFI
throw a compile-warning libffi not available
via warnings "syntax".
Normally we should suppress such declaration warnings,
as only calling extern subs should be forbidden without libffi.

fix the arg and CvHASSIG handling.
TODO: run-time signature type checks, prep_ffi_ret.

implement prep_ffi_ret
with all new ffi types (see https://docs.perl6.org/language/nativecall)

improve prep_ffi_ret types
change default rettype from :long to :void, analog to perl6.
simplify the type handling, encoded missing for str.

implement prep_ffi_sig

attr parsing: add parser in_sub and lex_attr_state

in_sub is needed to allow attributes not only in my decls.
lex_attr_state is needed to save the subname LEXER state of either
XATTRBLOCK or XATTRTERM over subsignature parsing, which destroyes this state
but is needed afterwards in subattrlist.

fix PL_in_sub state, for pmruntime funcs. fixes t/re/pat.t
my $died=qr/(?{})/;$error=$died?($@||qq(Zombie)):qq(none);
the qr func setting in_sub, and :qq(none) consuming it falsely

silence conversion and nonnull optimizer warnings
one since gcc 6.0. clang not yet checked.

magic ffienc for the :encoded attribute WIP
for string arguments and return type, PAD sv attachments.

Maybe use it also for all string values (as in Perl6), added to Encode when
being used outside of Latin-1/UTF-8.  But then as index into an encoded
array of names.  Now as shared name, attached as new F ffienc magic.

TODO: and add an attributes->import catchall CvEXTERN setter,
for extern sub cases where the parser forgot to call it with
"native".

parse empty extern sub () as sig, not proto

'extern sub name ()' is not an empty prototype, it's an empty signature.
treat 'sub name () :native' also as is_extern (EXTERNSUB token), to
signify () as signature, not as prototype.

attributes::get returns native
not native(lib) or the CvXFFI. Not symbol(name), encoded(name), nativeconv() yet

add warnings ffi
for the compile-time no ffi without DynaLoader warning.
Add the associated run-time error: Null extern sub symbol.

ffi: fix :symbol for slabbed CvFFILIB

also ignore find_symbol dlsym errors.
fix some PADLIST assertions.

attr_runtime: defer SAVEFREEOP(attr)
from new{ATTR,MY}SUB to attrs_runtime.
enhance dup_attrlist for variables to protect from SAVEFREEOP(attrs).

use GVSV, not just GV for the attribute argument. But keep using
REGFGEN, not SREFGEN, because peep and fold_constants rely on the bad
SREFGEN-null-kid format, and cannot deal with SREFGEN-kid.

Closes #291

harmonize diagnostic messages
ffi warnings and errors

fix sub EXISTING_SYM () :native :symbol(OTHERSYM)

use flat lists as attrs argument to attributes->import, not
nested. this was ignore in dup_attrslist().
add a testcase to test for the 2nd :symbol(OTHER) to resolve, not
skip.
Change the :symbol is already resolved warning to redefine, and only
if it's superfluous, resolving to the same symbol.

fix the attrs double-frees
  but still some minor attrs leaks, compile-time only.
  no ffi leaks at run-time though.
fix extern sub :attr
fix the externsub attribute case with import call for native,
fix lexer for several attributes: cv specific,
fix one minor SV leak in attributes::get
allow NULL rvalue in prep_ffi_ret.

windows and travis configs

harmonize prep_ffi_ret decls.

windows passes with the I_DLFCN fix appveypr smokes without libffi.
Need to enable it yet, copying the dlls from somewhere. Best with a
win32/ helper.

improve the tests skips

fix RTLD_DEFAULT logic

on windows it will fail, dl_load_file already did the searches.
on BSDs it is -2, everywhere else 0.
include dlfcn.h

I_DLFCN: not available under MSVC

util.c included this, but skipped on windows
which has no USE_C_BACKTRACE.

The win32 config files were wrong.

handle more type errors
invalid attribute arguments

prepare for more native const ops
not just one

c++ -fpermissive compat

use memcpy() which does a better copy of the wanted size,
and is optimized to the same code as a simple cast.
esp. we don't use a union, when we can use a single and more precise line.

we cannot use void* with C++, use char* instead.

improve the tests to use int, not long.

fix GVSV threaded

On threads a GVSV for the native($n) argument is invalid,
we need to use SVREF(GVOP) which is a PADOP.
This failed in op destruction on the invalid padix.

There is a problem with the padix from the upper scope.
Use the previous padix when copying it to the attributes->import
call.

reindent newGVOP and other overlong calls
no functional changes.

enum parser->lex_attr_state

rurban added a commit that referenced this issue Sep 18, 2018

ffi: probe in Configure
i_ffi, d_libffi, useffi. See #22

findffi: search all the libffi versions, expand
to absolute path as -I../ doesnt work.

vms: add libffi probes (untested)

Probe for the OpenVMS libffi port, also needed for python ctypes.
A 3.0.9 port exists for HP-UX/ia64, VMS/Alpha and VMS/ia64, but not
sure about its status, esp. OpenVMS. VAX should work.

find cygwin libXXX.dll.a libs
esp. for -lffi, which has no static lib.

rurban added a commit that referenced this issue Sep 18, 2018

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

parse attributes :native :symbol
set CvFFILIB via dl_load_file and CvXSUB symbol via dl_find_symbol.
TODO: set from SV values, not just constants.

use sv_chop in toke to advance PL_lex_stuff
use the OOK hack to do SvPVX(PL_lex_stuff)++
otherwise it will fail in sv_free. avoid copies.

add enterffi op to compiler

add and fix core extern tests WIP
not deparsed yet.

Resolve core attribute arguments, runtime setters

Some builtin attributes need to resolve symbolnames :native($libname)
at run-time, not only constants at parse-time, as via apply_attrs(),
which does the import in a BEGIN{} block.

Closes #291
As described in http://perl11.org/blog/attributes-args.html

perldiag: document standalone :symbol warning

add native and symbol() helpers

and fix start_subparse to start the attribute->import call.

skip miniperl, set ENTERFFI type
handle GvCV, SvRV and direct CV in ENTERFFI.
no overloaded object and no LV.

Set the right type already in the ck_subr to have less
op misses in entersub, also for xsub calls.
Note that a compile-time ffi call will not fall back to
a user-sub if redefined. Only done for XS to Perl or Perl to XS/FFI.

Simplify a few builtins.

Change attribute args: "native(" is followed by the arg.

start with the C part: ffi_call
remove unneeded leaveffi, prepare cfi usage.

document the ffi

fix extern sub parsing

and also lexical 'my extern sub name();'.
extern needs to trigger compile-time attributes->import().

checkcfgvar new config vars

cperl Porting/checkcfgvar.pl d_libffi i_ffi useffi  --default=undef --regen
note that vms has a libffi port:
  http://de.openvms.org/OpenVMS-Ports/detail.php?id=141
which needs to be installed/probed for.

add nativeconv() attribute
need a config-time helper for valid ABI values

prepare :encoded() attribute
for Str args or CV rettypes. TODO: attach
the encoding layer to the sig or ret pass.

Unify perldiag warnings. Less memory, same content.

fix prep_cif without USE_FFI
throw a compile-warning libffi not available
via warnings "syntax".
Normally we should suppress such declaration warnings,
as only calling extern subs should be forbidden without libffi.

fix the arg and CvHASSIG handling.
TODO: run-time signature type checks, prep_ffi_ret.

implement prep_ffi_ret
with all new ffi types (see https://docs.perl6.org/language/nativecall)

improve prep_ffi_ret types
change default rettype from :long to :void, analog to perl6.
simplify the type handling, encoded missing for str.

implement prep_ffi_sig

attr parsing: add parser in_sub and lex_attr_state

in_sub is needed to allow attributes not only in my decls.
lex_attr_state is needed to save the subname LEXER state of either
XATTRBLOCK or XATTRTERM over subsignature parsing, which destroyes this state
but is needed afterwards in subattrlist.

fix PL_in_sub state, for pmruntime funcs. fixes t/re/pat.t
my $died=qr/(?{})/;$error=$died?($@||qq(Zombie)):qq(none);
the qr func setting in_sub, and :qq(none) consuming it falsely

silence conversion and nonnull optimizer warnings
one since gcc 6.0. clang not yet checked.

magic ffienc for the :encoded attribute WIP
for string arguments and return type, PAD sv attachments.

Maybe use it also for all string values (as in Perl6), added to Encode when
being used outside of Latin-1/UTF-8.  But then as index into an encoded
array of names.  Now as shared name, attached as new F ffienc magic.

TODO: and add an attributes->import catchall CvEXTERN setter,
for extern sub cases where the parser forgot to call it with
"native".

parse empty extern sub () as sig, not proto

'extern sub name ()' is not an empty prototype, it's an empty signature.
treat 'sub name () :native' also as is_extern (EXTERNSUB token), to
signify () as signature, not as prototype.

attributes::get returns native
not native(lib) or the CvXFFI. Not symbol(name), encoded(name), nativeconv() yet

add warnings ffi
for the compile-time no ffi without DynaLoader warning.
Add the associated run-time error: Null extern sub symbol.

ffi: fix :symbol for slabbed CvFFILIB

also ignore find_symbol dlsym errors.
fix some PADLIST assertions.

attr_runtime: defer SAVEFREEOP(attr)
from new{ATTR,MY}SUB to attrs_runtime.
enhance dup_attrlist for variables to protect from SAVEFREEOP(attrs).

use GVSV, not just GV for the attribute argument. But keep using
REGFGEN, not SREFGEN, because peep and fold_constants rely on the bad
SREFGEN-null-kid format, and cannot deal with SREFGEN-kid.

Closes #291

harmonize diagnostic messages
ffi warnings and errors

fix sub EXISTING_SYM () :native :symbol(OTHERSYM)

use flat lists as attrs argument to attributes->import, not
nested. this was ignore in dup_attrslist().
add a testcase to test for the 2nd :symbol(OTHER) to resolve, not
skip.
Change the :symbol is already resolved warning to redefine, and only
if it's superfluous, resolving to the same symbol.

fix the attrs double-frees
  but still some minor attrs leaks, compile-time only.
  no ffi leaks at run-time though.
fix extern sub :attr
fix the externsub attribute case with import call for native,
fix lexer for several attributes: cv specific,
fix one minor SV leak in attributes::get
allow NULL rvalue in prep_ffi_ret.

windows and travis configs

harmonize prep_ffi_ret decls.

windows passes with the I_DLFCN fix appveypr smokes without libffi.
Need to enable it yet, copying the dlls from somewhere. Best with a
win32/ helper.

improve the tests skips

fix RTLD_DEFAULT logic

on windows it will fail, dl_load_file already did the searches.
on BSDs it is -2, everywhere else 0.
include dlfcn.h

I_DLFCN: not available under MSVC

util.c included this, but skipped on windows
which has no USE_C_BACKTRACE.

The win32 config files were wrong.

handle more type errors
invalid attribute arguments

prepare for more native const ops
not just one

c++ -fpermissive compat

use memcpy() which does a better copy of the wanted size,
and is optimized to the same code as a simple cast.
esp. we don't use a union, when we can use a single and more precise line.

we cannot use void* with C++, use char* instead.

improve the tests to use int, not long.

fix GVSV threaded

On threads a GVSV for the native($n) argument is invalid,
we need to use SVREF(GVOP) which is a PADOP.
This failed in op destruction on the invalid padix.

There is a problem with the padix from the upper scope.
Use the previous padix when copying it to the attributes->import
call.

reindent newGVOP and other overlong calls
no functional changes.

enum parser->lex_attr_state

rurban added a commit that referenced this issue Sep 18, 2018

ffi: probe in Configure
i_ffi, d_libffi, useffi. See #22

findffi: search all the libffi versions, expand
to absolute path as -I../ doesnt work.

vms: add libffi probes (untested)

Probe for the OpenVMS libffi port, also needed for python ctypes.
A 3.0.9 port exists for HP-UX/ia64, VMS/Alpha and VMS/ia64, but not
sure about its status, esp. OpenVMS. VAX should work.

find cygwin libXXX.dll.a libs
esp. for -lffi, which has no static lib.

rurban added a commit that referenced this issue Sep 18, 2018

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

parse attributes :native :symbol
set CvFFILIB via dl_load_file and CvXSUB symbol via dl_find_symbol.
TODO: set from SV values, not just constants.

use sv_chop in toke to advance PL_lex_stuff
use the OOK hack to do SvPVX(PL_lex_stuff)++
otherwise it will fail in sv_free. avoid copies.

add enterffi op to compiler

add and fix core extern tests WIP
not deparsed yet.

Resolve core attribute arguments, runtime setters

Some builtin attributes need to resolve symbolnames :native($libname)
at run-time, not only constants at parse-time, as via apply_attrs(),
which does the import in a BEGIN{} block.

Closes #291
As described in http://perl11.org/blog/attributes-args.html

perldiag: document standalone :symbol warning

add native and symbol() helpers

and fix start_subparse to start the attribute->import call.

skip miniperl, set ENTERFFI type
handle GvCV, SvRV and direct CV in ENTERFFI.
no overloaded object and no LV.

Set the right type already in the ck_subr to have less
op misses in entersub, also for xsub calls.
Note that a compile-time ffi call will not fall back to
a user-sub if redefined. Only done for XS to Perl or Perl to XS/FFI.

Simplify a few builtins.

Change attribute args: "native(" is followed by the arg.

start with the C part: ffi_call
remove unneeded leaveffi, prepare cfi usage.

document the ffi

fix extern sub parsing

and also lexical 'my extern sub name();'.
extern needs to trigger compile-time attributes->import().

checkcfgvar new config vars

cperl Porting/checkcfgvar.pl d_libffi i_ffi useffi  --default=undef --regen
note that vms has a libffi port:
  http://de.openvms.org/OpenVMS-Ports/detail.php?id=141
which needs to be installed/probed for.

add nativeconv() attribute
need a config-time helper for valid ABI values

prepare :encoded() attribute
for Str args or CV rettypes. TODO: attach
the encoding layer to the sig or ret pass.

Unify perldiag warnings. Less memory, same content.

fix prep_cif without USE_FFI
throw a compile-warning libffi not available
via warnings "syntax".
Normally we should suppress such declaration warnings,
as only calling extern subs should be forbidden without libffi.

fix the arg and CvHASSIG handling.
TODO: run-time signature type checks, prep_ffi_ret.

implement prep_ffi_ret
with all new ffi types (see https://docs.perl6.org/language/nativecall)

improve prep_ffi_ret types
change default rettype from :long to :void, analog to perl6.
simplify the type handling, encoded missing for str.

implement prep_ffi_sig

attr parsing: add parser in_sub and lex_attr_state

in_sub is needed to allow attributes not only in my decls.
lex_attr_state is needed to save the subname LEXER state of either
XATTRBLOCK or XATTRTERM over subsignature parsing, which destroyes this state
but is needed afterwards in subattrlist.

fix PL_in_sub state, for pmruntime funcs. fixes t/re/pat.t
my $died=qr/(?{})/;$error=$died?($@||qq(Zombie)):qq(none);
the qr func setting in_sub, and :qq(none) consuming it falsely

silence conversion and nonnull optimizer warnings
one since gcc 6.0. clang not yet checked.

magic ffienc for the :encoded attribute WIP
for string arguments and return type, PAD sv attachments.

Maybe use it also for all string values (as in Perl6), added to Encode when
being used outside of Latin-1/UTF-8.  But then as index into an encoded
array of names.  Now as shared name, attached as new F ffienc magic.

TODO: and add an attributes->import catchall CvEXTERN setter,
for extern sub cases where the parser forgot to call it with
"native".

parse empty extern sub () as sig, not proto

'extern sub name ()' is not an empty prototype, it's an empty signature.
treat 'sub name () :native' also as is_extern (EXTERNSUB token), to
signify () as signature, not as prototype.

attributes::get returns native
not native(lib) or the CvXFFI. Not symbol(name), encoded(name), nativeconv() yet

add warnings ffi
for the compile-time no ffi without DynaLoader warning.
Add the associated run-time error: Null extern sub symbol.

ffi: fix :symbol for slabbed CvFFILIB

also ignore find_symbol dlsym errors.
fix some PADLIST assertions.

attr_runtime: defer SAVEFREEOP(attr)
from new{ATTR,MY}SUB to attrs_runtime.
enhance dup_attrlist for variables to protect from SAVEFREEOP(attrs).

use GVSV, not just GV for the attribute argument. But keep using
REGFGEN, not SREFGEN, because peep and fold_constants rely on the bad
SREFGEN-null-kid format, and cannot deal with SREFGEN-kid.

Closes #291

harmonize diagnostic messages
ffi warnings and errors

fix sub EXISTING_SYM () :native :symbol(OTHERSYM)

use flat lists as attrs argument to attributes->import, not
nested. this was ignore in dup_attrslist().
add a testcase to test for the 2nd :symbol(OTHER) to resolve, not
skip.
Change the :symbol is already resolved warning to redefine, and only
if it's superfluous, resolving to the same symbol.

fix the attrs double-frees
  but still some minor attrs leaks, compile-time only.
  no ffi leaks at run-time though.
fix extern sub :attr
fix the externsub attribute case with import call for native,
fix lexer for several attributes: cv specific,
fix one minor SV leak in attributes::get
allow NULL rvalue in prep_ffi_ret.

windows and travis configs

harmonize prep_ffi_ret decls.

windows passes with the I_DLFCN fix appveypr smokes without libffi.
Need to enable it yet, copying the dlls from somewhere. Best with a
win32/ helper.

improve the tests skips

fix RTLD_DEFAULT logic

on windows it will fail, dl_load_file already did the searches.
on BSDs it is -2, everywhere else 0.
include dlfcn.h

I_DLFCN: not available under MSVC

util.c included this, but skipped on windows
which has no USE_C_BACKTRACE.

The win32 config files were wrong.

handle more type errors
invalid attribute arguments

prepare for more native const ops
not just one

c++ -fpermissive compat

use memcpy() which does a better copy of the wanted size,
and is optimized to the same code as a simple cast.
esp. we don't use a union, when we can use a single and more precise line.

we cannot use void* with C++, use char* instead.

improve the tests to use int, not long.

fix GVSV threaded

On threads a GVSV for the native($n) argument is invalid,
we need to use SVREF(GVOP) which is a PADOP.
This failed in op destruction on the invalid padix.

There is a problem with the padix from the upper scope.
Use the previous padix when copying it to the attributes->import
call.

reindent newGVOP and other overlong calls
no functional changes.

enum parser->lex_attr_state

rurban added a commit that referenced this issue Sep 18, 2018

ffi: probe in Configure
i_ffi, d_libffi, useffi. See #22

findffi: search all the libffi versions, expand
to absolute path as -I../ doesnt work.

vms: add libffi probes (untested)

Probe for the OpenVMS libffi port, also needed for python ctypes.
A 3.0.9 port exists for HP-UX/ia64, VMS/Alpha and VMS/ia64, but not
sure about its status, esp. OpenVMS. VAX should work.

find cygwin libXXX.dll.a libs
esp. for -lffi, which has no static lib.

rurban added a commit that referenced this issue Sep 18, 2018

ffi: parse extern sub NAME SIG ATTRIB?;
optionally also as
  sub NAME SIG :native();

mark it as CvEXTERN.
mandatory SIG, optional return type: default int.
See #22

parse attributes :native :symbol
set CvFFILIB via dl_load_file and CvXSUB symbol via dl_find_symbol.
TODO: set from SV values, not just constants.

use sv_chop in toke to advance PL_lex_stuff
use the OOK hack to do SvPVX(PL_lex_stuff)++
otherwise it will fail in sv_free. avoid copies.

add enterffi op to compiler

add and fix core extern tests WIP
not deparsed yet.

Resolve core attribute arguments, runtime setters

Some builtin attributes need to resolve symbolnames :native($libname)
at run-time, not only constants at parse-time, as via apply_attrs(),
which does the import in a BEGIN{} block.

Closes #291
As described in http://perl11.org/blog/attributes-args.html

perldiag: document standalone :symbol warning

add native and symbol() helpers

and fix start_subparse to start the attribute->import call.

skip miniperl, set ENTERFFI type
handle GvCV, SvRV and direct CV in ENTERFFI.
no overloaded object and no LV.

Set the right type already in the ck_subr to have less
op misses in entersub, also for xsub calls.
Note that a compile-time ffi call will not fall back to
a user-sub if redefined. Only done for XS to Perl or Perl to XS/FFI.

Simplify a few builtins.

Change attribute args: "native(" is followed by the arg.

start with the C part: ffi_call
remove unneeded leaveffi, prepare cfi usage.

document the ffi

fix extern sub parsing

and also lexical 'my extern sub name();'.
extern needs to trigger compile-time attributes->import().

checkcfgvar new config vars

cperl Porting/checkcfgvar.pl d_libffi i_ffi useffi  --default=undef --regen
note that vms has a libffi port:
  http://de.openvms.org/OpenVMS-Ports/detail.php?id=141
which needs to be installed/probed for.

add nativeconv() attribute
need a config-time helper for valid ABI values

prepare :encoded() attribute
for Str args or CV rettypes. TODO: attach
the encoding layer to the sig or ret pass.

Unify perldiag warnings. Less memory, same content.

fix prep_cif without USE_FFI
throw a compile-warning libffi not available
via warnings "syntax".
Normally we should suppress such declaration warnings,
as only calling extern subs should be forbidden without libffi.

fix the arg and CvHASSIG handling.
TODO: run-time signature type checks, prep_ffi_ret.

implement prep_ffi_ret
with all new ffi types (see https://docs.perl6.org/language/nativecall)

improve prep_ffi_ret types
change default rettype from :long to :void, analog to perl6.
simplify the type handling, encoded missing for str.

implement prep_ffi_sig

attr parsing: add parser in_sub and lex_attr_state

in_sub is needed to allow attributes not only in my decls.
lex_attr_state is needed to save the subname LEXER state of either
XATTRBLOCK or XATTRTERM over subsignature parsing, which destroyes this state
but is needed afterwards in subattrlist.

fix PL_in_sub state, for pmruntime funcs. fixes t/re/pat.t
my $died=qr/(?{})/;$error=$died?($@||qq(Zombie)):qq(none);
the qr func setting in_sub, and :qq(none) consuming it falsely

silence conversion and nonnull optimizer warnings
one since gcc 6.0. clang not yet checked.

magic ffienc for the :encoded attribute WIP
for string arguments and return type, PAD sv attachments.

Maybe use it also for all string values (as in Perl6), added to Encode when
being used outside of Latin-1/UTF-8.  But then as index into an encoded
array of names.  Now as shared name, attached as new F ffienc magic.

TODO: and add an attributes->import catchall CvEXTERN setter,
for extern sub cases where the parser forgot to call it with
"native".

parse empty extern sub () as sig, not proto

'extern sub name ()' is not an empty prototype, it's an empty signature.
treat 'sub name () :native' also as is_extern (EXTERNSUB token), to
signify () as signature, not as prototype.

attributes::get returns native
not native(lib) or the CvXFFI. Not symbol(name), encoded(name), nativeconv() yet

add warnings ffi
for the compile-time no ffi without DynaLoader warning.
Add the associated run-time error: Null extern sub symbol.

ffi: fix :symbol for slabbed CvFFILIB

also ignore find_symbol dlsym errors.
fix some PADLIST assertions.

attr_runtime: defer SAVEFREEOP(attr)
from new{ATTR,MY}SUB to attrs_runtime.
enhance dup_attrlist for variables to protect from SAVEFREEOP(attrs).

use GVSV, not just GV for the attribute argument. But keep using
REGFGEN, not SREFGEN, because peep and fold_constants rely on the bad
SREFGEN-null-kid format, and cannot deal with SREFGEN-kid.

Closes #291

harmonize diagnostic messages
ffi warnings and errors

fix sub EXISTING_SYM () :native :symbol(OTHERSYM)

use flat lists as attrs argument to attributes->import, not
nested. this was ignore in dup_attrslist().
add a testcase to test for the 2nd :symbol(OTHER) to resolve, not
skip.
Change the :symbol is already resolved warning to redefine, and only
if it's superfluous, resolving to the same symbol.

fix the attrs double-frees
  but still some minor attrs leaks, compile-time only.
  no ffi leaks at run-time though.
fix extern sub :attr
fix the externsub attribute case with import call for native,
fix lexer for several attributes: cv specific,
fix one minor SV leak in attributes::get
allow NULL rvalue in prep_ffi_ret.

windows and travis configs

harmonize prep_ffi_ret decls.

windows passes with the I_DLFCN fix appveypr smokes without libffi.
Need to enable it yet, copying the dlls from somewhere. Best with a
win32/ helper.

improve the tests skips

fix RTLD_DEFAULT logic

on windows it will fail, dl_load_file already did the searches.
on BSDs it is -2, everywhere else 0.
include dlfcn.h

I_DLFCN: not available under MSVC

util.c included this, but skipped on windows
which has no USE_C_BACKTRACE.

The win32 config files were wrong.

handle more type errors
invalid attribute arguments

prepare for more native const ops
not just one

c++ -fpermissive compat

use memcpy() which does a better copy of the wanted size,
and is optimized to the same code as a simple cast.
esp. we don't use a union, when we can use a single and more precise line.

we cannot use void* with C++, use char* instead.

improve the tests to use int, not long.

fix GVSV threaded

On threads a GVSV for the native($n) argument is invalid,
we need to use SVREF(GVOP) which is a PADOP.
This failed in op destruction on the invalid padix.

There is a problem with the padix from the upper scope.
Use the previous padix when copying it to the attributes->import
call.

reindent newGVOP and other overlong calls
no functional changes.

enum parser->lex_attr_state
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment